map-core-func 0.1.4 → 0.1.7
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/dist/map-core-func.cjs.js +4 -19
- package/dist/map-core-func.esm.js +4 -19
- package/dist/map-core-func.min.js +14 -29
- package/package.json +1 -1
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
var t,e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={exports:{}};t=i,function(e){var i,n,r="fulfilled",o="undefined",s=function(){var t=[],i=0;function r(){for(;t.length-i;){try{t[i]()}catch(t){e.console&&e.console.error(t)}t[i++]=n,1024==i&&(t.splice(0,1024),i=0)}}var s=function(){if(typeof MutationObserver===o)return typeof process!==o&&"function"==typeof process.nextTick?function(){process.nextTick(r)}:typeof setImmediate!==o?function(){setImmediate(r)}:function(){setTimeout(r,0)};var t=document.createElement("div");return new MutationObserver(r).observe(t,{attributes:!0}),function(){t.setAttribute("a",0)}}();return function(e){t.push(e),t.length-i==1&&s()}}();function a(t){if(!(this instanceof a))throw new TypeError("Zousan must be created with the new keyword");if("function"==typeof t){var e=this;try{t((function(t){e.resolve(t)}),(function(t){e.reject(t)}))}catch(t){e.reject(t)}}else if(0<arguments.length)throw new TypeError("Zousan resolver "+t+" is not a function")}function h(t,e){if("function"==typeof t.y)try{var i=t.y.call(n,e);t.p.resolve(i)}catch(e){t.p.reject(e)}else t.p.resolve(e)}function l(t,e){if("function"==typeof t.n)try{var i=t.n.call(n,e);t.p.resolve(i)}catch(e){t.p.reject(e)}else t.p.reject(e)}a.prototype={resolve:function(t){if(this.state===i){if(t===this)return this.reject(new TypeError("Attempt to resolve promise with self"));var e=this;if(t&&("function"==typeof t||"object"==typeof t))try{var n=!0,o=t.then;if("function"==typeof o)return void o.call(t,(function(t){n&&(n=!1,e.resolve(t))}),(function(t){n&&(n=!1,e.reject(t))}))}catch(o){return void(n&&this.reject(o))}this.state=r,this.v=t,e.c&&s((function(){for(var i=0,n=e.c.length;i<n;i++)h(e.c[i],t)}))}},reject:function(t){if(this.state===i){var n=this;this.state="rejected",this.v=t;var r=this.c;s(r?function(){for(var e=0,i=r.length;e<i;e++)l(r[e],t)}:function(){n.handled||!a.suppressUncaughtRejectionError&&e.console&&a.warn("You upset Zousan. Please catch rejections: ",t,t?t.stack:null)})}},then:function(t,e){var n=new a,o={y:t,n:e,p:n};if(this.state===i)this.c?this.c.push(o):this.c=[o];else{var c=this.state,u=this.v;this.handled=!0,s((function(){c===r?h(o,u):l(o,u)}))}return n},catch:function(t){return this.then(null,t)},finally:function(t){return this.then(t,t)},timeout:function(t,e){e=e||"Timeout";var i=this;return new a((function(n,r){setTimeout((function(){r(Error(e))}),t),i.then((function(t){n(t)}),(function(t){r(t)}))}))}},a.resolve=function(t){var e=new a;return e.resolve(t),e},a.reject=function(t){var e=new a;return e.c=[],e.reject(t),e},a.all=function(t){var e=[],i=0,n=new a;function r(r,o){r&&"function"==typeof r.then||(r=a.resolve(r)),r.then((function(r){e[o]=r,++i==t.length&&n.resolve(e)}),(function(t){n.reject(t)}))}for(var o=0;o<t.length;o++)r(t[o],o);return t.length||n.resolve(e),n},a.warn=console.warn,t.exports&&(t.exports=a),e.define&&e.define.amd&&e.define([],(function(){return a})),(e.Zousan=a).soon=s}(e);var n=i.exports,r={exports:{}},o={exports:{}};o.exports=function(){function t(t,i,r,o,s){e(t,i,r||0,o||t.length-1,s||n)}function e(t,n,r,o,s){for(;o>r;){if(o-r>600){var a=o-r+1,h=n-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(a-c)/a)*(h-a/2<0?-1:1);e(t,n,Math.max(r,Math.floor(n-h*c/a+u)),Math.min(o,Math.floor(n+(a-h)*c/a+u)),s)}var d=t[n],p=r,f=o;for(i(t,r,n),s(t[o],d)>0&&i(t,r,o);p<f;){for(i(t,p,f),p++,f--;s(t[p],d)<0;)p++;for(;s(t[f],d)>0;)f--}0===s(t[r],d)?i(t,r,f):i(t,++f,o),f<=n&&(r=f+1),n<=f&&(o=f-1)}}function i(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function n(t,e){return t<e?-1:t>e?1:0}return t}(),r.exports=a,r.exports.default=a;var s=o.exports;function a(t,e){if(!(this instanceof a))return new a(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function h(t,e,i){if(!i)return e.indexOf(t);for(var n=0;n<e.length;n++)if(i(t,e[n]))return n;return-1}function l(t,e){c(t,0,t.children.length,e,t)}function c(t,e,i,n,r){r||(r=y(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var o,s=e;s<i;s++)o=t.children[s],u(r,t.leaf?n(o):o);return r}function u(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function d(t,e){return t.minX-e.minX}function p(t,e){return t.minY-e.minY}function f(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function m(t){return t.maxX-t.minX+(t.maxY-t.minY)}function g(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function v(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function y(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function _(t,e,i,n,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=n||(o=e+Math.ceil((i-e)/n/2)*n,s(t,o,e,i,r),a.push(e,o,o,i))}a.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!v(t,e))return i;for(var r,o,s,a,h=[];e;){for(r=0,o=e.children.length;r<o;r++)s=e.children[r],v(t,a=e.leaf?n(s):s)&&(e.leaf?i.push(s):g(t,a)?this._all(s,i):h.push(s));e=h.pop()}return i},collides:function(t){var e=this.data,i=this.toBBox;if(!v(t,e))return!1;for(var n,r,o,s,a=[];e;){for(n=0,r=e.children.length;n<r;n++)if(o=e.children[n],v(t,s=e.leaf?i(o):o)){if(e.leaf||g(t,s))return!0;a.push(o)}e=a.pop()}return!1},load:function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0,i=t.length;e<i;e++)this.insert(t[e]);return this}var n=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},insert:function(t){return t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=y([]),this},remove:function(t,e){if(!t)return this;for(var i,n,r,o,s=this.data,a=this.toBBox(t),l=[],c=[];s||l.length;){if(s||(s=l.pop(),n=l[l.length-1],i=c.pop(),o=!0),s.leaf&&-1!==(r=h(t,s.children,e)))return s.children.splice(r,1),l.push(s),this._condense(l),this;o||s.leaf||!g(s,a)?n?(i++,s=n.children[i],o=!1):s=null:(l.push(s),c.push(i),i=0,n=s,s=s.children[0])}return this},toBBox:function(t){return t},compareMinX:d,compareMinY:p,toJSON:function(){return this.data},fromJSON:function(t){return this.data=t,this},_all:function(t,e){for(var i=[];t;)t.leaf?e.push.apply(e,t.children):i.push.apply(i,t.children),t=i.pop();return e},_build:function(t,e,i,n){var r,o=i-e+1,s=this._maxEntries;if(o<=s)return l(r=y(t.slice(e,i+1)),this.toBBox),r;n||(n=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,n-1))),(r=y([])).leaf=!1,r.height=n;var a,h,c,u,d=Math.ceil(o/s),p=d*Math.ceil(Math.sqrt(s));for(_(t,e,i,p,this.compareMinX),a=e;a<=i;a+=p)for(_(t,a,c=Math.min(a+p-1,i),d,this.compareMinY),h=a;h<=c;h+=d)u=Math.min(h+d-1,c),r.children.push(this._build(t,h,u,n-1));return l(r,this.toBBox),r},_chooseSubtree:function(t,e,i,n){for(var r,o,s,a,h,l,c,u,d,p;n.push(e),!e.leaf&&n.length-1!==i;){for(c=u=1/0,r=0,o=e.children.length;r<o;r++)h=f(s=e.children[r]),d=t,p=s,(l=(Math.max(p.maxX,d.maxX)-Math.min(p.minX,d.minX))*(Math.max(p.maxY,d.maxY)-Math.min(p.minY,d.minY))-h)<u?(u=l,c=h<c?h:c,a=s):l===u&&h<c&&(c=h,a=s);e=a||e.children[0]}return e},_insert:function(t,e,i){var n=this.toBBox,r=i?t:n(t),o=[],s=this._chooseSubtree(r,this.data,e,o);for(s.children.push(t),u(s,r);e>=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(r,o,e)},_split:function(t,e){var i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);var o=this._chooseSplitIndex(i,r,n),s=y(i.children.splice(o,i.children.length-o));s.height=i.height,s.leaf=i.leaf,l(i,this.toBBox),l(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(i,s)},_splitRoot:function(t,e){this.data=y([t,e]),this.data.height=t.height+1,this.data.leaf=!1,l(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,r,o,s,a,h,l,u,d,p,m,g,v,y;for(h=l=1/0,n=e;n<=i-e;n++)r=c(t,0,n,this.toBBox),o=c(t,n,i,this.toBBox),d=r,p=o,m=void 0,g=void 0,v=void 0,y=void 0,m=Math.max(d.minX,p.minX),g=Math.max(d.minY,p.minY),v=Math.min(d.maxX,p.maxX),y=Math.min(d.maxY,p.maxY),s=Math.max(0,v-m)*Math.max(0,y-g),a=f(r)+f(o),s<h?(h=s,u=n,l=a<l?a:l):s===h&&a<l&&(l=a,u=n);return u},_chooseSplitAxis:function(t,e,i){var n=t.leaf?this.compareMinX:d,r=t.leaf?this.compareMinY:p;this._allDistMargin(t,e,i,n)<this._allDistMargin(t,e,i,r)&&t.children.sort(n)},_allDistMargin:function(t,e,i,n){t.children.sort(n);var r,o,s=this.toBBox,a=c(t,0,e,s),h=c(t,i-e,i,s),l=m(a)+m(h);for(r=e;r<i-e;r++)o=t.children[r],u(a,t.leaf?s(o):o),l+=m(a);for(r=i-e-1;r>=e;r--)o=t.children[r],u(h,t.leaf?s(o):o),l+=m(h);return l},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)u(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():l(t[i],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}};var x=r.exports,w={exports:{}};!function(t){!function(){function e(t,e,i){var n=e.x,r=e.y,o=i.x-n,s=i.y-r;if(0!==o||0!==s){var a=((t.x-n)*o+(t.y-r)*s)/(o*o+s*s);a>1?(n=i.x,r=i.y):a>0&&(n+=o*a,r+=s*a)}return(o=t.x-n)*o+(s=t.y-r)*s}function i(t,n,r,o,s){for(var a,h=o,l=n+1;l<r;l++){var c=e(t[l],t[n],t[r]);c>h&&(a=l,h=c)}h>o&&(a-n>1&&i(t,n,a,o,s),s.push(t[a]),r-a>1&&i(t,a,r,o,s))}function n(t,e){var n=t.length-1,r=[t[0]];return i(t,0,n,e,r),r.push(t[n]),r}function r(t,e,i){if(t.length<=2)return t;var r=void 0!==e?e*e:1;return t=i?t:function(t,e){for(var i,n,r,o,s,a=t[0],h=[a],l=1,c=t.length;l<c;l++)i=t[l],r=a,o=void 0,s=void 0,o=(n=i).x-r.x,s=n.y-r.y,o*o+s*s>e&&(h.push(i),a=i);return a!==i&&h.push(i),h}(t,r),t=n(t,r)}t.exports=r,t.exports.default=r}()}(w);for(var b=w.exports,M=[],S=0
|
|
2
|
-
/*!
|
|
3
|
-
* Contains code from THREE.js
|
|
4
|
-
* MIT License
|
|
5
|
-
* https://github.com/mrdoob/three.js
|
|
6
|
-
*/;S<6;S++)M[S]=[];var T=[];function E(t,e,i){var n,r,o,s,a,h,l,c,u,d,p,f,m,g,v,y,_;r=(n=t)[0],o=n[1],s=n[2],a=n[3],h=n[4],l=n[5],c=n[6],u=n[7],d=n[8],p=n[9],f=n[10],m=n[11],g=n[12],v=n[13],y=n[14],_=n[15],P(M[0],a-r,u-h,m-d,_-g),P(M[1],a+r,u+h,m+d,_+g),P(M[2],a+o,u+l,m+p,_+v),P(M[3],a-o,u-l,m-p,_-v),P(M[4],a-s,u-c,m-f,_-y),P(M[5],a+s,u+c,m+f,_+y);for(var x=0;x<6;x++)if(!i||"0"!==i.charAt(x)){var w=M[x];if(T[0]=w[0]>0?e[1][0]:e[0][0],T[1]=w[1]>0?e[1][1]:e[0][1],T[2]=w[2]>0?e[1][2]:e[0][2],A(w,T)<0)return!1}return!0}var C=1/6;function P(t,e,i,n,r){return t[0]=e*C,t[1]=i*C,t[2]=n*C,t[3]=r*C,t}function A(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}
|
|
7
|
-
/*!
|
|
8
|
-
* maptalks v1.0.0-rc.18
|
|
9
|
-
* LICENSE : BSD-3-Clause
|
|
10
|
-
* (c) 2016-2023 maptalks.org
|
|
11
|
-
*/var L="_maptalks__internal_layer_",R=["MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"],O=["FeatureCollection","Feature","Point","LineString","Polygon"].concat(R),D=["markerFile","polygonPatternFile","linePatternFile","markerFillPatternFile","markerLinePatternFile"],I=[["markerWidth","markerHeight"],[],[null,"lineWidth"],[],[null,"markerLineWidth"]],k={lineWidth:1,lineOpacity:1,lineDx:1,lineDy:1,polygonOpacity:1,markerWidth:1,markerHeight:1,markerDx:1,markerDy:1,markerOpacity:1,markerFillOpacity:1,markerLineWidth:1,markerLineOpacity:1,textSize:1,textOpacity:1,textHaloRadius:1,textWrapWidth:1,textLineSpacing:1,textDx:1,textDy:1},z=["lineColor","polygonFill","markerFill","markerLineColor","textFill"],F=14;function B(){return Date.now()}function N(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)t[n]=i[n]}return t}function H(t){return null==t}function j(t){return"number"==typeof t&&!isNaN(t)}function G(t){return(0|t)===t}function U(t){return"object"==typeof t&&!!t}function V(t){return!H(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function W(t){return!H(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}var Z=Object.prototype.hasOwnProperty;function q(t,e){return Z.call(t,e)}var X=Math.PI/180;function Y(t){return t*X}function J(t){return t/X}var Q="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)&&!process.versions.electron&&!process.versions.nw&&!process.versions["node-webkit"],K={},$={};function tt(){return window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI}if(!Q){var et=navigator.userAgent.toLowerCase(),it=document.documentElement,nt="ActiveXObject"in window,rt=-1!==et.indexOf("webkit"),ot=-1!==et.indexOf("phantom"),st=-1!==et.search("android [23]"),at=-1!==et.indexOf("chrome"),ht=-1!==et.indexOf("gecko")&&!rt&&!window.opera&&!nt,lt=/iphone/i.test(et)&&/micromessenger/i.test(et),ct="undefined"!=typeof orientation||-1!==et.indexOf("mobile"),ut=!window.PointerEvent&&window.MSPointerEvent,dt=window.PointerEvent&&navigator.pointerEnabled||ut,pt=nt&&"transition"in it.style,ft="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!st,mt="MozPerspective"in it.style,gt="OTransition"in it.style,vt=(pt||ft||mt)&&!gt&&!ot,yt="undefined"!=typeof window&&W(window.createImageBitmap),_t="undefined"!=typeof window&&W(window.ResizeObserver),xt="undefined"!=typeof window&&W(window.btoa),wt="undefined"!=typeof window&&W(window.Proxy),bt=0;at&&(bt=et.match(/chrome\/([\d.]+)/)[1]);var Mt=!ot&&(dt||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch),St="undefined"!=typeof window&&"WebGLRenderingContext"in window,Tt=tt(),Et=!1;try{new OffscreenCanvas(2,2).getContext("2d"),Et=!0}catch(t){Et=!1}var Ct=!1;try{window.addEventListener("testPassive",(function(){}),{get passive(){Ct=!0}})}catch(t){}if(K={ie:nt,ielt9:nt&&!document.addEventListener,edge:"msLaunchUri"in navigator&&!("documentMode"in document),webkit:rt,gecko:ht,android:-1!==et.indexOf("android"),android23:st,chrome:at,chromeVersion:bt,safari:!at&&-1!==et.indexOf("safari"),phantomjs:ot,ie3d:pt,webkit3d:ft,gecko3d:mt,opera12:gt,any3d:vt,iosWeixin:lt,mobile:ct,mobileWebkit:ct&&rt,mobileWebkit3d:ct&&ft,mobileOpera:ct&&window.opera,mobileGecko:ct&&ht,touch:!!Mt,msPointer:!!ut,pointer:!!dt,retina:Tt>1,devicePixelRatio:Tt,language:navigator.browserLanguage?navigator.browserLanguage:navigator.language,ie9:nt&&9===document.documentMode,ie10:nt&&10===document.documentMode,webgl:St,imageBitMap:yt,resizeObserver:_t,btoa:xt,decodeImageInWorker:Et,monitorDPRChange:!0,supportsPassive:Ct,proxy:wt,removeDPRListening:function(t){t&&delete $[t.id]},checkDevicePixelRatio:function(){if("undefined"!=typeof window&&K.monitorDPRChange){var t=tt(),e=t!==K.devicePixelRatio;return e&&(K.devicePixelRatio=t),e}return!1},addDPRListening:function(t){t&&($[t.id]=t)}},"undefined"!=typeof window&&window.matchMedia)for(var Pt=1;Pt<500;Pt++){var At=(.01*Pt).toFixed(2),Lt=window.matchMedia("screen and (resolution: "+At+"dppx)");Lt&&(Lt.addEventListener?Lt.addEventListener("change",K.checkDevicePixelRatio):Lt.addListener&&Lt.addListener(K.checkDevicePixelRatio))}if(K.devicePixelRatio){var Rt=K.devicePixelRatio;Object.defineProperty(K,"devicePixelRatio",{get:function(){return Rt},set:function(t){if(t!==Rt&&(Rt=t,K.monitorDPRChange))for(var e in $){var i=$[e];if(i&&i.options&&!i.options.devicePixelRatio&&i.checkSize&&i.getRenderer)i.getRenderer()&&i.checkSize(!0)}}})}}var Ot=K;function Dt(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function It(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var kt,zt,Ft=function(){function t(t,e,i){if(H(t)||H(e)?H(t.x)||H(t.y)?Array.isArray(t)&&(this.x=+t[0],this.y=+t[1],this.z=t[2]):(this.x=+t.x,this.y=+t.y,this.z=t.z):(this.x=+t,this.y=+e,this.z=i),this._isNaN())throw new Error("Position is NaN")}var e=t.prototype;return e.set=function(t,e,i){return this.x=t,this.y=e,this.z=i||0,this},e.abs=function(){return new this.constructor(Math.abs(this.x),Math.abs(this.y))},e._abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this},e._round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},e.round=function(){return new this.constructor(Math.round(this.x),Math.round(this.y))},e._ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},e.ceil=function(){return new this.constructor(Math.ceil(this.x),Math.ceil(this.y))},e.distanceTo=function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},e.mag=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e._floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},e.floor=function(){return new this.constructor(Math.floor(this.x),Math.floor(this.y))},e.copy=function(){return new this.constructor(this.x,this.y,this.z)},e._add=function(t,e){return H(t.x)?H(t[0])?(this.x+=t,this.y+=e):(this.x+=t[0],this.y+=t[1]):(this.x+=t.x,this.y+=t.y),this},e.add=function(t,e){var i,n;return H(t.x)?H(t[0])?(i=this.x+t,n=this.y+e):(i=this.x+t[0],n=this.y+t[1]):(i=this.x+t.x,n=this.y+t.y),new this.constructor(i,n)},e._sub=function(t,e){return H(t.x)?H(t[0])?(this.x-=t,this.y-=e):(this.x-=t[0],this.y-=t[1]):(this.x-=t.x,this.y-=t.y),this},e._substract=function(){return this._sub.apply(this,arguments)},e.sub=function(t,e){var i,n;return H(t.x)?H(t[0])?(i=this.x-t,n=this.y-e):(i=this.x-t[0],n=this.y-t[1]):(i=this.x-t.x,n=this.y-t.y),new this.constructor(i,n)},e.substract=function(){return this.sub.apply(this,arguments)},e.multi=function(t){return new this.constructor(this.x*t,this.y*t)},e._multi=function(t){return this.x*=t,this.y*=t,this},e.div=function(t){return this.multi(1/t)},e._div=function(t){return this._multi(1/t)},e.equals=function(t){return t instanceof this.constructor&&(this.x===t.x&&this.y===t.y&&this.z===t.z)},e._isNaN=function(){return isNaN(this.x)||isNaN(this.y)},e.isZero=function(){return 0===this.x&&0===this.y},e.toArray=function(){return j(this.z)?[this.x,this.y,this.z]:[this.x,this.y]},e.toFixed=function(t){return new this.constructor(this.x.toFixed(t),this.y.toFixed(t))},e.toJSON=function(){return{x:this.x,y:this.y}},t}(),Bt=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.closeTo=function(t,e){return e||(e=0),this.x>=t.x-e&&this.x<=t.x+e&&this.y>=t.y-e&&this.y<=t.y+e},i.mag=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},i.unit=function(){return this.copy()._unit()},i._unit=function(){return this._div(this.mag()),this},i.perp=function(){return this.copy()._perp()},i._perp=function(){var t=this.y;return this.y=this.x,this.x=-t,this},i.angleWith=function(t){return this.angleWithSep(t.x,t.y)},i.angleWithSep=function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},i._rotate=function(t){var e=Math.cos(t),i=Math.sin(t),n=e*this.x-i*this.y,r=i*this.x+e*this.y;return this.x=n,this.y=r,this},i.rotate=function(t){return this.copy()._rotate(t)},e}(Ft);function Nt(t){var e="data:image/svg+xml";return t.length>4&&".svg"===t.slice(-4)?1:t.slice(0,e.length)===e?2:0}function Ht(t,e){Q&&Ht.node?Ht.node(t,e):t.src=e[0]}!function(){if(Q)return kt=function(t){return setTimeout(t,16)},void(zt=clearTimeout);var t,e;function i(t){return setTimeout(t,33.333333333333336)}function n(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}"undefined"!=typeof window?(t=window.requestAnimationFrame||n("RequestAnimationFrame")||i,e=window.cancelAnimationFrame||n("CancelAnimationFrame")||n("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)}):(t=i,e=clearTimeout),kt=function(e){return t(e)},zt=function(t){t&&e(t)}}();var jt=0;function Gt(){return jt++}var Ut=Gt;function Vt(t){return t&&V(t)?JSON.parse(t):t}function Wt(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];if(i)for(var n=0,r=i.length;n<r;n++)t.push(i[n])}return t.length}function Zt(t,e){var i=e.indexOf(t);i>-1&&e.splice(i,1)}function qt(t,e,i){if(!Array.isArray(t))return i?e.call(i,t):e(t);for(var n,r,o=[],s=0,a=t.length;s<a;s++)H(n=t[s])?o.push(null):Array.isArray(n)?o.push(qt(n,e,i)):(r=i?e.call(i,n):e(n),o.push(r));return o}function Xt(t,e){return void 0===t?e:t}function Yt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}function Jt(t){if(Math.log2)return Math.log2(t);var e=Math.log(t)*Math.LOG2E,i=Math.round(e);return Math.abs(i-e)<1e-14?i:e}function Qt(t,e,i){return t*(1-i)+e*i}function Kt(t,e,i){if(t===i||t===e)return t;var n=i-e;return((t-e)%n+n)%n+e}function $t(t,e,i){return Math.min(i,Math.max(e,t))}function te(t){return Array.isArray(t)&&t.length>0}var ee=/^([a-z][a-z\d+\-.]*:)?\/\//i;var ie=/^url\((['"])(.+)\1\)$/i,ne=/^url\(([^'"].*[^'"])\)$/i;function re(t){return V(t)?ne.test(t)?1:ie.test(t)?2:3:0}function oe(t){var e=re(t);return 3===e?t:1===e?ne.exec(t)[1]:2===e?ie.exec(t)[2]:t}var se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function ae(t){if(Ot.btoa)return window.btoa(t);for(var e,i,n=String(t),r="",o=0,s=se;n.charAt(0|o)||(s="=",o%1);r+=s.charAt(63&e>>8-o%1*8)){if((i=n.charCodeAt(o+=3/4))>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|i}return r}function he(t,e){for(var i=atob(t),n=new ArrayBuffer(i.length),r=new Uint8Array(n),o=0;o<i.length;o++)r[o]=255&i.charCodeAt(o);return new Blob([n],{type:e})}function le(t,e,i,n){var r=i-t,o=n-e;return Math.atan2(o,r)}var ce="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function ue(t,e){if(!t&&!e)return!0;if(!t||!e)return!1;for(var i in t)if("center"===i){if(!e[i]||!de(t[i][0],e[i][0])||!de(t[i][1],e[i][1]))return!1}else if(t[i]!==e[i])return!1;return!0}function de(t,e,i){return null==i&&(i=1e-6),t>=e-i&&t<=e+i}function pe(t,e,i,n){t||(t=100),e||(e=4);var r=this,o=this.isVisible();return e*=2,this._flashTimeout&&clearTimeout(this._flashTimeout),this._flashTimeout=setTimeout((function s(){if(0===e)return o?r.show():r.hide(),void(i&&(n?i.call(n):i()));e%2==0?r.hide():r.show(),e--,r._flashTimeout=setTimeout(s,t)}),t),this}function fe(t,e){void 0===t&&(t=[]),void 0===e&&(e="_pt");for(var i=[],n=0,r=t.length;n<r;n++){var o=t[n];if(o){o[e]||(o[e]=new Bt(0,0));var s=o[e];s.x=0,s.y=0,i.push(s)}else i.push(null)}return i}function me(t,e){e(t.data)}function ge(t){if(t&&0===t.indexOf("http://")||0===t.indexOf("https://"))return t;var e=document.createElement("a");return e.href=t,t=e.href,e=null,t}var ve,ye={cssWidth:"1px",cssHeight:"1px",width:1,height:1};function _e(t,e){void 0===e&&(e=1);var i=t.width,n=t.height;return ye.cssWidth=i+"px",ye.cssHeight=n+"px",ye.width=Math.round(i*e),ye.height=Math.round(n*e),ye}var xe={width:100,height:10};var we,be=function(){function t(t,e){if(void 0===e&&(e={}),Array.isArray(t))if(t.length<2)console.error("colors.length should >1");else{this.colors=t;for(var i=1/0,n=-1/0,r=0,o=t.length;r<o;r++){var s=t[r][0];i=Math.min(s,i),n=Math.max(s,n)}this.min=i,this.max=n,this.valueOffset=this.max-this.min,this.options=Object.assign({},xe,e),this._initImgData()}else console.error("colors is not array")}var e=t.prototype;return e.getImageData=function(){return this.imgData},e._initImgData=function(){var t=function(){if(!ve){var t=xe.width,e=xe.height;OffscreenCanvas?ve=new OffscreenCanvas(t,e):((ve=document.createElement("canvas")).width=t,ve.height=e)}return ve}(),e=this.options,i=e.width,n=e.height;t.width=i,t.height=n;var r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);for(var o=r.createLinearGradient(0,0,t.width,0),s=this.colors,a=this.valueOffset,h=0,l=s.length;h<l;h++){var c=s[h],u=c[0],d=c[1],p=(u-this.min)/a;o.addColorStop(p,d)}r.fillStyle=o,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)},e.getColor=function(t){t=Math.max(this.min,t);var e=((t=Math.min(t,this.max))-this.min)/this.valueOffset,i=Math.round(e*this.imgData.width),n=4*(i=Math.min(i,this.imgData.width-1));return[this.imgData.data[n],this.imgData.data[n+1],this.imgData.data[n+2],this.imgData.data[n+3]]},t}();function Me(t,e){var i,n,r;if(Oe(t)){var o,s=t.stops&&"object"==typeof t.stops[0][0],a=s||void 0!==t.property,h=s||!a,l=t.type||e||"exponential";if("exponential"===l)o=Ee;else if("interval"===l)o=Te;else if("categorical"===l)o=Se;else if("identity"===l)o=Ae;else{if("color-interpolate"!==l)throw new Error('Unknown function type "'+l+'"');o=Pe}if(s){for(var c={},u=[],d=0;d<t.stops.length;d++){var p=t.stops[d];void 0===c[p[0].zoom]&&(c[p[0].zoom]={zoom:p[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),c[p[0].zoom].stops.push([p[0].value,p[1]])}for(var f in c)u.push([c[f].zoom,Me(c[f])]);i=function(e,i){var n=Ee({stops:u,base:t.base},e)(e,i);return"function"==typeof n?n(e,i):n},n=!1,r=!1}else h?(i=function(e){var i=o(t,e);return"function"==typeof i?i(e):i},n=!0,r=!1):(i=function(e,i){var n=o(t,i?i[t.property]:null);return"function"==typeof n?n(e,i):n},n=!1,r=!0)}else i=function(){return t},n=!0,r=!0;return i.isZoomConstant=r,i.isFeatureConstant=n,i}function Se(t,e){for(var i=0;i<t.stops.length;i++)if(e===t.stops[i][0])return t.stops[i][1];return t.default}function Te(t,e){for(var i=0;i<t.stops.length&&!(e<t.stops[i][0]);i++);return t.stops[Math.max(i-1,0)][1]}function Ee(t,e){for(var i=void 0!==t.base?t.base:1,n=0;!(n>=t.stops.length||e<=t.stops[n][0]);)n++;return 0===n?t.stops[n][1]:n===t.stops.length?t.stops[n-1][1]:Le(e,i,t.stops[n-1][0],t.stops[n][0],t.stops[n-1][1],t.stops[n][1])}"function"==typeof Map&&(we=new Map);var Ce={width:100,height:1};function Pe(t,e){var i=t.stops;if(i&&i.length>1){var n;if(we){var r=JSON.stringify(i);if(!we.has(r)){var o=new be(i,Ce);we.set(r,o)}n=we.get(r)}else n=new be(i,Ce);var s=n.getColor(e);return[s[0]/255,s[1]/255,s[2]/255,s[3]/255]}return i&&1===i.length?i[0][1]:null}function Ae(t,e){return i=e,n=t.default,void 0!==i?i:void 0!==n?n:void 0!==r?r:null;var i,n,r}function Le(t,e,i,n,r,o){return"function"==typeof r?function(){var s=r.apply(void 0,arguments),a=o.apply(void 0,arguments);return Le(t,e,i,n,s,a)}:r.length?function(t,e,i,n,r,o){for(var s=[],a=0;a<r.length;a++)s[a]=Re(t,e,i,n,r[a],o[a]);return s}(t,e,i,n,r,o):Re(t,e,i,n,r,o)}function Re(t,e,i,n,r,o){var s,a=n-i,h=t-i;return r*(1-(s=1===e?h/a:(Math.pow(e,h)-1)/(Math.pow(e,a)-1)))+o*s}function Oe(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type)}function De(t){for(var e in t)if(Oe(t[e]))return!0;return!1}function Ie(t){return Fe(t,"exponential")}function ke(t,e){if(!t)return null;var i=!1;if(Array.isArray(t)){for(var n,r=[],o=0;o<t.length;o++)(n=ke(t[o],e))?(r.push(n),i=!0):r.push(t[o]);return i?r:t}var s,a={__fn_types_loaded:!0},h=[];for(s in t)t.hasOwnProperty(s)&&h.push(s);for(var l=function(t){Object.defineProperty(a,t,{get:function(){return this["__fn_"+t]||(this["__fn_"+t]=Ie(this["_"+t])),this["__fn_"+t].apply(this,e())},set:function(e){this["_"+t]=e},configurable:!0,enumerable:!0})},c=0,u=h.length;c<u;c++)Oe(t[s=h[c]])?(i=!0,a["_"+s]=t[s],l(s)):a[s]=t[s];return i?a:t}function ze(t){if(!t||!t.stops)return[];for(var e=[],i=0,n=t.stops.length;i<n;i++)e.push(t.stops[i][1]);return e}function Fe(t,e){if(!Oe(t))return function(){return t};var i=!0,n=!0,r=(t=JSON.parse(JSON.stringify(t))).stops;if(r)for(var o=0;o<r.length;o++)if(Oe(r[o][1])){var s=Fe(r[o][1],e);i=i&&s.isZoomConstant,n=n&&s.isFeatureConstant,r[o]=[r[o][0],s]}var a=Me(t,e);return a.isZoomConstant=i&&a.isZoomConstant,a.isFeatureConstant=n&&a.isFeatureConstant,a}var Be=["Unknown","Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"];function Ne(t){return new Function("f","var p = (f && f.properties || {}); return "+He(t))}function He(t){if(!t)return"true";var e=t[0];if(t.length<=1)return"any"===e?"false":"true";var i="=="===e?Ge(t[1],t[2],"===",!1):"!="===e?Ge(t[1],t[2],"!==",!1):"<"===e||">"===e||"<="===e||">="===e?Ge(t[1],t[2],e,!0):"any"===e?Ve(t.slice(1),"||"):"all"===e?Ve(t.slice(1),"&&"):"none"===e?qe(Ve(t.slice(1),"||")):"in"===e?We(t[1],t.slice(2)):"!in"===e?qe(We(t[1],t.slice(2))):"has"===e?Ze(t[1]):"!has"===e?qe(Ze(t[1])):"contains"===e?function(t,e,i){var n=je(t);return void 0!==i?"("+n+" + '').indexOf(\""+e+'") === '+i:"("+n+" + '').indexOf(\""+e+'") >= 0'}(t[1],t[2],t[3]):"true";return"("+i+")"}function je(t){return"$"===t[0]?"f."+t.substring(1):"p["+JSON.stringify(t)+"]"}function Ge(t,e,i,n){return"object"==typeof(r=t)&&r&&t.op?function(t,e,i,n){var r=t.property,o=t.op,s=je(r);return"length"!==o?(console.error("not support "+o+" op"),"false"):Ue(s="(("+s+"+='').length)",r,e,i,n)}(t,e,i,n):Ue(je(t),t,e,i,n);var r}function Ue(t,e,i,n,r){var o="$type"===e?Be.indexOf(i):JSON.stringify(i);return(r?"typeof "+t+"=== typeof "+o+"&&":"")+t+n+o}function Ve(t,e){return t.map(He).join(e)}function We(t,e){"$type"===t&&(e=e.map((function(t){return Be.indexOf(t)})));var i=JSON.stringify(e.sort(Xe)),n=je(t);return e.length<=200?i+".indexOf("+n+") !== -1":"function(v, a, i, j) {\n while (i <= j) { var m = (i + j) >> 1;\n if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;\n }\n return false; }("+n+", "+i+",0,"+(e.length-1)+")"}function Ze(t){return"$id"===t?'"id" in f':JSON.stringify(t)+" in p"}function qe(t){return"!("+t+")"}function Xe(t,e){return t<e?-1:t>e?1:0}function Ye(t){var e=t._toJSON(),i=e.feature;return i.type=Be.indexOf(i.geometry.type),i.subType=e.subType,i}function Je(t){if(!Array.isArray(t))return Je([t]);for(var e=[],i=0;i<t.length;i++){var n=void 0;n=!0===t[i].filter?function(){return!0}:Ne(t[i].filter),e.push(Qe({},t[i],{filter:n}))}return e}function Qe(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)t[n]=i[n]}return t}var Ke=[],$e={};function ti(t,e){return ke(t,(function(){var t=e.getMap();return function(t,e,i){return t[0]=e,t[1]=i,t}(Ke,t?t.getZoom():12,N({},e.getProperties(),function(t,e,i,n){return t["{bearing}"]=e,t["{pitch}"]=i,t["{zoom}"]=n,t}($e,t&&t.getBearing()||0,t&&t.getPitch()||0,t?t.getZoom():10)))}))}function ei(t){var e={stroke:{stroke:t.markerLineColor,"stroke-width":t.markerLineWidth,"stroke-opacity":t.markerLineOpacity,"stroke-dasharray":null,"stroke-linecap":"butt","stroke-linejoin":"round"},fill:{fill:t.markerFill,"fill-opacity":t.markerFillOpacity}};return 0===e.stroke["stroke-width"]&&(e.stroke["stroke-opacity"]=0),e}function ii(t,e,i){if(!t.markerPath)return null;var n=1,r=ei(t);j(t.markerOpacity)&&(n=t.markerOpacity),j(t.opacity)&&(n*=t.opacity);var o={};if(r){for(var s in r.stroke)r.stroke.hasOwnProperty(s)&&(H(r.stroke[s])||(o[s]=r.stroke[s]));for(var a in r.fill)r.fill.hasOwnProperty(a)&&(H(r.fill[a])||(o[a]=r.fill[a]))}for(var h,l=Array.isArray(t.markerPath)?t.markerPath:[t.markerPath],c=[],u=0;u<l.length;u++)(h=N({},h=V(l[u])?{path:l[u]}:l[u],o)).d=h.path,delete h.path,c.push(h);var d=['<svg version="1.1"','xmlns="http://www.w3.org/2000/svg"'];n<1&&d.push('opacity="'+n+'"'),t.markerPathWidth&&t.markerPathHeight&&d.push('viewBox="0 0 '+t.markerPathWidth+" "+t.markerPathHeight+'"'),d.push('preserveAspectRatio="none"'),e&&d.push('width="'+e+'"'),i&&d.push('height="'+i+'"'),d.push("><defs></defs>");for(var p=0;p<c.length;p++){var f="<path ";for(var m in c[p])c[p].hasOwnProperty(m)&&(f+=" "+m+'="'+c[p][m]+'"');f+="></path>",d.push(f)}return d.push("</svg>"),"data:image/svg+xml;base64,"+ae(d.join(" "))}function ni(t,e){if(!t)return[];var i=t;Array.isArray(t)||(i=[t]);for(var n,r,o,s,a=[],h=D,l=i.length-1;l>=0;l--)if(t=i[l]){e&&(t=ri(t));for(var c=0;c<h.length;c++)if(Oe(n=t[h[c]])&&(n=ze(n)),n){Array.isArray(n)||(n=[n]);for(var u=0;u<n.length;u++)"url("===n[u].slice(0,4)&&(n[u]=oe(n[u])),r=I[c],a.push([n[u],t[r[0]],t[r[1]]])}if("path"===t.markerType&&t.markerPath)if(o=Oe(t.markerWidth)?200:t.markerWidth,s=Oe(t.markerHeight)?200:t.markerHeight,Oe(t.markerPath)){n=ze(t.markerPath);for(var d=t.markerPath,p=0;p<n.length;p++)t.markerPath=n[p],a.push([ii(t),o,s]);t.markerPath=d}else a.push([ii(t),o,s])}return a}function ri(t){if(!t)return null;var e=t;if(Q)return e;for(var i,n=D,r=0,o=n.length;r<o;r++)(i=e[n[r]])&&(e[n[r]]=oi(i));return e}function oi(t){if(Oe(t)){for(var e=t.stops,i=0;i<e.length;i++)e[i][1]=oi(e[i][1]);return t}return"url("===t.slice(0,4)&&(t=oe(t)),t}var si=function(){function t(t,e){j(t)&&j(e)?(this.width=t,this.height=e):j(t.width)?(this.width=t.width,this.height=t.height):Array.isArray(t)&&(this.width=t[0],this.height=t[1])}var e=t.prototype;return e.copy=function(){return new t(this.width,this.height)},e.add=function(e,i){var n,r;return e instanceof t?(n=this.width+e.width,r=this.height+e.height):(n=this.width+e,r=this.height+i),new t(n,r)},e.equals=function(t){return this.width===t.width&&this.height===t.height},e.multi=function(e){return new t(this.width*e,this.height*e)},e._multi=function(t){return this.width*=t,this.height*=t,this},e._round=function(){return this.width=Math.round(this.width),this.height=Math.round(this.height),this},e.toPoint=function(){return new Bt(this.width,this.height)},e.toArray=function(){return[this.width,this.height]},e.toJSON=function(){return{width:this.width,height:this.height}},t}();function ai(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}var hi=/[\b\t\r\v\f]/gim;function li(t){return V(t)?t.replace(hi,""):t}function ci(t){return ai(t).split(/\s+/)}var ui="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):null;function di(t,e){return di.node?di.node(t,e):(ui.font=e,ui.measureText(t).width)}function pi(t,e,i){var n=di(t,e);return new si(n,i||F)}function fi(t,e,i,n){if(!t||0===t.length)return[{text:"",width:0}];var r=H(n)?di(t,e):n,o=r/t.length,s=Math.floor(i/o/2);if(o>=i||s<=0)return[{text:"",width:i}];if(r<=i)return[{text:t,width:r}];for(var a=[],h=t.substring(0,s),l=o*s,c=s,u=t.length;c<u;c++){var d=t[c],p=di(h+d);p>=i?(a.push({text:h,width:l}),h=t.substring(c,s+c),c+=s-1,l=o*s):(h+=d,l=p),c>=u-1&&(l=di(h),a.push({text:h,width:l}))}return a}var mi=/\{([\w_]+)\}/g;function gi(t,e){return V(t)?t.replace(mi,(function(t,i){if(!e)return"";var n=e[i];return H(n)?"":Array.isArray(n)?n.join():n})):t}function vi(t,e){j(t)&&(t+=""),t=t||"";var i=e.textMaxHeight||0,n=wi(t,e);return i&&i<n.size.height&&(n.size.height=i),n}function yi(t,e,i){var n=t.width,r=t.height;return new Bt("left"===e?-n:"right"===e?0:-n/2,"top"===i?-r:"bottom"===i?0:-r/2)}var _i="monospace";function xi(t){return t.textFont?t.textFont:(t.textStyle&&"normal"!==t.textStyle?t.textStyle+" ":"")+(t.textWeight&&"normal"!==t.textWeight?t.textWeight+" ":"")+t.textSize+"px "+(t.textFaceName?'"'===t.textFaceName[0]?t.textFaceName:'"'+t.textFaceName+'"':_i)}function wi(t,e){var i=xi(e),n=e.textLineSpacing||0,r=pi(t,i,e.textSize),o=r.width,s=r.height,a=e.textWrapCharacter,h=[],l=e.textWrapWidth;(!l||l>o)&&(l=o),V(t)||(t+="");var c=0;if(a&&t.indexOf(a)>=0)for(var u=t.split(a),d=0,p=u.length;d<p;d++){var f=u[d],m=di(f,i);if(m>l)for(var g=fi(f,i,l,m),v=0,y=g.length;v<y;v++){var _=g[v].width;_>c&&(c=_),h.push({text:g[v].text,size:new si(_,s)})}else m>c&&(c=m),h.push({text:f,size:new si(m,s)})}else if(o>l)for(var x=fi(t,i,l,o),w=0;w<x.length;w++){var b=x[w].width;b>c&&(c=b),h.push({text:x[w].text,size:new si(b,s)})}else o>c&&(c=o),h.push({text:t,size:r});var M=h.length;return{total:M,size:new si(c,s*M+n*(M-1)),rows:h,rawSize:r}}function bi(t){var e=0,i=t&&t.length||0;if(!i)return e;for(var n=0;n<i;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return e}function Mi(t){return t&&t.colorStops}function Si(t){var e=[t.type];if(t.places&&e.push(t.places.join()),t.colorStops){for(var i=[],n=t.colorStops.length-1;n>=0;n--)i.push(t.colorStops[n].join());e.push(i.join(","))}return e.join("_")}function Ti(t,e){if(!t)return 1;var i=[];if(Array.isArray(t)){for(var n=0;n<t.length;n++)i.push(Ti(t[n],e));return i.sort().join(",")}var r=Object.keys(t).sort().reduce((function(i,n){return e&&0!==n.indexOf(e)||(i[n]=t[n]),i}),{});return bi(JSON.stringify(r))}function Ei(t,e){function i(t,e){H(t.opacity)?t.opacity=e:t.opacity*=e}var n;if(Array.isArray(t)){n=[];for(var r=0;r<t.length;r++){var o=N({},t[r]);i(o,e),n.push(o)}}else i(n=N({},t),e);return n}function Ci(t){var e=Array.prototype.slice.call(arguments,1);if(e&&e.length||(e=[{}]),Array.isArray(t)){for(var i,n,r=[],o=0,s=t.length;o<s;o++){i=t[o],n={};for(var a=0,h=e.length;a<h;a++)Array.isArray(e[a])?H(e[a][o])?N(n,i||{}):N(n,i,e[a][o]):N(n,i,e[a]?e[a]:{});r.push(n)}return r}var l=[{},t];return l.push.apply(l,e),N.apply(this,l)}function Pi(t){if(t.symbol&&(t=[t]),Array.isArray(t))return t;var e=t.$root,i=t.$iconset;if(t=t.style,e||i){e&&"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),i&&"/"===i[i.length-1]&&(i=i.substring(0,i.length-1));Ai(t,(function(t){return"{$root}"===t?e:"{$iconset}"===t?i:null}))}return t}function Ai(t,e){for(var i=0;i<t.length;i++){var n=t[i].symbol;n&&Ri(n,e)}}var Li=/(\{\$root\}|\{\$iconset\})/g;function Ri(t,e){for(var i in t)t.hasOwnProperty(i)&&"textName"!==i&&(V(t[i])&&t[i].length>2?t[i]=t[i].replace(Li,e):Oe(t[i])?t[i]=Oi(t[i],e):U(t[i])&&Ri(t[i],e))}function Oi(t,e){var i=t.default;V(i)&&(t.default=i.replace(Li,e));for(var n=t.stops,r=0;r<n.length;r++)Array.isArray(n[r])&&(V(n[r][1])?n[r][1]=n[r][1].replace(Li,e):Oe(n[r][1])&&(n[r][1]=Oi(n[r][1],e)));return t}function Di(t){void 0===t&&(t=[]),Array.isArray(t)||(t=[t]);for(var e=t.length,i=0;i<e;i++){var n=t[i];if(n.style){var r=n.style,o=r.lineDasharray,s=r.lineWidth;if(s&&j(s)&&s>0&&o&&Array.isArray(o)&&o.length)return!0}}return!1}var Ii=Object.freeze({now:B,extend:N,isNil:H,isNumber:j,isInteger:G,isObject:U,isString:V,isFunction:W,hasOwn:q,join:function(t,e){return t.join?t.join(e||","):Array.prototype.join.call(t,e||",")},isEmpty:function(t){var e;for(e in t)return!1;return!e},toRadian:Y,toDegree:J,IS_NODE:Q,get requestAnimFrame(){return kt},get cancelAnimFrame(){return zt},isSVG:Nt,loadImage:Ht,UID:Gt,GUID:Ut,parseJSON:Vt,pushIn:Wt,removeFromArray:Zt,forEachCoord:qt,getValueOrDefault:Xt,sign:Yt,log2:Jt,interpolate:Qt,wrap:Kt,clamp:$t,isArrayHasData:te,isURL:function(t){return ee.test(t)},isCssUrl:re,extractCssUrl:oe,btoa:ae,b64toBlob:he,computeDegree:le,emptyImageUrl:ce,equalMapView:ue,flash:pe,_defaults:function(t,e){for(var i=Object.getOwnPropertyNames(e),n=0;n<i.length;n++){var r=i[n],o=Object.getOwnPropertyDescriptor(e,r);o&&o.configurable&&void 0===t[r]&&Object.defineProperty(t,r,o)}return t},getPointsResultPts:fe,getImageBitMap:me,getAbsoluteURL:ge,calCanvasSize:_e,translateToSVGStyles:ei,getMarkerPathBase64:ii,getExternalResources:ni,convertResourceUrl:ri,isGradient:Mi,getGradientStamp:Si,getSymbolStamp:function(t,e){return Ti(t,e)},getSymbolHash:Ti,lowerSymbolOpacity:Ei,extendSymbol:Ci,parseStyleRootPath:Pi,convertStylePath:Ai,parseSymbolPath:Ri,isDashLine:Di,trim:ai,escapeSpecialChars:li,splitWords:ci,stringWidth:di,stringLength:pi,splitContent:fi,CONTENT_EXPRE:mi,replaceVariable:gi,describeText:vi,getAlignPoint:yi,getFont:xi,splitTextToRow:wi,hashCode:bi}),ki=Q?function(t){return t[0]}:function(t){for(var e=document.documentElement.style,i=0;i<t.length;i++)if(t[i]in e)return t[i];return!1},zi=ki(["transform","WebkitTransform","OTransform","MozTransform","msTransform"]),Fi=ki(["transformOrigin","WebkitTransformOrigin","OTransformOrigin","MozTransformOrigin","msTransformOrigin"]),Bi=ki(["transition","WebkitTransition","OTransition","MozTransition","msTransition"]),Ni=ki(["filter","WebkitFilter","OFilter","MozFilter","msFilter"]);function Hi(t,e){var i=document.createElement(t);return e&&en(i,e),i}function ji(t,e,i){var n=Hi(t);return e&&Ki(n,e),i&&i.appendChild(n),n}function Gi(t){if(!t)return this;if(Ot.ielt9||Ot.ie9){var e=Hi("div");e.appendChild(t),e.innerHTML="",e=null}else t.parentNode&&t.parentNode.removeChild(t);return this}function Ui(t,e,i,n){if(!(t&&t.addEventListener&&e&&i))return this;for(var r=function(e){e||(e=window.event),i.call(n||t,e)},o=e.split(" "),s=o.length-1;s>=0;s--){var a=o[s];if(a)t["Z__"+a]||(t["Z__"+a]=[]),Wi(t,a,i)>=0&&(console.warn(t,"find '"+a+"' handler:",i," The old listener function will be removed"),Vi(t,a,i)),t["Z__"+a].push({callback:r,src:i}),t.addEventListener(a,r,!!Ot.supportsPassive&&{capture:!1,passive:!1})}return this}function Vi(t,e,i){function n(e,i){"mousewheel"===e&&Ot.gecko&&(e="DOMMouseScroll"),t.removeEventListener(e,i,!1)}if(!t||!t.removeEventListener||!e)return this;for(var r=e.split(" "),o=r.length-1;o>=0;o--){var s=r[o];if(s){if(!i&&t["Z__"+s]){for(var a=t["Z__"+s],h=0,l=a.length;h<l;h++)n(a[h].callback);return delete t["Z__"+s],this}var c=Wi(t,s,i);if(c<0)return this;n(s,t["Z__"+s][c].callback),t["Z__"+s].splice(c,1)}}return this}function Wi(t,e,i){if(!t||!t["Z__"+e]||!i)return-1;for(var n=t["Z__"+e],r=0,o=n.length;r<o;r++)if(n[r].src===i)return r;return-1}function Zi(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this}function qi(t){return t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,this}function Xi(t){return t.onselectstart=function(){return!1},t.ondragstart=function(){return!1},t.setAttribute("unselectable","on"),this}function Yi(t,e){return t?(Ot.any3d?rn(t,e):(t.style.left=e.x+"px",t.style.top=e.y+"px"),e):null}function Ji(t){var e=window.getComputedStyle(t),i=[parseInt(e["padding-left"]),parseInt(e["padding-top"])],n=t.getBoundingClientRect(),r=t.offsetWidth,o=t.offsetHeight,s=r?n.width/r:1,a=o?n.height/o:1;return t.__position=[n.left+i[0],n.top+i[1],s,a],t.__position}function Qi(t,e){t||(t=window.event);var i=e.__position;return i||(i=Ji(e)),new Bt((t.clientX-i[0]-e.clientLeft)/i[2],(t.clientY-i[1]-e.clientTop)/i[3])}function Ki(t,e){var i,n,r,o=t.style.cssText;return n=";",(r=(i=o).length-n.length)>=0&&i.indexOf(n,r)===r||(o+=";"),t.style.cssText=o+e,this}function $i(t,e){if(void 0!==t.classList)return t.classList.contains(e);var i=nn(t);return i.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(i)}function tn(t,e){if(void 0===t.classList||$i(t,e)){var i=nn(t);en(t,(i?i+" ":"")+e)}else for(var n=ci(e),r=0,o=n.length;r<o;r++)t.classList.add(n[r]);return this}function en(t,e){return H(t.className.baseVal)?t.className=e:t.className.baseVal=e,this}function nn(t){return H(t.className.baseVal)?t.className:t.className.baseVal}function rn(t,e){var i=e||new Bt(0,0);return t.style[zi]=Ot.any3d?"translate3d("+i.x+"px,"+i.y+"px,0px)":"translate("+i.x+"px,"+i.y+"px)",this}function on(t){return/<[a-z\][\s\S]*>/i.test(t)}function sn(t,e){var i=an(t);V(e)?i.innerHTML=e:i.appendChild(e);var n=new si(i.clientWidth,i.clientHeight);return Gi(i),n}function an(t){var e=document.createElement(t);return e.style.cssText="position:absolute;left:-10000px;top:-10000px;",document.body.appendChild(e),e}var hn,ln=Ui,cn=Vi,un=Object.freeze({TRANSFORM:zi,TRANSFORMORIGIN:Fi,TRANSITION:Bi,CSSFILTER:Ni,createEl:Hi,createElOn:ji,removeDomNode:Gi,addDomEvent:Ui,removeDomEvent:Vi,listensDomEvent:Wi,preventDefault:Zi,stopPropagation:qi,preventSelection:Xi,offsetDom:Yi,computeDomPosition:Ji,getEventContainerPoint:Qi,setStyle:Ki,hasClass:$i,addClass:tn,setClass:en,getClass:nn,setOpacity:function(t,e){return t.style.opacity=e,this},setTransform:rn,setTransformMatrix:function(t,e){var i="matrix("+(V(e)?e:e.join())+")";return t.style[zi]!==i&&(t.style[zi]=i),this},removeTransform:function(t){return t.style[zi]&&(t.style[zi]=""),this},isHTML:on,measureDom:sn,getDomRuler:an,on:ln,off:cn}),dn="function"==typeof Map,pn=function(){},fn=function(){function t(t,e){this.max=t,this.onRemove=e||pn,this.reset()}var e=t.prototype;return e.reset=function(){for(var t in this.data)this.onRemove(this.data[t]);return this.data={},this.order=[],this},e.clear=function(){this.reset(),delete this.onRemove},e.add=function(t,e){if(this.has(t))this.order.splice(this.order.indexOf(t),1),this.data[t]=e,this.order.push(t);else if(this.data[t]=e,this.order.push(t),this.order.length>this.max){var i=this.getAndRemove(this.order[0]);i&&this.onRemove(i)}return this},e.has=function(t){return t in this.data},e.keys=function(){return this.order},e.getAndRemove=function(t){if(!this.has(t))return null;var e=this.data[t];return delete this.data[t],this.order.splice(this.order.indexOf(t),1),e},e.get=function(t){return this.has(t)?this.data[t]:null},e.remove=function(t){if(!this.has(t))return this;var e=this.data[t];return delete this.data[t],this.onRemove(e),this.order.splice(this.order.indexOf(t),1),this},e.setMaxSize=function(t){for(this.max=t;this.order.length>this.max;){var e=this.getAndRemove(this.order[0]);e&&this.onRemove(e)}return this},t}();dn&&(hn=function(){function t(t,e){this.max=t,this.onRemove=e||pn,this.reset()}var e=t.prototype;return e.reset=function(){if(this.data){var t=this.data.values(),e=Array.isArray(t),i=0;for(t=e?t:t[Symbol.iterator]();;){var n;if(e){if(i>=t.length)break;n=t[i++]}else{if((i=t.next()).done)break;n=i.value}var r=n;this.onRemove(r)}}return this.data=new Map,this},e.clear=function(){this.reset(),delete this.onRemove},e.add=function(t,e){return e?(this.has(t)?(this.data.delete(t),this.data.set(t,e),this.data.size>this.max&&this.shrink()):this.data.set(t,e),this):this},e.keys=function(){var t=new Array(this.data.size),e=0,i=this.data.keys(),n=Array.isArray(i),r=0;for(i=n?i:i[Symbol.iterator]();;){var o;if(n){if(r>=i.length)break;o=i[r++]}else{if((r=i.next()).done)break;o=r.value}var s=o;t[e++]=s}return t},e.shrink=function(){for(var t=this.data.keys(),e=t.next();this.data.size>this.max;){var i=this.getAndRemove(e.value);i&&this.onRemove(i),e=t.next()}},e.has=function(t){return this.data.has(t)},e.getAndRemove=function(t){if(!this.has(t))return null;var e=this.data.get(t);return this.data.delete(t),e},e.get=function(t){return this.has(t)?this.data.get(t):null},e.remove=function(t){if(!this.has(t))return this;var e=this.data.get(t);return this.data.delete(t),this.onRemove(e),this},e.setMaxSize=function(t){return this.max=t,this.data.size>this.max&&this.shrink(),this},t}());var mn=dn?hn:fn,gn={jsonp:function(t,e){var i="_maptalks_jsonp_"+Gt();t.match(/\?/)?t+="&callback="+i:t+="?callback="+i;var n=document.createElement("script");return n.type="text/javascript",n.src=t,window[i]=function(t){e(null,t),document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[i]},document.getElementsByTagName("head")[0].appendChild(n),this},get:function(t,e,i){if(W(e)){var n=i;i=e,e=n}if(Q&&gn.get.node)return gn.get.node(t,i,e);var r=gn._getClient(i);if(r.open("GET",t,!0),e){for(var o in e.headers)r.setRequestHeader(o,e.headers[o]);r.withCredentials="include"===e.credentials,e.responseType&&(r.responseType=e.responseType)}return r.send(null),r},post:function(t,e,i){var n;if(V(t)){if(W(e)){var r=i;i=e,e=r}n=(e=e||{}).postData}else{var o=i;n=e,t=(e=t).url,i=o}if(Q&&gn.post.node)return e.url=t,gn.post.node(e,n,i);var s=gn._getClient(i);if(s.open("POST",e.url,!0),e.headers||(e.headers={}),e.headers["Content-Type"]||(e.headers["Content-Type"]="application/x-www-form-urlencoded"),"setRequestHeader"in s)for(var a in e.headers)e.headers.hasOwnProperty(a)&&s.setRequestHeader(a,e.headers[a]);return V(n)||(n=JSON.stringify(n)),s.send(n),s},_wrapCallback:function(t,e){return function(){4===t.readyState&&(200===t.status?"arraybuffer"===t.responseType?0===t.response.byteLength?e(new Error("http status 200 returned without content.")):e(null,{data:t.response,cacheControl:t.getResponseHeader("Cache-Control"),expires:t.getResponseHeader("Expires"),contentType:t.getResponseHeader("Content-Type")}):e(null,t.responseText):e(new Error(t.statusText+","+t.status)))}},_getClient:function(t){var e;try{e=new XMLHttpRequest}catch(t){try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}}return e.onreadystatechange=gn._wrapCallback(e,t),e},getArrayBuffer:function(t,e,i){if(W(e)){var n=i;i=e,e=n}return e||(e={}),e.responseType="arraybuffer",gn.get(t,e,i)},getImage:function(t,e,i){return gn.getArrayBuffer(e,i,(function(e,i){if(e)t.onerror&&t.onerror(e);else if(i){var n=window.URL||window.webkitURL,r=t.onload;t.onload=function(){r&&r(),n.revokeObjectURL(t.src)};var o=new Blob([new Uint8Array(i.data)],{type:i.contentType});t.cacheControl=i.cacheControl,t.expires=i.expires,t.src=i.data.byteLength?n.createObjectURL(o):ce}}))},getJSON:function(t,e,i){if(W(e)){var n=i;i=e,e=n}var r=function(t,e){var n=e?Vt(e):null;i(t,n)};return e&&e.jsonp?gn.jsonp(t,r):gn.get(t,e,r)}},vn="#000",yn=!1,_n=null,xn=Math.PI/180,wn={getCanvas2DContext:function(t){return t.getContext("2d",{willReadFrequently:!0})},setHitTesting:function(t){yn=t},createCanvas:function(t,e,i){var n;return Q?n=new i(t,e):((n=Hi("canvas")).width=t,n.height=e),n},prepareCanvasFont:function(t,e){t.textBaseline="top",t.font=xi(e);var i=e.textFill;i||(i="#000"),t.fillStyle=wn.getRgba(i,e.textOpacity)},prepareCanvas:function(t,e,i,n){if(e){var r=e.lineWidth;H(r)||t.lineWidth===r||(t.lineWidth=r);var o=e.linePatternFile,s=e.lineColor||vn;if(n)t.strokeStyle="#000";else if(o&&i){var a;(e.linePatternDx||e.linePatternDy)&&(a=[e.linePatternDx,e.linePatternDy]),wn._setStrokePattern(t,o,r,a,i),e.lineDasharray=[]}else Mi(s)?e.lineGradientExtent?t.strokeStyle=wn._createGradient(t,s,e.lineGradientExtent):t.strokeStyle=vn:(Array.isArray(s)&&(s=wn.normalizeColorToRGBA(s)),t.strokeStyle=s);e.lineJoin&&(t.lineJoin=e.lineJoin),e.lineCap&&(t.lineCap=e.lineCap),t.setLineDash&&te(e.lineDasharray)&&t.setLineDash(e.lineDasharray);var h=e.polygonPatternFile,l=e.polygonFill||"rgba(255,255,255,0)";if(n)t.fillStyle="#000";else if(h&&i){var c=Sn(h),u=i.getImage([c,null,null]);if(u||(u=i.getImage([c+"-texture",null,r])),Nt(c)&&u instanceof Image&&(Ot.edge||Ot.ie)){var d=u.width||20,p=u.height||20,f=wn.createCanvas(d,p);wn.image(f.getContext("2d"),u,0,0,d,p),u=f}u?(t.fillStyle=t.createPattern(u,"repeat"),(e.polygonPatternDx||e.polygonPatternDy)&&(t.fillStyle.polygonPatternOffset=[e.polygonPatternDx,e.polygonPatternDy])):"undefined"!=typeof console&&console.warn("img not found for",c)}else Mi(l)?e.polygonGradientExtent?t.fillStyle=wn._createGradient(t,l,e.polygonGradientExtent):t.fillStyle="rgba(255,255,255,0)":(Array.isArray(l)&&(l=wn.normalizeColorToRGBA(l)),t.fillStyle=l)}},_createGradient:function(t,e,i){var n=null,r=e.places,o=i.getMin(),s=i.getMax(),a=i.getWidth(),h=i.getHeight();if(e.type&&"linear"!==e.type){if("radial"===e.type){if(r){if(6!==r.length)throw new Error("A radial gradient's places should have 6 numbers.");r=[o.x+r[0]*a,o.y+r[1]*h,a*r[2],o.x+r[3]*a,o.y+r[4]*h,a*r[5]]}else{var l=i.getCenter()._round();r=[l.x,l.y,Math.abs(l.x-o.x),l.x,l.y,0]}n=t.createRadialGradient.apply(t,r)}}else{if(r){if(4!==r.length)throw new Error("A linear gradient's places should have 4 numbers.");r=[o.x+r[0]*a,o.y+r[1]*h,o.x+r[2]*a,o.y+r[3]*h]}else r=[o.x,o.y,s.x,o.y];n=t.createLinearGradient.apply(t,r)}return e.colorStops.forEach((function(t){n.addColorStop.apply(n,t)})),n},_setStrokePattern:function(t,e,i,n,r){var o,s=Sn(e);if(Q)o=r.getImage([s,null,i]);else{var a=s+"-texture-"+i;if(!(o=r.getImage(a))){var h=r.getImage([s,null,null]);if(h){var l;l=h.width&&h.height?Math.round(h.width*i/h.height):i;var c=wn.createCanvas(l,i,t.canvas.constructor);wn.image(c.getContext("2d"),h,0,0,l,i),r.addResource([a,null,i],c),o=c}}}o?(t.strokeStyle=t.createPattern(o,"repeat"),t.strokeStyle.linePatternOffset=n):"undefined"!=typeof console&&console.warn("img not found for",s)},clearRect:function(t,e,i,n,r){t.canvas._drawn=!1,t.clearRect(e,i,n,r)},fillCanvas:function(t,e,i,n){if(yn&&(e=1),t.canvas._drawn=!0,0!==e){var r,o=wn._isPattern(t.fillStyle),s=t.fillStyle&&t.fillStyle.polygonPatternOffset,a=s?s[0]:0,h=s?s[1]:0;H(e)&&(e=1),e<1&&(r=t.globalAlpha,t.globalAlpha*=e),o&&(i=i||0,n=n||0,t.translate(i+a,n+h)),t.fill(),o&&t.translate(-i-a,-n-h),e<1&&(t.globalAlpha=r)}},getRgba:function(t,e){return H(e)&&(e=1),"#"!==t[0]?(Array.isArray(t)&&(t=wn.normalizeColorToRGBA(t,e)),t):(7===t.length?(i=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16)):(i=17*parseInt(t.substring(1,2),16),n=17*parseInt(t.substring(2,3),16),r=17*parseInt(t.substring(3,4),16)),"rgba("+i+","+n+","+r+","+e+")");var i,n,r},normalizeColorToRGBA:function(t,e){return void 0===e&&(e=1),"rgba("+255*t[0]+","+255*t[1]+","+255*t[2]+","+(4===t.length?t[3]:1)*e+")"},image:function(t,e,i,n,r,o){t.canvas._drawn=!0;try{j(r)&&j(o)?t.drawImage(e,i,n,r,o):t.drawImage(e,i,n)}catch(t){console&&(console.warn("error when drawing image on canvas:",t),console.warn(e))}},text:function(t,e,i,n,r){wn._textOnMultiRow(t,r.rows,n,i,r.size,r.rawSize)},_textOnMultiRow:function(t,e,i,n,r,o){for(var s,a,h=yi(r,i.textHorizontalAlignment,i.textVerticalAlignment),l=o.height+i.textLineSpacing,c=n.add(0,h.y),u=i.textMaxHeight,d=0,p=0,f=e.length;p<f&&(s=e[p].text,a=yi(e[p].size,i.textHorizontalAlignment,i.textVerticalAlignment),wn._textOnLine(t,s,c.add(a.x,p*l),i.textHaloRadius,i.textHaloFill,i.textHaloOpacity),!(u>0&&(d+=l)+o.height>=u));p++);},_textOnLine:function(t,e,i,n,r,o){yn&&(o=1);var s,a,h=0!==o&&0!==n;t.textBaseline="top";var l=t.shadowBlur,c=t.shadowOffsetX,u=t.shadowOffsetY;if(h){var d=t.globalAlpha;t.globalAlpha*=o,t.miterLimit=2,t.lineJoin="round",t.lineCap="round",t.lineWidth=2*n,Array.isArray(r)&&(r=wn.normalizeColorToRGBA(r)),t.strokeStyle=r,t.strokeText(e,i.x,i.y+1),t.miterLimit=10,t.globalAlpha=d,s=t.globalCompositeOperation,t.globalCompositeOperation="destination-out",a=t.fillStyle,t.fillStyle="#000"}l&&h&&(t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0),wn.fillText(t,e,i),s&&(t.globalCompositeOperation=s,wn.fillText(t,e,i,a),l&&(t.shadowBlur=l,t.shadowOffsetX=c,t.shadowOffsetY=u))},fillText:function(t,e,i,n){t.canvas._drawn=!0,n&&(t.fillStyle=n),t.fillText(e,i.x,i.y+1)},_stroke:function(t,e,i,n){if(yn&&(e=1),t.canvas._drawn=!0,0!==e){var r,o=t.strokeStyle&&t.strokeStyle.linePatternOffset,s=o?o[0]:0,a=o?o[1]:0,h=wn._isPattern(t.strokeStyle)&&(!H(i)&&!H(n)||!H(s)&&!H(a));H(e)&&(e=1),e<1&&(r=t.globalAlpha,t.globalAlpha*=e),h&&(i=i||0,n=n||0,t.translate(i+s,n+a)),t.stroke(),h&&t.translate(-i-s,-n-a),e<1&&(t.globalAlpha=r)}},_path:function(t,e,i,n,r){if(te(e))for(var o,s,a=te(i),h=!0!==r&&wn._isPattern(t.strokeStyle),l=0,c=e.length;l<c;l++)if(o=e[l],!a||t.setLineDash)t.lineTo(o.x,o.y),h&&l>0&&(u(e[l-1],o),t.beginPath(),t.moveTo(o.x,o.y));else if(a){if(l===c-1)break;s=e[l+1],bn(t,o,s,i)}function u(e,i){var r=le(e.x,e.y,i.x,i.y);t.save();var o=Math.cos(r);Math.abs(o)<1e-7?t.translate(e.x-t.lineWidth/2,e.y):t.translate(e.x,e.y-t.lineWidth/2/o),t.rotate(r),wn._stroke(t,n),t.restore()}},path:function(t,e,i,n,r){te(e)&&(t.beginPath(),t.moveTo(e[0].x,e[0].y),wn._path(t,e,r,i),wn._stroke(t,i))},_multiClip:function(t,e){if(e&&0!==e.length)for(var i=0,n=(e=e[0]).length;i<n;i++){var r=e[i],o=r.x,s=r.y;0===i?t.moveTo(o,s):t.lineTo(o,s),i===n-1&&(o=e[0].x,s=e[0].y,t.lineTo(o,s))}},polygon:function(t,e,i,n,r,o){if(t.isMultiClip)wn._multiClip(t,e);else if(t.isClip)wn._multiClip(t,Array.isArray(e[0])?e:[e]);else if(te(e)){var s=wn._isPattern(t.strokeStyle),a=te(r)&&!t.setLineDash||s&&!o;te(e[0])||(e=[e]);var h,l,c,u=t;if(e.length>1&&!Q&&(_n||(_n=wn.createCanvas(1,1)),t.canvas._drawn=!1,_n.width=t.canvas.width,_n.height=t.canvas.height,Tn(t=_n.getContext("2d"),u)),a){for(t.save(),l=0,c=e.length;l<c;l++)te(e[l])&&(wn._ring(t,e[l],null,0,!0),h=n,l>0&&(t.globalCompositeOperation="destination-out",h=1),wn.fillCanvas(t,h,e[l][0].x,e[l][0].y),l>0?t.globalCompositeOperation="source-over":c>1&&(t.fillStyle="#fff"),wn._stroke(t,0));t.restore()}var d=t.fillStyle;for(l=0,c=e.length;l<c;l++)te(e[l])&&(o?(wn.paintSmoothLine(t,e[l],i,o,!0),t.closePath()):wn._ring(t,e[l],r,i),a||(h=n,l>0&&(t.globalCompositeOperation="destination-out",h=1),wn.fillCanvas(t,h,e[l][0].x,e[l][0].y),l>0?t.globalCompositeOperation="source-over":c>1&&(t.fillStyle="#fff")),wn._stroke(t,i));t.fillStyle!==d&&(t.fillStyle=d),e.length>1&&!Q&&(u.drawImage(_n,0,0),u.canvas._drawn=t.canvas._drawn,Tn(u,t))}},_ring:function(t,e,i,n,r){var o=wn._isPattern(t.strokeStyle);r||!o||e[0].equals(e[e.length-1])||(e=e.concat([e[0]])),t.beginPath(),t.moveTo(e[0].x,e[0].y),wn._path(t,e,i,n,r),o||t.closePath()},paintSmoothLine:function(t,e,i,n,r,o,s){if(e)if(e.length<=2||!n)wn.path(t,e,i);else{var a,h=e.length,l=r?h:h-1;t.beginPath(),t.moveTo(e[0].x,e[0].y),void 0!==s&&(l-=Math.max(l-o-1,0));for(var c=0;c<l;c++){var u=e[c].x,d=e[c].y,p=void 0,f=void 0,m=void 0,g=void 0,v=void 0,y=void 0;c-1<0?r?(p=e[l-1].x,f=e[l-1].y):(p=e[c+1].x,f=e[c+1].y):(p=e[c-1].x,f=e[c-1].y),c+1<h?(m=e[c+1].x,g=e[c+1].y):(m=e[c+1-h].x,g=e[c+1-h].y),c+2<h?(v=e[c+2].x,y=e[c+2].y):r?(v=e[c+2-h].x,y=e[c+2-h].y):(v=e[c].x,y=e[c].y);var _=w(p,f,u,d,m,g,v,y,n,c===l-1?s:1);if(c===l-1&&s>=0&&s<1){t.bezierCurveTo(_[0],_[1],_[2],_[3],_[4],_[5]),e.splice(l-1,h-(l-1)-1);var x=new Bt(_[4],_[5]);x.prevCtrlPoint=new Bt(_[2],_[3]),e.push(x),h=e.length}else t.bezierCurveTo(_[0],_[1],_[2],_[3],m,g);e[c].nextCtrlPoint=_.slice(0,2),e[c].prevCtrlPoint=a?a.slice(2):null,a=_}!r&&e[1].prevCtrlPoint&&(e[0].nextCtrlPoint=e[1].prevCtrlPoint,delete e[0].prevCtrlPoint),e[h-1].prevCtrlPoint||(e[h-1].prevCtrlPoint=e[h-2].nextCtrlPoint),wn._stroke(t,i)}function w(t,e,i,n,r,o,s,a,h,l){var c=(t+i)/2,u=(e+n)/2,d=(i+r)/2,p=(n+o)/2,f=(r+s)/2,m=(o+a)/2,g=Math.sqrt((i-t)*(i-t)+(n-e)*(n-e)),v=Math.sqrt((r-i)*(r-i)+(o-n)*(o-n)),y=g/(g+v),_=v/(v+Math.sqrt((s-r)*(s-r)+(a-o)*(a-o))),x=c+(d-c)*y,w=u+(p-u)*y,b=d+(f-d)*_,M=p+(m-p)*_,S=x+(d-x)*h+i-x,T=w+(p-w)*h+n-w,E=b+(d-b)*h+r-b,C=M+(p-M)*h+o-M,P=[S,T,E,C];return l<1?function(t,e,i,n,r,o,s,a,h,l){var c=1-t,u=1-e,d=i*u*u+2*r*e*u+s*e*e,p=r*u*u+2*s*e*u+h*e*e,f=n*u*u+2*o*e*u+a*e*e,m=o*u*u+2*a*e*u+l*e*e;return[(i*c*c+2*r*t*c+s*t*t)*u+(r*c*c+2*s*t*c+h*t*t)*e,(n*c*c+2*o*t*c+a*t*t)*u+(o*c*c+2*a*t*c+l*t*t)*e,d*c+p*t,f*c+m*t,d*u+p*e,f*u+m*e]}(0,l,i,n,S,T,E,C,r,o):P}},_arcBetween:function(t,e,i,n){var r=n,o=e.distanceTo(i),s=o/2/Math.sin(r/2),a=Math.asin((i.y-e.y)/o);e.x>i.x&&(a=Math.PI-a);var h=a-(90*xn-r/2),l=Math.cos(h)*s,c=Math.sin(h)*s,u=e.x+l,d=e.y+c,p=Math.asin((i.y-d)/s);u>i.x&&(p=Math.PI-p);var f=p+r;return t.beginPath(),t.arc(u,d,s,p,f),[u,d]},_lineTo:function(t,e){t.lineTo(e.x,e.y)},bezierCurveAndFill:function(t,e,i,n){t.beginPath();var r=e[0];t.moveTo(r.x,r.y);var o=[t];o.push.apply(o,e.splice(1)),wn._bezierCurveTo.apply(wn,o),wn.fillCanvas(t,n),wn._stroke(t,i)},_bezierCurveTo:function(t,e,i,n){t.bezierCurveTo(e.x,e.y,i.x,i.y,n.x,n.y)},ellipse:function(t,e,i,n,r,o,s){var a,h,l,c,u,d,p,f,m;t.beginPath(),i===n&&i===r?t.arc(e.x,e.y,i,0,2*Math.PI):t.ellipse?n!==r?(t.ellipse(e.x,e.y,i,n,0,180*xn,360*xn,!1),t.ellipse(e.x,e.y,i,r,0,0,180*xn,!1)):t.ellipse(e.x,e.y,i,n,0,0,360*xn,!1):(a=e.x,h=e.y,p=(l=i)*(d=.5522848),f=(c=n)*d,m=(u=r)*d,t.moveTo(a-l,h),t.bezierCurveTo(a-l,h-f,a-p,h-c,a,h-c),t.bezierCurveTo(a+p,h-c,a+l,h-f,a+l,h),t.bezierCurveTo(a+l,h+m,a+p,h+u,a,h+u),t.bezierCurveTo(a-p,h+u,a-l,h+m,a-l,h),t.closePath()),wn.fillCanvas(t,s,e.x-i,e.y-n),wn._stroke(t,o,e.x-i,e.y-n)},rectangle:function(t,e,i,n,r){var o=e.x,s=e.y;t.beginPath(),t.rect(o,s,i.width,i.height),wn.fillCanvas(t,r,o,s),wn._stroke(t,n,o,s)},sector:function(t,e,i,n,r,o){var s=xn,a=n[0],h=n[1];function l(t,e,i,n,a,h){var l=s*-h,c=s*-a;t.beginPath(),t.moveTo(e,i),t.arc(e,i,n,l,c),t.lineTo(e,i),wn.fillCanvas(t,o,e-n,i-n),wn._stroke(t,r,e-n,i-n)}l(t,e.x,e.y,i,a,h)},_isPattern:function(t){return!V(t)&&!("addColorStop"in t)},drawCross:function(t,e,i,n,r){t.canvas._drawn=!0,t.strokeStyle=r,t.lineWidth=n,t.beginPath(),t.moveTo(e-5,i),t.lineTo(e+5,i),t.moveTo(e,i-5),t.lineTo(e,i+5),t.stroke()},copy:function(t,e){var i=e||Hi("canvas");return i.width=t.width,i.height=t.height,i.getContext("2d").drawImage(t,0,0),i},pixelRect:function(t,e,i,n){var r=t.lineWidth,o=t.globalAlpha,s=!1;if(r>0&&i>0)s=!0,i<1&&(t.globalAlpha*=i);else{if(!(n>0))return;n<1&&(t.globalAlpha*=n)}t.canvas._drawn=!0,s?t.strokeRect(e[0],e[1],1,1):t.fillRect(e[0],e[1],1,1),t.globalAlpha!==o&&(t.globalAlpha=o)}};function bn(t,e,i,n){var r=e.x,o=e.y,s=i.x,a=i.y,h=n,l=function(t,e){return t<=e},c=function(t,e){return t>=e},u=function(t,e){return Math.min(t,e)},d=function(t,e){return Math.max(t,e)},p={thereYet:c,cap:u},f={thereYet:c,cap:u};o-a>0&&(f.thereYet=l,f.cap=d),r-s>0&&(p.thereYet=l,p.cap=d),t.moveTo(r,o);for(var m,g,v=r,y=o,_=0,x=!0;!p.thereYet(v,s)||!f.thereYet(y,a);)m=Math.atan2(a-o,s-r),g=h[_],v=p.cap(s,v+Math.cos(m)*g),y=f.cap(a,y+Math.sin(m)*g),x?t.lineTo(v,y):t.moveTo(v,y),_=(_+1)%h.length,x=!x}var Mn="data:image/";function Sn(t){return t.substring(0,Mn.length)===Mn?t:oe(t)}function Tn(t,e){t.filter=e.filter,t.fillStyle=e.fillStyle,t.globalAlpha=e.globalAlpha,t.lineCap=e.lineCap,t.lineDashOffset=e.lineDashOffset,t.lineJoin=e.lineJoin,t.lineWidth=e.lineWidth,t.shadowBlur=e.shadowBlur,t.shadowColor=e.shadowColor,t.shadowOffsetX=e.shadowOffsetX,t.shadowOffsetY=e.shadowOffsetY,t.strokeStyle=e.strokeStyle}var En="undefined"!=typeof Promise?Promise:n,Cn=function(t){return function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.on=function(t,e,i){if(!t)return this;if(!V(t))return this._switch("on",t,e);if(!e)return this;this._eventMap||(this._eventMap={});var n,r,o=t.toLowerCase().split(" ");i||(i=this);for(var s=0,a=o.length;s<a;s++){n=o[s],(r=this._eventMap[n])||(r=[],this._eventMap[n]=r);var h=r.length;if(h>0)for(var l=0;l<h;l++)if(e===r[l].handler&&r[l].context===i)return console.warn(this,"find '"+t+"' handler:",e," The old listener function will be removed"),this;r.push({handler:e,context:i})}return this},i.addEventListener=function(){return this.on.apply(this,arguments)},i.once=function(t,e,i){if(!V(t)){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]=this._wrapOnceHandler(r,t[r],i));return this._switch("on",n)}for(var o=t.split(" "),s=0,a=o.length;s<a;s++)this.on(o[s],this._wrapOnceHandler(o[s],e,i));return this},i.off=function(t,e,i){if(!this._eventMap||!t)return this;if(!V(t))return this._switch("off",t,e);if(!e)return this;var n,r,o,s=t.split(" ");i||(i=this);for(var a=0,h=s.length;a<h;a++){if(o="Z__"+(n=s[a].toLowerCase()),!(r=this._eventMap[n]))return this;for(var l=r.length-1;l>=0;l--){var c=r[l];e!==c.handler&&e!==c.handler[o]||c.context!==i||(delete c.handler[o],r.splice(l,1))}r.length||delete this._eventMap[n]}return this},i.removeEventListener=function(){return this.off.apply(this,arguments)},i.listens=function(t,e,i){if(!this._eventMap||!V(t))return 0;var n=this._eventMap[t.toLowerCase()];if(!n||!n.length)return 0;if(!e)return n.length;for(var r=0,o=n.length;r<o;r++)if(e===n[r].handler&&(H(i)||n[r].context===i))return 1;return 0},i.getListeningEvents=function(){return this._eventMap?Object.keys(this._eventMap):[]},i.copyEventListeners=function(t){var e,i=t._eventMap;if(!i)return this;for(var n in i)for(var r=0,o=(e=i[n]).length;r<o;r++)this.on(n,e[r].handler,e[r].context);return this},i.fire=function(){return this._eventParent?this._eventParent.fire.apply(this._eventParent,arguments):this._fire.apply(this,arguments)},i._wrapOnceHandler=function(t,e,i){var n=this,r="Z__"+t,o=!1,s=function a(){o||(delete s[r],o=!0,i?e.apply(i,arguments):e.apply(this,arguments),n.off(t,a,this))};return s[r]=e,s},i._switch=function(t,e,i){for(var n in e)e.hasOwnProperty(n)&&this[t](n,e[n],i);return this},i._clearListeners=function(t){this._eventMap&&V(t)&&(this._eventMap[t.toLowerCase()]&&(this._eventMap[t]=null))},i._clearAllListeners=function(){this._eventMap=null},i._setEventParent=function(t){return this._eventParent=t,this},i._setEventTarget=function(t){return this._eventTarget=t,this},i._fire=function(t,e){if(!this._eventMap)return this;var i=this._eventMap[t.toLowerCase()];if(!i)return this;e||(e={}),e.type=t,e.target=this._eventTarget||this;for(var n,r,o=i.slice(0),s=0,a=o.length;s<a;s++)o[s]&&(n=o[s].context,!0,r=N({},e),!1===(n?o[s].handler.call(n,r):o[s].handler(r))&&e.domEvent&&qi(e.domEvent));return this},e}(t)},Pn=function(){function t(t){this.target=t}var e=t.prototype;return e.enable=function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},e.disable=function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},e.enabled=function(){return!!this._enabled},e.remove=function(){this.disable(),delete this.target,delete this.dom},t}(),An=Cn(Pn),Ln=function(){function t(t){if(!this||!this.setOptions)throw new Error('Class instance is being created without "new" operator.');this.setOptions(t),this.callInitHooks(),this._isUpdating=!1}var e=t.prototype;return e.proxyOptions=function(){var t=this;return Ot.proxy?(this.options.isExtensible||(this.options=new Proxy(this.options,{set:function(e,i,n){if(e[i]===n)return!0;if(e[i]=n,t._isUpdating)return!0;var r={};return r[i]=n,t.config(r),!0}})),this):this},e.callInitHooks=function(){var t=Object.getPrototypeOf(this);return this._visitInitHooks(t),this},e.setOptions=function(t){if(this.hasOwnProperty("options")||(this.options=this.options?Object.create(this.options):{}),!t)return this;for(var e in t)this.options[e]=t[e];return this},e.config=function(t){if(this._isUpdating=!0,!t){var e={};for(var i in this.options)this.options.hasOwnProperty(i)&&(e[i]=this.options[i]);return this._isUpdating=!1,e}if(2===arguments.length){var n={};n[t]=arguments[1],t=n}for(var r in t)this.options[r]=t[r],this[r]&&this[r]instanceof An&&(t[r]?this[r].enable():this[r].disable());return this.onConfig(t),this._isUpdating=!1,this},e.onConfig=function(){},e._visitInitHooks=function(t){if(!this._initHooksCalled){var e=Object.getPrototypeOf(t);e._visitInitHooks&&e._visitInitHooks.call(this,e),this._initHooksCalled=!0;var i=t._initHooks;if(i&&i!==e._initHooks)for(var n=0;n<i.length;n++)i[n].call(this)}},t.addInitHook=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];var r="function"==typeof t?t:function(){this[t].apply(this,i)},o=this.prototype,s=Object.getPrototypeOf(o);return o._initHooks&&o._initHooks!==s._initHooks||(o._initHooks=[]),o._initHooks.push(r),this},t.include=function(){for(var t=0;t<arguments.length;t++)N(this.prototype,t<0||arguments.length<=t?void 0:arguments[t]);return this},t.mergeOptions=function(t){var e=this.prototype,i=Object.getPrototypeOf(e);return e.options&&e.options!==i.options||(e.options=e.options?Object.create(e.options):{}),N(e.options,t),this},t}(),Rn={},On=function(t){return function(t){function e(){return t.apply(this,arguments)||this}return Dt(e,t),e.registerJSONType=function(t){return t?(Rn[t]=this,this):this},e.getJSONClass=function(t){return t?Rn[t]:null},e.prototype.getJSONType=function(){if(void 0===this._jsonType){var t=Object.getPrototypeOf(this).constructor;for(var e in Rn)if(Rn[e]===t){this._jsonType=e;break}}if(!this._jsonType)throw new Error("Found an unregistered geometry class!");return this._jsonType},e}(t)},Dn={},In=function(){function t(){this._tree=x(9,["[0]","[1]","[2]","[3]"])}var e=t.prototype;return e.collides=function(t){return Dn.minX=t[0],Dn.minY=t[1],Dn.maxX=t[2],Dn.maxY=t[3],this._tree.collides(Dn)},e.insertBox=function(t){return this._tree.insert(t),this},e.bulkInsertBox=function(t){return this._tree.load(t),this},e.clear=function(){return this._tree.clear(),this},t}();function kn(t){return function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.addHandler=function(t,e){if(!e)return this;if(this._handlers||(this._handlers=[]),this[t])return this[t].enable(),this;var i=this[t]=new e(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},i.removeHandler=function(t){if(!t)return this;var e=this[t];if(e){var i=this._handlers.indexOf(e);i>=0&&this._handlers.splice(i,1),this[t].remove(),delete this[t]}return this},i._clearHandlers=function(){for(var t=0,e=this._handlers.length;t<e;t++)this._handlers[t].remove();this._handlers=[]},e}(t)}var zn="touchstart mousedown",Fn={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},Bn={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},Nn=function(t){function e(e,i){var n;return void 0===i&&(i={}),(n=t.call(this,null)||this).dom=e,n.options=i,n}Dt(e,t);var i=e.prototype;return i.enable=function(){return this.dom?(this._onMouseDown=function(t){return this.onMouseDown(t)},ln(this.dom,zn,this._onMouseDown,this),this):this},i.disable=function(){return this.dom?(this._offEvents(),cn(this.dom,zn,this._onMouseDown),delete this._onMouseDown,this):this},i.onMouseDown=function(t){if((this.options.rightclick||2!==t.button)&&!(t.touches&&t.touches.length>1||this.options.cancelOn&&!0===this.options.cancelOn(t))){var e=this.dom;e.setCapture?e.setCapture():window.captureEvents&&window.captureEvents(window.Event.MOUSEMOVE|window.Event.MOUSEUP),e.ondragstart=function(){return!1},delete this.moved;var i=t.touches?t.touches[0]:t;this.startPos=new Bt(i.clientX,i.clientY),cn(document,Fn[t.type],this.onMouseMove),cn(document,Bn[t.type],this.onMouseUp),ln(document,Fn[t.type],this.onMouseMove,this),ln(document,Bn[t.type],this.onMouseUp,this),this.options.ignoreMouseleave||(cn(this.dom,"mouseleave",this.onMouseUp),ln(this.dom,"mouseleave",this.onMouseUp,this)),this.fire("mousedown",{domEvent:t,mousePos:new Bt(i.clientX,i.clientY)})}},i.onMouseMove=function(t){if(t.touches&&t.touches.length>1)this.moved&&(this.interupted=!0,this.onMouseUp(t));else{var e=t.touches?t.touches[0]:t,i=new Bt(e.clientX,e.clientY).sub(this.startPos);(i.x||i.y)&&(this.moved?this.fire("dragging",{domEvent:t,mousePos:new Bt(e.clientX,e.clientY)}):(this.fire("dragstart",{domEvent:t,mousePos:this.startPos.copy()}),this.moved=!0))}},i.onMouseUp=function(t){var e=t.changedTouches?t.changedTouches[0]:t;this._offEvents();var i={domEvent:t};j(e.clientX)&&(i.mousePos=new Bt(parseInt(e.clientX,0),parseInt(e.clientY,0))),this.moved&&(i.interupted=this.interupted,this.fire("dragend",i),delete this.interupted,delete this.moved),this.fire("mouseup",i)},i._offEvents=function(){var t=this.dom;if(cn(t,"mouseleave",this.onMouseUp),"undefined"!=typeof document&&"undefined"!=typeof window){for(var e in Fn)cn(document,Fn[e],this.onMouseMove),cn(document,Bn[e],this.onMouseUp);t.releaseCapture?t.releaseCapture():window.captureEvents&&window.captureEvents(window.Event.MOUSEMOVE|window.Event.MOUSEUP)}},e}(An),Hn=function(t){function e(){return t.apply(this,arguments)||this}return Dt(e,t),e.toNumberArrays=function(t){return Array.isArray(t)?qt(t,(function(t){return[t.x,t.y]})):[t.x,t.y]},e.toCoordinates=function(t){if(j(t[0])&&j(t[1]))return new e(t);if(t instanceof e)return t;for(var i=[],n=0,r=t.length;n<r;n++){var o=t[n];Array.isArray(o)?j(o[0])?i.push(new e(o)):i.push(e.toCoordinates(o)):o instanceof e?i.push(o):i.push(new e(o))}return i},e}(Ft),jn=function(){function t(t,e){this.type=t,this.properties=e}return t.createProj4=function(e){return new t("proj4",{proj:e})},t.fromProjectionCode=function(e){return e&&t[e=e.toUpperCase().replace(":","")]||null},t}();jn.WGS84=jn.createProj4("+proj=longlat +datum=WGS84 +no_defs"),jn.EPSG4326=jn.WGS84,jn.EPSG3857=jn.createProj4("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"),jn.IDENTITY=jn.createProj4("+proj=identity +no_defs"),jn.CGCS2000=jn.createProj4("+proj=longlat +datum=CGCS2000"),jn.EPSG4490=jn.CGCS2000,jn.BD09LL=jn.createProj4("+proj=longlat +datum=BD09"),jn.GCJ02=jn.createProj4("+proj=longlat +datum=GCJ02");var Gn,Un=new Bt(0,0),Vn=new Hn(0,0),Wn=new Hn(0,0),Zn=new Hn(0,0),qn=new Hn(0,0),Xn=new Hn(0,0),Yn=new Hn(0,0),Jn=new Hn(0,0),Qn=new Hn(0,0),Kn=[],$n=[],tr=function(){function t(t,e,i,n){this._clazz=Hn;var r=arguments.length,o=r>0?arguments[r-1]:null;o&&o.unproject&&(this.projection=arguments[r-1]),this._dirty=!0,this._initialize(t,e,i,n)}var e=t.prototype;return e._initialize=function(t,e,i,n){if(this.xmin=null,this.xmax=null,this.ymin=null,this.ymax=null,!H(t)){var r=this.projection;j(t)&&j(e)&&j(i)&&j(n)?r?this.set(t,e,i,n):this.set(Math.min(t,i),Math.min(e,n),Math.max(t,i),Math.max(e,n)):Array.isArray(t)?r?this.set(t[0],t[1],t[2],t[3]):this.set(Math.min(t[0],t[2]),Math.min(t[1],t[3]),Math.max(t[0],t[2]),Math.max(t[1],t[3])):j(t.x)&&j(e.x)&&j(t.y)&&j(e.y)?r?this.set(t.x,t.y,e.x,e.y):(t.x>e.x?(this.xmin=e.x,this.xmax=t.x):(this.xmin=t.x,this.xmax=e.x),t.y>e.y?(this.ymin=e.y,this.ymax=t.y):(this.ymin=t.y,this.ymax=e.y)):j(t.xmin)&&j(t.xmax)&&j(t.ymin)&&j(t.ymax)&&this.set(t.xmin,t.ymin,t.xmax,t.ymax)}},e._add=function(t){return this._dirty=!0,H(t.x)?H(t.xmin)?H(t[0])||(this.xmin+=t[0],this.ymin+=t[1],this.xmax+=t[0],this.ymax+=t[1]):(this.xmin+=t.xmin,this.ymin+=t.ymin,this.xmax+=t.xmax,this.ymax+=t.ymax):(this.xmin+=t.x,this.ymin+=t.y,this.xmax+=t.x,this.ymax+=t.y),this},e.add=function(){var t=new this.constructor(this.xmin,this.ymin,this.xmax,this.ymax,this.projection);return t._add.apply(t,arguments)},e._scale=function(t){return this._dirty=!0,this.xmin*=t,this.ymin*=t,this.xmax*=t,this.ymax*=t,this},e._sub=function(t){return this._dirty=!0,H(t.x)?H(t.xmin)?H(t[0])||(this.xmin-=t[0],this.ymin-=t[1],this.xmax-=t[0],this.ymax-=t[1]):(this.xmin-=t.xmin,this.ymin-=t.ymin,this.xmax-=t.xmax,this.ymax-=t.ymax):(this.xmin-=t.x,this.ymin-=t.y,this.xmax-=t.x,this.ymax-=t.y),this},e._substract=function(){return this._sub.apply(this,arguments)},e.sub=function(){var t=new this.constructor(this.xmin,this.ymin,this.xmax,this.ymax,this.projection);return t._sub.apply(t,arguments)},e.substract=function(){return this.sub.apply(this,arguments)},e.round=function(){return new this.constructor(Math.round(this.xmin),Math.round(this.ymin),Math.round(this.xmax),Math.round(this.ymax),this.projection)},e._round=function(){return this._dirty=!0,this.xmin=Math.round(this.xmin),this.ymin=Math.round(this.ymin),this.xmax=Math.round(this.xmax),this.ymax=Math.round(this.ymax),this},e.getMin=function(t){return t?(t.set(this.xmin,this.ymin),t):new this._clazz(this.xmin,this.ymin)},e.getMax=function(t){return t?(t.set(this.xmax,this.ymax),t):new this._clazz(this.xmax,this.ymax)},e.getCenter=function(t){var e=(this.xmin+this.xmax)/2,i=(this.ymin+this.ymax)/2;return t?(t.set(e,i),t):new this._clazz(e,i)},e.isValid=function(){return!(H(this.xmin)||H(this.ymin)||H(this.xmax)||H(this.ymax))},e.equals=function(t){return this.xmin===t.xmin&&this.xmax===t.xmax&&this.ymin===t.ymin&&this.ymax===t.ymax},e.intersects=function(t){this._project(this),this._project(t);var e=Math.max(this.pxmin,t.pxmin),i=Math.max(this.pymin,t.pymin),n=Math.min(this.pxmax,t.pxmax),r=Math.min(this.pymax,t.pymax),o=!(e>n||i>r);return o},e.within=function(t){return this._project(this),this._project(t),this.pxmin>=t.pxmin&&this.pxmax<=t.pxmax&&this.pymin>=t.pymin&&this.pymax<=t.pymax},e.contains=function(t){if(!t)return!1;this._project(this);var e=this.projection;if(e)if(void 0!==t.x){var i=Vn;Array.isArray(t)?(i.x=t[0],i.y=t[1]):(i.x=t.x,i.y=t.y),t=e.project(i,i)}else void 0!==t.xmin&&this._project(t);return(t.x||t.pxmin||0)>=this.pxmin&&(t.x||t.pxmax||0)<=this.pxmax&&(t.y||t.pymin||0)>=this.pymin&&(t.y||t.pymax||0)<=this.pymax},e.getWidth=function(){return Math.abs(this.xmax-this.xmin)},e.getHeight=function(){return Math.abs(this.ymax-this.ymin)},e.getSize=function(){return new si(this.getWidth(),this.getHeight())},e.set=function(t,e,i,n){return this.xmin=t,this.ymin=e,this.xmax=i,this.ymax=n,this._dirty=!0,this},e.__combine=function(t){var e,i,n,r;void 0!==t.x&&(Gn.xmin=Gn.xmax=t.x,Gn.ymin=Gn.ymax=t.y,t=Gn),this._project(t),this._project(this),j(this.pxmin)?(e=Math.min(this.pxmin,t.pxmin),i=Math.min(this.pymin,t.pymin),n=Math.max(this.pxmax,t.pxmax),r=Math.max(this.pymax,t.pymax)):(e=t.pxmin,i=t.pymin,n=t.pxmax,r=t.pymax);var o=this.projection;if(o){Wn.set(e,i),Zn.set(n,r);var s=o.unproject(Wn,Wn),a=o.unproject(Zn,Zn);e=s.x,i=s.y,n=a.x,r=a.y}return $n[0]=e,$n[1]=i,$n[2]=n,$n[3]=r,$n},e._combine=function(t){if(!t||t.isValid&&!t.isValid())return this;var e=this.__combine(t);return this.set(e[0],e[1],e[2],e[3]),this._dirty=!0,this},e.combine=function(t){if(!t||t.isValid&&!t.isValid())return this;var e=this.__combine(t);return new this.constructor(e[0],e[1],e[2],e[3],this.projection)},e.intersection=function(t){if(!this.intersects(t))return null;qn.x=Math.max(this.pxmin,t.pxmin),qn.y=Math.max(this.pymin,t.pymin),Xn.x=Math.min(this.pxmax,t.pxmax),Xn.y=Math.min(this.pymax,t.pymax);var e=qn,i=Xn,n=this.projection;return n&&(e=n.unproject(e,e),i=n.unproject(i,i)),new this.constructor(e,i,n)},e.expand=function(t){var e,i;return j(t)?e=i=t:(e=t.width||t.x||t[0]||0,i=t.height||t.y||t[1]||0),new this.constructor(this.xmin-e,this.ymin-i,this.xmax+e,this.ymax+i,this.projection)},e._expand=function(t){var e,i;return j(t)?e=i=t:(e=t.width||t.x||t[0]||0,i=t.height||t.y||t[1]||0),this.xmin-=e,this.ymin-=i,this.xmax+=e,this.ymax+=i,this._dirty=!0,this},e.toJSON=function(){return{xmin:this.xmin,ymin:this.ymin,xmax:this.xmax,ymax:this.ymax}},e.toArray=function(t){var e=this.xmin,i=this.ymin,n=this.xmax,r=this.ymax;return t?(t[0].x=e,t[0].y=r,t[1].x=n,t[1].y=r,t[2].x=n,t[2].y=i,t[3].x=e,t[3].y=i,t[4].x=e,t[4].y=r,t):[new this._clazz([e,r]),new this._clazz([n,r]),new this._clazz([n,i]),new this._clazz([e,i]),new this._clazz([e,r])]},e.toString=function(){return this.xmin+","+this.ymin+","+this.xmax+","+this.ymax},e.copy=function(){return new this.constructor(this.xmin,this.ymin,this.xmax,this.ymax,this.projection)},e.convertTo=function(t,e){if(!this.isValid())return null;var i,n=e||new this.constructor;return e&&n.set(null,null,null,null),this._clazz===Hn?i=Yn:this._clazz===Bt&&(i=Un),i.x=this.xmin,i.y=this.ymax,n._combine(t(i)),i.x=this.xmax,n._combine(t(i)),i.y=this.ymin,n._combine(t(i)),i.x=this.xmin,n._combine(t(i)),n},e._project=function(t){if(t&&t.isValid()){var e=this.projection;if(e){if(t._dirty){Jn.set(t.xmax,t.ymin),Qn.set(t.xmin,t.ymax),Kn[0]=Jn,Kn[1]=Qn;var i=e.projectCoords(Kn),n=i[0],r=i[1];t.pxmin=Math.min(n.x,r.x),t.pymin=Math.min(n.y,r.y),t.pxmax=Math.max(n.x,r.x),t.pymax=Math.max(n.y,r.y)}delete t._dirty}else t.pxmin=t.xmin,t.pxmax=t.xmax,t.pymin=t.ymin,t.pymax=t.ymax}else t&&(t.pxmin=t.pxmax=t.pymin=t.pymax=null)},t}();Gn=new tr(0,0,0,0);var er=function(t){function e(e,i,n,r){var o;return(o=t.call(this,e,i,n,r)||this)._clazz=Bt,o}return Dt(e,t),e}(tr),ir=function(){function t(t){this.matrix=t}var e=t.prototype;return e.transform=function(t,e,i){var n=this.matrix[0]*(t.x-this.matrix[2])/e,r=-this.matrix[1]*(t.y-this.matrix[3])/e;return i?(i.x=n,i.y=r,i):new Bt(n,r)},e.untransform=function(t,e,i){var n=t.x*e/this.matrix[0]+this.matrix[2],r=t.y*e/-this.matrix[1]+this.matrix[3];return i?(i.x=n,i.y=r,i):new Hn(n,r)},t}(),nr={project:function(){},unproject:function(){},projectCoords:function(t,e){var i=this;if(!t)return[];if(!Array.isArray(t))return this.project(t);if(0===t.length)return[];if(!this.isSphere())return qt(t,this.project,this);if(Array.isArray(t[0]))return t.map((function(t){return i.projectCoords(t,e)}));for(var n,r,o,s,a,h,l=!1!==e,c=this.getCircum(),u=this.getSphereExtent(),d=u.sx,p=u.sy,f=t[0],m=[this.project(f)],g=1,v=t.length;g<v;g++)s=(o=t[g]).x-f.x,a=o.y-f.y,h=this.project(o),Math.abs(s)>180&&l&&(void 0===n&&(n=o.x>f.x),n&&(h._add(-c.x*Yt(s)*d,0),o._add(-360*Yt(s),0))),Math.abs(a)>90&&l&&(void 0===r&&(r=o.y<f.y),r&&(h._add(0,-c.y*Yt(a)*p),o._add(0,-180*Yt(a)))),f=o,m.push(h);return m},unprojectCoords:function(t){return t?Array.isArray(t)?qt(t,this.unproject,this):this.unproject(t):[]},isSphere:function(){return!!this.sphere},isOutSphere:function(t){return!!this.isSphere()&&!this.getSphereExtent().contains(t)},wrapCoord:function(t){if(!this.isSphere())return t;var e=this.getSphereExtent(),i=new Hn(t);return e.contains(i)||(i.x=Kt(t.x,e.xmin,e.xmax),i.y=Kt(t.y,e.ymin,e.ymax)),i},getCircum:function(){if(!this.circum&&this.isSphere()){var t=this.getSphereExtent();this.circum={x:t.getWidth(),y:t.getHeight()}}return this.circum},getSphereExtent:function(){if(!this.extent&&this.isSphere()){var t=this.project(new Hn(180,90)),e=this.project(new Hn(-180,-90));this.extent=new tr(e,t,this),this.extent.sx=t.x>e.x?1:-1,this.extent.sy=t.y>e.y?1:-1}return this.extent}},rr={measureLength:function(t,e){if(!Array.isArray(t))return this.measureLenBetween(t,e);for(var i=0,n=0,r=t.length;n<r-1;n++)i+=this.measureLenBetween(t[n],t[n+1]);return i}},or=N({measure:"IDENTITY",measureLenBetween:function(t,e){if(!t||!e)return 0;try{return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}catch(t){return 0}},measureArea:function(t){if(!Array.isArray(t))return 0;for(var e=0,i=0,n=t.length;i<n;i++){var r=t[i],o=null;o=i===n-1?t[0]:t[i+1],e+=r.x*o.y-r.y*o.x}return Math.abs(e/2)},locate:function(t,e,i,n){return(n=n||new Hn(0,0)).set(t.x,t.y),this._locate(n,e,i)},_locate:function(t,e,i){return t?(e||(e=0),i||(i=0),e||i?(t.x=t.x+e,t.y=t.y+i,t):t):null},rotate:function(t,e,i){return t=new Hn(t.x,t.y),this._rotate(t,e,i)},_rotate:function(){var t=new Bt(0,0);return function(e,i,n){return t.x=e.x-i.x,t.y=e.y-i.y,t._rotate(n*Math.PI/180),e.x=i.x+t.x,e.y=i.y+t.y,e}}()},rr),sr=function(){function t(t){this.radius=t}var e=t.prototype;return e.measureLenBetween=function(t,e){if(!t||!e)return 0;var i=Y(t.y),n=Y(e.y),r=i-n,o=Y(t.x)-Y(e.x);return i=2*Math.asin(Math.sqrt(Math.pow(Math.sin(r/2),2)+Math.cos(i)*Math.cos(n)*Math.pow(Math.sin(o/2),2))),i*=this.radius,Math.round(1e5*i)/1e5},e.measureArea=function(t){var e,i=Y(this.radius),n=0,r=t,o=r.length;if(o<3)return 0;for(e=0;e<o-1;e++){var s=r[e],a=r[e+1];n+=s.x*i*Math.cos(Y(s.y))*a.y*i-a.x*i*Math.cos(Y(a.y))*s.y*i}return o=r[e],r=r[0],n+=o.x*i*Math.cos(Y(o.y))*r.y*i-r.x*i*Math.cos(Y(r.y))*o.y*i,.5*Math.abs(n)},e.locate=function(t,e,i,n){return(n=n||new Hn(0,0)).set(t.x,t.y),this._locate(n,e,i)},e._locate=function(t,e,i){if(!t)return null;if(e||(e=0),i||(i=0),!e&&!i)return t;var n,r,o=Y(t.y);if(0!==i){var s=Math.abs(i);r=Kt(180*(o+=2*Math.sin(s/(2*this.radius))*(i>0?1:-1))/Math.PI,-90,90)}else r=t.y;if(0!==e){var a=Math.abs(e),h=Y(t.x);n=Kt(180*(h+=2*Math.sqrt(Math.pow(Math.sin(a/(2*this.radius)),2)/Math.pow(Math.cos(o),2))*(e>0?1:-1))/Math.PI,-180,180)}else n=t.x;return t.x=n,t.y=r,t},e.rotate=function(t,e,i){return t=new Hn(t),this._rotate(t,e,i)},e._rotate=function(t,e,i){var n=function(t,e,i){void 0===i&&(i={});var n;n=i.final?ar(e,t):ar(t,e);return n>180?-(360-n):n}(e,t),r=n-i,o=this.measureLenBetween(e,t);return t.x=e.x,t.y=e.y,function(t,e,i,n){var r=e/n,o=t.x*Math.PI/180,s=Y(t.y),a=Y(i),h=r*Math.cos(a),l=s+h;Math.abs(l)>Math.PI/2&&(l=l>0?Math.PI-l:-Math.PI-l);var c=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),u=Math.abs(c)>1e-11?h/c:Math.cos(s),d=r*Math.sin(a)/u,p=o+d;return t.x=(180*p/Math.PI+540)%360-180,t.y=180*l/Math.PI,t}(t,o,r,this.radius)},t}();function ar(t,e){var i=Y(t.y),n=Y(e.y),r=Y(e.x-t.x);r>Math.PI&&(r-=2*Math.PI),r<-Math.PI&&(r+=2*Math.PI);var o=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(i/2+Math.PI/4));return(J(Math.atan2(r,o))+360)%360}var hr=N({measure:"EPSG:4326",sphere:new sr(6378137),measureLenBetween:function(){return this.sphere.measureLenBetween.apply(this.sphere,arguments)},measureArea:function(){return this.sphere.measureArea.apply(this.sphere,arguments)},_locate:function(){return this.sphere._locate.apply(this.sphere,arguments)},locate:function(){return this.sphere.locate.apply(this.sphere,arguments)},_rotate:function(){return this.sphere._rotate.apply(this.sphere,arguments)},rotate:function(){return this.sphere.rotate.apply(this.sphere,arguments)}},rr),lr=N({measure:"BAIDU",sphere:new sr(6370996.81),measureLenBetween:function(){return this.sphere.measureLenBetween.apply(this.sphere,arguments)},measureArea:function(){return this.sphere.measureArea.apply(this.sphere,arguments)},_locate:function(){return this.sphere._locate.apply(this.sphere,arguments)},locate:function(){return this.sphere.locate.apply(this.sphere,arguments)},_rotate:function(){return this.sphere._rotate.apply(this.sphere,arguments)},rotate:function(){return this.sphere.rotate.apply(this.sphere,arguments)}},rr),cr=hr,ur={};function dr(t){ur[t.measure]=t}dr(or),dr(hr),dr(lr);var pr={getInstance:function(t){if(!t)return cr;for(var e in ur)if(q(ur,e)){var i=ur[e].measure;if(!i)continue;if(t.toLowerCase()===i.toLowerCase())return ur[e]}return null}},fr=N({},nr,{code:"EPSG:3857",rad:Math.PI/180,metersPerDegree:6378137*Math.PI/180,maxLatitude:85.0511287798,project:function(t,e){var i=this.rad,n=this.metersPerDegree,r=this.maxLatitude,o=t.x,s=Math.max(Math.min(r,t.y),-r),a=o*n,h=(0===s?0:Math.log(Math.tan((90+s)*i/2))/i)*n;return e?(e.x=a,e.y=h,e):new Hn(a,h)},unproject:function(t,e){var i,n=this.rad,r=this.metersPerDegree,o=t.x/r,s=t.y;0===s?i=0:(i=s/r,i=(2*Math.atan(Math.exp(i*n))-Math.PI/2)/n),Math.abs(Math.abs(o)-180)<1e-7&&(o=180*Yt(o)),Math.abs(Math.abs(i)-this.maxLatitude)<1e-7&&(i=Yt(i)*this.maxLatitude);var a=Kt(o,-180,180),h=Kt(i,-this.maxLatitude,this.maxLatitude);return e?(e.x=a,e.y=h,e):new Hn(a,h)}},hr),mr=N({},nr,{code:"EPSG:4326",project:function(t,e){return e?(e.x=t.x,e.y=t.y,e):new Hn(t)},unproject:function(t,e){return e?(e.x=t.x,e.y=t.y,e):new Hn(t)}},hr),gr=N({},mr,{code:"EPSG:4490"}),vr=N({},nr,{code:"BAIDU",project:function(t,e){return this.convertLL2MC(t,e)},unproject:function(t,e){return this.convertMC2LL(t,e)}},lr,{EARTHRADIUS:6370996.81,MCBAND:[12890594.86,8362377.87,5591021,3481989.83,1678043.12,0],LLBAND:[75,60,45,30,15,0],MC2LL:[[1.410526172116255e-8,898305509648872e-20,-1.9939833816331,200.9824383106796,-187.2403703815547,91.6087516669843,-23.38765649603339,2.57121317296198,-.03801003308653,17337981.2],[-7.435856389565537e-9,8983055097726239e-21,-.78625201886289,96.32687599759846,-1.85204757529826,-59.36935905485877,47.40033549296737,-16.50741931063887,2.28786674699375,10260144.86],[-3.030883460898826e-8,898305509983578e-20,.30071316287616,59.74293618442277,7.357984074871,-25.38371002664745,13.45380521110908,-3.29883767235584,.32710905363475,6856817.37],[-1.981981304930552e-8,8983055099779535e-21,.03278182852591,40.31678527705744,.65659298677277,-4.44255534477492,.85341911805263,.12923347998204,-.04625736007561,4482777.06],[3.09191371068437e-9,8983055096812155e-21,6995724062e-14,23.10934304144901,-.00023663490511,-.6321817810242,-.00663494467273,.03430082397953,-.00466043876332,2555164.4],[2.890871144776878e-9,8983055095805407e-21,-3.068298e-8,7.47137025468032,-353937994e-14,-.02145144861037,-1234426596e-14,.00010322952773,-323890364e-14,826088.5]],LL2MC:[[-.0015702102444,111320.7020616939,0x60e374c3105a3,-0x24bb4115e2e164,0x5cc55543bb0ae8,-0x7ce070193f3784,0x5e7ca61ddf8150,-0x261a578d8b24d0,0x665d60f3742ca,82.5],[.0008277824516172526,111320.7020463578,647795574.6671607,-4082003173.641316,10774905663.51142,-15171875531.51559,12053065338.62167,-5124939663.577472,913311935.9512032,67.5],[.00337398766765,111320.7020202162,4481351.045890365,-23393751.19931662,79682215.47186455,-115964993.2797253,97236711.15602145,-43661946.33752821,8477230.501135234,52.5],[.00220636496208,111320.7020209128,51751.86112841131,3796837.749470245,992013.7397791013,-1221952.21711287,1340652.697009075,-620943.6990984312,144416.9293806241,37.5],[-.0003441963504368392,111320.7020576856,278.2353980772752,2485758.690035394,6070.750963243378,54821.18345352118,9540.606633304236,-2710.55326746645,1405.483844121726,22.5],[-.0003218135878613132,111320.7020701615,.00369383431289,823725.6402795718,.46104986909093,2351.343141331292,1.58060784298199,8.77738589078284,.37238884252424,7.45]],convertMC2LL:function(t,e){for(var i,n=0,r=this.MCBAND.length;n<r;n++)if(Math.abs(t.y)>=this.MCBAND[n]){i=this.MC2LL[n];break}return this.convertor(t,i,e)},convertLL2MC:function(t,e){var i,n,r;t.x=this.getLoop(t.x,-180,180),t.y=this.getRange(t.y,-74,74);var o=new Hn(t.x,t.y);for(n=0,r=this.LLBAND.length;n<r;n++)if(o.y>=this.LLBAND[n]){i=this.LL2MC[n];break}if(!i)for(n=this.LLBAND.length-1;n>=0;n--)if(o.y<=-this.LLBAND[n]){i=this.LL2MC[n];break}return this.convertor(t,i,e)},convertor:function(t,e,i){if(!t||!e)return null;var n=e[0]+e[1]*Math.abs(t.x),r=Math.abs(t.y)/e[9],o=e[2]+e[3]*r+e[4]*r*r+e[5]*r*r*r+e[6]*r*r*r*r+e[7]*r*r*r*r*r+e[8]*r*r*r*r*r*r;return n*=t.x<0?-1:1,o*=t.y<0?-1:1,i?(i.x=n,i.y=o,i):new Hn(n,o)},toRadians:function(t){return Math.PI*t/180},toDegrees:function(t){return 180*t/Math.PI},getRange:function(t,e,i){return null!=e&&(t=Math.max(t,e)),null!=i&&(t=Math.min(t,i)),t},getLoop:function(t,e,i){if(t===1/0)return i;if(t===-1/0)return e;for(;t>i;)t-=i-e;for(;t<e;)t+=i-e;return t}}),yr=N({},nr,{code:"IDENTITY",project:function(t,e){return e?(e.x=t.x,e.y=t.y,e):t.copy()},unproject:function(t,e){return e?(e.x=t.x,e.y=t.y,e):t.copy()}},or),_r=fr,xr=Object.freeze({EPSG3857:fr,DEFAULT:_r,EPSG4326:mr,EPSG4490:gr,BAIDU:vr,IDENTITY:yr,Common:nr}),wr=function(t){return function(t){function e(){return t.apply(this,arguments)||this}return Dt(e,t),e.registerRenderer=function(t,e){var i=this.prototype,n=Object.getPrototypeOf(i);return i._rendererClasses&&i._rendererClasses!==n._rendererClasses||(i._rendererClasses=i._rendererClasses?Object.create(i._rendererClasses):{}),i._rendererClasses[t.toLowerCase()]=e,this},e.getRendererClass=function(t){var e=this.prototype;return e._rendererClasses?e._rendererClasses[t.toLowerCase()]:null},e}(t)},br={};function Mr(t,e){br[t]=e}var Sr,Tr="\n var adapters = {};\n onmessage = function (msg) {\n msg = msg.data;\n if (msg.messageType === 'batch') {\n const messages = msg.messages;\n if (messages) {\n for (let i = 0; i < messages.length; i++) {\n dispatch(messages[i]);\n }\n }\n } else {\n dispatch(msg);\n }\n };\n\n function dispatch(msg) {\n var workerKey = msg.workerKey;\n var adapter = adapters[workerKey];\n if (!adapter) {\n post(msg.callback, 'Unregistered worker adapters for ' + workerKey);\n return;\n }\n try {\n adapter.onmessage(msg, wrap(msg.callback));\n } catch (err) {\n post(msg.callback, workerKey + ':' + err.message);\n console.error(err);\n throw err;\n }\n }\n\n function post(callback, err, data, buffers) {\n var msg = {\n callback : callback\n };\n if (err) {\n msg.error = err;\n } else {\n msg.data = data;\n }\n if (buffers && buffers.length > 0) {\n postMessage(msg, buffers);\n } else {\n postMessage(msg);\n }\n }\n function wrap(callback) {\n return function (err, data, buffers) {\n post(callback, err, data, buffers);\n };\n }\n var workerExports;\n",Er="\n workerExports = null;\n";function Cr(){if("undefined"==typeof window)return null;if(!Sr){var t=function(){var t=Tr;for(var e in br){var i=br[e];W(i)&&0===i.length&&(i=i()),t+="\n workerExports = {};\n ("+i+")(workerExports, self);\n adapters['"+e+"'] = workerExports",t+="\n workerExports.initialize && workerExports.initialize(self);\n "}return t+Er}();Sr=window.URL.createObjectURL(new Blob([t],{type:"text/javascript"})),br=null}return Sr}var Pr,Ar="undefined"!=typeof window?window.navigator.hardwareConcurrency||4:0,Lr=Math.max(Math.floor(Ar/2),1),Rr=function(){function t(t){void 0===t&&(t=50),this._limit=t,this._messages=[],this.buffers=[]}var e=t.prototype;return e.addMessage=function(t,e){if(this._messages.push(t),Array.isArray(e))for(var i=0;i<e.length;i++)this.buffers.indexOf(e[i])<0&&this.buffers.push(e[i])},e.isFull=function(){return this._messages.length>=this._limit},e.getMessage=function(){return{messageType:"batch",messages:this._messages}},t}(),Or=function(){function t(){this.active={},this.workerCount="undefined"!=typeof window?window.MAPTALKS_WORKER_COUNT||Lr:0,this._messages=[],this._messageBuffers=[]}var e=t.prototype;return e.acquire=function(t){if(!this.workers){this.workers=[];for(var e=Cr(),i=0;i<this.workerCount;i++){var n=new Worker(e);n.id=i,this.workers.push(n)}URL.revokeObjectURL(e)}return this.active[t]=!0,this.workers.slice()},e.release=function(t){delete this.active[t],0===Object.keys(this.active).length&&(this.workers.forEach((function(t){t.terminate()})),this.workers=null)},e.addMessage=function(t,e,i){var n=this._messages[t];n&&n.length||(n=this._messages[t]=[new Rr]);var r=n[n.length-1];r.isFull()&&(r=new Rr,this._messages[t].push(r)),r.addMessage(e,i)},e.commit=function(){if(this._messages.length)for(var t=0;t<this._messages.length;t++)if(this._messages[t]&&this._messages[t].length){var e=this._messages[t].shift();this.workers[t].postMessage(e.getMessage(),e.buffers)}},t}();function Dr(){return Pr||(Pr=new Or),Pr}kt&&kt((function t(){Dr().commit(),kt(t)}));var Ir=0,kr=[],zr=function(){function t(t){var e=this;this.workerKey=t,this.workerPool=Dr(),this.currentActor=0,this.actorId=Gt(),this.workers=this.workerPool.acquire(this.actorId),this.callbacks={},this.callbackID=0,this.receiveFn=this.receive.bind(this),this.workers.forEach((function(t){t.addEventListener("message",e.receiveFn,!1)}))}var e=t.prototype;return e.isActive=function(){return!!this.workers},e.broadcast=function(t,e,i){var n=this;return i=i||function(){},function(t,e,i){t.length||i(null,[]);var n=t.length,r=new Array(t.length),o=null;t.forEach((function(t,s){e(t,(function(t,e){t&&(o=t),r[s]=e,0==--n&&i(o,r)}))}))}(this.workers,(function(i,r){n.send(t,e,r,i.id)}),i),this},e.send=function(t,e,i,n){var r=i?this.actorId+":"+this.callbackID++:null;return i&&(this.callbacks[r]=i),this.post({data:t,callback:String(r)},e,n),this},e.receive=function(t){var e=this,i=t.data,n=i.callback,r=this.callbacks[n];delete this.callbacks[n],"<request>"===i.type?this.actorId===i.actorId&&this[i.command](i.params,(function(t,n,r){var o={type:"<response>",callback:i.callback};t?o.error=t.message:o.data=n,e.post(o,r||kr,i.workerId)})):r&&i.error?r(i.error):r&&r(null,i.data)},e.remove=function(){var t=this;this.workers.forEach((function(e){e.removeEventListener("message",t.receiveFn,!1)})),this.workerPool.release(this.actorId),delete this.receiveFn,delete this.workers,delete this.callbacks,delete this.workerPool},e.post=function(t,e,i){return("number"!=typeof i||isNaN(i))&&(i=this.currentActor=(this.currentActor+1)%this.workerPool.workerCount),t.workerId=i,t.workerKey=this.workerKey,t.actorId=this.actorId,this.workerPool.addMessage(i,t,e||kr),i},e.getDedicatedWorker=function(){return Ir=(Ir+1)%this.workerPool.workerCount},t}();var Fr="core-fetch-image",Br=[],Nr=function(t){function e(){return t.call(this,Fr)||this}return Dt(e,t),e.prototype.fetchImage=function(t,e){var i={url:t};this.send(i,Br,e)},e}(zr),Hr=function(t){function e(e){var i;return(i=t.call(this)||this).layer=e,i._painted=!1,i._drawTime=0,!Ot.decodeImageInWorker||"gl"!==e.options.renderer&&(Ot.safari||Ot.iosWeixin)||(i._resWorkerConn=new Nr),i.setToRedraw(),i}Dt(e,t);var i=e.prototype;return i.render=function(t){this.prepareRender(),this.getMap()&&this.layer.isVisible()&&(this.resources||(this.resources=new jr),this.checkAndDraw(this._tryToDraw,t))},i.checkAndDraw=function(t){var e=this;this._toRedraw=!1;for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];if(this.checkResources){var o=this.checkResources();o.length>0?(this._loadingResource=!0,this.loadResources(o).then((function(){e._loadingResource=!1,e.layer&&(e.layer.fire("resourceload"),e.setToRedraw())}))):t.call.apply(t,[this].concat(n))}else t.call.apply(t,[this].concat(n))},i.testIfNeedRedraw=function(){var t=this.getMap();return!this._loadingResource&&(!!this._toRedraw||!(t.isInteracting()&&!this.drawOnInteracting)&&!!this.needToRedraw())},i.needToRedraw=function(){var t=this.getMap();return!(!t.isInteracting()&&!t.getRenderer().isViewChanged())&&!(!t.getPitch()&&t.isMoving()&&!t.isZooming()&&!t.isRotating()&&!this.layer.options.forceRenderOnMoving)},i.onSkipDrawOnInteracting=function(){},i.isLoadingResource=function(){return this._loadingResource},i.isRenderComplete=function(){return!!this._renderComplete},i.mustRenderOnInteracting=function(){return!this._painted},i.setToRedraw=function(){return this._toRedraw=!0,this},i.setCanvasUpdated=function(){return this._canvasUpdated=!0,this},i.isCanvasUpdated=function(){return!!this._canvasUpdated},i.remove=function(){this.onRemove(),delete this._loadingResource,delete this.southWest,delete this.canvas,delete this.context,delete this.canvasExtent2D,delete this._extent2D,this.resources&&this.resources.remove(),delete this.resources,delete this.layer},i.onRemove=function(){},i.onAdd=function(){},i.getMap=function(){return this.layer?this.layer.getMap():null},i.getCanvasImage=function(){var t=this.getMap();if(this._canvasUpdated=!1,this._renderZoom!==t.getZoom()||!this.canvas||!this._extent2D)return null;if(this.isBlank())return null;if(this.layer.isEmpty&&this.layer.isEmpty())return null;var e=t._pointToContainerPoint(this.southWest)._add(0,-t.height);return{image:this.canvas,layer:this.layer,point:e}},i.clear=function(){this.clearCanvas()},i.isBlank=function(){return!this._painted},i.show=function(){this.setToRedraw()},i.hide=function(){this.clear(),this.setToRedraw()},i.setZIndex=function(){this.setToRedraw()},i.hitDetect=function(t){if(!this.context||this.layer.isEmpty&&this.layer.isEmpty()||this.isBlank()||this._errorThrown||this.layer.isVisible&&!this.layer.isVisible())return!1;var e=this.getMap(),i=e.getDevicePixelRatio(),n=e.getSize();if(t.x<0||t.x>n.width*i||t.y<0||t.y>n.height*i)return!1;var r=this.getImageData&&this.getImageData();if(r){var o=Math.round(i*t.x),s=Math.round(i*t.y)*r.width*4+4*o;return r.data[s+3]>0}try{if(this.context.getImageData(i*t.x,i*t.y,1,1).data[3]>0)return!0}catch(t){return this._errorThrown||(console&&console.warn("hit detect failed with tainted canvas, some geometries have external resources in another domain:\n",t),this._errorThrown=!0),!1}return!1},i.loadResources=function(t){this.resources||(this.resources=new jr);var e=this.resources,i=[];if(te(t))for(var n={},r=t.length-1;r>=0;r--){var o=t[r];o&&o.length&&!n[o.join("-")]&&(n[o.join("-")]=1,e.isResourceLoaded(o,!0)||i.push(new En(this._promiseResource(o))))}return En.all(i)},i.prepareRender=function(){delete this._renderComplete;var t=this.getMap();this._renderZoom=t.getZoom(),this.canvasExtent2D=this._extent2D=t._get2DExtent(),this.southWest=t._containerPointToPoint(new Bt(0,t.height))},i.createCanvas=function(){if(!this.canvas){var t=this.getMap(),e=t.getSize(),i=t.getDevicePixelRatio(),n=Math.round(i*e.width),r=Math.round(i*e.height);if(this.layer._canvas){var o=this.layer._canvas;o.width=n,o.height=r,o.style&&(o.style.width=e.width+"px",o.style.height=e.height+"px"),this.canvas=this.layer._canvas}else this.canvas=wn.createCanvas(n,r,t.CanvasClass);this.onCanvasCreate()}},i.onCanvasCreate=function(){},i.createContext=function(){if(!(this.gl&&this.gl.canvas===this.canvas||this.context)&&(this.context=wn.getCanvas2DContext(this.canvas),this.context)){this.layer.options.globalCompositeOperation&&(this.context.globalCompositeOperation=this.layer.options.globalCompositeOperation);var t=this.getMap().getDevicePixelRatio();1!==t&&this.context.scale(t,t)}},i.resetCanvasTransform=function(){if(this.context){var t=this.getMap().getDevicePixelRatio();this.context.setTransform(t,0,0,t,0,0)}},i.resizeCanvas=function(t){var e=this.canvas;if(e){var i=t||this.getMap().getSize(),n=this.getMap().getDevicePixelRatio(),r=_e(i,n),o=r.width,s=r.height,a=r.cssWidth,h=r.cssHeight;!this.layer._canvas||e.style.width===a&&e.style.height===h||(e.style.width=a,e.style.height=h),e.width===o&&e.height===s||(e.height=s,e.width=o,1!==n&&this.context&&this.context.scale(n,n))}},i.clearCanvas=function(){if(this.context&&this.getMap()){var t=1/this.getMap().getDevicePixelRatio(),e=this.canvas.width*t,i=this.canvas.height*t;wn.clearRect(this.context,0,0,Math.max(e,this.canvas.width),Math.max(i,this.canvas.height))}},i.prepareCanvas=function(){this.canvas?(this.resetCanvasTransform(),this.clearCanvas(),this.resizeCanvas()):(this.createCanvas(),this.createContext(),this.layer.onCanvasCreate(),this.layer.fire("canvascreate",{context:this.context,gl:this.gl})),delete this._maskExtent;var t=this.layer.getMask();if(!t)return this.layer.fire("renderstart",{context:this.context,gl:this.gl}),null;var e=this._maskExtent=t._getMaskPainter().get2DExtent();return e.intersects(this._extent2D),this.layer.fire("renderstart",{context:this.context,gl:this.gl}),e},i.clipCanvas=function(t){var e=this.layer.getMask();if(!e)return!1;var i=this.southWest,n=this.getMap();this.southWest=n._containerPointToPoint(new Bt(0,n.height)),t.save();var r=n.getDevicePixelRatio();if(1!==r&&(t.save(),t.scale(r,r)),e.getGeometries){t.isMultiClip=!0;var o=e.getGeometries()||[];t.beginPath(),o.forEach((function(e){e._getMaskPainter().paint(null,t)})),t.stroke(),t.isMultiClip=!1}else{t.isClip=!0,t.beginPath(),e._getMaskPainter().paint(null,t),t.isClip=!1}return 1!==r&&t.restore(),t.clip(),this.southWest=i,!0},i.getViewExtent=function(){return{extent:this._extent2D,maskExtent:this._maskExtent,zoom:this._renderZoom,southWest:this.southWest}},i.completeRender=function(){this.getMap()&&(this._renderComplete=!0,this.layer.fire("renderend",{context:this.context,gl:this.gl}),this.setCanvasUpdated())},i.getEvents=function(){return{_zoomstart:this.onZoomStart,_zooming:this.onZooming,_zoomend:this.onZoomEnd,_resize:this.onResize,_movestart:this.onMoveStart,_moving:this.onMoving,_moveend:this.onMoveEnd,_dragrotatestart:this.onDragRotateStart,_dragrotating:this.onDragRotating,_dragrotateend:this.onDragRotateEnd,_spatialreferencechange:this.onSpatialReferenceChange}},i.onZoomStart=function(){},i.onZoomEnd=function(){this.setToRedraw()},i.onZooming=function(){},i.onMoveStart=function(){},i.onMoving=function(){},i.onMoveEnd=function(){this.setToRedraw()},i.onResize=function(){delete this._extent2D,this.resizeCanvas(),this.setToRedraw()},i.onDragRotateStart=function(){},i.onDragRotating=function(){},i.onDragRotateEnd=function(){this.setToRedraw()},i.onSpatialReferenceChange=function(){},i.getDrawTime=function(){return this._drawTime},i._tryToDraw=function(t){this._toRedraw=!1,!this.canvas&&this.layer.isEmpty&&this.layer.isEmpty()?this._renderComplete=!0:this._drawAndRecord(t)},i._drawAndRecord=function(t){if(this.getMap()){var e=this._painted;this._painted=!0;var i=B();this.draw(t),i=B()-i,this._drawTime=e?i:i/2,e&&this.layer&&this.layer.options.logDrawTime&&console.log(this.layer.getId(),"frameTimeStamp:",t,"drawTime:",this._drawTime)}},i._promiseResource=function(t){var e=this,i=this.resources,n=this.layer.options.crossOrigin,r=this.layer.options.renderer||"";return function(o){if(i.isResourceLoaded(t,!0))o(t);else if(!Nt(t[0])&&e._resWorkerConn){var s=ge(t[0]);e._resWorkerConn.fetchImage(s,(function(i,n){if(i)return i&&"undefined"!=typeof console&&console.warn(i),void o(t);me(n,(function(i){e._cacheResource(t,i),o(t)}))}))}else{var a=new Image;H(n)?"canvas"!==r&&(a.crossOrigin=""):a.crossOrigin=n,Nt(t[0])&&!Q&&(t[1]&&(t[1]*=2),t[2]&&(t[2]*=2)),a.onload=function(){e._cacheResource(t,a),o(t)},a.onabort=function(e){console&&console.warn("image loading aborted: "+t[0]),e&&console&&console.warn(e),o(t)},a.onerror=function(e){e&&"undefined"!=typeof console&&console.warn(e),i.markErrorResource(t),o(t)},Ht(a,t)}}},i._cacheResource=function(t,e){if(this.layer&&this.resources){var i=t[1],n=t[2];if(this.layer.options.cacheSvgOnCanvas&&1===Nt(t[0])&&(Ot.edge||Ot.ie)){H(i)&&(i=e.width||this.layer.options.defaultIconSize[0]),H(n)&&(n=e.height||this.layer.options.defaultIconSize[1]);var r=wn.createCanvas(i,n);wn.image(r.getContext("2d"),e,0,0,i,n),e=r}this.resources.addResource(t,e)}},e}(Ln),jr=function(){function t(){this.resources={},this._errors={}}var e=t.prototype;return e.addResource=function(t,e){var i=this;if(this.resources[t[0]]={image:e,width:+t[1],height:+t[2],refCnt:0},e&&!e.close&&Ot.imageBitMap&&!Ot.safari&&!Ot.iosWeixin){if(e.src&&Nt(e.src))return;createImageBitmap(e).then((function(e){i.resources[t[0]]&&(i.resources[t[0]].image=e)}))}},e.isResourceLoaded=function(t,e){if(!t)return!1;var i=this._getImgUrl(t);if(this._errors[i])return!0;var n=this.resources[i];return!!n&&!(e&&Nt(t[0])&&(+t[1]>n.width||+t[2]>n.height))},e.login=function(t){var e=this.resources[t];e&&e.refCnt++},e.logout=function(t){var e=this.resources[t];e&&e.refCnt--<=0&&delete this.resources[t]},e.getImage=function(t){var e=this._getImgUrl(t);return!this.isResourceLoaded(t)||this._errors[e]?null:this.resources[e].image},e.markErrorResource=function(t){this._errors[this._getImgUrl(t)]=1},e.merge=function(t){if(!t)return this;for(var e in t.resources){var i=t.resources[e];this.addResource([e,i.width,i.height],i.image)}return this},e.forEach=function(t){if(!this.resources)return this;for(var e in this.resources)q(this.resources,e)&&t(e,this.resources[e]);return this},e._getImgUrl=function(t){return Array.isArray(t)?t[0]:t},e.remove=function(){for(var t in this.resources){var e=this.resources[t];e&&e.image&&e.image.close&&e.image.close()}this.resources={}},t}();Ot.decodeImageInWorker&&Mr(Fr,(function(){return"\nfunction (exports) {\n exports.onmessage = function (msg, postResponse) {\n var url = msg.data.url;\n var fetchOptions = msg.data.fetchOptions;\n requestImageOffscreen(url, function (err, data) {\n var buffers = [];\n if (data && data.data) {\n buffers.push(data.data);\n }\n postResponse(err, data, buffers);\n }, fetchOptions);\n };\n\n var offCanvas, offCtx;\n function requestImageOffscreen(url, cb, fetchOptions) {\n if (!offCanvas) {\n offCanvas = new OffscreenCanvas(2, 2);\n offCtx = offCanvas.getContext('2d',{willReadFrequently: true });\n }\n fetch(url, fetchOptions ? fetchOptions : {})\n .then(response => response.blob())\n .then(blob => createImageBitmap(blob))\n .then(bitmap => {\n // var { width, height } = bitmap;\n // offCanvas.width = width;\n // offCanvas.height = height;\n // offCtx.drawImage(bitmap, 0, 0);\n // bitmap.close();\n // var imgData = offCtx.getImageData(0, 0, width, height);\n // debugger\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects#supported_objects\n cb(null, {data:bitmap});\n }).catch(err => {\n console.warn('error when loading tile:', url);\n console.warn(err);\n cb(err);\n });\n }\n}"}));var Gr={markerWidth:10,markerHeight:10,markerLineWidth:1};var Ur=new Bt(0,0);function Vr(t,e,i,n,r,o,s){var a,h,l,c,u,d,p=Ur.set(e,i),f=t.set(p.x,p.y,p.x+o,p.y+s);return f._add(r),n&&(h=n,l=(a=f).xmin,c=a.ymin,u=a.xmax,d=a.ymax,Kr.set(l,c,u,d),Kr.convertTo((function(t){return t._rotate(h)}),a)),f}var Wr=[];function Zr(t,e,i){var n=Jr(e,(i=i||Qr(Wr,e))[0],i[1]);return Vr(t,e.markerDx||0,e.markerDy||0,$r(e),n,i[0],i[1])}function qr(t){return"rectangle"===t?"right":"middle"}function Xr(t){return"bar"===t||"pie"===t||"pin"===t?"top":"rectangle"===t?"bottom":"middle"}var Yr=new si(0,0);function Jr(t,e,i){var n=2*(t.shadowBlur||0)+.5;Yr.width=e,Yr.height=i;var r=t.markerType,o=yi(Yr,t.markerHorizontalAlignment||qr(r),t.markerVerticalAlignment||Xr(r));return o.x!==-e/2&&(o.x-=Yt(o.x+e/2)*n),o.y!==-i/2&&(o.y-=Yt(o.y+i/2)*n),o}function Qr(t,e){var i=Xt(e.markerWidth,Gr.markerWidth),n=Xt(e.markerHeight,Gr.markerHeight),r=Xt(e.markerLineWidth,Gr.markerLineWidth),o=2*((e.shadowBlur||0)+Math.max(Math.abs(e.shadowOffsetX||0)+Math.abs(e.shadowOffsetY||0))),s=Math.round(i+r+o+1),a=Math.round(n+r+o+1);return t[0]=s,t[1]=a,t}var Kr=new er;function $r(t,e){void 0===e&&(e="markerRotation");var i=t[e];return j(i)?-i*Math.PI/180:0}function to(t,e,i){var n=e.markerFile,r=i?i.getImage(n):null,o=e.markerWidth||(r?r.width:0),s=e.markerHeight||(r?r.height:0);Yr.width=o,Yr.height=s;var a=yi(Yr,e.markerHorizontalAlignment||"middle",e.markerVerticalAlignment||"top");return Vr(t,e.markerDx||0,e.markerDy||0,$r(e),a,o,s)}function eo(t,e,i){var n=i.size,r=yi(n,e.textHorizontalAlignment,e.textVerticalAlignment);if(e.textHaloRadius){var o=e.textHaloRadius;n=n.add(2*o,2*o)}return Vr(t,e.textDx||0,e.textDy||0,$r(e,"textRotation"),r,n.width,n.height)}var io=new er;function no(t,e,i,n){var r=t||new er;if(Array.isArray(e)){for(var o=e,s=0;s<o.length;s++)no(r,o[s],i,n[s]);return r}return ro(e)&&r._combine(eo(io,e,n)),oo(e)&&r._combine(to(io,e,i)),so(e)&&r._combine(Zr(io,e)),ao(e)&&r._combine(to(io,e)),r}function ro(t){return!!t&&!H(t.textName)}function oo(t){return!!t&&!H(t.markerFile)}function so(t){return!!t&&!(!H(t.markerFile)||H(t.markerType)||"path"===t.markerType)}function ao(t){return!!t&&!(!H(t.markerFile)||"path"!==t.markerType)}var ho,lo=["markerWidth","markerHeight","markerHorizontalAlignment","markerVerticalAlignment","markerDx","markerDy","textName","textSize","textDx","textDy","textVerticalAlignment","textHorizontalAlignment","textRotation"],co=["textName","markerType","markerFile","textHaloRadius","shadowBlur","shadowOffsetX","shadowOffsetY","textWrapWidth"];function uo(t,e,i,n){for(var r,o=[],s=0,a=0,h=t.length;a<h-1;a++)(r=po(t[a],t[a+1],e,a,i,n))&&(o[s]=o[s]||[],o[s].push({point:r[0],index:a}),r[1]===t[a+1]&&a!==h-2||(o[s].push({point:r[1],index:a+1}),s++));return o}function po(t,e,i,n,r,o){var s,a,h,l=n?ho:go(t,i),c=go(e,i);for(ho=c;;){if(!(l|c))return[t,e];if(l&c)return!1;if(o)return[t,e];h=go(a=mo(t,e,s=l||c,i,r),i),s===l?(t=a,l=h):(e=a,c=h)}}function fo(t,e,i){var n,r,o,s,a,h,l,c,u,d=[1,4,2,8];for(r=0,l=t.length;r<l;r++)t[r]._code=go(t[r],e);for(s=0;s<4;s++){for(c=d[s],n=[],r=0,o=(l=t.length)-1;r<l;o=r++)a=t[r],h=t[o],a._code&c?h._code&c||((u=mo(h,a,c,e,i))._code=go(u,e),n.push(u)):(h._code&c&&((u=mo(h,a,c,e,i))._code=go(u,e),n.push(u)),n.push(a));t=n}return t}function mo(t,e,i,n,r){var o,s,a=e.x-t.x,h=e.y-t.y,l=n.getMin(),c=n.getMax();8&i?(o=t.x+a*(c.y-t.y)/h,s=c.y):4&i?(o=t.x+a*(l.y-t.y)/h,s=l.y):2&i?(o=c.x,s=t.y+h*(c.x-t.x)/a):1&i&&(o=l.x,s=t.y+h*(l.x-t.x)/a);var u=new Bt(o,s);return r&&u._round(),u}function go(t,e){var i=0;return t.x<e.getMin().x?i|=1:t.x>e.getMax().x&&(i|=2),t.y<e.getMin().y?i|=4:t.y>e.getMax().y&&(i|=8),i}function vo(t,e,i,n){t=new Bt(t);var r,o,s,a=Math.abs(i.x-e.x),h=Math.abs(i.y-e.y),l=Math.sqrt(Math.abs(a*a-h*h));return a>=h?(r=new Bt(e.x-l,e.y),o=new Bt(e.x+l,e.y),s=2*a):(r=new Bt(e.x,e.y-l),o=new Bt(e.x,e.y+l),s=2*h),t.distanceTo(r)+t.distanceTo(o)<=s+2*n}var yo=function(){function t(){}var e=t.prototype;return e.getMap=function(){return this.geometry.getMap()},e.getPainter=function(){return this.painter},e.isDynamicSize=function(){return!1},t.testColor=function(t){return!(!t||!V(t))&&z.indexOf(t)>=0},t}(),_o=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i._prepareContext=function(t){if(Oe(this.symbol.opacity)?this._opacityFn||(this._opacityFn=Ie(this.symbol.opacity)):delete this._opacityFn,j(this.symbol.opacity))t.globalAlpha!==this.symbol.opacity&&(t.globalAlpha=this.symbol.opacity);else if(this._opacityFn){var e=this.getMap();t.globalAlpha=this._opacityFn(e.getZoom())}else 1!==t.globalAlpha&&(t.globalAlpha=1)},i.prepareCanvas=function(t,e,i){t.setLineDash&&te(e.lineDasharray)&&t.setLineDash(e.lineDasharray);var n=this.getPainter().isHitTesting();wn.prepareCanvas(t,e,i,n)},i.remove=function(){},i.setZIndex=function(){},i.show=function(){},i.hide=function(){},i._defineStyle=function(t){return ti(t,this.geometry)},e}(yo);function xo(t,e,i,n){var r,o=wo(i),s=i,a=s.markerType.toLowerCase(),h=bo(a,s.markerWidth,s.markerHeight),l=o.lineOpacity,c=o.polygonOpacity;Mi(o.polygonFill)&&(Mi(o.polygonFill)&&(r||(r=function(t,e,i){var n=new er;return n._combine(t),n.xmin+=-e/2,n.ymin+=-i/2,n.xmax+=e/2,n.ymax+=i/2,n}(e,s.markerWidth,s.markerHeight)),o.polygonGradientExtent=r));wn.prepareCanvas(t,o,n);var u=s.markerWidth,d=s.markerHeight,p=s.markerLineWidth/2;if("ellipse"===a)wn.ellipse(t,e,u/2,d/2,d/2,l,c);else if("cross"===a||"x"===a){for(var f=h.length-1;f>=0;f--)h[f]._add(e);wn.path(t,h.slice(0,2),l),wn.path(t,h.slice(2,4),l)}else if("diamond"===a||"bar"===a||"square"===a||"rectangle"===a||"triangle"===a){"bar"===a?e=e.add(0,-p):"rectangle"===a&&(e=e.add(p,p));for(var m=h.length-1;m>=0;m--)h[m]._add(e);wn.polygon(t,h,l,c)}else if("pin"===a){e=e.add(0,-p);for(var g=h.length-1;g>=0;g--)h[g]._add(e);var v=t.lineCap;t.lineCap="round",wn.bezierCurveAndFill(t,h,l,c),t.lineCap=v}else{if("pie"!==a)throw new Error("unsupported markerType: "+a);e=e.add(0,-p);var y=180*Math.atan(u/2/d)/Math.PI,_=t.lineCap;t.lineCap="round",wn.sector(t,e,d,[90-y,90+y],l,c),t.lineCap=_}return t.canvas}function wo(t){var e={lineColor:t.markerLineColor,linePatternFile:t.markerLinePatternFile,lineWidth:t.markerLineWidth,lineOpacity:t.markerLineOpacity,lineDasharray:t.markerLineDasharray,lineCap:"butt",lineJoin:"round",polygonFill:t.markerFill,polygonPatternFile:t.markerFillPatternFile,polygonOpacity:t.markerFillOpacity};return 0===e.lineWidth&&(e.lineOpacity=0),e}function bo(t,e,i){var n,r,o,s,a=i/2,h=e/2;if("triangle"===t)return[n=new Bt(0,0-a),r=new Bt(0-h,0+a),o=new Bt(0+h,0+a)];if("cross"===t)return[n=new Bt(0-h,0),r=new Bt(0+h,0),o=new Bt(0,0-a),s=new Bt(0,0+a)];if("diamond"===t)return[n=new Bt(0-h,0),r=new Bt(0,0-a),o=new Bt(0+h,0),s=new Bt(0,0+a)];if("square"===t)return[n=new Bt(0-h,0+a),r=new Bt(0+h,0+a),o=new Bt(0+h,0-a),s=new Bt(0-h,0-a)];if("rectangle"===t)return r=(n=new Bt(0,0)).add(e,0),o=n.add(e,i),s=n.add(0,i),[n,r,o,s];if("x"===t)return[n=new Bt(0-h,0+a),r=new Bt(0+h,0-a),o=new Bt(0+h,0+a),s=new Bt(0-h,0-a)];if("bar"===t)return[n=new Bt(0-h,0-i),r=new Bt(0+h,0-i),o=new Bt(0+h,0),s=new Bt(0-h,0)];if("pin"===t||"pie"===t){var l=i*Math.atan(h/a);return[n=new Bt(0,0),r=new Bt(0-l,0-i),o=new Bt(0+l,0-i),s=new Bt(0,0)]}return[]}var Mo,So=new Bt(0,0),To=new Bt(0,0),Eo=new Bt(0,0),Co=new Bt(0,0),Po=function(t){function e(e,i,n){var r;return(r=t.call(this)||this).symbol=e,r.geometry=i,r.painter=n,r}Dt(e,t);var i=e.prototype;return i.get2DExtent=function(){for(var t=this.getMap(),e=t.getGLRes(),i=new er,n=this._getRenderPoints()[0],r=n.length-1;r>=0;r--)n[r]&&i._combine(t._pointAtResToPoint(n[r],e));return i},i.isDynamicSize=function(){var t=this.symbol;return Oe(t.markerWidth)||Oe(t.markerHeight)||Oe(t.textSize)},i._rotateExtent=function(t,e){return t.convertTo((function(t){return t._rotate(e)}))},i._getRenderPoints=function(){var t=this.getPainter().isSpriting()?"center":this.getPlacement();return this.getPainter().getRenderPoints(t)},i._getRenderContainerPoints=function(t){var e=this.getPainter();if(e.isSpriting())return this._getRenderPoints()[0];var i,n=this.geometry,r=this.getDxDy();if(n._cPoint&&!t){var o=t?Eo:Co;o.set(n._cPoint.x,n._cPoint.y);var s=e.containerOffset;o._sub(s);var a=r.x,h=r.y;(a||h)&&o._add(a||0,h||0),i=[o]}else{var l=this._getRenderPoints()[0];i=this.painter._pointContainerPoints(l,r.x,r.y,t,!0,this.getPlacement())}if(!i||!Array.isArray(i[0]))return i;for(var c=[],u=0,d=i.length;u<d;u++)for(var p=0,f=i[u].length;p<f;p++)c.push(i[u][p]);return c},i.getPlacement=function(){return this.symbol.markerPlacement},i.getRotation=function(){return $r(this.style)},i.getDxDy=function(){var t=this.style,e=t.markerDx,i=t.markerDy;return new Bt(e,i)},i._getRotationAt=function(t){var e=this.getRotation();e||(e=0);var i=this._getRenderPoints()[1];if(!i||!i[t])return e;var n=this.getMap(),r=i[t][0],o=i[t][1];if(n.isTransforming()){var s=n.getGLRes();return r=n._pointAtResToContainerPoint(i[t][0],s,0,So),o=n._pointAtResToContainerPoint(i[t][1],s,0,To),e+le(r.x,r.y,o.x,o.y)}return e+-le(r.x,r.y,o.x,o.y)},i._rotate=function(t,e,i){if(i){var n=this.getDxDy(),r=e.sub(n);return t.save(),t.translate(r.x,r.y),t.rotate(i),n}return null},e}(_o),Ao=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.getPlacement=function(){return"point"},i.getDxDy=function(){return new Bt(0,0)},i.symbolize=function(t){var e=this.geometry,i=e.getLayer();if(e.options.debug||!i||i.options.debug){var n=this.getMap();if(n&&!n.isZooming()){var r=i.options.debugOutline;t.strokeStyle=r,t.fillStyle=r;var o=e.getContainerExtent().toArray();wn.polygon(t,[o],1,0);for(var s=this._getRenderContainerPoints(),a=this.geometry.getId(),h=bo("cross",10,10),l=0;l<s.length;l++){var c=s[l];H(a)||wn.fillText(t,a,c.add(8,-4),r);for(var u=[],d=0;d<h.length;d++)u.push(h[d].add(c));wn.path(t,u.slice(0,2),1),wn.path(t,u.slice(2,4),1)}}}},e}(Po),Lo=new si(1,1),Ro=function(t){function e(e,i,n){var r;return(r=t.call(this,e,i,n)||this).style=r._defineStyle(r.translate()),r}Dt(e,t),e.test=function(t){return oo(t)};var i=e.prototype;return i.symbolize=function(t,e){var i=this.style;if(this.painter.isHitTesting()||0!==i.markerWidth&&0!==i.markerHeight&&0!==i.markerOpacity){var n=this._getRenderContainerPoints();if(te(n)){var r=this._getImage(e);if(r){this._prepareContext(t);var o,s=i.markerWidth,a=i.markerHeight;if(!j(s)||!j(a)){s=r.width,a=r.height,i.markerWidth=s,i.markerHeight=a;var h=i.markerFile;e.isResourceLoaded(h)||e.addResource(h,r);var l=this.getPainter();l.isSpriting()||l.removeCache()}"path"!==this.symbol.markerType&&j(i.markerOpacity)&&i.markerOpacity<1&&(o=t.globalAlpha,t.globalAlpha*=i.markerOpacity),Lo.width=s,Lo.height=a;for(var c=yi(Lo,i.markerHorizontalAlignment,i.markerVerticalAlignment),u=0,d=n.length;u<d;u++){var p=n[u],f=this.getRotation()?this._rotate(t,p,this._getRotationAt(u)):null;f&&(p=f),wn.image(t,r,p.x+c.x,p.y+c.y,s,a),f&&t.restore()}void 0!==o&&(t.globalAlpha=o)}else"undefined"!=typeof console&&console.warn("no img found for "+(this.style.markerFile||this._url[0]))}}},i._getImage=function(t){return function(t,e){return t&&t.getImage(e)||null}(t,this.style.markerFile)},i.getFixedExtent=function(t){return this._fixedExtent=this._fixedExtent||new er,to(this._fixedExtent,this.style,t)},i.translate=function(){var t=this.symbol;return{markerFile:t.markerFile,markerOpacity:Xt(t.markerOpacity,1),markerWidth:Xt(t.markerWidth,null),markerHeight:Xt(t.markerHeight,null),markerRotation:Xt(t.markerRotation,0),markerDx:Xt(t.markerDx,0),markerDy:Xt(t.markerDy,0),markerHorizontalAlignment:Xt(t.markerHorizontalAlignment,"middle"),markerVerticalAlignment:Xt(t.markerVerticalAlignment,"top")}},e}(Po),Oo=new Hn(0,0),Do=new Hn(0,0),Io=function(t){function e(e,i,n){var r;return(r=t.call(this)||this).symbol=e,r.geometry=i,r.painter=n,"Point"===i.type?It(r):(r.style=r._defineStyle(r.translate()),r)}Dt(e,t),e.test=function(t,e){if(!t)return!1;if(e&&"Point"===e.type)return!1;for(var i in t){var n=i.slice(0,4);if("line"===n||"poly"===n)return!0}return!1};var i=e.prototype;return i.symbolize=function(t,e){var i=this.style;if(0!==i.polygonOpacity||0!==i.lineOpacity||this.painter.isHitTesting()){var n=this._getPaintParams();if(n){this._prepareContext(t);var r=Mi(i.lineColor),o="Polygon"===this.geometry.getJSONType()||"LineString"===this.geometry.type;!r||!i.lineColor.places&&o||(i.lineGradientExtent=this.geometry.getContainerExtent()._expand(i.lineWidth)),Mi(i.polygonFill)&&(i.polygonGradientExtent=this.geometry.getContainerExtent());var s=n[0];if("Polygon"===this.geometry.getJSONType()&&s.length>0&&Array.isArray(s[0][0])||"LineString"===this.geometry.type&&s.length>0&&Array.isArray(s[0]))for(var a=0;a<s.length;a++){this.prepareCanvas(t,i,e),r&&o&&!i.lineColor.places&&this._createGradient(t,s[a],i.lineColor);var h=[t,s[a]];n.length>1&&h.push.apply(h,n.slice(1)),h.push(i.lineOpacity,i.polygonOpacity,i.lineDasharray),this.geometry._paintOn.apply(this.geometry,h)}else{this.prepareCanvas(t,i,e),r&&o&&!i.lineColor.places&&this._createGradient(t,s,i.lineColor);var l=[t];l.push.apply(l,n),l.push(i.lineOpacity,i.polygonOpacity,i.lineDasharray),this.geometry._paintOn.apply(this.geometry,l)}t.setLineDash&&Array.isArray(i.lineDasharray)&&t.setLineDash([])}}},i.get2DExtent=function(){var t=this.getMap(),e=this.geometry._getPrjExtent();if(!e)return null;this._extMin&&this._extMax||(this._extMin=new Hn(0,0),this._extMax=new Hn(0,0)),this._extMin.x=e.xmin,this._extMin.y=e.ymin,this._extMax.x=e.xmax,this._extMax.y=e.ymax;var i=t._prjToPoint(this._extMin,void 0,Oo),n=t._prjToPoint(this._extMax,void 0,Do);return this._pxExtent?this._pxExtent.set(Math.min(i.x,n.x),Math.min(i.y,n.y),Math.max(i.x,n.x),Math.max(i.y,n.y)):this._pxExtent=new er(i,n),this._pxExtent},i.getFixedExtent=function(){var t=this.style.lineWidth/2;return new er(-t,-t,t,t)},i._getPaintParams=function(){return this.getPainter().getPaintParams(this.style.lineDx,this.style.lineDy)},i.translate=function(){var t=this.symbol,e={lineColor:Xt(t.lineColor,"#000"),lineWidth:Xt(t.lineWidth,2),lineOpacity:Xt(t.lineOpacity,1),lineDasharray:Xt(t.lineDasharray,[]),lineCap:Xt(t.lineCap,"butt"),lineJoin:Xt(t.lineJoin,"miter"),linePatternFile:Xt(t.linePatternFile,null),lineDx:Xt(t.lineDx,0),lineDy:Xt(t.lineDy,0),polygonFill:Xt(t.polygonFill,null),polygonOpacity:Xt(t.polygonOpacity,1),polygonPatternFile:Xt(t.polygonPatternFile,null),polygonPatternDx:Xt(t.polygonPatternDx,0),polygonPatternDy:Xt(t.polygonPatternDy,0),linePatternDx:Xt(t.linePatternDx,0),linePatternDy:Xt(t.linePatternDy,0)};return 0===e.lineWidth&&(e.lineOpacity=0),"LineString"!==this.geometry.type||e.polygonFill||(e.polygonFill=e.lineColor),e},i._createGradient=function(t,e,i){if(Array.isArray(e)&&e.length){var n=e.length,r=t.createLinearGradient(e[0].x,e[0].y,e[n-1].x,e[n-1].y);i.colorStops.forEach((function(t){r.addColorStop.apply(r,t)})),t.strokeStyle=r}},e}(_o),ko=function(t){function e(e,i,n){var r,o=(r=t.call(this,e,i,n)||this).translate();return r._dynamic=De(o),r.style=r._defineStyle(o),0===r.style.textWrapWidth?It(r):(r.strokeAndFill=r._defineStyle(r.translateLineAndFill(r.style)),r)}Dt(e,t),e.test=function(t){return ro(t)};var i=e.prototype;return i.symbolize=function(t,e){if(this.painter.isHitTesting()||0!==this.style.textSize&&(this.style.textOpacity||this.style.textHaloRadius&&this.style.textHaloOpacity)&&0!==this.style.textWrapWidth){var i=this._getRenderContainerPoints();if(te(i)){var n=this.style,r=this.strokeAndFill,o=gi(this.style.textName,this.geometry.getProperties());this._dynamic&&delete this._textDesc;var s=this._textDesc=this._textDesc||vi(o,this.style);this._prepareContext(t),this.prepareCanvas(t,r,e),wn.prepareCanvasFont(t,n);for(var a=0,h=i.length;a<h;a++){var l=i[a],c=this.getRotation()?this._rotate(t,l,this._getRotationAt(a)):null;c&&(l=c),wn.text(t,o,l,n,s),c&&t.restore()}}}},i.getPlacement=function(){return this.symbol.textPlacement},i.getRotation=function(){var t=this.style.textRotation;return j(t)?-t*Math.PI/180:null},i.getDxDy=function(){var t=this.style;return new Bt(t.textDx,t.textDy)},i.getFixedExtent=function(){var t=this.geometry.getTextDesc();return Array.isArray(t)&&(t=t[this._index]),this._fixedExtent=this._fixedExtent||new er,t?eo(this._fixedExtent,this.style,t):this._fixedExtent},i.translate=function(){var t=this.symbol,e={textName:t.textName,textFaceName:Xt(t.textFaceName,"monospace"),textWeight:Xt(t.textWeight,"normal"),textStyle:Xt(t.textStyle,"normal"),textSize:Xt(t.textSize,F),textFont:Xt(t.textFont,null),textFill:Xt(t.textFill,"#000"),textOpacity:Xt(t.textOpacity,1),textHaloFill:Xt(t.textHaloFill,"#ffffff"),textHaloRadius:Xt(t.textHaloRadius,0),textHaloOpacity:Xt(t.textHaloOpacity,1),textWrapWidth:Xt(t.textWrapWidth,null),textWrapCharacter:Xt(t.textWrapCharacter,"\n"),textLineSpacing:Xt(t.textLineSpacing,0),textDx:Xt(t.textDx,0),textDy:Xt(t.textDy,0),textHorizontalAlignment:Xt(t.textHorizontalAlignment,"middle"),textVerticalAlignment:Xt(t.textVerticalAlignment,"middle"),textAlign:Xt(t.textAlign,"center"),textRotation:Xt(t.textRotation,0),textMaxWidth:Xt(t.textMaxWidth,0),textMaxHeight:Xt(t.textMaxHeight,0)};return e.textMaxWidth>0&&(!e.textWrapWidth||e.textWrapWidth>e.textMaxWidth)&&(e.textWrapWidth||(e.textMaxHeight=1),e.textWrapWidth=e.textMaxWidth),e},i.translateLineAndFill=function(t){return{lineColor:t.textHaloRadius?t.textHaloFill:t.textFill,lineWidth:t.textHaloRadius,lineOpacity:t.textOpacity,lineDasharray:null,lineCap:"butt",lineJoin:"round",polygonFill:t.textFill,polygonOpacity:t.textOpacity}},e}(Po),zo=[],Fo=function(t){function e(e,i,n){var r,o=(r=t.call(this,e,i,n)||this).translate();return r._dynamic=De(o),r.style=r._defineStyle(o),r.strokeAndFill=r._defineStyle(wo(r.style)),r.padding=0,r}Dt(e,t),e.test=function(t){return so(t)};var i=e.prototype;return i.symbolize=function(t,e){var i=this.style;if(this.painter.isHitTesting()||0!==i.markerWidth&&0!==i.markerHeight&&(0!==i.polygonOpacity||0!==i.lineOpacity)){var n=this._getRenderContainerPoints();te(n)&&(this._prepareContext(t),this.getPainter().isSpriting()||this.geometry.getLayer().getMask()===this.geometry||this._dynamic||!1===this.geometry.getLayer().options.cacheVectorOnCanvas?this._drawMarkers(t,n,e):this._drawMarkersWithCache(t,n,e))}},i._drawMarkers=function(t,e,i){for(var n=e.length-1;n>=0;n--){var r=e[n],o=this.getRotation()?this._rotate(t,r,this._getRotationAt(n)):null;o&&(r=o),this._drawVectorMarker(t,r,i),o&&t.restore()}},i._drawMarkersWithCache=function(t,e,i){var n=this._stampSymbol(),r=i.getImage(n);r||(r=this._createMarkerImage(t,i),i.addResource([n,r.width,r.height],r));for(var o=Jr(this.style,r.width,r.height),s=e.length-1;s>=0;s--){var a=e[s],h=this.getRotation()?this._rotate(t,a,this._getRotationAt(s)):null;h&&(a=h),wn.image(t,r,a.x+o.x,a.y+o.y),h&&t.restore()}},i._createMarkerImage=function(t,e){var i=t.canvas.constructor,n=Qr(zo,this.style),r=wn.createCanvas(n[0],n[1],i),o=this._getCacheImageAnchor(n[0],n[1]),s=r.getContext("2d");return this._drawVectorMarker(s,o,e),r},i._stampSymbol=function(){return this._stamp||(this._stamp=bi([this.style.markerType,Mi(this.style.markerFill)?Si(this.style.markerFill):this.style.markerFill,this.style.markerFillOpacity,this.style.markerFillPatternFile,Mi(this.style.markerLineColor)?Si(this.style.markerLineColor):this.style.markerLineColor,this.style.markerLineWidth,this.style.markerLineOpacity,this.style.markerLineDasharray?this.style.markerLineDasharray.join(","):"",this.style.markerLinePatternFile,this.style.markerWidth,this.style.markerHeight,this.style.markerHorizontalAlignment,this.style.markerVerticalAlignment].join("_"))),this._stamp},i._getCacheImageAnchor=function(t,e){var i=2*(this.symbol.shadowBlur||0)+this.padding,n=this.style.markerType;return"bar"===n||"pie"===n||"pin"===n?new Bt(t/2,e-i):"rectangle"===n?new Bt(i,i):new Bt(t/2,e/2)},i._getGraidentExtent=function(t){var e=new er,i=this.getDxDy(),n=this.getFixedExtent();if(Array.isArray(t))for(var r=t.length-1;r>=0;r--)e._combine(t[r]);else e._combine(t);return e.xmin+=n.xmin-i.x,e.ymin+=n.ymin-i.y,e.xmax+=n.xmax-i.x,e.ymax+=n.ymax-i.y,e},i._drawVectorMarker=function(t,e,i){xo(t,e,this.style,i)},i.getFixedExtent=function(){var t=this.isDynamicSize(),e=this.style.markerWidth,i=this.style.markerHeight;return this._fixedExtent=this._fixedExtent||new er,Zr(this._fixedExtent,this.style,t?[128,128*(0===e?1:i/e)]:null)},i.translate=function(){var t=this.symbol,e={markerType:Xt(t.markerType,"ellipse"),markerFill:Xt(t.markerFill,"#00f"),markerFillOpacity:Xt(t.markerFillOpacity,1),markerFillPatternFile:Xt(t.markerFillPatternFile,null),markerLineColor:Xt(t.markerLineColor,"#000"),markerLineWidth:Xt(t.markerLineWidth,Gr.markerLineWidth),markerLineOpacity:Xt(t.markerLineOpacity,1),markerLineDasharray:Xt(t.markerLineDasharray,[]),markerLinePatternFile:Xt(t.markerLinePatternFile,null),markerDx:Xt(t.markerDx,0),markerDy:Xt(t.markerDy,0),markerWidth:Xt(t.markerWidth,Gr.markerWidth),markerHeight:Xt(t.markerHeight,Gr.markerHeight),markerRotation:Xt(t.markerRotation,0),shadowBlur:Xt(t.shadowBlur,0),shadowOffsetX:Xt(t.shadowOffsetX,0),shadowOffsetY:Xt(t.shadowOffsetY,0)},i=e.markerType,n=qr(i),r=Xr(i);return e.markerHorizontalAlignment=Xt(t.markerHorizontalAlignment,n),e.markerVerticalAlignment=Xt(t.markerVerticalAlignment,r),j(t.markerOpacity)&&(j(t.markerFillOpacity)&&(e.markerFillOpacity*=t.markerOpacity),j(t.markerLineOpacity)&&(e.markerLineOpacity*=t.markerOpacity)),e},e}(Po),Bo=function(t){function e(e,i,n){var r;H(e.markerWidth)&&(e.markerWidth=80),H(e.markerHeight)&&(e.markerHeight=80),e=N(e,(r=t.call(this,e,i,n)||this).translate());var o=r.style=r._defineStyle(e);return Ot.gecko?r._url=[ii(o,o.markerWidth,o.markerHeight),o.markerWidth,o.markerHeight]:r._url=[ii(o),o.markerWidth,o.markerHeight],r}Dt(e,t),e.test=function(t){return ao(t)};var i=e.prototype;return i._prepareContext=function(){},i._getImage=function(t){var e=this;if(t&&t.isResourceLoaded(this._url))return t.getImage(this._url);var i=this.painter,n=new Image;return n.onload=function(){var t=i.getLayer()&&i.getLayer().getRenderer();t&&t.setToRedraw()},n.onerror=function(i){i&&"undefined"!=typeof console&&console.warn(i),t.markErrorResource(e._url)},n.src=this._url[0],t&&t.addResource(this._url,n),n},e}(Ro),No={lineWidth:1,polygonFill:"#fff",polygonOpacity:.5},Ho=function(t){function e(e,i,n){var r;return(r=t.call(this,e,i,n)||this).style=i.getLayer().options.drawAltitude,r.style&&U(r.style)||(r.style={lineWidth:2}),r.style.lineWidth||(r.style.lineWidth=0),r.dxdy=r._defineStyle({dx:e.textDx||e.markerDx,dy:e.textDy||e.markerDy}),r}Dt(e,t),e.test=function(t,e){if(!e.getLayer())return!1;var i=e.getJSONType();return"Marker"===i||"LineString"===i};var i=e.prototype;return i.symbolize=function(t){var e=this.geometry.getLayer();if(e.options.drawAltitude){var i=this.geometry.getProperties();if(i&&i[e.options.altitudeProperty]){var n=this._getStyle();if(this._prepareContext(t),"LineString"===this.geometry.type){var r=this._getPaintParams(n.lineDx,n.lineDy,!1,!0);if(!r)return;var o=this.getPainter().getPaintParams(n.lineDx,n.lineDy,!0,!0,"_groundpt")[0];this._drawLineAltitude(t,r[0],o)}else{var s=this._getRenderContainerPoints(),a=this._getRenderContainerPoints(!0);if(!s||0===s.length)return;this._drawMarkerAltitude(t,s[0],a[0])}}}},i.getDxDy=function(){var t=this.dxdy;return new Bt(t.dx||0,t.dy||0)},i.get2DExtent=function(){return"LineString"===this.geometry.type?Io.prototype.get2DExtent.apply(this):t.prototype.get2DExtent.call(this)},i.getPlacement=function(){return"point"},i._getPaintParams=function(t,e){return this.getPainter().getPaintParams(t||0,e||0,null,!0,"_altpt")},i._drawMarkerAltitude=function(t,e,i){var n=this._getStyle();this.prepareCanvas(t,n),wn.path(t,[e,i],n.lineOpacity,null,n.lineDasharray)},i._drawLineAltitude=function(t,e,i){var n=this._getStyle();if(e.length>0&&Array.isArray(e[0]))for(var r=0;r<e.length;r++)this._drawLine(t,e[r],i[r]);else this._drawLine(t,e,i);t.setLineDash&&Array.isArray(n.lineDasharray)&&t.setLineDash([])},i._drawLine=function(t,e,i){var n=this._getStyle();this.prepareCanvas(t,n);for(var r=0,o=e.length-1;r<o;r++)wn.polygon(t,[e[r],e[r+1],i[r+1],i[r]],n.lineOpacity,n.polygonOpacity,n.lineDasharray)},i._getStyle=function(){var t=this.geometry.getLayer().options.drawAltitude;return U(t)||(t=No),t.lineWidth||(t.lineWidth=0,t.lineOpacity=0),t},e}(Po),jo=[Ho,Io,Ro,Bo,Fo,ko],Go=new Bt(0,0),Uo=new er,Vo=new er,Wo=new er,Zo=new er,qo=new er,Xo={},Yo={minx:1/0,miny:1/0,maxx:-1/0,maxy:-1/0},Jo=function(t){function e(e){var i;return(i=t.call(this)||this).geometry=e,i.symbolizers=i._createSymbolizers(),i._altAtGL=i._getGeometryAltitude(),i}Dt(e,t);var i=e.prototype;return i.getMap=function(){return this.geometry.getMap()},i.getLayer=function(){return this.geometry.getLayer()},i._createSymbolizers=function(){var t=this.getSymbol(),e=[],i=jo,n=t;Array.isArray(t)||(n=[t]);for(var r=n.length-1;r>=0;r--)for(var o=n[r],s=i.length-1;s>=0;s--)if(i[s].test(o,this.geometry)){var a=new i[s](o,this.geometry,this);a._index=r,e.push(a),a instanceof Po&&(this._hasPoint=!0)}if(!e.length&&console){var h=this.geometry.getId();console.warn("invalid symbol for geometry("+(this.geometry?this.geometry.getType()+(h?":"+h:""):"")+") to draw : "+JSON.stringify(t))}return this._debugSymbolizer=new Ao(t,this.geometry,this),e},i.hasPoint=function(){return!!this._hasPoint},i.getRenderPoints=function(t){return this._verifyProjection(),this._renderPoints||(this._renderPoints={}),t||(t="center"),this._renderPoints[t]||(this._renderPoints[t]=this.geometry._getRenderPoints(t)),this._renderPoints[t]},i.getPaintParams=function(t,e,i,n,r){void 0===r&&(r="_pt");var o,s,a,h,l,c=this.getLayer()._getRenderer().mapStateCache,u=this.getMap();c&&!this._hitPoint?(o=c.resolution,s=c.pitch,a=c.bearing,h=c.glScale,l=c.containerExtent):(o=u.getResolution(),s=u.getPitch(),a=u.getBearing(),h=u.getGLScale(),l=u.getContainerExtent());var d=this.geometry,p=o,f=0!==s,m=0!==a,g=this._cachedParams,v=d._paintAsPath&&d._paintAsPath();if(v&&this._unsimpledParams&&p<=this._unsimpledParams._res)g=this._unsimpledParams;else if(!g||g._res!==o||this._pitched!==f&&d._redrawWhenPitch()||this._rotated!==m&&d._redrawWhenRotate()){if(!(g=d._getPaintParams()))return null;g._res=p,!d._simplified&&v&&(this._unsimpledParams||(this._unsimpledParams=g),p>this._unsimpledParams._res&&(this._unsimpledParams._res=p)),this._cachedParams=g}if(!g)return null;this._pitched=f,this._rotated=m;var y=h,_=[],x=g[0],w=l,b=this._pointContainerPoints(x,t,e,i,n||this._hitPoint&&!w.contains(this._hitPoint),null,r);if(!b)return null;_.push(b);for(var M=1,S=g.length;M<S;M++)j(g[M])||g[M]instanceof si?j(g[M])?_.push(g[M]/y):_.push(g[M].multi(1/y)):_.push(g[M]);return _},i._pointContainerPoints=function(t,e,i,n,r,o,s){if(void 0===s&&(s="_pt"),this._aboveCamera())return null;var a,h,l,c=this.getLayer()._getRenderer(),u=c.mapStateCache,d=this.getMap(),p=this.geometry,f=this.containerOffset;u?(a=u.glRes,h=u.containerExtent):(a=d.getGLRes(),h=d.getContainerExtent());var m=this.getLayer().options.roundPoint,g=1/0,v=1/0,y=-1/0,_=-1/0,x=!r,w=c.layer.options.clipBBoxBufferSize||3,b=this.symbolizers;function M(t,n){void 0===t&&(t=[]),void 0===n&&(n=[]);for(var r=fe(t,s),o=0,l=(r=d._pointsAtResToContainerPoints(t,a,n,r)).length;o<l;o++){var c=r[o];c._sub(f),(e||i)&&c._add(e||0,i||0),m&&(c.x=Math.ceil(c.x),c.y=Math.ceil(c.y)),g=Math.min(c.x,g),v=Math.min(c.y,v),y=Math.max(c.x,y),_=Math.max(c.y,_)}if(x&&Di(b)){if(qo.ymin=h.ymin,qo.ymin<w&&(qo.ymin=h.ymin-w),qo.xmin=h.xmin-w,qo.xmax=h.xmax+w,qo.ymax=h.ymax+w,p.getShell&&p.getHoles)return fo(r,qo);var u=uo(r,qo,!1);if(u.length){var M=[];return u.forEach((function(t){for(var e=0,i=t.length;e<i;e++)M.push(t[e].point)})),M}}return r}var S=this.getAltitude();if(Array.isArray(t)){var T,E=this.geometry;!r&&E.options.enableClip?(T=this._clip(t,S)).inView&&(x=!1):T={points:t,altitude:S};var C=T.points;S=T.altitude,n&&(S=0);var P=S;l=[];for(var A=[],L=j(S),R=0,O=C.length;R<O;R++){var D=C[R];if(Array.isArray(D)){if(L){var I=M(D,S);l.push(I);continue}for(var k=[],z=0,F=D.length;z<F;z++)Array.isArray(S)&&(P=S[R]?S[R][z]:0),k.push(P);var B=M(D,k);l.push(B)}else Array.isArray(S)&&(P="vertex-last"===o?S[S.length-1-R]:"line"===o?(S[R]+S[R+1])/2:S[R]),A.push(P)}A.length&&(l=M(C,A))}else t instanceof Bt&&(n&&(S=0),l=d._pointAtResToContainerPoint(t,a,S)._sub(f),(e||i)&&l._add(e,i));return Yo.minx=g,Yo.miny=v,Yo.maxx=y,Yo.maxy=_,this._containerBbox=Yo,l},i._clip=function(t,e){if(j(e)&&0!==e)return{points:t,altitude:e};if(Array.isArray(e)){for(var i=!1,n=0,r=e.length;n<r;n++)if(0!==e[n]){i=!0;break}if(i)return{points:t,altitude:e}}var o=this.getMap(),s=this.geometry,a=this.getSymbol().lineWidth;j(a)||(a=4);var h,l,c,u=this.getLayer()._getRenderer().mapStateCache;u?(h=u._2DExtent,l=u.glExtent,c=u.pitch):(h=o._get2DExtent(),l=o._get2DExtentAtRes(o.getGLRes()),c=o.getPitch());var d=h._expand(a);if(c>0&&e){var p=o.cameraLookAt,f=o.cameraPosition;Go.set(f.x,f.y),d=d._combine(Go._add(Yt(p[0]-f[0]),Yt(p[1]-f[1])))}var m=t;if(this.get2DExtent(null,Zo).within(d))return{points:m,altitude:e,inView:!0};var g=l._expand(a*o._glScale);Wo.xmin=g.xmin,Wo.xmax=g.xmax,Wo.ymin=g.ymin,Wo.ymax=g.ymax;var v=s.options.smoothness;if(s.getShell&&this.geometry.getHoles&&!v){var y=g.xmin,_=g.ymin,x=g.xmax,w=g.ymax,b=Math.abs(x-y),M=Math.abs(w-_),S=Math.sqrt(b*b+M*M),T=(S-b)/2,E=(S-M)/2;if(Wo.xmin=g.xmin-T,Wo.xmax=g.xmax+T,Wo.ymin=g.ymin-E,Wo.ymax=g.ymax+E,Array.isArray(t[0])){m=[];for(var C=0;C<t.length;C++){var P=fo(t[C],Wo);P.length&&m.push(P)}}else m=fo(t,Wo)}else if("LineString"===s.getJSONType()&&!v){if(Array.isArray(t[0])){m=[];for(var A=0;A<t.length;A++)Wt(m,uo(t[A],Wo,!1,!!v))}else m=uo(t,Wo,!1,!!v);return this._interpolateSegAlt(m,t,e)}return{points:m,altitude:e}},i._interpolateSegAlt=function(t,e,i){if(!Array.isArray(i)){var n=function(t){return t.point};return{points:t.map((function(t){return Array.isArray(t)?t.map(n):t.point})),altitude:i}}var r=Qo(t,e,i);i=[];var o=r.map((function(t){if(Array.isArray(t)){var e=[],n=t.map((function(t){return e.push(t.altitude),t.point}));return i.push(e),n}return i.push(t.altitude),t.point}));return{points:o,altitude:i}},i.getSymbol=function(){return this.geometry._getInternalSymbol()},i.paint=function(t,e,i){if(this.symbolizers){var n=this.getLayer(),r=n._getRenderer();if(r&&(r.context||e)){var o=r.mapStateCache||{};if(this.geometry._isCheck||!t||t.intersects(this.get2DExtent(r.resources,Uo))){var s=this.getMap(),a=this.getMinAltitude(),h=s.getFrustumAltitude();if(!(a&&h&&h<a)){this.containerOffset=i||o.offset||s._pointToContainerPoint(r.southWest)._add(0,-s.height),this._beforePaint();for(var l=e||r.context,c=[l,r.resources],u=this.symbolizers.length-1;u>=0;u--)(l.shadowBlur||this.symbolizers[u].symbol.shadowBlur)&&this._prepareShadow(l,this.symbolizers[u].symbol),this.symbolizers[u].symbolize.apply(this.symbolizers[u],c);this._afterPaint(),this._painted=!0,(this.geometry.options.debug||n.options.debug)&&this._debugSymbolizer.symbolize.apply(this._debugSymbolizer,c)}}}}},i.getSprite=function(t,e){if("Point"!==this.geometry.type)return null;if(this._spriting=!0,!this._sprite&&this.symbolizers.length>0){var i=new er;this.symbolizers.forEach((function(e){var n=e.getFixedExtent(t);i._combine(n)}));var n,r=i.getMin().multi(-1),o=e||(this.getMap()?this.getMap().CanvasClass:null),s=wn.createCanvas(i.getWidth(),i.getHeight(),o);this._renderPoints&&(n=this._renderPoints);for(var a=s.getContext("2d"),h=[a,t],l=this.symbolizers.length-1;l>=0;l--){var c=this.symbolizers[l].getDxDy();this._renderPoints={center:[[r.add(c)]]},this._prepareShadow(a,this.symbolizers[l].symbol),this.symbolizers[l].symbolize.apply(this.symbolizers[l],h)}n&&(this._renderPoints=n),this._sprite={canvas:s,offset:i.getCenter()}}return this._spriting=!1,this._sprite},i.isSpriting=function(){return!!this._spriting},i.hitTest=function(t,e){if((!e||e<.5)&&(e=.5),this._hitPoint=t.sub(e,e),!Mo){var i=this.getMap()?this.getMap().CanvasClass:null;Mo=wn.createCanvas(1,1,i)}wn.setHitTesting(!0),Mo.width=Mo.height=2*e;var n=wn.getCanvas2DContext(Mo);try{this.paint(null,n,this._hitPoint)}catch(t){throw t}finally{wn.setHitTesting(!1)}delete this._hitPoint;for(var r=n.getImageData(0,0,Mo.width,Mo.height).data,o=3,s=r.length;o<s;o+=4)if(r[o]>0)return!0;return!1},i.isHitTesting=function(){return!!this._hitPoint},i._prepareShadow=function(t,e){e.shadowBlur?(t.shadowBlur=this.isHitTesting()?0:e.shadowBlur,t.shadowColor=e.shadowColor||"#000",t.shadowOffsetX=e.shadowOffsetX||0,t.shadowOffsetY=e.shadowOffsetY||0):t.shadowBlur&&(t.shadowBlur=null,t.shadowColor=null,t.shadowOffsetX=null,t.shadowOffsetY=null)},i._eachSymbolizer=function(t,e){if(this.symbolizers){e||(e=this);for(var i=this.symbolizers.length-1;i>=0;i--)t.apply(e,[this.symbolizers[i]])}},i.get2DExtent=function(t,e){this._verifyProjection();var i=this.getMap();t=t||this.getLayer()._getRenderer().resources;var n=i.getZoom(),r=this._isDynamicSize();if(this._extent2D&&this._extent2D._zoom===n&&this._fixedExtent||(this._extent2D&&this._extent2D._zoom!==n&&delete this._extent2D,this.symbolizers&&(this._extent2D||(this._extent2D=this._computeExtent2D(new er),this._extent2D._zoom=n),this._fixedExtent||(this._fixedExtent=this._computeFixedExtent(t,new er)))),!this._extent2D)return r&&delete this._fixedExtent,null;var o=this._fixedExtent,s=o.xmin,a=o.ymin,h=o.xmax,l=o.ymax;return r&&delete this._fixedExtent,Vo.set(s,-l,h,-a),e?(e.set(this._extent2D.xmin,this._extent2D.ymin,this._extent2D.xmax,this._extent2D.ymax),e._add(Vo),e):this._extent2D.add(Vo)},i._computeExtent2D=function(t){for(var e=this.symbolizers.length-1;e>=0;e--){var i=this.symbolizers[e];t._combine(i.get2DExtent())}return t},i._computeFixedExtent=function(t,e){for(var i=this.symbolizers.length-1;i>=0;i--){var n=this.symbolizers[i];n.getFixedExtent&&e._combine(n.getFixedExtent(t))}return e},i._isDynamicSize=function(){for(var t=this.symbolizers.length-1;t>=0;t--){if(this.symbolizers[t].isDynamicSize())return!0}return!1},i._aboveCamera=function(){var t=this.getMinAltitude(),e=this.getMap().getFrustumAltitude();return t&&e&&e<t},i.getFixedExtent=function(){var t=this.getMap().getZoom();return this._isDynamicSize()?this._computeFixedExtent(null,new er):(this._extent2D&&this._extent2D._zoom===t||this.get2DExtent(null,Vo),this._fixedExtent)},i.setZIndex=function(t){this._eachSymbolizer((function(e){e.setZIndex(t)}))},i.show=function(){this._painted?(this.removeCache(),this._eachSymbolizer((function(t){t.show()}))):this.getLayer().isCanvasRender()||this.paint()},i.hide=function(){this._eachSymbolizer((function(t){t.hide()}))},i.repaint=function(){this._altAtGL=this._getGeometryAltitude(),this.removeCache();var t=this.getLayer();if(t){var e=t.getRenderer();e&&e.setToRedraw()&&e.setToRedraw()}},i.refreshSymbol=function(){this.removeCache(),this._removeSymbolizers(),this.symbolizers=this._createSymbolizers()},i.remove=function(){this.removeCache(),this._removeSymbolizers()},i._removeSymbolizers=function(){this._eachSymbolizer((function(t){delete t.painter,t.remove()})),delete this.symbolizers},i.removeCache=function(){delete this._renderPoints,delete this._paintParams,delete this._sprite,delete this._extent2D,delete this._fixedExtent,delete this._cachedParams,delete this._unsimpledParams},i.getAltitude=function(){return this.geometry._getAltitude()!==this._propAlt&&(this._altAtGL=this._getGeometryAltitude()),this._altAtGL?this._altAtGL:0},i.getMinAltitude=function(){return this.minAltitude?this.minAltitude:0},i.getMaxAltitude=function(){return this.maxAltitude?this.maxAltitude:0},i._getGeometryAltitude=function(){var t=this;if(!this.getMap())return 0;var e=this.geometry._getAltitude();if(this._propAlt=e,!e)return this.minAltitude=this.maxAltitude=0,0;var i=this.geometry.getCenter();return i?Array.isArray(e)?(this.minAltitude=Number.MAX_VALUE,this.maxAltitude=Number.MIN_VALUE,e.map((function(e){var n=t._meterToPoint(i,e);return n<t.minAltitude&&(t.minAltitude=n),n>t.maxAltitude&&(t.maxAltitude=n),n}))):(this.minAltitude=this.maxAltitude=this._meterToPoint(i,e),this.minAltitude):0},i._meterToPoint=function(t,e){var i=this.getMap(),n=i.getGLRes();return i.altitudeToPoint(e,n)*Yt(e)},i._verifyProjection=function(){var t=this.geometry._getProjection()||Xo;this._projCode&&this._projCode!==t.code&&this.removeCache(),this._projCode=t.code},i._beforePaint=function(){},i._afterPaint=function(){},e}(Ln);function Qo(t,e,i){if(!Array.isArray(i))return t;for(var n=[],r=0,o=t.length;r<o;r++)if(Array.isArray(t[r]))n.push(Qo(t[r],e,i));else{var s=t[r];if(s.point.equals(e[s.index]))s.altitude=i[s.index],n.push(s);else{var a=void 0,h=void 0;0===s.index?(a=s.index,h=s.index+1):(a=s.index-1,h=s.index);var l=s.point.distanceTo(e[h]),c=l/(l+e[a].distanceTo(s.point)),u=Qt(i[a],i[h],1-c);s.altitude=u,n.push(s)}}return n}var Ko=new er,$o=function(t){function e(e,i){var n;return(n=t.call(this)||this).geometry=e,n.isMask=i,n}Dt(e,t);var i=e.prototype;return i._eachPainter=function(t){for(var e,i=this.geometry.getGeometries(),n=0,r=i.length;n<r&&(!(e=this.isMask?i[n]._getMaskPainter():i[n]._getPainter())||!e||!1!==t.call(this,e));n++);},i.paint=function(t){this.geometry&&this._eachPainter((function(e){e.paint(t)}))},i.get2DExtent=function(t,e){e&&e.set(null,null,null,null);var i=e||new er;return this._eachPainter((function(e){i=i._combine(e.get2DExtent(t,Ko))})),i},i.remove=function(){var t=arguments;this._eachPainter((function(e){e.remove.apply(e,t)}))},i.setZIndex=function(){var t=arguments;this._eachPainter((function(e){e.setZIndex.apply(e,t)}))},i.show=function(){var t=arguments;this._eachPainter((function(e){e.show.apply(e,t)}))},i.hide=function(){var t=arguments;this._eachPainter((function(e){e.hide.apply(e,t)}))},i.repaint=function(){var t=arguments;this._eachPainter((function(e){e.repaint.apply(e,t)}))},i.refreshSymbol=function(){var t=arguments;this._eachPainter((function(e){e.refreshSymbol.apply(e,t)}))},i.hasPoint=function(){var t=!1;return this._eachPainter((function(e){return!e.hasPoint()||(t=!0,!1)})),t},i.getMinAltitude=function(){var t=!0,e=0;return this._eachPainter((function(i){var n=i.getMinAltitude();(t||n<e)&&(t=!1,e=n)})),e},i.getMaxAltitude=function(){var t=0;return this._eachPainter((function(e){var i=e.getMaxAltitude();i>t&&(t=i)})),t},e}(Ln),ts={"EPSG:3857":{projection:"EPSG:3857",resolutions:function(){for(var t=[],e=12756274*Math.PI,i=0;i<23;i++)t[i]=e/(256*Math.pow(2,i));return t}(),fullExtent:{top:6378137*Math.PI,left:-6378137*Math.PI,bottom:-6378137*Math.PI,right:6378137*Math.PI}},"EPSG:4326":{projection:"EPSG:4326",fullExtent:{top:90,left:-180,bottom:-90,right:180},resolutions:function(){for(var t=[],e=0;e<23;e++)t[e]=180/(128*Math.pow(2,e));return t}()},BAIDU:{projection:"baidu",resolutions:function(){for(var t=Math.pow(2,18),e=[],i=0;i<23;i++)e[i]=t,t*=.5;return e}(),fullExtent:{top:33554432,left:-33554432,bottom:-33554432,right:33554432}},IDENTITY:{projection:"identity",resolutions:function(){for(var t=Math.pow(2,8),e=[],i=0;i<23;i++)e[i]=t,t*=.5;return e}(),fullExtent:{top:2e5,left:-2e5,bottom:-2e5,right:2e5}},"PRESET-VT-3857":{projection:"EPSG:3857",resolutions:function(){for(var t=[],e=6378137*Math.PI,i=0;i<23;i++)t[i]=e/(256*Math.pow(2,i));return t}(),fullExtent:{top:6378137*Math.PI,left:-6378137*Math.PI,bottom:-6378137*Math.PI,right:6378137*Math.PI}}};ts["EPSG:4490"]=ts["EPSG:4326"];var es=function(){function t(t){void 0===t&&(t={}),this.options=t,this._initSpatialRef()}t.getPreset=function(t){return ts[t.toUpperCase()]},t.getAllPresets=function(){return Object.keys(ts)},t.getProjectionInstance=function(t){if(!t)return null;if(U(t))return t.locate||("identity"===(t=N({},t)).measure?N(t,pr.getInstance("IDENTITY")):N(t,pr.getInstance("EPSG:4326"))),t;for(var e in t=(t+"").toLowerCase(),xr)if(q(xr,e)){var i=xr[e].code;if(i&&i.toLowerCase()===t)return xr[e]}return null},t.equals=function(t,e){if(V(t)||V(e))return t===e;if(!t&&!e)return!0;if(!t||!e)return!1;if(t.projection!==e.projection)return!1;var i=t.fullExtent,n=e.fullExtent;if(i&&!n||!i&&n)return!1;if(i&&n&&(i.top!==n.top||i.bottom!==n.bottom||i.left!==n.left||i.right!==n.right))return!1;var r=t.resolutions,o=e.resolutions;if(r&&o){if(r.length!==o.length)return!1;for(var s=0;s<r.length;s++)if(r[s]!==o[s])return!1}else if(r||o)return!1;return!0};var e=t.prototype;return e._initSpatialRef=function(){var e=this.options.projection;if(!(e=e?t.getProjectionInstance(e):_r))throw new Error("must provide a valid projection in map's spatial reference.");(e=N({},nr,e)).measureLength||N(e,pr.DEFAULT),this._projection=e;var i,n=this.options.resolutions;if(!n&&(e.code&&(i=ts[e.code.toUpperCase()])&&(n=i.resolutions,this.isEPSG="IDENTITY"!==e.code),!n))throw new Error("must provide valid resolutions in map's spatial reference.");if(this._resolutions=n,this._pyramid=!0,this._pyramid)for(var r=0;r<n.length;r++)if(n[r]&&n[r-1]&&n[r-1]/n[r]!=2){this._pyramid=!1;break}var o=this.options.fullExtent;if(!o&&(e.code&&(i=ts[e.code.toUpperCase()])&&(o=i.fullExtent),!o))throw new Error("must provide a valid fullExtent in map's spatial reference.");if(H(o.left)?(this._fullExtent=new tr(o),o.left=o.xmin,o.right=o.xmax,o.top=o.ymax,o.bottom=o.ymin):this._fullExtent=new tr(new Hn(o.left,o.top),new Hn(o.right,o.bottom)),H(o.top)||H(o.bottom)||H(o.left)||H(o.right))throw new Error("must provide valid top/bottom/left/right in fullExtent.");N(this._fullExtent,o),this._projection.fullExtent=o;var s=o.right>=o.left?1:-1,a=o.top>=o.bottom?-1:1;this._transformation=new ir([s,a,0,0])},e.getResolutions=function(){return this._resolutions||[]},e.getResolution=function(t){var e=0|t;e<0?e=0:e>this._resolutions.length-1&&(e=this._resolutions.length-1);var i=this._resolutions[e];return e!==t&&t>0&&e<this._resolutions.length-1?i+(this._resolutions[e+1]-i)*(t-e):i},e.getProjection=function(){return this._projection},e.getFullExtent=function(){return this._fullExtent},e.getTransformation=function(){return this._transformation},e.getMinZoom=function(){for(var t=0;t<this._resolutions.length;t++)if(!H(this._resolutions[t]))return t;return 0},e.getMaxZoom=function(){for(var t=this._resolutions.length-1;t>=0;t--)if(!H(this._resolutions[t]))return t;return this._resolutions.length-1},e.getZoomDirection=function(){return Yt(this._resolutions[this.getMinZoom()]-this._resolutions[this.getMaxZoom()])},e.toJSON=function(){return this.json||(this.json={resolutions:this._resolutions,fullExtent:{top:this._fullExtent.top,left:this._fullExtent.left,bottom:this._fullExtent.bottom,right:this._fullExtent.right},projection:this._projection.code}),this.json},e.isPyramid=function(){return this._pyramid},t}(),is=new Bt(0,0),ns=new er,rs={},os=function(t){function e(e){var i,n=N({},e),r=n.symbol,o=n.properties,s=n.id;return delete n.symbol,delete n.id,delete n.properties,i=t.call(this,n)||this,r?i.setSymbol(r):i._genSizeSymbol(),o&&i.setProperties(o),H(s)||i.setId(s),i}Dt(e,t);var i=e.prototype;return i.getFirstCoordinate=function(){if("GeometryCollection"===this.type){var t=this.getGeometries();return t.length?t[0].getFirstCoordinate():null}var e=this.getCoordinates();if(!Array.isArray(e))return e;do{e=e[0]}while(Array.isArray(e)&&e.length>0);return e},i.getLastCoordinate=function(){if("GeometryCollection"===this.type){var t=this.getGeometries();return t.length?t[t.length-1].getLastCoordinate():null}var e=this.getCoordinates();if(!Array.isArray(e))return e;do{e=e[e.length-1]}while(Array.isArray(e)&&e.length>0);return e},i.addTo=function(t,e){return t.addGeometry(this,e),this},i.getLayer=function(){return this._layer?this._layer:null},i.getMap=function(){return this._layer?this._layer.getMap():null},i.getId=function(){return this._id},i.setId=function(t){var e=this.getId();return this._id=t,this._fireEvent("idchange",{old:e,new:t}),this},i.getProperties=function(){return this.properties?this.properties:this._getParent()?this._getParent().getProperties():null},i.setProperties=function(t){var e=this.properties;return this.properties=U(t)?N({},t):t,this._repaint(),this._fireEvent("propertieschange",{old:e,new:t}),this},i.getType=function(){return this.type},i.getSymbol=function(){var t=this._symbol;return t?Array.isArray(t)?Ci(t):N({},t):null},i.setSymbol=function(t){return this._symbolUpdated=t,this._symbol=this._prepareSymbol(t),this.onSymbolChanged(),delete this._compiledSymbol,delete this._symbolHash,this},i.getSymbolHash=function(){return this._symbolHash||(this._symbolHash=Ti(this._symbolUpdated)),this._symbolHash},i.updateSymbol=function(t){if(!t)return this;var e=this._getSymbol();if(Array.isArray(e)){if(!Array.isArray(t))throw new Error("Parameter of updateSymbol is not an array.");for(var i=0;i<t.length;i++)ro(t[i])&&delete this._textDesc,e[i]&&t[i]&&(e[i]=Ci(e[i],t[i]))}else{if(Array.isArray(t))throw new Error("Geometry's symbol is not an array to update.");ro(e)&&delete this._textDesc,e=Ci(e||this._getInternalSymbol(),t)}return this._eventSymbolProperties=t,delete this._compiledSymbol,this.setSymbol(e)},i.getTextContent=function(){var t=this._getInternalSymbol();if(Array.isArray(t)){for(var e=[],i=!1,n=0;n<t.length;n++)e[n]=gi(t[n]&&t[n].textName,this.getProperties()),H(e[n])||(i=!0);return i?e:null}return gi(t&&t.textName,this.getProperties())},i.getTextDesc=function(){if(!this._textDesc){var t=this.getTextContent(),e=this._sizeSymbol,i=Array.isArray(t);Array.isArray(e)?this._textDesc=e.map((function(e,n){return vi(i?t[n]:"",e)})):this._textDesc=vi(t,e)}return this._textDesc},i.getCenter=function(){return this._computeCenter(this._getMeasurer())},i.getExtent=function(){var t=this._getPrjExtent(),e=this._getProjection();if(t&&e){var i=e.unproject(new Hn(t.xmin,t.ymin)),n=e.unproject(new Hn(t.xmax,t.ymax));return new tr(i,n,e)}return this._computeExtent(this._getMeasurer())},i.getContainerExtent=function(t){var e=this.get2DExtent();if(!e||!e.isValid())return null;var i=this.getMap(),n=i.getGLRes(),r=this.getMinAltitude(),o=i.altitudeToPoint(r,n)*Yt(r),s=e.convertTo((function(t){return i._pointAtResToContainerPoint(t,n,o,is)}),t),a=this.getMaxAltitude();if(a!==r){a=i.altitudeToPoint(a,n)*Yt(a);var h=e.convertTo((function(t){return i._pointAtResToContainerPoint(t,n,a,is)}),ns);s._combine(h)}var l=this.getLayer();if(l&&"LineString"===this.type&&a&&l.options.drawAltitude){var c=e.convertTo((function(t){return i._pointAtResToContainerPoint(t,n,0,is)}),ns);s._combine(c)}return s&&s._add(this._getFixedExtent()),this.options.smoothness&&s._expand(.15*s.getWidth()),s},i._getFixedExtent=function(){this._fixedExtent||(this._fixedExtent=new er);var t=this._sizeSymbol,e=(t&&t.lineWidth||1)/2;this._fixedExtent.set(-e,-e,e,e);var i=t&&t.lineDx||0;this._fixedExtent._add([i,0]);var n=t&&t.lineDy||0;return this._fixedExtent._add([0,n]),this._fixedExtent},i.get2DExtent=function(){var t=this.getMap();if(!t)return null;if(this._extent2d)return this._extent2d;var e=this._getPrjExtent();if(!e||!e.isValid())return null;var i=e.getMin(),n=e.getMax(),r=t.getGLRes();return t._prjToPointAtRes(i,r,i),t._prjToPointAtRes(n,r,n),this._extent2d=new er(i,n),this._extent2d.z=t.getZoom(),this._extent2d},i.getSize=function(){var t=this.getContainerExtent();return t?t.getSize():null},i.containsPoint=function(t,e){if(!this.getMap())throw new Error('The geometry is required to be added on a map to perform "containsPoint".');return t instanceof Hn&&(t=this.getMap().coordToContainerPoint(t)),this._containsPoint(t,e)},i._containsPoint=function(t,e){var i=this._getPainter();return!!i&&(e=e||0,this._hitTestTolerance&&(e+=this._hitTestTolerance()),i.hitTest(t,e))},i.show=function(){if(this.options.visible=!0,this.getMap()){var t=this._getPainter();t&&t.show(),this._fireEvent("show")}return this},i.hide=function(){if(this.options.visible=!1,this.getMap()){this.onHide();var t=this._getPainter();t&&t.hide(),this._fireEvent("hide")}return this},i.isVisible=function(){if(!this.options.visible)return!1;var t=this._getInternalSymbol();if(!t)return!0;if(Array.isArray(t)){if(!t.length)return!0;for(var e=0,i=t.length;e<i;e++)if(H(t[e].opacity)||t[e].opacity>0)return!0;return!1}return H(t.opacity)||U(t.opacity)||j(t.opacity)&&t.opacity>0},i.getZIndex=function(){return this.options.zIndex||0},i.setZIndex=function(t){var e=this.options.zIndex;return this.options.zIndex=t,this._fireEvent("zindexchange",{old:e,new:t}),this},i.setZIndexSilently=function(t){return this.options.zIndex=t,this},i.bringToFront=function(){var t=this.getLayer();if(!t||!t.getGeoMaxZIndex)return this;var e=t.getGeoMaxZIndex();return this.setZIndex(e+1),this},i.bringToBack=function(){var t=this.getLayer();if(!t||!t.getGeoMinZIndex)return this;var e=t.getGeoMinZIndex();return this.setZIndex(e-1),this},i.translate=function(t,e){if(H(t))return this;var i=new Hn(t,e);if(0===i.x&&0===i.y)return this;var n=this.getCoordinates();if(this._silence=!0,n)if(Array.isArray(n)){var r=qt(n,(function(t){return t.add(i)}));this.setCoordinates(r)}else this.setCoordinates(n.add(i));return this._silence=!1,this._fireEvent("positionchange"),this},i.flash=function(t,e,i,n){return pe.call(this,t,e,i,n)},i.copy=function(){var t=this.toJSON(),i=e.fromJSON(t);return i.options.visible=!0,i},i.remove=function(){return this.getLayer()?(this._fireEvent("removestart"),this._unbind(),this._fireEvent("removeend"),this._fireEvent("remove"),this):this},i.toGeoJSONGeometry=function(){return this._exportGeoJSONGeometry()},i.toGeoJSON=function(t){t||(t={});var e={type:"Feature",geometry:null};if(H(t.geometry)||t.geometry){var i=this._exportGeoJSONGeometry();e.geometry=i}var n,r=this.getId();return H(r)||(e.id=r),(H(t.properties)||t.properties)&&(n=this._exportProperties()),e.properties=n,e},i.toJSON=function(t){t||(t={});var e=this._toJSON(t);return N(e,this._exportGraphicOptions(t)),e},i.getLength=function(){return this._computeGeodesicLength(this._getMeasurer())},i.getArea=function(){return this._computeGeodesicArea(this._getMeasurer())},i.rotate=function(t,e){if("GeometryCollection"===this.type)return this.getGeometries().forEach((function(i){return i.rotate(t,e)})),this;e=e?new Hn(e):this.getCenter();var i=this._getMeasurer(),n=this.getCoordinates();if(!Array.isArray(n)){if(e.x!==n.x||e.y!==n.y){var r=i._rotate(n,e,t);this.setCoordinates(r)}return this}return qt(n,(function(n){return i._rotate(n,e,t)})),this.setCoordinates(n),this},i._getConnectPoints=function(){return[this.getCenter()]},i._initOptions=function(t){var e=N({},t),i=e.symbol,n=e.properties,r=e.id;delete e.symbol,delete e.id,delete e.properties,this.setOptions(e),i&&this.setSymbol(i),n&&this.setProperties(n),H(r)||this.setId(r)},i._bindLayer=function(t){if(this.getLayer())throw new Error("Geometry cannot be added to two or more layers at the same time.");this._layer=t,this._clearCache(),this._bindInfoWindow(),this._bindMenu()},i._prepareSymbol=function(t){if(Array.isArray(t)){for(var e=[],i=0;i<t.length;i++)e.push(ri(this._checkAndCopySymbol(t[i])));return e}return t?ri(t=this._checkAndCopySymbol(t)):null},i._checkAndCopySymbol=function(t){var e={};for(var i in t)k[i]&&V(t[i])?e[i]=+t[i]:e[i]=t[i];return e},i._getSymbol=function(){return this._symbol},i._setExternSymbol=function(t){return this._eventSymbolProperties=t,this._symbol||delete this._textDesc,this._externSymbol=this._prepareSymbol(t),this.onSymbolChanged(),this},i._getInternalSymbol=function(){return this._symbol?this._symbol:this._externSymbol?this._externSymbol:this.options.symbol?this.options.symbol:null},i._getPrjExtent=function(){var t=this._getProjection();return this._verifyProjection(),!this._extent&&t&&(this._extent=this._computePrjExtent(t)),this._extent},i._unbind=function(){var t=this.getLayer();t&&(this._animPlayer&&this._animPlayer.finish(),this._unbindMenu(),this._unbindInfoWindow(),this.isEditing()&&this.endEdit(),this._removePainter(),this.onRemove&&this.onRemove(),t.onRemoveGeometry&&t.onRemoveGeometry(this),delete this._layer,delete this._internalId,delete this._extent)},i._getInternalId=function(){return this._internalId},i._setInternalId=function(t){this._internalId=t},i._getMeasurer=function(){return this._getProjection()?this._getProjection():es.getProjectionInstance(this.options.defaultProjection)},i._getProjection=function(){var t=this.getMap();return t?t.getProjection():null},i._verifyProjection=function(){var t=this._getProjection();this._projCode&&t&&this._projCode!==t.code&&this._clearProjection(),this._projCode=t?t.code:this._projCode},i._getExternalResources=function(){return ni(this._getInternalSymbol())},i._getPainter=function(){var t=this.getLayer();if(!this._painter&&t)if(-1!==R.indexOf(this.type)){if(t.constructor.getCollectionPainterClass){var e=t.constructor.getCollectionPainterClass();e&&(this._painter=new e(this))}}else if(t.constructor.getPainterClass){var i=t.constructor.getPainterClass();i&&(this._painter=new i(this))}return this._painter},i._getMaskPainter=function(){return this._maskPainter||(this._maskPainter=this.getGeometries&&this.getGeometries()?new $o(this,!0):new Jo(this)),this._maskPainter},i._removePainter=function(){this._painter&&this._painter.remove(),delete this._painter},i._paint=function(t){if(this._painter){if(this._dirtyCoords){delete this._dirtyCoords;var e=this._getProjection();e&&(this._pcenter=e.project(this._coordinates),this._clearCache())}this._painter.paint(t)}},i._clearCache=function(){delete this._extent,delete this._extent2d},i._clearProjection=function(){delete this._extent,delete this._extent2d},i._repaint=function(){this._painter&&this._painter.repaint()},i.onHide=function(){this.closeMenu(),this.closeInfoWindow()},i.onShapeChanged=function(){this._clearCache(),this._repaint(),this._fireEvent("shapechange")},i.onPositionChanged=function(){this._clearCache(),this._repaint(),this._fireEvent("positionchange")},i.onSymbolChanged=function(){this._painter&&this._painter.refreshSymbol();var t={};this._eventSymbolProperties?(t.properties=N({},this._eventSymbolProperties),delete this._eventSymbolProperties):delete this._textDesc,this._genSizeSymbol(),this._fireEvent("symbolchange",t)},i._genSizeSymbol=function(){var t=this._getInternalSymbol();if(t)if(Array.isArray(t)){this._sizeSymbol=[];for(var e=!1,i=0;i<t.length;i++){var n=this._sizeSymbol[i]=this._getSizeSymbol(t[i]);!e&&n&&n._dynamic&&(e=!0)}this._sizeSymbol._dynamic=e}else this._sizeSymbol=this._getSizeSymbol(t);else delete this._sizeSymbol},i._getSizeSymbol=function(t){var e=ti({lineWidth:t.lineWidth,lineDx:t.lineDx,lineDy:t.lineDy},this);return(Oe(t.lineWidth)||Oe(t.lineDx)||Oe(t.lineDy))&&(e._dynamic=!0),e},i._getCompiledSymbol=function(){return this._compiledSymbol||(this._compiledSymbol=ti(this._getInternalSymbol(),this)),this._compiledSymbol},i.onConfig=function(t){var e;t.properties&&(e=t.properties,delete t.properties);var i=!1;for(var n in t)if(t.hasOwnProperty(n)){var r=n.slice(0,5);if("arrow"===r||"smoot"===r){i=!0;break}}e?(this.setProperties(e),this._repaint()):i&&this._repaint()},i._setParent=function(t){t&&(this._parent=t)},i._getParent=function(){return this._parent},i._fireEvent=function(t,e){this._silence||(this.getLayer()&&this.getLayer()._onGeometryEvent&&(e||(e={}),e.type=t,e.target=this,this.getLayer()._onGeometryEvent(e)),this.fire(t,e))},i._toJSON=function(t){return{feature:this.toGeoJSON(t)}},i._exportGraphicOptions=function(t){var e={};return(H(t.options)||t.options)&&(e.options=this.config()),(H(t.symbol)||t.symbol)&&(e.symbol=this.getSymbol()),(H(t.infoWindow)||t.infoWindow)&&this._infoWinOptions&&(e.infoWindow=this._infoWinOptions),e},i._exportGeoJSONGeometry=function(){var t=this.getCoordinates(),e=Hn.toNumberArrays(t);return{type:this.getType(),coordinates:e}},i._exportProperties=function(){var t=null,e=this.getProperties();return H(e)||(t=U(e)?N({},e):e),t},i._hitTestTolerance=function(){var t=this.getLayer();return t&&t.options.geometryEventTolerance||0},i._getAltitude=function(){var t=this.getLayer();if(!t)return 0;var e=t.options,i=t.getAltitude?t.getAltitude():0,n=e.enableAltitude;if(!n)return i;var r=ss(t),o=(this.properties||rs)[r];if(H(o)){var s=as(this,i,n);return H(s)?i:s}return Array.isArray(o)?o.map((function(t){return t+i})):o+i},i.getAltitude=function(){var t=ss(this.getLayer()),e=(this.properties||rs)[t];if(!H(e))return e;var i=as(this,0,!1);return H(i)?0:i},i.setAltitude=function(t){if(!j(t))return this;var e=this.getLayer(),i=ss(e),n=this.properties||rs,r=n[i];if(!H(r))if(Array.isArray(r))for(var o=0,s=r.length;o<s;o++)r[o]=t;else n[i]=t;var a=this.getCoordinates?this.getCoordinates():null;if(!a)return this;if(hs(a,t),e){var h=e.getRenderer();h&&h.gl?this.setCoordinates(a):h&&this._repaint()}return this},i._genMinMaxAlt=function(){var t=this,e=this._getAltitude();Array.isArray(e)?(this._minAlt=Number.MAX_VALUE,this._maxAlt=Number.MIN_VALUE,e.forEach((function(e){var i=e;i<t._minAlt&&(t._minAlt=i),i>t._maxAlt&&(t._maxAlt=i)}))):this._minAlt=this._maxAlt=e},i.getMinAltitude=function(){return void 0===this._minAlt&&this._genMinMaxAlt(),this._minAlt?this._minAlt:0},i.getMaxAltitude=function(){return void 0===this._maxAlt&&this._genMinMaxAlt(),this._maxAlt?this._maxAlt:0},e}(On(Cn(kn(Ln))));function ss(t){var e="altitude";t&&(e=t.options.altitudeProperty);return e}function as(t,e,i){var n=t.getCoordinates?t.getCoordinates():null;if(n){var r=[];if(ls(n,r),r.length){var o=cs(n,e,i);return t.getShell?o[0][0]:o}}return null}function hs(t,e){if(Array.isArray(t))for(var i=0,n=t.length;i<n;i++)hs(t[i],e);else t.z=e}function ls(t,e){if(!e.length)if(Array.isArray(t))for(var i=0,n=t.length;i<n;i++)ls(t[i],e);else j(t.z)&&e.push(t.z)}function cs(t,e,i){if(Array.isArray(t)){for(var n=[],r=0,o=t.length;r<o;r++)n.push(cs(t[r],e,i));return n}return j(t.z)?i?e+t.z:t.z:i?e:0}os.mergeOptions({id:null,visible:!0,interactive:!0,editable:!0,cursor:null,antiMeridian:!1,defaultProjection:"EPSG:4326"});var us={attribution:null,minZoom:null,maxZoom:null,visible:!0,opacity:1,globalCompositeOperation:null,renderer:"canvas",debugOutline:"#0f0",cssFilter:null,forceRenderOnMoving:!1,forceRenderOnZooming:!1,forceRenderOnRotating:!1,collision:!1,collisionScope:"layer",hitDetect:!Ot.mobile},ds=function(t){function e(e,i){var n,r;return i&&(r=i.canvas,delete i.canvas),(n=t.call(this,i)||this)._canvas=r,n.setId(e),i&&(n.setZIndex(i.zIndex),i.mask&&n.setMask(os.fromJSON(i.mask))),n.proxyOptions(),n}Dt(e,t);var i=e.prototype;return i.load=function(){if(!this.getMap())return this;if(this.onLoad()){this._initRenderer();var t=this.getZIndex();H(t)||(this._renderer.setZIndex(t),this.isCanvasRender()||this._renderer.render()),this.onLoadEnd()}return this},i.getId=function(){return this._id},i.setId=function(t){var e=this._id;return H(t)||(t+=""),this._id=t,this.fire("idchange",{old:e,new:t}),this},i.addTo=function(t){return t.addLayer(this),this},i.setZIndex=function(t){return this._zIndex=t,H(t)?delete this.options.zIndex:this.options.zIndex=t,this.map&&this.map._sortLayersByZIndex(),this._renderer&&this._renderer.setZIndex(t),this},i.getZIndex=function(){return this._zIndex||0},i.getMinZoom=function(){var t=this.getMap(),e=this.options.minZoom;return t?Math.max(t.getMinZoom(),e||0):e},i.getMaxZoom=function(){var t=this.getMap(),e=this.options.maxZoom;return t?Math.min(t.getMaxZoom(),H(e)?1/0:e):e},i.getOpacity=function(){return this.options.opacity},i.setOpacity=function(t){return this.config("opacity",t),this},i.isCanvasRender=function(){var t=this._getRenderer();return t&&t instanceof Hr},i.getMap=function(){return this.map?this.map:null},i.getProjection=function(){var t=this.getMap();return t?t.getProjection():null},i.bringToFront=function(){var t=this._getLayerList();if(!t.length)return this;var e=t[t.length-1];if(1===t.length||e===this)return this;var i=e.getZIndex();return this.setZIndex(i+1),this},i.bringToBack=function(){var t=this._getLayerList();if(!t.length)return this;var e=t[0];if(1===t.length||e===this)return this;var i=e.getZIndex();return this.setZIndex(i-1),this},i.show=function(){var t=this;if(!this.options.visible){this.options.visible=!0;var e=this.getRenderer();e&&e.show();var i=this.getMap();e&&i?i.once("renderend",(function(){t.fire("show")})):this.fire("show")}return this},i.hide=function(){var t=this;if(this.options.visible){this.options.visible=!1;var e=this.getRenderer();e&&e.hide();var i=this.getMap();e&&i?i.once("renderend",(function(){t.fire("hide")})):this.fire("hide")}return this},i.isVisible=function(){if(j(this.options.opacity)&&this.options.opacity<=0)return!1;var t=this.getMap();if(t){var e=t.getZoom();if(!H(this.options.maxZoom)&&this.options.maxZoom<e||!H(this.options.minZoom)&&this.options.minZoom>e)return!1}return H(this.options.visible)&&(this.options.visible=!0),this.options.visible},i.remove=function(){return this.map&&this.map.removeLayer(this),this},i.getMask=function(){return this._mask},i.setMask=function(t){if(!("Point"===t.type&&t._isVectorMarker()||"Polygon"===t.type||"MultiPolygon"===t.type))throw new Error("Mask for a layer must be a marker with vector marker symbol or a Polygon(MultiPolygon).");if(t._bindLayer(this),"Point"===t.type?t.updateSymbol({markerLineColor:"rgba(0, 0, 0, 0)",markerFillOpacity:0}):t.setSymbol({lineColor:"rgba(0, 0, 0, 0)",polygonOpacity:0}),this._mask=t,this.options.mask=t.toJSON(),!this.getMap()||this.getMap().isZooming())return this;var e=this._getRenderer();return e&&e.setToRedraw&&this._getRenderer().setToRedraw(),this},i.removeMask=function(){if(delete this._mask,delete this.options.mask,!this.getMap()||this.getMap().isZooming())return this;var t=this._getRenderer();return t&&t.setToRedraw&&this._getRenderer().setToRedraw(),this},i.onLoad=function(){return!0},i.onLoadEnd=function(){},i.isLoaded=function(){return!!this._loaded},i.getCollisionIndex=function(){if("layer"===this.options.collisionScope)return this._collisionIndex||(this._collisionIndex=new In),this._collisionIndex;var t=this.getMap();return t?t.getCollisionIndex():null},i.clearCollisionIndex=function(){return"layer"===this.options.collisionScope&&this._collisionIndex&&this._collisionIndex.clear(),this},i.getRenderer=function(){return this._getRenderer()},i.onConfig=function(t){if(t&&Object.keys&&Object.keys(t).length>0&&H(t.animation)){this._optionsHook&&W(this._optionsHook)&&this._optionsHook(t);var e=this.getRenderer();e&&e.setToRedraw&&e.setToRedraw()}},i.onAdd=function(){},i.onRendererCreate=function(){},i.onCanvasCreate=function(){},i.onRemove=function(){},i._bindMap=function(t,e){t&&(this.map=t,H(e)||this.setZIndex(e),this._switchEvents("on",this),this.onAdd(),this.fire("add"))},i._initRenderer=function(){var t=this.options.renderer;if(this.constructor.getRendererClass){var e=this.constructor.getRendererClass(t);if(!e)throw new Error("Invalid renderer for Layer("+this.getId()+"):"+t);this._renderer=new e(this),this._renderer.layer=this,this._renderer.setZIndex(this.getZIndex()),this._switchEvents("on",this._renderer),this._renderer.onAdd&&this._renderer.onAdd(),this.onRendererCreate(),this.fire("renderercreate",{renderer:this._renderer})}},i._doRemove=function(){this._loaded=!1,this._switchEvents("off",this),this.onRemove(),this._renderer&&(this._switchEvents("off",this._renderer),this._renderer.remove(),delete this._renderer),delete this.map,delete this._collisionIndex},i._switchEvents=function(t,e){e&&e.getEvents&&this.getMap()&&this.getMap()[t](e.getEvents(),e)},i._getRenderer=function(){return this._renderer},i._getLayerList=function(){return this.map?this.map._layers:[]},i._getMask2DExtent=function(){if(!this._mask||!this.getMap())return null;var t=this._mask._getMaskPainter();return t?t.get2DExtent():null},e}(On(Cn(wr(Ln))));ds.mergeOptions(us);var ps=ds.prototype.fire;ds.prototype.fire=function(t,e){return"layerload"===t&&(this._loaded=!0),this.map&&(e||(e={}),e.type=t,e.target=this,this.map._onLayerEvent(e)),ps.apply(this,arguments)};var fs,ms,gs,vs,ys,_s,xs,ws=new Hn(0,0),bs=["centerCross","fog","fogColor","debugSky"],Ms={maxVisualPitch:70,maxPitch:80,centerCross:!1,zoomInCenter:!1,zoomOrigin:null,zoomAnimation:!Q,zoomAnimationDuration:330,panAnimation:!Q,panAnimationDuration:600,rotateAnimation:!Q,zoomable:!0,enableInfoWindow:!0,hitDetect:!Ot.mobile,hitDetectLimit:5,fpsOnInteracting:25,layerCanvasLimitOnInteracting:-1,maxZoom:null,minZoom:null,maxExtent:null,fixCenterOnResize:!0,checkSize:!0,checkSizeInterval:1e3,renderer:"canvas",cascadePitches:[10,60],renderable:!0,clickTimeThreshold:280,stopRenderOnOffscreen:!0,preventWheelScroll:!0},Ss=function(t){function e(i,n){var r;if(!n)throw new Error("Invalid options when creating map.");if(!n.center)throw new Error("Invalid center when creating map.");var o=N({},n),s=o.zoom;delete o.zoom;var a=new Hn(o.center);delete o.center;var h=o.baseLayer;delete o.baseLayer;var l=o.layers;return delete o.layers,(r=t.call(this,o)||this).VERSION=e.VERSION,Object.defineProperty(It(It(r)),"id",{value:Gt(),writable:!1}),r._loaded=!1,r._initContainer(i),r._panels={},r._baseLayer=null,r._layers=[],r._zoomLevel=s,r._center=a,r.setSpatialReference(o.spatialReference||o.view),r._mapViewPoint=new Bt(0,0),r._initRenderer(),r._updateMapSize(r._getContainerDomSize()),h&&r.setBaseLayer(h),l&&r.addLayer(l),r.setMaxExtent(o.maxExtent),r._Load(),r.proxyOptions(),r}Dt(e,t),e.addOnLoadHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};return this.prototype._onLoadHooks=this.prototype._onLoadHooks||[],this.prototype._onLoadHooks.push(i),this};var i=e.prototype;return i.isLoaded=function(){return!!this._loaded},i.getContainer=function(){return this._containerDOM},i.getSpatialReference=function(){return this._spatialReference},i.setSpatialReference=function(t){var e=this.options.spatialReference;return this._loaded&&es.equals(e,t)||this._updateSpatialReference(t,e),this},i._updateSpatialReference=function(t,e){if(V(t)&&(t=es.getPreset(t)),t=N({},t),this._center=this.getCenter(),this.options.spatialReference=t,this._spatialReference=new es(t),this.options.spatialReference&&W(this.options.spatialReference.projection)){var i=this._spatialReference.getProjection();this.options.spatialReference.projection=i.code}return this._resetMapStatus(),this._fireEvent("spatialreferencechange",{old:e,new:N({},this.options.spatialReference)}),this},i.onConfig=function(t){var e=t.spatialReference||t.view;H(e)||this._updateSpatialReference(e,null);for(var i=!1,n=0,r=bs.length;n<r;n++){if(!H(t[bs[n]])){i=!0;break}}if(!i)return this;var o=this.getRenderer();return o&&o.setToRedraw(),this},i.getProjection=function(){return this._spatialReference?this._spatialReference.getProjection():null},i.getFullExtent=function(){return this._spatialReference?this._spatialReference.getFullExtent():null},i.setCursor=function(t){return delete this._cursor,this._trySetCursor(t),this._cursor=t,this},i.resetCursor=function(){return this.setCursor(null)},i.getCenter=function(){return this._loaded&&this._prjCenter?this.getProjection().unproject(this._prjCenter):this._center},i.setCenter=function(t){if(!t)return this;t=new Hn(t);var e=this.getProjection().project(t);return this._verifyExtent(e)?this._loaded?(this.onMoveStart(),this._setPrjCenter(e),this.onMoveEnd(this._parseEventFromCoord(this.getCenter())),this):(this._center=t,this):this},i.getSize=function(){return H(this.width)||H(this.height)?this._getContainerDomSize():new si(this.width,this.height)},i.getContainerExtent=function(){var t=this.height,e=this.getPitch(),i=this.options.maxVisualPitch;return i&&e>i&&(t=this._getVisualHeight(i)),new er(0,this.height-t,this.width,this.height)},i._getVisualHeight=function(t){t=t||.01;var e=(90-this.getPitch())*Math.PI/180,i=this.getFov()*Math.PI/180;t*=Math.PI/180;var n=this.cameraCenterDistance/this.getGLScale(),r=Math.tan(i/2),o=n*r/(1/Math.tan(t)-r)/Math.sin(t),s=n*(Math.sin(e)*o/(n+Math.cos(e)*o));return this.height/2+s},i.getExtent=function(){return this._pointToExtent(this._get2DExtent())},i.getProjExtent=function(){var t=this._get2DExtent();return new tr(this._pointToPrj(t.getMin()),this._pointToPrj(t.getMax()))},i.getPrjExtent=function(){return this.getProjExtent()},i.getMaxExtent=function(){return this.options.maxExtent?new tr(this.options.maxExtent,this.getProjection()):null},i.setMaxExtent=function(t){if(t){var e=new tr(t,this.getProjection());this.options.maxExtent=e;var i=this.getProjection();this._prjMaxExtent=e.convertTo((function(t){return i.project(t)})),this._verifyExtent(this._getPrjCenter())||(this._loaded?this._panTo(this._prjMaxExtent.getCenter()):this._center=i.unproject(this._prjMaxExtent.getCenter()))}else delete this.options.maxExtent,delete this._prjMaxExtent;return this},i.getZoom=function(){return this._zoomLevel},i.getZoomForScale=function(t,e,i){var n=this.getZoom();if(H(e)&&(e=n),1===t&&e===n)return n;var r=this._getResolution(e)/t,o=this.getZoomFromRes(r);if(i)return o;var s=1e-6;return this.getSpatialReference().getZoomDirection()<0?Math.ceil(o-s):Math.floor(o+s)},i.getZoomFromRes=function(t){var e=this._getResolutions(),i=this._getResolution(this.getMinZoom()),n=this._getResolution(this.getMaxZoom());if(i<=n){if(t<=i)return this.getMinZoom();if(t>=n)return this.getMaxZoom()}else{if(t>=i)return this.getMinZoom();if(t<=n)return this.getMaxZoom()}for(var r=e.length,o=0;o<r-1;o++)if(e[o]){var s=e[o+1]-e[o],a=t-e[o];if(Yt(s)===Yt(a)&&Math.abs(s)>=Math.abs(a))return o+a/s}return r-1},i.setZoom=function(t,e){return void 0===e&&(e={animation:!0}),isNaN(t)||H(t)||(t=+t,this._loaded&&this.options.zoomAnimation&&e.animation?this._zoomAnimation(t):this._zoom(t)),this},i.getMaxZoom=function(){return H(this.options.maxZoom)?this.getMaxNativeZoom():this.options.maxZoom},i.setMaxZoom=function(t){var e=this.getMaxNativeZoom();return t>e&&(t=e),null!==t&&t<this._zoomLevel&&(this.setZoom(t),t=+t),this.options.maxZoom=t,this},i.getMinZoom=function(){return H(this.options.minZoom)?this._spatialReference.getMinZoom():this.options.minZoom},i.setMinZoom=function(t){if(null!==t){t=+t;var e=this._spatialReference.getMinZoom();t<e&&(t=e),t>this._zoomLevel&&this.setZoom(t)}return this.options.minZoom=t,this},i.getMaxNativeZoom=function(){var t=this.getSpatialReference();return t?t.getMaxZoom():null},i.getGLRes=function(){if(this._glRes)return this._glRes;var t=this.getSpatialReference().getFullExtent();return this._glRes=(t.right-t.left)/Math.pow(2,19),this._glRes},i.getGLScale=function(t){return H(t)&&(t=this.getZoom()),this._getResolution(t)/this.getGLRes()},i.zoomIn=function(){return this.setZoom(this.getZoom()+1)},i.zoomOut=function(){return this.setZoom(this.getZoom()-1)},i.isZooming=function(){return!!this._zooming},i.isInteracting=function(){return this.isZooming()||this.isMoving()||this.isRotating()},i.setCenterAndZoom=function(t,e){return H(e)||this._zoomLevel===e?this.setCenter(t):(this.setCenter(t),this.setZoom(e,{animation:!1})),this},i.getFitZoom=function(t,e){var i=this;if(!(t&&t instanceof tr))return this._zoomLevel;if(t.xmin===t.xmax&&t.ymin===t.ymax)return this.getMaxZoom();var n=this.getSize(),r=t.convertTo((function(t){return i.coordToPoint(t)})),o=r.getWidth(),s=r.getHeight(),a=n.width/o,h=n.height/s,l=this.getSpatialReference().getZoomDirection()<0?Math.max(a,h):Math.min(a,h);return this.getZoomForScale(l,null,e)},i.getView=function(){return{center:this.getCenter().toArray(),zoom:this.getZoom(),pitch:this.getPitch(),bearing:this.getBearing()}},i.setView=function(t){return t?(t.center&&this.setCenter(t.center),null===t.zoom||isNaN(+t.zoom)||this.setZoom(+t.zoom,{animation:!1}),null===t.pitch||isNaN(+t.pitch)||this.setPitch(+t.pitch),null===t.pitch||isNaN(+t.bearing)||this.setBearing(+t.bearing),this):this},i.getResolution=function(t){return this._getResolution(t)},i.getScale=function(t){var e=H(t)?this.getZoom():t,i=this._getResolution(this.getMaxNativeZoom());return this._getResolution(e)/i},i.fitExtent=function(t,e,i,n){if(void 0===i&&(i={}),!t)return this;t=new tr(t,this.getProjection());var r=this.getFitZoom(t)+(e||0),o=t.getCenter();return void 0===i.animation||i.animation?this._animateTo({center:o,zoom:r},{duration:i.duration||this.options.zoomAnimationDuration,easing:i.easing||"out"},n):this.setCenterAndZoom(o,r)},i.getBaseLayer=function(){return this._baseLayer},i.setBaseLayer=function(t){var e=!1;if(this._baseLayer&&(e=!0,this._fireEvent("baselayerchangestart"),this._baseLayer.remove()),!t)return delete this._baseLayer,this._fireEvent("baselayerchangeend"),this._fireEvent("setbaselayer"),this;return this._baseLayer=t,t._bindMap(this,-1),this._baseLayer.on("layerload",(function(){this._fireEvent("baselayerload"),e&&(e=!1,this._fireEvent("baselayerchangeend"))}),this),this._loaded&&this._baseLayer.load(),this._fireEvent("setbaselayer"),this},i.removeBaseLayer=function(){return this._baseLayer&&(this._baseLayer.remove(),delete this._baseLayer,this._fireEvent("baselayerremove")),this},i.getLayers=function(t){return this._getLayers((function(e){return!(e===this._baseLayer||e.getId().indexOf(L)>=0)&&(!t||t(e))}))},i.getLayer=function(t){if(!t)return null;var e=this._layerCache?this._layerCache[t]:null;if(e)return e;var i=this.getBaseLayer();return i&&i.getId()===t?i:null},i.addLayer=function(t){if(!t)return this;if(!Array.isArray(t))return t=Array.prototype.slice.call(arguments,0),this.addLayer(t);this._layerCache||(this._layerCache={});for(var e=this._layers,i=0,n=t.length;i<n;i++){var r=t[i],o=r.getId();if(H(o))throw new Error("Invalid id for the layer: "+o);if(r.getMap()!==this){if(this._layerCache[o])throw new Error("Duplicate layer id in the map: "+o);this._layerCache[o]=r,r._bindMap(this),e.push(r),this._loaded&&r.load()}}return this._sortLayersByZIndex(),this._fireEvent("addlayer",{layers:t}),this},i.removeLayer=function(t){if(!t)return this;if(!Array.isArray(t))return this.removeLayer([t]);for(var e=[],i=0,n=t.length;i<n;i++){var r=t[i];if(r instanceof ds||(r=this.getLayer(r)),r){var o=r.getMap();if(o&&o===this){e.push(r),this._removeLayer(r,this._layers),this._loaded&&r._doRemove();var s=r.getId();this._layerCache&&delete this._layerCache[s]}}}if(e.length>0){var a=this.getRenderer();a&&a.setLayerCanvasUpdated(),e.forEach((function(t){t.fire("remove")}))}return this._fireEvent("removelayer",{layers:t}),this},i.sortLayers=function(t){if(!t||!Array.isArray(t))return this;for(var e=[],i=Number.MAX_VALUE,n=0,r=t.length;n<r;n++){var o=t[n];if(V(t[n])&&(o=this.getLayer(o)),!(o instanceof ds&&o.getMap()&&o.getMap()===this))throw new Error("It must be a layer added to this map to order.");o.getZIndex()<i&&(i=o.getZIndex()),e.push(o)}for(var s=0,a=e.length;s<a;s++)e[s].setZIndex(i+s);return this},i.toDataURL=function(t){t||(t={});var e=t.mimeType;e||(e="image/png");var i=t.save,n=this._getRenderer();if(n&&n.toDataURL){var r=t.fileName;r||(r="export");var o=n.toDataURL(e,t.quality||.92);if(i&&o){var s;if("undefined"!=typeof Blob&&"undefined"!=typeof atob){var a=he(o.replace(/^data:image\/(png|jpeg|jpg|webp);base64,/,""),e);s=URL.createObjectURL(a)}else s=o;var h=document.createElement("a");h.download=r,h.href=s,document.body.appendChild(h),h.click(),document.body.removeChild(h)}return o}return null},i.coordToPoint=function(t,e,i){return this.coordinateToPoint(t,e,i)},i.coordToPointAtRes=function(t,e,i){return this.coordinateToPointAtRes(t,e,i)},i.pointToCoord=function(t,e,i){return this.pointToCoordinate(t,e,i)},i.pointAtResToCoord=function(t,e,i){return this.pointAtResToCoordinate(t,e,i)},i.coordToViewPoint=function(t,e,i){return this.coordinateToViewPoint(t,e,i)},i.viewPointToCoord=function(t,e){return this.viewPointToCoordinate(t,e)},i.coordToContainerPoint=function(t,e,i){return this.coordinateToContainerPoint(t,e,i)},i.containerPointToCoord=function(t,e){return this.containerPointToCoordinate(t,e)},i.containerPointToViewPoint=function(t,e){return e?e.set(t.x,t.y):e=t.copy(),e._sub(this.getViewPoint())},i.viewPointToContainerPoint=function(t,e){return e?e.set(t.x,t.y):e=t.copy(),e._add(this.getViewPoint())},i.checkSize=function(t){var e=B()-this._initTime<1500&&0===this.width||0===this.height,i=this._getContainerDomSize(),n=this.height,r=this.width;if(!t&&i.width===r&&i.height===n)return this;Ji(this._containerDOM);var o=this.getCenter();if(this.options.fixCenterOnResize)this._updateMapSize(i);else{var s=this._getVisualHeight(this.getPitch()),a=new Bt(0,this.height-s),h=this._containerPointToPrj(a);this._updateMapSize(i);var l=this._getVisualHeight(this.getPitch()),c=new Bt(0,this.height-l);this._setPrjCoordAtContainerPoint(h,c),this._mapViewCoord=this._getPrjCenter()}var u=0===i.width||0===i.height||0===r||0===n;return(e||u)&&(this._eventSilence=!0,this.setCenter(o),delete this._eventSilence),this._fireEvent("resize"),this},i.locate=function(t,e,i){return this.getProjection()._locate(new Hn(t),e,i)},i.getMainPanel=function(){return this._getRenderer().getMainPanel()},i.getPanels=function(){return this._panels},i.remove=function(){var t=this;if(this.isRemoved())return this;this._fireEvent("removestart"),this._removeDomEvents(),this._clearHandlers(),this.removeBaseLayer();for(var e=this.getLayers(),i=0;i<e.length;i++)e[i].remove();return this._getRenderer()&&this._getRenderer().remove(),this._containerDOM.childNodes&&this._containerDOM.childNodes.length>0&&Array.prototype.slice.call(this._containerDOM.childNodes,0).filter((function(t){return"maptalks-wrapper"===t.className})).forEach((function(e){return t._containerDOM.removeChild(e)})),delete this._panels,delete this._containerDOM,delete this.renderer,this._fireEvent("removeend"),this._clearAllListeners(),Ot.removeDPRListening&&Ot.removeDPRListening(this),this},i.isRemoved=function(){return!this._containerDOM},i.isMoving=function(){return!!this._moving},i.onMoveStart=function(t){this._mapAnimPlayer&&this._stopAnim(this._mapAnimPlayer);var e=this._getPrjCenter();this._originCenter&&!this._verifyExtent(e)||(this._originCenter=e),this._moving=!0,this._trySetCursor("move"),this._fireEvent("movestart",this._parseEvent(t?t.domEvent:null,"movestart"))},i.onMoving=function(t){this._fireEvent("moving",this._parseEvent(t?t.domEvent:null,"moving"))},i.onMoveEnd=function(t){if(this._moving=!1,this._trySetCursor("default"),this._fireEvent("moveend",t&&t.domEvent?this._parseEvent(t.domEvent,"moveend"):t),!this._verifyExtent(this._getPrjCenter())&&this._originCenter){var e=this._originCenter;this._panTo(e)}},i.onDragRotateStart=function(t){this._dragRotating=!0,this._fireEvent("dragrotatestart",this._parseEvent(t?t.domEvent:null,"dragrotatestart"))},i.onDragRotating=function(t){this._fireEvent("dragrotating",this._parseEvent(t?t.domEvent:null,"dragrotating"))},i.onDragRotateEnd=function(t){this._dragRotating=!1,this._fireEvent("dragrotateend",this._parseEvent(t?t.domEvent:null,"dragrotateend"))},i.isDragRotating=function(){return!!this._dragRotating},i.isOffscreen=function(t,e){void 0===e&&(e=0);var i=this.width+e,n=this.height+e,r=t.xmin,o=t.ymin,s=t.xmax,a=t.ymax;return Array.isArray(t)&&(r=t[0],o=t[1],s=t[2],a=t[3]),s<e||r>=i||a<e||o>n},i.getRenderer=function(){return this._getRenderer()},i.getDevicePixelRatio=function(){return this.options.devicePixelRatio||Ot.devicePixelRatio||1},i.setDevicePixelRatio=function(t){return j(t)&&t>0&&t!==this.options.devicePixelRatio&&(this.options.devicePixelRatio=t,this.checkSize(!0)),this},i._initContainer=function(t){if(V(t)){if(this._containerDOM=document.getElementById(t),!this._containerDOM)throw new Error("Invalid container when creating map: '"+t+"'")}else this._containerDOM=t,Q&&(this.CanvasClass=this._containerDOM.constructor);if(this._containerDOM.childNodes&&this._containerDOM.childNodes.length>0&&"maptalks-wrapper"===this._containerDOM.childNodes[0].className)throw new Error("Container is already loaded with another map instance, use map.remove() to clear it.")},i._trySetCursor=function(t){return this._cursor||this._priorityCursor||(t||(t="default"),this._setCursorToPanel(t)),this},i._setPriorityCursor=function(t){if(t)this._priorityCursor=t,this._setCursorToPanel(t);else{var e=!1;this._priorityCursor&&(e=!0),delete this._priorityCursor,e&&this.setCursor(this._cursor)}return this},i._setCursorToPanel=function(t){var e=this.getMainPanel();e&&e.style&&e.style.cursor!==t&&(e.style.cursor=t)},i._removeLayer=function(t,e){if(t&&e){var i=e.indexOf(t);i>-1&&e.splice(i,1)}},i._sortLayersByZIndex=function(){if(this._layers){for(var t=0,e=this._layers.length;t<e;t++)this._layers[t]._order=t,this._layers[t].sortLayersByZIndex&&this._layers[t].sortLayersByZIndex();this._layers.sort((function(t,e){var i=t.getZIndex()-e.getZIndex();return 0===i?t._order-e._order:i}))}},i._fireEvent=function(t,e){this._eventSilence||(this.fire("_"+t,e),this.fire(t,e))},i._Load=function(){this._resetMapStatus(),this.options.pitch&&(this.setPitch(this.options.pitch),delete this.options.pitch),this.options.bearing&&(this.setBearing(this.options.bearing),delete this.options.bearing),delete this._glRes,this._loadAllLayers(),this._getRenderer().onLoad(),this._loaded=!0,this._callOnLoadHooks(),this._initTime=B()},i._initRenderer=function(){var t=this.options.renderer,i=e.getRendererClass(t);this._renderer=new i(this),this._renderer.load()},i._getRenderer=function(){return this._renderer},i._loadAllLayers=function(){this._baseLayer&&this._baseLayer.load(),this._eachLayer((function(t){t&&t.load()}),this.getLayers())},i._getLayers=function(t){for(var e=this._baseLayer?[this._baseLayer].concat(this._layers):this._layers,i=[],n=0;n<e.length;n++)t&&!t.call(this,e[n])||i.push(e[n]);return i},i._eachLayer=function(t){if(!(arguments.length<2)){var e=Array.prototype.slice.call(arguments,1);e&&!Array.isArray(e)&&(e=[e]);for(var i=[],n=0,r=e.length;n<r;n++)i=i.concat(e[n]);for(var o=0,s=i.length;o<s;o++)t.call(t,i[o])}},i._onLayerEvent=function(t){t&&"idchange"===t.type&&(delete this._layerCache[t.old],this._layerCache[t.new]=t.target)},i._resetMapStatus=function(){var t=this.getMaxZoom(),e=this.getMinZoom(),i=this._spatialReference.getMaxZoom(),n=this._spatialReference.getMinZoom();(H(t)||-1===t||t>i)&&this.setMaxZoom(i),(H(e)||-1===e||e<n)&&this.setMinZoom(n),(t=this.getMaxZoom())<(e=this.getMinZoom())&&this.setMaxZoom(e),(H(this._zoomLevel)||this._zoomLevel>t)&&(this._zoomLevel=t),this._zoomLevel<e&&(this._zoomLevel=e),delete this._prjCenter;var r=this.getProjection();this._prjCenter=r.project(this._center),this._calcMatrices();var o=this._getRenderer();o&&o.resetContainer()},i._getContainerDomSize=function(){if(!this._containerDOM)return null;var t,e,i=this._containerDOM;if(this._containerDomContentRect)return t=this._containerDomContentRect.width,e=this._containerDomContentRect.height,new si(t,e);if(H(i.width)||H(i.height)){if(H(i.clientWidth)||H(i.clientHeight))throw new Error("can not get size of container");t=parseInt(i.clientWidth,0),e=parseInt(i.clientHeight,0)}else{t=i.width,e=i.height;var n=this.getDevicePixelRatio();1!==n&&i.layer&&(t/=n,e/=n)}return new si(t,e)},i._updateMapSize=function(t){return this.width=t.width,this.height=t.height,this._getRenderer().updateMapSize(t),this._calcMatrices(),this},i._getPrjCenter=function(){return this._prjCenter},i._setPrjCenter=function(t){this._prjCenter=t,this.isInteracting()&&!this.isMoving()&&(this._mapViewCoord=t),this._calcMatrices()},i._setPrjCoordAtContainerPoint=function(t,e){if(e.x===this.width/2&&e.y===this.height/2)return this;var i=this._containerPointToPoint(e)._sub(this._prjToPoint(this._getPrjCenter())),n=this._pointToPrj(this._prjToPoint(t).sub(i));return this._setPrjCenter(n),this},i._verifyExtent=function(t){if(!t)return!1;var e=this._prjMaxExtent;return!e||e.contains(t)},i._offsetCenterByPixel=function(t){var e=new Bt(this.width/2-t.x,this.height/2-t.y),i=this._containerPointToPrj(e);return this._setPrjCenter(i),i},i.offsetPlatform=function(t){return t?(this._getRenderer().offsetPlatform(t),this._mapViewCoord=this._getPrjCenter(),this._mapViewPoint=this._mapViewPoint.add(t),this):this._mapViewPoint},i.getViewPoint=function(){var t=this._getViewPointFrameOffset(),e=this.offsetPlatform();return t&&(e=e.add(t)),e},i._resetMapViewPoint=function(){this._mapViewPoint=new Bt(0,0),this._mapViewCoord=this._getPrjCenter()},i._getResolution=function(t){return void 0!==t&&t!==this._zoomLevel||void 0===this._mapRes?(H(t)&&(t=this._zoomLevel),this._spatialReference.getResolution(t)):this._mapRes},i._getResolutions=function(){return this._spatialReference.getResolutions()},i._prjToPoint=function(t,e,i){e=H(e)?this.getZoom():e;var n=this._getResolution(e);return this._prjToPointAtRes(t,n,i)},i._prjToPointAtRes=function(t,e,i){return this._spatialReference.getTransformation().transform(t,e,i)},i._prjsToPointsAtRes=function(t,e,i){void 0===i&&(i=[]);for(var n=this._spatialReference.getTransformation(),r=[],o=0,s=t.length;o<s;o++){var a=n.transform(t[o],e,i[o]);r.push(a)}return r},i._pointToPrj=function(t,e,i){e=H(e)?this.getZoom():e;var n=this._getResolution(e);return this._pointToPrjAtRes(t,n,i)},i._pointToPrjAtRes=function(t,e,i){return this._spatialReference.getTransformation().untransform(t,e,i)},i._pointToPoint=function(t,e,i){return H(e)?(i?(i.x=t.x,i.y=t.y):i=t.copy(),i):this._pointAtResToPoint(t,this._getResolution(e),i)},i._pointAtResToPoint=function(t,e,i){return i?(i.x=t.x,i.y=t.y):i=t.copy(),i._multi(e/this._getResolution())},i._pointToPointAtRes=function(t,e,i){return i?(i.x=t.x,i.y=t.y):i=t.copy(),i._multi(this._getResolution()/e)},i._containerPointToPrj=function(t,e){return this._pointToPrj(this._containerPointToPoint(t,void 0,e),void 0,e)},i._callOnLoadHooks=function(){var t=e.prototype;if(t._onLoadHooks)for(var i=0,n=t._onLoadHooks.length;i<n;i++)t._onLoadHooks[i].call(this)},i._fixPrjOnWorldWide=function(t){var e=this.getProjection();if(e&&e.fullExtent&&t){var i=e.fullExtent||{},n=i.left,r=i.bottom,o=i.top,s=i.right;j(n)&&(t.x=Math.max(n,t.x)),j(s)&&(t.x=Math.min(s,t.x)),j(r)&&(t.y=Math.max(r,t.y)),j(o)&&(t.y=Math.min(o,t.y))}return this},e}(kn(Cn(wr(Ln))));Ss.include({coordinateToPoint:function(t,e,i){var n=this._getResolution(e);return this.coordinateToPointAtRes(t,n,i)},coordinateToPointAtRes:(xs=new Hn(0,0),function(t,e,i){var n=this.getProjection().project(t,xs);return this._prjToPointAtRes(n,e,i)}),pointToCoordinate:function(){var t=new Hn(0,0);return function(e,i,n){var r=this._pointToPrj(e,i,t);return this.getProjection().unproject(r,n)}}(),pointAtResToCoordinate:function(){var t=new Hn(0,0);return function(e,i,n){var r=this._pointToPrjAtRes(e,i,t);return this.getProjection().unproject(r,n)}}(),coordinateToViewPoint:function(){var t=new Hn(0,0);return function(e,i,n){return this._prjToViewPoint(this.getProjection().project(e,t),i,n)}}(),viewPointToCoordinate:function(){var t=new Hn(0,0);return function(e,i){return this.getProjection().unproject(this._viewPointToPrj(e,t),i)}}(),coordinateToContainerPoint:function(t,e,i){var n=this._getResolution(e);return this.coordinateToContainerPointAtRes(t,n,i)},coordinateToContainerPointAtRes:function(){var t=new Hn(0,0);return function(e,i,n){var r=this.getProjection().project(e,t);return this._prjToContainerPointAtRes(r,i,n)}}(),coordinatesToContainerPoints:function(t,e){var i=this._getResolution(e);return this.coordinatesToContainerPointsAtRes(t,i)},coordinatesToContainerPointsAtRes:function(t,e){for(var i=[],n=this._spatialReference.getTransformation(),r=e/this._getResolution(),o=this.getProjection(),s=new Hn(0,0),a=this.isTransforming(),h=this._prjToPoint(this._getPrjCenter(),void 0,ws),l=0,c=t.length;l<c;l++){var u=o.project(t[l],s),d=n.transform(u,e);d=d._multi(r),this._toContainerPoint(d,a,r,0,h),i.push(d)}return i},containerPointToCoordinate:function(){var t=new Hn(0,0);return function(e,i){var n=this._containerPointToPrj(e,t);return this.getProjection().unproject(n,i)}}(),containerToExtent:(ys=new Bt(0,0),_s=new Bt(0,0),function(t){var e=new er(this._containerPointToPoint(t.getMin(ys),void 0,ys),this._containerPointToPoint(t.getMax(_s),void 0,_s));return this._pointToExtent(e)}),distanceToPixel:function(){var t=new Bt(0,0),e=new Bt(0,0);return function(i,n,r){var o=this.getProjection();if(!o)return null;var s=this.getScale()/this.getScale(r),a=this.getCenter(),h=o.locate(a,i,n),l=this.coordToContainerPoint(a,void 0,t),c=this.coordToContainerPoint(h,void 0,e);return c._sub(l)._multi(s)._abs(),new si(c.x,c.y)}}(),distanceToPoint:function(t,e,i,n){var r=this._getResolution(i);return this.distanceToPointAtRes(t,e,r,n)},distanceToPointAtRes:function(){var t=new Bt(0,0),e=new Hn(0,0);return function(i,n,r,o,s){var a=this.getProjection();if(!a)return null;var h=o||this.getCenter(),l=a.locate(h,i,n,e),c=this.coordToPointAtRes(h,r,t),u=this.coordToPointAtRes(l,r,s);return u._sub(c)._abs(),u}}(),altitudeToPoint:(gs=new Hn(0,40),vs=new Bt(0,0),function(t,e,i){void 0===t&&(t=0);var n=this.distanceToPointAtRes(t,t,e,i||gs,vs);t<0&&n.x>0&&(n.x=-n.x);var r=this.options.heightFactor;return r&&1!==r&&(n.x*=r,n.y*=r),n.x}),pointAtResToAltitude:function(){var t=new Hn(0,40);return function(e,i,n){return void 0===e&&(e=0),this.pointAtResToDistance(e,0,i,n||t)}}(),pixelToDistance:(fs=new Hn(0,0),ms=new Hn(0,0),function(t,e){var i=this.getProjection();if(!i)return null;var n=this.getFullExtent(),r=n.top>n.bottom?-1:1,o=fs.set(this.width/2+t,this.height/2+r*e),s=this.containerPointToCoord(o,ms);return i.measureLength(this.getCenter(),s)}),pointToDistance:function(t,e,i){var n=this.getResolution(i);return this.pointAtResToDistance(t,e,n)},pointAtResToDistance:function(){var t=new Bt(0,0),e=new Hn(0,0),i=new Hn(0,0),n=new Hn(0,0);return function(r,o,s,a){var h=this.getProjection();if(!h)return null;var l=a?h.project(a,e):this._getPrjCenter(),c=this._prjToPointAtRes(l,s,t);c._add(r,o);var u=this.pointAtResToCoord(c,s,i),d=a||h.unproject(l,n);return h.measureLength(d,u)}}(),locateByPoint:function(){var t=new Bt(0,0);return function(e,i,n){var r=this.coordToContainerPoint(e,void 0,t);return this.containerPointToCoord(r._add(i,n))}}(),_get2DExtent:function(t,e){var i;if(void 0!==t&&t!==this._zoomLevel||!this._mapExtent2D||(i=this._mapExtent2D),i)return e?(e.set(i.xmin,i.ymin,i.xmax,i.ymax),e):i.copy();var n=this._getResolution(t);return this._get2DExtentAtRes(n,e)},_get2DExtentAtRes:function(){var t=new Bt(0,0);return function(e,i){var n=this;return e===this._mapGlRes&&this._mapGlExtent2D?this._mapGlExtent2D:this.getContainerExtent().convertTo((function(i){return n._containerPointToPointAtRes(i,e,t)}),i)}}(),_pointToExtent:function(){var t=new Hn(0,0),e=new Hn(0,0);return function(i){var n=i.getMin(),r=i.getMax(),o=this.getFullExtent(),s=!o||o.left<=o.right?[n.x,r.x]:[r.x,n.x],a=s[0],h=s[1],l=!o||o.top>o.bottom?[r.y,n.y]:[n.y,r.y],c=l[0],u=l[1],d=n.set(a,u),p=r.set(h,c);return new tr(this.pointToCoord(d,void 0,t),this.pointToCoord(p,void 0,e),this.getProjection())}}(),_getViewPointFrameOffset:function(){var t=new Bt(0,0);return function(){if(this.isZooming())return null;var e=this._getPrjCenter();return this._mapViewCoord&&!this._mapViewCoord.equals(e)?this._prjToContainerPoint(this._mapViewCoord)._sub(this._prjToContainerPoint(e,void 0,t)):null}}(),_viewPointToPrj:function(){var t=new Bt(0,0);return function(e,i){return this._containerPointToPrj(this.viewPointToContainerPoint(e,t),i)}}(),_prjToContainerPoint:function(t,e,i,n){var r=this._getResolution(e);return this._prjToContainerPointAtRes(t,r,i,n)},_prjToContainerPointAtRes:function(){var t=new Bt(0,0);return function(e,i,n,r){return this._pointAtResToContainerPoint(this._prjToPointAtRes(e,i,t),i,r||0,n)}}(),_prjToViewPoint:function(){var t=new Bt(0,0);return function(e,i,n){var r=this._prjToContainerPoint(e,void 0,t,n);return this.containerPointToViewPoint(r,i)}}(),_viewPointToPoint:function(){var t=new Bt(0,0);return function(e,i,n){return this._containerPointToPoint(this.viewPointToContainerPoint(e,t),i,n)}}(),_pointToViewPoint:function(){var t=new Hn(0,0);return function(e,i,n){return this._prjToViewPoint(this._pointToPrj(e,i,t),n)}}()}),Ss.mergeOptions(Ms);var Ts=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.addHooks=function(){this.target&&this.target.on("_dblclick",this._onDoubleClick,this)},i.removeHooks=function(){this.target&&this.target.off("_dblclick",this._onDoubleClick,this)},i._onDoubleClick=function(t){var e=this.target;if(e.options.doubleClickZoom){var i=e.getZoom(),n=t.domEvent.shiftKey?Math.ceil(i)-1:Math.floor(i)+1;e._zoomAnimation(n,t.containerPoint)}},e}(An);Ss.mergeOptions({doubleClickZoom:!0}),Ss.addOnLoadHook("addHandler","doubleClickZoom",Ts);var Es=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.addHooks=function(){var t=this.target;if(t){var e=t._panels.mapWrapper||t._containerDOM;this._dragHandler=new Nn(e,{cancelOn:this._cancelOn.bind(this),rightclick:!0}),this._dragHandler.on("mousedown",this._onMouseDown,this).on("dragstart",this._onDragStart,this).on("dragging",this._onDragging,this).on("dragend",this._onDragEnd,this).enable()}},i.removeHooks=function(){this._dragHandler.off("mousedown",this._onMouseDown,this).off("dragstart",this._onDragStart,this).off("dragging",this._onDragging,this).off("dragend",this._onDragEnd,this),this._dragHandler.remove(),delete this._dragHandler},i._cancelOn=function(t){return!(!this.target.isZooming()&&!this._ignore(t))},i._ignore=function(t){return!!t&&(t.domEvent&&(t=t.domEvent),this.target._ignoreEvent(t))},i._onMouseDown=function(t){delete this.startDragTime,delete this._mode,2===t.domEvent.button||t.domEvent.ctrlKey?(this.target.options.dragRotate||this.target.options.dragPitch)&&(this._mode="rotatePitch"):this.target.options.dragPan&&(this._mode="move"),this.target._stopAnim(this.target._mapAnimPlayer),Zi(t.domEvent)},i._onDragStart=function(t){this.startDragTime=B(),"move"===this._mode?this._moveStart(t):"rotatePitch"===this._mode&&this._rotateStart(t)},i._onDragging=function(t){this.target._isEventOutMap(t.domEvent)||("move"===this._mode?this._moving(t):"rotatePitch"===this._mode&&this._rotating(t))},i._onDragEnd=function(t){"move"===this._mode?this._moveEnd(t):"rotatePitch"===this._mode&&this._rotateEnd(t),delete this.startDragTime,delete this.startBearing},i._start=function(t){this.preX=t.mousePos.x,this.preY=t.mousePos.y,this.startX=this.preX,this.startY=this.preY,this._startPrjCenter=this.target._getPrjCenter().copy()},i._moveStart=function(t){this._start(t);var e=this.target;e.onMoveStart(t);var i=Qi(e._getActualEvent(t.domEvent),e.getContainer());this.startPrjCoord=e._containerPointToPrj(i)},i._moving=function(t){if(this.startDragTime){var e=this.target,i=Qi(e._getActualEvent(t.domEvent),e.getContainer());e._setPrjCoordAtContainerPoint(this.startPrjCoord,i),e.onMoving(t)}},i._moveEnd=function(t){if(this.startDragTime){var e="touchend"===t.domEvent.type,i=this.target,n=B()-this.startDragTime,r=t.mousePos.x,o=t.mousePos.y,s=r-this.startX,a=o-this.startY,h=i._getPrjCenter(),l=h.sub(this._startPrjCenter);if(this._clear(),i.options.panAnimation&&!t.interupted&&i._verifyExtent(i._getPrjCenter())&&n<280&&Math.abs(a)+Math.abs(s)>5){n*=5;var c=e?5:2.8,u=h.add(l._multi(c));i._panTo(u,{duration:e?3*n:2*n,easing:"outExpo"})}else i.onMoveEnd(t)}},i._rotateStart=function(t){this._start(t),delete this._rotateMode,this.startBearing=this.target.getBearing(),this.target.onDragRotateStart(t),this._db=0},i._rotating=function(t){var e=this.target,i=t.mousePos.x,n=t.mousePos.y,r=e.getPitch(),o=e.getBearing(),s=Math.abs(i-this.preX),a=Math.abs(n-this.preY);if(this._rotateMode||(e.options.dragRotatePitch?this._rotateMode="rotate_pitch":this._rotateMode=s>a?"rotate":s<a?"pitch":"rotate"),!("pitch"===this._rotateMode&&0===r&&a<10)){if(this._rotateMode.indexOf("rotate")>=0&&e.options.dragRotate){var h=0;h=e.options.dragPitch||s>a?-.6*(this.preX-i):i>e.width/2?.6*(this.preY-n):-.6*(this.preY-n);var l=e.getBearing()+h;this._db=this._db||0,this._db+=h,e._setBearing(l)}this._rotateMode.indexOf("pitch")>=0&&e.options.dragPitch&&e._setPitch(e.getPitch()+.4*(this.preY-n)),this.preX=i,this.preY=n,e.getBearing()===o&&e.getPitch()===r||e.onDragRotating(t)}},i._rotateEnd=function(t){var e=this.target,i=e.getBearing();this._clear();var n=B()-this.startDragTime;if(e.onDragRotateEnd(t),e.options.rotateAnimation&&Math.abs(i-this.startBearing)>20&&("rotate"===this._rotateMode||"rotate_pitch"===this._rotateMode)&&!t.interupted&&n<400){var r=e.getBearing();e._animateTo({bearing:r+this._db/1.5},{easing:"outQuint",duration:1600})}},i._clear=function(){delete this.startPrjCoord,delete this.preX,delete this.preY,delete this.startX,delete this.startY},e}(An);Ss.mergeOptions({draggable:!0,dragPan:!0,dragRotatePitch:!0,dragRotate:!0,dragPitch:!0}),Ss.addOnLoadHook("addHandler","draggable",Es);var Cs="mousedown mouseup mousemove click dblclick contextmenu touchstart touchmove touchend",Ps={mousemove:["mousemove","mouseover","mouseout","mouseenter"],touchend:["touchend","click"]},As=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.addHooks=function(){var t=this.target,e=t._panels.allLayers||t._containerDOM;ln(e,Cs,this._identifyGeometryEvents,this)},i.removeHooks=function(){var t=this.target,e=t._panels.allLayers||t._containerDOM;cn(e,Cs,this._identifyGeometryEvents)},i._identifyGeometryEvents=function(t,e){var i=this.target;if(!i.isInteracting()&&!i._ignoreEvent(t)){var n=null,r=e||t.type,o="mousedown"===r||"touchstart"===r&&t.touches&&1===t.touches.length;if(o)this._mouseDownTime=B();else if(("click"===r||"touchend"===r)&&this._mouseDownTime){var s=this._mouseDownTime;if(delete this._mouseDownTime,B()-s>300){if("click"===r)return}else"touchend"===r&&(n="click")}var a=t.touches&&t.touches.length>0?t.touches[0]:t.changedTouches&&t.changedTouches.length>0?t.changedTouches[0]:t;if(a){var h=Qi(a,i._containerDOM);"touchstart"===r&&Zi(t);for(var l=null,c=this.target.getRenderer().getTopElements(),u=o&&2!==t.button,d=0;d<c.length;d++)if(c[d].hitTest(h)){var p=c[d].options.cursor;if(p&&(l=p),u||c[d].events&&c[d].events.indexOf(r)>=0){var f={target:i,type:r,domEvent:t,containerPoint:h};if(u)return i._setPriorityCursor(l),void c[d].mousedown(f);c[d].onEvent(f)}}var m=i._getLayers((function(t){return!(!t.identify||!t.options.geometryEvents)}));if(i._setPriorityCursor(l),m.length){var g=Ps[r]||[r],v={includeInternals:!0,filter:function(e){if(!(e instanceof os))return!1;var i=e._getEventTypeToFire(t);if("mousemove"===r){if(!l&&e.options.cursor&&(l=e.options.cursor),!e.listens("mousemove")&&!e.listens("mouseover")&&!e.listens("mouseenter"))return!1}else if(!e.listens(i)&&!e.listens(n))return!1;return!0},count:1,onlyVisible:i.options.onlyVisibleGeometryEvents,containerPoint:h,layers:m,eventTypes:g},y=function(e){var o=!0;if("mousemove"===r){var s={};if(e.length>0)for(var a=e.length-1;a>=0;a--){var h=e[a];if(h instanceof os){var c=h._getInternalId();s[c]=h,h._onEvent(t),this._prevOverGeos&&this._prevOverGeos.geomap[c]||h._onEvent(t,"mouseenter"),o=h._onEvent(t,"mouseover")}}i._setPriorityCursor(l);var u=this._prevOverGeos&&this._prevOverGeos.geos;if(this._prevOverGeos={geos:e,geomap:s},u&&u.length>0)for(var d=u.length-1;d>=0;d--){var p=u[d];if(p instanceof os)s[u[d]._getInternalId()]||(o=p._onEvent(t,"mouseout"))}}else{if(!e||!e.length)return;for(var f=e.length-1;f>=0;f--)if(e[f]instanceof os){o=e[f]._onEvent(t),n&&e[f]._onEvent(t,n);break}}!1===o&&qi(t)}.bind(this);"mousemove"===r||"touchmove"===r?this._queryIdentifyTimeout=i.getRenderer().callInNextFrame((function(){i.isInteracting()||i.identifyAtPoint(v,y)})):i.identifyAtPoint(v,y)}}}},e}(An);Ss.mergeOptions({geometryEvents:!0,onlyVisibleGeometryEvents:!0}),Ss.addOnLoadHook("addHandler","geometryEvents",As);var Ls=4.000244140625,Rs=function(t){function e(e){var i;return(i=t.call(this,e)||this)._thisScrollZoom=i._scrollZoom.bind(It(It(i))),i._wheelZoomRate=.0022222222222222222,i._defaultZoomRate=.01,i._delta=0,i}Dt(e,t);var i=e.prototype;return i.addHooks=function(){Ui(this.target._containerDOM,"wheel",this._onWheelScroll,this)},i.removeHooks=function(){Vi(this.target._containerDOM,"wheel",this._onWheelScroll)},i._onWheelScroll=function(t){var e=this.target;if(e.options.preventWheelScroll&&(Zi(t),qi(t)),e._ignoreEvent(t)||!e.options.zoomable)return!1;var i=e._containerDOM,n=e._checkZoomOrigin(Qi(t,i));return e.options.seamlessZoom?(this._zooming||(this._trackPadSuspect=0,this._ensureTrackpad=!1),this._seamless(t,n)):this._interval(t,n)},i._seamless=function(t,e){var i=t.deltaMode===window.WheelEvent.DOM_DELTA_LINE?60*t.deltaY:t.deltaY;if(i%Ls!=0&&(this._ensureTrackpad||(Math.abs(i)<60?this._trackPadSuspect++:this._trackPadSuspect=0,this._trackPadSuspect>=2&&(this._ensureTrackpad=!0)),this._ensureTrackpad&&(i*=14)),t.shiftKey&&i&&(i/=4),this._lastWheelEvent=t,this._delta-=i,!this._zooming&&this._delta){var n=this.target;this._zoomOrigin=e,n.onZoomStart(null,e)}this._start()},i._start=function(){if(this._delta){this._zooming=!0;var t=this.target;this._active||(t.getRenderer().callInNextFrame(this._thisScrollZoom),this._active=!0)}},i._scrollZoom=function(){var t=this;if(this._active=!1,this._delta){var e=Math.abs(this._delta)>Ls?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);var n=this.target,r=n.getZoom(),o=n.getZoomForScale(i,r,!0);this._delta=0,n.onZooming(o,this._zoomOrigin),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((function(){t._zooming=!1,delete t._timeout,n.onZoomEnd(n.getZoom(),t._zoomOrigin)}),210)}},i._interval=function(t,e){var i=this,n=this.target;if(this._zooming)return this._requesting++,!1;this._requesting=0;var r=(t.deltaY?-1*t.deltaY:t.wheelDelta?t.wheelDelta:t.detail)>0?1:-1;t.detail&&(r*=-1);var o=n.getZoom(),s=o+r;if((s=n._checkZoom(r>0?Math.ceil(s):Math.floor(s)))===o)return!1;this._zooming=!0,this._delta||(n.onZoomStart(null,e),this._origin=e,this._delta=r,this._startZoom=n.getZoom());return n._animateTo({zoom:s-1*this._delta/2,around:this._origin},{continueOnViewChanged:!0,easing:"linear",duration:90,wheelZoom:!0},(function(e){"finished"===e.state.playState?i._requesting<1||Math.abs(s-i._startZoom)>2||s===n.getMaxZoom()||s===n.getMinZoom()?(n._animateTo({zoom:s,around:i._origin},{continueOnViewChanged:!0,duration:100},(function(t){"running"!==t.state.playState&&(delete i._zooming,delete i._requesting)})),delete i._startZoom,delete i._origin,delete i._delta,i._requesting=0):H(i._requesting)||(delete i._zooming,i._onWheelScroll(t)):"running"!==e.state.playState&&(delete i._zooming,delete i._requesting)})),!1},e}(An);Ss.mergeOptions({scrollWheelZoom:!0,seamlessZoom:!0}),Ss.addOnLoadHook("addHandler","scrollWheelZoom",Rs);var Os=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.addHooks=function(){Ui(this.target.getContainer(),"touchstart",this._onTouchStart,this)},i.removeHooks=function(){Vi(this.target.getContainer(),"touchstart",this._onTouchStart)},i._onTouchStart=function(t){var e=this.target;if(t.touches&&!(t.touches.length<2)){var i=e.getContainer(),n=Qi(t.touches[0],i),r=Qi(t.touches[1],i);this.preY=n.y,this._startP1=n,this._startP2=r,this._startDist=n.distanceTo(r),this._startVector=n.sub(r),this._startZoom=e.getZoom(),this._startBearing=e.getBearing(),cn(document,"touchmove",this._onTouchMove),cn(document,"touchend",this._onTouchEnd),Ui(document,"touchmove",this._onTouchMove,this),Ui(document,"touchend",this._onTouchEnd,this),Zi(t),e._fireEvent("touchactstart")}},i._onTouchMove=function(t){var e=this.target;if(t.touches&&!(t.touches.length<2)){var i=e.getContainer(),n=Qi(t.touches[0],i),r=Qi(t.touches[1],i),o=n.sub(this._startP1),s=r.sub(this._startP2),a=n.sub(r),h=n.distanceTo(r)/this._startDist,l=180*a.angleWith(this._startVector)/Math.PI,c=.4*((this.preY||n.y)-n.y);this.preY=n.y;var u={domEvent:t,mousePos:[n,r]};if(this.mode||(e.options.touchRotate&&Math.abs(l)>8?this.mode=e.options.touchZoomRotate?"rotate_zoom":"rotate":e.options.touchPitch&&o.y*s.y>0&&Math.abs(o.y)>10&&Math.abs(s.y)>10?this.mode="pitch":e.options.zoomable&&e.options.touchZoom&&Math.abs(1-h)>.15&&(this.mode=e.options.touchZoomRotate&&e.options.touchRotate?"rotate_zoom":"zoom"),this._startTouching(u)),"zoom"===this.mode||"rotate_zoom"===this.mode){this._scale=h;var d=e._getResolution(this._startZoom)/h,p=e.getZoomFromRes(d);e.onZooming(p,this._Origin)}"rotate"===this.mode||"rotate_zoom"===this.mode?(e._setBearing(this._startBearing+l),e.onDragRotating(u)):"pitch"===this.mode&&(e._setPitch(e.getPitch()+c),e.onDragRotating(u)),e._fireEvent("touchactinging")}},i._startTouching=function(t){var e=this.target;if("zoom"===this.mode||"rotate_zoom"===this.mode){var i=e.getSize();this._Origin=new Bt(i.width/2,i.height/2),e.onZoomStart(null,this._Origin)}"rotate"!==this.mode&&"pitch"!==this.mode&&"rotate_zoom"!==this.mode||e.onDragRotateStart(t)},i._onTouchEnd=function(t){delete this.preY;var e=this.target;if(cn(document,"touchmove",this._onTouchMove),cn(document,"touchend",this._onTouchEnd),"zoom"===this.mode||"rotate_zoom"===this.mode){var i=this._scale,n=e._getResolution(this._startZoom)/i,r=e.getZoomFromRes(n);e.onZoomEnd(r,this._Origin)}"pitch"!==this.mode&&"rotate"!==this.mode&&"rotate_zoom"!==this.mode||e.onDragRotateEnd({domEvent:t}),delete this.mode,e._fireEvent("touchactend")},e}(An);Ss.mergeOptions({touchGesture:!0,touchZoom:!0,touchPitch:!0,touchRotate:!0,touchZoomRotate:!1}),Ss.addOnLoadHook("addHandler","touchGesture",Os);var Ds="__anim_player",Is={outExpo:function(t){return 1===t?1:1-Math.pow(2,-10*t)},outQuint:function(t){return 1-Math.pow(1-t,5)},in:function(t){return Math.pow(t,2)},out:function(t){return 1-Is.in(1-t)},inAndOut:function(t){return 3*t*t-2*t*t*t},linear:function(t){return t},upAndDown:function(t){return t<.5?Is.inAndOut(2*t):1-Is.inAndOut(2*(t-.5))}},ks=function(t,e){this.state=t,this.styles=e},zs=function(t,e,i,n){this._animation=t,this.options=e,this._onFrame=i,this.playState="idle",this.ready=!0,this.finished=!1,this.target=n},Fs={speed:{slow:2e3,normal:1e3,fast:500},_resolveStyles:function(t){if(!t)return null;function e(t){if(!Array.isArray(t))return Fs._resolveStyles(t);for(var e=[],i=[],n=[],r=0;r<t.length;r++){var o=Fs._resolveStyles(t[r]);o&&(e.push(o[0]),i.push(o[1]),n.push(o[2]))}return e.length?[e,i,n]:null}function i(t){var e,i=t;Array.isArray(t)||(i=j(t)?[0,t]:t instanceof Bt||t instanceof Hn?[new(e=t.constructor)(0,0),t]:[t,t]);var n=i[0],r=i[1];return j(n)&&j(r)?n===r?null:[n,r-n,r]:Array.isArray(n)&&j(n[0])||n instanceof Hn||n instanceof Bt?(Array.isArray(n)?(n=new Hn(n),r=new Hn(r)):(n=new(e=n.constructor)(n),r=new e(r)),n.equals(r)?null:[n,r.sub(n),r]):[n,r,r]}var n,r={},o={},s={};for(var a in t)if(t.hasOwnProperty(a)){var h=t[a];if(!h)continue;if(Array.isArray(h)&&(H(h[0])||H(h[1])))continue;var l=void 0;n=h,(l=!Array.isArray(n)&&n.constructor===Object||Array.isArray(n)&&n[0].constructor===Object?e(h):i(h))&&(o[a]=l[0],r[a]=l[1],s[a]=l[2])}return[o,r,s]},framing:function(t,e){e||(e={});var i,n,r,o=e.easing?Is[e.easing]:Is.linear;o||(o=Is.linear),(t=Fs._resolveStyles(t))&&(n=t[0],i=t[1],r=t[2]);var s=function t(e,i,n){if(!i||!n)return null;var o={};for(var s in n)if(n.hasOwnProperty(s)){if(i[s]===r[s]){o[s]=i[s];continue}var a=i[s],h=n[s];if(j(h))o[s]=a+e*h;else if(Array.isArray(h)){for(var l=[],c=0;c<h.length;c++)l.push(t(e,a[c],h[c]));o[s]=l}else{var u=h.constructor;o[s]=u===Object?t(e,a,h):a instanceof Bt||a instanceof Hn?a.add(h.multi(e)):h}}return o};return function(t,e){var a,h;if(t<0)a={playState:"idle",delta:0},h=n;else if(t<e){var l=o(t/e);a={playState:"running",delta:l},h=s(l,n,i)}else a={playState:"finished",delta:1},h=r;return a.startStyles=n,a.destStyles=r,a.progress=t,a.remainingMs=e-t,new ks(a,h)}},_requestAnimFrame:function(t){this._frameQueue||(this._frameQueue=[]),this._frameQueue.push(t),this._a()},_a:function(){this._animationFrameId||(this._animationFrameId=kt(Fs._frameFn))},_run:function(){if(this._frameQueue.length){var t=this._frameQueue;this._frameQueue=[];for(var e=0,i=t.length;e<i;e++)t[e]();this._frameQueue.length?this._animationFrameId=kt(Fs._frameFn):delete this._animationFrameId}},animate:function(t,e,i,n){e||(e={});var r=Fs.framing(t,e);return new zs(r,e,i,n)}};Fs._frameFn=Fs._run.bind(Fs),N(zs.prototype,{_prepare:function(){var t=this.options,e=t.speed||t.duration;V(e)&&((e=Fs.speed[e])||(e=+e)),e||(e=Fs.speed.normal),this.duration=e,this._framer=t.framer||Fs._requestAnimFrame.bind(Fs)},play:function(){if("idle"!==this.playState&&"paused"!==this.playState||this.target&&this.target[Ds])return this;this.target&&(this.target[Ds]=1),"idle"===this.playState&&(this.currentTime=0,this._prepare());var t=B();if(!this.startTime){var e=this.options;this.startTime=e.startTime?e.startTime:t}return this._playStartTime=Math.max(t,this.startTime),"paused"===this.playState&&(this._playStartTime-=this.currentTime),this.playState="running",this._run(),this},pause:function(){return"paused"===this.playState||(this.playState="paused",this._run()),this},cancel:function(){return"idle"===this.playState||(this.playState="idle",this.finished=!1,this._run()),this},finish:function(){return"finished"===this.playState||(this.playState="finished",this.finished=!0,this._run()),this},reverse:function(){},_run:function(){var t=this,e=this._onFrame,i=B(),n=i-this._playStartTime;if(this.options.repeat&&n>=this.duration&&(this._playStartTime=i,n=0),"running"===this.playState){var r=this._animation(n,this.duration);this.playState=r.state.playState,"running"!==this.playState&&this.target&&delete this.target[Ds],"idle"===this.playState?this.startTime>i&&setTimeout(this._run.bind(this),this.startTime-i):"running"===this.playState?this._framer((function(){"running"===t.playState&&(t.currentTime=n,e&&e(r),t._run())})):"finished"===this.playState&&(this.finished=!0,e&&e(r))}else if(this.target&&delete this.target[Ds],e){"finished"===this.playState?n=this.duration:"idle"===this.playState&&(n=0);var o=this._animation(n,this.duration);o.state.playState=this.playState,e(o)}}});var Bs=Object.freeze({Animation:Fs,Easing:Is,Player:zs,Frame:ks}),Ns=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.animateShow=function(t,e){var i=this;void 0===t&&(t={}),this._showPlayer&&this._showPlayer.finish(),W(t)&&(e=t={});var n=this.getCoordinates();if(0===n.length)return this;this._animIdx=0,this._animLenSoFar=0,this.show();var r=!!this.getShell?this.getShell().concat(this.getShell()[0]):n,o=this._getProjection(),s=o.projectCoords(r,this.options.antiMeridian);this._prjAniShowCenter=this._getPrjExtent().getCenter(),this._aniShowCenter=o.unproject(this._prjAniShowCenter);var a=t.duration||1e3,h=t.easing||"out";this.setCoordinates([]);var l=0;s.length&&(s[0]._distance=0);for(var c=1;c<s.length;c++){var u=s[c].distanceTo(s[c-1]);s[c]._distance=u,l+=u}this._tempCoord=new Hn(0,0),this._tempPrjCoord=new Bt(0,0);var d=this._showPlayer=Fs.animate({t:a},{duration:a,easing:h},(function(t){if(i.getMap()){var o=i._drawAnimShowFrame(t.styles.t,a,l,r,s);"finished"===t.state.playState&&(delete i._showPlayer,delete i._aniShowCenter,delete i._prjAniShowCenter,delete i._animIdx,delete i._animLenSoFar,delete i._animTailRatio,delete i._tempCoord,delete i._tempPrjCoord,i.setCoordinates(n)),e&&e(t,o)}else if("finished"!==d.playState&&(d.finish(),e)){var h=i.getCoordinates();e(t,h[h.length-1])}}),this);return d.play(),d},i._drawAnimShowFrame=function(t,e,i,n,r){if(0===t)return n[0];var o,s,a=t/e*i,h=0;for(o=this._animIdx+1,s=r.length;o<s&&(h=r[o]._distance,!(this._animLenSoFar+h>a));o++)this._animLenSoFar+=h;if(this._animIdx=o-1,this._animIdx>=s-1)return this.setCoordinates(n),n[n.length-1];var l=this._animIdx,c=r[l],u=r[l+1],d=(a-this._animLenSoFar)/h;this._animTailRatio=d;var p=c.x+(u.x-c.x)*d,f=c.y+(u.y-c.y)*d;this._tempPrjCoord.x=p,this._tempPrjCoord.y=f;var m=this._tempPrjCoord,g=n[l],v=n[l+1],y=g.x+(v.x-g.x)*d,_=g.y+(v.y-g.y)*d;this._tempCoord.x=y,this._tempCoord.y=_;var x=this._tempCoord,w=!!this.getShell;if(!w&&this.options.smoothness>0){for(var b=[],M=[],S=0;S<=this._animIdx;S++)b.push(n[S]),M.push(r[S]);b.push(x,x),M.push(m,m),this.setCoordinates(b),this._setPrjCoordinates(M)}else{var T=n.slice(0,this._animIdx+1);T.push(x);var E=r.slice(0,this._animIdx+1);E.push(m),w?(this.setCoordinates([this._aniShowCenter].concat(T)),this._setPrjCoordinates([this._prjAniShowCenter].concat(E))):(this.setCoordinates(T),this._setPrjCoordinates(E))}return x},i._getCenterInExtent=function(t,e,i){var n=this.getExtent();if(!t.intersects(n))return null;var r=i(e,t);if(0===r.length)return null;var o=0,s=0,a=0;r.forEach((function(t){Array.isArray(t)?t.forEach((function(t){t.point&&(t=t.point),o+=t.x,s+=t.y,a++})):(t.point&&(t=t.point),o+=t.x,s+=t.y,a++)}));var h=new Hn(o,s)._multi(1/a);return h.count=a,h},i._getPath2DPoints=function(t,e,i){if(!te(t))return[];var n=this.getMap(),r=!e&&this._shouldSimplify(),o=this.options.simplifyTolerance*n._getResolution(),s=Array.isArray(t[0]);if(delete this._simplified,r&&!s){var a=t.length;t=b(t,o,!1),this._simplified=t.length<a}if(i||(i=n._getResolution()),Array.isArray(t)){var h=[],l="_glPt";if(!Array.isArray(t[0]))return h=fe(t,l),n._prjsToPointsAtRes(t,i,h);for(var c=[],u=0,d=t.length;u<d;u++){var p=t[u];h=fe(p,l);var f=n._prjsToPointsAtRes(p,i,h);c.push(f)}return c}return n._prjToPointAtRes(t,i)},i._shouldSimplify=function(){var t=this.getLayer(),e=this.getProperties(),i=e&&t.options.enableAltitude&&!H(e[t.options.altitudeProperty])&&0!==e[t.options.altitudeProperty];return t&&t.options.enableSimplify&&!i&&this.options.enableSimplify&&!this._showPlayer},i._setPrjCoordinates=function(t){this._prjCoords=t,this.onShapeChanged()},i._getPrjCoordinates=function(){return this._verifyProjection(),!this._prjCoords&&this._getProjection()&&(this._prjCoords=this._projectCoords(this._coordinates)),this._prjCoords},i._updateCache=function(){this._clearCache(),this._getProjection()&&this._prjCoords&&(this._coordinates=this._unprojectCoords(this._getPrjCoordinates()))},i._clearProjection=function(){this._prjCoords=null,t.prototype._clearProjection.call(this)},i._projectCoords=function(t){var e=this._getProjection();return e?e.projectCoords(t,this.options.antiMeridian):[]},i._unprojectCoords=function(t){var e=this._getProjection();return e?e.unprojectCoords(t):[]},i._computeCenter=function(){var t=this._coordinates;if(!te(t))return null;for(var e=0,i=0,n=0,r=t.length,o=0;o<r;o++)t[o]&&j(t[o].x)&&j(t[o].y)&&(e+=t[o].x,i+=t[o].y,n++);return new Hn(e/n,i/n)},i._computeExtent=function(){var t=this._coordinates;if(!te(t))return null;var e=[t];return this.hasHoles&&this.hasHoles()&&e.push.apply(e,this.getHoles()),this._coords2Extent(e,this._getProjection())},i._computePrjExtent=function(){var t=[this._getPrjCoordinates()];return this.hasHoles&&this.hasHoles()&&t.push.apply(t,this._getPrjHoles()),this._coords2Extent(t)},i._get2DLength=function(){for(var t=this._getPath2DPoints(this._getPrjCoordinates(),!0),e=0,i=1,n=t.length;i<n;i++)e+=t[i].distanceTo(t[i-1]);return e},i._hitTestTolerance=function(){var e,i=this._getInternalSymbol();if(Array.isArray(i)){e=0;for(var n=0;n<i.length;n++)j(i[n].lineWidth)&&i[n].lineWidth>e&&(e=i[n].lineWidth)}else e=i.lineWidth;return t.prototype._hitTestTolerance.call(this)+(j(e)?e/2:1.5)},i._coords2Extent=function(t,e){if(!t||0===t.length||Array.isArray(t[0])&&0===t[0].length)return null;for(var i=new tr(e),n=0,r=t.length;n<r;n++)for(var o=0,s=t[n].length;o<s;o++)i._combine(t[n][o]);return i},e}(os);Ns.mergeOptions({smoothness:0,enableClip:!0,enableSimplify:!0,simplifyTolerance:2,symbol:{lineColor:"#000",lineWidth:2,lineOpacity:1,polygonFill:"#fff",polygonOpacity:1,opacity:1}});var Hs="Polygon",js=function(t){function e(e,i){var n;return(n=t.call(this,i)||this).type="Polygon",e&&n.setCoordinates(e),n}Dt(e,t);var i=e.prototype;return i.getOutline=function(){return this._getPainter()?new e(this.getExtent().toArray(),{symbol:{lineWidth:1,lineColor:"6b707b"}}):null},i.setCoordinates=function(t){if(!t)return this._coordinates=null,this._holes=null,this._projectRings(),this;var e=Hn.toCoordinates(t),i=e.length;if(Array.isArray(e[0])){if(this._coordinates=this._trimRing(e[0]),i>1){for(var n=[],r=1;r<i;r++)e[r]&&n.push(this._trimRing(e[r]));this._holes=n}}else this._coordinates=this._trimRing(e);return this._projectRings(),this},i.getCoordinates=function(){if(!this._coordinates)return[];for(var t=this.getHoles(),e=[this._copyAndCloseRing(this._coordinates)],i=0,n=t.length;i<n;i++)e.push(this._copyAndCloseRing(t[i]));return e},i.getCenterInExtent=function(t){return this._getCenterInExtent(t,this.getShell(),fo)},i.getShell=function(){return this._coordinates||[]},i.getHoles=function(){return this._holes||[]},i.hasHoles=function(){return this.getHoles().length>0},i._projectRings=function(){this.getMap()?(this._prjCoords=this._projectCoords(this._coordinates),this._prjHoles=this._projectCoords(this._holes),this.onShapeChanged()):this.onShapeChanged()},i._setPrjCoordinates=function(t){this._prjCoords=t,this.onShapeChanged()},i._cleanRing=function(t){for(var e=t.length-1;e>=0;e--)t[e]||t.splice(e,1)},i._checkRing=function(t){if(this._cleanRing(t),!t||!te(t))return!1;var e=t[t.length-1],i=!0;return t[0].x===e.x&&t[0].y===e.y||(i=!1),i},i._trimRing=function(t){var e=this._checkRing(t);return te(t)&&e&&t.splice(t.length-1,1),t},i._copyAndCloseRing=function(t){t=t.slice(0);var e=this._checkRing(t);return te(t)&&!e?(t.push(t[0].copy()),t):t},i._getPrjShell=function(){return this.getJSONType()===Hs?this._getPrjCoordinates():(this._verifyProjection(),this._getProjection()&&!this._prjShell&&(this._prjShell=this._projectCoords(this.getShell())),this._prjShell)},i._getPrjHoles=function(){var t=this._getProjection();return this._verifyProjection(),t&&!this._prjHoles&&(this._prjHoles=this._projectCoords(this.getHoles())),this._prjHoles},i._computeGeodesicLength=function(t){var e=this.getCoordinates();if(!te(e))return 0;for(var i=0,n=0,r=e.length;n<r;n++)i+=t.measureLength(e[n]);return i},i._computeGeodesicArea=function(t){var e=this.getCoordinates();if(!te(e))return 0;for(var i=t.measureArea(e[0]),n=1,r=e.length;n<r;n++)i-=t.measureArea(e[n]);return i},i._updateCache=function(){t.prototype._updateCache.call(this),this._prjHoles&&(this._holes=this._unprojectCoords(this._getPrjHoles()))},i._clearCache=function(){return delete this._prjShell,t.prototype._clearCache.call(this)},i._clearProjection=function(){this._prjHoles&&(this._prjHoles=null),this._prjShell&&(this._prjShell=null),t.prototype._clearProjection.call(this)},e}(Ns);function Gs(t){return function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.getCoordinates=function(){return this._coordinates},i.setCoordinates=function(t){var e=t instanceof Hn?t:new Hn(t);if(e.equals(this._coordinates))return this;if(this._coordinates=e,!this.getMap())return this._dirtyCoords=!0,this.onPositionChanged(),this;var i=this._getProjection();return this._setPrjCoordinates(i.project(this._coordinates)),this},i._getCenter2DPoint=function(t){var e=this.getMap();if(!e)return null;var i=this._getPrjCoordinates();return i?(t||(t=e._getResolution()),e._prjToPointAtRes(i,t)):null},i._getPrjCoordinates=function(){var t=this._getProjection();return this._verifyProjection(),!this._pcenter&&t&&this._coordinates&&(this._pcenter=t.project(this._coordinates)),this._pcenter},i._setPrjCoordinates=function(t){this._pcenter=t,this.onPositionChanged()},i._updateCache=function(){this._clearCache();var t=this._getProjection();this._pcenter&&t&&(this._coordinates=t.unproject(this._pcenter))},i._clearProjection=function(){this._pcenter=null,t.prototype._clearProjection.call(this)},i._computeCenter=function(){return this._coordinates?this._coordinates.copy():null},e}(t)}js.registerJSONType(Hs);var Us=new er,Vs=function(t){function e(e,i){var n;return(n=t.call(this,i)||this).type="Point",e&&n.setCoordinates(e),n}Dt(e,t);var i=e.prototype;return i.getOutline=function(){var t=this.getCoordinates(),i=this.getContainerExtent(),n=this.getMap().coordToContainerPoint(t);return new e(t,{symbol:{markerType:"square",markerWidth:i.getWidth(),markerHeight:i.getHeight(),markerLineWidth:1,markerLineColor:"6b707b",markerFill:"rgba(0, 0, 0, 0)",markerDx:i.xmin-(n.x-i.getWidth()/2),markerDy:i.ymin-(n.y-i.getHeight()/2)}})},i.setSymbol=function(){var e;delete this._fixedExtent;for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.prototype.setSymbol).call.apply(e,[this].concat(n))},i._getSizeSymbol=function(t){for(var e,i={},n=!1,r=!1,o=0;o<lo.length;o++){var s=t[lo[o]];H(s)||(!n&&Oe(s)&&(n=!0,r=!0),i[lo[o]]=s)}for(var a=0;a<co.length;a++){var h=t[co[a]];H(h)||(!n&&Oe(h)&&(n=!0),i[co[a]]=h)}return n?(e=ti(i,this),r&&(e._dynamic=!0)):e=i,e},i._setExternSymbol=function(e){return this._symbol||delete this._fixedExtent,t.prototype._setExternSymbol.call(this,e)},i._isDynamicSize=function(){return this._sizeSymbol&&this._sizeSymbol._dynamic},i._getFixedExtent=function(){if(this._fixedExtent&&!this._isDynamicSize())return this._fixedExtent;this._fixedExtent=this._fixedExtent||new er,this._fixedExtent.set(null,null,null,null);var t=this._sizeSymbol;if(!t)return this._fixedExtent;var e=this.getLayer()&&this.getLayer().getRenderer(),i=e&&e.resources,n=this.getTextDesc();if(Array.isArray(t)){Us.set(1/0,1/0,-1/0,-1/0);for(var r=0;r<t.length;r++)t[r]&&this._fixedExtent._combine(no(Us,t[r],i,n&&n[r]))}else this._fixedExtent=no(this._fixedExtent,t,i,n);return this._fixedExtent},i._isVectorMarker=function(){var t=this._getInternalSymbol();return!Array.isArray(t)&&so(t)},i._canEdit=function(){var t=this._getInternalSymbol();return!Array.isArray(t)&&(so(t)||ao(t)||oo(t))},i._containsPoint=function(e,i){var n=this.getContainerExtent();return i&&(n=n.expand(i)),!!n.contains(e)&&(!this.options.hitTestForEvent||t.prototype._containsPoint.call(this,e,i))},i._computeExtent=function(){return Ws.call(this,"getCenter")},i._computePrjExtent=function(){return Ws.call(this,"_getPrjCoordinates")},i._computeGeodesicLength=function(){return 0},i._computeGeodesicArea=function(){return 0},i._getSprite=function(t,e){return this._getPainter()?this._getPainter().getSprite(t,e):new Jo(this).getSprite(t,e)},e}(Gs(os));function Ws(t){var e=this[t]();return e?new tr(e,e,this._getProjection()):null}Vs.mergeOptions({symbol:{markerType:"path",markerPath:[{path:"M8 23l0 0 0 0 0 0 0 0 0 0c-4,-5 -8,-10 -8,-14 0,-5 4,-9 8,-9l0 0 0 0c4,0 8,4 8,9 0,4 -4,9 -8,14z M3,9 a5,5 0,1,0,0,-0.9Z",fill:"#DE3333"}],markerPathWidth:16,markerPathHeight:23,markerWidth:24,markerHeight:34},hitTestForEvent:!1}),Vs.registerJSONType("Marker");var Zs=function(t){function e(e,i){var n;return(n=t.call(this,i)||this).type="LineString",e&&n.setCoordinates(e),n}Dt(e,t);var i=e.prototype;return i.getOutline=function(){return js.prototype.getOutline.call(this)},i.setCoordinates=function(t){return t?(this._coordinates=Hn.toCoordinates(t),this.getMap()?this._setPrjCoordinates(this._projectCoords(this._coordinates)):this.onShapeChanged(),this):(this._coordinates=null,this._setPrjCoordinates(null),this)},i.getCoordinates=function(){return this._coordinates||[]},i.getCenterInExtent=function(t){return this._getCenterInExtent(t,this.getCoordinates(),uo)},i._computeGeodesicLength=function(t){return t.measureLength(this.getCoordinates())},i._computeGeodesicArea=function(){return 0},e}(Ns);Zs.mergeOptions({arrowStyle:null,arrowPlacement:"vertex-last"}),Zs.registerJSONType("LineString");var qs=new er,Xs=function(t){function e(e,i){var n;return(n=t.call(this,i)||this).type="GeometryCollection",n.setGeometries(e),n}Dt(e,t);var i=e.prototype;return i.getContainerExtent=function(t){var e=t||new er;return this.forEach((function(t){e._combine(t.getContainerExtent(qs))})),e},i.setGeometries=function(t){for(var e=this._checkGeometries(t||[]),i=this._getSymbol(),n=this.config(),r=e.length-1;r>=0;r--)e[r]._initOptions(n),e[r]._setParent(this),e[r]._setEventParent(this),i&&e[r].setSymbol(i);return this._geometries=e,this.getLayer()&&(this._bindGeometriesToLayer(),this.onShapeChanged()),this},i.getGeometries=function(){return this._geometries||[]},i.forEach=function(t,e){for(var i=this.getGeometries(),n=0,r=i.length;n<r;n++)i[n]&&(e?t.call(e,i[n],n):t(i[n],n));return this},i.filter=function(t,i){if(!t)return new e;var n=[],r=W(t),o=r?t:Ne(t);return this.forEach((function(t){var e=r?t:Ye(t);(i?o.call(i,e):o(e))&&n.push(t)}),this),new e(n)},i.translate=function(t){if(!t)return this;if(this.isEmpty())return this;var e=arguments;return this.forEach((function(t){t&&t.translate&&t.translate.apply(t,e)})),this},i.isEmpty=function(){return!te(this.getGeometries())},i.remove=function(){return this.forEach((function(t){t._unbind()})),os.prototype.remove.apply(this,arguments)},i.show=function(){return this.options.visible=!0,this.forEach((function(t){t.show()})),this},i.hide=function(){return this.options.visible=!1,this.forEach((function(t){t.hide()})),this},i.onConfig=function(t){this.forEach((function(e){e.config(t)}))},i.getSymbol=function(){var e=t.prototype.getSymbol.call(this);if(!e){var i=[],n=!1;this.forEach((function(t){t.getSymbol()&&!n&&(n=!0),i.push(t.getSymbol())})),n&&(e={children:i})}return e},i.setSymbol=function(t){if(t&&t.children)this._symbol=null,this.forEach((function(e,i){e.setSymbol(t.children[i])}));else{var e=this._prepareSymbol(t);this._symbol=e,this.forEach((function(t){t.setSymbol(e)}))}return this.onSymbolChanged(),this},i._setExternSymbol=function(t){return t=this._prepareSymbol(t),this._externSymbol=t,this.forEach((function(e){e._setExternSymbol(t)})),this.onSymbolChanged(),this},i._bindLayer=function(){t.prototype._bindLayer.apply(this,arguments),this._bindGeometriesToLayer()},i._bindGeometriesToLayer=function(){var t=this.getLayer();this.forEach((function(e){e._bindLayer(t)}))},i._checkGeometries=function(t){var e="The geometry added to collection is invalid.";if(t&&!Array.isArray(t)){if(t instanceof os)return[t];throw new Error(e)}for(var i=0,n=t.length;i<n;i++)if(!this._checkGeo(t[i]))throw new Error(e+" Index: "+i);return t},i._checkGeo=function(t){return t instanceof os},i._updateCache=function(){this._clearCache(),this.isEmpty()||this.forEach((function(t){t&&t._updateCache&&t._updateCache()}))},i._removePainter=function(){this._painter&&this._painter.remove(),delete this._painter,this.forEach((function(t){t._removePainter()}))},i._computeCenter=function(t){if(!t||this.isEmpty())return null;for(var e=0,i=0,n=0,r=this.getGeometries(),o=0,s=r.length;o<s;o++)if(r[o]){var a=r[o]._computeCenter(t);a&&(e+=a.x,i+=a.y,n++)}return 0===n?null:new Hn(e/n,i/n)},i._containsPoint=function(t,e){if(this.isEmpty())return!1;delete this._pickGeometryIndex;for(var i=this.getGeometries(),n=0,r=i.length;n<r;n++)if(i[n]._containsPoint(t,e))return this._pickGeometryIndex=n,!0;return!1},i._computeExtent=function(t){return Ys.call(this,t,"_computeExtent")},i._computePrjExtent=function(t){return Ys.call(this,t,"_computePrjExtent")},i._computeGeodesicLength=function(t){if(!t||this.isEmpty())return 0;for(var e=this.getGeometries(),i=0,n=0,r=e.length;n<r;n++)e[n]&&(i+=e[n]._computeGeodesicLength(t));return i},i._computeGeodesicArea=function(t){if(!t||this.isEmpty())return 0;for(var e=this.getGeometries(),i=0,n=0,r=e.length;n<r;n++)e[n]&&(i+=e[n]._computeGeodesicArea(t));return i},i._exportGeoJSONGeometry=function(){var t=[];if(!this.isEmpty())for(var e=this.getGeometries(),i=0,n=e.length;i<n;i++)e[i]&&t.push(e[i]._exportGeoJSONGeometry());return{type:"GeometryCollection",geometries:t}},i._toJSON=function(t){var e,i={type:"Feature",geometry:{type:"GeometryCollection",geometries:this.getGeometries().filter((function(t){return t&&t._toJSON})).map((function(t){var e=t._toJSON();return e.subType?e:t._exportGeoJSONGeometry()}))}},n=this.getId();return H(n)||(i.id=n),(H(t.properties)||t.properties)&&(e=this._exportProperties()),i.properties=e,t.feature=i,t},i._clearProjection=function(){if(!this.isEmpty())for(var t=this.getGeometries(),e=0,i=t.length;e<i;e++)t[e]&&t[e]._clearProjection()},i._getConnectPoints=function(){var t=this.getExtent();return[new Hn(t.xmin,t.ymax),new Hn(t.xmax,t.ymin),new Hn(t.xmin,t.ymin),new Hn(t.xmax,t.ymax)]},i._getExternalResources=function(){if(this.isEmpty())return[];for(var t,e,i=this.getGeometries(),n=[],r={},o=0,s=i.length;o<s;o++)if(i[o])for(var a=0,h=(t=ni(i[o]._getInternalSymbol())).length;a<h;a++)r[e=t[a].join()]||(n.push(t[a]),r[e]=1);return n},i.startEdit=function(t){var e=this;if(this.isEmpty())return this;t||(t={}),t.symbol&&(this._originalSymbol=this.getSymbol(),this.setSymbol(t.symbol)),this._draggbleBeforeEdit=this.options.draggable,this.config("draggable",!1);for(var i=this.getGeometries(),n=0,r=i.length;n<r;n++)i[n].startEdit(t);this._editing=!0;var o=this.getLayer();return o&&"canvas"===o.options.renderer&&this.hide(),setTimeout((function(){e.fire("editstart")}),1),this},i.endEdit=function(){if(this.isEmpty())return this;for(var t=this.getGeometries(),e=0,i=t.length;e<i;e++)t[e].endEdit();return this._originalSymbol&&(this.setSymbol(this._originalSymbol),delete this._originalSymbol),this._editing=!1,this.show(),this.config("draggable",this._draggbleBeforeEdit),this.fire("editend"),this},i.isEditing=function(){return!!this._editing},e}(os);function Ys(t,e){if(this.isEmpty())return null;for(var i=new tr,n=this.getGeometries(),r=0,o=n.length;r<o;r++)if(n[r]){var s=n[r][e](t);s&&i._combine(s)}return i}Xs.registerJSONType("GeometryCollection");var Js=function(t){function e(e,i,n,r){var o;return(o=t.call(this,null,r)||this).GeometryType=e,o.type=i,o._initData(n),o}Dt(e,t);var i=e.prototype;return i.getCoordinates=function(){for(var t=[],e=this.getGeometries(),i=0,n=e.length;i<n;i++){var r=e[i];t.push(r.getShell&&"Polygon"!==r.getJSONType()?[r.getShell()]:r.getCoordinates())}return t},i.setCoordinates=function(t){for(var e=[],i=0,n=(t=t||[]).length;i<n;i++){var r=new this.GeometryType(t[i],this.config());e.push(r)}return this.setGeometries(e),this},i._initData=function(t){(t=t||[]).length&&(t[0]instanceof this.GeometryType?this.setGeometries(t):this.setCoordinates(t))},i._checkGeo=function(t){return t instanceof this.GeometryType},i._exportGeoJSONGeometry=function(){var t=this.getCoordinates(),e=Hn.toNumberArrays(t);return{type:this.getType(),coordinates:e}},i._toJSON=function(t){return{feature:this.toGeoJSON(t)}},e}(Xs),Qs=function(t){function e(e,i){return t.call(this,Vs,"MultiPoint",e,i)||this}return Dt(e,t),e.prototype.findClosest=function(t){if(!t)return null;var e=this.getCoordinates(),i=null,n=1/0;return e.forEach((function(e){var r,o,s,a,h=(r=e,s=(o=t).x-r.x,a=o.y-r.y,Math.sqrt(s*s+a*a));h<n&&(i=e,n=h)})),i},e}(Js);Qs.registerJSONType("MultiPoint");var Ks=function(t){function e(){return t.apply(this,arguments)||this}return Dt(e,t),e.prototype.getCenterInExtent=function(t){var e=this.getGeometries(),i=0,n=0,r=0;return e.forEach((function(e){var o=e.getCenterInExtent(t);o&&(i+=o.x*o.count,n+=o.y*o.count,r+=o.count)})),0===r?null:new Hn(i,n)._multi(1/r)},e}(Js),$s=function(t){function e(e,i){return t.call(this,Zs,"MultiLineString",e,i)||this}return Dt(e,t),e}(Ks);$s.registerJSONType("MultiLineString");var ta=function(t){function e(e,i){return t.call(this,js,"MultiPolygon",e,i)||this}return Dt(e,t),e}(Ks);ta.registerJSONType("MultiPolygon");var ea={Marker:Vs,LineString:Zs,Polygon:js,MultiPoint:Qs,MultiLineString:$s,MultiPolygon:ta},ia={toGeometry:function(t,e){if(V(t)&&(t=Vt(t)),Array.isArray(t)){for(var i=[],n=0,r=t.length;n<r;n++){var o=ia._convert(t[n],e);Array.isArray(o)?Wt(i,o):i.push(o)}return i}return ia._convert(t,e)},_convert:function(t,e){if(!t||H(t.type))return null;var i=t.type;if("Feature"===i){var n=t.geometry,r=ia._convert(n);return r?(r.setId(t.id),r.setProperties(t.properties),e&&e(r),r):null}if("FeatureCollection"===i){var o=t.features;return o?ia.toGeometry(o,e):null}if(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon"].indexOf(i)>=0){var s=new ea["Point"===i?"Marker":i](t.coordinates);return e&&e(s),s}if("GeometryCollection"===i){var a=t.geometries;if(!te(a)){var h=new Xs;return e&&e(h),h}for(var l=[],c=a.length,u=0;u<c;u++)a[u].subType?l.push(os.getJSONClass(a[u].subType).fromJSON(a[u])):l.push(ia._convert(a[u]));var d=new Xs(l);return e&&e(d),d}return null}},na=function(t){function e(e,i,n){var r;return r=t.call(this,null,n)||this,e&&r.setCoordinates(e),r._radius=i,r}Dt(e,t),e.fromJSON=function(t){var i=t.feature,n=new e(t.coordinates,t.radius,t.options);return n.setProperties(i.properties),n};var i=e.prototype;return i.getRadius=function(){return this._radius},i.setRadius=function(t){return this._radius=t,this.onShapeChanged(),this},i.getShell=function(){for(var t,e,i,n=this._getMeasurer(),r=this.getCoordinates(),o=this.options.numberOfShellPoints,s=this.getRadius(),a=[],h=0,l=o-1;h<l;h++){t=360*h/l*Math.PI/180,e=s*Math.cos(t),i=s*Math.sin(t);var c=n.locate(r,e,i);a.push(c)}return a.push(a[0]),a},i.getHoles=function(){return[]},i.animateShow=function(){return this.show()},i._containsPoint=function(e,i){var n=this.getMap();if(n.getPitch())return t.prototype._containsPoint.call(this,e,i);var r=n._pointToContainerPoint(this._getCenter2DPoint()),o=this.getSize(),s=H(i)?this._hitTestTolerance():i,a=r.add(o.width/2,o.height/2);return vo(e,r,a,s)},i._computePrjExtent=function(t){var e=this._getMinMax(t);if(!e)return null;var i=this._getPrjCoordinates(),n=e.map((function(e){return t.project(e)})),r=n[0].x-i.x,o=n[1].x-i.x,s=n[2].y-i.y,a=n[3].y-i.y;return new tr(i.add(r,s),i.add(o,a))},i._computeExtent=function(t){var e=this._getMinMax(t);return e?new tr(e[0].x,e[2].y,e[1].x,e[3].y,this._getProjection()):null},i._getMinMax=function(t){if(!t||!this._coordinates||H(this._radius))return null;var e=this._radius;return[t.locate(this._coordinates,-e,0),t.locate(this._coordinates,e,0),t.locate(this._coordinates,0,e),t.locate(this._coordinates,0,-e)]},i._computeGeodesicLength=function(){return H(this._radius)?0:2*Math.PI*this._radius},i._computeGeodesicArea=function(){return H(this._radius)?0:Math.PI*Math.pow(this._radius,2)},i._exportGeoJSONGeometry=function(){return{type:"Polygon",coordinates:Hn.toNumberArrays([this.getShell()])}},i._toJSON=function(t){var e=this.getCenter(),i=N({},t);i.geometry=!1;var n=this.toGeoJSON(i);return n.geometry={type:"Polygon"},{feature:n,subType:"Circle",coordinates:[e.x,e.y],radius:this.getRadius()}},e}(Gs(js));na.mergeOptions({numberOfShellPoints:60}),na.registerJSONType("Circle");var ra=function(t){function e(e,i,n,r){var o;return o=t.call(this,null,r)||this,e&&o.setCoordinates(e),o.width=i,o.height=n,o}Dt(e,t),e.fromJSON=function(t){var i=t.feature,n=new e(t.coordinates,t.width,t.height,t.options);return n.setProperties(i.properties),n};var i=e.prototype;return i.getWidth=function(){return this.width},i.setWidth=function(t){return this.width=t,this.onShapeChanged(),this},i.getHeight=function(){return this.height},i.setHeight=function(t){return this.height=t,this.onShapeChanged(),this},i.getShell=function(){for(var t,e,i,n,r=this._getMeasurer(),o=this.getCoordinates(),s=this.options.numberOfShellPoints,a=this.getWidth(),h=this.getHeight(),l=[],c=Math.pow(a/2,2)*Math.pow(h/2,2),u=Math.pow(a/2,2),d=Math.pow(h/2,2),p=0;p<s;p++){e=(t=360*p/s)*Math.PI/180,i=Math.sqrt(c/(u*Math.pow(Math.tan(e),2)+d)),n=Math.sqrt(c/(d*Math.pow(1/Math.tan(e),2)+u)),t>90&&t<270&&(i*=-1),t>180&&t<360&&(n*=-1);var f=r.locate(o,i,n);l.push(f)}return l},i.getHoles=function(){return[]},i.animateShow=function(){return this.show()},i._containsPoint=function(e,i){var n=this.getMap();if(n.isTransforming())return t.prototype._containsPoint.call(this,e,i);var r=n.getProjection(),o=H(i)?this._hitTestTolerance():i,s=r.projectCoords([this._coordinates,n.locate(this._coordinates,this.getWidth()/2,this.getHeight()/2)],this.options.antiMeridian);return vo(e,n._prjToContainerPoint(s[0]),n._prjToContainerPoint(s[1]),o)},i._computePrjExtent=function(){return na.prototype._computePrjExtent.apply(this,arguments)},i._computeExtent=function(){return na.prototype._computeExtent.apply(this,arguments)},i._getMinMax=function(t){if(!t||!this._coordinates||H(this.width)||H(this.height))return null;var e=this.getWidth(),i=this.getHeight();return[t.locate(this._coordinates,-e/2,0),t.locate(this._coordinates,e/2,0),t.locate(this._coordinates,0,-i/2),t.locate(this._coordinates,0,i/2)]},i._computeGeodesicLength=function(){if(H(this.width)||H(this.height))return 0;var t=this.width>this.height?this.width:this.height;return 2*Math.PI*t/2-4*Math.abs(this.width-this.height)},i._computeGeodesicArea=function(){return H(this.width)||H(this.height)?0:Math.PI*this.width*this.height/4},i._exportGeoJSONGeometry=function(){return{type:"Polygon",coordinates:Hn.toNumberArrays([this.getShell()])}},i._toJSON=function(t){var e=N({},t),i=this.getCenter();e.geometry=!1;var n=this.toGeoJSON(e);return n.geometry={type:"Polygon"},{feature:n,subType:"Ellipse",coordinates:[i.x,i.y],width:this.getWidth(),height:this.getHeight()}},e}(Gs(js));ra.mergeOptions({numberOfShellPoints:80}),ra.registerJSONType("Ellipse");var oa=function(t){function e(e,i,n,r){var o;return o=t.call(this,null,r)||this,e&&o.setCoordinates(e),o._width=i,o._height=n,o}Dt(e,t),e.fromJSON=function(t){var i=t.feature,n=new e(t.coordinates,t.width,t.height,t.options);return n.setProperties(i.properties),n};var i=e.prototype;return i.getCoordinates=function(){return this._coordinates},i.setCoordinates=function(t){if(this._coordinates=t instanceof Hn?t:new Hn(t),!this._coordinates||!this.getMap())return this.onPositionChanged(),this;var e=this._getProjection();return this._setPrjCoordinates(e.project(this._coordinates)),this},i.getWidth=function(){return this._width},i.setWidth=function(t){return this._width=t,this.onShapeChanged(),this},i.getHeight=function(){return this._height},i.setHeight=function(t){return this._height=t,this.onShapeChanged(),this},i.getShell=function(){var t=this._getMeasurer(),e=this._coordinates,i=this.getMap(),n=1,r=-1;if(i){var o=i.getFullExtent();o.left>o.right&&(n=-1),o.bottom>o.top&&(r=1)}var s=[];return s.push(e),s.push(t.locate(e,n*this._width,0)),s.push(t.locate(e,n*this._width,r*this._height)),s.push(t.locate(e,0,r*this._height)),s.push(e),s},i.getHoles=function(){return[]},i.animateShow=function(){return this.show()},i._getPrjCoordinates=function(){var t=this._getProjection();return this._verifyProjection(),!this._pnw&&t&&this._coordinates&&(this._pnw=t.project(this._coordinates)),this._pnw},i._setPrjCoordinates=function(t){this._pnw=t,this.onPositionChanged()},i._getPrjShell=function(){var e=t.prototype._getPrjShell.call(this),i=this._getProjection();if(!i.isSphere())return e;for(var n=i.getSphereExtent(),r=n.sx,o=n.sy,s=this._getProjection().getCircum(),a=e[0],h=1,l=e.length;h<l;h++){var c=e[h],u=0,d=0;r*(a.x-c.x)>0&&(u=s.x*r),o*(a.y-c.y)<0&&(d=s.y*o),e[h]._add(u,d)}return e},i._updateCache=function(){this._clearCache();var t=this._getProjection();this._pnw&&t&&(this._coordinates=t.unproject(this._pnw))},i._clearProjection=function(){this._pnw=null,t.prototype._clearProjection.call(this)},i._computeCenter=function(t){return t.locate(this._coordinates,this._width/2,-this._height/2)},i._containsPoint=function(e,i){var n=this.getMap();if(n.isTransforming())return t.prototype._containsPoint.call(this,e,i);var r=H(i)?this._hitTestTolerance():i,o=n._getResolution()*r,s=this._getPrjExtent().expand(o),a=n._containerPointToPrj(e);return s.contains(a)},i._computePrjExtent=function(t){var e=this._getSouthEast(t);if(!e)return null;var i=t.projectCoords([new Hn(this._coordinates.x,e.y),new Hn(e.x,this._coordinates.y)],this.options.antiMeridian);return new tr(i[0],i[1])},i._computeExtent=function(t){var e=this._getSouthEast(t);return e?new tr(this._coordinates,e,this._getProjection()):null},i._getSouthEast=function(t){if(!t||!this._coordinates||H(this._width)||H(this._height))return null;var e=this.getWidth(),i=-this.getHeight();if(t.fullExtent){var n=t.fullExtent;e*=n.right>n.left?1:-1,i*=n.top>n.bottom?1:-1}var r=t.locate(this._coordinates,e,0),o=t.locate(this._coordinates,0,i);return r.y=o.y,r},i._computeGeodesicLength=function(){return H(this._width)||H(this._height)?0:2*(this._width+this._height)},i._computeGeodesicArea=function(){return H(this._width)||H(this._height)?0:this._width*this._height},i._exportGeoJSONGeometry=function(){return{type:"Polygon",coordinates:Hn.toNumberArrays([this.getShell()])}},i._toJSON=function(t){var e=N({},t),i=this.getCoordinates();e.geometry=!1;var n=this.toGeoJSON(e);return n.geometry={type:"Polygon"},{feature:n,subType:"Rectangle",coordinates:[i.x,i.y],width:this.getWidth(),height:this.getHeight()}},e}(js);oa.registerJSONType("Rectangle");var sa=function(t){function e(e,i,n,r,o){var s;return(s=t.call(this,e,i,o)||this).startAngle=n,s.endAngle=r,s}Dt(e,t),e.fromJSON=function(t){var i=t.feature,n=new e(t.coordinates,t.radius,t.startAngle,t.endAngle,t.options);return n.setProperties(i.properties),n};var i=e.prototype;return i.getStartAngle=function(){return this.startAngle},i.setStartAngle=function(t){return this.startAngle=t,this.onShapeChanged(),this},i.getEndAngle=function(){return this.endAngle},i.setEndAngle=function(t){return this.endAngle=t,this.onShapeChanged(),this},i.getShell=function(){for(var t,e,i,n=this._getMeasurer(),r=this.getCoordinates(),o=this.options.numberOfShellPoints-2,s=this.getRadius(),a=[r.copy()],h=this.getStartAngle(),l=this.getEndAngle()-h,c=0;c<o;c++){t=(l*c/(o-1)+h)*Math.PI/180,e=s*Math.cos(t),i=s*Math.sin(t);var u=n.locate(r,e,i);a.push(u)}return a.push(r.copy()),a},i._containsPoint=function(e,i){var n=this.getMap();if(n.isTransforming())return t.prototype._containsPoint.call(this,e,i);var r=n._pointToContainerPoint(this._getCenter2DPoint()),o=H(i)?this._hitTestTolerance():i,s=this.getSize(),a=r,h=e,l=h.x-a.x,c=a.y-h.y,u=Math.atan2(c,l),d=u<0?360*(u+2*Math.PI)/(2*Math.PI):360*u/(2*Math.PI),p=this.startAngle%360,f=this.endAngle%360,m=!1;return m=p>f?!(d>f&&d<p):d>=p&&d<=f,h.distanceTo(a)<=s.width/2+o&&m},i._computeGeodesicLength=function(){return H(this._radius)?0:2*Math.PI*this._radius*Math.abs(this.startAngle-this.endAngle)/360+2*this._radius},i._computeGeodesicArea=function(){return H(this._radius)?0:Math.PI*Math.pow(this._radius,2)*Math.abs(this.startAngle-this.endAngle)/360},i._toJSON=function(t){var e=N({},t),i=this.getCenter();e.geometry=!1;var n=this.toGeoJSON(e);return n.geometry={type:"Polygon"},{feature:n,subType:"Sector",coordinates:[i.x,i.y],radius:this.getRadius(),startAngle:this.getStartAngle(),endAngle:this.getEndAngle()}},e}(na);sa.mergeOptions({numberOfShellPoints:60}),sa.registerJSONType("Sector");var aa=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i._arc=function(t,e,i){for(var n=this.options.arcDegree*Math.PI/180,r=1,o=e.length;r<o;r++){var s=wn._arcBetween(t,e[r-1],e[r],n),a=[e[r-1].x+e[r].x-s[0],e[r-1].y+e[r].y-s[1]];e[r-1].nextCtrlPoint=a,e[r].prevCtrlPoint=a,wn._stroke(t,i)}},i._quadraticCurve=function(t,e){if(e.length<=2)wn._path(t,e);else{var i,n;for(i=2,n=e.length;i<n;i+=2)t.quadraticCurveTo(e[i-1].x,e[i-1].y,e[i].x,e[i].y);if((i-=1)<n)for(;i<n;i++)t.lineTo(e[i].x,e[i].y)}},i._bezierCurve=function(t,e){if(e.length<=3)wn._path(t,e);else{var i,n;for(i=1,n=e.length;i+2<n;i+=3)t.bezierCurveTo(e[i].x,e[i].y,e[i+1].x,e[i+1].y,e[i+2].x,e[i+2].y);if(i<n)for(;i<n;i++)t.lineTo(e[i].x,e[i].y)}},i._getCurveArrowPoints=function(t,e,i,n,r,o){var s,a=e.length;for(s=o;s<a;s+=o){var h=this._getArrowShape(e[s-1],e[s],i,n,r);h&&t.push(h)}if((s-=o)<a-1)for(s+=1;s<a;s++){var l=this._getArrowShape(e[s-1],e[s],i,n,r);l&&t.push(l)}},e}(Zs);aa.mergeOptions({enableSimplify:!1,enableClip:!1});var ha=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i._toJSON=function(t){return{feature:this.toGeoJSON(t),subType:"ArcCurve"}},i._paintOn=function(t,e,i){t.beginPath(),this._arc(t,e,i),wn._stroke(t,i),this._paintArrow(t,e,i)},e.fromJSON=function(t){var i=t.feature,n=new e(i.geometry.coordinates,t.options);return n.setProperties(i.properties),n},e}(aa);ha.registerJSONType("ArcCurve"),ha.mergeOptions({arcDegree:90});var la=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t),e.fromJSON=function(t){var i=t.feature,n=new e(i.geometry.coordinates,t.options);return n.setProperties(i.properties),n};var i=e.prototype;return i._toJSON=function(t){return{feature:this.toGeoJSON(t),subType:"CubicBezierCurve"}},i._paintOn=function(t,e,i){t.beginPath(),t.moveTo(e[0].x,e[0].y),this._bezierCurve(t,e),wn._stroke(t,i),this._paintArrow(t,e,i)},i._getArrowPoints=function(t,e,i,n,r){return this._getCurveArrowPoints(t,e,i,n,r,3)},e}(aa);la.registerJSONType("CubicBezierCurve");var ca=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t),e.fromJSON=function(t){var i=t.feature,n=new e(i.geometry.coordinates,t.options);return n.setProperties(i.properties),n};var i=e.prototype;return i._toJSON=function(t){return{feature:this.toGeoJSON(t),subType:"QuadBezierCurve"}},i._paintOn=function(t,e,i){t.beginPath(),t.moveTo(e[0].x,e[0].y),this._quadraticCurve(t,e,i),wn._stroke(t,i),this._paintArrow(t,e,i)},i._getArrowPoints=function(t,e,i,n,r){return this._getCurveArrowPoints(t,e,i,n,r,2)},e}(aa);ca.registerJSONType("QuadBezierCurve");var ua={textFaceName:"monospace",textSize:12,textLineSpacing:8,textWrapCharacter:"\n",textHorizontalAlignment:"middle",textVerticalAlignment:"middle"},da={markerType:"square",markerLineColor:"#000",markerLineWidth:2,markerLineOpacity:1,markerFill:"#fff",markerOpacity:1},pa=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.getContent=function(){return this._content},i.setContent=function(t){var e=this._content;return this._content=li(t),this._refresh(),this._fireEvent("contentchange",{old:e,new:t}),this},i.onAdd=function(){this._refresh()},i.toJSON=function(){var e=t.prototype.toJSON.call(this);return delete e.symbol,e},i.setSymbol=function(e){if(this._refreshing||!e)return t.prototype.setSymbol.call(this,e);var i=this._parseSymbol(e);if(this.setTextStyle){var n=this.getTextStyle()||{};n.symbol=i[0],this.setTextStyle(n)}else this.setTextSymbol&&this.setTextSymbol(i[0]);if(this.setBoxStyle){var r=this.getBoxStyle()||{};r.symbol=i[1],this.setBoxStyle(r)}else this.setBoxSymbol&&this.setBoxSymbol(i[1]);return this},i._parseSymbol=function(t){var e={},i={};for(var n in t)q(t,n)&&(0===n.indexOf("text")?e[n]=t[n]:i[n]=t[n]);return[e,i]},i._getTextSize=function(t){return wi(this._content,t).size},i._getInternalSymbol=function(){return this._symbol},i._getDefaultTextSymbol=function(){return N({},ua)},i._getDefaultBoxSymbol=function(){return N({},da)},i._getDefaultPadding=function(){return[12,8]},e}(Vs),fa=function(t){function e(e,i,n,r,o){var s;return void 0===o&&(o={}),(s=t.call(this,i,o)||this)._content=li(e),s._width=H(n)?100:n,s._height=H(r)?40:r,o.boxSymbol&&s.setBoxSymbol(o.boxSymbol),o.textStyle&&s.setTextStyle(o.textStyle),s._refresh(),s}Dt(e,t);var i=e.prototype;return i.getWidth=function(){return this._width},i.setWidth=function(t){return this._width=t,this._refresh(),this},i.getHeight=function(){return this._height},i.setHeight=function(t){return this._height=t,this._refresh(),this},i.getBoxSymbol=function(){return N({},this.options.boxSymbol)},i.setBoxSymbol=function(t){return this.options.boxSymbol=t?N({},t):t,this.getSymbol()&&this._refresh(),this},i.getTextStyle=function(){return this.options.textStyle?N({},this.options.textStyle):null},i.setTextStyle=function(t){return this.options.textStyle=t?N({},t):t,this.getSymbol()&&this._refresh(),this},e.fromJSON=function(t){var i=t.feature,n=new e(t.content,i.geometry.coordinates,t.width,t.height,t.options);return n.setProperties(i.properties),n.setId(i.id),t.symbol&&n.setSymbol(t.symbol),n},i._toJSON=function(t){return{feature:this.toGeoJSON(t),width:this.getWidth(),height:this.getHeight(),subType:"TextBox",content:this._content}},i._refresh=function(){var t,e,i=this.getTextStyle()||{},n=i.padding||[12,8];if(Oe(this._width)){var r=(t=JSON.parse(JSON.stringify(this._width))).stops;if(r)for(var o=0;o<r.length;o++)r[o][1]=r[o][1]-2*n[0]}else t=this._width-2*n[0];if(Oe(this._height)){var s=(e=JSON.parse(JSON.stringify(this._height))).stops;if(s)for(var a=0;a<s.length;a++)s[a][1]=s[a][1]-2*n[1]}else e=this._height-2*n[1];var h=N({},i.symbol||this._getDefaultTextSymbol(),this.options.boxSymbol||this._getDefaultBoxSymbol(),{textName:this._content,markerWidth:this._width,markerHeight:this._height,textHorizontalAlignment:"middle",textVerticalAlignment:"middle",textMaxWidth:t,textMaxHeight:e});i.wrap&&!h.textWrapWidth&&(h.textWrapWidth=t);var l,c=i.horizontalAlignment;if(h.textDx=h.markerDx||0,Oe(this._width)){var u=(l=JSON.parse(JSON.stringify(this._width))).stops;if(u)for(var d=0;d<u.length;d++)u[d][1]=u[d][1]/2-n[0],"left"===c&&(u[d][1]*=-1)}else l=h.markerWidth/2-n[0],"left"===c&&(l*=-1);"left"===c?(h.textHorizontalAlignment="right",h.textDx=l):"right"===c&&(h.textHorizontalAlignment="left",h.textDx=l);var p,f=i.verticalAlignment;if(h.textDy=h.markerDy||0,Oe(this._height)){var m=(p=JSON.parse(JSON.stringify(this._height))).stops;if(m)for(var g=0;g<m.length;g++)m[g][1]=m[g][1]/2-n[1],"top"===f&&(m[g][1]*=-1)}else p=h.markerHeight/2-n[1],"top"===f&&(p*=-1);"top"===f?(h.textVerticalAlignment="bottom",h.textDy=p):"bottom"===f&&(h.textVerticalAlignment="top",h.textDy=p),this._refreshing=!0,this.updateSymbol(h),delete this._refreshing},i.startEdit=function(e){var i=this._getCompiledSymbol();if(Oe(this._width)){var n=i.markerWidth;this._oldWidth=this._width,this.setWidth(n)}if(Oe(this._height)){var r=i.markerHeight;this._oldHeight=this._height,this.setHeight(r)}t.prototype.startEdit.call(this,e)},i.endEdit=function(){var e=this.getMap(),i=e&&e.getZoom();if(this._oldWidth){for(var n=this._width/Ie(this._oldWidth)(i),r=this._oldWidth.stops,o=0;o<r.length;o++)r[o][1]*=n;this.setWidth(this._oldWidth),delete this._oldWidth}if(this._oldHeight){for(var s=this._height/Ie(this._oldHeight)(i),a=this._oldHeight.stops,h=0;h<a.length;h++)a[h][1]*=s;this.setHeight(this._oldHeight),delete this._oldHeight}t.prototype.endEdit.call(this)},e}(pa);fa.mergeOptions({textStyle:{wrap:!0,padding:[12,8],verticalAlignment:"middle",horizontalAlignment:"middle"},boxSymbol:null}),fa.registerJSONType("TextBox");var ma=function(t){function e(e,i,n){var r;return void 0===n&&(n={}),r=t.call(this,i,n)||this,n.textSymbol&&r.setTextSymbol(n.textSymbol),n.boxStyle&&r.setBoxStyle(n.boxStyle),r._content=li(e),r._refresh(),r}Dt(e,t);var i=e.prototype;return i.getBoxStyle=function(){return this.options.boxStyle?N({},this.options.boxStyle):null},i.setBoxStyle=function(t){return this.options.boxStyle=t?N({},t):t,this._refresh(),this},i.getTextSymbol=function(){return N({},this._getDefaultTextSymbol(),this.options.textSymbol)},i.setTextSymbol=function(t){return this.options.textSymbol=t?N({},t):t,this._refresh(),this},e.fromJSON=function(t){var i=t.feature,n=new e(t.content,i.geometry.coordinates,t.options);return n.setProperties(i.properties),n.setId(i.id),t.symbol&&n.setSymbol(t.symbol),n},i._canEdit=function(){return!1},i._toJSON=function(t){return{feature:this.toGeoJSON(t),subType:"Label",content:this._content}},i._refresh=function(){var t=N({},this.getTextSymbol(),{textName:this._content}),e=this.getBoxStyle();if(e){N(t,e.symbol);var i=this._getBoxSize(t),n=i[1],r=e.padding||this._getDefaultPadding(),o=i[0];t.markerWidth=o.width,t.markerHeight=o.height;var s=t.textDx||0,a=t.textDy||0,h=yi(n,t.textHorizontalAlignment,t.textVerticalAlignment)._add(s,a),l=e.horizontalAlignment||"middle";t.markerDx=h.x,"left"===l?t.markerDx+=t.markerWidth/2-r[0]:"right"===l?t.markerDx-=t.markerWidth/2-n.width-r[0]:t.markerDx+=n.width/2;var c=e.verticalAlignment||"middle";t.markerDy=h.y,"top"===c?t.markerDy+=t.markerHeight/2-r[1]:"bottom"===c?t.markerDy-=t.markerHeight/2-n.height-r[1]:t.markerDy+=n.height/2}this._refreshing=!0,this.updateSymbol(t),delete this._refreshing},i._getBoxSize=function(t){t.markerType||(t.markerType="square");var e,i,n=this.getBoxStyle(),r=this._getTextSize(t),o=n.padding||this._getDefaultPadding();return e=r.width+2*o[0],i=r.height+2*o[1],n.minWidth&&(!e||e<n.minWidth)&&(e=n.minWidth),n.minHeight&&(!i||i<n.minHeight)&&(i=n.minHeight),[new si(e,i),r]},e}(pa);ma.mergeOptions({boxStyle:null,textSymbol:null}),ma.registerJSONType("Label");var ga=function(t){return function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t),e._hasConnectors=function(t){return!H(t.__connectors)&&t.__connectors.length>0},e._getConnectors=function(t){return t.__connectors};var i=e.prototype;return i.getConnectSource=function(){return this._connSource},i.setConnectSource=function(t){var e=this._connTarget;return this.onRemove(),this._connSource=t,this._connTarget=e,this.onAdd(),this},i.getConnectTarget=function(){return this._connTarget},i.setConnectTarget=function(t){var e=this._connSource;return this.onRemove(),this._connSource=e,this._connTarget=t,this._updateCoordinates(),this._registerEvents(),this},i._updateCoordinates=function(){var t=this.getMap();if(!t&&this._connSource&&(t=this._connSource.getMap()),!t&&this._connTarget&&(t=this._connTarget.getMap()),t&&this._connSource&&this._connTarget){for(var e,i,n=this._connSource._getConnectPoints(),r=this._connTarget._getConnectPoints(),o=0,s=this.getCoordinates(),a=0,h=n.length;a<h;a++)for(var l=n[a],c=0,u=r.length;c<u;c++){var d=r[c],p=t.computeLength(l,d);0===a&&0===c?(e=l,i=d,o=p):p<o&&(e=l,i=d)}te(s)&&s[0].equals(e)&&s[1].equals(i)||this.setCoordinates([e,i])}},i.onAdd=function(){this._registerEvents(),this._updateCoordinates()},i.onRemove=function(){if(this._connSource&&(this._connSource.__connectors&&Zt(this,this._connSource.__connectors),this._connSource.off("dragging positionchange",this._updateCoordinates,this).off("remove",this.onRemove,this),this._connSource.off("dragstart mousedown mouseover",this._showConnect,this),this._connSource.off("dragend mouseup mouseout",this.hide,this),this._connSource.off("show",this._showConnect,this).off("hide",this.hide,this),delete this._connSource),this._connTarget&&(Zt(this,this._connTarget.__connectors),this._connTarget.off("dragging positionchange",this._updateCoordinates,this).off("remove",this.onRemove,this),this._connTarget.off("show",this._showConnect,this).off("hide",this.hide,this),delete this._connTarget),!(this._connSource instanceof os&&this._connTarget instanceof os)){var t=this.getMap();t&&t.off("movestart moving moveend zoomstart zooming zoomend rotate pitch fovchange spatialreferencechange",this._updateCoordinates,this)}},i._showConnect=function(){this._connSource&&this._connTarget&&this._connSource.isVisible()&&this._connTarget.isVisible()&&(this._updateCoordinates(),this.show())},i._registerEvents=function(){if(this._connSource&&this._connTarget){this._connSource.__connectors||(this._connSource.__connectors=[]),this._connTarget.__connectors||(this._connTarget.__connectors=[]),this._connSource.__connectors.push(this),this._connTarget.__connectors.push(this),this._connSource.on("dragging positionchange",this._updateCoordinates,this).on("remove",this.remove,this),this._connTarget.on("dragging positionchange",this._updateCoordinates,this).on("remove",this.remove,this),this._connSource.on("show",this._showConnect,this).on("hide",this.hide,this),this._connTarget.on("show",this._showConnect,this).on("hide",this.hide,this);var t=this.options.showOn;if(this.hide(),"moving"===t?(this._connSource.on("dragstart",this._showConnect,this).on("dragend",this.hide,this),this._connTarget.on("dragstart",this._showConnect,this).on("dragend",this.hide,this)):"click"===t?(this._connSource.on("mousedown",this._showConnect,this).on("mouseup",this.hide,this),this._connTarget.on("mousedown",this._showConnect,this).on("mouseup",this.hide,this)):"mouseover"===t?(this._connSource.on("mouseover",this._showConnect,this).on("mouseout",this.hide,this),this._connTarget.on("mouseover",this._showConnect,this).on("mouseout",this.hide,this)):this._showConnect(),!(this._connSource instanceof os&&this._connTarget instanceof os)){var e=this.getMap();e&&e.on("movestart moving moveend zoomstart zooming zoomend rotate pitch fovchange spatialreferencechange",this._updateCoordinates,this)}}},e}(t)},va={showOn:"always"},ya=function(t){function e(e,i,n){var r;return r=t.call(this,null,n)||this,1===arguments.length&&(n=e,e=null,i=null),r._connSource=e,r._connTarget=i,r}return Dt(e,t),e}(ga(Zs));ya.mergeOptions(va),ya.registerJSONType("ConnectorLine");var _a=function(t){function e(e,i,n){var r;return r=t.call(this,null,n)||this,1===arguments.length&&(n=e,e=null,i=null),r._connSource=e,r._connTarget=i,r}return Dt(e,t),e}(ga(ha));_a.mergeOptions(va),_a.registerJSONType("ArcConnectorLine");var xa=[],wa=function(t){function e(e,i,n){var r;i&&!(i instanceof os)&&!Array.isArray(i)&&O.indexOf(i.type)<0&&(n=i,i=null),(r=t.call(this,e,n)||this)._maxZIndex=0,r._minZIndex=0,r._initCache(),i&&r.addGeometry(i);var o=r.options.style;return o&&r.setStyle(o),r}Dt(e,t);var i=e.prototype;return i.getGeometryById=function(t){return H(t)||""===t?null:this._geoMap[t]?this._geoMap[t]:null},i.getGeometries=function(t,e){if(!t)return this._geoList.slice(0);for(var i,n=[],r=0,o=this._geoList.length;r<o;r++)i=this._geoList[r],(e?t.call(e,i):t(i))&&n.push(i);return n},i.getFirstGeometry=function(){return this._geoList.length?this._geoList[0]:null},i.getLastGeometry=function(){var t=this._geoList.length;return 0===t?null:this._geoList[t-1]},i.getCount=function(){return this._geoList.length},i.getExtent=function(){if(0===this.getCount())return null;var t=new tr(this.getProjection());return this.forEach((function(e){t._combine(e.getExtent())})),t},i.forEach=function(t,e){for(var i=this._geoList.slice(0),n=0,r=i.length;n<r;n++)e?t.call(e,i[n],n):t(i[n],n);return this},i.filter=function(t,e){var i=[],n=W(t),r=n?t:Ne(t);return this.forEach((function(t){var o=n?t:Ye(t);(e?r.call(e,o):r(o))&&i.push(t)}),this),i},i.isEmpty=function(){return!this._geoList.length},i.addGeometry=function(t,e){if(!t)return this;if("FeatureCollection"===t.type)return this.addGeometry(ia.toGeometry(t),e);if(!Array.isArray(t)){var i=arguments.length,n=arguments[i-1];return t=Array.prototype.slice.call(arguments,0,i-1),e=n,n&&U(n)&&("type"in n||n instanceof os)&&(t.push(n),e=!1),this.addGeometry(t,e)}if(0===t.length)return this;var r;this._initCache(),e&&(r=new tr),this._toSort=this._maxZIndex>0;for(var o=[],s=0,a=t.length;s<a;s++){var h=t[s];if(!h)throw new Error("Invalid geometry to add to layer("+this.getId()+") at index:"+s);if(!(h instanceof os)&&(h=os.fromJSON(h),Array.isArray(h)))for(var l=0,c=h.length;l<c;l++)this._add(h[l],r,s),o.push(h[l]);Array.isArray(h)||(this._add(h,r,s),o.push(h))}var u=this.getMap();if(u&&(this._getRenderer().onGeometryAdd(o),r&&!H(r.xmin))){var d=r.getCenter(),p=u.getFitZoom(r);if(U(e)){var f=W(e.step)?e.step:function(){};u.animateTo({center:d,zoom:p},N({duration:u.options.zoomAnimationDuration,easing:"out"},e),f)}else!0===e&&u.setCenterAndZoom(d,p)}return this.fire("addgeo",{geometries:t}),this},i.getGeoMinZIndex=function(){return this._minZIndex},i.getGeoMaxZIndex=function(){return this._maxZIndex},i._add=function(t,e,i){this._toSort||(this._toSort=0!==t.getZIndex()),this._updateZIndex(t.getZIndex());var n=t.getId();if(!H(n)){if(!H(this._geoMap[n]))throw new Error("Duplicate geometry id in layer("+this.getId()+"):"+n+", at index:"+i);this._geoMap[n]=t}var r=Gt();t._setInternalId(r),this._geoList.push(t),this.onAddGeometry(t),t._bindLayer(this),t.onAdd&&t.onAdd(),e&&e._combine(t.getExtent()),t._fireEvent("add",{layer:this}),this._cookedStyles&&this._styleGeometry(t)},i.removeGeometry=function(t){if(!Array.isArray(t))return this.removeGeometry([t]);for(var e=t.length-1;e>=0;e--)t[e]instanceof os||(t[e]=this.getGeometryById(t[e])),t[e]&&this===t[e].getLayer()&&t[e].remove();return this.fire("removegeo",{geometries:t}),this},i.clear=function(){this._clearing=!0,this.forEach((function(t){t.remove()})),this._geoMap={};var t=this._geoList;this._geoList=[];var e=this._getRenderer();return e&&(e.onGeometryRemove(t),e.clearImageData&&e.clearImageData()),this._clearing=!1,this.fire("clear"),this},i.onRemoveGeometry=function(t){if(t&&!this._clearing&&(this===t.getLayer()&&!H(t._getInternalId()))){var e=t.getId();H(e)||delete this._geoMap[e];var i=this._findInList(t);i>=0&&this._geoList.splice(i,1),this._getRenderer()&&this._getRenderer().onGeometryRemove([t])}},i.getStyle=function(){return this.options.style?this.options.style:null},i.setStyle=function(t){return this.options.style=t,t=Pi(t),this._cookedStyles=Je(t),this.forEach((function(t){this._styleGeometry(t)}),this),this.fire("setstyle",{style:t}),this},i._styleGeometry=function(t){if(!this._cookedStyles)return!1;for(var e=Ye(t),i=0,n=this._cookedStyles.length;i<n;i++)if(!0===this._cookedStyles[i].filter(e))return t._setExternSymbol(this._cookedStyles[i].symbol),!0;return!1},i.removeStyle=function(){return this.options.style?(delete this.options.style,delete this._cookedStyles,this.forEach((function(t){t._setExternSymbol(null)}),this),this.fire("removestyle"),this):this},i.onAddGeometry=function(t){this.getStyle()&&this._styleGeometry(t)},i.hide=function(){for(var t=0,e=this._geoList.length;t<e;t++)this._geoList[t].onHide();return ds.prototype.hide.call(this)},i._initCache=function(){this._geoList||(this._geoList=[],this._geoMap={})},i._updateZIndex=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this._maxZIndex=Math.max(this._maxZIndex,Math.max.apply(Math,e)),this._minZIndex=Math.min(this._minZIndex,Math.min.apply(Math,e))},i._sortGeometries=function(){var t=this;this._toSort&&(this._maxZIndex=0,this._minZIndex=0,this._geoList.sort((function(e,i){return t._updateZIndex(e.getZIndex(),i.getZIndex()),t._compare(e,i)})),this._toSort=!1)},i._compare=function(t,e){return t.getZIndex()===e.getZIndex()?t._getInternalId()-e._getInternalId():t.getZIndex()-e.getZIndex()},i._findInList=function(t){var e=this._geoList.length;if(0===e)return-1;this._sortGeometries();for(var i,n=0,r=e-1;n<=r;){if(i=Math.floor((n+r)/2),this._geoList[i]===t)return i;this._compare(this._geoList[i],t)>0?r=i-1:n=i+1}return-1},i._onGeometryEvent=function(t){if(t&&t.target){var e=t.type;"idchange"===e?this._onGeometryIdChange(t):"zindexchange"===e?this._onGeometryZIndexChange(t):"positionchange"===e?this._onGeometryPositionChange(t):"shapechange"===e?this._onGeometryShapeChange(t):"symbolchange"===e?this._onGeometrySymbolChange(t):"show"===e?this._onGeometryShow(t):"hide"===e?this._onGeometryHide(t):"propertieschange"===e&&this._onGeometryPropertiesChange(t)}},i._onGeometryIdChange=function(t){if(t.new!==t.old||!this._geoMap[t.old]||this._geoMap[t.old]!==t.target){if(!H(t.new)){if(this._geoMap[t.new])throw new Error("Duplicate geometry id in layer("+this.getId()+"):"+t.new);this._geoMap[t.new]=t.target}H(t.old)||t.new===t.old||delete this._geoMap[t.old]}},i._onGeometryZIndexChange=function(t){t.old!==t.new&&(this._updateZIndex(t.new),this._toSort=!0,this._getRenderer()&&this._getRenderer().onGeometryZIndexChange(t))},i._onGeometryPositionChange=function(t){this._getRenderer()&&this._getRenderer().onGeometryPositionChange(t)},i._onGeometryShapeChange=function(t){this._getRenderer()&&this._getRenderer().onGeometryShapeChange(t)},i._onGeometrySymbolChange=function(t){this._getRenderer()&&this._getRenderer().onGeometrySymbolChange(t)},i._onGeometryShow=function(t){this._getRenderer()&&this._getRenderer().onGeometryShow(t)},i._onGeometryHide=function(t){this._getRenderer()&&this._getRenderer().onGeometryHide(t)},i._onGeometryPropertiesChange=function(t){this._getRenderer()&&this._getRenderer().onGeometryPropertiesChange(t)},i._hasGeoListeners=function(t){if(!t)return!1;Array.isArray(t)||(xa[0]=t,t=xa);for(var e=this.getGeometries()||[],i=0,n=e.length;i<n;i++)for(var r=0,o=t.length;r<o;r++){var s=t[r];if(e[i].listens(s)>0)return!0}return!1},e}(ds);wa.mergeOptions({drawImmediate:!1,geometryEvents:!0});var ba=new er,Ma={debug:!1,enableSimplify:!0,defaultIconSize:[20,20],cacheVectorOnCanvas:!0,cacheSvgOnCanvas:Ot.gecko,enableAltitude:!1,altitudeProperty:"altitude",drawAltitude:!1,sortByDistanceToCamera:!1,roundPoint:!1,altitude:0,clipBBoxBufferSize:3,geometryEventTolerance:1},Sa=function(t){function e(e,i,n){return t.call(this,e,i,n)||this}Dt(e,t);var i=e.prototype;return i.onConfig=function(e){if(t.prototype.onConfig.call(this,e),e.enableAltitude||e.drawAltitude||e.altitudeProperty){var i=this.getRenderer();i&&i.setToRedraw&&i.setToRedraw()}},i.identify=function(t,e){void 0===e&&(e={});var i=this.getRenderer();t instanceof Hn||(t=new Hn(t));var n=this.getMap().coordToContainerPoint(t);return e.onlyVisible&&i&&i.identifyAtPoint?i.identifyAtPoint(n,e):this._hitGeos(this._geoList,n,e)},i.identifyAtPoint=function(t,e){void 0===e&&(e={});var i=this.getRenderer();return t instanceof Bt||(t=new Bt(t)),e.onlyVisible&&i&&i.identifyAtPoint?i.identifyAtPoint(t,e):this._hitGeos(this._geoList,t,e)},i._hitGeos=function(t,e,i){void 0===i&&(i={});var n=i.filter,r=[],o=i.tolerance,s=this.getMap(),a=this.getRenderer(),h=a&&a.getImageData&&a.getImageData();if(h){for(var l=0,c=t.length-1;c>=0;c--){var u=t[c]._hitTestTolerance()+(o||0);u>l&&(l=u)}var d=s.getDevicePixelRatio();h.r=d;for(var p=!1,f=e.x-l,m=e.y-l,g=-l;g<=l;g++){for(var v=-l;v<=l;v++){var y=Math.round((f+g)*d),_=Math.round((m+v)*d)*h.width*4+4*y;if(h.data[_+3]>0){p=!0;break}}if(p)break}if(!p)return r}for(var x=t.length-1;x>=0;x--){var w=t[x];if(w&&w.isVisible()&&w._getPainter()&&w.options.interactive){if(!(w instanceof Zs&&(w._getArrowStyle()||w instanceof aa))){var b=w.getContainerExtent(ba);if(o&&(b=b._expand(o)),!b||!b.contains(e))continue}if(w._containsPoint(e,o)&&(!n||n(w))&&(r.push(w),i.count&&r.length>=i.count))break}}return r},i.getAltitude=function(){return this.options.altitude||0},i.toJSON=function(t){t||(t={});var e={type:this.getJSONType(),id:this.getId(),options:this.config()};if(H(t.geometries)||t.geometries){var i;if(t.clipExtent){var n=this.getMap(),r=n?n.getProjection():null;i=new tr(t.clipExtent,r)}for(var o=[],s=this.getGeometries(),a=0,h=s.length;a<h;a++){var l=s[a],c=l.getExtent();if(c&&(!i||i.intersects(c))){var u=l.toJSON(t.geometries);o.push(u)}}e.geometries=o}return e},e.fromJSON=function(t){if(!t||"VectorLayer"!==t.type)return null;for(var i=new e(t.id,t.options),n=t.geometries,r=[],o=0;o<n.length;o++){var s=os.fromJSON(n[o]);s&&r.push(s)}return i.addGeometry(r),i},e.getPainterClass=function(){return Jo},e.getCollectionPainterClass=function(){return $o},e}(wa);Sa.mergeOptions(Ma),Sa.registerJSONType("VectorLayer");var Ta="_map_tool",Ea=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.addTo=function(t){return t?(this._map=t,t[Ta]&&t[Ta].disable(),this.onAdd&&this.onAdd(),this.enable(),t[Ta]=this,this._fireEvent("add"),this):this},i.getMap=function(){return this._map},i.enable=function(){return!this._map||this._enabled||(this._enabled=!0,this._switchEvents("off"),this._registerEvents(),this.onEnable&&this.onEnable(),this._fireEvent("enable")),this},i.disable=function(){return this._enabled&&this._map?(this._enabled=!1,this._switchEvents("off"),this.onDisable&&this.onDisable(),this._fireEvent("disable"),this):this},i.isEnabled=function(){return!!this._enabled},i.remove=function(){return this._map?(this.disable(),this._map&&(delete this._map[Ta],delete this._map),this._fireEvent("remove"),this):this},i._registerEvents=function(){this._switchEvents("on")},i._switchEvents=function(t){var e=this.getEvents();e&&this._map[t](e,this)},i._fireEvent=function(t,e){e||(e={}),this.fire(t,e)},e}(Cn(Ln)),Ca={},Pa=function(t){function e(e){var i;return(i=t.call(this,e)||this)._checkMode(),i._events={click:i._clickHandler,"mousemove touchmove":i._mouseMoveHandler,dblclick:i._doubleClickHandler,"mousedown touchstart":i._mouseDownHandler,"mouseup touchend":i._mouseUpHandler,mousemove:i._mouseMoveHandler,mousedown:i._mouseDownHandler,mouseup:i._mouseUpHandler},i}Dt(e,t),e.registerMode=function(t,e){Ca[t.toLowerCase()]=e},e.getRegisterMode=function(t){return Ca[t.toLowerCase()]};var i=e.prototype;return i.getMode=function(){return this.options.mode?this.options.mode.toLowerCase():null},i.setMode=function(t){return this._geometry&&(this._geometry.remove(),delete this._geometry),this._clearStage(),this._switchEvents("off"),this.options.mode=t,this._checkMode(),this.isEnabled()&&(this._switchEvents("on"),this._restoreMapCfg(),this._saveMapCfg()),this},i.getSymbol=function(){var t=this.options.symbol;return Ci(t||this.options.symbol)},i.setSymbol=function(t){return t?(this.options.symbol=t,this._geometry&&this._geometry.setSymbol(t),this):this},i.getCurrentGeometry=function(){return this._geometry},i.onAdd=function(){this._checkMode()},i.onEnable=function(){this._saveMapCfg(),this._drawToolLayer=this._getDrawLayer(),this._clearStage(),this._loadResources();var t=this.getMap();return this.options.autoPanAtEdge&&(this._mapAutoPanAtEdge=t.options.autoPanAtEdge,this._mapAutoPanAtEdge||t.config({autoPanAtEdge:!0})),this._geometryEvents=t.options.geometryEvents,this.options.blockGeometryEvents&&t.config("geometryEvents",!1),this},i.onDisable=function(){var t=this.getMap();return this._restoreMapCfg(),this.endDraw({ignoreEndEvent:!0}),this._map&&(t.removeLayer(this._getDrawLayer()),this.options.autoPanAtEdge&&(this._mapAutoPanAtEdge||t.config({autoPanAtEdge:!1}))),this.options.blockGeometryEvents&&t.config("geometryEvents",this._geometryEvents),this},i.undo=function(){var t=this._getRegisterMode(),e=t.action;if(!this._shouldRecordHistory(e)||!this._historyPointer)return this;var i=this._clickCoords.slice(0,--this._historyPointer);return t.update(this.getMap().getProjection(),i,this._geometry),this},i.redo=function(){var t=this._getRegisterMode(),e=t.action;if(!this._shouldRecordHistory(e)||H(this._historyPointer)||this._historyPointer===this._clickCoords.length)return this;var i=this._clickCoords.slice(0,++this._historyPointer);return t.update(this.getMap().getProjection(),i,this._geometry),this},i._shouldRecordHistory=function(t){return Array.isArray(t)&&"click"===t[0]&&"mousemove"===t[1]&&"dblclick"===t[2]},i._checkMode=function(){this._getRegisterMode()},i._saveMapCfg=function(){var t=this.getMap();this._mapDoubleClickZoom=t.options.doubleClickZoom,t.config({doubleClickZoom:this.options.doubleClickZoom});for(var e=this._getRegisterMode().action,i=!1,n=0;n<e.length;n++)if(e[n].indexOf("mousedown")>=0||e[n].indexOf("touchstart")>=0){i=!0;break}if(i){var r=this.getMap();this._mapDraggable=r.options.draggable,r.config({draggable:!1})}},i._restoreMapCfg=function(){var t=this.getMap();t.config({doubleClickZoom:this._mapDoubleClickZoom}),H(this._mapDraggable)||t.config("draggable",this._mapDraggable),delete this._mapDraggable,delete this._mapDoubleClickZoom},i._loadResources=function(){var t=ni(this.getSymbol());t.length>0&&this._drawToolLayer._getRenderer().loadResources(t)},i._getProjection=function(){return this._map.getProjection()},i._getRegisterMode=function(){var t=this.getMode(),i=e.getRegisterMode(t);if(!i)throw new Error(t+" is not a valid mode of DrawTool.");return i},i.getEvents=function(){var t=this._getRegisterMode().action,e={};if(Array.isArray(t)){for(var i=0;i<t.length;i++)e[t[i]]=this._events[t[i]];return e}return null},i._mouseDownHandler=function(t){this._createGeometry(t)},i._mouseUpHandler=function(t){this.endDraw(t)},i._clickHandler=function(t){var e=this.getMap(),i=this._getRegisterMode();if(this._clickCoords&&this._clickCoords.length){var n=this._clickCoords.length,r=e._pointToPrj(t.point2d);if(this._clickCoords[n-1].equals(r))return}if(this._geometry){var o=e._pointToPrj(t.point2d);H(this._historyPointer)||(this._clickCoords=this._clickCoords.slice(0,this._historyPointer));var s=this._geometry.snapTo;if(s&&W(s)){var a=this._getSnapResult(s,t.containerPoint);if(o=a.prjCoord,this._clickCoords=this._clickCoords.concat(a.effectedVertex),this._clickCoords[this._clickCoords.length-1].equals(o))return}if(this._clickCoords.push(o),this._historyPointer=this._clickCoords.length,t.drawTool=this,i.update(e.getProjection(),this._clickCoords,this._geometry,t),"point"===this.getMode())return void this.endDraw(t);this._clickCoords.length<=1?this._fireEvent("drawstart",t):this._fireEvent("drawvertex",t),i.clickLimit&&i.clickLimit===this._historyPointer&&this.endDraw(t)}else this._createGeometry(t)},i._createGeometry=function(t){var e=this.getMode(),i=this._getRegisterMode(),n=this.getMap()._pointToPrj(t.point2d),r=this.getSymbol();if(!this._geometry){this._clickCoords=[n],t.drawTool=this,this._geometry=i.create(this.getMap().getProjection(),this._clickCoords,t),r&&"point"!==e?this._geometry.setSymbol(r):this.options.hasOwnProperty("symbol")&&this._geometry.setSymbol(this.options.symbol),this._addGeometryToStage(this._geometry),this._fireEvent("drawstart",t);var o=this._geometry.snapTo;if(o&&W(o)){var s=this._getSnapResult(o,t.containerPoint),a=this.getMap();if(a&&s){var h=s.prjCoord;this._clickCoords=[h],i.update(a.getProjection(),this._clickCoords,this._geometry,t)}}}"point"===e&&"mousemove"!==t.type&&this.endDraw(t)},i._mouseMoveHandler=function(t){var e=this.getMap();if(e&&!e.isInteracting())if("point"!==this.getMode()||this._geometry){if(this._geometry){var i=this._getMouseContainerPoint(t);if(this._isValidContainerPoint(i)){var n=e._pointToPrj(t.point2d),r=[],o=this._geometry.snapTo;if(o&&W(o)){var s=this._getSnapResult(o,i);n=s.prjCoord,r=s.effectedVertex}var a=e.getProjection();t.drawTool=this;var h=this._getRegisterMode();if(this._shouldRecordHistory(h.action)){var l=this._clickCoords.slice(0,this._historyPointer);if(l&&l.length>0&&n.equals(l[l.length-1]))return;h.update(a,l.concat(r,[n]),this._geometry,t)}else h.update(a,n,this._geometry,t);this._fireEvent("mousemove",t)}}}else this._createGeometry(t)},i._doubleClickHandler=function(t){if(this._geometry){var e=this._getMouseContainerPoint(t);if(this._isValidContainerPoint(e)){var i=this._getRegisterMode(),n=this._clickCoords;if(!(n.length<2)){var r=this.getMode();if(!(r&&r.indexOf("polygon")>-1&&n.length<3)){for(var o=this.getMap().getProjection(),s=[n[0]],a=1,h=n.length;a<h;a++)n[a].x===n[a-1].x&&n[a].y===n[a-1].y||s.push(n[a]);s.length<2||this._geometry&&this._geometry instanceof js&&s.length<3||(t.drawTool=this,i.update(o,s,this._geometry,t),this.endDraw(t))}}}}},i._addGeometryToStage=function(t){this._getDrawLayer().addGeometry(t)},i.endDraw=function(t){if(!this._geometry||this._ending)return this;this._ending=!0;var e=this._geometry;return this._clearStage(),t=t||{},this._geometry=e,t.ignoreEndEvent||this._fireEvent("drawend",t),delete this._geometry,this.options.once&&this.disable(),delete this._ending,delete this._historyPointer,this._vertexes&&(this._vertexes=[]),this},i._clearStage=function(){this._getDrawLayer().clear(),delete this._geometry,delete this._clickCoords},i._getMouseContainerPoint=function(t){var e=this._getRegisterMode().action;return(e[0].indexOf("mousedown")>=0||e[0].indexOf("touchstart")>=0)&&qi(t.domEvent),t.containerPoint},i._isValidContainerPoint=function(t){var e=this._map.getSize(),i=e.width,n=e.height;return!(t.x<0||t.y<0)&&!(t.x>i||t.y>n)},i._getSnapResult=function(t,e){var i=this.getMap(),n=[];if(this.options.edgeAutoComplete){var r=this._clickCoords[(this._historyPointer||1)-1];n.push(i._prjToContainerPoint(r));var o=this._clickCoords[(this._historyPointer||1)-2];o&&n.push(i._prjToContainerPoint(o))}var s=t(e,n);e=(s.effectedVertex?s.point:s)||e;var a=i._containerPointToPrj(e);return s.effectedVertex&&(s.effectedVertex=s.effectedVertex.map((function(t){return i._containerPointToPrj(t)}))),{prjCoord:a,effectedVertex:s.effectedVertex||[]}},i._getDrawLayer=function(){var t=L+"drawtool",e=this._map.getLayer(t);return e||(e=new Sa(t,{enableSimplify:!1,enableAltitude:this.options.enableAltitude}),this._map.addLayer(e)),e},i._fireEvent=function(t,e){e||(e={}),e=N({},e),this._geometry&&(e.geometry=this._getRegisterMode().generate(this._geometry,{drawTool:this}),e.tempGeometry=this._geometry),Ea.prototype._fireEvent.call(this,t,e)},e}(Ea);Pa.mergeOptions({symbol:{lineColor:"#000",lineWidth:2,lineOpacity:1,polygonFill:"#fff",polygonOpacity:.3},doubleClickZoom:!1,mode:null,once:!1,autoPanAtEdge:!1,ignoreMouseleave:!0,blockGeometryEvents:!1});var Aa=function(t){function e(e){var i;return(i=t.call(this,e)||this).drawTool=new Pa({mode:"boxZoom",ignoreMouseleave:!1}),i}Dt(e,t);var i=e.prototype;return i.addHooks=function(){this.target.on("_mousedown",this._onMouseDown,this)},i.removeHooks=function(){this.target.off("_mousedown",this._onMouseDown,this),this.drawTool.isEnabled()&&this.drawTool.remove()},i._onMouseDown=function(t){this.target.options.boxZoom&&t.domEvent.shiftKey&&this.drawTool.setSymbol(this.target.options.boxZoomSymbol).on("drawend",this._boxZoom,this).addTo(this.target)},i._boxZoom=function(t){var e=this.target;this.drawTool.remove();var i=t.geometry,n=i.getCenter(),r=i.getSymbol(),o=r.markerWidth,s=r.markerHeight,a=new tr(n,e.locateByPoint(n,o,s),e.getProjection()),h=e.getFitZoom(a);e._animateTo({center:a.getCenter(),zoom:h})},e}(An);Ss.mergeOptions({boxZoom:!0,boxZoomSymbol:{markerType:"rectangle",markerLineWidth:3,markerLineColor:"#1bbc9b",markerLineDasharray:[10,5],markerFillOpacity:.1,markerFill:"#1bbc9b",markerWidth:1,markerHeight:1}}),Ss.addOnLoadHook("addHandler","boxZoom",Aa);var La=30,Ra=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.addHooks=function(){this.target&&this.target.on("_mousemove",this._onMouseMove,this)},i.removeHooks=function(){this.target&&this.target.off("_mousemove",this._onMouseMove,this)},i._onMouseMove=function(t){var e=this.target;if(e.options.autoPanAtEdge){var i=t.containerPoint,n=e.getContainerExtent();if(n){var r,o=i.x,s=i.y,a=n.xmax,h=n.ymax;o<La&&(r=[Math.abs(o-La),0]),s<La&&(r=[0,Math.abs(s-La)]),o+La>a&&(r=[-Math.abs(o+La-a),0]),s+La>h&&(r=[0,-Math.abs(s+La-h)]),r&&e.panBy(r,{duration:1})}}},e}(An);function Oa(t,e,i){return t*(1-i)+e*i}Ss.mergeOptions({autoPanAtEdge:!1}),Ss.addOnLoadHook("addHandler","autoPanAtEdge",Ra),Ss.include({animateTo:function(t,e,i){var n=this;void 0===e&&(e={}),W(e)&&(i=e,e={});var r=this.getProjection(),o=this.getView(),s={},a=!0;for(var h in t)if(q(t,h)&&!H(t[h])&&("prjCenter"===h||!H(o[h])))if(a=!1,"center"===h){var l=new Hn(o[h]),c=new Hn(t[h]);l.equals(c)||(s.center=[l,c])}else if("prjCenter"===h){var u=new Hn(this._getPrjCenter()),d=new Hn(t[h]);u.equals(d)||(s.prjCenter=[u,d])}else o[h]!==t[h]&&"around"!==h&&(s[h]=[o[h],t[h]]);if(a)return null;this._animPlayer&&(this._isInternalAnimation?"running"===this._animPlayer.playState&&(this._animPlayer.pause(),this._prevAnimPlayer=this._animPlayer):(delete this._prevAnimPlayer,this._stopAnim(this._animPlayer)));var p=t.around||new Bt(this.width/2,this.height/2),f=this._getRenderer(),m=this._animPlayer=Fs.animate(s,{easing:e.easing||"out",duration:e.duration||this.options.zoomAnimationDuration,framer:function(t){f.callInNextFrame(t)},repeat:e.repeat},(function(t){if(n.isRemoved())m.finish();else{if("running"===m.playState){if(t.styles.center){var o=t.styles.center;n._setPrjCenter(r.project(o)),n.onMoving(n._parseEventFromCoord(n.getCenter()))}else if(t.styles.prjCenter){var a=t.styles.prjCenter;n._setPrjCenter(a),n.onMoving(n._parseEventFromCoord(n.getCenter()))}H(t.styles.zoom)||n.onZooming(t.styles.zoom,p),H(t.styles.pitch)||n._setPitch(t.styles.pitch),H(t.styles.bearing)||n._setBearing(t.styles.bearing),n._fireEvent("animating")}else"paused"===m.playState&&m!==n._mapAnimPlayer||(m._interupted||(s.center?n._setPrjCenter(r.project(s.center[1])):s.prjCenter&&n._setPrjCenter(s.prjCenter[1]),H(s.pitch)||n._setPitch(s.pitch[1]),H(s.bearing)||n._setBearing(s.bearing[1])),n._endAnim(m,s,p,e));i&&i(t)}}),this);return this._startAnim(s,p),m},_animateTo:function(t,e,i){return void 0===e&&(e={}),this._mapAnimPlayer&&this._stopAnim(this._mapAnimPlayer),this._isInternalAnimation=!0,this._mapAnimPlayer=this.animateTo(t,e,i),delete this._isInternalAnimation,this._mapAnimPlayer},flyTo:function(t,e,i){var n=this;void 0===e&&(e={}),this._animPlayer&&(this._isInternalAnimation?"running"===this._animPlayer.playState&&(this._animPlayer.pause(),this._prevAnimPlayer=this._animPlayer):(delete this._prevAnimPlayer,this._stopAnim(this._animPlayer))),W(e)&&(i=e,e={}),e=N({curve:1.42},e);var r=this;function o(t,e){return r.getResolution(e)/r.getResolution(t)}var s=t.around||new Bt(this.width/2,this.height/2),a=this.getMinZoom(),h=this.getMaxZoom(),l=this.getProjection(),c=this.getView(),u=c.zoom,d=c.bearing,p=c.pitch,f="zoom"in t?$t(+t.zoom,a,h):u,m="bearing"in t?+t.bearing:d,g="pitch"in t?+t.pitch:p,v=l.project(t.center&&new Hn(t.center)||this.getCenter()),y=o(f,u),_=l.project(this.getCenter()),x=v.sub(_),w=e.curve,b=Math.max(this.width,this.height),M=b/y,S=x.mag();if("minZoom"in e){var T=$t(Math.min(e.minZoom,u,f),a,h),E=b/o(T,u);w=Math.sqrt(E/S*2)}var C=w*w;function P(t){var e=(M*M-b*b+(t?-1:1)*C*C*S*S)/(2*(t?M:b)*C*S);return Math.log(Math.sqrt(e*e+1)-e)}function A(t){return(Math.exp(t)-Math.exp(-t))/2}function L(t){return(Math.exp(t)+Math.exp(-t))/2}var R=P(0),O=function(t){return L(R)/L(R+w*t)},D=function(t){return b*((L(R)*(A(e=R+w*t)/L(e))-A(R))/C)/S;var e},I=(P(1)-R)/w;if(Math.abs(S)<1e-6||!isFinite(I)){if(Math.abs(b-M)<1e-6)return this.animateTo(t,e,i);var k=M<b?-1:1;I=Math.abs(Math.log(M/b))/w,D=function(){return 0},O=function(t){return Math.exp(k*w*t)}}var z=this._getRenderer(),F=this._animPlayer=Fs.animate({k:[0,1]},{easing:e.easing||"out",duration:e.duration||8,framer:function(t){z.callInNextFrame(t)}},(function(r){if(n.isRemoved())F.finish();else{var o=r.styles.k,a=o*I,h=1/O(a),l={};if(t.center){var c=1===o?v:_.add(x.multi(D(a)));l.prjCenter=[v,c]}if(u!==f){var y=1===o?f:n.getZoomForScale(h,u,!0);l.zoom=[u,y]}if(p!==g){var w=Oa(p,g,o);l.pitch=[g,w]}if(d!==m){var b=Oa(d,m,o);l.bearing=[m,b]}if("running"===F.playState){if(l.prjCenter){var M=l.prjCenter;n._setPrjCenter(M[1]),n.onMoving(n._parseEventFromCoord(n.getCenter()))}l.zoom&&n.onZooming(l.zoom[1],s),l.pitch&&n._setPitch(l.pitch[1]),l.bearing&&n._setBearing(l.bearing[1]),n._fireEvent("animating")}else"paused"===F.playState&&F!==n._mapAnimPlayer||(F._interupted||(l.prjCenter&&n._setPrjCenter(l.prjCenter[1]),l.pitch&&n._setPitch(l.pitch[1]),l.bearing&&n._setBearing(l.bearing[1])),n._endAnim(F,l,s,e));i&&i(r)}}));return this._startAnim({center:t.center,zoom:t.zoom!==u,pitch:g!==p,bearing:m!==d},s),this},isAnimating:function(){return!!this._animPlayer},isRotating:function(){return this.isDragRotating()||!!this._animRotating},_endAnim:function(t,e,i,n){delete this._animRotating;var r,o=t._interupted?"animateinterrupted":"animateend";if(t===this._animPlayer&&delete this._animPlayer,t===this._mapAnimPlayer&&delete this._mapAnimPlayer,e.center)r=t._interupted?this.getCenter():e.center[1],this.onMoveEnd(this._parseEventFromCoord(r));else if(e.prjCenter){var s;s=t._interupted?this._getPrjCenter():e.prjCenter[1];var a=this._parseEventFromCoord(this.getProjection().unproject(s));a.point2d=this._prjToPoint(s),this.onMoveEnd(a)}H(e.zoom)||(t._interupted?this.onZoomEnd(this.getZoom(),i):n.wheelZoom?this.onZooming(e.zoom[1],i):this.onZoomEnd(e.zoom[1],i)),o&&this._fireEvent(o),H(e.pitch)||this.getPitch()||this.getRenderer().setToRedraw(),n.wheelZoom||this._resumePrev(t)},_startAnim:function(t,e){this._animPlayer&&((t.center||t.prjCenter)&&this.onMoveStart(),t.zoom&&!this.isZooming()&&this.onZoomStart(t.zoom[1],e),(t.pitch||t.bearing)&&(this._animRotating=!0),this._fireEvent("animatestart"),this._animPlayer.play())},_stopAnim:function(t){t&&(delete this._animRotating,"finished"!==t.playState&&(t._interupted=!0,t.cancel()),t===this._animPlayer&&delete this._animPlayer,t===this._mapAnimPlayer&&delete this._mapAnimPlayer)},_resumePrev:function(t){if(this._prevAnimPlayer){var e=this._prevAnimPlayer;"paused"!==e.playState&&delete this._prevAnimPlayer,t!==e&&(this._animPlayer=e,e.play())}}});var Da="mousedown mouseup mouseover mouseout mouseenter mouseleave mousemove click dblclick contextmenu keypress touchstart touchmove touchend ";function Ia(t,e,i,n,r){var o=1/Math.tan(e/2),s=1/(n-r);return t[0]=o/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(r+n)*s,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*r*n*s,t[15]=0,t}function ka(t,e,i){var n,r,o,s,a,h,l,c,u,d,p,f,m=i[0],g=i[1],v=i[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*v+e[12],t[13]=e[1]*m+e[5]*g+e[9]*v+e[13],t[14]=e[2]*m+e[6]*g+e[10]*v+e[14],t[15]=e[3]*m+e[7]*g+e[11]*v+e[15]):(n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=e[5],l=e[6],c=e[7],u=e[8],d=e[9],p=e[10],f=e[11],t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=a,t[5]=h,t[6]=l,t[7]=c,t[8]=u,t[9]=d,t[10]=p,t[11]=f,t[12]=n*m+a*g+u*v+e[12],t[13]=r*m+h*g+d*v+e[13],t[14]=o*m+l*g+p*v+e[14],t[15]=s*m+c*g+f*v+e[15]),t}function za(t,e,i){var n=i[0],r=i[1],o=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Fa(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=e[5],l=e[6],c=e[7],u=e[8],d=e[9],p=e[10],f=e[11],m=e[12],g=e[13],v=e[14],y=e[15],_=i[0],x=i[1],w=i[2],b=i[3];return t[0]=_*n+x*a+w*u+b*m,t[1]=_*r+x*h+w*d+b*g,t[2]=_*o+x*l+w*p+b*v,t[3]=_*s+x*c+w*f+b*y,_=i[4],x=i[5],w=i[6],b=i[7],t[4]=_*n+x*a+w*u+b*m,t[5]=_*r+x*h+w*d+b*g,t[6]=_*o+x*l+w*p+b*v,t[7]=_*s+x*c+w*f+b*y,_=i[8],x=i[9],w=i[10],b=i[11],t[8]=_*n+x*a+w*u+b*m,t[9]=_*r+x*h+w*d+b*g,t[10]=_*o+x*l+w*p+b*v,t[11]=_*s+x*c+w*f+b*y,_=i[12],x=i[13],w=i[14],b=i[15],t[12]=_*n+x*a+w*u+b*m,t[13]=_*r+x*h+w*d+b*g,t[14]=_*o+x*l+w*p+b*v,t[15]=_*s+x*c+w*f+b*y,t}function Ba(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],h=e[6],l=e[7],c=e[8],u=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],v=e[15],y=i*a-n*s,_=i*h-r*s,x=i*l-o*s,w=n*h-r*a,b=n*l-o*a,M=r*l-o*h,S=c*m-u*f,T=c*g-d*f,E=c*v-p*f,C=u*g-d*m,P=u*v-p*m,A=d*v-p*g,L=y*A-_*P+x*C+w*E-b*T+M*S;return L?(L=1/L,t[0]=(a*A-h*P+l*C)*L,t[1]=(r*P-n*A-o*C)*L,t[2]=(m*M-g*b+v*w)*L,t[3]=(d*b-u*M-p*w)*L,t[4]=(h*E-s*A-l*T)*L,t[5]=(i*A-r*E+o*T)*L,t[6]=(g*x-f*M-v*_)*L,t[7]=(c*M-d*x+p*_)*L,t[8]=(s*P-a*E+l*S)*L,t[9]=(n*E-i*P-o*S)*L,t[10]=(f*b-m*x+v*y)*L,t[11]=(u*x-c*b-p*y)*L,t[12]=(a*T-s*C-h*S)*L,t[13]=(i*C-n*T+r*S)*L,t[14]=(m*_-f*w-g*y)*L,t[15]=(c*w-u*_+d*y)*L,t):null}function Na(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ha(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ja(t,e,i,n){return t[0]=e,t[1]=i,t[2]=n,t}function Ga(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function Ua(t){var e=t[0],i=t[1],n=t[2];return Math.sqrt(e*e+i*i+n*n)}function Va(t,e){var i=e[0],n=e[1],r=e[2],o=i*i+n*n+r*r;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function Wa(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[0],a=i[1],h=i[2];return t[0]=r*h-o*a,t[1]=o*s-n*h,t[2]=n*a-r*s,t}function Za(t,e){var i=e[0]-t[0],n=e[1]-t[1],r=e[2]-t[2];return Math.hypot?Math.hypot(i,n,r):function(){var t=0,e=arguments.length;for(;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}(i,n,r)}function qa(t,e,i){var n=e[0],r=e[1],o=e[2],s=1/(i[3]*n+i[7]*r+i[11]*o+i[15]);return t[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])*s,t[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])*s,t[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])*s,t}Ss.include({_registerDomEvents:function(){Ui(this._panels.mapWrapper||this._containerDOM,Da,this._handleDOMEvent,this)},_removeDomEvents:function(){Vi(this._panels.mapWrapper||this._containerDOM,Da,this._handleDOMEvent)},_handleDOMEvent:function(t){var e=this.options.clickTimeThreshold,i=t.type,n="mousedown"===i||"touchstart"===i&&(!t.touches||1===t.touches.length);n&&(this._domMouseDownTime=B(),this._domMouseDownView=this.getView());var r="contextmenu"===i&&function(t){if(!t._domMouseDownView)return!0;var e=t.getView(),i=t._domMouseDownView;return e.bearing!==i.bearing||e.pitch!==i.pitch}(this);if("contextmenu"===i){Zi(t);var o=this._domMouseDownTime;B()-o<=e&&!r&&this._fireDOMEvent(this,t,"dom:"+t.type)}else this._fireDOMEvent(this,t,"dom:"+t.type);if(!this._ignoreEvent(t)){var s,a=!1;if(n)this._mouseDownTime=B();else if("click"===i||"touchend"===i||"contextmenu"===i){if(!this._mouseDownTime)return;var h=this._mouseDownTime;if(delete this._mouseDownTime,B()-h>e){if("click"===i||"contextmenu"===i)return}else if("contextmenu"===i){if(r)return}else"touchend"===i&&(a=!0)}a&&(this._clickTime&&B()-this._clickTime<=e?(delete this._clickTime,s="dblclick",this._fireDOMEvent(this,t,"dom:dblclick")):(this._clickTime=B(),s="click",this._fireDOMEvent(this,t,"dom:click"))),this._ignoreEvent(t)||(this._fireDOMEvent(this,t,i),s&&this._fireDOMEvent(this,t,s))}},_ignoreEvent:function(t){if(!t||!this._panels.control)return!1;if(this._isEventOutMap(t))return!0;var e,i=t.srcElement||t.target;if(i)for(;i&&i!==this._containerDOM;){if(i.className&&i.className.indexOf&&(i.className.indexOf("maptalks-control")>=0||i.className.indexOf("maptalks-ui")>=0&&e&&!e.eventsPropagation))return!0;e=i,i=i.parentNode}return!1},_isEventOutMap:function(t){if(this.getPitch()>this.options.maxVisualPitch){var e=Qi(this._getActualEvent(t),this._containerDOM);if(!this.getContainerExtent().contains(e))return!0}return!1},_parseEvent:function(t,e){if(!t)return null;var i={domEvent:t};if("keypress"!==e){var n=this._getActualEvent(t);if(n&&void 0!==n.clientX){var r=Qi(n,this._containerDOM);i=N(i,{containerPoint:r,viewPoint:this.containerPointToViewPoint(r)});var o=this.options.maxVisualPitch;(this.getPitch()<=o||r.y>=this.height-this._getVisualHeight(o))&&(i=N(i,{coordinate:this.containerPointToCoord(r),point2d:this._containerPointToPoint(r)}))}}return i},_parseEventFromCoord:function(t){var e=this.coordToContainerPoint(t);return{coordinate:t,containerPoint:e,viewPoint:this.containerPointToViewPoint(e),point2d:this.coordToPoint(t)}},_getActualEvent:function(t){return t.touches&&t.touches.length>0?t.touches[0]:t.changedTouches&&t.changedTouches.length>0?t.changedTouches[0]:t},_fireDOMEvent:function(t,e,i){if(!this.isRemoved()){var n=this._parseEvent(e,i);this._fireEvent(i,n)}},_getEventParams:function(t){var e=this,i={domEvent:t},n=t.touches&&t.touches.length>0?t.touches[0]:t.changedTouches&&t.changedTouches.length>0?t.changedTouches[0]:t;if(n){var r=Qi(n,e._containerDOM);i.coordinate=e.containerPointToCoordinate(r),i.containerPoint=r,i.viewPoint=e.containerPointToViewPoint(r),i.pont2d=e._containerPointToPoint(r)}return i}}),Ss.addOnLoadHook("_registerDomEvents"),Ss.include({isFullScreen:function(){return!!(document.webkitIsFullScreen||document.mozFullScreen||document.msFullscreenElement||document.fullscreenElement)},requestFullScreen:function(t){return this._fireEvent("fullscreenstart"),this._requestFullScreen(t||this._containerDOM),this._fireEvent("fullscreenend"),this},cancelFullScreen:function(){return this._cancelFullScreen(),this._fireEvent("cancelfullscreen"),this},_requestFullScreen:function(t){if(t.requestFullscreen)t.requestFullscreen();else if(t.mozRequestFullScreen)t.mozRequestFullScreen();else if(t.webkitRequestFullScreen)t.webkitRequestFullScreen();else if(t.msRequestFullScreen)t.msRequestFullScreen();else{var e="fullscreen=1,status=no,resizable=yes,top=0,left=0,scrollbars=no,titlebar=no,menubar=no,location=no,toolbar=no,z-look=yes,width="+(screen.availWidth-8)+",height="+(screen.availHeight-45);null!==window.open(location.href,"_blank",e)&&(window.opener=null,window.close())}},_cancelFullScreen:function(){if(document.exitFullscreen)document.exitFullscreen();else if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{null!==window.open(location.href,"_blank","fullscreen=no,status=yes,resizable=yes,scrollbars=no,titlebar=no,menubar=yes,location=yes,toolbar=yes,z-look=yes")&&(window.opener=null,window.close())}}}),Ss.include({panTo:function(t,e,i){if(void 0===e&&(e={}),!t)return this;if(W(e)&&(i=e,e={}),t=new Hn(t),void 0===e.animation||e.animation){var n=this.getProjection().project(t);return this._panAnimation(n,e.duration,i)}return this.setCenter(t),this},_panTo:function(t,e){return void 0===e&&(e={}),void 0===e.animation||e.animation?this._panAnimation(t,e.duration):(this.onMoveStart(),this._setPrjCenter(t),this.onMoveEnd(this._parseEventFromCoord(this.getCenter())),this)},panBy:function(t,e,i){if(void 0===e&&(e={}),!t)return this;if(W(e)&&(i=e,e={}),t=new Bt(t),this.getContainerExtent().ymin>0&&t.y>30){var n=t.y;t.y=30,t.x=30*t.x/n,console.warn("offset is limited to panBy when pitch is above maxPitch")}if(this.onMoveStart(),void 0===e.animation||e.animation){t=t.multi(-1);var r=this._containerPointToPrj(new Bt(this.width/2+t.x,this.height/2+t.y));this._panAnimation(r,e.duration,i)}else this._offsetCenterByPixel(t),this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));return this},_panAnimation:function(t,e,i){return this._animateTo({prjCenter:t},{duration:e||this.options.panAnimationDuration},i)}}),os.fromJSON=function(t){if(Array.isArray(t)){for(var e=[],i=0,n=t.length;i<n;i++){var r=os.fromJSON(t[i]);Array.isArray(t)?e=e.concat(r):e.push(r)}return e}return t&&!t.feature?ia.toGeometry(t):(t.subType?(o=os.getJSONClass(t.subType).fromJSON(t),H(t.feature.id)||o.setId(t.feature.id)):(o=ia.toGeometry(t.feature),t.options&&o.config(t.options)),t.symbol&&o.setSymbol(t.symbol),t.infoWindow&&o.setInfoWindow(t.infoWindow),o);var o},ds.fromJSON=function(t){if(!t)return null;var e=t.type,i=ds.getJSONClass(e);if(!i||!i.fromJSON)throw new Error("unsupported layer type:"+e);return i.fromJSON(t)},Ss.include({JSON_VERSION:"1.0",toJSON:function(t){t||(t={});var e={jsonVersion:this.JSON_VERSION,version:this.VERSION,extent:this.getExtent().toJSON()};e.options=this.config(),e.options.center=this.getCenter(),e.options.zoom=this.getZoom(),e.options.bearing=this.getBearing(),e.options.pitch=this.getPitch();var i=this.getBaseLayer();(H(t.baseLayer)||t.baseLayer)&&i&&(e.baseLayer=i.toJSON(t.baseLayer));var n={};t.clipExtent&&(!0===t.clipExtent?n.clipExtent=this.getExtent():n.clipExtent=t.clipExtent);var r=[];if(H(t.layers)||t.layers&&!Array.isArray(t.layers)){for(var o=this.getLayers(),s=0,a=o.length;s<a;s++)if(o[s].toJSON){var h=N({},U(t.layers)?t.layers:{},n);r.push(o[s].toJSON(h))}e.layers=r}else if(te(t.layers)){for(var l=t.layers,c=0;c<l.length;c++){var u=l[c],d=this.getLayer(u.id);if(d.toJSON){var p=N({},u.options,n);r.push(d.toJSON(p))}}e.layers=r}else e.layers=[];return e}}),Ss.fromJSON=function(t,e,i){if(!t||!e)return null;i||(i={});var n=new Ss(t,e.options);if(H(i.baseLayer)||i.baseLayer){var r=ds.fromJSON(e.baseLayer);r&&n.setBaseLayer(r)}if(H(i.layers)||i.layers){for(var o=[],s=e.layers,a=0;a<s.length;a++){var h=ds.fromJSON(s[a]);o.push(h)}n.addLayer(o)}return n},Ss.include({computeLength:function(t,e){if(!this.getProjection())return null;var i=new Hn(t),n=new Hn(e);return i.equals(n)?0:this.getProjection().measureLength(i,n)},computeGeometryLength:function(t){return t._computeGeodesicLength(this.getProjection())},computeGeometryArea:function(t){return t._computeGeodesicArea(this.getProjection())},identify:function(t,e){var i=new Hn((t=t||{}).coordinate);return this._identify(t,e,(function(e){return e.identify(i,t)}))},identifyAtPoint:function(t,e){var i=new Bt((t=t||{}).containerPoint),n=this.containerPointToCoord(i);return this._identify(t,e,(function(e){return e.identifyAtPoint?e.identifyAtPoint(i,t):n?e.identify(n,t):[]}))},_identify:function(t,e,i){var n=t.layers;if(!te(n))return this;for(var r=t.eventTypes,o=[],s=0,a=n.length;s<a;s++)V(n[s])?o.push(this.getLayer(n[s])):o.push(n[s]);r&&(o=o.filter((function(t){return!t._hasGeoListeners||t._hasGeoListeners(r)})));for(var h=[],l=o.length-1;l>=0&&!(t.count&&h.length>=t.count);l--){var c=o[l];if(c&&c.getMap()&&(t.includeInvisible||c.isVisible())&&(t.includeInternals||!(c.getId().indexOf(L)>=0))){var u=i(c);u&&(Array.isArray(u)?Wt(h,u):h.push(u))}}return e.call(this,h),this}}),Ss.include({_zoom:function(t,e){this.options.zoomable&&!this.isZooming()&&(e=this._checkZoomOrigin(e),t=this._checkZoom(t),this.onZoomStart(t,e),this._frameZoom=this.getZoom(),this.onZoomEnd(t,e))},_zoomAnimation:function(t,e,i){this.options.zoomable&&!this.isZooming()&&(t=this._checkZoom(t),this.getZoom()!==t&&(e=this._checkZoomOrigin(e),this._startZoomAnim(t,e,i)))},_checkZoomOrigin:function(t){return t&&!this.options.zoomInCenter||(t=new Bt(this.width/2,this.height/2)),this.options.zoomOrigin&&(t=new Bt(this.options.zoomOrigin)),t},_startZoomAnim:function(t,e,i){H(i)&&(i=1);var n=this._getResolution(this._startZoomVal)/this._getResolution(t),r=this.options.zoomAnimationDuration*Math.abs(n-i)/Math.abs(n-1);this._frameZoom=this._startZoomVal,this._animateTo({zoom:t,around:e},{continueOnViewChanged:!0,duration:r})},onZoomStart:function(t,e){this.options.zoomable&&!this.isZooming()&&(this._mapAnimPlayer&&this._stopAnim(this._mapAnimPlayer),this._zooming=!0,this._startZoomVal=this.getZoom(),this._startZoomCoord=this._containerPointToPrj(e),this._fireEvent("zoomstart",{from:this._startZoomVal,to:t}))},onZooming:function(t,e,i){if(this.options.zoomable&&this._frameZoom!==t){H(i)&&(i=1),this._zoomTo(t,e);var n=this.getResolution(t),r=this.getResolution(this._startZoomVal)/n/i,o=this._prjToContainerPoint(this._startZoomCoord,this._startZoomVal),s=this.getViewPoint();if(!this.isRotating()&&!o.equals(e)&&1!==r){var a=this.getPitch(),h=o._sub(e)._multi(1/(1-r));a&&(h.y/=Math.cos(a*Math.PI/180)),e=e.add(h)}var l={view:[r,0,0,r,(e.x-s.x)*(1-r),(e.y-s.y)*(1-r)]},c=this.getDevicePixelRatio();1!==c&&(e=e.multi(c)),l.container=[r,0,0,r,e.x*(1-r),e.y*(1-r)],this._fireEvent("zooming",{from:this._startZoomVal,to:t,origin:e,matrix:l}),this._frameZoom=t}},onZoomEnd:function(t,e){if(this.options.zoomable){var i=this._startZoomVal;this._zoomTo(t,e),this._zooming=!1,this._getRenderer().onZoomEnd(),this._fireEvent("zoomend",{from:i,to:t}),this._verifyExtent(this._getPrjCenter())||this._panTo(this._prjMaxExtent.getCenter())}},_zoomTo:function(t,e){this._zoomLevel=t,this._calcMatrices(),e&&this._setPrjCoordAtContainerPoint(this._startZoomCoord,e)},_checkZoom:function(t){var e=this.getMaxZoom(),i=this.getMinZoom();return t<i&&(t=i),t>e&&(t=e),t}});var Xa,Ya,Ja,Qa,Ka,$a,th,eh,ih,nh=Math.PI/180,rh=new Hn(0,0);function oh(){return Na(new Array(16))}Ss.include({getFov:function(){return this._fov||(this._fov=.6435011087932844),this._fov/nh},setFov:function(t){if(this.isZooming())return this;if(t=Math.max(.01,Math.min(60,t)),this._fov===t)return this;var e=this.getFov();return this._fov=t*nh,this._calcMatrices(),this._renderLayers(),this._fireEvent("fovchange",{from:e,to:this.getFov()}),this},getBearing:function(){return this._angle?-this._angle/nh:0},setBearing:function(t){return this._mapAnimPlayer&&this._stopAnim(this._mapAnimPlayer),this._setBearing(t)},_setBearing:function(t){if(Ot.ie9)throw new Error("map can't rotate in IE9.");var e=-Kt(t,-180,180)*nh;if(this._angle===e)return this;var i=this.getBearing();return this._fireEvent("rotatestart",{from:i,to:e}),this._angle=e,this._calcMatrices(),this._renderLayers(),this._fireEvent("rotate",{from:i,to:e}),this._fireEvent("rotateend",{from:i,to:e}),this},getPitch:function(){return this._pitch?this._pitch/Math.PI*180:0},setPitch:function(t){return this._mapAnimPlayer&&this._stopAnim(this._mapAnimPlayer),this._setPitch(t)},_setPitch:function(t){if(Ot.ie9)throw new Error("map can't tilt in IE9.");var e=$t(t,0,this.options.maxPitch)*nh;if(this._pitch===e)return this;var i=this.getPitch();return this._fireEvent("pitchstart",{from:i,to:e}),this._pitch=e,this._calcMatrices(),this._renderLayers(),this._fireEvent("pitch",{from:i,to:e}),this._fireEvent("pitchend",{from:i,to:e}),this},isTransforming:function(){return!(!this._pitch&&!this._angle)},getFrustumAltitude:function(){return this._frustumAltitude},_calcFrustumAltitude:function(){var t=90-this.getPitch(),e=this.getFov()/2,i=this.cameraPosition?this.cameraPosition[2]:0;if(e<=t)return i;e=Math.PI*e/180;var n=new Bt(this.cameraPosition).distanceTo(new Bt(this.cameraLookAt)),r=i*Math.tan(2*e);return i+Math.tan(e)*(n+r)},_pointToContainerPoint:function(t,e,i,n){void 0===i&&(i=0);var r=this._getResolution(e);return this._pointAtResToContainerPoint(t,r,i,n)},_pointAtResToContainerPoint:function(t,e,i,n){void 0===i&&(i=0),n||(n=new Bt(0,0)),t=this._pointAtResToPoint(t,e,n);var r,o=this.isTransforming(),s=e/this._getResolution();return o||i||(r=this._prjToPoint(this._getPrjCenter(),void 0,rh)),this._toContainerPoint(n,o,s,i,r),n},_pointsAtResToContainerPoints:function(t,e,i,n){void 0===i&&(i=[]),void 0===n&&(n=[]);var r=this.getPitch(),o=this.getBearing();if(0===r&&0===o){var s=this._get2DExtent(),a=s.xmin,h=s.ymin,l=s.xmax,c=s.ymax;if(l>a&&c>h){for(var u=e/this._getResolution(),d=this.getSize(),p=d.width,f=d.height,m=(l-a)/p,g=(c-h)/f,v=0,y=t.length;v<y;v++)if(t[v]){var _=n[v];_.x=t[v].x,_.y=t[v].y,_._multi(u),_.x=(_.x-a)*m,_.y=f-(_.y-h)*g}else n[v]=null;return n}}for(var x=Array.isArray(i),w=this.isTransforming(),b=e/this._getResolution(),M=this._prjToPoint(this._getPrjCenter(),void 0,rh),S=0,T=t.length;S<T;S++)if(t[S]){var E=n[S];E.x=t[S].x,E.y=t[S].y,E._multi(b);var C=x?i[S]||0:i;this._toContainerPoint(E,w,b,C,M)}else n[S]=null;return n},_toContainerPoint:(ih=[0,0,0],function(t,e,i,n,r){var o=this.width/2,s=this.height/2;if(e||n){n*=i;var a=this._glScale;ja(ih,t.x*a,t.y*a,n*a);var h=this._projIfBehindCamera(ih,this.cameraPosition,this.cameraForward);qa(h,h,this.projViewMatrix),t.x=h[0]*o+o,t.y=-h[1]*s+s}else t._sub(r.x,r.y),t.set(t.x,-t.y),t._add(o,s)}),_projIfBehindCamera:($a=new Array(3),th=new Array(3),eh=new Array(3),function(t,e,i){Ga($a,t,e);var n=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}(i,$a);return n<=0&&(function(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}(th,i,1.01*n),function(t,e,i){t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2]}(t,e,Ga(eh,$a,th))),t}),_containerPointToPoint:function(t,e,i){var n=this._getResolution(e);return this._containerPointToPointAtRes(t,n,i)},_containerPointToPointAtRes:(Ja=[0,0,0],Qa=[0,0,0,1],Ka=[0,0,0,1],function(t,e,i){if(this.isTransforming()){var n=this.width/2||1,r=this.height/2||1;ja(Ja,(t.x-n)/n,(r-t.y)/r,0),ja(Qa,Ja[0],Ja[1],0),ja(Ka,Ja[0],Ja[1],1),Qa[3]=Ka[3]=1,qa(Qa,Qa,this.projViewMatrixInverse),qa(Ka,Ka,this.projViewMatrixInverse);var o=Qa[0],s=Ka[0],a=Qa[1],h=Ka[1],l=Qa[2],c=Ka[2],u=l===c?0:(0-l)/(c-l),d=Qt(o,s,u),p=Qt(a,h,u);return i?(i.x=d,i.y=p):i=new Bt(d,p),i._multi(1/this._glScale),this._getResolution()===e?i:this._pointToPointAtRes(i,e,i)}var f=this._prjToPointAtRes(this._getPrjCenter(),e,i),m=this._getResolution()/e,g=m*(t.x-this.width/2),v=m*(t.y-this.height/2);return f._add(g,-v)}),_calcMatrices:(Ya=oh(),function(){delete this._mapRes,delete this._mapGlRes,delete this._mapExtent2D,delete this._mapGlExtent2D;var t=this.getSize(),e=t.width||1,i=t.height||1;this._glScale=this.getGLScale();var n=this._getCameraWorldMatrix(),r=this.getFov()*Math.PI/180,o=this._getCameraFar(r,this.getPitch());this.cameraFar=o,this.cameraNear=this.cameraCenterDistance/20;var s=this.projMatrix||oh();Ia(s,r,e/i,this.cameraNear,o),this.projMatrix=s,this.viewMatrix=Ba(this.viewMatrix||oh(),n),this.projViewMatrix=Fa(this.projViewMatrix||oh(),s,this.viewMatrix),this._calcCascadeMatrixes(),this.projViewMatrixInverse=Fa(this.projViewMatrixInverse||oh(),n,Ba(Ya,s)),this.domCssMatrix=this._calcDomMatrix(),this._frustumAltitude=this._calcFrustumAltitude(),this._mapRes=this._getResolution(),this._mapGlRes=this.getGLRes(),this._mapExtent2D=this._get2DExtent(),this._mapGlExtent2D=this._get2DExtentAtRes(this._mapGlRes)}),_getCameraFar:function(t,e){var i=this.cameraCenterDistance=Za(this.cameraPosition,this.cameraLookAt),n=i,r=(this.options.cameraInfiniteFar?10:4)*i;if(e>0&&(e=e*Math.PI/180,2/Math.PI-e>t/2)){var o=Math.tan(t/2),s=Math.tan(e);r=Math.max(i*o/(1/s-o),r)}return(n+=r)+1},_calcCascadeMatrixes:function(){var t=oh();function e(e,i,n){var r=this.width,o=this.height,s=this.getFov()*Math.PI/180,a=this._getCameraFar(s,i),h=this.cameraCenterDistance;a=h+(a-h)/Math.cos((90-i)*Math.PI/180)*Math.cos((90-e)*Math.PI/180),Ia(t,s,r/o,.1,a);var l=this.viewMatrix;return Fa(n,t,l)}return function(){var t=this.getPitch(),i=this.options.cascadePitches[0],n=this.options.cascadePitches[1],r=this.cascadeFrustumMatrix0=this.cascadeFrustumMatrix0||oh(),o=this.cascadeFrustumMatrix1=this.cascadeFrustumMatrix1||oh();t>i?e.call(this,t,i,r):Ha(this.cascadeFrustumMatrix0,this.projViewMatrix),t>n?e.call(this,t,n,o):Ha(this.cascadeFrustumMatrix1,this.cascadeFrustumMatrix0)}}(),_calcDomMatrix:function(){var t=oh(),e=oh(),i=[1,-1,1],n=[0,0,0];return function(){var r=this.width||1,o=this.height||1,s=.5/Math.tan(this._fov/2)*o;return za(t,this.projMatrix,i),ka(t,t,ja(n,0,0,-s)),this._pitch&&function(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[4],s=e[5],a=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11];e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*r+l*n,t[5]=s*r+c*n,t[6]=a*r+u*n,t[7]=h*r+d*n,t[8]=l*r-o*n,t[9]=c*r-s*n,t[10]=u*r-a*n,t[11]=d*r-h*n}(t,t,this._pitch),this._angle&&function(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],s=e[1],a=e[2],h=e[3],l=e[4],c=e[5],u=e[6],d=e[7];e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r+l*n,t[1]=s*r+c*n,t[2]=a*r+u*n,t[3]=h*r+d*n,t[4]=l*r-o*n,t[5]=c*r-s*n,t[6]=u*r-a*n,t[7]=d*r-h*n}(t,t,this._angle),Na(e),za(e,e,ja(n,r/2,-o/2,1)),Fa(this.domCssMatrix||oh(),e,t)}}(),_getFovZ:function(t){var e=this.getGLScale(t),i=this._getFovRatio();return e*(this.height||1)/2/i},_getCameraWorldMatrix:(Xa={},function(){var t=this.getGLRes(),e=this._prjToPointAtRes(this._prjCenter,t);this.cameraLookAt=ja(this.cameraLookAt||[0,0,0],e.x,e.y,0);var i=this.getPitch()*nh,n=this.getBearing()*nh,r=this._getFovZ(),o=r*Math.cos(i),s=Math.sin(i)*r,a=e.x-s*Math.sin(n),h=e.y-s*Math.cos(n);this.cameraPosition=ja(this.cameraPosition||[0,0,0],a,h,o),this.cameraToCenterDistance=Za(this.cameraPosition,this.cameraLookAt);var l=s||1,c=this.cameraUp=ja(this.cameraUp||[0,0,0],Math.sin(n)*l,Math.cos(n)*l,0),u=this.cameraWorldMatrix=this.cameraWorldMatrix||oh();!function(t,e,i,n){var r=[0,0,0],o=[0,0,0],s=[0,0,0];Ga(s,e,i),0===Ua(s)&&(s[2]=1),Va(s,s),Wa(r,n,s),0===Ua(s)&&(1===Math.abs(n[2])?s[0]+=1e-4:s[2]+=1e-4,Va(s,s),Wa(r,n,s)),Va(r,r),Wa(o,s,r),t[0]=r[0],t[4]=o[0],t[8]=s[0],t[1]=r[1],t[5]=o[1],t[9]=s[1],t[2]=r[2],t[6]=o[2],t[10]=s[2]}(u,this.cameraPosition,this.cameraLookAt,c);var d,p,f,m=this.cameraForward||[0,0,0];return Ga(m,this.cameraLookAt,this.cameraPosition),this.cameraForward=Va(m,m),function(t,e){var i,n=e[0],r=e[4],o=e[8],s=e[1],a=e[5],h=e[9],l=e[2],c=e[6],u=e[10],d=n+a+u;d>0?(i=.5/Math.sqrt(d+1),t.w=.25/i,t.x=(c-h)*i,t.y=(o-l)*i,t.z=(s-r)*i):n>a&&n>u?(i=2*Math.sqrt(1+n-a-u),t.w=(c-h)/i,t.x=.25*i,t.y=(r+s)/i,t.z=(o+l)/i):a>u?(i=2*Math.sqrt(1+a-n-u),t.w=(o-l)/i,t.x=(r+s)/i,t.y=.25*i,t.z=(h+c)/i):(i=2*Math.sqrt(1+u-n-a),t.w=(s-r)/i,t.x=(o+l)/i,t.y=(h+c)/i,t.z=.25*i)}(Xa,u),function(t,e){var i=t,n=e.x,r=e.y,o=e.z,s=e.w,a=n+n,h=r+r,l=o+o,c=n*a,u=n*h,d=n*l,p=r*h,f=r*l,m=o*l,g=s*a,v=s*h,y=s*l;i[0]=1-(p+m),i[4]=u-y,i[8]=d+v,i[1]=u+y,i[5]=1-(c+m),i[9]=f-g,i[2]=d-v,i[6]=f+g,i[10]=1-(c+p),i[3]=0,i[7]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1}(u,Xa),d=u,p=this.cameraPosition,(f=d)[12]=p[0],f[13]=p[1],f[14]=p[2],u}),_getFovRatio:function(){var t=this.getFov();return Math.tan(t/2*nh)},_renderLayers:function(){this.isInteracting()||this._getLayers().forEach((function(t){if(t){var e=t._getRenderer();e&&e.setToRedraw&&e.setToRedraw()}}))}}),Ss.include({_onViewChange:function(t){this._viewHistory||(this._viewHistory=[],this._viewHistoryPointer=0);for(var e=this._getCurrentView(),i=this._viewHistory.length-1;i>=0;i--)if(ue(t,this._viewHistory[i]))return this._viewHistoryPointer=i,void this._fireViewChange(e,t);this._viewHistoryPointer<this._viewHistory.length-1&&this._viewHistory.splice(this._viewHistoryPointer+1),this._viewHistory.push(t);var n=this.options.viewHistoryCount;n>0&&this._viewHistory.length>n&&this._viewHistory.splice(0,this._viewHistory.length-n),this._viewHistoryPointer=this._viewHistory.length-1,this._fireViewChange(e,t)},zoomToPreviousView:function(t){if(void 0===t&&(t={}),!this.hasPreviousView())return null;var e=this._viewHistory[--this._viewHistoryPointer];return this._zoomToView(e,t),e},hasPreviousView:function(){return!(!this._viewHistory||0===this._viewHistoryPointer)},zoomToNextView:function(t){if(void 0===t&&(t={}),!this.hasNextView())return null;var e=this._viewHistory[++this._viewHistoryPointer];return this._zoomToView(e,t),e},hasNextView:function(){return!(!this._viewHistory||this._viewHistoryPointer===this._viewHistory.length-1)},_zoomToView:function(t,e){var i=this,n=this.getView();e.animation?this._animateTo(t,{duration:e.duration},(function(e){"finished"===e.state.playState&&i._fireViewChange(n,t)})):(this.setView(t),this._fireViewChange(n,t))},getViewHistory:function(){return this._viewHistory},_fireViewChange:function(t,e){this._fireEvent("viewchange",{old:t,new:e}),this._insertUICollidesQueue()},_getCurrentView:function(){return this._viewHistory?this._viewHistory[this._viewHistoryPointer]:null}}),Ss.mergeOptions({viewHistory:!0,viewHistoryCount:10});var sh=new In;Ss.include({getCollisionIndex:function(){return this._collisionIndex||this.createCollisionIndex(),this._collisionIndex||this.createCollisionIndex()},createCollisionIndex:function(){return this.clearCollisionIndex(),this._collisionIndex=new In,this._collisionIndex},clearCollisionIndex:function(){return this.collisionFrameTime=0,this._collisionIndex&&this._collisionIndex.clear(),this},_insertUICollidesQueue:function(){return this._uiCollidesQueue||(this._uiCollidesQueue=[]),this._uiCollidesQueue.push(1),this},uiCollides:function(){if(!this.uiList||0===this.uiList.length||!this._uiCollidesQueue||0===this._uiCollidesQueue.length)return this;var t=sh;t.clear();for(var e=this.uiList,i=0,n=e.length;i<n;i++){var r=e[i],o=r.options,s=o.collisionBufferSize;if(o.collision){var a=r.getDOM();if(r.isVisible()&&a&&a.getBoundingClientRect){r.bbox||(r.bbox=[0,0,0,0]);var h=a.getBoundingClientRect(),l=h.x,c=h.y,u=l-s,d=l+h.width+s,p=c-s,f=c+h.height+s;r.bbox[0]=u,r.bbox[1]=p,r.bbox[2]=d,r.bbox[3]=f,t.collides(r.bbox)?r._collidesEffect(!1):(t.insertBox(r.bbox),r._collidesEffect(!0))}}}return this._uiCollidesQueue=[],this},_addUI:function(t){return this.uiList||(this.uiList=[]),this.uiList.indexOf(t)>-1||(this.uiList.push(t),this.uiList=this.uiList.sort((function(t,e){return e.options.collisionWeight-t.options.collisionWeight}))),this},_removeUI:function(t){if(!this.uiList)return-1;var e=this.uiList.indexOf(t);return e<0||this.uiList.splice(e,1),e}});var ah=function(t){function e(e){var i;return(i=t.call(this,e)||this).on("enable",i._afterEnable,It(It(i))).on("disable",i._afterDisable,It(It(i))),i._measureLayers=[],i}Dt(e,t);var i=e.prototype;return i.clear=function(){if(te(this._measureLayers))for(var t=0;t<this._measureLayers.length;t++)this._measureLayers[t].remove();return delete this._lastMeasure,delete this._lastVertex,this._measureLayers=[],this},i.getMeasureLayers=function(){return this._measureLayers},i.getLastMeasure=function(){return this._lastMeasure?this._lastMeasure:0},i.undo=function(){t.prototype.undo.call(this);var e=this._historyPointer;if(e!==this._vertexes.length)for(var i=e;i<this._vertexes.length;i++)this._vertexes[i].label&&this._vertexes[i].label.remove(),this._vertexes[i].marker.remove();return this},i.redo=function(){t.prototype.redo.call(this);var e=this._historyPointer-1;return this._vertexes[e]&&(this._vertexes[e].marker.getLayer()||(this._vertexes[e].label&&this._vertexes[e].label.addTo(this._measureMarkerLayer),this._vertexes[e].marker.addTo(this._measureMarkerLayer))),this},i._measure=function(t){var e,i,n=this.getMap();t instanceof os?e=n.computeGeometryLength(t):Array.isArray(t)&&(e=n.getProjection().measureLength(t)),this._lastMeasure=e,i="zh-CN"===this.options.language?[" 米"," 公里"," 英尺"," 英里"]:[" m"," km"," feet"," mile"];var r="";return this.options.metric&&(r+=e<1e3?e.toFixed(0)+i[0]:(e/1e3).toFixed(2)+i[1]),this.options.imperial&&(e*=3.2808399,r.length>0&&(r+="\n"),r+=e<5280?e.toFixed(0)+i[2]:(e/5280).toFixed(2)+i[3]),r},i._registerMeasureEvents=function(){this.on("drawstart",this._msOnDrawStart,this).on("drawvertex",this._msOnDrawVertex,this).on("mousemove",this._msOnMouseMove,this).on("drawend",this._msOnDrawEnd,this)},i._afterEnable=function(){this._registerMeasureEvents()},i._afterDisable=function(){this.off("drawstart",this._msOnDrawStart,this).off("drawvertex",this._msOnDrawVertex,this).off("mousemove",this._msOnMouseMove,this).off("drawend",this._msOnDrawEnd,this)},i._msOnDrawStart=function(t){var e=this.getMap(),i=e._pointToPrj(t.point2d),n=Gt(),r="distancetool_"+n,o="distancetool_markers_"+n;e.getLayer(r)?(this._measureLineLayer=e.getLayer(r),this._measureMarkerLayer=e.getLayer(o)):(this._measureLineLayer=new Sa(r).addTo(e),this._measureMarkerLayer=new Sa(o).addTo(e)),this._measureLayers.push(this._measureLineLayer),this._measureLayers.push(this._measureMarkerLayer);var s=new Vs(t.coordinate,{symbol:this.options.vertexSymbol});s._setPrjCoordinates(i);var a="zh-CN"===this.options.language?"起点":"start",h=new ma(a,t.coordinate,this.options.labelOptions);h._setPrjCoordinates(i),this._lastVertex=h,this._addVertexMarker(s,h)},i._msOnMouseMove=function(t){var e=this._measure(this._msGetCoordsToMeasure(t));if(!this._tailMarker){var i=Ci(this.options.vertexSymbol);i.markerWidth/=2,i.markerHeight/=2,this._tailMarker=new Vs(t.coordinate,{symbol:i}).addTo(this._measureMarkerLayer),this._tailLabel=new ma(e,t.coordinate,this.options.labelOptions).addTo(this._measureMarkerLayer)}var n=this._geometry._getPrjCoordinates(),r=n[n.length-1];this._tailMarker.setCoordinates(t.coordinate),this._tailMarker._setPrjCoordinates(r),this._tailLabel.setContent(e),this._tailLabel.setCoordinates(t.coordinate),this._tailLabel._setPrjCoordinates(r)},i._msGetCoordsToMeasure=function(t){return t.geometry.getCoordinates().concat([t.coordinate])},i._msOnDrawVertex=function(t){var e=this._geometry._getPrjCoordinates(),i=e[e.length-1],n=t.geometry,r=new Vs(t.coordinate,{symbol:this.options.vertexSymbol}),o=this._measure(n),s=new ma(o,t.coordinate,this.options.labelOptions);this._addVertexMarker(r,s),s._setPrjCoordinates(i),r._setPrjCoordinates(i),this._lastVertex=s},i._addVertexMarker=function(t,e){this._vertexes||(this._vertexes=[]),void 0!==this._historyPointer&&this._vertexes.length>this._historyPointer-1&&(this._vertexes.length=this._historyPointer-1),this._vertexes.push({label:e,marker:t}),this._measureMarkerLayer.addGeometry(t),e&&this._measureMarkerLayer.addGeometry(e)},i._msOnDrawEnd=function(t){if(this._clearTailMarker(),t.geometry._getPrjCoordinates().length<2)return this._lastMeasure=0,void this._clearMeasureLayers();var e=this._lastVertex.getSize();e||(e=new si(10,10)),this._addClearMarker(this._lastVertex.getCoordinates(),this._lastVertex._getPrjCoordinates(),e.width);var i=t.geometry.copy();i._setPrjCoordinates(t.geometry._getPrjCoordinates()),i.addTo(this._measureLineLayer),this._lastMeasure=i.getLength()},i._addClearMarker=function(t,e,i){var n=this.options.clearButtonSymbol,r={markerDx:(n.markerDx||0)+i,textDx:(n.textDx||0)+i};Array.isArray(n)&&(r=n.map((function(t){return t?{markerDx:(t.markerDx||0)+i,textDx:(t.textDx||0)+i}:null}))),n=Ci(n,r);var o=new Vs(t,{symbol:n}),s=this._measureLineLayer,a=this._measureMarkerLayer;o.on("click",(function(){return s.remove(),a.remove(),!1}),this),o.addTo(this._measureMarkerLayer),o._setPrjCoordinates(e)},i._clearTailMarker=function(){this._tailMarker&&(this._tailMarker.remove(),delete this._tailMarker),this._tailLabel&&(this._tailLabel.remove(),delete this._tailLabel)},i._clearMeasureLayers=function(){this._measureLineLayer.remove(),this._measureMarkerLayer.remove()},e}(Pa);ah.mergeOptions({mode:"LineString",language:"zh-CN",metric:!0,imperial:!1,symbol:{lineColor:"#000",lineWidth:3,lineOpacity:1},vertexSymbol:{markerType:"ellipse",markerFill:"#fff",markerLineColor:"#000",markerLineWidth:3,markerWidth:11,markerHeight:11},labelOptions:{textSymbol:{textFaceName:"monospace",textLineSpacing:1,textHorizontalAlignment:"right",textDx:15},boxStyle:{padding:[6,2],symbol:{markerType:"square",markerFill:"#fff",markerFillOpacity:.9,markerLineColor:"#b4b3b3"}}},clearButtonSymbol:[{markerType:"square",markerFill:"#fff",markerLineColor:"#b4b3b3",markerLineWidth:2,markerWidth:15,markerHeight:15,markerDx:20},{markerType:"x",markerWidth:10,markerHeight:10,markerDx:20}]});var hh=function(t){function e(e){var i;return(i=t.call(this,e)||this)._measureLayers=[],i}Dt(e,t);var i=e.prototype;return i._measure=function(t){var e,i,n=this.getMap();t instanceof os?e=n.computeGeometryArea(t):Array.isArray(t)&&(e=n.getProjection().measureArea(t)),this._lastMeasure=e,i="zh-CN"===this.options.language?[" 平方米"," 平方公里"," 平方英尺"," 平方英里"]:[" sq.m"," sq.km"," sq.ft"," sq.mi"];var r="";if(this.options.metric&&(r+=e<1e6?e.toFixed(0)+i[0]:(e/1e6).toFixed(2)+i[1]),this.options.imperial){e*=3.2808399,r.length>0&&(r+="\n");var o=27878400;r+=e<o?e.toFixed(0)+i[2]:(e/o).toFixed(2)+i[3]}return r},i._msGetCoordsToMeasure=function(t){return t.geometry.getShell().concat([t.coordinate])},i._msOnDrawVertex=function(t){var e=this.getMap()._pointToPrj(t.point2d),i=new Vs(t.coordinate,{symbol:this.options.vertexSymbol});i._setPrjCoordinates(e),this._measure(t.geometry),this._lastVertex=i,this._addVertexMarker(i)},i._msOnDrawEnd=function(t){var e;if(this._clearTailMarker(),t.point2d)e=this.getMap()._pointToPrj(t.point2d);else{var i=t.geometry._getPrjCoordinates();i=i.slice(0,i.length-1),t.geometry._setPrjCoordinates(i),e=i[i.length-1]}if(t.geometry._getPrjCoordinates().length<3)return this._lastMeasure=0,void this._clearMeasureLayers();var n=this._measure(t.geometry),r=this.getMap().getProjection().unproject(e),o=new ma(n,r,this.options.labelOptions).addTo(this._measureMarkerLayer);o._setPrjCoordinates(e);var s=o.getSize();s||(s=new si(10,10)),this._addClearMarker(r,e,s.width);var a=t.geometry.copy();a._setPrjCoordinates(t.geometry._getPrjCoordinates()),a.addTo(this._measureLineLayer),this._lastMeasure=a.getArea()},e}(ah);hh.mergeOptions({mode:"Polygon",symbol:{lineColor:"#000000",lineWidth:2,lineOpacity:1,lineDasharray:"",polygonFill:"#ffffff",polygonOpacity:.5}});var lh={create:function(t,e){var i=t.unproject(e[0]),n=new na(i,0);return n._setPrjCoordinates(e[0]),n},update:function(t,e,i){var n=i.getMap(),r=Array.isArray(e)?e[e.length-1]:e,o=t.unproject(r),s=n.computeLength(i.getCenter(),o);i.setRadius(s)},generate:function(t){return t}};Pa.registerMode("circle",N({clickLimit:2,action:["click","mousemove","click"]},lh)),Pa.registerMode("freeHandCircle",N({action:["mousedown touchstart","mousemove touchmove","mouseup touchend"]},lh));var ch={create:function(t,e){var i=t.unproject(e[0]),n=new ra(i,0,0);return n._setPrjCoordinates(e[0]),n},update:function(t,e,i){var n=i.getMap(),r=i.getCenter(),o=Array.isArray(e)?e[e.length-1]:e,s=t.unproject(o),a=n.computeLength(r,new Hn({x:s.x,y:r.y})),h=n.computeLength(r,new Hn({x:r.x,y:s.y}));i.setWidth(2*a),i.setHeight(2*h)},generate:function(t){return t}};Pa.registerMode("ellipse",N({clickLimit:2,action:["click","mousemove","click"]},ch)),Pa.registerMode("freeHandEllipse",N({action:["mousedown touchstart","mousemove touchmove","mouseup touchend"]},ch));var uh={create:function(t,e){var i=new js([]);return i._firstClick=e[0],i},update:function(t,e,i,n){var r=i.getMap(),o=n.containerPoint,s=r._prjToContainerPoint(i._firstClick),a=[[s.x,s.y],[o.x,s.y],[o.x,o.y],[s.x,o.y]];i.setCoordinates(a.map((function(t){return r.containerPointToCoord(new Bt(t))}))),i._setPrjCoordinates(a.map((function(t){return r._containerPointToPrj(new Bt(t))})))},generate:function(t){return t}};Pa.registerMode("rectangle",N({clickLimit:2,action:["click","mousemove","click"]},uh)),Pa.registerMode("freeHandRectangle",N({action:["mousedown touchstart","mousemove touchmove","mouseup touchend"]},uh)),Pa.registerMode("point",{clickLimit:1,action:["click","mousemove"],create:function(t,e){var i=t.unproject(e[0]),n=new Vs(i);return n._setPrjCoordinates(e[0]),n},generate:function(t){return t},update:function(t,e,i){if(Array.isArray(e)&&(e=e[e.length-1]),!e)return i;var n=t.unproject(e);return i.setCoordinates(n),i}});var dh={create:function(t,e){var i=e.map((function(e){return t.unproject(e)})),n=new Zs(i);return n._setPrjCoordinates(e),n},update:function(t,e,i){var n,r=i.getSymbol();Array.isArray(e)?n=e:(n=i._getPrjCoordinates()).push(e);var o=n.map((function(e){return t.unproject(e)}));i.setCoordinates(o),i._setPrjCoordinates(n);var s=i.getLayer();if(s){var a=s.getGeometryById("polygon");if(!a&&n.length>=3){if(a=new js([o],{id:"polygon"}),r){var h=Ci(r,{lineOpacity:0});a.setSymbol(h)}a.addTo(s)}a&&a._setPrjCoordinates(n)}},generate:function(t){var e=new js(t.getCoordinates(),{symbol:t.getSymbol()});return e._setPrjCoordinates(t._getPrjCoordinates()),e._projCode=t._projCode,e}};Pa.registerMode("polygon",N({action:["click","mousemove","dblclick"]},dh)),Pa.registerMode("freeHandPolygon",N({action:["mousedown touchstart","mousemove touchmove","mouseup touchend"]},dh));var ph={create:function(t,e){var i=e.map((function(e){return t.unproject(e)})),n=new Zs(i);return n._setPrjCoordinates(e),n},update:function(t,e,i){var n;Array.isArray(e)?n=e:(n=i._getPrjCoordinates()).push(e);var r=n.map((function(e){return t.unproject(e)}));i.setCoordinates(r),i._setPrjCoordinates(n)},generate:function(t){return t}};function fh(t){for(var e=t.tileInfo,i=[e.cols,e.rows],n=[],r=e.lods,o=0,s=r.length;o<s;o++)n.push(r[o].resolution);var a=t.fullExtent,h=e.origin,l=[1,-1,h.x,h.y];return delete a.spatialReference,{spatialReference:{resolutions:n,fullExtent:a},tileSystem:l,tileSize:i}}function mh(t,e){return void 0===e&&(e=[]),e.forEach((function(e){var i=e[0],n=e[1];t=t.replace(i,n)})),t}function gh(t){var e=t.projection,i=t.isArcgis,n=t.isGeoServer,r=t.isSuperMap,o=.0002645833333333333;return(i||n||r)&&(o=28e-5),e&&e.indexOf("4326")>-1&&(o=2.3767925226029154e-9,(i||r)&&(o=2.518101729011901e-9),n&&(o=2.51528279553466e-9)),o}Pa.registerMode("linestring",N({action:["click","mousemove","dblclick"]},ph)),Pa.registerMode("freeHandLinestring",N({action:["mousedown touchstart","mousemove touchmove","mouseup touchend"]},ph)),Pa.registerMode("arccurve",{action:["click","mousemove","dblclick"],create:function(t,e){var i=e.map((function(e){return t.unproject(e)})),n=new ha(i);return n._setPrjCoordinates(e),n},update:ph.update,generate:function(t){return t}}),Pa.registerMode("quadbeziercurve",{action:["click","mousemove","dblclick"],create:function(t,e){var i=e.map((function(e){return t.unproject(e)})),n=new ca(i);return n._setPrjCoordinates(e),n},update:ph.update,generate:function(t){return t}}),Pa.registerMode("cubicbeziercurve",{action:["click","mousemove","dblclick"],create:function(t,e){var i=e.map((function(e){return t.unproject(e)})),n=new la(i);return n._setPrjCoordinates(e),n},update:ph.update,generate:function(t){return t}}),Pa.registerMode("boxZoom",{action:["mousedown","mousemove","mouseup"],create:function(t,e){e=e[0];var i=t.unproject(e),n=new Vs(i);return n._firstClick=e,n},update:function(t,e,i,n){var r=i.getMap(),o=r._prjToContainerPoint(i._firstClick),s=n.containerPoint;e=r._containerPointToPrj(new Hn(Math.min(o.x,s.x),Math.min(o.y,s.y)));var a=t.unproject(e);i.setCoordinates(a)._setPrjCoordinates(e),i.updateSymbol({markerWidth:Math.abs(o.x-s.x),markerHeight:Math.abs(o.y-s.y)})},generate:function(t){return t}}),es.loadArcgis=function(t,e,i){if(void 0===i&&(i={jsonp:!0}),V(t)&&"{"!==t.substring(0,1))gn.getJSON(t,(function(t,i){if(t)e(t);else{var n=fh(i);e(null,n)}}),i);else{V(t)&&(t=Vt(t));var n=fh(t);e(null,n)}return this};var vh="wmts";function yh(t,e){var i=t.getElementsByTagName(e);if(i&&i.length)return i;var n=vh+":"+e;return t.getElementsByTagName(n)}function _h(t,e){for(var i=0;i<t.length;i++){var n=t[i];if((n=n.getElementsByTagName("ows:Identifier")[0])&&n.textContent===e)return t[i]}return null}function xh(t,e){void 0===e&&(e={});var i,n,r,o=yh(t,"TileMatrix"),s=[],a=[],h=[],l=!1;if(!i){var c=t.getElementsByTagName("ows:SupportedCRS")[0];c&&(i=function(t){for(var e="",i=t.split(""),n=i.length-1;n>=0&&!isNaN(i[n]);n--)e=i[n]+e;return e}(i=(i=c.textContent).split("EPSG")[1]),i=function(t){var e=t.indexOf("EPSG")>-1?t:"EPSG:"+t;return mh(e,[["4490","4326"],["102100","3857"],["900913","3857"]])}(i))}n||(n=t.getElementsByTagName("ows:Identifier")[0])&&(n=n.textContent),e.projection=i;for(var u=1/0,d=0;d<o.length;d++){var p=o[d],f=p.getElementsByTagName("ows:Identifier")[0].textContent;isNaN(parseInt(f))?(r=f.substr(0,f.lastIndexOf(":")),f=(f=f.split(":"))[f.length-1],f=parseInt(f),l=!0,e.isGeoServer=!0):f=parseInt(f),u=Math.min(u,f);var m=yh(p,"ScaleDenominator")[0].textContent,g=yh(p,"TopLeftCorner")[0].textContent,v=yh(p,"TileWidth")[0].textContent,y=yh(p,"TileHeight")[0].textContent;if(0===h.length&&h.push(parseInt(v),parseInt(y)),0===a.length){var _=g.split(" ").filter((function(t){return""!==t})).map((function(t){return parseFloat(t)})),x=_[0],w=_[1];x>0?a.push(1,-1,w,x):a.push(1,-1,x,w)}var b=gh(e),M=parseFloat(m)*b;s.push(M)}if(u>0)for(var S=s[0],T=u-1;T>=0;T--)S*=2,s.splice(0,0,S);return{resolutions:s,tileSize:h,tileSystem:a,projection:i,TileMatrixSet:n,isGeoServer:l,levelStr:r}}es.loadWMTS=function(t,e,i){return void 0===i&&(i={jsonp:!0}),V(t)&&gn.get(t,(function(n,r){if(n)e(n);else{var o=function(t,e,i){null==i.isArcgis&&(i.isArcgis=t.indexOf("arcgis")>-1),null==i.isSuperMap&&(i.isSuperMap=t.indexOf("supermap")>-1);var n=(new DOMParser).parseFromString(t,"text/xml").querySelectorAll("Contents")[0];if(!n)return[];var r=yh(n,"Layer");if(!r.length)return[];for(var o=[],s=0,a=n.childNodes.length;s<a;s++)"TileMatrixSet"===n.childNodes[s].localName&&o.push(n.childNodes[s]);if(!o.length)return[];for(var h=[],l=0,c=r.length;l<c;l++){var u=r[l],d=u.querySelectorAll("Style")[0];d&&(d=d.getElementsByTagName("ows:Identifier")[0])&&(d=d.textContent);var p=u.getElementsByTagName("ows:Identifier")[0];p&&(p=p.textContent);var f=yh(u,"TileMatrixSetLink");if(0!==f.length)for(var m=0,g=f.length;m<g;m++){var v=f[m];(v=yh(v,"TileMatrixSet")[0])&&(v=v.textContent);var y=_h(o,v);if(y){var _=u.querySelectorAll("ResourceURL")[0],x="";_&&(x=_.attributes.template.value);var w=xh(y,i),b=w.resolutions,M=w.tileSize,S=w.tileSystem,T=w.projection,E=w.TileMatrixSet,C=w.isGeoServer,P=w.levelStr;x.length||(x=e.substr(0,e.lastIndexOf("?")),x+="?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER={LAYER}&STYLE={Style}&TILEMATRIXSET={TileMatrixSet}&FORMAT={tiles}&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}");var A=mh(x,[["{LAYER}",p],["{Layer}",p],["{layer}",p],["{STYLE}",d],["{Style}",d],["{style}",d],["{TileMatrixSet}",E],["{TileMatrix}",C?P+":{z}":"{z}"],["{TileRow}","{y}"],["{TileCol}","{x}"],["{tiles}",C?"image/png":"tiles"]]);h.push({tileSize:M,tileSystem:S,spatialReference:{resolutions:b,projection:T},urlTemplate:A,info:{layerName:p,TileMatrixSet:E,style:d,tileSize:M,tileSystem:S,resolutions:b,projection:T,urlTemplate:A}})}}}return h}(r,t,i);e(null,o)}}),i),this};var wh=function(t){function e(e){var i;return(i=t.call(this,e)||this).proxyOptions(),i}Dt(e,t);var i=e.prototype;return i.addTo=function(t){return this._owner=t,this._switchEvents("on"),this.onAdd&&this.onAdd(),this.fire("add"),this},i.getMap=function(){return this._owner?this._owner.getBaseLayer?this._owner:this._owner.getMap():null},i._collides=function(){var t=this.getMap();return t?(t._addUI(this),t._insertUICollidesQueue(),this):this},i._collidesEffect=function(t){var e=this.getDOM();if(!e)return this;var i=t?"visible":"hidden";if(e.style.visibility=i,!e.classList||!e.classList.add)return this;if(!this.options.collisionFadeIn)return this;var n="mtk-ui-fadein",r=e.classList.contains(n);return t&&!r?e.classList.add(n):!t&&r&&e.classList.remove(n),this},i.show=function(t){var e=this.getMap();if(!e)return this;this.options.visible=!0,t=t||this._coordinate||this._owner.getCenter();var i=this.isVisible();this._showBySymbolChange||this.fire("showstart");var n=this._getUIContainer();this._coordinate=t,this._removePrevDOM(),this._mapEventsOn||this._switchMapEvents("on");var r=this.__uiDOM=this.buildOn(e);if(r.eventsPropagation=this.options.eventsPropagation,this._observerDomSize(r),!r)return this._showBySymbolChange||this.fire("showend"),this._collides(),this;this._measureSize(r),this._singleton()&&(r._uiComponent=this,e[this._uiDomKey()]=r),this._setPosition(),r.style[Bi]=null,n.appendChild(r);var o=this._getAnimation();if(i&&(o.ok=!1),o.ok&&(o.fade&&(r.style.opacity=0),o.scale)){if(this.getTransformOrigin){var s=this.getTransformOrigin();r.style[Fi]=s}r.style[zi]=this._toCSSTranslate(this._pos)+" scale(0)"}this.isSupportZoomFilter()||(r.style.display=""),this.options.eventsToStop&&ln(r,this.options.eventsToStop,qi),this.options.autoPan&&this._autoPan();var a=o.transition;return o.ok&&a&&(r.offsetHeight,a&&(r.style[Bi]=a),o.fade&&(r.style.opacity=1),o.scale&&(r.style[zi]=this._toCSSTranslate(this._pos)+" scale(1)")),this._showBySymbolChange||this.fire("showend"),this._collides(),this},i.hide=function(){var t=this;if(!this.getDOM())return this;this._onDomMouseout&&this._onDomMouseout(),this.options.visible=!1;var e=this._getAnimation(),i=this.getDOM();return this.options.animationOnHide||(e.ok=!1),e.ok?(i.offsetHeight,i.style[Bi]=e.transition,setTimeout((function(){i.style.display="none",t.fire("hide")}),this.options.animationDuration)):(i.style.display="none",this.fire("hide")),e.fade&&(i.style.opacity=0),e.scale&&(i.style[zi]=this._toCSSTranslate(this._pos)+" scale(0)"),this._switchMapEvents("off"),this._collides(),this},i.isVisible=function(){if(!this.options.visible)return!1;var t=this.getDOM();return this.getMap()&&t&&t.parentNode&&"none"!==t.style.display},i.remove=function(){if(delete this._mapEventsOn,!this._owner)return this;var t=this.getMap();return t&&t._removeUI(this),this.hide(),this._switchEvents("off"),this.onRemove&&this.onRemove(),!this._singleton()&&this.__uiDOM&&this._removePrevDOM(),delete this._owner,this.fire("remove"),this._collides(),this},i.getSize=function(){return this._domContentRect&&this._size&&(this._size.width=this._domContentRect.width,this._size.height=this._domContentRect.height),this._size?this._size.copy():null},i.getOwner=function(){return this._owner},i.getDOM=function(){return this.__uiDOM},i._roundPoint=function(t){return this.options.roundPoint&&(t=t._round()),t},i.getPosition=function(){if(!this.getMap())return null;var t=this._roundPoint(this._getViewPoint());if(this.getOffset){var e=this._roundPoint(this.getOffset());e&&t._add(e)}return t},i._getAnimation=function(){for(var t={fade:!1,scale:!1},e=this.options.animation?this.options.animation.split(","):[],i=0;i<e.length;i++){var n=ai(e[i]);"fade"===n?t.fade=!0:"scale"===n&&(t.scale=!0)}var r=null;return t.fade&&(r="opacity "+this.options.animationDuration+"ms"),t.scale&&(r=r?r+",":"",r+=zi+" "+this.options.animationDuration+"ms"),t.transition=r,t.ok=null!==r,t},i._getViewPoint=function(){var t=0,e=this._coordinate||{};j(e.z)?t=e.z:this._owner&&this._owner.getAltitude&&(t=this._owner.getAltitude()||0);var i=this._meterToPoint(this._coordinate,t);return this.getMap().coordToViewPoint(this._coordinate,void 0,i)._add(this.options.dx,this.options.dy)},i._meterToPoint=function(t,e){var i=this.getMap();return i.altitudeToPoint(e,i._getResolution())*Yt(e)},i._autoPan=function(){var t=this.getMap(),e=this.getDOM();if(!t.isMoving()){var i=this._getViewPoint()._round(),n=t.width,r=t.height,o=t.viewPointToContainerPoint(i),s=this.getOffset(),a=o.add(s),h=t._viewPointToPrj(i),l=parseInt(e.clientWidth),c=parseInt(e.clientHeight),u=0,d=0;if(a.x<0?u=50-a.x:a.x+l>n&&(u=-(a.x+l-n)-50),a.y-c<0?d=Math.abs(a.y-c)+50:a.y+c>r&&(d=r-(a.y+c)-50),l>=n&&(u=n/2-o.x),0!==d||0!==u){var p=o.add(u,d),f=t._containerPointToPoint(p)._sub(t._prjToPoint(t._getPrjCenter())),m=t._pointToPrj(t._prjToPoint(h).sub(f));t._panAnimation(m)}}},i._measureSize=function(t){var e=this._getUIContainer();t.style.position="absolute";var i=t.style.bottom?"bottom":"top";if(t.style.display="",e.appendChild(t),t.getBoundingClientRect){var n=t.getBoundingClientRect();this._size=new si(n.width,n.height)}else this._size=new si(t.clientWidth,t.clientHeight);return t.style.display="none",t.style.left="0px",t.style[i]="0px",this._size},i._removePrevDOM=function(){this.onDomRemove&&this.onDomRemove();var t=this.options.eventsToStop;if(this._singleton()){var e=this.getMap(),i=this._uiDomKey();if(e[i]){t&&cn(e[i],t,qi);var n=e[i]._uiComponent;n&&n!==this&&n.isVisible()&&n.fire("hide"),Gi(e[i]),n&&!this.hideDom&&n._switchMapEvents("off"),delete e[i]}delete this.__uiDOM}else this.__uiDOM&&(t&&cn(this.__uiDOM,t,qi),Gi(this.__uiDOM),delete this.__uiDOM);this._resizeObserver&&(this._resizeObserver.disconnect(),delete this._resizeObserver,delete this._domContentRect)},i._uiDomKey=function(){return"__ui_"+this._getClassName()},i._singleton=function(){return this.options.single},i._getUIContainer=function(){return this.getMap()._panels.ui},i._getClassName=function(){return"UIComponent"},i._switchMapEvents=function(t){var e=this.getMap();if(e){this._mapEventsOn="on"===t;var i=this._getDefaultEvents();if(this.getEvents&&N(i,this.getEvents()),i)for(var n in i)i.hasOwnProperty(n)&&e[t](n,i[n],this)}},i._switchEvents=function(t){var e=this._getOwnerEvents();if(this._owner)for(var i in e)e.hasOwnProperty(i)&&this._owner[t](i,e[i],this)},i._getDefaultEvents=function(){return{"zooming rotate pitch":this.onEvent,zoomend:this.onZoomEnd,moving:this.onMoving,moveend:this.onMoving,resize:this.onResize}},i._getOwnerEvents=function(){var t={};return this._owner&&this._owner instanceof os&&(t.positionchange=this.onGeometryPositionChange,t.symbolchange=this._updatePosition),this.getOwnerEvents&&N(t,this.getOwnerEvents()),t},i.onGeometryPositionChange=function(t){this._owner&&this.isVisible()&&(this._showBySymbolChange=!0,this.show(t.target.getCenter()),delete this._showBySymbolChange)},i.onMoving=function(){this.isVisible()&&this.getMap().isTransforming()&&this._updatePosition()},i.onEvent=function(){this.isVisible()&&this._updatePosition()},i.onZoomEnd=function(){this.isVisible()&&this._setPosition()},i.onResize=function(){this.isVisible()&&this._setPosition()},i.onDomSizeChange=function(){this.isVisible()&&(this._setPosition(),this._collides())},i._updatePosition=function(){return this.getMap()?(this.getMap()._getRenderer().callInNextFrame(this._setPosition.bind(this)),this):this},i._setPosition=function(){var t=this.getDOM();if(t){t.style[Bi]=null;var e=this.getPosition();this._pos=e,t.style[zi]=this._toCSSTranslate(e)+" scale(1)"}},i._toCSSTranslate=function(t){if(!t)return"";if(Ot.any3d){var e=this.getMap(),i=e?e.getBearing():0,n=e?e.getPitch():0,r="";return this.options.pitchWithMap&&n&&(r+=" rotateX("+Math.round(n)+"deg)"),this.options.rotateWithMap&&i&&(r+=" rotateZ("+Math.round(-i)+"deg)"),"translate3d("+t.x+"px,"+t.y+"px, 0px)"+r}return"translate("+t.x+"px,"+t.y+"px)"},i._observerDomSize=function(t){var e=this;return t&&Ot.resizeObserver&&!this._resizeObserver?(this._resizeObserver=new ResizeObserver((function(t){if(t.length){var i=t[0].borderBoxSize;i&&i.length?e._domContentRect={width:i[0].inlineSize,height:i[0].blockSize}:e._domContentRect=t[0].contentRect}else delete e._domContentRect;e.onDomSizeChange&&e.onDomSizeChange()})),this._resizeObserver.observe(t),this):this},i.isSupportZoomFilter=function(){return!1},i.onConfig=function(){return this._updatePosition(),this},e.isSupport=function(t){return!!(t&&W(t.on)&&W(t.off)&&W(t.getCenter))},e}(Cn(Ln));wh.mergeOptions({eventsPropagation:!1,eventsToStop:null,dx:0,dy:0,autoPan:!1,autoPanDuration:600,single:!0,animation:"scale",animationOnHide:!1,animationDuration:500,pitchWithMap:!1,rotateWithMap:!1,visible:!0,roundPoint:!1,collision:!1,collisionBufferSize:2,collisionWeight:0,collisionFadeIn:!1});var bh="mousedown mouseup mouseenter mouseover mouseout mousemove click dblclick contextmenu keypress touchstart touchmove touchend",Mh=function(t){function e(e,i){var n;return(n=t.call(this,i)||this)._markerCoord=new Hn(e),n}Dt(e,t);var i=e.prototype;return i._getClassName=function(){return"UIMarker"},i.setCoordinates=function(t){return this._markerCoord=t,this.fire("positionchange"),this.isVisible()&&(this._coordinate=this._markerCoord,this._setPosition(),this._collides()),this},i.getCoordinates=function(){return this._markerCoord},i.getCenter=function(){return this.getCoordinates()},i.getAltitude=function(){var t=this.getCoordinates()||{};return j(t.z)?t.z:this.options.altitude||0},i.setAltitude=function(t){return j(t)&&this._markerCoord&&(this._markerCoord.z=t,this._updatePosition&&(this._updatePosition(),this._collides())),this},i.setContent=function(t){var e=this.options.content;return this.options.content=t,this.fire("contentchange",{old:e,new:t}),this.isVisible()&&this.show(),this},i.getContent=function(){return this.options.content},i.onAdd=function(){this.show()},i.show=function(){return t.prototype.show.call(this,this._markerCoord)},i.flash=function(t,e,i,n){return pe.call(this,t,e,i,n)},i.buildOn=function(){var t,e=this.options.content,i=V(e);return i||W(e)?(t=Hi("div"),i?t.innerHTML=this.options.content:e.bind(this)(t)):t=this.options.content,this.options.containerClass&&(t.className=this.options.containerClass),this._registerDOMEvents(t),t},i.getOffset=function(){var t=this.getSize(),e=-t.width/2,i=-t.height/2,n=this.options,r=n.horizontalAlignment,o=n.verticalAlignment;return"left"===r?e=-t.width:"right"===r&&(e=0),"top"===o?i=-t.height:"bottom"===o&&(i=0),new Bt(e,i)},i.getTransformOrigin=function(){return"center center"},i.onDomRemove=function(){var t=this.getDOM();this._removeDOMEvents(t)},i.isDragging=function(){return!!this.draggable&&this.draggable.isDragging()},i._registerDOMEvents=function(t){ln(t,bh,this._onDomEvents,this)},i._onDomEvents=function(t){var e=this.getMap()._parseEvent(t,t.type),i=t.type;if("mousedown"===i&&(this._mousedownEvent=t),"mouseup"===i&&(this._mouseupEvent=t),("click"!==i||!this._mouseClickPositionIsChange())&&("touchstart"===i&&(this._touchstartTime=B()),this.fire(t.type,e),"touchend"===i&&Ot.touch)){var n=this.getMap().options.clickTimeThreshold||280;B()-this._touchstartTime<n&&this._onDomEvents(N({},t,{type:"click"}))}},i._removeDOMEvents=function(t){cn(t,bh,this._onDomEvents)},i._mouseClickPositionIsChange=function(){var t=this._mousedownEvent||{},e=t.x,i=t.y,n=this._mouseupEvent||{},r=n.x,o=n.y;return e!==r||i!==o},i._getConnectPoints=function(){var t=this.getMap(),e=t.coordToContainerPoint(this.getCoordinates()),i=this.getSize(),n=i.width,r=i.height;return[t.containerPointToCoordinate(e.add(-n/2,0)),t.containerPointToCoordinate(e.add(n/2,0)),t.containerPointToCoordinate(e.add(0,r/2)),t.containerPointToCoordinate(e.add(0,-r/2))]},i._getViewPoint=function(){var t=0;if(this._owner){var e=this.getAltitude();e>0&&(t=this._meterToPoint(this._coordinate,e))}return this.getMap().coordToViewPoint(this._coordinate,void 0,t)._add(this.options.dx,this.options.dy)},i._getDefaultEvents=function(){return N({},t.prototype._getDefaultEvents.call(this),{"zooming zoomend":this.onZoomFilter})},i._setPosition=function(){this.onZoomFilter(),t.prototype._setPosition.call(this)},i.onZoomFilter=function(){var t=this.getDOM();t&&(this.isVisible()||"none"===t.style.display?this.isVisible()&&"none"===t.style.display&&(t.style.display=""):t.style.display="none")},i.isVisible=function(){var t=this.getMap();if(!t)return!1;if(!this.options.visible)return!1;var e=t.getZoom(),i=this.options,n=i.minZoom,r=i.maxZoom;return!(!H(n)&&e<n||!H(r)&&e>r)&&(this.getDOM()&&!0)},i.isSupportZoomFilter=function(){return!0},e}(kn(wh));Mh.mergeOptions({containerClass:null,eventsPropagation:!0,draggable:!1,single:!1,content:null,altitude:0,minZoom:0,maxZoom:null,horizontalAlignment:"middle",verticalAlignment:"middle"});var Sh=Ot.touch?"touchstart mousedown":"mousedown",Th=function(t){function e(e){return t.call(this,e)||this}Dt(e,t);var i=e.prototype;return i.addHooks=function(){this.target.on(Sh,this._startDrag,this)},i.removeHooks=function(){this.target.off(Sh,this._startDrag,this)},i._startDrag=function(t){var e=t.domEvent;e.touches&&e.touches.length>1||2===e.button||this.isDragging()||(this.target.on("click",this._endDrag,this),this._lastCoord=t.coordinate,this._lastPoint=t.containerPoint,this._prepareDragHandler(),this._dragHandler.onMouseDown(t.domEvent),this.target.fire("dragstart",t))},i._prepareDragHandler=function(){this._dragHandler=new Nn(this.target.getDOM(),{cancelOn:this._cancelOn.bind(this),ignoreMouseleave:!0}),this._dragHandler.on("mousedown",this._onMouseDown,this),this._dragHandler.on("dragging",this._dragging,this),this._dragHandler.on("mouseup",this._endDrag,this),this._dragHandler.enable()},i._cancelOn=function(t){var e=(t.srcElement||t.target).tagName.toLowerCase();return"button"===e||"input"===e||"select"===e||"option"===e||"textarea"===e},i._onMouseDown=function(t){qi(t.domEvent)},i._dragging=function(t){var e=this.target,i=e.getMap()._parseEvent(t.domEvent),n=i.domEvent;if(!(n.touches&&n.touches.length>1))if(this._isDragging){var r=i.coordinate,o=i.containerPoint;this._lastCoord||(this._lastCoord=r),this._lastPoint||(this._lastPoint=o);var s=r.sub(this._lastCoord),a=o.sub(this._lastPoint);this._lastCoord=r,this._lastPoint=o,this.target.setCoordinates(this.target.getCoordinates().add(s)),i.coordOffset=s,i.pointOffset=a,e.fire("dragging",i)}else this._isDragging=!0},i._endDrag=function(t){var e=this.target,i=e.getMap();if(this._dragHandler&&(e.off("click",this._endDrag,this),this._dragHandler.disable(),delete this._dragHandler),delete this._lastCoord,delete this._lastPoint,this._isDragging=!1,i){var n=i._parseEvent(t.domEvent);e&&e._mouseClickPositionIsChange&&e._mouseClickPositionIsChange()&&e.fire("dragend",n)}},i.isDragging=function(){return!!this._isDragging},e}(An);Mh.addInitHook("addHandler","draggable",Th);var Eh=/\{ *([\w_]+) *\}/g,Ch={containerClass:"maptalks-msgBox",autoPan:!0,autoCloseOn:null,autoOpenOn:"click",width:"auto",minHeight:120,custom:!1,title:null,content:null,enableTemplate:!1},Ph=new si(0,0),Ah=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i._getClassName=function(){return"InfoWindow"},i.addTo=function(e){return e instanceof os&&(e.getInfoWindow()&&e.getInfoWindow()!==this&&e.removeInfoWindow(),e._infoWindow=this),t.prototype.addTo.call(this,e)},i.setContent=function(t){var e=this.options.content;return this.options.content=t,this.fire("contentchange",{old:e,new:t}),this.isVisible()&&this.show(this._coordinate),this},i.getContent=function(){return this.options.content},i.setTitle=function(t){var e=t;return this.options.title=t,this.fire("contentchange",{old:e,new:t}),this.isVisible()&&this.show(this._coordinate),this},i.getTitle=function(){return this.options.title},i.buildOn=function(){var t=W(this.options.content),e=V(this.options.content);if(this.options.custom){if(e||t){var i=Hi("div");return e?(i.innerHTML=this.options.content,this._replaceTemplate(i)):this.options.content.bind(this)(i),i}return this._replaceTemplate(this.options.content),this.options.content}this._bindDomEvents(this.getDOM(),"off");var n=Hi("div");this.options.containerClass&&(n.className=this.options.containerClass);var r=this._getWindowWidth();n.style.width=j(r)?r+"px":"auto",n.style.bottom="0px";var o='<em class="maptalks-ico"></em>';this.options.title&&(o+="<h2>"+this.options.title+"</h2>"),o+='<a href="javascript:void(0);" class="maptalks-close"></a><div class="maptalks-msgContent"></div>',n.innerHTML=o,this._replaceTemplate(n);var s=n.querySelector(".maptalks-msgContent");return e||t?e?s.innerHTML=this.options.content:this.options.content.bind(this)(s):s.appendChild(this.options.content),this._onCloseBtnClick=this.hide.bind(this),Ui(n.querySelector(".maptalks-close"),"click touchend",this._onCloseBtnClick),t||this._replaceTemplate(s),this._bindDomEvents(n,"on"),n},i._replaceTemplate=function(t){if(this.options.enableTemplate&&this._owner&&this._owner.getProperties&&t&&t.innerHTML){var e=this._owner.getProperties()||{};if(U(e)){var i=t.innerHTML;t.innerHTML=i.replace(Eh,(function(t,i){return e[i]}))}}return this},i.getTransformOrigin=function(){return this.getSize().width/2+"px bottom"},i.getOffset=function(){var t=this.getSize(),e=new Bt(-t.width/2,0);this.options.custom?e._sub(0,t.height):e._sub(4,12);var i=this.getOwner();if(i instanceof Vs||i instanceof Qs){var n,r;if(i instanceof Vs)n=i._getPainter(),r=i.getSize();else{var o=i.getGeometries();if(!o||!o.length)return e;n=o[0]._getPainter(),r=o[0].getSize()}if(r||(r=Ph),n){var s=n.getFixedExtent();e._add(s.xmax-r.width/2,s.ymin)}else e._add(0,-r.height)}return e},i.show=function(e){return this.getMap()&&this.getMap().options.enableInfoWindow?t.prototype.show.call(this,e):this},i.getEvents=function(){if(!this.options.autoCloseOn)return null;var t={};return t[this.options.autoCloseOn]=this.hide,t},i.getOwnerEvents=function(){var t=this.getOwner();if(!this.options.autoOpenOn||!t)return null;var e={};return e[this.options.autoOpenOn]=this._onAutoOpen,e},i.onRemove=function(){this._onDomMouseout(),this.onDomRemove()},i.onDomRemove=function(){this._onCloseBtnClick&&(Vi(this.getDOM().childNodes[2],"click touchend",this._onCloseBtnClick),delete this._onCloseBtnClick)},i._onAutoOpen=function(t){var e=this,i=this.getOwner();setTimeout((function(){i instanceof Vs||i instanceof wh?e.show(i.getCoordinates()):i instanceof Qs?e.show(i.findClosest(t.coordinate)):i instanceof Zs||i instanceof $s?(e.getMap().getScale()>=8&&(t.coordinate=e._rectifyMouseCoordinte(i,t.coordinate)),e.show(t.coordinate)):e.show(t.coordinate)}),1)},i._rectifyMouseCoordinte=function(t,e){var i=this;return t instanceof Zs?this._rectifyLineStringMouseCoordinate(t,e).coordinate:t instanceof $s?t.getGeometries().map((function(t){return i._rectifyLineStringMouseCoordinate(t,e)})).sort((function(t,e){return t.dis-e.dis}))[0].coordinate:e},i._rectifyLineStringMouseCoordinate=function(t,e){for(var i=this,n=t.getCoordinates().map((function(t){return i.getMap().coordToContainerPoint(t)})),r=this.getMap().coordToContainerPoint(e),o=1/0,s=-1,a=0,h=n.length;a<h;a++){var l=n[a],c=r.distanceTo(l);c<o&&(o=c,s=a)}var u=[];0===s?u.push(n[0],n[1]):s===n.length-1?u.push(n[s-1],n[s]):u.push(n[s-1],n[s],n[s+1]);for(var d=[],p=this.getMap().getSize(),f=p.width,m=p.height,g=0,v=u.length-1;g<v;g++){var y=u[g],_=u[g+1];if(y.x===_.x)for(var x=Math.max(0,Math.min(y.y,_.y)),w=Math.min(m,Math.max(y.y,_.y)),b=x;b<=w;b++)d.push(new Bt(y.x,b));else for(var M=(_.y-y.y)/(_.x-y.x),S=Math.max(0,Math.min(y.x,_.x)),T=Math.min(f,Math.max(y.x,_.x)),E=S;E<=T;E++){var C=M*(E-y.x)+y.y;d.push(new Bt(E,C))}}for(var P=1/0,A=-1,L=0,R=d.length;L<R;L++){var O=d[L],D=r.distanceTo(O);D<P&&(P=D,A=L)}return{dis:P,coordinate:A<0?e:this.getMap().containerPointToCoord(d[A])}},i._getWindowWidth=function(){var t=Ch.width,e=this.options.width;return e||(e=t),e},i._bindDomEvents=function(t,e){if(t){var i=this._getDomEvents(),n="on"===e?ln:cn;for(var r in i)n(t,r,i[r],this)}},i._getDomEvents=function(){return{mouseover:this._onDomMouseover,mouseout:this._onDomMouseout}},i._onDomMouseover=function(t){var e=this.getMap();e&&(e.options.preventWheelScroll=!1)},i._onDomMouseout=function(t){var e=this.getMap();e&&(e.options.preventWheelScroll=!0)},e}(wh);Ah.mergeOptions(Ch);var Lh="remove hide shapechange positionchange dragend animatestart",Rh=function(t){Dt(i,t);var e=i.prototype;function i(e,i){var n;return void 0===i&&(i={}),(n=t.call(this,i)||this)._content=e,n}return e._getClassName=function(){return"ToolTip"},e.addTo=function(e){if(i.isSupport(e))return e.on("mousemove",this.onMouseMove,this),e.on("mouseout",this.onMouseOut,this),e.on(Lh,this.hideDom,this),t.prototype.addTo.call(this,e);throw new Error("Invalid geometry or UIMarker the tooltip is added to.")},e.setStyle=function(t){return this.options.containerClass=t,this},e.getStyle=function(){return this.options.containerClass},e.getContent=function(){return this._content},e.buildOn=function(){var t=Hi("div"),e=this.options||{};e.height&&(t.style.height=e.height+"px"),e.width&&(t.style.width=e.width+"px");var i=e.containerClass||e.cssName;return!i&&e.height&&(t.style.lineHeight=e.height+"px"),W(this._content)?this._content.bind(this)(t):t.innerHTML='<div class="'+i+'">'+this._content+"</div>",t},e.onMouseOut=function(){clearTimeout(this._timeout),this.isVisible()&&this._removePrevDOM(),this._switchMapEvents("off")},e.onMouseMove=function(t){var e=this;clearTimeout(this._timeout);var i=this.getMap();if(i){var n=i.locateByPoint(t.coordinate,-5,25);0===this.options.showTimeout?this.show(n):this._timeout=setTimeout((function(){i&&e.show(n)}),this.options.showTimeout)}},e.onRemove=function(){clearTimeout(this._timeout),this._owner&&(this._owner.off("mouseover",this.onMouseOver,this),this._owner.off("mouseout",this.onMouseOut,this),this._owner.off(Lh,this.hideDom,this))},e.hideDom=function(){return this.hide()},e.onEvent=function(){return t.prototype.onEvent.call(this),this.hideDom(),this},e._getViewPoint=function(){return this.getMap().coordToViewPoint(this._coordinate,void 0,0)._add(this.options.dx,this.options.dy)},i}(wh);Rh.mergeOptions({width:0,height:0,animation:"fade",containerClass:"maptalks-tooltip",showTimeout:400});var Oh=function(t){function e(e){return t.call(this,e)||this}Dt(e,t);var i=e.prototype;return i._getClassName=function(){return"Menu"},i.addTo=function(t){return t._menu&&t._menu!==this&&t.removeMenu(),t._menu=this,this._owner=t,wh.prototype.addTo.apply(this,arguments)},i.setItems=function(t){return this.options.items=t,this},i.getItems=function(){return this.options.items||[]},i.buildOn=function(){if(this.options.custom){if(V(this.options.items)){var t=Hi("div");return t.innerHTML=this.options.items,t}return this.options.items}var e=Hi("div");this.options.containerClass&&tn(e,this.options.containerClass),e.style.width=this._getMenuWidth()+"px";var i=this._createMenuItemDom();return e.appendChild(i),ln(e,"contextmenu",Zi),e},i.getOffset=function(){if(!this.getMap())return null;var t=this.getMap().getSize(),e=this.getMap().viewPointToContainerPoint(this._getViewPoint()),i=this.getSize(),n=0,r=0;return e.x+i.width>t.width&&(n=-i.width),e.y+i.height>t.height&&(r=-i.height),new Bt(n,r)},i.getTransformOrigin=function(){var t=this.getOffset()._multi(-1);return t.x+"px "+t.y+"px"},i.getEvents=function(){return{"_zoomstart _zoomend _movestart _dblclick _click":this._removePrevDOM}},i._createMenuItemDom=function(){var t=this,e=this.getMap(),i=Hi("ul");tn(i,"maptalks-menu-items");var n,r,o=this.getItems();function s(i){return function(n){var r=e._parseEvent(n,"click");r.target=t,r.owner=t._owner,r.index=i,!1!==this._callback(r)&&(t.hide(),t._owner&&t._owner.fire("closemenu"))}}for(var a=0,h=o.length;a<h;a++){if("-"===(n=o[a])||"_"===n)tn(r=Hi("li"),"maptalks-menu-splitter");else{r=Hi("li");var l=n.item;W(l)&&(l=l({owner:this._owner,index:a})),r.innerHTML=l,r._callback=n.click,ln(r,"click",s(a))}i.appendChild(r)}var c=this.options.maxHeight||0;return c>0&&Ki(i,"max-height: "+c+"px; overflow-y: auto;"),i},i._getMenuWidth=function(){return this.options.width||160},e}(wh);Oh.mergeOptions({containerClass:"maptalks-menu",animation:null,animationDelay:10,animationOnHide:!1,autoPan:!1,width:160,maxHeight:0,custom:!1,items:[]});var Dh={setMenu:function(t){return this._menuOptions=t,this._menu?this._menu.setOptions(t):this.on("contextmenu",this._defaultOpenMenu,this),this},getMenu:function(){return this._menu},openMenu:function(t){var e=this instanceof Ss?this:this.getMap();return t||(t=this.getCenter()),this._menu?this._menu.show(t):this._menuOptions&&e&&(this._bindMenu(),this._menu.show(t)),this.fire("openmenu",{coordinate:t}),this},setMenuItems:function(t){return this._menuOptions||(this._menuOptions={}),Array.isArray(t)&&(this._menuOptions.custom=!1),this._menuOptions.items=t,this.setMenu(this._menuOptions),this},getMenuItems:function(){return this._menu?this._menu.getItems():this._menuOptions&&this._menuOptions.items||[]},closeMenu:function(){return this._menu&&this._menu.hide(),this.fire("closemenu",{}),this},removeMenu:function(){return this.off("contextmenu",this._defaultOpenMenu,this),this._unbindMenu(),delete this._menuOptions,this.fire("removemenu",{}),this},_bindMenu:function(){return this._menuOptions?(this._menu=new Oh(this._menuOptions),this._menu.addTo(this),this):this},_unbindMenu:function(){return this._menu&&(this.closeMenu(),this._menu.remove(),delete this._menu),this},_defaultOpenMenu:function(t){return this.openMenu(t.coordinate),!1}};Ss.include(Dh),os.include(Dh);var Ih=Object.freeze({UIComponent:wh,UIMarker:Mh,InfoWindow:Ah,ToolTip:Rh,Menuable:Dh,Menu:Oh}),kh=function(t){function e(e){return e&&e.position&&!V(e.position)&&(e.position=N({},e.position)),t.call(this,e)||this}Dt(e,t);var i=e.prototype;return i.addTo=function(t){if(this.remove(),!t.options.control)return this;this._map=t;var e=t._panels.control;return this.__ctrlContainer=Hi("div"),Ki(this.__ctrlContainer,"position:absolute;overflow:visible;"),this.update(),e.appendChild(this.__ctrlContainer),this.onAdd&&this.onAdd(),this.fire("add",{dom:e}),this},i.update=function(){return this.__ctrlContainer.innerHTML="",this._controlDom=this.buildOn(this.getMap()),this._controlDom&&(this._updatePosition(),this.__ctrlContainer.appendChild(this._controlDom)),this},i.getMap=function(){return this._map},i.getPosition=function(){return N({},this._parse(this.options.position))},i.setPosition=function(t){return V(t)?this.options.position=t:this.options.position=N({},t),this._updatePosition(),this},i.getContainerPoint=function(){var t,e,i=this.getPosition(),n=this.getMap().getSize();return H(i.left)?H(i.right)||(t=n.width-parseInt(i.right)):t=parseInt(i.left),H(i.top)?H(i.bottom)||(e=n.height-parseInt(i.bottom)):e=parseInt(i.top),new Bt(t,e)},i.getContainer=function(){return this.__ctrlContainer},i.getDOM=function(){return this._controlDom},i.show=function(){return this.__ctrlContainer.style.display="",this},i.hide=function(){return this.__ctrlContainer.style.display="none",this},i.isVisible=function(){return this.__ctrlContainer&&""===this.__ctrlContainer.style.display},i.remove=function(){return this._map?(Gi(this.__ctrlContainer),this.onRemove&&this.onRemove(),delete this._map,delete this.__ctrlContainer,delete this._controlDom,this.fire("remove"),this):this},i._parse=function(t){var i=t;return V(t)&&(i=e.positions[i]),i},i._updatePosition=function(){var t=this.getPosition();for(var e in t||(t={top:20,left:20}),t)t.hasOwnProperty(e)&&(t[e]=parseInt(t[e]),this.__ctrlContainer.style[e]=t[e]+"px");this.fire("positionchange",{position:N({},t)})},e}(Cn(Ln));kh.positions={"top-left":{top:20,left:20},"top-right":{top:20,right:20},"bottom-left":{bottom:20,left:20},"bottom-right":{bottom:20,right:20}},Ss.mergeOptions({control:!0}),Ss.include({addControl:function(t){return this._containerDOM.getContext||t.addTo(this),this},removeControl:function(t){return t&&t.getMap()===this?(t.remove(),this):this}});var zh="addlayer removelayer setbaselayer baselayerremove",Fh=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.buildOn=function(){return this._attributionContainer=Hi("div"),this._attributionContainer.className="maptalks-attribution",this._update(),this._attributionContainer},i.onAdd=function(){this.getMap().on(zh,this._update,this)},i.onRemove=function(){this.getMap().off(zh,this._update,this)},i._update=function(){var t=this.getMap();if(t){var e=t._getLayers((function(t){return t.options.attribution})).reverse().map((function(t){return t.options.attribution})),i=this.options.content+(e.length>0?" - "+e.join(", "):"");this._attributionContainer.innerHTML='<span style="padding:0px 4px">'+i+"</span>"}},e}(kh);Fh.mergeOptions({position:{bottom:0,left:0},content:'<a href="http://maptalks.org" target="_blank">maptalks</a>'}),Ss.mergeOptions({attribution:!0}),Ss.addOnLoadHook((function(){var t=this.options.attribution||this.options.attributionControl;t&&(this.attributionControl=new Fh(t),this.addControl(this.attributionControl))}));var Bh=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.buildOn=function(){var t=this.container=Hi("div",this.options.containerClass),e=this.panel=Hi("div","panel"),i=this.button=Hi("button");return t.appendChild(i),t.appendChild(e),t},i.onAdd=function(){ln(this.button,"mouseover",this._show,this),ln(this.panel,"mouseleave",this._hide,this),ln(this.getMap(),"click",this._hide,this)},i.onRemove=function(){this.panel&&(cn(this.button,"mouseover",this._show),cn(this.panel,"mouseleave",this._hide),cn(this.getMap(),"click",this._hide),Gi(this.panel),Gi(this.button),delete this.panel,delete this.button,delete this.container)},i._show=function(){$i(this.container,"shown")||(tn(this.container,"shown"),this._createPanel())},i._hide=function(t){this.panel.contains(t.toElement||t.relatedTarget)||en(this.container,this.options.containerClass)},i._createPanel=function(){this.panel.innerHTML="";var t=Hi("ul");this.panel.appendChild(t),this._renderLayers(this.getMap(),t)},i._renderLayers=function(t,e){var i=this,n=t.getBaseLayer(),r=t.getLayers(),o=r.length;if(n){var s=n.layers||[n],a=Hi("li","group"),h=Hi("ul"),l=Hi("label");l.innerHTML=this.options.baseTitle,a.appendChild(l);for(var c=0,u=s.length;c<u;c++){var d=s[c];this._isExcluded(d)&&(h.appendChild(this._renderLayer(s[c],!0)),a.appendChild(h),e.appendChild(a))}}if(o){var p=Hi("li","group"),f=Hi("ul"),m=Hi("label"),g=Hi("input");g.type="checkbox",g.checked=!0,m.innerHTML=this.options.overlayTitle,p.appendChild(g),p.appendChild(m);for(var v=function(t){var e=t.target.checked,i=t.target.parentNode;if(i){var n=i.getElementsByTagName("ul")[0];if(n){var r=function(t){var i=t._layer;i&&i[e?"show":"hide"]()},o=function(t){var i=t._layer,n=t.childNodes[0];n&&(n.checked=e),i&&i[e?"show":"hide"]()};r(i),n.childNodes.forEach((function(t){o(t);var e=t.getElementsByTagName("ul")[0];e&&(r(t),e.childNodes.forEach((function(t){o(t)})))}))}}},y=0;y<o;y++){var _=r[y];this._isExcluded(_)&&(_.getLayers?function(){var t=Hi("li","group"),e=Hi("ul"),n=Hi("label"),r=Hi("input");n.innerHTML=_.getId(),r.type="checkbox",r.checked=_.isVisible(),r.onchange=v,t.appendChild(r),t.appendChild(n),t.appendChild(e),t._layer=_,f.appendChild(t),(_.getLayers()||[]).forEach((function(t){e.appendChild(i._renderLayer(t,!1,r.checked))}))}():f.appendChild(this._renderLayer(_)),_&&!_.isVisible()&&(g.checked=!1))}p.appendChild(f),e.appendChild(p),g.onchange=v}},i._isExcluded=function(t){var e=t.getId(),i=this.options.excludeLayers;return!(i.length&&i.indexOf(e)>=0)},i._renderLayer=function(t,e,i){var n=this;void 0===i&&(i=!0);var r=Hi("li","layer"),o=Hi("label"),s=Hi("input"),a=this.getMap(),h=t.options.visible;t.options.visible=!0;var l=t.isVisible();return t.options.visible=h,r.className="layer",e?(s.type="radio",s.name="base"):s.type="checkbox",s.checked=h&&l,i||(s.checked=!1),l||s.setAttribute("disabled","disabled"),s.onchange=function(e){if("radio"===e.target.type){var i=a.getBaseLayer(),r=i.layers;if(r)for(var o=0,s=r.length;o<s;o++){var h=r[o];h[h===t?"show":"hide"]()}else i.isVisible()||i.show();a._fireEvent("setbaselayer")}else t[e.target.checked?"show":"hide"]();n.fire("layerchange",{target:t})},r.appendChild(s),o.innerHTML=t.getId(),r.appendChild(o),r._layer=t,r},e}(kh);Bh.mergeOptions({position:"top-right",baseTitle:"Base Layers",overlayTitle:"Layers",excludeLayers:[],containerClass:"maptalks-layer-switcher"}),Ss.mergeOptions({layerSwitcherControl:!1}),Ss.addOnLoadHook((function(){this.options.layerSwitcherControl&&(this.layerSwitcherControl=new Bh(this.options.layerSwitcherControl),this.addControl(this.layerSwitcherControl))}));var Nh=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.buildOn=function(){var t=this.options.size;this.options.maximize||(t=[0,0]);var e=Hi("div"),i=this.mapContainer=Hi("div");i.style.width=t[0]+"px",i.style.height=t[1]+"px",i.className=this.options.containerClass;var n=this.button=Hi("div");return n.className=this.options.buttonClass,e.appendChild(i),e.appendChild(n),e},i.onAdd=function(){this.options.maximize&&this._createOverview(),this.getMap().on("resize moving zooming rotate dragrotating viewchange",this._update,this).on("setbaselayer",this._updateBaseLayer,this).on("spatialreferencechange",this._updateSpatialReference,this),ln(this.button,"click",this._onButtonClick,this),this._updateButtonText()},i.onRemove=function(){this.getMap().off("resize moving zooming rotate dragrotating viewchange",this._update,this).off("setbaselayer",this._updateBaseLayer,this).off("spatialreferencechange",this._updateSpatialReference,this),this._overview&&(this._overview.remove(),delete this._overview,delete this._perspective),cn(this.button,"click",this._onButtonClick)},i.maxmize=function(){var t=this.options.size,e=this.mapContainer;return e.style.width=t[0]+"px",e.style.height=t[1]+"px",this._createOverview(),this},i.minimize=function(){this._overview&&this._overview.remove(),delete this._overview,delete this._perspective;var t=this.mapContainer;return t.style.width="0px",t.style.height="0px",this},i.getOverviewMap=function(){return this._overview},i._onButtonClick=function(){this._overview?this.minimize():this.maxmize(),this._updateButtonText()},i._updateButtonText=function(){this._overview?this.button.innerHTML="-":this.button.innerHTML="+"},i._createOverview=function(){var t=this.getMap(),e=this.mapContainer,i=t.config();N(i,{center:t.getCenter(),zoom:this._getOverviewZoom(),zoomAnimationDuration:150,pitch:0,bearing:0,scrollWheelZoom:!1,checkSize:!1,doubleClickZoom:!1,touchZoom:!1,control:!1,draggable:!1,maxExtent:null}),this._overview=new Ss(e,i),this._updateBaseLayer(),this._perspective=new js(this._getPerspectiveCoords(),{draggable:!0,cursor:"move",symbol:this.options.symbol}).on("dragend",this._onDragEnd,this),new Sa("perspective_layer",this._perspective).addTo(this._overview),this.fire("load")},i._getOverviewZoom=function(){var t=this.getMap(),e=t.getZoom(),i=t.getMinZoom(),n=this.options.level;if(n>0){for(var r=n;r>0;r--)if(e-r>=i)return e-r}else for(var o=n;o<0;o++)if(e-o>=i)return e-o;return e},i._onDragEnd=function(){var t=this._perspective.getCenter();this._overview.setCenter(t),this.getMap().panTo(t)},i._getPerspectiveCoords=function(){var t=this.getMap(),e=t.getProjection();return t.getContainerExtent().toArray().map((function(i){if(e){var n=t._containerPointToPrj(i);return t._fixPrjOnWorldWide(n),e.unproject(n)}return t.containerPointToCoordinate(i)}))},i._update=function(){if(this._overview){Ji(this._overview._containerDOM);var t=this._getPerspectiveCoords();this._perspective.setCoordinates(t),this._overview.setCenterAndZoom(this.getMap().getCenter(),this._getOverviewZoom())}},i._updateSpatialReference=function(){if(this._overview){var t=this.getMap().options.spatialReference;this._overview.setSpatialReference(t)}},i._updateBaseLayer=function(){if(this._overview){var t=this.getMap().getBaseLayer();if(t){var e=t.layers,i=0;if(e)for(var n=0,r=e.length;n<r;n++){if(e[n].isVisible()){i=n;break}}var o=t.toJSON(),s=null;e?(s=o.layers[i].options).visible=!0:s=o.options,this._overview.setMinZoom(s.minZoom||null).setMaxZoom(s.maxZoom||null),delete s.minZoom,delete s.maxZoom,delete o.options.canvas,o.options.visible=!0,o.options.renderer="canvas";var a=ds.fromJSON(o);for(var h in t)W(t[h])&&t.hasOwnProperty(h)&&t[h]!==t.constructor.prototype[h]&&(a[h]=t[h]);this._overview.setBaseLayer(a)}else this._overview.setBaseLayer(null)}},e}(kh);Nh.mergeOptions({level:4,position:{right:1,bottom:1},size:[300,200],maximize:!0,symbol:{lineWidth:3,lineColor:"#1bbc9b",polygonFill:"#1bbc9b",polygonOpacity:.4},containerClass:"maptalks-overview",buttonClass:"maptalks-overview-button"}),Ss.mergeOptions({overviewControl:!1}),Ss.addOnLoadHook((function(){this.options.overviewControl&&(this.overviewControl=new Nh(this.options.overviewControl),this.addControl(this.overviewControl))}));var Hh=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.buildOn=function(){var t;if(this.options.custom)V(this.options.content)?(t=Hi("div")).innerHTML=this.options.content:t=this.options.content;else{if(t=Hi("div","maptalks-panel"),this.options.closeButton){var e=Hi("a","maptalks-close");e.href="javascript:;",e.onclick=function(){t.style.display="none"},t.appendChild(e)}var i=Hi("div","maptalks-panel-content");i.innerHTML=this.options.content,t.appendChild(i)}return this.draggable=new Nn(t,{cancelOn:this._cancelOn.bind(this),ignoreMouseleave:!0}),this.draggable.on("dragstart",this._onDragStart,this).on("dragging",this._onDragging,this).on("dragend",this._onDragEnd,this),this.options.draggable&&this.draggable.enable(),t},i.update=function(){return this.draggable&&(this.draggable.disable(),delete this.draggable),kh.prototype.update.call(this)},i.setContent=function(t){var e=this.options.content;return this.options.content=t,this.fire("contentchange",{old:e,new:t}),this.isVisible()&&this.update(),this},i.getContent=function(){return this.options.content},i._cancelOn=function(t){var e=(t.srcElement||t.target).tagName.toLowerCase();return"button"===e||"input"===e||"select"===e||"option"===e||"textarea"===e},i._onDragStart=function(t){this._startPos=t.mousePos,this._startPosition=N({},this.getPosition()),this.fire("dragstart",t)},i._onDragging=function(t){var e=t.mousePos.sub(this._startPos),i=this._startPosition,n=this.getPosition();H(n.top)||(n.top=parseInt(i.top)+e.y),H(n.bottom)||(n.bottom=parseInt(i.bottom)-e.y),H(n.left)||(n.left=parseInt(i.left)+e.x),H(n.right)||(n.right=parseInt(i.right)-e.x),this.setPosition(n),this.fire("dragging",t)},i._onDragEnd=function(t){delete this._startPos,delete this._startPosition,this.fire("dragend",t)},i._getConnectPoints=function(){var t=this.getMap(),e=this.getContainerPoint(),i=this.getDOM(),n=parseInt(i.clientWidth),r=parseInt(i.clientHeight);return[t.containerPointToCoordinate(e.add(n/2,0)),t.containerPointToCoordinate(e.add(n,r/2)),t.containerPointToCoordinate(e.add(n/2,r)),t.containerPointToCoordinate(e.add(0,r/2))]},e}(kh);Hh.mergeOptions({position:"top-right",draggable:!0,custom:!1,content:"",closeButton:!0});var jh=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.buildOn=function(t){return this._map=t,this._scaleContainer=Hi("div",this.options.containerClass),this._addScales(),t.on("zoomend",this._update,this),this._map._loaded&&this._update(),this._scaleContainer},i.onRemove=function(){this.getMap().off("zoomend",this._update,this)},i._addScales=function(){var t="border: 2px solid #000000;border-top: none;line-height: 1.1;padding: 0px;color: #000000;font-size: 11px;text-align:center;white-space: nowrap;overflow: hidden;-moz-box-sizing: content-box;box-sizing: content-box;background: #fff; background: rgba(255, 255, 255, 0);";this.options.metric&&(this._mScale=ji("div",this.options.containerClass?null:t,this._scaleContainer)),this.options.imperial&&(this._iScale=ji("div",this.options.containerClass?null:t,this._scaleContainer))},i._update=function(){var t=this._map.pixelToDistance(this.options.maxWidth,0);this._updateScales(t)},i._updateScales=function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},i._updateMetric=function(t){var e=this._getRoundNum(t),i=e<1e3?e+" m":e/1e3+" km";this._updateScale(this._mScale,i,e/t)},i._updateImperial=function(t){var e,i,n,r=3.2808399*t;r>5280?(e=r/5280,i=this._getRoundNum(e),this._updateScale(this._iScale,i+" mile",i/e)):(n=this._getRoundNum(r),this._updateScale(this._iScale,n+" feet",n/r))},i._updateScale=function(t,e,i){t.style.width=Math.round(this.options.maxWidth*i)+"px",t.innerHTML=e},i._getRoundNum=function(t){var e=Math.pow(10,(Math.floor(t)+"").length-1),i=t/e;return e*(i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:1)},e}(kh);jh.mergeOptions({position:"bottom-left",maxWidth:100,metric:!0,imperial:!1,containerClass:null}),Ss.mergeOptions({scaleControl:!1}),Ss.addOnLoadHook((function(){this.options.scaleControl&&(this.scaleControl=new jh(this.options.scaleControl),this.addControl(this.scaleControl))}));var Gh=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.buildOn=function(t){this._map=t;var e=Hi("div"),i=Hi("ul","maptalks-toolbar-hx");e.appendChild(i),this.options.vertical?tn(e,"maptalks-toolbar-vertical"):tn(e,"maptalks-toolbar-horizonal");var n=this;function r(t,e,i,r){var o=n._getItems()[e];return function(n){return qi(n),t({target:o,index:e,childIndex:i,dom:r})}}var o=this.options.items;if(te(o))for(var s=0,a=o.length;s<a;s++){var h=o[s],l=Hi("li");if(28!==this.options.height&&(l.style.lineHeight=this.options.height+"px"),l.style.height=this.options.height+"px",l.style.cursor="pointer",on(h.item)){l.style.textAlign="center";var c=sn("div",h.item);l.innerHTML='<div style="margin-top:'+(this.options.height-c.height)/2+'px;">'+h.item+"</div>"}else l.innerHTML=h.item;if(h.click&&ln(l,"click",r(h.click,s,null,l)),te(h.children)){var u=this._createDropMenu(s);l.appendChild(u),l._menu=u,ln(l,"mouseover",(function(){this._menu.style.display=""})),ln(l,"mouseout",(function(){this._menu.style.display="none"}))}i.appendChild(l)}return e},i._createDropMenu=function(t){var e=this;function i(t,i,n){var r=e._getItems()[i].children[n];return function(e){return qi(e),t({target:r,index:i,childIndex:n})}}var n=Hi("div","maptalks-dropMenu"),r=this._getItems(),o=r.length,s=Hi("ul"),a=r[t].children;t===o-1&&a&&(n.style.cssText="right: 0px;",s.style.cssText="right: 0px;position: absolute;",this.options.reverseMenu&&(s.style.bottom=0)),n.appendChild(Hi("em","maptalks-ico"));for(var h=0,l=0,c=a.length;l<c;l++){var u=pi(a[l].item,"12px");u.width>h&&(h=u.width)}for(var d=0,p=a.length;d<p;d++){var f=a[d],m=Hi("li");m.innerHTML='<a href="javascript:;">'+f.item+"</a>",m.style.cursor="pointer",m.style.width=h+24+"px",ln(m.childNodes[0],"click",i(f.click,t,d)),s.appendChild(m)}if(this.options.vertical){var g=h<95?95:h;this.options.reverseMenu?n.style.right=-(g+20)+"px":n.style.left=-(g+20)+"px"}else this.options.reverseMenu?n.style.bottom="28px":n.style.top="28px";return n.appendChild(s),n.style.display="none",n},i._getItems=function(){return this.options.items||[]},e}(kh);Gh.mergeOptions({height:28,vertical:!1,position:"top-right",reverseMenu:!1,items:{}});var Uh=10,Vh=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.buildOn=function(t){var e=this.options,i=Hi("div","maptalks-zoom");if(e.zoomLevel){var n=Hi("span","maptalks-zoom-zoomlevel");i.appendChild(n),this._levelDOM=n}var r=Hi("div","maptalks-zoom-slider"),o=Hi("a","maptalks-zoom-zoomin");if(o.href="javascript:;",o.innerHTML="+",r.appendChild(o),this._zoomInButton=o,e.slider){var s=Hi("div","maptalks-zoom-slider-box"),a=Hi("div","maptalks-zoom-slider-ruler"),h=Hi("span","maptalks-zoom-slider-reading"),l=Hi("span","maptalks-zoom-slider-dot");a.appendChild(h),s.appendChild(a),s.appendChild(l),r.appendChild(s),this._sliderBox=s,this._sliderRuler=a,this._sliderReading=h,this._sliderDot=l}var c=Hi("a","maptalks-zoom-zoomout");return c.href="javascript:;",c.innerHTML="-",r.appendChild(c),this._zoomOutButton=c,i.appendChild(r),t.on("_zoomend _zooming _zoomstart _spatialreferencechange",this._update,this),this._update(),this._registerDomEvents(),i},i.onRemove=function(){this.getMap().off("_zoomend _zooming _zoomstart _spatialreferencechange",this._update,this),this._zoomInButton&&cn(this._zoomInButton,"click",this._onZoomInClick),this._zoomOutButton&&cn(this._zoomOutButton,"click",this._onZoomOutClick),this._sliderRuler&&(cn(this._sliderRuler,"click",this._onClickRuler),this.dotDragger.disable(),delete this.dotDragger)},i._update=function(){var t=this.getMap();if(this._sliderBox){var e=(t.getMaxZoom()-t.getMinZoom())*Uh;this._sliderBox.style.height=e+16+"px",this._sliderRuler.style.height=e+8+"px",this._sliderRuler.style.cursor="pointer";var i=(t.getMaxZoom()-t.getZoom())*Uh;this._sliderReading.style.height=(t.getZoom()-t.getMinZoom()+1)*Uh+"px",this._sliderDot.style.top=i+"px"}this._updateText()},i._updateText=function(){if(this._levelDOM){var t=this.getMap().getZoom();G(t)||(t=Math.floor(10*t)/10),this._levelDOM.innerHTML=t}},i._registerDomEvents=function(){this._zoomInButton&&ln(this._zoomInButton,"click",this._onZoomInClick,this),this._zoomOutButton&&ln(this._zoomOutButton,"click",this._onZoomOutClick,this),this._sliderRuler&&(ln(this._sliderRuler,"click",this._onClickRuler,this),this.dotDragger=new Nn(this._sliderDot,{ignoreMouseleave:!0}),this.dotDragger.on("dragstart",this._onDotDragstart,this).on("dragging dragend",this._onDotDrag,this).enable())},i._onZoomInClick=function(t){Zi(t),this.getMap().zoomIn()},i._onZoomOutClick=function(t){Zi(t),this.getMap().zoomOut()},i._onClickRuler=function(t){Zi(t);var e=this.getMap(),i=Qi(t,this._sliderRuler).y,n=e.getMaxZoom(),r=Math.floor(n-i/Uh);e.setZoom(r)},i._onDotDragstart=function(t){Zi(t.domEvent);var e=this.getMap(),i=e.getSize().toPoint()._multi(.5);e.onZoomStart(e.getZoom(),i)},i._onDotDrag=function(t){Zi(t.domEvent);var e=this.getMap(),i=e.getSize().toPoint()._multi(.5),n=Qi(t.domEvent,this._sliderRuler),r=e.getMaxZoom(),o=e.getMinZoom(),s=n.y,a=r-s/Uh;r<a?(a=r,s=0):o>a&&(a=o,s=(r-o)*Uh),"dragging"===t.type?e.onZooming(a,i,1):"dragend"===t.type&&(this.options.seamless?e.onZoomEnd(a,i):e.onZoomEnd(Math.round(a),i)),this._sliderDot.style.top=s+"px",this._sliderReading.style.height=(e.getZoom()-o+1)*Uh+"px",this._updateText()},e}(kh);Vh.mergeOptions({position:"top-left",slider:!0,zoomLevel:!0,seamless:!1}),Ss.mergeOptions({zoomControl:!1}),Ss.addOnLoadHook((function(){this.options.zoomControl&&(this.zoomControl=new Vh(this.options.zoomControl),this.addControl(this.zoomControl))}));var Wh=function(){function t(t,e,i,n){Array.isArray(t)?(this.scale={x:t[0],y:t[1]},this.origin={x:t[2],y:t[3]}):(this.scale={x:t,y:e},this.origin={x:i,y:n})}return t.getDefault=function(t){return"baidu"===t.code.toLowerCase()?"baidu":t.code.toLowerCase()==="EPSG:4326".toLowerCase()?"tms-global-geodetic":"identity"===t.code.toLowerCase()?[1,-1,0,0]:"web-mercator"},t}(),Zh=6378137*Math.PI;N(Wh,{"web-mercator":new Wh([1,-1,-Zh,Zh]),"tms-global-mercator":new Wh([1,1,-Zh,-Zh]),"tms-global-geodetic":new Wh([1,1,-180,-90]),baidu:new Wh([1,1,0,0])});var qh=function(){function t(t,e,i,n){this.map=t,this.tileSize=n,this.fullExtent=i,this.prepareTileInfo(e,i),this._xScale=i.right>=i.left?1:-1,this._yScale=i.top>=i.bottom?1:-1;var r=t.getGLRes();this._pointOrigin=t._prjToPointAtRes(new Bt(this.tileSystem.origin),r),this._glRes=r}var e=t.prototype;return e.prepareTileInfo=function(t,e){if(V(t)?t=Wh[t.toLowerCase()]:Array.isArray(t)&&(t=new Wh(t)),!t)throw new Error("Invalid TileSystem");this.tileSystem=t;var i=e.right>e.left?1:-1,n=e.top>e.bottom?-1:1,r=t.origin.x,o=t.origin.y;this.transformation=new ir([i,n,r,o])},e._getTileNum=function(t,e){var i=this.tileSystem,n=this.tileSize,r=Math.floor(1e-7*i.scale.x+t.x/(n.width*e)),o=Math.ceil(1e-7*i.scale.y+t.y/(n.height*e));return{x:i.scale.x*r,y:i.scale.y*o}},e.getTileIndex=function(t,e,i){var n=this.tileSystem,r=this.transformation.transform(t,1),o=this._getTileNum(r,e);return n.scale.x<0&&(o.x-=1),n.scale.y>0&&(o.y-=1),this.getNeighorTileIndex(o.x,o.y,0,0,e,i)},e.getNeighorTileIndex=function(t,e,i,n,r,o){var s=this.tileSystem,a=t+s.scale.x*i,h=e-s.scale.y*n,l=!1,c=a,u=h,d=this._getTileFullIndex(r);return o&&(!0!==o&&"x"!==o||(d.xmax===d.xmin?a=d.xmin:a<d.xmin?(a=d.xmax-(d.xmin-a)%(d.xmax-d.xmin))===d.xmax&&(a=d.xmin):a>=d.xmax&&(a=d.xmin+(a-d.xmin)%(d.xmax-d.xmin))),!0!==o&&"y"!==o||(d.ymax===d.ymin?h=d.ymin:h>=d.ymax?h=d.ymin+(h-d.ymin)%(d.ymax-d.ymin):h<d.ymin&&(h=d.ymax-(d.ymin-h)%(d.ymax-d.ymin))===d.ymax&&(h=d.ymin))),(a<d.xmin||a>d.xmax||h>d.ymax||h<d.ymin)&&(l=!0),{x:a,y:h,idx:c,idy:u,out:l}},e._getTileFullIndex=function(t){if(this._tileFullIndex||(this._tileFullIndex={}),this._tileFullIndex[t])return this._tileFullIndex[t];var e=this.fullExtent,i=this.transformation,n=this._getTileNum(i.transform(new Hn(e.left,e.top),1),t),r=this._getTileNum(i.transform(new Hn(e.right,e.bottom),1),t),o=this.tileSystem;return o.scale.x<0&&(n.x-=1,r.x-=1),o.scale.y>0&&(n.y-=1,r.y-=1),this._tileFullIndex[t]=new tr(n,r),this._tileFullIndex[t]},e.getTilePrjNW=function(t,e,i){var n=this.tileSystem,r=this.tileSize,o=n.origin.y+this._yScale*n.scale.y*(e+(1===n.scale.y?1:0))*i*r.height,s=n.origin.x+this._xScale*n.scale.x*(t+(1===n.scale.x?0:1))*i*r.width;return new Hn(s,o)},e.getTilePointNW=function(t,e,i){var n=this._glRes/i,r=this.tileSystem,o=this.tileSize,s=this._pointOrigin.y*n+this._yScale*r.scale.y*(e+(1===r.scale.y?1:0))*o.height,a=this._pointOrigin.x*n+this._xScale*r.scale.x*(t+(1===r.scale.x?0:1))*o.width;return new Bt(a,s)},e.getTilePrjSE=function(t,e,i){var n=this.tileSystem,r=this.tileSize,o=n.origin.y+this._yScale*n.scale.y*(e+(1===n.scale.y?0:1))*i*r.height,s=n.origin.x+this._xScale*n.scale.x*(t+(1===n.scale.x?1:0))*i*r.width;return new Hn(s,o)},e.getTilePointSE=function(t,e,i){var n=this._glRes/i,r=this.tileSystem,o=this.tileSize,s=this._pointOrigin.y*n+this._yScale*r.scale.y*(e+(1===r.scale.y?0:1))*o.height,a=this._pointOrigin.x*n+this._xScale*r.scale.x*(t+(1===r.scale.x?1:0))*o.width;return new Bt(a,s)},e.getTilePrjExtent=function(t,e,i){var n=this.getTilePrjNW(t,e,i),r=this.getTilePrjSE(t,e,i);return new tr(n,r)},t}(),Xh=new Bt(0,0),Yh="undefined"!=typeof Set,Jh=function(){function t(){this._table=Yh?new Set:{}}var e=t.prototype;return e.add=function(t){Yh?this._table.add(t):this._table[t]=!0},e.has=function(t){return Yh?this._table.has(t):this._table[t]},e.reset=function(){Yh?this._table.clear():this._table={}},t}(),Qh={urlTemplate:null,subdomains:null,errorUrl:null,repeatWorld:!0,background:!0,backgroundZoomDiff:6,loadingLimitOnInteracting:3,tileRetryCount:0,placeholder:!1,crossOrigin:null,tileSize:[256,256],offset:[0,0],tileSystem:null,fadeAnimation:!Q,debug:!1,spatialReference:null,maxCacheSize:256,renderer:Ot.webgl?"gl":"canvas",clipByPitch:!0,maxAvailableZoom:null,cascadeTiles:!0,zoomOffset:0,pyramidMode:1,decodeImageInWorker:!1,tileLimitPerFrame:0,backZoomOffset:0},Kh=/\{ *([\w_]+) *\}/g,$h=new Bt(0,0),tl=new Bt(0,0),el=new Bt(0,0),il=new Bt(0,0),nl=new Bt(0,0),rl=new Bt(0,0),ol=[[0,0,0],[0,0,0]],sl=[0,0,0],al=[0,0,0],hl=[],ll=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t),e.fromJSON=function(t){return t&&"TileLayer"===t.type?new e(t.id,t.options):null};var i=e.prototype;return i.forceReload=function(){return this.clear(),this.load(),this},i.getTileSize=function(){if(this._tileSize)return this._tileSize;var t=this.options.tileSize;return j(t)&&(t=[t,t]),this._tileSize=new si(t),this._tileSize},i.getTiles=function(t,e){return this._coordCache={},this._isPyramidMode()?this._getPyramidTiles(t,e):this._getCascadeTiles(t,e)},i._isPyramidMode=function(){var t=this.getSpatialReference();return!this._disablePyramid&&!this._hasOwnSR&&this.options.pyramidMode&&t&&t.isPyramid()},i._getTileFullExtent=function(){if(this._tileFullExtent)return this._tileFullExtent;var t=this.getSpatialReference(),e=t.getFullExtent(),i=t.getResolution(0),n=this.getMap();return this._tileFullExtent=e.convertTo((function(t){return n._prjToPointAtRes(t,i,Xh)})),this._tileFullExtent},i._getRootNodes=function(t){var e=this.getMap();if(this._rootNodes){var i=this._rootNodes,n=i.tiles,r=i.mapWidth,o=i.mapHeight;if(e.width!==r||e.height!==o){for(var s=this._getRootError(),a=0;a<n.length;a++)n[a].error=s;this._rootNodes.mapWidth=e.width,this._rootNodes.mapHeight=e.height}for(var h=0;h<n.length;h++)n[h].offset[0]=t[0],n[h].offset[1]=t[1];return this._rootNodes}var l=this.getSpatialReference(),c=l.getResolution(0),u=this._getTileConfig(),d=l.getFullExtent(),p=u.tileSystem,f=p.origin,m=p.scale,g=u.getTilePrjExtent(0,0,c),v=g.getWidth(),y=g.getHeight(),_=1e-5,x=Math.abs((f.x-d.left)/v);x=Math.ceil(x-_);var w=Math.abs((d.right-f.x)/v);w=Math.ceil(w-_);var b=Math.ceil(Math.abs(d.top-f.y)/y);b=Math.ceil(b-_);var M=Math.ceil(Math.abs(d.bottom-f.y)/y);if((w+x)*((M=Math.ceil(M-_))+b)>32)return{status:0,error:"Too many root nodes"};for(var S=this._getRootError(),T=[],E=-x;E<w;E++)for(var C=-b;C<M;C++){var P=m.y<0?C:-(C+1);T.push({x:E,y:P,z:0,idx:E,idy:P,res:c,extent2d:u.getTilePrjExtent(E,P,c).convertTo((function(t){return e._prjToPointAtRes(t,c,Xh)})),id:this._getTileId(E,P,0),url:this.getTileUrl(E,P,0+this.options.zoomOffset),offset:[0,0],error:S,children:[]})}return this._rootNodes={status:1,tiles:T,mapWidth:e.width,mapHeight:e.height},this._getRootNodes(t)},i._getRootError=function(){var t=this.getMap(),e=Y(t.getFov()),i=t.width/t.height,n=t.cameraPosition[2],r=n*Math.tan(.5*e),o=r*i,s=Math.sqrt(n*n+r*r+o*o);return t._getFovZ(0)*(s/n)*this.getSpatialReference().getResolution(0)/t.getResolution(0)},i._getPyramidTiles=function(t,e){var i=this.getMap();isNaN(+t)&&(t=this._getTileZoom(i.getZoom()));var n,r=this.getSpatialReference(),o=Math.min(t,this.getMaxZoom()),s=i.projViewMatrix,a=this._getTileFullExtent(),h=this._getTileOffset(0);if(this.options.repeatWorld){var l=i.getContainerExtent(),c=this._convertToExtent2d(l),u=r.getResolution(0)/i.getResolution();if(c.within(a.copy()._scale(u))){var d=this._getRootNodes(h);if(1!==d.status)return console.warn(d.error),this._disablePyramid=!0,this.getTiles(t,e);n=d.tiles.concat()}else{var p=i.getPitch(),f=i.options.cascadePitches[1],m=Math.floor(i._getVisualHeight(f)),g=p<=f?l:new er(0,i.height-m,i.width,i.height);this._visitedTiles=new Jh;var v=this._getTiles(0,g,2,e&&e.getRenderer(),!0),y=this._getRootError();v.tiles.forEach((function(t){t.error=y})),n=v.tiles}}else{var _=this._getRootNodes(h);if(1!==_.status)return console.warn(_.error),this._disablePyramid=!0,this.getTiles(t,e);n=_.tiles.concat()}for(var x=i.getGLRes(),w={0:h},b=this.options.backZoomOffset+t,M=new er,S=[];n.length>0;){var T=n.pop();T.z!==o?(w[T.z+1]||(w[T.z+1]=this._getTileOffset(T.z+1)),this._splitNode(T,s,n,S,M,o,w[T.z+1],e&&e.getRenderer(),x),b<t&&S[S.length-1]!==T&&b===T.z&&S.push(T)):(M._combine(T.extent2d),S.push(T))}return{tileGrids:[{extent:M,count:S.length,tiles:S,offset:[0,0],zoom:t}],count:S.length}},i._splitNode=function(t,e,i,n,r,o,s,a,h){for(var l=this._getTileConfig().tileSystem.scale.y,c=t.z+1,u=this.getSpatialReference(),d=t.x,p=t.y,f=t.extent2d,m=t.idx,g=t.idy,v=f.getWidth()/2*2,y=f.getHeight()/2*2,_=2*f.xmin,x=2*f.ymax,w=2*f.ymin,b=a||this.getRenderer(),M=!1,S=[],T=u.getResolution(c),E=T/h,C=0;C<4;C++){var P=C%2,A=C>>1,L=(d<<1)+P,R=(p<<1)+A,O=(m<<1)+P,D=(g<<1)+A;t.children||(t.children=[]);var I=t.children[C];I||(I=this._getTileId(O,D,c),t.children[C]=I);var k=b.isTileCachedOrLoading(I),z=void 0,F=k&&k.info;if(!F){if(this.tileInfoCache||(this.tileInfoCache=new mn(4*this.options.maxCacheSize)),!(F=this.tileInfoCache.get(I))){if(l<0){var B=_+P*v,N=x-A*y;z=new er(B,N-y,B+v,N)}else{var H=_+P*v,j=w+A*y;z=new er(H,j,H+v,j+y)}F={x:L,y:R,idx:O,idy:D,z:c,extent2d:z,error:t.error/2,res:T,id:I,parentNodeId:t.id,children:[],url:this.getTileUrl(L,R,c+this.options.zoomOffset),offset:s},this.tileInfoCache.add(I,F)}a&&(F.layer=this.getId())}F.error=t.error/2,F.offset[0]=s[0],F.offset[1]=s[1];var G=this._isTileVisible(F,e,E,o,s);if(1===G)M=!0;else{if(-1===G)continue;if(0===G&&c!==o)return n.push(t),void r._combine(t.extent2d)}S.push(F)}c===o?M?i.push.apply(i,S):(n.push(t),r._combine(t.extent2d)):i.push.apply(i,S)},i._isTileVisible=function(t,e,i,n,r){if(0===t.z)return 1;if(!this._isTileInFrustum(t,e,i,r))return-1;var o=this.options.maxError;return H(o)&&(o=1),this._getScreenSpaceError(t,i,n,r)>=o?1:0},i._isTileInFrustum=function(t,e,i,n){if(!this._zScale){var r=this.getMap(),o=r.getGLRes();this._zScale=r.altitudeToPoint(100,o)/100}var s=t.extent2d,a=s.xmin,h=s.ymin,l=s.xmax,c=s.ymax;return ol[0][0]=(a-n[0])*i,ol[0][1]=(h-n[1])*i,ol[0][2]=(t.minAltitude||0)*this._zScale,ol[1][0]=(l-n[0])*i,ol[1][1]=(c-n[1])*i,ol[1][2]=(t.maxAltitude||0)*this._zScale,E(e,ol)},i._getScreenSpaceError=function(t,e,i,n){var r=t.error,o=this.getMap(),s=t.extent2d,a=s.xmin,h=s.ymin,l=s.xmax,c=s.ymax;sl[0]=(a-n[0])*e,sl[1]=(h-n[1])*e,al[0]=(l-n[0])*e,al[1]=(c-n[1])*e;var u,d,p,f,m,g,v=(u=sl,d=al,p=o.cameraPosition,f=Math.max(u[0]-p[0],0,p[0]-d[0]),m=Math.max(u[1]-p[1],0,p[1]-d[1]),g=Math.max(u[2]-p[2],0,p[2]-d[2]),Math.sqrt(f*f+m*m+g*g)),y=Math.max(Math.abs(v),1e-7),_=Math.abs(t.z-i);return r*(o.height<1e3||_<=1?1:_<=2?.7:.605)/y},i._getCascadeTiles=function(t,e){var i=this.getMap(),n=i.getPitch(),r=e&&e.getRenderer(),o=i.getContainerExtent(),s=[],a=0,h=this.getMinZoom(),l=i.options.cascadePitches[0],c=i.options.cascadePitches[1],u=Math.floor(i._getVisualHeight(c)),d=H(t)?this._getTileZoom(i.getZoom()):t;if(this._visitedTiles=new Jh,!H(t)||!this.options.cascadeTiles||n<=l||!H(h)&&d<=h){var p=n<=c?o:new er(0,i.height-u,i.width,i.height),f=this._getTiles(d,p,2,r);return f&&(a+=f.tiles.length,s.push(f)),{tileGrids:s,count:a}}var m=Math.floor(i._getVisualHeight(l)),g=new er(0,i.height-m,i.width,i.height),v=this._getTiles(d,g,0,r);a+=v?v.tiles.length:0,s.push(v);var y,_,x=g.ymin,w=i.getSpatialReference().getZoomDirection(),b=w;if(n>c){d-b<=h&&(b=0);var M=new er(0,i.height-u,i.width,x);a+=(y=this._getTiles(d-b,M,1,r))?y.tiles.length:0,x=M.ymin,b+=4*w,s.push(y)}if(d-b>=h){var S=new er(0,o.ymin,i.width,x);a+=(_=this._getTiles(d-b,S,2,r))?_.tiles.length:0,s.push(_)}return y&&_&&(s[1]=_,s[2]=y),{tileGrids:s,count:a}},i.getTileUrl=function(t,e,i){var n=this.options.urlTemplate,r="";if(this.options.subdomains){var o=this.options.subdomains;if(te(o)){var s=(t+e)%o.length;s<0&&(s=0),r=o[s]}}if(W(n))return n(t,e,i,r);var a={x:t,y:e,z:i,s:r};return this.options.token&&(a.token=this.options.token),this.options.customTags&&N(a,this.options.customTags),n.replace(Kh,(function(t,e){var i=a[e];if(void 0===i)throw new Error("No value provided for variable "+t);return"function"==typeof i&&(i=i(a)),i}))},i.clear=function(){return this._renderer&&this._renderer.clear(),this.tileInfoCache&&this.tileInfoCache.reset(),this.fire("clear"),this},i.toJSON=function(){return{type:this.getJSONType(),id:this.getId(),options:this.config()}},i.getSpatialReference=function(){var t=this.getMap();if(t&&(!this.options.spatialReference||es.equals(this.options.spatialReference,t.options.spatialReference)))return t.getSpatialReference();if(this._sr)return this._sr;var e=this.options.spatialReference;if(V(e)&&!(e=es.getPreset(e)))throw new Error("Unsupported spatial reference: "+this.options.spatialReference+", possible values: "+es.getAllPresets().join());return this._sr=new es(e),this._srMinZoom=this._sr.getMinZoom(),this._srMaxZoom=this._sr.getMaxZoom(),this._hasOwnSR=this._sr.toJSON().projection!==t.getSpatialReference().toJSON().projection,this._sr},i.getMinZoom=function(){return this.getSpatialReference()!==this.getMap().getSpatialReference()?Math.max(t.prototype.getMinZoom.call(this),this._srMinZoom):t.prototype.getMinZoom.call(this)},i.getMaxZoom=function(){return this.getSpatialReference()!==this.getMap().getSpatialReference()?Math.min(t.prototype.getMaxZoom.call(this),this._srMaxZoom):t.prototype.getMaxZoom.call(this)},i._getTileZoom=function(t){if(!this._hasOwnSR){var e=this.getMap().getResolution(t),i=this.getSpatialReference().getResolution(t);t+=Math.log(i/e)*Math.LOG2E}var n=this.options.maxAvailableZoom;return!H(n)&&t>n&&(t=n),G(t)||(t=Math.round(t)),t=Math.max(0,t)},i._getTiles=function(t,e,i,n,r){var o=this.getMap(),s=t,a=o.projViewMatrix,h=o.getResolution(t)/o.getResolution(t-1)==.5;i<2&&(0===i&&h&&(s-=1),a=0===i?o.cascadeFrustumMatrix0:1===i?o.cascadeFrustumMatrix1:o.projViewMatrix);var l=s+this.options.zoomOffset,c=this._getTileOffset(l),u=c[0]||c[1],d={zoom:s,extent:null,offset:c,tiles:[]};if(l<0)return d;if(!(o&&this.isVisible()&&o.width&&o.height))return d;if(!r){var p=this.getMinZoom(),f=this.getMaxZoom();if(!H(p)&&s<p||!H(f)&&s>f)return d}var m=this._getTileConfig();if(!m)return d;var g,v={zoom:c},y=this.getSpatialReference().getResolution(l);g=this._hasOwnSR?o.getGLScale(s):y/o.getGLRes();var _=!this._hasOwnSR&&this.options.repeatWorld,x=this._convertToExtent2d(e),w=this._getMask2DExtent();if(w){var b=w.intersection(x);if(!b)return d;e=b.convertTo((function(t){return o._pointToContainerPoint(t,void 0,0,Xh)}))}var M,S=o._containerPointToPrj(e.getCenter(),$h),T=o._prjToPoint(S,l,tl);M=u?this._project(o._pointToPrj(T._add(c),l,tl),tl):this._project(S,tl);var E=o.getGLScale()/o.getGLScale(l);el.x=x.xmin*E,el.y=x.ymax*E,il.x=x.xmax*E,il.y=x.ymin*E;for(var C=this._project(o._pointToPrj(el._add(c),l,el),el),P=this._project(o._pointToPrj(il._add(c),l,il),il),A=m.getTileIndex(M,y,_),L=m.getTileIndex(C,y,_),R=m.getTileIndex(P,y,_),O=Math.ceil(Math.abs(A.idy-L.idy)),D=Math.ceil(Math.abs(A.idx-L.idx)),I=Math.ceil(Math.abs(A.idy-R.idy)),k=Math.ceil(Math.abs(A.idx-R.idx)),z=(O+I+1)*(D+k+1),F=this.getTileSize(),B=this.getRenderer()||n,N=this._getTileConfig().tileSystem.scale,j=[],G=new er,U=new Bt(0,0),V=-O;V<=I;V++)for(var W=-D,Z=-1/0,q=!1;W>=Z&&W<=k;){var X=m.getNeighorTileIndex(A.idx,A.idy,W,V,y,_);Z===-1/0?W++:W--;var Y=this._getTileId(X.idx,X.idy,s);if(!(X.out||this._visitedTiles&&this._visitedTiles.has(Y))){var J=B&&B.isTileCachedOrLoading(Y);J&&(J=J.info);var Q=void 0;if(J){var K=J.extent2d;U.set(K.xmin,K.ymax),Q=U}else if(this._hasOwnSR){var $=m.getTilePrjNW(X.x,X.y,y);Q=o._prjToPoint(this._unproject($,il),s)}else Q=m.getTilePointNW(X.x,X.y,y);var tt=void 0,et=void 0;if(this._hasOwnSR){var it=void 0;if(this._hasOwnSR){var nt=m.getTilePrjSE(X.x,X.y,y);it=o._prjToPoint(this._unproject(nt,il),s,il)}else it=m.getTilePointSE(X.x,X.y,y);tt=Math.ceil(Math.abs(it.x-Q.x)),et=Math.ceil(Math.abs(it.y-Q.y))}else tt=F.width,et=F.height;var rt=N.x*(X.idx-X.x)*tt,ot=N.y*(X.idy-X.y)*et;J||!rt&&!ot||Q._add(rt,ot);var st=J&&J.extent2d||new er(Q.x,Q.y-et,Q.x+tt,Q.y);if(z<=4||q||this._isTileInExtent(a,st,c,g)){var at=this._hasOwnSR?o._getResolution(s):y;this._visitedTiles&&0===i&&this._visitedTiles.add(Y),h&&0===i?(this._splitTiles(a,j,B,X,s+1,at,st,rt,ot,v,n),G._combine(st)):(J?(J.offset[0]=c[0],J.offset[1]=c[1]):(J={z:s,x:X.x,y:X.y,idx:X.idx,idy:X.idy,extent2d:st,offset:c,id:Y,res:at,url:this.getTileUrl(X.x,X.y,s)},n&&(J.layer=this.getId())),j.push(J),G._combine(st)),Z===-1/0?(Z=W,W=k):q||(q=!0)}}}if(j.length){var ht=o._containerPointToPoint(e.getCenter(),s,Xh)._add(c),lt=new Bt(0,0),ct=new Bt(0,0);j.sort((function(t,e){return lt.set((t.extent2d.xmin+t.extent2d.xmax)/2,(t.extent2d.ymin+t.extent2d.ymax)/2),ct.set((e.extent2d.xmin+e.extent2d.xmax)/2,(e.extent2d.ymin+e.extent2d.ymax)/2),lt.distanceTo(ht)-ct.distanceTo(ht)}))}return{offset:c,zoom:t,extent:G,tiles:j}},i._convertToExtent2d=function(t){var e=this,i=this.getMap();return t.convertTo((function(t){if(t.y>0&&t.y<i.height){var n=(0===t.x?0:1)+t.y;e._coordCache[n]||(e._coordCache[n]=i._containerPointToPoint(t)),e._coordCache[n]}return i._containerPointToPoint(t,void 0,Xh)}))},i._splitTiles=function(t,e,i,n,r,o,s,a,h,l,c){var u=this._getTileConfig().tileSystem.scale.y,d=this.getMap().getGLScale(r),p=nl.set(2*s.xmin,u<0?2*s.ymax:2*s.ymin),f=s.getWidth(),m=s.getHeight(),g=2*n.idx,v=2*n.idy,y=2*n.x,_=2*n.y,x=this._checkAndAddTile(t,i,g,v,y,_,r,o,0,0,f,m,p,d,l,c);x&&e.push(x),(x=this._checkAndAddTile(t,i,g,v,y,_,r,o,0,1,f,m,p,d,l,c))&&e.push(x),(x=this._checkAndAddTile(t,i,g,v,y,_,r,o,1,0,f,m,p,d,l,c))&&e.push(x),(x=this._checkAndAddTile(t,i,g,v,y,_,r,o,1,1,f,m,p,d,l,c))&&e.push(x)},i._checkAndAddTile=function(t,e,i,n,r,o,s,a,h,l,c,u,d,p,f,m){var g=this._getTileId(i+h,n+l,s);if(this._visitedTiles&&this._visitedTiles.has(g))return null;var v=f[s];v||(v=f[s]=this._getTileOffset(s));var y=this._getTileConfig().tileSystem.scale.y,_=new er(d.x+h*c,d.y+y*l*u,d.x+(h+1)*c,d.y+y*(l+1)*u);if(!this._isSplittedTileInExtent(t,_,v,p))return null;var x=a/2,w=e&&e.isTileCachedOrLoading(g);return w?w=w.info:(w={z:s,x:r+h,y:o+l,extent2d:_,id:g,offset:v,res:x,url:this.getTileUrl(r+h,o+l,s+this.options.zoomOffset)},m&&(w.layer=this.getId())),w},i._getTileOffset=function(t){var e=this.options.offset;return W(e)&&(e=e.call(this,t)),j(e)?[e,e]:e||[0,0]},i._getTileId=function(t,e,i,n){return(n||this.getId())+"_"+e+"_"+t+"_"+i},i._project=function(t,e){if(this._hasOwnSR){var i=this.getMap().getProjection();return this.getSpatialReference().getProjection().project(i.unproject(t,e),e)}return t},i._unproject=function(t,e){if(this._hasOwnSR){var i=this.getMap(),n=this.getSpatialReference(),r=i.getProjection(),o=n.getProjection();return r.project(o.unproject(t,e),e)}return t},i._initTileConfig=function(){var t=this.getMap(),e=this.getTileSize(),i=this.getSpatialReference(),n=i.getProjection(),r=i.getFullExtent();this._defaultTileConfig=new qh(t,Wh.getDefault(n),r,e),this.options.hasOwnProperty("tileSystem")&&(this._tileConfig=new qh(t,this.options.tileSystem,r,e)),delete this._rootNodes,delete this._tileFullExtent,delete this._disablePyramid},i._getTileConfig=function(){return this._defaultTileConfig||this._initTileConfig(),this._tileConfig||this._defaultTileConfig},i._bindMap=function(e){var i=e.getBaseLayer();return i===this&&(i.options.hasOwnProperty("forceRenderOnMoving")||this.config({forceRenderOnMoving:!0})),this._onSpatialReferenceChange(),t.prototype._bindMap.apply(this,arguments)},i._isTileInExtent=function(t,e,i,n){var r,o=this.getMap();if(t!==o.projViewMatrix){var s=e.getCenter(rl)._sub(i[0],i[1])._multi(n);ja(hl,s.x,s.y,0);var a=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return s=s||1,t[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/s,t[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,t[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,t}(hl,hl,o.projViewMatrix);r=a[1]<0?o.projViewMatrix:t}else r=o.projViewMatrix;return ol[0][0]=(e.xmin-i[0])*n,ol[0][1]=(e.ymin-i[1])*n,ol[1][0]=(e.xmax-i[0])*n,ol[1][1]=(e.ymax-i[1])*n,E(r,ol)},i._isSplittedTileInExtent=function(t,e,i,n){var r=this.getMap();return ol[0][0]=(e.xmin-i[0])*n,ol[0][1]=(e.ymin-i[1])*n,ol[1][0]=(e.xmax-i[0])*n,ol[1][1]=(e.ymax-i[1])*n,E(r.projViewMatrix,ol)},i.getEvents=function(){return{spatialreferencechange:this._onSpatialReferenceChange}},i._onSpatialReferenceChange=function(){delete this._tileConfig,delete this._defaultTileConfig,delete this._sr,delete this._srMinZoom,delete this._hasOwnSR,delete this._rootNodes,this.tileInfoCache&&this.tileInfoCache.reset();var t=this.getRenderer();t&&t.clear()},i.getPolygonOffsetCount=function(){return 2},i.getPolygonOffset=function(){return this._polygonOffset||0},i.setPolygonOffset=function(t){return this._polygonOffset=t,this},e}(ds);ll.registerJSONType("TileLayer"),ll.mergeOptions(Qh);var cl=new si(256,256),ul="show hide remove";function dl(t){return Array.isArray(t)||(t=[t]),t}var pl=function(t){function e(e,i,n){var r;return(r=t.call(this,e,n)||this).layers=i||[],r._checkChildren(),r.layerMap={},r._groupChildren=[],r}Dt(e,t),e.fromJSON=function(t){if(!t||"GroupTileLayer"!==t.type)return null;var i=t.layers.map((function(t){return ds.fromJSON(t)}));return new e(t.id,i,t.options)};var i=e.prototype;return i.getLayers=function(){return this.layers},i.addLayer=function(t){var e=this;void 0===t&&(t=[]),t=dl(t);var i=this.layers.length;return t.forEach((function(t){t instanceof ll&&(-1!==e.layers.indexOf(t)||e.layerMap[t.getId()]||e.layers.push(t))})),i!==this.layers.length&&(this._sortLayers(),this._refresh(),this._renderLayers()),this},i.removeLayer=function(t){var e=this;void 0===t&&(t=[]),t=dl(t);var i=this.layers.length;return t.forEach((function(t){if(t instanceof ll||(t=e.layerMap[t]),t instanceof ll){var i=e.layers.indexOf(t);i>=0&&(e.layers.splice(i,1),t._doRemove(),t.off(ul,e._onLayerShowHide,e))}})),i!==this.layers.length&&(this._refresh(),this._renderLayers()),this},i.clearLayers=function(){var t=this;return this.layers.forEach((function(e){e._doRemove(),e.off(ul,t._onLayerShowHide,t)})),this.layers=[],this._refresh(),this._renderLayers(),this},i.toJSON=function(){return{type:this.getJSONType(),id:this.getId(),layers:this.layers.map((function(t){return t.toJSON()})),options:this.config()}},i.getTileSize=function(t){var e=this.getLayer(t);return e?e.getTileSize():cl},i.getTiles=function(t,e){for(var i=this.layers,n=[],r=0,o=0,s=i.length;o<s;o++){var a=i[o];if(a&&a.options.visible&&a.isVisible()&&a.getMap()){var h=a.getTiles(t,e||this);h&&0!==h.count&&(r+=h.count,Wt(n,h.tileGrids))}}return{count:r,tileGrids:n}},i.onAdd=function(){this._sortLayers(),this._refresh(),t.prototype.onAdd.call(this)},i.onRemove=function(){var e=this;this.layers.forEach((function(t){t._doRemove(),t.off(ul,e._onLayerShowHide,e)})),this.layerMap={},this._groupChildren=[],t.prototype.onRemove.call(this)},i.getLayer=function(t){return this.getChildLayer(t)},i.getChildLayer=function(t){var e=this.layerMap[t];if(e)return e;for(var i=0;i<this._groupChildren.length;i++){var n=this._groupChildren[i].getChildLayer(t);if(n)return n}return null},i._onLayerShowHide=function(t){var e=t||{},i=e.type,n=e.target;return"remove"===i&&n&&(this.layers.splice(this.layers.indexOf(n),1),n._doRemove(),n.off(ul,this._onLayerShowHide,this),this._refresh()),this._renderLayers(),this},i._renderLayers=function(){var t=this.getRenderer();return t&&t.setToRedraw(),this},i._refresh=function(){var t=this,e=this.getMap();return this._groupChildren=[],this.layerMap={},this.layers.forEach((function(i){t.layerMap[i.getId()]=i,i.getChildLayer&&t._groupChildren.push(i),i.getMap()||i._bindMap(e),i.on(ul,t._onLayerShowHide,t)})),this},i.isVisible=function(){if(!t.prototype.isVisible.call(this))return!1;for(var e=this.layers,i=0,n=e.length;i<n;i++)if(e[i].isVisible())return!0;return!1},i._checkChildren=function(){var t=this,e={};this.layers.forEach((function(i){var n=i.getId();if(e[n])throw new Error("Duplicate child layer id ("+n+") in the GroupTileLayer ("+t.getId()+")");e[n]=1}))},i._sortLayers=function(){this.layers.sort((function(t,e){return t.options.zIndex-e.options.zIndex}))},e}(ll);pl.registerJSONType("GroupTileLayer"),pl.mergeOptions({maxCacheSize:1024});var fl,ml={crs:null,uppercase:!1,detectRetina:!1},gl={service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},vl=function(t){function e(e,i){var n;return n=t.call(this,e)||this,fl||(fl=N({},n.options)),n.wmsParams=N({},gl),n.setOptions(i),n.setZIndex(i.zIndex),Ot.proxy||n._optionsHook(i),n}Dt(e,t);var i=e.prototype;return i._optionsHook=function(t){for(var e in void 0===t&&(t={}),t)"tileSize"===e&&(this._tileSize=null),e in fl||(this.wmsParams[e]=t[e]);var i=this.getTileSize();return this.wmsParams.width=i.width,this.wmsParams.height=i.height,this._wmsVersion=parseFloat(this.wmsParams.version),this},i.onAdd=function(){var e=this.getMap().getDevicePixelRatio(),i=ml.detectRetina?e:1;this.wmsParams.width*=i,this.wmsParams.height*=i;var n=this.options.crs||this.getMap().getProjection().code,r=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[r]=n,t.prototype.onAdd.call(this)},i.getTileUrl=function(e,i,n){var r=this.getSpatialReference().getResolution(n),o=this._getTileConfig().getTilePrjExtent(e,i,r),s=o.getMax(),a=o.getMin(),h=(this._wmsVersion>=1.3&&("EPSG:4326"===this.wmsParams.crs||"EPSG:4490"===this.wmsParams.crs)?[a.y,a.x,s.y,s.x]:[a.x,a.y,s.x,s.y]).join(","),l=t.prototype.getTileUrl.call(this,e,i,n);return l+function(t,e,i){var n=[];for(var r in t)n.push(encodeURIComponent(i?r.toUpperCase():r)+"="+encodeURIComponent(t[r]));return(e&&-1!==e.indexOf("?")?"&":"?")+n.join("&")}(this.wmsParams,l,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+h},i.toJSON=function(){return{type:"WMSTileLayer",id:this.getId(),options:this.config()}},e.fromJSON=function(t){return t&&"WMSTileLayer"===t.type?new e(t.id,t.options):null},e}(ll);vl.registerJSONType("WMSTileLayer"),vl.mergeOptions(ml);var yl=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).options.hasOwnProperty("forceRenderOnMoving")||(n.options.forceRenderOnMoving=!1),n}Dt(e,t);var i=e.prototype;return i.drawTile=function(){},i.toJSON=function(){return{type:"CanvasTileLayer",id:this.getId(),options:this.config()}},e.fromJSON=function(t){return t&&"CanvasTileLayer"===t.type?new e(t.id,t.options):null},e}(ll);function _l(t,e,i){var n=t.createShader(e);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var r=t.getShaderInfoLog(n);throw t.deleteShader(n),new Error("Failed to compile shader: "+r)}return n}function xl(t,e,i){var n=_l(t,t.VERTEX_SHADER,e),r=_l(t,t.FRAGMENT_SHADER,i);if(!n||!r)return null;var o=t.createProgram();return o?(t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),{program:o,vertexShader:n,fragmentShader:r}):null}function wl(t,e,i){if(Array.isArray(i[0])){for(var n=Float32Array.BYTES_PER_ELEMENT,r=0,o=0;o<i.length;o++)r+=i[o][1]||0;for(var s=0,a=0;a<i.length;a++){var h=t.getAttribLocation(e,i[a][0]);if(h<0)throw new Error("Failed to get the storage location of "+i[a][0]);t.vertexAttribPointer(h,i[a][1],t[i[a][2]||"FLOAT"],!1,n*r,n*s),s+=i[a][1]||0,t.enableVertexAttribArray(h)}}else{var l=t.getAttribLocation(e,i[0]);t.vertexAttribPointer(l,i[1],t[i[2]||"FLOAT"],!1,0,0),t.enableVertexAttribArray(l)}}yl.registerJSONType("CanvasTileLayer");var bl="\n attribute vec2 a_position;\n\n attribute vec2 a_texCoord;\n\n uniform mat4 u_matrix;\n\n varying vec2 v_texCoord;\n\n void main() {\n gl_Position = u_matrix * vec4(a_position, 0., 1.);\n\n v_texCoord = a_texCoord;\n }\n ",Ml="\n precision mediump float;\n\n uniform sampler2D u_image;\n\n uniform float u_opacity;\n uniform float u_debug_line;\n\n varying vec2 v_texCoord;\n\n void main() {\n if (u_debug_line == 1.) {\n gl_FragColor = vec4(0., 1., 0., 1.);\n } else {\n gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;\n }\n }\n ",Sl=[0,0],Tl=[0,0,0],El=new Array(16),Cl=new Bt(20,20),Pl=function(t){var e,i=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.drawGLImage=function(t,e,i,n,r,o,s,a){this.gl.program!==this.program&&this.useProgram(this.program);var h=this.gl;if(this.loadTexture(t),this.canvas.gl&&this.canvas.gl.wrap){var l=this.layer&&this.layer.options.opacity;H(l)&&(l=1),s*=l}Tl[0]=e||0,Tl[1]=i||0;var c=Na(El);ka(c,c,Tl),za(c,c,[o,o,1]),Fa(c,this.getMap().projViewMatrix,c),h.uniformMatrix4fv(this.program.u_matrix,!1,c),h.uniform1f(this.program.u_opacity,s),h.uniform1f(this.program.u_debug_line,0);var u=t.glBuffer;!u||u.width===n&&u.height===r||(this.saveImageBuffer(u),delete t.glBuffer),t.glBuffer?h.bindBuffer(h.ARRAY_BUFFER,u):t.glBuffer=this.bufferTileData(0,0,n,r),Sl[0]="a_position",Sl[1]=2,Sl[2]=t.glBuffer.type,this.enableVertexAttrib(Sl),h.drawArrays(h.TRIANGLE_STRIP,0,4),a&&this.drawDebug(c,0,0,n,r,a)},i.drawDebug=function(t,e,i,n,r,o){var s=this.gl;s.disable(s.DEPTH_TEST),s.bindBuffer(s.ARRAY_BUFFER,this._debugBuffer),this.enableVertexAttrib(["a_position",2,"FLOAT"]),s.bufferData(s.ARRAY_BUFFER,new Float32Array([e,i,e+n,i,e+n,i-r,e,i-r,e,i]),s.DYNAMIC_DRAW),s.uniformMatrix4fv(this.program.u_matrix,!1,t),s.uniform1f(this.program.u_opacity,1),s.uniform1f(this.program.u_debug_line,1),s.drawArrays(s.LINE_STRIP,0,5);var a=this._debugInfoCanvas;if(!a){var h=this.getMap().getDevicePixelRatio()>1?2:1;(a=this._debugInfoCanvas=document.createElement("canvas")).width=256*h,a.height=32*h;var l=a.getContext("2d");l.font="20px monospace",l.scale(h,h)}var c=a.getContext("2d");c.clearRect(0,0,a.width,a.height);var u=this.layer.options.debugOutline;wn.fillText(c,o,Cl,u),this.loadTexture(a),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,a);var d=e,p=e+(n=256),f=i-r+32,m=i-r;s.bufferData(s.ARRAY_BUFFER,this.set8(d,f,d,m,p,f,p,m),s.DYNAMIC_DRAW),s.uniform1f(this.program.u_debug_line,0),s.drawArrays(s.TRIANGLE_STRIP,0,4),s.enable(s.DEPTH_TEST)},i.bufferTileData=function(t,e,i,n,r){var o,s=t,a=t+i,h=e,l=e-n;o=G(s)&&G(a)&&G(h)&&G(l)?this.set8Int(s,h,s,l,a,h,a,l):this.set8(s,h,s,l,a,h,a,l);var c=this.loadImageBuffer(o,r);return c.width=i,c.height=n,c.type=o instanceof Int16Array?"SHORT":"FLOAT",c},i.drawTinImage=function(t,e,i,n,r){var o=this.gl;this.loadTexture(t),o.uniformMatrix4fv(this.program.u_matrix,!1,this.getMap().projViewMatrix),o.uniform1f(this.program.u_opacity,r),o.bindBuffer(o.ARRAY_BUFFER,this.posBuffer),this.enableVertexAttrib(["a_position",3]),o.bufferData(o.ARRAY_BUFFER,new Float32Array(e),o.DYNAMIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,this.texBuffer),this.enableVertexAttrib(["a_texCoord",2]),o.bufferData(o.ARRAY_BUFFER,new Float32Array(i),o.DYNAMIC_DRAW),o.bufferData(o.ELEMENT_ARRAY_BUFFER,new Uint16Array(n),o.DYNAMIC_DRAW),o.drawElements(o.TRIANGLES,n.length,o.UNSIGNED_SHORT,0)},i.createCanvas2=function(){this.canvas2=wn.createCanvas(this.canvas.width,this.canvas.height)},i.createGLContext=function(){this.canvas.gl&&this.canvas.gl.wrap?this.gl=this.canvas.gl.wrap():this.gl=function(t,e){for(var i={alpha:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:!1},n=["webgl","experimental-webgl"],r=null,o=0;o<n.length;++o){try{r=t.getContext(n[o],e||i)}catch(t){}if(r)break}return r}(this.canvas2||this.canvas,this.layer.options.glOptions);var t=this.gl;t.clearColor(0,0,0,0),t.enable(t.DEPTH_TEST),t.enable(t.STENCIL_TEST),t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),this.program=this.createProgram(bl,this.layer.options.fragmentShader||Ml),this._debugBuffer=this.createBuffer(),this.useProgram(this.program),this.texBuffer=this.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.texBuffer),this.enableVertexAttrib(["a_texCoord",2,"UNSIGNED_BYTE"]),t.bufferData(t.ARRAY_BUFFER,new Uint8Array([0,0,0,1,1,0,1,1]),t.STATIC_DRAW),this.enableSampler("u_image"),t.activeTexture(t.TEXTURE0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)},i.resizeGLCanvas=function(){this.gl&&this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.canvas2&&(this.canvas2.width===this.canvas.width&&this.canvas2.height===this.canvas.height||(this.canvas2.width=this.canvas.width,this.canvas2.height=this.canvas.height))},i.clearGLCanvas=function(){this.gl&&(this.gl.clearStencil(255),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.STENCIL_BUFFER_BIT)),this.gl.wrap||this.gl.clear(this.gl.DEPTH_BUFFER_BIT)},i.disposeImage=function(t){t&&(t.texture&&this.saveTexture(t.texture),t.glBuffer&&this.saveImageBuffer(t.glBuffer),delete t.texture,delete t.glBuffer)},i._createTexture=function(t){var e=this.gl,i=this.getTexture()||e.createTexture();return e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),G(Jt(t.width))&&G(Jt(t.width))&&e.generateMipmap(e.TEXTURE_2D),i},i.getTexture=function(){this._textures||(this._textures=[]);var t=this._textures;return t&&t.length>0?t.pop():null},i.saveTexture=function(t){this._textures.push(t)},i.loadTexture=function(t){var e=this.gl,i=t.texture;return i||(i=this._createTexture(t),t.texture=i),e.bindTexture(e.TEXTURE_2D,i),i},i.getImageBuffer=function(){this._imageBuffers||(this._imageBuffers=[]);var t=this._imageBuffers;return t&&t.length>0?t.pop():null},i.saveImageBuffer=function(t){this._imageBuffers||(this._imageBuffers=[]),this._imageBuffers.push(t)},i.loadImageBuffer=function(t,e){var i=this.gl,n=e||this.createImageBuffer();return i.bindBuffer(i.ARRAY_BUFFER,n),i.bufferData(i.ARRAY_BUFFER,t,i.STATIC_DRAW),n},i.createImageBuffer=function(){return this.getImageBuffer()||this.createBuffer()},i.removeGLCanvas=function(){var t=this.gl;if(t){if(this._debugBuffer&&(t.deleteBuffer(this._debugBuffer),delete this._debugBuffer),this._buffers&&(this._buffers.forEach((function(e){t.deleteBuffer(e)})),delete this._buffers),this._textures&&(this._textures.forEach((function(e){return t.deleteTexture(e)})),delete this._textures),this._debugInfoCanvas){var e=this._debugInfoCanvas.texture;e&&t.deleteTexture(e),delete this._debugInfoCanvas.texture,delete this._debugInfoCanvas}var i=t.program;t.deleteShader(i.fragmentShader),t.deleteShader(i.vertexShader),t.deleteProgram(i),delete this.gl,delete this.canvas2}},i.createBuffer=function(){var t=this.gl.createBuffer();if(!t)throw new Error("Failed to create the buffer object");return this._buffers||(this._buffers=[]),this._buffers.push(t),t},i.enableVertexAttrib=function(t){wl(this.gl,this.gl.program,t)},i.createProgram=function(t,e){for(var i=this.gl,n=xl(i,t,e),r=n.program,o=n.vertexShader,s=n.fragmentShader,a=i.getProgramParameter(r,35718),h=[],l=0;l<a;++l){var c=i.getActiveUniform(r,l);h.push(c.name)}return r.vertexShader=o,r.fragmentShader=s,this._initUniforms(r,h),r},i.useProgram=function(t){var e=this.gl;return e.useProgram(t),e.program=t,this},i.enableSampler=function(t,e){var i=this.gl,n=this._getUniform(i.program,t);return e||(e=0),i.uniform1i(n,e),n},i._initUniforms=function(t,e){for(var i=0;i<e.length;i++){var n=e[i],r=e[i],o=n.indexOf("[");o>=0&&(n=n.substring(0,o),Q||(r=r.substring(0,o))),t[n]=this._getUniform(t,r)}},i._getUniform=function(t,e){var i=this.gl.getUniformLocation(t,e);if(!i)throw new Error("Failed to get the storage location of "+e);return i},e}(t);return N(i.prototype,{set8:(e=Ot.ie9?null:new Float32Array(8),function(t,i,n,r,o,s,a,h){return e[0]=t,e[1]=i,e[2]=n,e[3]=r,e[4]=o,e[5]=s,e[6]=a,e[7]=h,e}),set8Int:function(){var t=Ot.ie9?null:new Int16Array(8);return function(e,i,n,r,o,s,a,h){return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t[4]=o,t[5]=s,t[6]=a,t[7]=h,t}}()}),i},Al={renderer:Ot.webgl?"gl":"canvas",crossOrigin:null},Ll=new Bt(0,0),Rl=function(t){function e(e,i,n){var r;return!i||Array.isArray(i)||i.url||(n=i,i=null),(r=t.call(this,e,n)||this)._images=i,r}Dt(e,t);var i=e.prototype;return i.onAdd=function(){this._prepareImages(this._images)},i.setImages=function(t){return this._images=t,this._prepareImages(t),this},i.getImages=function(){return this._images},i._prepareImages=function(t){t=t||[],Array.isArray(t)||(t=[t]);var e=this.getMap(),i=e.getGLRes();this._imageData=t.map((function(t){var n=new tr(t.extent);return N({},t,{extent:n,extent2d:n.convertTo((function(t){return e.coordToPointAtRes(t,i)}))})})),this._images=t;var n=this.getRenderer();n&&n.refreshImages()},e}(ds);Rl.mergeOptions(Al);var Ol=[],Dl=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.isDrawable=function(){return!this.getMap().getPitch()||(console&&console.warn("ImageLayer with canvas renderer can't be pitched, use gl renderer ('renderer' : 'gl') instead."),!1)},i.checkResources=function(){var t=this;if(this._imageLoaded)return Ol;var e=this.layer._imageData.map((function(t){return[t.url,null,null]}));if(this.resources){var i=[],n=new jr;e.forEach((function(e){if(t.resources.isResourceLoaded(e)){var r=t.resources.getImage(e);n.addResource(e,r)}else i.push(e)})),this.resources.forEach((function(e,i){n.isResourceLoaded(e)||t.retireImage(i.image)})),this.resources=n,e=i}return this._imageLoaded=!0,e},i.retireImage=function(t){t.close&&t.close()},i.refreshImages=function(){this._imageLoaded=!1,this.setToRedraw()},i.draw=function(){this.isDrawable()&&(this.prepareCanvas(),this._painted=!1,this._drawImages(),this.completeRender())},i._drawImages=function(){var t=this.layer._imageData,e=this.getMap(),i=e._get2DExtentAtRes(e.getGLRes());if(t&&t.length)for(var n=0;n<t.length;n++){var r=t[n].extent2d,o=this.resources&&this.resources.getImage(t[n].url);o&&i.intersects(r)&&(this._painted=!0,this._drawImage(o,r,t[n].opacity||1))}},i._drawImage=function(t,e,i){var n=0,r=this.context;i<1&&(n=r.globalAlpha,r.globalAlpha=i);var o=this.getMap(),s=Ll.set(e.xmin,e.ymax),a=o._pointAtResToContainerPoint(s,o.getGLRes()),h=a.x,l=a.y,c=o.getBearing();c&&(r.save(),r.translate(h,l),c&&r.rotate(-c*Math.PI/180),h=l=0);var u=o.getGLScale();r.drawImage(t,h,l,e.getWidth()/u,e.getHeight()/u),c&&r.restore(),n&&(r.globalAlpha=n)},i.drawOnInteracting=function(){this.draw()},e}(Hr),Il=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.isDrawable=function(){return!0},i._drawImage=function(t,e,i){this.drawGLImage(t,e.xmin,e.ymax,e.getWidth(),e.getHeight(),1,i)},i.createContext=function(){this.createGLContext()},i.resizeCanvas=function(e){this.canvas&&(t.prototype.resizeCanvas.call(this,e),this.resizeGLCanvas())},i.clearCanvas=function(){this.canvas&&(t.prototype.clearCanvas.call(this),this.clearGLCanvas())},i.retireImage=function(t){t.close&&t.close(),this.disposeImage(t)},i.onRemove=function(){this.removeGLCanvas(),t.prototype.onRemove.call(this)},e}(Pl(Dl));Rl.registerRenderer("canvas",Dl),Rl.registerRenderer("gl",Il);var kl=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.getPrepareParams=function(){return[]},i.getDrawParams=function(){return[]},i.onCanvasCreate=function(){this.canvas&&this.layer.options.doubleBuffer&&(this.buffer=wn.createCanvas(this.canvas.width,this.canvas.height,this.getMap().CanvasClass))},i.needToRedraw=function(){return!!this.layer.options.animation||!(this.getMap().isInteracting()&&!this.layer.drawOnInteracting)&&t.prototype.needToRedraw.call(this)},i.draw=function(){this.prepareCanvas(),this.prepareDrawContext(),this._drawLayer.apply(this,arguments)},i.drawOnInteracting=function(){this._drawLayerOnInteracting.apply(this,arguments)},i.getCanvasImage=function(){var e=t.prototype.getCanvasImage.call(this);if(e&&e.image&&this.layer.options.doubleBuffer){var i=e.image;this.buffer.width===i.width&&this.buffer.height===i.height||(this.buffer.width=i.width,this.buffer.height=i.height);var n=this.buffer.getContext("2d"),r=this.layer.doubleBuffer(n,this.context);(void 0===r||r)&&(wn.image(n,i,0,0),e.image=this.buffer)}return e},i.remove=function(){return delete this._drawContext,t.prototype.remove.call(this)},i.onZoomStart=function(e){this.layer.onZoomStart(e),t.prototype.onZoomStart.call(this,e)},i.onZooming=function(e){this.layer.onZooming(e),t.prototype.onZooming.call(this,e)},i.onZoomEnd=function(e){this.layer.onZoomEnd(e),t.prototype.onZoomEnd.call(this,e)},i.onMoveStart=function(e){this.layer.onMoveStart(e),t.prototype.onMoveStart.call(this,e)},i.onMoving=function(e){this.layer.onMoving(e),t.prototype.onMoving.call(this,e)},i.onMoveEnd=function(e){this.layer.onMoveEnd(e),t.prototype.onMoveEnd.call(this,e)},i.onResize=function(e){this.layer.onResize(e),t.prototype.onResize.call(this,e)},i.prepareDrawContext=function(){if(!this._predrawed){var t=zl(this.getPrepareParams());this._drawContext=this.layer.prepareToDraw.apply(this.layer,[this.context].concat(t)),this._drawContext||(this._drawContext=[]),Array.isArray(this._drawContext)||(this._drawContext=[this._drawContext]),this._predrawed=!0}},i._prepareDrawParams=function(){if(!this.getMap())return null;var t=this.getViewExtent();if(t.maskExtent&&!t.extent.intersects(t.maskExtent))return this.completeRender(),null;var e=[this.context,t],i=zl(this.getDrawParams());return e.push.apply(e,i),e.push.apply(e,this._drawContext),e},i._drawLayer=function(){var t=this._prepareDrawParams();if(t){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];this.layer.draw.apply(this.layer,t.concat(i)),this.completeRender()}},i._drawLayerOnInteracting=function(){if(this.layer.drawOnInteracting){var t=this._prepareDrawParams();if(t){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];this.layer.drawOnInteracting.apply(this.layer,t.concat(i)),this.completeRender()}}},e}(Hr);function zl(t){return t||(t=[]),Array.isArray(t)||(t=[t]),t}var Fl=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.isCanvasRender=function(){return!0},i.prepareToDraw=function(){},i.draw=function(){},i.redraw=function(){return this._getRenderer()&&this._getRenderer().setToRedraw(),this},i.play=function(){return this.config("animation",!0),this},i.pause=function(){return this.config("animation",!1),this},i.isPlaying=function(){return this.options.animation},i.clearCanvas=function(){return this._getRenderer()&&this._getRenderer().clearCanvas(),this},i.requestMapToRender=function(){return this._getRenderer()&&this._getRenderer().requestMapToRender(),this},i.completeRender=function(){return this._getRenderer()&&this._getRenderer().completeRender(),this},i.onCanvasCreate=function(){return this},i.onZoomStart=function(){},i.onZooming=function(){},i.onZoomEnd=function(){},i.onMoveStart=function(){},i.onMoving=function(){},i.onMoveEnd=function(){},i.onResize=function(){},i.doubleBuffer=function(t){return t.clearRect(0,0,t.canvas.width,t.canvas.height),this},e}(ds);Fl.mergeOptions({doubleBuffer:!1,animation:!1}),Fl.registerRenderer("canvas",kl);var Bl=new Bt(0,0),Nl=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.getParticles=function(){},i.draw=function(t,e){var i=this.getParticles(B());if(i&&0!==i.length){var n=this.getMap(),r=e.extent;e.maskExtent&&(r=e.extent.intersection(e.maskExtent)),r=r.convertTo((function(t){return n._pointToContainerPoint(t,void 0,0,Bl)}));for(var o=2*Math.PI,s=0,a=i.length;s<a;s++){var h=i[s].point;if(r.contains(h)){var l=i[s].color||this.options.lineColor||"#fff",c=i[s].r;t.fillStyle!==l&&(t.fillStyle=l),c<=2?t.fillRect(h.x-c/2,h.y-c/2,c,c):(t.beginPath(),t.arc(h.x,h.y,c/2,0,o),t.fill())}}this._fillCanvas(t)}else{this._getRenderer()&&(this._getRenderer()._shouldClear=!0)}},i._fillCanvas=function(t){var e=t.globalCompositeOperation;t.globalCompositeOperation="destination-out";var i=this.options.trail||30;t.fillStyle="rgba(0, 0, 0, "+1/i+")",t.fillRect(0,0,t.canvas.width,t.canvas.height),t.globalCompositeOperation=e},e}(Fl);Nl.mergeOptions({animation:!0}),Nl.registerRenderer("canvas",function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.draw=function(){this.canvas&&this.layer.options.animation&&!this._shouldClear||(this.prepareCanvas(),this._shouldClear=!1),this.prepareDrawContext(),this._drawLayer()},i.drawOnInteracting=function(){this.draw(),this._shouldClear=!1},i.onSkipDrawOnInteracting=function(){this._shouldClear=!0},e}(kl));var Hl,jl,Gl=new jr,Ul=function(t){function e(e,i,n){var r;(r=t.call(this,n)||this).target=e,e.once("remove",r.delete,It(It(r)));var o=r.options.symbol,s=o.markerLineWidth||1;return r.w=o.markerWidth+s,r.h=o.markerHeight+s,r.opacity=H(o.opacity)?1:o.opacity,r.map=i,r.events=n.events,r._fetchImage(),r.addTo(i),r}Dt(e,t);var i=e.prototype;return i.getCursor=function(){return this.options.cursor||"default"},i._fetchImage=function(){var t=this.map,e=this.options.symbol,i=e.markerFile;this.url=i||Ti(e);var n=Gl.getImage(this.url);if(!n){var r=this.w,o=this.h;if(i)(n=new Image).onload=function(){var e=t.getRenderer();e&&e.setToRedraw()},n.src=this.url;else{var s=document.createElement("canvas");s.width=r,s.height=o,n=xo(s.getContext("2d"),{x:r/2,y:o/2},e,Gl)}Gl.addResource([this.url,r,o],n)}Gl.login(this.url),this._img=n},i.setContainerPoint=function(t){this._point=t,this._point._sub(this.w/2,this.h/2)},i.getContainerPoint=function(){return this._point.add(this.w/2,this.h/2)},i.offset=function(t){this._point._add(t)},i.render=function(t){if(!this._img)return!1;var e=this.options.symbol,i=e.markerDx||0,n=e.markerDy||0,r=this.map,o=this._point,s=o.x,a=o.y,h=this.w,l=this.h;if(s+h>0&&s<r.width&&a+l>0&&a<r.height){var c=r.getDevicePixelRatio();return t.globalAlpha=this.opacity,t.drawImage(this._img,Math.round((s+i)*c),Math.round((a+n)*c),Math.round(h*c),Math.round(l*c)),!0}return!1},i.delete=function(){if(this.map){var t=this.map.getRenderer();t&&t.removeTopElement(this)}Gl.logout(this.url),this._dragger&&(this._dragger.disable(),delete this._dragger),delete this.map},i.hitTest=function(t){var e=this.options.symbol,i=e.markerDx||0,n=e.markerDy||0,r=this.w,o=this.h,s=this._point.x+i,a=this._point.y+n;return t.x>=s&&t.x<=s+r&&t.y>=a&&t.y<=a+o},i.addTo=function(t){this.map=t,t.getRenderer().addTopElement(this)},i.onEvent=function(t){this.fire(t.type,t)},i.mousedown=function(t){var e=t.target,i=this.options.cursor;i&&e.setCursor(i),this.onDragstart(t)},i.onDragstart=function(t){var e=t.containerPoint,i=t.target,n=i._panels.mapWrapper||i._containerDOM,r=this._dragger=new Nn(n);r.on("dragging",this.onDragging,this).on("mouseup",this.onDragend,this).enable(),r.type="handle",r.onMouseDown(t.domEvent),Hl=e.x,jl=e.y,this.fire("dragstart",{containerPoint:e})},i.onDragging=function(t){if(this._dragger){var e=this.map,i=Qi(t.domEvent,e._containerDOM),n={x:i.x-Hl,y:i.y-jl},r=e.containerPointToCoord(new Bt(Hl,jl)),o=e.containerPointToCoord(i);Hl=i.x,jl=i.y,this.offset(n),this.fire("dragging",{containerPoint:i,coordOffset:o._sub(r)})}},i.onDragend=function(t){if(this._dragger){var e=this.map;e.resetCursor();var i=Qi(t.domEvent,e._containerDOM),n={x:i.x-Hl,y:i.y-jl};this.offset(n),this._dragger.disable(),delete this._dragger,this.fire("dragend",{containerPoint:i})}},e}(Cn(Ln)),Vl=function(){function t(t,e){this.target=t,t.once("remove",this.delete,this),this.map=e,this.addTo(e)}var e=t.prototype;return e.setPoints=function(t){this.points=t;var e=t.map((function(t){return t.x})),i=t.map((function(t){return t.y}));this.xmin=Math.min.apply(Math,e),this.xmax=Math.max.apply(Math,e),this.ymin=Math.min.apply(Math,i),this.ymax=Math.max.apply(Math,i)},e.hitTest=function(){return!1},e.render=function(t){var e=this.map;if(!(this.xmax<=0||this.xmin>=e.width||this.ymax<=0||this.ymin>=e.height)){var i=e.getDevicePixelRatio();t.lineWidth=1,t.strokeStyle="#000",t.globalAlpha=1,t.beginPath();var n=this.points;t.moveTo(o(n[0].x),o(n[0].y));for(var r=1;r<this.points.length;r++)t.lineTo(o(n[r].x),o(n[r].y));t.closePath(),t.stroke()}function o(t){return Math.round(t)*i+.5}},e.addTo=function(t){this.map=t,t.getRenderer().addTopElement(this)},e.delete=function(){if(this.map){var t=this.map.getRenderer();t&&t.removeTopElement(this)}},t}(),Wl=L+"_edit_stage_";function Zl(t,e){return{markerType:t,markerFill:"#fff",markerLineColor:"#000",markerLineWidth:2,markerWidth:10,markerHeight:10,opacity:e}}var ql={fixAspectRatio:!1,symbol:null,removeVertexOn:"contextmenu",centerHandleSymbol:Zl("ellipse",1),vertexHandleSymbol:Zl("square",1),newVertexHandleSymbol:Zl("square",.4)},Xl=function(t){function e(e,i){var n;return(n=t.call(this,i)||this)._geometry=e,n._geometry?n:It(n)}Dt(e,t);var i=e.prototype;return i.getMap=function(){return this._geometry.getMap()},i.prepare=function(){var t=this.getMap();t&&(t.on("drawtopstart",this._refresh,this),this.options.symbol&&(this._originalSymbol=this._geometry.getSymbol(),this._geometry.setSymbol(this.options.symbol)),this._prepareEditStageLayer())},i._prepareEditStageLayer=function(){var t=this._geometry.getLayer();if("canvas"===t.options.renderer){var e=this.getMap(),i=Gt(),n=Wl+i+"_shadow";if(this._shadowLayer=e.getLayer(n),!this._shadowLayer){var r=t.constructor;this._shadowLayer=new r(n),e.addLayer(this._shadowLayer)}}},i.start=function(){if(this._geometry&&this._geometry.getMap()&&!this._geometry.editing){this.editing=!0,this.prepare();var t,e=this._geometry,i="canvas"===this._geometry.getLayer().options.renderer;this._geometryDraggble=e.options.draggable,i?(e.config("draggable",!1),(t=e.copy()).setSymbol(e._getInternalSymbol()),t.copyEventListeners(e),e._getParent()&&t.copyEventListeners(e._getParent()),t._setEventTarget(e),t.setId(null).config({draggable:!1}),this._shadow=t,e.hide()):e instanceof Vs&&e.config("draggable",!0),this._switchGeometryEvents("on"),(e instanceof Vs||e instanceof na||e instanceof oa||e instanceof ra)&&this._createOrRefreshOutline(),this._shadowLayer&&this._shadowLayer.bringToFront().addGeometry(t),e instanceof Vs?t&&(t.config("draggable",!0),t.on("dragend",this._onMarkerDragEnd,this)):this._createCenterHandle(),e instanceof Vs&&!1!==this.options.resize?this.createMarkerEditor():e instanceof na?this.createCircleEditor():e instanceof oa||e instanceof ra?this.createEllipseOrRectEditor():e instanceof sa||(e instanceof js||e instanceof Zs)&&this.createPolygonEditor()}},i.stop=function(){delete this._history,delete this._historyPointer,delete this._editOutline,this._switchGeometryEvents("off"),this.getMap()?(this._geometry.config("draggable",this._geometryDraggble),this._shadow&&(delete this._shadow,delete this._geometryDraggble,this._geometry.show()),this._shadowLayer&&(this._shadowLayer.remove(),delete this._shadowLayer),this._refreshHooks=[],this.options.symbol&&(this._geometry.setSymbol(this._originalSymbol),delete this._originalSymbol),this.editing=!1,this.fire("remove")):this.fire("remove")},i.isEditing=function(){return!H(this.editing)&&this.editing},i._getGeometryEvents=function(){return{symbolchange:this._onGeoSymbolChange,dragstart:this._onDragStart,dragend:this._onDragEnd,"positionchange shapechange":this._exeAndReset}},i._switchGeometryEvents=function(t){if(this._geometry){var e=this._getGeometryEvents();for(var i in e)this._geometry[t](i,e[i],this)}},i._onGeoSymbolChange=function(t){this._shadow&&this._shadow.setSymbol(t.target._getInternalSymbol())},i._onMarkerDragEnd=function(){this._update("setCoordinates",this._shadow.getCoordinates().toArray())},i._createOrRefreshOutline=function(){var t=this._geometry,e=this._editOutline;e||(this._editOutline=new Vl(this,this.getMap()),this._addRefreshHook(this._createOrRefreshOutline));var i=this._editOutline.points;if(t instanceof Vs)this._editOutline.setPoints(t.getContainerExtent().toArray(i));else{var n=this.getMap();(i=t._getPrjExtent().toArray(i)).forEach((function(t){return n._prjToContainerPoint(t,null,t)})),this._editOutline.setPoints(i)}return e},i._createCenterHandle=function(){var t,e=this,i=this.getMap(),n=this.options.centerHandleSymbol,r=i.coordToContainerPoint(this._geometry.getCenter()),o=this.createHandle(r,{symbol:n,cursor:"move",onDown:function(){if(e._shadow){var i=Ei((t=e._shadow.copy())._getInternalSymbol(),.5);t.setSymbol(i).addTo(e._geometry.getLayer())}},onMove:function(i){var n=i.coordOffset;t?t.translate(n):e._geometry.translate(n)},onUp:function(){var i=t||e._geometry;e._update("setCoordinates",Hn.toNumberArrays(i.getCoordinates())),t&&t.remove()}});this._addRefreshHook((function(){var t=e._geometry.getCenter();o.setContainerPoint(i.coordToContainerPoint(t))}))},i._createHandleInstance=function(t,e){var i=this.getMap(),n=ke(e.symbol,(function(){return[i.getZoom(),{"{bearing}":i.getBearing(),"{pitch}":i.getPitch(),"{zoom}":i.getZoom()}]})),r=this.options.removeVertexOn,o=new Ul(this,i,{symbol:n,cursor:e.cursor,events:r});return o.setContainerPoint(t),o},i.createHandle=function(t,e){e||(e={});var i=this._createHandleInstance(t,e),n=this;return i.on("dragstart",(function(t){return this._updating=!0,e.onDown&&(this._geometry.fire("handledragstart"),e.onDown.call(n,t.containerPoint,t)),!1}),this),i.on("dragging",(function(t){return n._hideContext(),e.onMove&&(this._geometry.fire("handledragging"),e.onMove.call(n,t)),!1}),this),i.on("dragend",(function(t){return e.onUp&&(this._geometry.fire("handledragend"),e.onUp.call(n,t)),this._updating=!1,!1}),this),e.onRefresh&&(i.refresh=e.onRefresh),i},i._createResizeHandles=function(t,e,i){var n=this,r=["nw-resize","n-resize","ne-resize","w-resize","e-resize","sw-resize","s-resize","se-resize"],o=[null,"y",null,"x","x",null,"y",null],s=this._geometry,a=s instanceof Vs;t||(t=[]);var h=this,l=[],c={},u=this.getMap(),d=this.options.vertexHandleSymbol,p=function(){for(var p=function(){if(a){var t=s.getContainerExtent();return[new Bt(t.xmin,t.ymin),new Bt((t.xmax+t.xmin)/2,t.ymin),new Bt(t.xmax,t.ymin),new Bt(t.xmin,(t.ymin+t.ymax)/2),new Bt(t.xmax,(t.ymin+t.ymax)/2),new Bt(t.xmin,t.ymax),new Bt((t.xmax+t.xmin)/2,t.ymax),new Bt(t.xmax,t.ymax)]}var e=s._getPrjExtent();return[new Bt(e.xmin,e.ymax),new Bt((e.xmax+e.xmin)/2,e.ymax),new Bt(e.xmax,e.ymax),new Bt(e.xmin,(e.ymax+e.ymin)/2),new Bt(e.xmax,(e.ymax+e.ymin)/2),new Bt(e.xmin,e.ymin),new Bt((e.xmax+e.xmin)/2,e.ymin),new Bt(e.xmax,e.ymin)]}(),f=function(f){if(Array.isArray(t)&&t.some((function(t){return t===f})))return"continue";var m,g=p[f],v=a?g:u._prjToContainerPoint(g);if(l.length<p.length-t.length){var y=n.createHandle(v,{symbol:d,cursor:r[f],axis:o[f],onMove:(m=f,function(t){h._updating=!0,e(t.containerPoint,m),s.fire("resizing")}),onUp:function(){h._updating=!1,i()}});c[f]=l.length,l.push(y)}else l[c[f]].setContainerPoint(v)},m=0;m<p.length;m++)f(m)};return p(),this._addRefreshHook(p),l},i.createMarkerEditor=function(){var t=this,e=this._shadow||this._geometry,i=this.getMap();if(e._canEdit()){this._history||this._recordHistory(p());var n=e._getInternalSymbol(),r=new Bt(0,0);j(n.markerDx)&&(r.x=n.markerDx),j(n.markerDy)&&(r.y=n.markerDy);var o=null,s="middle",a="middle";if(Fo.test(n)){var h=n.markerType;"pin"===h||"pie"===h||"bar"===h?(o=[5,6,7],s="bottom"):"rectangle"===h&&(o=[0,1,2,3,5],s="top",a="left")}else(Ro.test(n)||Bo.test(n))&&(s="bottom",o=[5,6,7]);var l,c=[2,1,2,0,0,2,1,2];if(this.options.fixAspectRatio){var u=e.getSize();l=u.width/u.height}var d=this._createResizeHandles(o,(function(n,h){if(o&&o.indexOf(h)>=0){var u=i.containerPointToCoordinate(n.sub(r)),p=e.getCoordinates();u.x=p.x,e.setCoordinates(u),t._updateCoordFromShadow(!0),n=d[d.length-1-h].getContainerPoint()}var f=i.coordToContainerPoint(e.getCoordinates()).add(r),m=e._getInternalSymbol(),g=n.sub(f);"bottom"===s&&n.y>f.y&&(g.y=0);var v="middle"===s?2:1,y="left"===a?1:2,_=Math.abs(g.x)*y,x=Math.abs(g.y)*v;l&&(x=(_=Math.max(_,x*l))/l);var w=c[h];e instanceof fa?((l||0===w||2===w)&&(e.setWidth(_),e!==t._geometry&&t._geometry.setWidth(_)),(l||1===w||2===w)&&(e.setHeight(x),e!==t._geometry&&t._geometry.setHeight(x))):((l||0===w||2===w)&&(m.markerWidth=Math.min(_,t._geometry.options.maxMarkerWidth||1/0)),(l||1===w||2===w)&&(m.markerHeight=Math.min(x,t._geometry.options.maxMarkerHeight||1/0)),e.setSymbol(m),e!==t._geometry&&t._geometry.setSymbol(m))}),(function(){t._update(p())}))}else console&&console.warn("A marker can't be resized with symbol:",e.getSymbol());function p(){var t=[["setCoordinates",e.getCoordinates().toArray()]];return e instanceof fa?(t.push(["setWidth",e.getWidth()]),t.push(["setHeight",e.getHeight()])):t.push(["setSymbol",e.getSymbol()]),t}},i.createCircleEditor=function(){var t=this,e=this._shadow||this._geometry,i=this.getMap();this._history||this._recordHistory([["setCoordinates",e.getCoordinates().toArray()],["setRadius",e.getRadius()]]),this._createResizeHandles(null,(function(n){var r=e.getCenter(),o=i.containerPointToCoord(n),s=new Zs([[r.x,r.y],[o.x,r.y]]),a=new Zs([[r.x,r.y],[r.x,o.y]]),h=Math.max(i.computeGeometryLength(s),i.computeGeometryLength(a));e.setRadius(h),e!==t._geometry&&t._geometry.setRadius(h)}),(function(){t._update("setRadius",e.getRadius())}))},i.createEllipseOrRectEditor=function(){var t=this,e=[2,1,2,0,0,2,1,2],i=this._shadow||this._geometry;this._history||this._recordHistory(a());var n,r=this.getMap(),o=this._geometry instanceof oa;this.options.fixAspectRatio&&(n=i.getWidth()/i.getHeight());var s=this._createResizeHandles(null,(function(a,h){var l,c,u,d=o?1:2,p=s[h].getContainerPoint(),f=e[h];if(o){var m=s[7-h].getContainerPoint(),g=(l=p.sub(m)).abs();c=r.pixelToDistance(g.x,0),u=r.pixelToDistance(0,g.y);var v=i.getSize(),y=i.getCoordinates(),_=i.getWidth(),x=i.getHeight(),w=r.containerPointToCoord(a),b=r.containerPointToCoord(m),M=new Zs([[b.x,b.y],[w.x,b.y]]),S=new Zs([[b.x,b.y],[b.x,w.y]]);if(c=r.computeGeometryLength(M),u=r.computeGeometryLength(S),0===f)if(n&&(g.y=g.x/n,v.height=Math.abs(g.y),u=c/n),p.y=m.y-v.height/2,w.y=y.y,4===h)w.x=Math.min(w.x,y.x);else{var T=r.locate(y,_,0);w.x=r.locate(new Hn(T.x,w.y),-c,0).x}else if(1===f)n&&(g.x=g.y*n,v.width=Math.abs(g.x),c=u*n),p.x=m.x-v.width/2,w.x=y.x,w.y=Math.max(w.y,b.y);else{if(n&&(c>u*n?(u=c/n,p.y=m.y+g.x*Yt(l.y)/n):(c=u*n,p.x=m.x+g.y*Yt(l.x)*n)),0===h||5===h){var E=0===h?r.locate(y,_,0):r.locate(y,_,-x);w.x=r.locate(new Hn(E.x,w.y),-c,0).x}else w.x=Math.min(w.x,b.x);w.y=Math.max(w.y,b.y)}i.setCoordinates(w),t._updateCoordFromShadow(!0)}else{var C=i.getCenter(),P=r.containerPointToCoord(p),A=new Zs([[C.x,C.y],[P.x,C.y]]),L=new Zs([[C.x,C.y],[C.x,P.y]]);c=r.computeGeometryLength(A),u=r.computeGeometryLength(L),n&&(u=(c=Math.max(c,u*n))/n)}(n||0===f||2===f)&&(i.setWidth(c*d),i!==t._geometry&&t._geometry.setWidth(c*d)),(n||1===f||2===f)&&(i.setHeight(u*d),i!==t._geometry&&t._geometry.setHeight(u*d))}),(function(){t._update(a())}));function a(){return[["setCoordinates",i.getCoordinates().toArray()],["setWidth",i.getWidth()],["setHeight",i.getHeight()]]}},i.createPolygonEditor=function(){var t=this.getMap(),e=this._shadow||this._geometry,i=this;this._history||this._recordHistory("setCoordinates",Hn.toNumberArrays(e.getCoordinates()));var n=e instanceof js?3:2,r="maptalks--editor-vertex-index",o={0:[]},s={0:[]};function a(t){if(void 0===t&&(t=0),e instanceof js){var i=e.getCoordinates()[t]||[];return i.slice(0,i.length-1)}return e.getCoordinates()}function h(t){return void 0===t&&(t=0),0===t?e._getPrjCoordinates():e._getPrjHoles()[t-1]}function l(){for(var t in o){for(var e=o[t].length-1;e>=0;e--)o[t][e][r]=e;for(var n=s[t].length-1;n>=0;n--)s[t][n][r]=n}i._updateCoordFromShadow()}function c(t){i._updating=!0;var a=t.target,c=a[r],u=j(a._ringIndex)?a._ringIndex:0,d=h(u);if(!(d.length<=n)){var p,f=e instanceof Zs&&(0===c||c===d.length-1);d.splice(c,1),u>0?e._prjHoles[u-1]=d:e._setPrjCoordinates(d),e._updateCache(),o[u].splice(c,1)[0].delete(),c<s[u].length&&s[u].splice(c,1)[0].delete(),p=0===c?s[u].length-1:c-1,s[u].splice(p,1)[0].delete(),f||s[u].splice(p,0,g.call(i,p,u)),l(),i._updating=!1}}function u(n,r,o){void 0===o&&(o=0);var a=i._geometry.snapTo;a&&W(a)&&(n=i._geometry.snapTo(n)||n);var l,c=h(o),u=t._containerPointToPrj(n.sub(p())),d=c[r];d.x=u.x,d.y=u.y,e._updateCache(),e.onShapeChanged(),i._updateCoordFromShadow(!0),l=0===r?s[o].length-1:r-1,s[o][r]&&s[o][r].refresh(),s[o][l]&&s[o][l].refresh()}var d=new Bt(0,0);function p(){var t=e._getCompiledSymbol();return d.x=t.lineDx||0,d.y=t.lineDy||0,d}function f(e,n,o){void 0===n&&(n=0);var s=(o||a(n))[e],h=i.createHandle(t.coordToContainerPoint(s)._add(p()),{symbol:i.options.vertexHandleSymbol,cursor:"pointer",axis:null,onMove:function(){u(h.getContainerPoint(),h[r],n)},onRefresh:function(e,i){s=(i||a(n))[h[r]];var o=t.coordToContainerPoint(s);h.setContainerPoint(o._add(p()))},onUp:function(){i._updateCoordFromShadow()},onDown:function(t,e){!e||!e.domEvent||e.domEvent.button}});return h[r]=e,h._ringIndex=n,h.on(i.options.removeVertexOn,c),h}var m=!1;function g(n,c,d){void 0===c&&(c=0);var v,y=d||a(c);v=n+1>=y.length?y[0]:y[n+1];var _=y[n].add(v).multi(.5),x=i.createHandle(_,{symbol:i.options.newVertexHandleSymbol,cursor:"pointer",axis:null,onDown:function(n,o){if(!o||!o.domEvent||2!==o.domEvent.button){var a=h(c),l=x[r],u=x.getContainerPoint(),d=t._containerPointToPrj(u);a.splice(l+1,0,d),c>0?e._prjHoles[c-1]=a:e._setPrjCoordinates(a),e._updateCache(),x.opacity=1,s[c].splice(l,0,g.call(i,l,c),g.call(i,l+1,c)),m=!0}},onMove:function(){u(x.getContainerPoint(),x[r]+1,c)},onUp:function(t){if(t&&t.domEvent&&2===t.domEvent.button)m=!1;else{var e=x[r];Zt(x,s[c]),x.delete(),o[c].splice(e+1,0,f.call(i,e+1,c)),l(),i._updateCoordFromShadow(),m=!1}},onRefresh:function(e,i){y=i||a(e);var n,o=x[r];n=o===y.length-1?0:o+1;var s=y[o].add(y[n]).multi(.5),h=t.coordToContainerPoint(s);x.setContainerPoint(h._add(p()))}});return x[r]=n,x}if(e instanceof js)for(var v=e.getHoles().length+1,y=0;y<v;y++){o[y]=[],s[y]=[];for(var _=a(y),x=0,w=_.length;x<w;x++)o[y].push(f.call(this,x,y,_)),x<w-1&&s[y].push(g.call(this,x,y,_));s[y].push(g.call(this,_.length-1,y,_))}else{for(var b=a(0),M=0,S=b.length;M<S;M++)o[0].push(f.call(this,M,0,b)),M<S-1&&s[0].push(g.call(this,M,0,b));s[0].length&&2===e.getCoordinates().length&&(s[0][0].options.symbol.markerDx=12)}this._addRefreshHook((function(){if(!m){for(var t in s)for(var i=a(t),n=s[t].length-1;n>=0;n--)s[t][n].refresh(t,i);for(var r in s[0].length&&e instanceof Zs&&(2===e.getCoordinates().length?s[0][0].options.symbol.markerDx=12:e.getCoordinates().length>2&&(s[0][0].options.symbol.markerDx=0)),o)for(var h=a(r),l=o[r].length-1;l>=0;l--)o[r][l].refresh(r,h)}}))},i._refresh=function(){if(this._refreshHooks)for(var t=this._refreshHooks.length-1;t>=0;t--)this._refreshHooks[t].call(this)},i._hideContext=function(){this._geometry&&(this._geometry.closeMenu(),this._geometry.closeInfoWindow())},i._addRefreshHook=function(t){t&&(this._refreshHooks||(this._refreshHooks=[]),this._refreshHooks.push(t))},i._update=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];this._exeHistory([t,i]),this._recordHistory.apply(this,[t].concat(i))},i._updateCoordFromShadow=function(t){var e=(this._shadow||this._geometry).getCoordinates(),i=this._geometry,n=this._updating;this._updating=!0,i.setCoordinates(e),t||this._recordHistory("setCoordinates",Hn.toNumberArrays(i.getCoordinates())),this._updating=n},i._recordHistory=function(t){this._history||(this._history=[],this._historyPointer=0);for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];if(this._history.length){var r=this._history[this._history.length-1];if(r[0]===t&&JSON.stringify(r[1])===JSON.stringify(i))return}this._historyPointer<this._history.length-1&&this._history.splice(this._historyPointer+1),this._history.push([t,i]),this._historyPointer=this._history.length-1,this._geometry.fire("editrecord")},i.cancel=function(){if(!this._history||0===this._historyPointer)return this;this._historyPointer=0;var t=this._history[0];return this._exeAndReset(t),this},i.undo=function(){if(!this._history||0===this._historyPointer)return this;var t=this._history[--this._historyPointer];return this._exeAndReset(t),this},i.redo=function(){if(!this._history||this._historyPointer===this._history.length-1)return this;var t=this._history[++this._historyPointer];return this._exeAndReset(t),this},i._exeAndReset=function(t){if(!this._updating){this._exeHistory(t);var e=this._history,i=this._historyPointer;this.stop(),this._history=e,this._historyPointer=i,this.start()}},i._onDragStart=function(){this._updating=!0},i._onDragEnd=function(){this._updating=!1},i._exeHistory=function(t){if(Array.isArray(t)){var e=this._updating;this._updating=!0;var i=this._shadow||this._geometry,n=this._geometry;Array.isArray(t[0])?t[0].forEach((function(t){var e=t[0],r=t.slice(1);i[e].apply(i,r),i!==n&&n[e].apply(n,r)})):(i[t[0]].apply(i,t[1]),i!==n&&n[t[0]].apply(n,t[1])),this._updating=e}},e}(Cn(Ln));Xl.mergeOptions(ql);var Yl={startEditText:function(){return this.getMap()?(this.hide(),this.endEditText(),this._prepareEditor(),this._fireEvent("edittextstart"),this):this},endEditText:function(){if(this._textEditor){var t=this._textEditor.innerHTML;t=t.replace(/<p>/gi,"").replace(/<\/p>/gi,"<br/>"),this._textEditor.innerHTML=t;var e=this._textEditor.innerText.replace(/[\r\n]+$/gi,"");this.setContent(e),cn(this._textEditor,"mousedown dblclick",qi),this.getMap().off("mousedown",this.endEditText,this),this._editUIMarker.remove(),delete this._editUIMarker,this._textEditor.onkeyup=null,delete this._textEditor,this.show(),this._fireEvent("edittextend")}return this},isEditingText:function(){return!!this._textEditor},getTextEditor:function(){return this._editUIMarker},_prepareEditor:function(){var t=this.getMap(),e=this._createEditor();this._textEditor=e,t.on("mousedown",this.endEditText,this);var i=this._getEditorOffset();this._editUIMarker=new Mh(this.getCoordinates(),{animation:null,content:e,dx:i.dx,dy:i.dy}).addTo(t),this._setCursorToLast(this._textEditor)},_getEditorOffset:function(){var t=this._getInternalSymbol()||{},e=0,i=0,n=t.textHorizontalAlignment;return"middle"===n||H(n)?(e=(t.textDx||0)-2,i=(t.textDy||0)-2):(e=(t.markerDx||0)-2,i=(t.markerDy||0)-2),{dx:e,dy:i}},_createEditor:function(){var t=this.getContent(),e=this.getSize(),i=this._getInternalSymbol()||{},n=e.width,r=i.textFill||"#000000",o=i.textSize||12,s=e.height,a=i.markerLineColor||"#000",h=i.markerFill||"#3398CC",l=i.textLineSpacing||0,c=Hi("div");return c.contentEditable=!0,c.style.cssText="background:"+h+"; border:1px solid "+a+";\n color:"+r+";font-size:"+o+"px;width:"+(n-2)+"px;height:"+(s-2)+"px;margin: auto;\n line-height:"+(o+l)+"px;outline: 0; padding:0; margin:0;word-wrap: break-word;\n overflow: hidden;-webkit-user-modify: read-write-plaintext-only;",c.innerText=t,ln(c,"mousedown dblclick",qi),c.onkeyup=function(t){var e=c.style.height||0;13===t.keyCode&&(c.style.height=parseInt(e)+o/2+"px")},c},_setCursorToLast:function(t){var e;window.getSelection?(t.focus(),(e=window.getSelection()).selectAllChildren(t),e.collapseToEnd()):document.selection&&((e=document.selection.createRange()).moveToElementText(t),e.collapse(!1),e.select())}};pa.include(Yl),os.include({animate:function(t,e,i){var n=this;this._animPlayer&&this._animPlayer.finish(),W(e)&&(i=e),e||(e={});var r,o=this.getMap(),s=this._getProjection(),a=this._prepareAnimationStyles(t),h=e.focus;if(delete this._animationStarted,o){var l=o._getRenderer();e.framer=function(t){l.callInNextFrame(t)}}var c=Fs.animate(a,e,(function(t){if(o&&o.isRemoved())c.finish();else{o&&!n._animationStarted&&h&&o.onMoveStart();var e=t.styles;for(var a in e)if("symbol"!==a&&"translate"!==a&&e.hasOwnProperty(a)){var l="set"+a[0].toUpperCase()+a.slice(1);n[l](e[a])}var u=e.translate;if(u){var d=u;r&&(d=u.sub(r)),r=u,n.translate(d)}var p=e.symbol;if(p){var f=n.getSymbol()||{};n.setSymbol(Ci(f,p))}if(o&&h){var m=s.project(n.getCenter());o._setPrjCenter(m);var g=o._parseEventFromCoord(s.unproject(m));"running"!==c.playState?o.onMoveEnd(g):o.onMoving(g)}n._fireAnimateEvent(c.playState),i&&i(t)}}),this);return this._animPlayer=c,this._animPlayer.play()},_prepareAnimationStyles:function(t){var e=this._getInternalSymbol(),i={};for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];if("translate"!==n&&"symbol"!==n){var o=this["get"+n[0].toUpperCase()+n.substring(1)]();i[n]=[o,r]}else if("symbol"===n){var s=void 0;if(Array.isArray(t.symbol)){if(!Array.isArray(e))throw new Error("geometry'symbol isn't a composite symbol, while the symbol in styles is.");s=[];for(var a=t.symbol,h=0;h<a.length;h++)if(a[h]){var l={};for(var c in a[h])a[h].hasOwnProperty(c)&&(l[c]=[e[h][c],a[h][c]]);s.push(l)}else s.push(null)}else{if(Array.isArray(e))throw new Error("geometry'symbol is a composite symbol, while the symbol in styles isn't.");for(var u in s={},r)r.hasOwnProperty(u)&&(s[u]=[e[u],r[u]])}i.symbol=s}else"translate"===n&&(i.translate=new Hn(r))}return i},_fireAnimateEvent:function(t){"finished"===t?(delete this._animationStarted,this._fireEvent("animateend")):"running"===t&&(this._animationStarted?this._fireEvent("animating"):(this._fireEvent("animatestart"),this._animationStarted=!0))}});var Jl=L+"_drag_stage",Ql=Ot.touch?"touchstart mousedown":"mousedown",Kl=function(t){function e(e){return t.call(this,e)||this}Dt(e,t);var i=e.prototype;return i.addHooks=function(){this.target.on(Ql,this._startDrag,this)},i.removeHooks=function(){this._endDrag(),this.target.off(Ql,this._startDrag,this),delete this.container},i._prepareDragHandler=function(){this._dragHandler=new Nn(this.container),this._dragHandler.on("dragging",this._dragging,this).on("mouseup",this._endDrag,this).enable()},i._prepareShadow=function(){var t=this,e=this.target;if("canvas"===e.getLayer().options.renderer){this._prepareDragStageLayer(),this._shadow&&this._shadow.remove();var i=this._shadow=e.copy();if(i.getGeometries){var n=i.getGeometries(),r=e.getGeometries();n.forEach((function(e,i){t._updateShadowSymbol(e,r[i])}))}else this._updateShadowSymbol(i,e);i.setId(null),this._prepareShadowConnectors()}},i._updateShadowSymbol=function(t,e){if(t.setSymbol(e._getInternalSymbol()),e.options.dragShadow){var i=Ei(t._getInternalSymbol(),.5);t.setSymbol(i)}},i._prepareShadowConnectors=function(){var t=this.target,e=this._shadow,i=this._dragStageLayer._getRenderer().resources,n=[];if(ya._hasConnectors(t))for(var r=ya._getConnectors(t),o=0,s=r.length;o<s;o++){var a=r[o],h=a.config(),l=a._getInternalSymbol();h.symbol=Ei(l,.5);var c=void 0;c=a.getConnectSource()===t?new a.constructor(e,a.getConnectTarget(),h):new a.constructor(a.getConnectSource(),e,h),n.push(c),a.getLayer()&&a.getLayer()._getRenderer()&&i.merge(a.getLayer()._getRenderer().resources)}this._shadowConnectors=n,n.push(e),this._dragStageLayer.bringToFront().addGeometry(n)},i._onTargetUpdated=function(){this._shadow&&this._shadow.setSymbol(this.target._getSymbol())},i._prepareDragStageLayer=function(){var t=this.target.getMap(),e=this.target.getLayer();this._dragStageLayer=t.getLayer(Jl),this._dragStageLayer||(this._dragStageLayer=new Sa(Jl,{enableAltitude:e.options.enableAltitude,altitudeProperty:e.options.altitudeProperty}),t.addLayer(this._dragStageLayer));var i=new jr;i.merge(e._getRenderer().resources),this._dragStageLayer._getRenderer().resources=i},i._startDrag=function(t){var e=this.target.getMap();if(e&&(!this.target._getParent()&&!this.isDragging())){var i=t.domEvent;i.touches&&i.touches.length>1||2===i.button||(this.container=e._panels.mapWrapper||e._containerDOM,this.target.on("click",this._endDrag,this),this._lastCoord=this._correctCoord(t.coordinate),this._lastPoint=t.containerPoint,this._prepareDragHandler(),this._dragHandler.onMouseDown(t.domEvent),ln(this.container,"mouseleave",this._endDrag,this),this._startParam=t,this._moved=!1)}},i._dragging=function(t){var e=this.target,i=e.getMap(),n=i._parseEvent(t.domEvent),r=n.domEvent;if(!(r.touches&&r.touches.length>1)){var o=i._getVisualHeight(i.options.maxVisualPitch);if(!(n.containerPoint.y<i.height-o)){if(!this._moved)return this._moved=!0,e.on("symbolchange",this._onTargetUpdated,this),this._isDragging=!0,this._prepareShadow(),this._shadow&&(e.options.dragShadow||e.hide(),this._shadow._fireEvent("dragstart",n)),this.target._fireEvent("dragstart",this._startParam||n),void delete this._startParam;var s=this._shadow||e,a=s.options.dragOnAxis,h=s.options.dragOnScreenAxis,l=n.containerPoint,c=n.coordinate;this._lastPoint=this._lastPoint||l,this._lastCoord=this._lastCoord||c,h?("x"===a?l.y=this._lastPoint.y:"y"===a&&(l.x=this._lastPoint.x),c=i.containerPointToCoord(l)):c=this._correctCoord(c);var u=l.sub(this._lastPoint),d=c.sub(this._lastCoord);h||("x"===a?u.y=d.y=0:"y"===a&&(u.x=d.x=0)),this._lastPoint=l,this._lastCoord=c,s.translate(d),s===e||e.options.dragShadow||e.translate(d),n.coordOffset=d,n.pointOffset=u,s._fireEvent("dragging",n),s!==e&&e._fireEvent("dragging",n)}}},i._endDrag=function(t){if(this._dragHandler&&(this._dragHandler.disable(),delete this._dragHandler),this.container&&cn(this.container,"mouseleave",this._endDrag),this.target){var e=this.target;e.off("click",this._endDrag,this),e.off("symbolchange",this._onTargetUpdated,this),delete this._lastCoord,delete this._lastPoint,this._isDragging=!1;var i=e.getMap();if(this.enabled()&&i){var n=i._parseEvent(t?t.domEvent:null);this._updateTargetAndRemoveShadow(n),this._moved&&e._fireEvent("dragend",n)}}},i.isDragging=function(){return!!this._isDragging},i._updateTargetAndRemoveShadow=function(t){if(this._shadow){var e=this.target,i=e.getMap();e.options.dragShadow||e.show();var n=this._shadow;if(n){if(e.options.dragShadow)if(e.getGeometries){var r=n.getGeometries(),o=e.getGeometries();r.forEach((function(t,e){o[e].setCoordinates(r[e].getCoordinates())}))}else e.setCoordinates(n.getCoordinates());n._fireEvent("dragend",t),n.remove(),delete this._shadow}this._shadowConnectors&&(i.getLayer(Jl).removeGeometry(this._shadowConnectors),delete this._shadowConnectors),this._dragStageLayer&&(this._dragStageLayer._getRenderer().resources=new jr,this._dragStageLayer.remove())}},i._correctCoord=function(t){var e=this.target.getMap();if(!e.getPitch())return t;var i=this.target;if(!i.getMinAltitude())return t;var n=(i.getMinAltitude()+i.getMaxAltitude())/2;return e.locateByPoint(t,0,-n)},e}(An);os.mergeOptions({draggable:!1,dragShadow:!0,dragOnAxis:null,dragOnScreenAxis:!1}),os.addInitHook("addHandler","draggable",Kl),os.include({isDragging:function(){return this._getParent()?this._getParent().isDragging():!!this.draggable&&this.draggable.isDragging()}}),os.include({startEdit:function(t){var e=this.getMap();return e&&this.options.editable?(this._editor&&this.endEdit(),this._editor=new Xl(this,t),this._editor.start(),this._getParent()||this.fire("editstart"),e.getRenderer().setToRedraw(),this):this},endEdit:function(){if(this._editor){this._editor.stop(),delete this._editor,this._getParent()||this.fire("editend");var t=this.getMap();t&&t.getRenderer().setToRedraw()}return this},redoEdit:function(){return this.isEditing()?(this._editor.redo(),this._getParent()||this.fire("redoedit"),this):this},undoEdit:function(){return this.isEditing()?(this._editor.undo(),this._getParent()||this.fire("undoedit"),this):this},cancelEdit:function(){return this.isEditing()?(this._editor.cancel(),this._getParent()||this.fire("canceledit"),this):this},isEditing:function(){return!!this._editor&&this._editor.isEditing()}}),os.include({_onEvent:function(t,e){var i=this.getMap();if(i){var n=e||this._getEventTypeToFire(t);"contextmenu"===n&&this.listens("contextmenu")&&(qi(t),Zi(t));var r=i._getEventParams(t);j(this._pickGeometryIndex)&&(r.pickGeometryIndex=this._pickGeometryIndex),this._fireEvent(n,r)}},_getEventTypeToFire:function(t){return t.type}}),os.include({setInfoWindow:function(t){return this.removeInfoWindow(),t instanceof Ah?(this._infoWindow=t,this._infoWinOptions=N({},this._infoWindow.options),this._infoWindow.addTo(this),this):(this._infoWinOptions=N({},t),this._infoWindow?this._infoWindow.setOptions(t):this.getMap()&&this._bindInfoWindow(),this)},getInfoWindow:function(){return this._infoWindow?this._infoWindow:null},openInfoWindow:function(t){return this.getMap()?(t||(t=this.getCenter()),this._infoWindow?this._infoWindow.show(t):this._infoWinOptions&&this.getMap()&&(this._bindInfoWindow(),this._infoWindow.show(t)),this):this},closeInfoWindow:function(){return this._infoWindow&&this._infoWindow.hide(),this},removeInfoWindow:function(){return this._unbindInfoWindow(),delete this._infoWinOptions,delete this._infoWindow,this},_bindInfoWindow:function(){var t=this._infoWinOptions;return t?(this._infoWindow=new Ah(t),this._infoWindow.addTo(this),this):this},_unbindInfoWindow:function(){return this._infoWindow&&(this.closeInfoWindow(),this._infoWindow.remove(),delete this._infoWindow),this}});var $l=new Bt(0,0),tc=new Bt(0,0),ec=new Bt(0,0),ic=new Bt(0,0),nc=[],rc=function(t){function e(){return t.call(this,Fr)||this}Dt(e,t);var i=e.prototype;return i.checkUrl=function(t){return t&&V(t)?ge(t):t},i.fetchImage=function(t,e,i,n){var r={url:t=this.checkUrl(t),fetchOptions:n};this.send(r,nc,i,e)},e}(zr),oc=new Image,sc=function(t){function e(e){var i;return(i=t.call(this,e)||this).tilesInView={},i.tilesLoading={},i._parentTiles=[],i._childTiles=[],i._tileQueue=[],i.tileCache=new mn(e.options.maxCacheSize,i.deleteTile.bind(It(It(i)))),Ot.decodeImageInWorker&&i.layer.options.decodeImageInWorker&&("gl"===e.options.renderer||!Ot.safari&&!Ot.iosWeixin)&&(i._tileImageWorkerConn=new rc),i._compareTiles=hc.bind(It(It(i))),i}Dt(e,t);var i=e.prototype;return i.getCurrentTileZoom=function(){return this._tileZoom},i.draw=function(t,e){var i=this.getMap();if(this.isDrawable()){var n=this.prepareCanvas();if(!n||n.intersects(this.canvasExtent2D)){var r;this._renderTimestamp!==t&&(this._consumeTileQueue(),this._renderTimestamp=t);var o=!1,s=this._frameTiles;if(s&&t===s.timestamp){if(s.empty)return;r=s}else{if(!(r=this._getTilesInCurrentFrame()))return this._frameTiles={empty:!0,timestamp:t},void this.completeRender();o=!0,this._frameTiles=r,this._frameTiles.timestamp=t,r.loadingCount&&this.loadTileQueue(r.tileQueue)}var a=r,h=a.tiles,l=a.childTiles,c=a.parentTiles,u=a.placeholders,d=a.loading,p=a.loadingCount;this._drawTiles(h,c,l,u,e),p||d||(i.isAnimating()||!this._parentTiles.length&&!this._childTiles.length||(this._parentTiles=[],this._childTiles=[],this.setToRedraw()),this.completeRender()),o&&this._retireTiles()}else this.completeRender()}},i.getTileGridsInCurrentFrame=function(){return this._frameTileGrids},i._getTilesInCurrentFrame=function(){var t=this.getMap(),e=this.layer.getTiles();if(this._frameTileGrids=e,!(e=e.tileGrids)||!e.length)return null;var i=e.reduce((function(t,e){return t+(e&&e.tiles&&e.tiles.length||0)}),0);i>=this.tileCache.max/2&&this.tileCache.setMaxSize(2*i+1);var n=0,r=!1,o={},s=[],a=[],h={},l=[],c={},u=[],d={},p={},f=this._markTiles(),m=this._getLoadLimit(),g=e.length;this._tileZoom=e[0].zoom;for(var v=0;v<g;v++){var y=e[v].tiles,_=void 0;y.length&&(_=this._generatePlaceHolder(y[0].res));for(var x=0,w=y.length;x<w;x++){var b=y[x],M=b.id,S=!1;if(this._isLoadingTile(M))S=r=!0,this.tilesLoading[M].current=!0;else{var T=this._getCachedTile(M);if(T)T.image&&this.getTileOpacity(T.image)<1&&(S=r=!0,this.setToRedraw()),s.push(T);else if(S=r=!0,!(m&&n+f[0]>m)&&(!t.isInteracting()||t.isMoving()||t.isRotating()))n++,p[M]=b}if(S&&!o[M]){o[M]=1,_&&!d[M]&&(b.cache=!1,u.push({image:_,info:b}),d[M]=1);var E=this._findParentTile(b);if(E){var C=E.info.id;void 0===h[C]&&(h[C]=a.length,a.push(E))}else if(!a.length){var P=this._findChildTiles(b);P.length&&P.forEach((function(t){c[t.info.id]||(l.push(t),c[t.info.id]=1)}))}}}}return a.length&&(l.length=0,this._childTiles.length=0),{childTiles:l,parentTiles:a,tiles:s,placeholders:u,loading:r,loadingCount:n,tileQueue:p}},i.isTileCachedOrLoading=function(t){return this.tileCache.get(t)||this.tilesInView[t]||this.tilesLoading[t]},i._drawTiles=function(t,e,i,n,r){var o=this;e.length&&(e.sort(this._compareTiles),this._parentTiles=e),i.length&&(this._childTiles=i,this._childTiles.sort(this._compareTiles));var s={tiles:t,parentTiles:this._parentTiles,childTiles:this._childTiles,parentContext:r};this.onDrawTileStart(s,r),1===this.layer.options.opacity&&(this._childTiles.forEach((function(t){return o._drawTile(t.info,t.image,r)})),this._parentTiles.forEach((function(t){return o._drawTile(t.info,t.image,r)}))),t.sort(this._compareTiles);for(var a=0,h=t.length;a<h;a++)this._drawTileAndCache(t[a],r);this.layer.options.opacity<1&&(this._childTiles.forEach((function(t){return o._drawTile(t.info,t.image,r)})),this._parentTiles.forEach((function(t){return o._drawTile(t.info,t.image,r)}))),n.forEach((function(t){return o._drawTile(t.info,t.image,r)})),this.onDrawTileEnd(s,r)},i.onDrawTileStart=function(){},i.onDrawTileEnd=function(){},i._drawTile=function(t,e,i){e&&this.drawTile(t,e,i)},i._drawTileAndCache=function(t,e){t.current=!0,this.tilesInView[t.info.id]=t,this._drawTile(t.info,t.image,e),this.tileCache.add(t.info.id,t)},i.drawOnInteracting=function(t,e,i){this.draw(e,i)},i.needToRedraw=function(){var e=this.getMap();return!!this._tileQueue.length||(e.getPitch()?t.prototype.needToRedraw.call(this):!(!e.isRotating()&&!e.isZooming())||(e.isMoving()?!!this.layer.options.forceRenderOnMoving:t.prototype.needToRedraw.call(this)))},i.hitDetect=function(){return!1},i._getLoadLimit=function(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:0},i.isDrawable=function(){return!this.getMap().getPitch()||(console&&console.warn("TileLayer with canvas renderer can't be pitched, use gl renderer ('renderer' : 'gl') instead."),this.clear(),!1)},i.clear=function(){this._retireTiles(!0),this.tileCache.reset(),this.tilesInView={},this.tilesLoading={},this._parentTiles=[],this._childTiles=[],t.prototype.clear.call(this)},i._isLoadingTile=function(t){return!!this.tilesLoading[t]},i.clipCanvas=function(e){return t.prototype.clipCanvas.call(this,e)},i._clipByPitch=function(t){var e=this.getMap();if(e.getPitch()<=e.options.maxVisualPitch)return!1;if(!this.layer.options.clipByPitch)return!1;var i=e.getContainerExtent(),n=e.getDevicePixelRatio();return t.save(),t.strokeStyle="rgba(0, 0, 0, 0)",t.beginPath(),t.rect(0,Math.ceil(i.ymin)*n,Math.ceil(i.getWidth())*n,Math.ceil(i.getHeight())*n),t.stroke(),t.clip(),!0},i.loadTileQueue=function(t){for(var e in t)if(t.hasOwnProperty(e)){var i=t[e],n=this.loadTile(i);void 0===n.loadTime&&(this.tilesLoading[i.id]={image:n,current:!0,info:i})}},i.loadTile=function(t){var e;if(this._tileImageWorkerConn&&this.loadTileImage===this.constructor.prototype.loadTileImage)e={},this._fetchImage(e,t);else{var i=this.layer.getTileSize(t.layer);(e=new Image).width=i.width,e.height=i.height,e.onload=this.onTileLoad.bind(this,e,t),e.onerror=this.onTileError.bind(this,e,t),this.loadTileImage(e,t.url)}return e},i._fetchImage=function(t,e){var i=this;if(t instanceof Image)t.src=e.url;else{var n=e.x,r=e.y,o=Math.abs(n+r)%this._tileImageWorkerConn.workers.length;this._tileImageWorkerConn.fetchImage(e.url,o,(function(n,r){n?i.onTileError(t,e,n):me(r,(function(t){i.onTileLoad(t,e)}))}),this.layer.options.fetchOptions||{referrer:document.location.href,headers:{accept:"image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"}})}},i.loadTileImage=function(t,e){var i=this.layer.options.crossOrigin;return H(i)||(t.crossOrigin=i),Ht(t,[e])},i.abortTileLoading=function(t){t&&(t.onload=ac,t.onerror=ac,t.src=ce)},i.onTileLoad=function(t,e){this._tileQueue.push({tileInfo:e,tileData:t})},i._consumeTileQueue=function(){for(var t=0,e=this.layer.options.tileLimitPerFrame,i=this._tileQueue;i.length&&(e<=0||t<e);){var n=i.shift(),r=n.tileData,o=n.tileInfo;this.checkTileInQueue(r,o)&&(this.consumeTile(r,o),t++)}},i.checkTileInQueue=function(){return!0},i.consumeTile=function(t,e){if(this.layer){var i=e.id;if(this.tilesInView){var n={tile:e,tileImage:t};this.layer.fire("tileload",n),(t=n.tileImage).loadTime=B(),delete this.tilesLoading[i],this._addTileToCache(e,t),this.setToRedraw()}}},i.onTileError=function(t,e){if(this.layer){if(t.onerrorTick=t.onerrorTick||0,this.layer.options.tileRetryCount>t.onerrorTick)return t.onerrorTick++,void this._fetchImage(t,e);var i=this.layer.options.errorUrl;if(i){if(t instanceof Image&&t.src!==i)return void(t.src=i);(t=new Image).src=i}t=t instanceof Image?t:oc,this.abortTileLoading(t,e),t.loadTime=0,delete this.tilesLoading[e.id],this._addTileToCache(e,t),this.setToRedraw(),this.layer.fire("tileerror",{tile:e})}},i.drawTile=function(t,e){if(e&&this.getMap()){var i=t.extent2d,n=t.offset,r=$l.set(i.xmin-n[0],i.ymax-n[1]),o=t.z,s=t.id,a=this.getMap(),h=a.getZoom(),l=this.context,c=a._pointAtResToContainerPoint(r,t.res,0,tc),u=a.getBearing(),d=u||h!==o,p=this.getTileOpacity(e),f=l.globalAlpha;p<1&&(l.globalAlpha=p,this.setToRedraw()),d||c._round();var m=c.x,g=c.y,v=t.extent2d.xmax-t.extent2d.xmin,y=t.extent2d.ymax-t.extent2d.ymin;if(d){l.save(),l.translate(m,g),u&&(l.rotate(-u*Math.PI/180),v+=.1,y+=.1);var _=a._getResolution();if(_!==t.res){var x=t.res/_;l.scale(x,x)}m=g=0}if(wn.image(l,e,m,g,v,y),this.layer.options.debug){var w=this.layer.options.debugOutline;l.save(),l.strokeStyle=w,l.fillStyle=w,l.strokeWidth=10,l.font="20px monospace";var b=new Bt(m,g);wn.rectangle(l,b,{width:v,height:y},1,0),wn.fillText(l,this.getDebugInfo(s),b._add(32,y-14),w),wn.drawCross(l,m+v/2,g+y/2,2,w),l.restore()}d&&l.restore(),l.globalAlpha!==f&&(l.globalAlpha=f),this.setCanvasUpdated()}},i.getDebugInfo=function(t){var e=t.split("_"),i=e.length;return"x:"+e[i-2]+", y:"+e[i-3]+", z:"+e[i-1]},i._findChildTiles=function(t){var e=this._getLayerOfTile(t.layer);if(!e||!e.options.background)return[];for(var i=this.getMap(),n=[],r=t.res,o=t.extent2d.getMin(),s=t.extent2d.getMax(),a=e._project(i._pointToPrjAtRes(o,r,ec),ec),h=e._project(i._pointToPrjAtRes(s,r,ic),ic),l=1;l<3;l++)this._findChildTilesAt(n,a,h,e,t.z+l);return n},i._findChildTilesAt=function(t,e,i,n,r){var o=n.options.zoomOffset,s=n.getId(),a=n.getSpatialReference().getResolution(r+o);if(a)for(var h,l,c=n._getTileConfig().getTileIndex(e,a),u=n._getTileConfig().getTileIndex(i,a),d=Math.min(c.idx,u.idx),p=Math.max(c.idx,u.idx),f=Math.min(c.idy,u.idy),m=Math.max(c.idy,u.idy),g=d;g<p;g++)for(var v=f;v<m;v++)h=n._getTileId(g,v,r+o,s),this.tileCache.has(h)&&(l=this.tileCache.getAndRemove(h),t.push(l),this.tileCache.add(h,l))},i._findParentTile=function(t){var e=this.getMap(),i=this._getLayerOfTile(t.layer);if(!i||!i.options.background)return null;for(var n=i.getSpatialReference(),r=n.getZoomDirection(),o=i.options.zoomOffset,s=i.options.backgroundZoomDiff,a=t.res,h=t.extent2d.getCenter(),l=i._project(e._pointToPrjAtRes(h,a)),c=1;c<=s;c++){var u=t.z-r*c,d=n.getResolution(u+o);if(d){var p=i._getTileConfig().getTileIndex(l,d),f=i._getTileId(p.x,p.y,u+o,t.layer);if(this.tileCache.has(f)){var m=this.tileCache.getAndRemove(f);return this.tileCache.add(f,m),m}}}return null},i._getLayerOfTile=function(t){return this.layer.getChildLayer?this.layer.getChildLayer(t):this.layer},i._getCachedTile=function(t){var e=this.tilesInView,i=this.tileCache.getAndRemove(t);if(i){e[t]=i;var n=this.tilesLoading;if(n&&n[t]){n[t].current=!1;var r=n[t],o=r.image,s=r.info;this.abortTileLoading(o,s),delete n[t]}}else i=e[t];return i},i._addTileToCache=function(t,e){this.tilesInView[t.id]={image:e,current:!0,info:t}},i.getTileOpacity=function(t){return this.layer.options.fadeAnimation&&t.loadTime?Math.min(1,(B()-t.loadTime)/(1e3/60*10)):1},i.onRemove=function(){this.clear(),delete this.tileCache,delete this._tilePlaceHolder,t.prototype.onRemove.call(this)},i._markTiles=function(){var t=0,e=0;if(this.tilesLoading)for(var i in this.tilesLoading)this.tilesLoading[i].current=!1,t++;if(this.tilesInView)for(var n in this.tilesInView)this.tilesInView[n].current=!1,e++;return[t,e]},i._retireTiles=function(t){for(var e in this.tilesLoading){var i=this.tilesLoading[e];!t&&i.current||(i.image&&this.abortTileLoading(i.image,i.info),this.deleteTile(i),delete this.tilesLoading[e])}for(var n in this.tilesInView){var r=this.tilesInView[n];r.current||(delete this.tilesInView[n],this.tileCache.has(n)||this.deleteTile(r))}},i.deleteTile=function(t){t&&t.image&&(t.image.close&&t.image.close(),t.image.onload=null,t.image.onerror=null)},i._generatePlaceHolder=function(t){var e=this.getMap(),i=this.layer.options.placeholder;if(!i||e.getPitch())return null;var n=this.layer.getTileSize(),r=t/e._getResolution(),o=this._tilePlaceHolder=this._tilePlaceHolder||wn.createCanvas(1,1,e.CanvasClass);return o.width=n.width*r,o.height=n.height*r,W(i)?i(o):function(t){var e=t.getContext("2d"),i=t.width,n=t.height,r=i/16,o=n/16;e.beginPath();for(var s=0;s<16;s++)e.moveTo(0,s*o),e.lineTo(i,s*o),e.moveTo(s*r,0),e.lineTo(s*r,n);e.strokeStyle="rgba(180, 180, 180, 0.1)",e.lineWidth=1,e.stroke(),e.beginPath();for(var a=[[0,0],[i,0],[0,n],[i,n],[0,0],[0,n],[i,0],[i,n],[0,n/2],[i,n/2],[i/2,0],[i/2,n]],h=1;h<a.length;h+=2)e.moveTo(a[h-1][0],a[h-1][1]),e.lineTo(a[h][0],a[h][1]);e.lineWidth=4,e.stroke()}(o),o},e}(Hr);function ac(){return!1}function hc(t,e){return Math.abs(this._tileZoom-t.info.z)-Math.abs(this._tileZoom-e.info.z)}ll.registerRenderer("canvas",sc);var lc=new Bt(0,0),cc={properties:{}},uc=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.isDrawable=function(){return!0},i.needToRedraw=function(){var e=this.getMap();return!(!this._gl()||e.getPitch()||!e.isZooming()||e.isMoving()||e.isRotating())||t.prototype.needToRedraw.call(this)},i.onDrawTileStart=function(t,e){var i=this.gl;i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL),i.enable(i.POLYGON_OFFSET_FILL),i.enable(i.STENCIL_TEST),i.stencilOp(i.KEEP,i.KEEP,i.REPLACE);var n=H(this.layer.options.depthMask)||!!this.layer.options.depthMask;if(i.depthMask(n),e&&e.renderTarget){var r=e.renderTarget.fbo;if(r){var o=e.renderTarget.getFramebuffer(r);i.bindFramebuffer(i.FRAMEBUFFER,o)}}},i.onDrawTileEnd=function(t,e){var i=this.gl;e&&e.renderTarget&&(e.renderTarget.fbo&&i.bindFramebuffer(i.FRAMEBUFFER,null))},i.drawTile=function(e,i,n){if(!n||!n.sceneFilter||n.sceneFilter(cc)){var r=this.getMap();if(e&&r&&i){var o=e._glScale=e._glScale||e.res/r.getGLRes(),s=e.extent2d.xmax-e.extent2d.xmin,a=e.extent2d.ymax-e.extent2d.ymin;if(!1!==e.cache&&this._bindGLBuffer(i,s,a),this._gl()){var h=e.extent2d,l=e.offset,c=lc.set(h.xmin-l[0],e.extent2d.ymax-l[1]),u=c.x*o,d=c.y*o,p=this.getTileOpacity(i),f=null;this.layer.options.debug&&(f=this.getDebugInfo(e.id));var m=this.gl;m.stencilFunc(m.LEQUAL,this.tilesInView[e.id]?0:Math.abs(this.getCurrentTileZoom()-e.z),255);var g=this.layer.getPolygonOffset(),v=this.tilesInView[e.id]?g-1:g;m.polygonOffset(v,v),this.drawGLImage(i,u,d,s,a,o,p,f),p<1?this.setToRedraw():this.setCanvasUpdated()}else t.prototype.drawTile.call(this,e,i)}}},i._bindGLBuffer=function(t,e,i){t.glBuffer||(t.glBuffer=this.bufferTileData(0,0,e,i))},i.loadTileImage=function(t,e){var i=this.layer.options.crossOrigin;t.crossOrigin=null!==i?i:"",t.src=e},i.onCanvasCreate=function(){this.canvas.gl&&this.canvas.gl.wrap||this.createCanvas2()},i.createContext=function(){t.prototype.createContext.call(this),this.createGLContext()},i.resizeCanvas=function(e){this.canvas&&(t.prototype.resizeCanvas.call(this,e),this.resizeGLCanvas())},i.clearCanvas=function(){this.canvas&&(t.prototype.clearCanvas.call(this),this.clearGLCanvas())},i.getCanvasImage=function(){if(!this._gl()||!this.canvas2)return t.prototype.getCanvasImage.call(this);var e=t.prototype.getCanvasImage.call(this);return e&&(e.image=this.canvas2),e},i._gl=function(){if(this.canvas.gl&&this.canvas.gl.wrap)return!0;var t=this.getMap();return t&&(t.getPitch()||t.getBearing())||this.layer&&!!this.layer.options.fragmentShader},i.deleteTile=function(e){t.prototype.deleteTile.call(this,e),e&&e.image&&this.disposeImage(e.image),delete e.image},i.onRemove=function(){t.prototype.onRemove.call(this),this.removeGLCanvas()},e}(Pl(sc));function dc(t){var e=this.layer.getTileSize(),i=this.canvas.constructor,n=this.getMap(),r=n.getDevicePixelRatio(),o=wn.createCanvas(e.width*r,e.height*r,i);o.layer=this.layer;var s=this,a=new Bt(t.extent2d.xmin,t.extent2d.ymax),h=new tr(n.pointToCoordinate(a),n.pointToCoordinate(a.add(e.width,e.height)),n.getProjection());return this.layer.drawTile(o,{url:t.url,point:a,center:n.pointToCoordinate(a.add(e.width/2,e.height/2)),extent:h,z:t.z,x:t.x,y:t.y},(function(e){e?s.onTileError(o,t):s.onTileLoad(o,t)})),o}ll.registerRenderer("gl",uc);var pc=function(t){function e(){return t.apply(this,arguments)||this}return Dt(e,t),e.prototype.loadTile=function(){return dc.apply(this,arguments)},e}(sc),fc=function(t){function e(){return t.apply(this,arguments)||this}return Dt(e,t),e.prototype.loadTile=function(){return dc.apply(this,arguments)},e}(uc);yl.registerRenderer("canvas",pc),yl.registerRenderer("gl",fc);var mc="undefined"!=typeof Int8Array?new Int8Array([-1,1,0,-1,-1,0,1,1,0,1,-1,0]):[],gc=function(){function t(t,e,i){this.gl=t,this.quadVertices=e||mc,this.attributes=["a_position",3,vc(e)],this.debug=i}var e=t.prototype;return e.start=function(){var t=this.gl;t.enable(t.STENCIL_TEST),t.stencilMask(255),t.stencilOp(t.KEEP,t.REPLACE,t.REPLACE),t.depthMask(!1),this._save(),this.buffer||(this._createBuffer(),this._createProgram()),t.useProgram(this.program),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),wl(t,this.program,this.attributes),this.transformLoc||(this.transformLoc=t.getUniformLocation(this.program,"transform")),this.colorLoc||(this.colorLoc=t.getUniformLocation(this.program,"color")),this.debug||t.colorMask(!1,!1,!1,!1)},e.end=function(){var t=this.gl;t.depthMask(!0),this._restore(),this.debug||t.colorMask(!0,!0,!0,!0)},e.draw=function(t){var e=this.gl;e.uniformMatrix4fv(this.transformLoc,!1,t),e.uniform3fv(this.colorLoc,[Math.random(),Math.random(),Math.random()]),e.drawArrays(e.TRIANGLE_STRIP,0,4)},e.remove=function(){var t=this.gl;return this.buffer&&t.deleteBuffer(this.buffer),this.program&&(t.deleteShader(this.program.fragmentShader),t.deleteShader(this.program.vertexShader),t.deleteProgram(this.program)),delete this.transformLoc,delete this.gl,this},e.stencilMask=function(t){return this.gl.stencilMask(t),this},e.stencilFunc=function(t,e,i){return this.ref=e,this.gl.stencilFunc(t,e,i),this},e.stencilOp=function(t,e,i){return this.gl.stencilOp(t,e,i),this},e.resetFunc=function(){return this.ref=1,this.gl.stencilFunc(this.gl.ALWAYS,1,255),this},e._save=function(){var t=this.gl;this._savedProgram=t.program},e._restore=function(){var t=this.gl;t.program=this._savedProgram,t.program&&t.useProgram(t.program)},e._createBuffer=function(){var t=this.gl;if(this.buffer=t.createBuffer(),!this.buffer)throw new Error("Failed to create the buffer object");t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.quadVertices,t.STATIC_DRAW)},e._createProgram=function(){var t=xl(this.gl,"\n attribute vec3 a_position;\n uniform mat4 transform;\n\n void main()\n {\n gl_Position = transform * vec4(a_position, 1.0);\n }\n","\n precision mediump float;\n uniform vec3 color;\n void main()\n {\n gl_FragColor = vec4(color, 1.0);\n }\n"),e=t.program,i=t.vertexShader,n=t.fragmentShader;e.vertexShader=i,e.fragmentShader=n,this.program=e},t}();function vc(t){return t instanceof Float32Array?"FLOAT":t instanceof Int16Array?"SHORT":t instanceof Uint16Array?"UNSIGNED_SHORT":t instanceof Int8Array?"BYTE":t instanceof Uint8Array||t instanceof Uint8ClampedArray?"UNSIGNED_BYTE":"FLOAT"}var yc=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.checkResources=function(){var t=this._geosToCheck;if(this._resourceChecked||t||(t=this.layer._geoList),!te(t))return[];for(var e=[],i={},n=t.length-1;n>=0;n--){var r=t[n]._getExternalResources();if(r.length)if(this.resources)for(var o=0;o<r.length;o++){var s=r[o][0];this.resources.isResourceLoaded(r[o])||i[s]||(e.push(r[o]),i[s]=1)}else e.push.apply(e,r)}return this._resourceChecked=!0,delete this._geosToCheck,e},i.render=function(){return this.layer._sortGeometries(),t.prototype.render.apply(this,arguments)},i._addGeoToCheckRes=function(t){t&&(Array.isArray(t)||(t=[t]),this._geosToCheck||(this._geosToCheck=[]),Wt(this._geosToCheck,t))},i.onGeometryAdd=function(t){this._addGeoToCheckRes(t),_c(this)},i.onGeometryRemove=function(){_c(this)},i.onGeometrySymbolChange=function(t){this._addGeoToCheckRes(t.target),_c(this)},i.onGeometryShapeChange=function(){_c(this)},i.onGeometryPositionChange=function(){_c(this)},i.onGeometryZIndexChange=function(){_c(this)},i.onGeometryShow=function(){_c(this)},i.onGeometryHide=function(){_c(this)},i.onGeometryPropertiesChange=function(){_c(this)},e}(Hr);function _c(t){t.layer.options.drawImmediate&&t.render(),t.setToRedraw()}var xc=new er,wc=[],bc=new er,Mc=function(t){function e(){return t.apply(this,arguments)||this}Dt(e,t);var i=e.prototype;return i.getImageData=function(){if(!this.layer.options.geometryEvents||!this._lastRenderTime||B()-this._lastRenderTime<32)return null;if(!this.context||!this.context.canvas)return null;if(!this._imageData){var t=this.context.canvas,e=t.width,i=t.height;try{this._imageData=this.context.getImageData(0,0,e,i)}catch(t){console.warn("hit detect failed with tainted canvas, some geometries have external resources in another domain:\n",t)}}return this._imageData},i.clearImageData=function(){this._imageData=null,delete this._imageData,this._lastRenderTime=B()},i.checkResources=function(){var e=this,i=t.prototype.checkResources.apply(this,arguments),n=this.layer.getStyle();return n&&(Array.isArray(n)||(n=[n]),n.forEach((function(t){for(var n=ni(t.symbol,!0),r=0,o=n.length;r<o;r++)e.resources.isResourceLoaded(n[r])||i.push(n[r])}))),i},i.needToRedraw=function(){var e=this.getMap();return!(!e.isInteracting()||!this.layer.options.enableAltitude)||!(e.isZooming()&&!e.isRotating()&&!e.getPitch()&&!this._hasPoint&&this.layer.constructor===Sa)&&t.prototype.needToRedraw.call(this)},i.draw=function(){if(this.getMap()){if(!this.layer.isVisible()||this.layer.isEmpty())return this.clearCanvas(),void this.completeRender();this.prepareCanvas(),this.drawGeos(),this.completeRender()}},i.isBlank=function(){return!!this.context&&!this.context.canvas._drawn},i.drawOnInteracting=function(){if(this._geosToDraw){this._updateMapStateCache(),this._updateDisplayExtent();var t=this.getMap(),e=this.layer.getCount(),i=this.mapStateCache.resolution;(t.isZooming()&&t.options.seamlessZoom&&void 0!==this._drawnRes&&i>1.5*this._drawnRes&&this._geosToDraw.length<e||t.isMoving()||t.isInteracting())&&(this.prepareToDraw(),this._batchConversionMarkers(this.mapStateCache.glRes),this._onlyHasPoint||this.forEachGeo(this.checkGeo,this),this._drawnRes=i),this._sortByDistanceToCamera(t.cameraPosition);for(var n=0,r=this._geosToDraw.length;n<r;n++){var o=this._geosToDraw[n];o._isCheck||o.isVisible()?(o._paint(this._displayExtent),this._geosToDraw[n]._cPoint=void 0,this._geosToDraw[n]._inCurrentView=void 0):(delete o._cPoint,delete o._inCurrentView)}this.clearImageData()}},i.show=function(){this.layer.forEach((function(t){t._repaint()})),t.prototype.show.apply(this,arguments)},i.forEachGeo=function(t,e){this.layer.forEach(t,e)},i.drawGeos=function(){this._updateMapStateCache(),this._drawnRes=this.mapStateCache.resolution,this._updateDisplayExtent(),this.prepareToDraw(),this._batchConversionMarkers(this.mapStateCache.glRes),this._onlyHasPoint||this.forEachGeo(this.checkGeo,this),this._sortByDistanceToCamera(this.getMap().cameraPosition);for(var t=0,e=this._geosToDraw.length;t<e;t++)this._geosToDraw[t]._paint(),this._geosToDraw[t]._cPoint=void 0,this._geosToDraw[t]._inCurrentView=void 0;this.clearImageData()},i.prepareToDraw=function(){this._hasPoint=!1,this._geosToDraw=[]},i.checkGeo=function(t){if("Point"!==t.type||void 0===this._onlyHasPoint){if(t._isCheck=!1,t&&t.isVisible()&&t.getMap()&&t.getLayer()&&t.getLayer().isCanvasRender()){var e=t._getPainter(),i=!0;if(t._inCurrentView)i=!0;else if(!1===t._inCurrentView)i=!1;else{var n=e.get2DExtent(this.resources,xc);n&&n.intersects(this._displayExtent)||(i=!1)}i&&(e.hasPoint()&&(this._hasPoint=!0),t._isCheck=!0,this._geosToDraw.push(t))}}else t._inCurrentView&&(this._hasPoint=!0,t._isCheck=!0,this._geosToDraw.push(t))},i.onZoomEnd=function(){delete this.canvasExtent2D,t.prototype.onZoomEnd.apply(this,arguments)},i.onRemove=function(){this.forEachGeo((function(t){t.onHide()})),delete this._geosToDraw},i.onGeometryPropertiesChange=function(e){e&&this.layer._styleGeometry(e.target),t.prototype.onGeometryPropertiesChange.call(this,e)},i._updateDisplayExtent=function(){var t=this.canvasExtent2D;if(this._maskExtent){if(!this._maskExtent.intersects(t))return void this.completeRender();t=t.intersection(this._maskExtent)}this._displayExtent=t},i.identifyAtPoint=function(t,e){void 0===e&&(e={});var i=this._geosToDraw;return i?this.layer._hitGeos(i,t,e):[]},i._updateMapStateCache=function(){var t=this.getMap(),e=t._pointToContainerPoint(this.southWest)._add(0,-t.height),i=t.getResolution(),n=t.getPitch(),r=t.getBearing(),o=t.getGLScale(),s=t.getGLRes(),a=t.getContainerExtent(),h=t._get2DExtent(),l=t._get2DExtentAtRes(s);return this.mapStateCache={resolution:i,pitch:n,bearing:r,glScale:o,glRes:s,_2DExtent:h,glExtent:l,containerExtent:a,offset:e},this},i._batchConversionMarkers=function(t){if(this._onlyHasPoint=void 0,!this._constructorIsThis())return[];var e=[],i=[],n=[],r={},o=this.layer,s=o.options,a=o.getAltitude?o.getAltitude():0,h=o.isCanvasRender();this._onlyHasPoint=!0;for(var l=0,c=0,u=this.layer._geoList.length;c<u;c++){var d=this.layer._geoList[c];if("Point"===d.getType()){var p=d._painter;p||(p=d._getPainter());var f=p.getRenderPoints("center")[0][0],m=s.enableAltitude?d._getAltitude():a;void 0===r[m]&&(r[m]=p.getAltitude()),e[l]=f,n[l]=r[m],i[l]=d,l++}else this._onlyHasPoint=!1}if(0===l)return[];var g=this.getMap(),v=fe(e,"_pt");v=g._pointsAtResToContainerPoints(e,t,n,v);for(var y=g.getContainerExtent(),_=y.xmax,x=y.ymax,w=y.xmin,b=y.ymin,M={},S=0,T=i.length;S<T;S++){var E=i[S];if(E._cPoint=v[S],E._cPoint){var C=v[S],P=C.x,A=C.y;if(E._inCurrentView=P>=w&&A>=b&&P<=_&&A<=x,!E._inCurrentView){var L=E.getSymbolHash(),R=void 0;R=L?M[L]=M[L]||E._painter.getFixedExtent():E._painter.getFixedExtent(),bc.set(R.xmin,R.ymin,R.xmax,R.ymax),bc._add(v[S]),E._inCurrentView=bc.intersects(y)}E._inCurrentView&&(E.isVisible()&&h||(E._inCurrentView=!1),this._onlyHasPoint&&E._inCurrentView&&(this._hasPoint=!0,E._isCheck=!0,this._geosToDraw.push(E)))}else E._inCurrentView=!1}return v},i._sortByDistanceToCamera=function(t){if(this.layer.options.sortByDistanceToCamera&&this._geosToDraw.length){var e=this.getMap(),i=e.distanceToPoint(1e3,0,e.getGLScale()).x/1e3,n="center";this._geosToDraw.sort((function(e,r){var o=e.getType(),s=r.getType();if("Point"!==o||"Point"!==s)return 0;var a=e._painter,h=r._painter;if(!a||!h)return 0;var l=a.getRenderPoints(n)[0][0],c=h.getRenderPoints(n)[0][0],u=a.getAltitude()*i,d=h.getAltitude()*i;ja(wc,l.x,l.y,u);var p=Za(wc,t);return ja(wc,c.x,c.y,d),Za(wc,t)-p}))}},i._constructorIsThis=function(){return this.constructor===e},e}(yc);Sa.registerRenderer("canvas",Mc);var Sc=function(t){function e(e){var i;return(i=t.call(this)||this).map=e,i._handlerQueue=[],i._thisDocVisibilitychange=i._onDocVisibilitychange.bind(It(It(i))),i._thisDocDragStart=i._onDocDragStart.bind(It(It(i))),i._thisDocDragEnd=i._onDocDragEnd.bind(It(It(i))),i}Dt(e,t);var i=e.prototype;return i.callInNextFrame=function(t){this._handlerQueue.push(t)},i.executeFrameCallbacks=function(){var t=this._handlerQueue;this._handlerQueue=[];for(var e=0,i=t.length;e<i;e++)t[e]()},i.offsetPlatform=function(t,e){if(!this.map._panels.front)return this;if(!e&&0===t.x&&0===t.y)return this;var i=this.map._panels,n=this._frontCount=i.back.layerDOM.childElementCount,r=this._backCount=i.front.layerDOM.childElementCount,o=this._uiCount=i.front.uiDOM.childElementCount;if(n||r||o){var s=this.map.offsetPlatform();s=t?s.add(t)._round():s.round(),r&&Yi(i.back,s),(n||o)&&Yi(i.front,s)}return this},i.domChanged=function(){var t=this.map._panels;if(!t.front)return!1;var e=t.back.layerDOM.childElementCount;if(void 0===this._frontCount||this._frontCount!==e)return!0;var i=t.front.layerDOM.childElementCount;if(void 0===this._backCount||this._backCount!==i)return!0;var n=t.front.uiDOM.childElementCount;return void 0===this._uiCount||this._uiCount!==n},i.resetContainer=function(){if(this.map&&(this.map._resetMapViewPoint(),this.map._panels.front)){var t=new Bt(0,0);Yi(this.map._panels.back,t),Yi(this.map._panels.front,t)}},i.onZoomEnd=function(){this.resetContainer()},i.onLoad=function(){this._frameLoop()},i._onDocVisibilitychange=function(){"visible"===document.visibilityState&&this.setToRedraw()},i._getWrapPanel=function(){if(!this.map)return null;var t=this.map.getPanels();return t&&t.mapWrapper},i._onDocDragStart=function(){var t=this._getWrapPanel();t&&(t.style.overflow="visible")},i._onDocDragEnd=function(){var t=this._getWrapPanel();t&&(t.style.overflow="hidden")},i._containerIsOffscreen=function(){var t=this.map.getContainer();return!t||!t.style||"none"===t.style.display||Math.min(t.clientWidth,t.clientHeight)<=0},e}(Ln),Tc=function(t){function e(e){var i;return(i=t.call(this,e)||this)._containerIsCanvas=!!e._containerDOM.getContext,i._registerEvents(),i._loopTime=0,i}Dt(e,t);var i=e.prototype;return i.load=function(){this.initContainer()},i.renderFrame=function(t){var e=this.map;if(!e||!e.options.renderable)return!1;if(e.options.stopRenderOnOffscreen&&this._containerIsOffscreen())return!0;this._updateDomPosition(t),delete this._isViewChanged,e._fireEvent("framestart"),this.updateMapDOM(),e.clearCollisionIndex();var i=this._getAllLayerToRender();return this.drawLayers(i,t),this.drawLayerCanvas(i)&&(this.drawTops(),this._drawCenterCross(),e.options.debugSky&&this._debugSky()),this._needClear=!1,e._fireEvent("frameend"),this._recordView(),this._mapview=this._getMapView(),delete this._spatialRefChanged,this._fireLayerLoadEvents(),this.executeFrameCallbacks(),this._canvasUpdated=!1,e.uiCollides(),!0},i.updateMapDOM=function(){var t=this.map;if(!t.isZooming()){var e=t._getViewPointFrameOffset();e?t.offsetPlatform(e):this.domChanged()&&this.offsetPlatform(null,!0)}},i.drawLayers=function(t,e){for(var i=this.map,n=i.isInteracting(),r=[],o=[],s=i.options.fpsOnInteracting||0,a=0===s?0:1e3/s,h=this.map.options.layerCanvasLimitOnInteracting,l=t.length,c=i.getBaseLayer(),u=0,d=0;d<l;d++){var p=t[d];if(p.isVisible()){var f=p.isCanvasRender();f&&r.push(p.getId());var m=p._getRenderer();if(m){var g=this._checkLayerRedraw(p);f&&m.isCanvasUpdated()&&(g||o.push(p.getId()),this.setLayerCanvasUpdated());var v=m.__zoomTransformMatrix;if(delete m.__zoomTransformMatrix,g){if(n&&f){if(h>0&&l-1-d>h&&p!==c){p._getRenderer().clearCanvas();continue}u+=this._drawCanvasLayerOnInteracting(p,u,a,e)}else n&&m.drawOnInteracting?(m.prepareRender&&m.prepareRender(),m.checkAndDraw?m.checkAndDraw(m.drawOnInteracting,this._eventParam,e):m.drawOnInteracting(this._eventParam,e)):(m.render(e),f&&v&&m.isLoadingResource()&&(m.__zoomTransformMatrix=v));f&&(o.push(p.getId()),this.setLayerCanvasUpdated())}else f&&n&&(i.isZooming()&&!i.getPitch()?(m.prepareRender(),m.__zoomTransformMatrix=this._zoomMatrix):(i.getPitch()||i.isRotating())&&m.clearCanvas())}}}var y=this._canvasIds||[],_=this._updatedIds||[];if(this._canvasIds=r,this._updatedIds=o,!this.isLayerCanvasUpdated()){var x="---";y.join(x)===r.join(x)&&_.join(x)===o.join(x)||this.setLayerCanvasUpdated()}},i._checkLayerRedraw=function(t){if(this.isSpatialReferenceChanged())return!0;var e=this.map,i=t._getRenderer();return t.isCanvasRender()?i.testIfNeedRedraw():!(!i.needToRedraw||!i.needToRedraw())||(e.isInteracting()||this.isViewChanged())},i._drawCanvasLayerOnInteracting=function(t,e,i,n){var r=this.map,o=t._getRenderer(),s=o.getDrawTime(),a=0===i||i>0&&e+s<=i;if(o.mustRenderOnInteracting&&o.mustRenderOnInteracting())o.render(n);else{if(o.drawOnInteracting&&(t===r.getBaseLayer()||a||r.isZooming()&&t.options.forceRenderOnZooming||r.isMoving()&&t.options.forceRenderOnMoving||r.isRotating()&&t.options.forceRenderOnRotating))return o.prepareRender(),o.prepareCanvas(),o.checkAndDraw?o.checkAndDraw(o.drawOnInteracting,this._eventParam,n):o.drawOnInteracting(this._eventParam,n),s;!r.isZooming()||r.getPitch()||r.isRotating()?(r.getPitch()||r.isRotating())&&o.clearCanvas():(o.prepareRender(),o.__zoomTransformMatrix=this._zoomMatrix)}return o.drawOnInteracting&&!a&&o.onSkipDrawOnInteracting(this._eventParam,n),0},i._fireLayerLoadEvents=function(){if(this._updatedIds&&this._updatedIds.length>0){var t=this.map;this._updatedIds.reverse().forEach((function(e){var i=t.getLayer(e);if(i){var n=i._getRenderer();n&&n.isRenderComplete()&&i.fire("layerload")}}))}},i.isLayerCanvasUpdated=function(){return this._canvasUpdated},i.setLayerCanvasUpdated=function(){this._canvasUpdated=!0},i.drawLayerCanvas=function(t){var e=this.map;if(!e)return!1;if(!this.isLayerCanvasUpdated()&&!this.isViewChanged()&&!1===this._needClear)return!1;this.canvas||this.createCanvas(),e._fireEvent("renderstart",{context:this.context}),this._updateCanvasSize()||this.clearCanvas();for(var i,n=e.isInteracting(),r=e.options.layerCanvasLimitOnInteracting,o=t.length,s=[],a=0;a<o;a++){if(t[a].isVisible()&&t[a].isCanvasRender())if(t[a]._getRenderer()){var h=this._getLayerImage(t[a]);h&&h.image&&(t[a]===e.getBaseLayer()?i=[t[a],h]:s.push([t[a],h]))}}var l=this.canvas.width,c=this.canvas.height;i&&(this._drawLayerCanvasImage(i[0],i[1],l,c),this._drawFog()),o=s.length;for(var u=n&&r>=0&&o>r?o-r:0;u<o;u++)this._drawLayerCanvasImage(s[u][0],s[u][1],l,c);return e._fireEvent("renderend",{context:this.context}),!0},i.setToRedraw=function(){var t=this._getAllLayerToRender();this._needClear=!0;for(var e=0,i=t.length;e<i;e++){var n=t[e].getRenderer();n&&n.canvas&&n.setToRedraw&&n.setToRedraw()}},i.updateMapSize=function(t){if(t&&!this._containerIsCanvas){var e=t.width+"px",i=t.height+"px",n=this.map._panels;n.mapWrapper.style.width=e,n.mapWrapper.style.height=i,this._updateCanvasSize()}},i.getMainPanel=function(){return this.map?this._containerIsCanvas?this.map._containerDOM:this.map._panels?this.map._panels.mapWrapper:null:null},i.toDataURL=function(t,e){return this.canvas?this.canvas.toDataURL(t,e):null},i.remove=function(){Ot.webgl&&"undefined"!=typeof document&&(Vi(document,"visibilitychange",this._thisDocVisibilitychange),Vi(document,"dragstart",this._thisDocDragStart),Vi(document,"dragend",this._thisDocDragEnd)),this._resizeInterval&&clearInterval(this._resizeInterval),delete this.context,delete this.canvas,delete this.map,delete this._spatialRefChanged,this._cancelFrameLoop()},i.hitDetect=function(t){var e=this.map;if(e&&e.options.hitDetect&&!e.isInteracting()){var i=e._getLayers(),n="default",r=e.options.hitDetectLimit||0,o=0;t&&t._round&&t._round();for(var s=i.length-1;s>=0;s--){var a=i[s];if(!(!a.options.hitDetect||a.isEmpty&&a.isEmpty())){var h=a._getRenderer();if(h&&h.hitDetect&&(!h.isBlank||!h.isBlank())){if("default"!==a.options.cursor&&h.hitDetect(t)){n=a.options.cursor||"pointer";break}if(o++,r>0&&o>r)break}}}e._trySetCursor(n)}},i._getLayerImage=function(t){var e=t._getRenderer();return e.getCanvasImage?e.getCanvasImage():null},i.initContainer=function(){var t=this.map._panels;function e(e,i,n,r){var o=Hi("div",i);return n&&(o.style.cssText=n),t[e]=o,r||Xi(o),o}var i=this.map._containerDOM;if(!this._containerIsCanvas){i.innerHTML="";var n="position:absolute;top:0px;left:0px;",r=e("mapWrapper","maptalks-wrapper","position:absolute;overflow:hidden;",!0),o=e("allLayers","maptalks-all-layers",n+"padding:0px;margin:0px;z-index:0;overflow:visible;",!0),s=e("backStatic","maptalks-back-static",n+"z-index:0;",!0),a=e("back","maptalks-back",n+"z-index:1;"),h=e("backLayer","maptalks-back-layer",n),l=e("canvasContainer","maptalks-canvas-layer",n+"border:none;z-index:2;"),c=e("frontStatic","maptalks-front-static",n+"z-index:3;",!0),u=e("front","maptalks-front",n+"z-index:4;",!0),d=e("frontLayer","maptalks-front-layer",n+"z-index:0;"),p=e("ui","maptalks-ui",n+"border:none;z-index:1;",!0),f=e("control","maptalks-control","z-index:1",!0);i.appendChild(r),o.appendChild(s),a.appendChild(h),a.layerDOM=h,o.appendChild(a),o.appendChild(l),u.appendChild(d),u.layerDOM=d,u.uiDOM=p,o.appendChild(c),o.appendChild(u),u.appendChild(p),r.appendChild(o),r.appendChild(f),this.createCanvas(),this.resetContainer();var m=this.map._getContainerDomSize();this.updateMapSize(m)}},i.isViewChanged=function(){if(void 0!==this._isViewChanged)return this._isViewChanged;var t=this._mapview,e=this._getMapView();return this._isViewChanged=!t||!ue(t,e),this._isViewChanged},i._recordView=function(){var t=this.map;!t._onViewChange||t.isInteracting()||t.isAnimating()||ue(t.getView(),t._getCurrentView())||t._onViewChange(t.getView())},i.isSpatialReferenceChanged=function(){return this._spatialRefChanged},i._getMapView=function(){var t=this.map,e=t._getPrjCenter();return{x:e.x,y:e.y,zoom:t.getZoom(),pitch:t.getPitch(),bearing:t.getBearing(),width:t.width,height:t.height}},i._frameLoop=function(t){var e=this;this.map?(t=t||0,this._frameTimestamp=t,this._resizeCount=0,this.renderFrame(t),this._animationFrame=kt((function(t){e._frameLoop(t)}))):this._cancelFrameLoop()},i._cancelFrameLoop=function(){this._animationFrame&&zt(this._animationFrame)},i._drawLayerCanvasImage=function(t,e,i,n){var r=this.context,o=e.point.round(),s=this.map.getDevicePixelRatio();1!==s&&o._multi(s);var a=e.image,h=a.width,l=a.height;if(!(o.x+h<=0||o.y+l<=0)){var c=t.options.opacity;if(j(c)||(c=1),!(c<=0)){var u=e.opacity;if(j(u)||(u=1),!(u<=0)){var d=r.globalAlpha;c<1&&(r.globalAlpha*=c),u<1&&(r.globalAlpha*=u),t.options.cssFilter&&(r.filter=t.options.cssFilter);var p=t.getRenderer(),f=p.__zoomTransformMatrix,m=p.clipCanvas(this.context);f&&(r.save(),r.setTransform.apply(r,f)),r.drawImage(a,0,0,h,l,o.x,o.y,i,n),f&&r.restore(),m&&r.restore(),"none"!==r.filter&&(r.filter="none"),r.globalAlpha=d}}}},i._drawCenterCross=function(){var t=this.map.options.centerCross;if(t){var e=this.context,i=new Bt(this.canvas.width/2,this.canvas.height/2);W(t)?t(e,i):wn.drawCross(this.context,i.x,i.y,2,"#f00")}},i._drawContainerExtent=function(){var t=this.map.options.cascadePitches,e=this.map.height-this.map._getVisualHeight(t[0]),i=this.map.height-this.map._getVisualHeight(t[1]),n=this.map.getContainerExtent(),r=this.context;r.beginPath(),r.moveTo(0,n.ymin),r.lineTo(n.xmax,n.ymin),r.stroke(),r.beginPath(),r.moveTo(0,e),r.lineTo(n.xmax,e),r.stroke(),r.beginPath(),r.moveTo(0,i),r.lineTo(n.xmax,i),r.stroke()},i._drawFog=function(){var t=this.map;if(!(t.getPitch()<=t.options.maxVisualPitch)&&t.options.fog){var e=t.getDevicePixelRatio(),i=this.context,n=t.getContainerExtent(),r=(t.height-t._getVisualHeight(75))*e;r<0&&(r=0);var o=n.ymin*e,s=Math.ceil(o-r),a=t.options.fogColor.join(),h=i.createLinearGradient(0,r,0,o+30),l=1-30/(s+30);h.addColorStop(0,"rgba("+a+", 0)"),h.addColorStop(.3,"rgba("+a+", 0.3)"),h.addColorStop(l,"rgba("+a+", 1)"),h.addColorStop(1,"rgba("+a+", 0)"),i.beginPath(),i.fillStyle=h,i.fillRect(0,r,Math.ceil(n.getWidth())*e,Math.ceil(s+30))}},i._debugSky=function(){var t=this.map;if(!t)return this;var e=t.getContainerExtent().ymin;if(e<=0)return this;var i=this.context;return i.strokeStyle="red",i.strokeRect(0,0,t.width,e),this},i._getAllLayerToRender=function(){return this.map._getLayers()},i.clearCanvas=function(){this.canvas&&wn.clearRect(this.context,0,0,this.canvas.width,this.canvas.height)},i._updateCanvasSize=function(){if(!this.canvas||this._containerIsCanvas)return!1;var t=this.map,e=t.getSize(),i=this.canvas,n=_e(e,t.getDevicePixelRatio()),r=n.width,o=n.height,s=n.cssWidth,a=n.cssHeight;return!i.style||i.style.width===s&&i.style.height===a||(i.style.width=s,i.style.height=a),(r!==i.width||o!==i.height)&&(i.height=o,i.width=r,this.topLayer.width=i.width,this.topLayer.height=i.height,!0)},i.createCanvas=function(){this.topLayer=Hi("canvas"),this.topCtx=this.topLayer.getContext("2d"),this._containerIsCanvas?this.canvas=this.map._containerDOM:(this.canvas=Hi("canvas"),this._updateCanvasSize(),this.map._panels.canvasContainer.appendChild(this.canvas)),this.context=this.canvas.getContext("2d")},i._updateDomPosition=function(t){return void 0===this._checkPositionTime&&(this._checkPositionTime=-1/0),Math.abs(t-this._checkPositionTime)>=500&&(Ji(this.map._containerDOM),this._checkPositionTime=Math.min(t,this._checkPositionTime)),this},i._checkSize=function(){this.map&&this.map.checkSize()},i._setCheckSizeInterval=function(t){var e=this;Ot.resizeObserver?(this._resizeObserver&&this._resizeObserver.disconnect(),this.map&&(this._resizeObserver=new ResizeObserver((function(t){!e.map||e.map.isRemoved()?e._resizeObserver.disconnect():t.length&&(e.map._containerDomContentRect=t[0].contentRect,e._checkSize(t[0].contentRect),e._resizeCount=e._resizeCount||0,e.renderFrame((e._frameTimestamp||0)+ ++e._resizeCount/100))})),this._resizeObserver.observe(this.map._containerDOM))):(clearInterval(this._resizeInterval),this._checkSizeInterval=t,this._resizeInterval=setInterval((function(){!e.map||e.map.isRemoved()?clearInterval(e._resizeInterval):e._checkSize()}),this._checkSizeInterval))},i._registerEvents=function(){var t=this,e=this.map;e.options.checkSize&&!Q&&"undefined"!=typeof window&&this._setCheckSizeInterval(e.options.checkSizeInterval),Ot.mobile||e.on("_mousemove",this._onMapMouseMove,this),e.on("_dragrotatestart _dragrotating _dragrotateend _movestart _moving _moveend _zoomstart",(function(e){t._eventParam=e})),e.on("_zooming",(function(i){e.getPitch()||(t._zoomMatrix=i.matrix.container),t._eventParam=i})),e.on("_zoomend",(function(e){t._eventParam=e,delete t._zoomMatrix})),e.on("_spatialreferencechange",(function(){t._spatialRefChanged=!0})),Ot.webgl&&"undefined"!=typeof document&&(Ui(document,"visibilitychange",this._thisDocVisibilitychange,this),Ui(document,"dragstart",this._thisDocDragStart,this),Ui(document,"dragend",this._thisDocDragEnd,this)),Ot.addDPRListening&&Ot.addDPRListening(this.map)},i._onMapMouseMove=function(t){var e=this,i=this.map;!i.isInteracting()&&i.options.hitDetect&&(this._hitDetectFrame&&zt(this._hitDetectFrame),this._hitDetectFrame=kt((function(){e.hitDetect(t.containerPoint)})))},i._getCanvasLayers=function(){return this.map._getLayers((function(t){return t.isCanvasRender()}))},i.addTopElement=function(t){this._tops||(this._tops=[]),this._tops.push(t)},i.removeTopElement=function(t){if(this._tops){var e=this._tops.indexOf(t);e>=0&&this._tops.splice(e,1)}},i.getTopElements=function(){return this._tops||[]},i.drawTops=function(){this.topCtx.clearRect(0,0,this.topLayer.width,this.topLayer.height),this.map.fire("drawtopstart"),this.map.fire("drawtops");for(var t=this.getTopElements(),e=!1,i=0;i<t.length;i++)t[i].render(this.topCtx)&&(e=!0);e&&this.context.drawImage(this.topLayer,0,0),this.map.fire("drawtopsend")},e}(Sc);Ss.registerRenderer("canvas",Tc),Ss.mergeOptions({fog:!1,fogColor:[233,233,233]});var Ec=Object.freeze({ResourceCache:jr,CanvasRenderer:Hr,ImageGLRenderable:Pl,MapRenderer:Sc,MapCanvasRenderer:Tc,Renderable:wr,ImageLayerCanvasRenderer:Dl,ImageLayerGLRenderer:Il,TileLayerCanvasRenderer:sc,TileLayerGLRenderer:uc,CanvasTileLayerCanvasRenderer:pc,CanvasTileLayerGLRenderer:fc,QuadStencil:gc,OverlayLayerCanvasRenderer:yc,VectorLayerCanvasRenderer:Mc,CanvasLayerRenderer:kl}),Cc={_getRenderPoints:function(){return[[this._getCenter2DPoint(this.getMap().getGLRes())],null]}};Vs.include(Cc),ra.include(Cc),na.include(Cc),sa.include(Cc),oa.include({_getRenderPoints:function(t){var e=this.getMap(),i=e.getGLRes();if("vertex"===t){for(var n=this._trimRing(this.getShell()),r=[],o=0,s=n.length;o<s;o++)r.push(e.coordToPointAtRes(n[o],i));return[r,null]}return[[e.coordToPointAtRes(this.getCenter(),i)],null]}});var Pc={_getRenderPoints:function(t){var e,i=this.getMap(),n=i.getGLRes(),r=null;if("point"===t)(e=this._getPath2DPoints(this._getPrjCoordinates(),!1,n))&&e.length>0&&Array.isArray(e[0])&&(e=e[0].concat(e[1]));else if("vertex"===t)if(r=[],(e=this._getPath2DPoints(this._getPrjCoordinates(),!1,n))&&e.length>0&&Array.isArray(e[0])){for(var o=0,s=e.length;o<s;o++)for(var a=0,h=e[o].length;a<h;a++)0===a?r.push([e[o][a],e[o][a+1]]):r.push([e[o][a-1],e[o][a]]);e=e[0].concat(e[1])}else for(var l=0,c=e.length;l<c;l++)0===l?r.push([e[l],e[l+1]]):r.push([e[l-1],e[l]]);else if("line"===t){e=[],r=[];var u=this._getPath2DPoints(this._getPrjCoordinates(),!1,n);if(u.length>0&&Array.isArray(u[0]))for(var d,p=1,f=u.length;p<f;p++){d=u[p],this instanceof js&&d.length>0&&!d[0].equals(d[d.length-1])&&d.push(d[0]);for(var m=1,g=d.length;m<g;m++)e.push(d[m].add(d[m-1])._multi(.5)),r.push([d[m-1],d[m]])}else{this instanceof js&&u.length>0&&!u[0].equals(u[u.length-1])&&u.push(u[0]);for(var v=1,y=u.length;v<y;v++)e.push(u[v].add(u[v-1])._multi(.5)),r.push([u[v-1],u[v]])}}else if("vertex-first"===t){var _=this._getPrjCoordinates(),x=_.length,w=x?i._prjToPointAtRes(_[0],n):null;e=x?[w]:[],r=x?[[w,_[1]?i._prjToPointAtRes(_[1],n):w]]:[]}else if("vertex-last"===t){var b=this._getPrjCoordinates(),M=b.length,S=M?i._prjToPointAtRes(b[M-1],n):null;e=M?[S]:[];var T=M>1?M-2:M-1;r=M?[[b[T]?i._prjToPointAtRes(b[T],n):S,S]]:[]}else{var E=this.getCenter();if(E){var C=this._getProjection().project(E);e=[i._prjToPointAtRes(C,n)]}else e=[]}return[e,r]}};Zs.include(Pc),js.include(Pc);var Ac={within:!1,center:[0,0]};function Lc(t){if(t&&t._containerBbox){Ac.within=!1;var e=t._containerBbox,i=e.minx,n=e.miny,r=e.maxx,o=e.maxy,s=Math.abs(r-i),a=Math.abs(o-n);s<=1&&a<=1&&(Ac.within=!0,Ac.center[0]=(i+r)/2,Ac.center[1]=(n+o)/2),delete t._containerBbox}else Ac.within=!1;return Ac}os.include({_redrawWhenPitch:function(){return!1},_redrawWhenRotate:function(){return!1}});var Rc={_redrawWhenPitch:function(){return!0},_redrawWhenRotate:function(){return this instanceof ra||this instanceof sa},_paintAsPath:function(){var t=this.getMap();return this._getAltitude()>0||t.getPitch()||this instanceof ra&&t.getBearing()},_getPaintParams:function(){var t=this.getMap();if(this._paintAsPath())return js.prototype._getPaintParams.call(this,!0);var e=this._getPrjCoordinates(),i=t._prjToPointAtRes(e,t.getGLRes()),n=this._getRenderSize(i);return[i].concat(n)},_paintOn:function(){return this._paintAsPath()?wn.polygon.apply(wn,arguments):wn.ellipse.apply(wn,arguments)},_getRenderSize:function(t){var e=this.getMap(),i=e.getGLRes(),n=this._getPrjExtent(),r=e._prjToPointAtRes(n.getMin(),i),o=e._prjToPointAtRes(n.getMax(),i);return[Math.abs(o.x-r.x)/2,Math.abs(o.y-t.y),Math.abs(t.y-r.y)]}};ra.include(Rc),na.include(Rc),oa.include({_getPaintParams:function(){var t=this.getMap(),e=this._getPrjShell();return[this._getPath2DPoints(e,!1,t.getGLRes())]},_paintOn:wn.polygon}),sa.include(Rc,{_redrawWhenPitch:function(){return!0},_getPaintParams:function(){if(this._paintAsPath())return js.prototype._getPaintParams.call(this,!0);var t=this.getMap(),e=t._prjToPointAtRes(this._getPrjCoordinates(),t.getGLRes());return[e,this._getRenderSize(e)[0],[this.getStartAngle(),this.getEndAngle()]]},_paintOn:function(){if(this._paintAsPath())return wn.polygon.apply(wn,arguments);var t=this.getMap().getBearing(),e=arguments;return t&&(e[3]=e[3].slice(0),e[3][0]+=t,e[3][1]+=t),wn.sector.apply(wn,e)}}),Ns.include({_paintAsPath:function(){return!0}}),Zs.include({arrowStyles:{classic:[3,4]},_getArrowShape:function(t,e,i,n,r){if(!t||!e||t.equals(e))return null;r||(r=0);var o,s=i*n[0],a=i*n[1]+r,h=s/2+r;(o=e.nextCtrlPoint||e.prevCtrlPoint?e.prevCtrlPoint?e.sub(new Bt(e.prevCtrlPoint)):e.sub(new Bt(e.nextCtrlPoint)):e.sub(t))._unit();var l=e.sub(o.multi(a));o._perp();var c=l.add(o.multi(h));return o._multi(-1),[c,e,l.add(o.multi(h)),c]},_getPaintParams:function(){var t=this._getPrjCoordinates();return[this._getPath2DPoints(t,!1,this.getMap().getGLRes())]},_paintOn:function(t,e,i,n,r){var o=Lc(this._painter);o.within?wn.pixelRect(t,o.center,i,n):this.options.smoothness?wn.paintSmoothLine(t,e,i,this.options.smoothness,!1,this._animIdx,this._animTailRatio):wn.path(t,e,i,null,r),this._paintArrow(t,e,i)},_getArrowPlacement:function(){return this.options.arrowPlacement},_getArrowStyle:function(){var t=this.options.arrowStyle;return t?Array.isArray(t)?t:this.arrowStyles[t]:null},_getArrows:function(t,e,i){var n=this._getArrowStyle();if(!n||t.length<2)return[];for(var r=t.length>0&&Array.isArray(t[0])?t:[t],o=this._getArrowPlacement(),s=[],a=this.getMap(),h=a.coordToContainerPoint(this.getFirstCoordinate()),l=a.coordToContainerPoint(this.getLastCoordinate()),c=r.length-1;c>=0;c--){if("vertex-first"===o||"vertex-firstlast"===o&&r[c][0].closeTo(h,.01)){var u=this._getArrowShape(r[c][1],r[c][0],e,n,i);u&&s.push(u)}if("vertex-last"===o||"vertex-firstlast"===o&&r[c][r[c].length-1].closeTo(l,.01)){var d=this._getArrowShape(r[c][r[c].length-2],r[c][r[c].length-1],e,n,i);d&&s.push(d)}else"point"===o&&this._getArrowPoints(s,r[c],e,n,i)}return s},_getArrowPoints:function(t,e,i,n,r){for(var o=0,s=e.length-1;o<s;o++){var a=this._getArrowShape(e[o],e[o+1],i,n,r);a&&t.push(a)}},_paintArrow:function(t,e,i){var n=this._getInternalSymbol().lineWidth;(!j(n)||n<3)&&(n=3);var r=this._getArrows(e,n);if(r.length){t.setLineDash&&t.setLineDash([]);for(var o=r.length-1;o>=0;o--)t.fillStyle=t.strokeStyle,wn.polygon(t,r[o],i,i)}}}),js.include({_getPaintParams:function(t){var e=this.getMap().getGLRes(),i=this._getPrjShell(),n=this._getPath2DPoints(i,t,e),r=n.length>0&&Array.isArray(n[0]);r&&(n=[[n[0]],[n[1]]]);var o=this._getPrjHoles(),s=[];if(o&&o.length>0){for(var a=this._simplified,h=0;h<o.length;h++){var l=this._getPath2DPoints(o[h],t,e);Array.isArray(l)&&r?Array.isArray(l[0])?(n[0].push(l[0]),n[1].push(l[1])):n[0].push(l):s.push(l)}a&&(this._simplified=a)}return r||Wt(n=[n],s),[n]},_paintOn:function(t,e,i,n,r){var o=Lc(this._painter);o.within?wn.pixelRect(t,o.center,i,n):wn.polygon(t,e,i,n,r,this.options.smoothness)}}),Ss.VERSION="1.0.0-rc.18";var Oc={Actor:zr};
|
|
12
|
-
/**
|
|
13
|
-
* @license
|
|
14
|
-
* Copyright 2010-2021 Three.js Authors
|
|
15
|
-
* SPDX-License-Identifier: MIT
|
|
16
|
-
*/const Dc="127",Ic=0,kc=1,zc=2,Fc=1,Bc=2,Nc=3,Hc=0,jc=1,Gc=2,Uc=0,Vc=1,Wc=2,Zc=3,qc=4,Xc=5,Yc=100,Jc=101,Qc=102,Kc=103,$c=104,tu=200,eu=201,iu=202,nu=203,ru=204,ou=205,su=206,au=207,hu=208,lu=209,cu=210,uu=0,du=1,pu=2,fu=3,mu=4,gu=5,vu=6,yu=7,_u=0,xu=1,wu=2,bu=0,Mu=1,Su=2,Tu=3,Eu=4,Cu=5,Pu=300,Au=301,Lu=302,Ru=303,Ou=304,Du=306,Iu=307,ku=1e3,zu=1001,Fu=1002,Bu=1003,Nu=1004,Hu=1005,ju=1006,Gu=1007,Uu=1008,Vu=1009,Wu=1010,Zu=1011,qu=1012,Xu=1013,Yu=1014,Ju=1015,Qu=1016,Ku=1017,$u=1018,td=1019,ed=1020,id=1021,nd=1022,rd=1023,od=1024,sd=1025,ad=rd,hd=1026,ld=1027,cd=1028,ud=1029,dd=1030,pd=1031,fd=1032,md=1033,gd=33776,vd=33777,yd=33778,_d=33779,xd=35840,wd=35841,bd=35842,Md=35843,Sd=36196,Td=37492,Ed=37496,Cd=37808,Pd=37809,Ad=37810,Ld=37811,Rd=37812,Od=37813,Dd=37814,Id=37815,kd=37816,zd=37817,Fd=37818,Bd=37819,Nd=37820,Hd=37821,jd=36492,Gd=37840,Ud=37841,Vd=37842,Wd=37843,Zd=37844,qd=37845,Xd=37846,Yd=37847,Jd=37848,Qd=37849,Kd=37850,$d=37851,tp=37852,ep=37853,ip=2300,np=2301,rp=2302,op=2400,sp=2401,ap=2402,hp=2500,lp=2501,cp=3e3,up=3001,dp=3007,pp=3002,fp=3003,mp=3004,gp=3005,vp=3006,yp=3201,_p=0,xp=1,wp=7680,bp=519,Mp=35044,Sp=35048,Tp="300 es";function Ep(){}Object.assign(Ep.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)},removeEventListener:function(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}},dispatchEvent:function(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,n=i.length;e<n;e++)i[e].call(this,t);t.target=null}}});const Cp=[];for(let t=0;t<256;t++)Cp[t]=(t<16?"0":"")+t.toString(16);let Pp=1234567;const Ap={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Cp[255&t]+Cp[t>>8&255]+Cp[t>>16&255]+Cp[t>>24&255]+"-"+Cp[255&e]+Cp[e>>8&255]+"-"+Cp[e>>16&15|64]+Cp[e>>24&255]+"-"+Cp[63&i|128]+Cp[i>>8&255]+"-"+Cp[i>>16&255]+Cp[i>>24&255]+Cp[255&n]+Cp[n>>8&255]+Cp[n>>16&255]+Cp[n>>24&255]).toUpperCase()},clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:function(t,e,i){return(1-i)*t+i*e},damp:function(t,e,i,n){return Ap.lerp(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(Ap.euclideanModulo(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(Pp=t%2147483647),Pp=16807*Pp%2147483647,(Pp-1)/2147483646},degToRad:function(t){return t*Ap.DEG2RAD},radToDeg:function(t){return t*Ap.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,n,r){const o=Math.cos,s=Math.sin,a=o(i/2),h=s(i/2),l=o((e+n)/2),c=s((e+n)/2),u=o((e-n)/2),d=s((e-n)/2),p=o((n-e)/2),f=s((n-e)/2);switch(r){case"XYX":t.set(a*c,h*u,h*d,a*l);break;case"YZY":t.set(h*d,a*c,h*u,a*l);break;case"ZXZ":t.set(h*u,h*d,a*c,a*l);break;case"XZX":t.set(a*c,h*f,h*p,a*l);break;case"YXY":t.set(h*p,a*c,h*f,a*l);break;case"ZYZ":t.set(h*f,h*p,a*c,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class Lp{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*i-o*n+t.x,this.y=r*n+o*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}Lp.prototype.isVector2=!0;class Rp{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,i,n,r,o,s,a,h){const l=this.elements;return l[0]=t,l[1]=n,l[2]=s,l[3]=e,l[4]=r,l[5]=a,l[6]=i,l[7]=o,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,o=i[0],s=i[3],a=i[6],h=i[1],l=i[4],c=i[7],u=i[2],d=i[5],p=i[8],f=n[0],m=n[3],g=n[6],v=n[1],y=n[4],_=n[7],x=n[2],w=n[5],b=n[8];return r[0]=o*f+s*v+a*x,r[3]=o*m+s*y+a*w,r[6]=o*g+s*_+a*b,r[1]=h*f+l*v+c*x,r[4]=h*m+l*y+c*w,r[7]=h*g+l*_+c*b,r[2]=u*f+d*v+p*x,r[5]=u*m+d*y+p*w,r[8]=u*g+d*_+p*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],o=t[4],s=t[5],a=t[6],h=t[7],l=t[8];return e*o*l-e*s*h-i*r*l+i*s*a+n*r*h-n*o*a}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],o=t[4],s=t[5],a=t[6],h=t[7],l=t[8],c=l*o-s*h,u=s*a-l*r,d=h*r-o*a,p=e*c+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=c*f,t[1]=(n*h-l*i)*f,t[2]=(s*i-n*o)*f,t[3]=u*f,t[4]=(l*e-n*a)*f,t[5]=(n*r-s*e)*f,t[6]=d*f,t[7]=(i*a-h*e)*f,t[8]=(o*e-i*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,o,s){const a=Math.cos(r),h=Math.sin(r);return this.set(i*a,i*h,-i*(a*o+h*s)+o+t,-n*h,n*a,-n*(-h*o+a*s)+s+e,0,0,1),this}scale(t,e){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.elements,r=n[0],o=n[3],s=n[6],a=n[1],h=n[4],l=n[7];return n[0]=e*r+i*a,n[3]=e*o+i*h,n[6]=e*s+i*l,n[1]=-i*r+e*a,n[4]=-i*o+e*h,n[7]=-i*s+e*l,this}translate(t,e){const i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}let Op;Rp.prototype.isMatrix3=!0;const Dp={getDataURL:function(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Op&&(Op=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),Op.width=t.width,Op.height=t.height;const i=Op.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=Op}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}};let Ip=0;class kp extends Ep{constructor(t=kp.DEFAULT_IMAGE,e=kp.DEFAULT_MAPPING,i=zu,n=zu,r=ju,o=Uu,s=rd,a=Vu,h=1,l=cp){super(),Object.defineProperty(this,"id",{value:Ip++}),this.uuid=Ap.generateUUID(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=h,this.format=s,this.internalFormat=null,this.type=a,this.offset=new Lp(0,0),this.repeat=new Lp(1,1),this.center=new Lp(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Rp,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=l,this.version=0,this.onUpdate=null}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=Ap.generateUUID()),!e&&void 0===t.images[n.uuid]){let e;if(Array.isArray(n)){e=[];for(let t=0,i=n.length;t<i;t++)n[t].isDataTexture?e.push(zp(n[t].image)):e.push(zp(n[t]))}else e=zp(n);t.images[n.uuid]={uuid:n.uuid,url:e}}i.image=n.uuid}return e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Pu)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case ku:t.x=t.x-Math.floor(t.x);break;case zu:t.x=t.x<0?0:1;break;case Fu:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case ku:t.y=t.y-Math.floor(t.y);break;case zu:t.y=t.y<0?0:1;break;case Fu:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function zp(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Dp.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}kp.DEFAULT_IMAGE=void 0,kp.DEFAULT_MAPPING=Pu,kp.prototype.isTexture=!0;class Fp{constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*n+o[12]*r,this.y=o[1]*e+o[5]*i+o[9]*n+o[13]*r,this.z=o[2]*e+o[6]*i+o[10]*n+o[14]*r,this.w=o[3]*e+o[7]*i+o[11]*n+o[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const o=.01,s=.1,a=t.elements,h=a[0],l=a[4],c=a[8],u=a[1],d=a[5],p=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(l-u)<o&&Math.abs(c-f)<o&&Math.abs(p-m)<o){if(Math.abs(l+u)<s&&Math.abs(c+f)<s&&Math.abs(p+m)<s&&Math.abs(h+d+g-3)<s)return this.set(1,0,0,0),this;e=Math.PI;const t=(h+1)/2,a=(d+1)/2,v=(g+1)/2,y=(l+u)/4,_=(c+f)/4,x=(p+m)/4;return t>a&&t>v?t<o?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=y/i,r=_/i):a>v?a<o?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(a),i=y/n,r=x/n):v<o?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(v),i=_/r,n=x/r),this.set(i,n,r,e),this}let v=Math.sqrt((m-p)*(m-p)+(c-f)*(c-f)+(u-l)*(u-l));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(c-f)/v,this.z=(u-l)/v,this.w=Math.acos((h+d+g-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}Fp.prototype.isVector4=!0;class Bp extends Ep{constructor(t,e,i){super(),this.width=t,this.height=e,this.depth=1,this.scissor=new Fp(0,0,t,e),this.scissorTest=!1,this.viewport=new Fp(0,0,t,e),i=i||{},this.texture=new kp(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=1,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:ju,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}setTexture(t){t.image={width:this.width,height:this.height,depth:this.depth},this.texture=t}setSize(t,e,i=1){this.width===t&&this.height===e&&this.depth===i||(this.width=t,this.height=e,this.depth=i,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Bp.prototype.isWebGLRenderTarget=!0;class Np extends Bp{constructor(t,e,i){super(t,e,i),this.samples=4}copy(t){return super.copy.call(this,t),this.samples=t.samples,this}}Np.prototype.isWebGLMultisampleRenderTarget=!0;class Hp{constructor(t=0,e=0,i=0,n=1){this._x=t,this._y=e,this._z=i,this._w=n}static slerp(t,e,i,n){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),i.slerpQuaternions(t,e,n)}static slerpFlat(t,e,i,n,r,o,s){let a=i[n+0],h=i[n+1],l=i[n+2],c=i[n+3];const u=r[o+0],d=r[o+1],p=r[o+2],f=r[o+3];if(0===s)return t[e+0]=a,t[e+1]=h,t[e+2]=l,void(t[e+3]=c);if(1===s)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=f);if(c!==f||a!==u||h!==d||l!==p){let t=1-s;const e=a*u+h*d+l*p+c*f,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),o=Math.atan2(r,e*i);t=Math.sin(t*o)/r,s=Math.sin(s*o)/r}const r=s*i;if(a=a*t+u*r,h=h*t+d*r,l=l*t+p*r,c=c*t+f*r,t===1-s){const t=1/Math.sqrt(a*a+h*h+l*l+c*c);a*=t,h*=t,l*=t,c*=t}}t[e]=a,t[e+1]=h,t[e+2]=l,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,r,o){const s=i[n],a=i[n+1],h=i[n+2],l=i[n+3],c=r[o],u=r[o+1],d=r[o+2],p=r[o+3];return t[e]=s*p+l*c+a*d-h*u,t[e+1]=a*p+l*u+h*c-s*d,t[e+2]=h*p+l*d+s*u-a*c,t[e+3]=l*p-s*c-a*u-h*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=t._x,n=t._y,r=t._z,o=t._order,s=Math.cos,a=Math.sin,h=s(i/2),l=s(n/2),c=s(r/2),u=a(i/2),d=a(n/2),p=a(r/2);switch(o){case"XYZ":this._x=u*l*c+h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c-u*d*p;break;case"YXZ":this._x=u*l*c+h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c+u*d*p;break;case"ZXY":this._x=u*l*c-h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c-u*d*p;break;case"ZYX":this._x=u*l*c-h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c+u*d*p;break;case"YZX":this._x=u*l*c+h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c-u*d*p;break;case"XZY":this._x=u*l*c-h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],o=e[1],s=e[5],a=e[9],h=e[2],l=e[6],c=e[10],u=i+s+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(l-a)*t,this._y=(r-h)*t,this._z=(o-n)*t}else if(i>s&&i>c){const t=2*Math.sqrt(1+i-s-c);this._w=(l-a)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(r+h)/t}else if(s>c){const t=2*Math.sqrt(1+s-i-c);this._w=(r-h)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(a+l)/t}else{const t=2*Math.sqrt(1+c-i-s);this._w=(o-n)/t,this._x=(r+h)/t,this._y=(a+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ap.clamp(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,o=t._w,s=e._x,a=e._y,h=e._z,l=e._w;return this._x=i*l+o*s+n*h-r*a,this._y=n*l+o*a+r*s-i*h,this._z=r*l+o*h+i*a-n*s,this._w=o*l-i*s-n*a-r*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,o=this._w;let s=o*t._w+i*t._x+n*t._y+r*t._z;if(s<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,s=-s):this.copy(t),s>=1)return this._w=o,this._x=i,this._y=n,this._z=r,this;const a=1-s*s;if(a<=Number.EPSILON){const t=1-e;return this._w=t*o+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const h=Math.sqrt(a),l=Math.atan2(h,s),c=Math.sin((1-e)*l)/h,u=Math.sin(e*l)/h;return this._w=o*c+this._w*u,this._x=i*c+this._x*u,this._y=n*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){this.copy(t).slerp(e,i)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Hp.prototype.isQuaternion=!0;class jp{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Up.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Up.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,o=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*o,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,o=t.y,s=t.z,a=t.w,h=a*e+o*n-s*i,l=a*i+s*e-r*n,c=a*n+r*i-o*e,u=-r*e-o*i-s*n;return this.x=h*a+u*-r+l*-s-c*-o,this.y=l*a+u*-o+c*-r-h*-s,this.z=c*a+u*-s+h*-o-l*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,o=e.x,s=e.y,a=e.z;return this.x=n*a-r*s,this.y=r*o-i*a,this.z=i*s-n*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Gp.copy(this).projectOnVector(t),this.sub(Gp)}reflect(t){return this.sub(Gp.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ap.clamp(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}jp.prototype.isVector3=!0;const Gp=new jp,Up=new Hp;class Vp{constructor(t=new jp(1/0,1/0,1/0),e=new jp(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;for(let a=0,h=t.length;a<h;a+=3){const h=t[a],l=t[a+1],c=t[a+2];h<e&&(e=h),l<i&&(i=l),c<n&&(n=c),h>r&&(r=h),l>o&&(o=l),c>s&&(s=c)}return this.min.set(e,i,n),this.max.set(r,o,s),this}setFromBufferAttribute(t){let e=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;for(let a=0,h=t.count;a<h;a++){const h=t.getX(a),l=t.getY(a),c=t.getZ(a);h<e&&(e=h),l<i&&(i=l),c<n&&(n=c),h>r&&(r=h),l>o&&(o=l),c>s&&(s=c)}return this.min.set(e,i,n),this.max.set(r,o,s),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Zp.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t){return this.makeEmpty(),this.expandByObject(t)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new jp),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new jp),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t){t.updateWorldMatrix(!1,!1);const e=t.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),qp.copy(e.boundingBox),qp.applyMatrix4(t.matrixWorld),this.union(qp));const i=t.children;for(let t=0,e=i.length;t<e;t++)this.expandByObject(i[t]);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new jp),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Zp),Zp.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(tf),ef.subVectors(this.max,tf),Xp.subVectors(t.a,tf),Yp.subVectors(t.b,tf),Jp.subVectors(t.c,tf),Qp.subVectors(Yp,Xp),Kp.subVectors(Jp,Yp),$p.subVectors(Xp,Jp);let e=[0,-Qp.z,Qp.y,0,-Kp.z,Kp.y,0,-$p.z,$p.y,Qp.z,0,-Qp.x,Kp.z,0,-Kp.x,$p.z,0,-$p.x,-Qp.y,Qp.x,0,-Kp.y,Kp.x,0,-$p.y,$p.x,0];return!!of(e,Xp,Yp,Jp,ef)&&(e=[1,0,0,0,1,0,0,0,1],!!of(e,Xp,Yp,Jp,ef)&&(nf.crossVectors(Qp,Kp),e=[nf.x,nf.y,nf.z],of(e,Xp,Yp,Jp,ef)))}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new jp),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Zp.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(Zp).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Wp[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Wp[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Wp[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Wp[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Wp[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Wp[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Wp[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Wp[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Wp)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Vp.prototype.isBox3=!0;const Wp=[new jp,new jp,new jp,new jp,new jp,new jp,new jp,new jp],Zp=new jp,qp=new Vp,Xp=new jp,Yp=new jp,Jp=new jp,Qp=new jp,Kp=new jp,$p=new jp,tf=new jp,ef=new jp,nf=new jp,rf=new jp;function of(t,e,i,n,r){for(let o=0,s=t.length-3;o<=s;o+=3){rf.fromArray(t,o);const s=r.x*Math.abs(rf.x)+r.y*Math.abs(rf.y)+r.z*Math.abs(rf.z),a=e.dot(rf),h=i.dot(rf),l=n.dot(rf);if(Math.max(-Math.max(a,h,l),Math.min(a,h,l))>s)return!1}return!0}const sf=new Vp,af=new jp,hf=new jp,lf=new jp;class cf{constructor(t=new jp,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):sf.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;e<r;e++)n=Math.max(n,i.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return void 0===e&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new jp),e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new Vp),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){lf.subVectors(t,this.center);const e=lf.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.add(lf.multiplyScalar(i/t)),this.radius+=i}return this}union(t){return hf.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(af.copy(t.center).add(hf)),this.expandByPoint(af.copy(t.center).sub(hf)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const uf=new jp,df=new jp,pf=new jp,ff=new jp,mf=new jp,gf=new jp,vf=new jp;class yf{constructor(t=new jp,e=new jp(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new jp),e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,uf)),this}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new jp),e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=uf.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(uf.copy(this.direction).multiplyScalar(e).add(this.origin),uf.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){df.copy(t).add(e).multiplyScalar(.5),pf.copy(e).sub(t).normalize(),ff.copy(this.origin).sub(df);const r=.5*t.distanceTo(e),o=-this.direction.dot(pf),s=ff.dot(this.direction),a=-ff.dot(pf),h=ff.lengthSq(),l=Math.abs(1-o*o);let c,u,d,p;if(l>0)if(c=o*a-s,u=o*s-a,p=r*l,c>=0)if(u>=-p)if(u<=p){const t=1/l;c*=t,u*=t,d=c*(c+o*u+2*s)+u*(o*c+u+2*a)+h}else u=r,c=Math.max(0,-(o*u+s)),d=-c*c+u*(u+2*a)+h;else u=-r,c=Math.max(0,-(o*u+s)),d=-c*c+u*(u+2*a)+h;else u<=-p?(c=Math.max(0,-(-o*r+s)),u=c>0?-r:Math.min(Math.max(-r,-a),r),d=-c*c+u*(u+2*a)+h):u<=p?(c=0,u=Math.min(Math.max(-r,-a),r),d=u*(u+2*a)+h):(c=Math.max(0,-(o*r+s)),u=c>0?r:Math.min(Math.max(-r,-a),r),d=-c*c+u*(u+2*a)+h);else u=o>0?-r:r,c=Math.max(0,-(o*u+s)),d=-c*c+u*(u+2*a)+h;return i&&i.copy(this.direction).multiplyScalar(c).add(this.origin),n&&n.copy(pf).multiplyScalar(u).add(df),d}intersectSphere(t,e){uf.subVectors(t.center,this.origin);const i=uf.dot(this.direction),n=uf.dot(uf)-i*i,r=t.radius*t.radius;if(n>r)return null;const o=Math.sqrt(r-n),s=i-o,a=i+o;return s<0&&a<0?null:s<0?this.at(a,e):this.at(s,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,o,s,a;const h=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,u=this.origin;return h>=0?(i=(t.min.x-u.x)*h,n=(t.max.x-u.x)*h):(i=(t.max.x-u.x)*h,n=(t.min.x-u.x)*h),l>=0?(r=(t.min.y-u.y)*l,o=(t.max.y-u.y)*l):(r=(t.max.y-u.y)*l,o=(t.min.y-u.y)*l),i>o||r>n?null:((r>i||i!=i)&&(i=r),(o<n||n!=n)&&(n=o),c>=0?(s=(t.min.z-u.z)*c,a=(t.max.z-u.z)*c):(s=(t.max.z-u.z)*c,a=(t.min.z-u.z)*c),i>a||s>n?null:((s>i||i!=i)&&(i=s),(a<n||n!=n)&&(n=a),n<0?null:this.at(i>=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,uf)}intersectTriangle(t,e,i,n,r){mf.subVectors(e,t),gf.subVectors(i,t),vf.crossVectors(mf,gf);let o,s=this.direction.dot(vf);if(s>0){if(n)return null;o=1}else{if(!(s<0))return null;o=-1,s=-s}ff.subVectors(this.origin,t);const a=o*this.direction.dot(gf.crossVectors(ff,gf));if(a<0)return null;const h=o*this.direction.dot(mf.cross(ff));if(h<0)return null;if(a+h>s)return null;const l=-o*ff.dot(vf);return l<0?null:this.at(l/s,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class _f{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,i,n,r,o,s,a,h,l,c,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=o,g[9]=s,g[13]=a,g[2]=h,g[6]=l,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new _f).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/xf.setFromMatrixColumn(t,0).length(),r=1/xf.setFromMatrixColumn(t,1).length(),o=1/xf.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,i=t.x,n=t.y,r=t.z,o=Math.cos(i),s=Math.sin(i),a=Math.cos(n),h=Math.sin(n),l=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=o*l,i=o*c,n=s*l,r=s*c;e[0]=a*l,e[4]=-a*c,e[8]=h,e[1]=i+n*h,e[5]=t-r*h,e[9]=-s*a,e[2]=r-t*h,e[6]=n+i*h,e[10]=o*a}else if("YXZ"===t.order){const t=a*l,i=a*c,n=h*l,r=h*c;e[0]=t+r*s,e[4]=n*s-i,e[8]=o*h,e[1]=o*c,e[5]=o*l,e[9]=-s,e[2]=i*s-n,e[6]=r+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*l,i=a*c,n=h*l,r=h*c;e[0]=t-r*s,e[4]=-o*c,e[8]=n+i*s,e[1]=i+n*s,e[5]=o*l,e[9]=r-t*s,e[2]=-o*h,e[6]=s,e[10]=o*a}else if("ZYX"===t.order){const t=o*l,i=o*c,n=s*l,r=s*c;e[0]=a*l,e[4]=n*h-i,e[8]=t*h+r,e[1]=a*c,e[5]=r*h+t,e[9]=i*h-n,e[2]=-h,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,i=o*h,n=s*a,r=s*h;e[0]=a*l,e[4]=r-t*c,e[8]=n*c+i,e[1]=c,e[5]=o*l,e[9]=-s*l,e[2]=-h*l,e[6]=i*c+n,e[10]=t-r*c}else if("XZY"===t.order){const t=o*a,i=o*h,n=s*a,r=s*h;e[0]=a*l,e[4]=-c,e[8]=h*l,e[1]=t*c+r,e[5]=o*l,e[9]=i*c-n,e[2]=n*c-i,e[6]=s*l,e[10]=r*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(bf,t,Mf)}lookAt(t,e,i){const n=this.elements;return Ef.subVectors(t,e),0===Ef.lengthSq()&&(Ef.z=1),Ef.normalize(),Sf.crossVectors(i,Ef),0===Sf.lengthSq()&&(1===Math.abs(i.z)?Ef.x+=1e-4:Ef.z+=1e-4,Ef.normalize(),Sf.crossVectors(i,Ef)),Sf.normalize(),Tf.crossVectors(Ef,Sf),n[0]=Sf.x,n[4]=Tf.x,n[8]=Ef.x,n[1]=Sf.y,n[5]=Tf.y,n[9]=Ef.y,n[2]=Sf.z,n[6]=Tf.z,n[10]=Ef.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,o=i[0],s=i[4],a=i[8],h=i[12],l=i[1],c=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],_=i[11],x=i[15],w=n[0],b=n[4],M=n[8],S=n[12],T=n[1],E=n[5],C=n[9],P=n[13],A=n[2],L=n[6],R=n[10],O=n[14],D=n[3],I=n[7],k=n[11],z=n[15];return r[0]=o*w+s*T+a*A+h*D,r[4]=o*b+s*E+a*L+h*I,r[8]=o*M+s*C+a*R+h*k,r[12]=o*S+s*P+a*O+h*z,r[1]=l*w+c*T+u*A+d*D,r[5]=l*b+c*E+u*L+d*I,r[9]=l*M+c*C+u*R+d*k,r[13]=l*S+c*P+u*O+d*z,r[2]=p*w+f*T+m*A+g*D,r[6]=p*b+f*E+m*L+g*I,r[10]=p*M+f*C+m*R+g*k,r[14]=p*S+f*P+m*O+g*z,r[3]=v*w+y*T+_*A+x*D,r[7]=v*b+y*E+_*L+x*I,r[11]=v*M+y*C+_*R+x*k,r[15]=v*S+y*P+_*O+x*z,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],o=t[1],s=t[5],a=t[9],h=t[13],l=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+r*a*c-n*h*c-r*s*u+i*h*u+n*s*d-i*a*d)+t[7]*(+e*a*d-e*h*u+r*o*u-n*o*d+n*h*l-r*a*l)+t[11]*(+e*h*c-e*s*d-r*o*c+i*o*d+r*s*l-i*h*l)+t[15]*(-n*s*l-e*a*c+e*s*u+n*o*c-i*o*u+i*a*l)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],o=t[4],s=t[5],a=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],v=c*m*h-f*u*h+f*a*d-s*m*d-c*a*g+s*u*g,y=p*u*h-l*m*h-p*a*d+o*m*d+l*a*g-o*u*g,_=l*f*h-p*c*h+p*s*d-o*f*d-l*s*g+o*c*g,x=p*c*a-l*f*a-p*s*u+o*f*u+l*s*m-o*c*m,w=e*v+i*y+n*_+r*x;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/w;return t[0]=v*b,t[1]=(f*u*r-c*m*r-f*n*d+i*m*d+c*n*g-i*u*g)*b,t[2]=(s*m*r-f*a*r+f*n*h-i*m*h-s*n*g+i*a*g)*b,t[3]=(c*a*r-s*u*r-c*n*h+i*u*h+s*n*d-i*a*d)*b,t[4]=y*b,t[5]=(l*m*r-p*u*r+p*n*d-e*m*d-l*n*g+e*u*g)*b,t[6]=(p*a*r-o*m*r-p*n*h+e*m*h+o*n*g-e*a*g)*b,t[7]=(o*u*r-l*a*r+l*n*h-e*u*h-o*n*d+e*a*d)*b,t[8]=_*b,t[9]=(p*c*r-l*f*r-p*i*d+e*f*d+l*i*g-e*c*g)*b,t[10]=(o*f*r-p*s*r+p*i*h-e*f*h-o*i*g+e*s*g)*b,t[11]=(l*s*r-o*c*r-l*i*h+e*c*h+o*i*d-e*s*d)*b,t[12]=x*b,t[13]=(l*f*n-p*c*n+p*i*u-e*f*u-l*i*m+e*c*m)*b,t[14]=(p*s*n-o*f*n-p*i*a+e*f*a+o*i*m-e*s*m)*b,t[15]=(o*c*n-l*s*n+l*i*a-e*c*a-o*i*u+e*s*u)*b,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,o=t.x,s=t.y,a=t.z,h=r*o,l=r*s;return this.set(h*o+i,h*s-n*a,h*a+n*s,0,h*s+n*a,l*s+i,l*a-n*o,0,h*a-n*s,l*a+n*o,r*a*a+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,o=e._y,s=e._z,a=e._w,h=r+r,l=o+o,c=s+s,u=r*h,d=r*l,p=r*c,f=o*l,m=o*c,g=s*c,v=a*h,y=a*l,_=a*c,x=i.x,w=i.y,b=i.z;return n[0]=(1-(f+g))*x,n[1]=(d+_)*x,n[2]=(p-y)*x,n[3]=0,n[4]=(d-_)*w,n[5]=(1-(u+g))*w,n[6]=(m+v)*w,n[7]=0,n[8]=(p+y)*b,n[9]=(m-v)*b,n[10]=(1-(u+f))*b,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let r=xf.set(n[0],n[1],n[2]).length();const o=xf.set(n[4],n[5],n[6]).length(),s=xf.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],wf.copy(this);const a=1/r,h=1/o,l=1/s;return wf.elements[0]*=a,wf.elements[1]*=a,wf.elements[2]*=a,wf.elements[4]*=h,wf.elements[5]*=h,wf.elements[6]*=h,wf.elements[8]*=l,wf.elements[9]*=l,wf.elements[10]*=l,e.setFromRotationMatrix(wf),i.x=r,i.y=o,i.z=s,this}makePerspective(t,e,i,n,r,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const s=this.elements,a=2*r/(e-t),h=2*r/(i-n),l=(e+t)/(e-t),c=(i+n)/(i-n),u=-(o+r)/(o-r),d=-2*o*r/(o-r);return s[0]=a,s[4]=0,s[8]=l,s[12]=0,s[1]=0,s[5]=h,s[9]=c,s[13]=0,s[2]=0,s[6]=0,s[10]=u,s[14]=d,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(t,e,i,n,r,o){const s=this.elements,a=1/(e-t),h=1/(i-n),l=1/(o-r),c=(e+t)*a,u=(i+n)*h,d=(o+r)*l;return s[0]=2*a,s[4]=0,s[8]=0,s[12]=-c,s[1]=0,s[5]=2*h,s[9]=0,s[13]=-u,s[2]=0,s[6]=0,s[10]=-2*l,s[14]=-d,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}_f.prototype.isMatrix4=!0;const xf=new jp,wf=new _f,bf=new jp(0,0,0),Mf=new jp(1,1,1),Sf=new jp,Tf=new jp,Ef=new jp,Cf=new _f,Pf=new Hp;class Af{constructor(t=0,e=0,i=0,n=Af.DefaultOrder){this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._order=n||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e,i){const n=Ap.clamp,r=t.elements,o=r[0],s=r[4],a=r[8],h=r[1],l=r[5],c=r[9],u=r[2],d=r[6],p=r[10];switch(e=e||this._order){case"XYZ":this._y=Math.asin(n(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-s,o)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-n(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(h,l)):(this._y=Math.atan2(-u,o),this._z=0);break;case"ZXY":this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(h,o));break;case"ZYX":this._y=Math.asin(-n(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(h,o)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(n(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,o)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-n(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,o)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!1!==i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Cf.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Cf,e,i)}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e||this._order)}reorder(t){return Pf.setFromEuler(this),this.setFromQuaternion(Pf,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new jp(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Af.prototype.isEuler=!0,Af.DefaultOrder="XYZ",Af.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Lf{constructor(){this.mask=1}set(t){this.mask=1<<t|0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}}let Rf=0;const Of=new jp,Df=new Hp,If=new _f,kf=new jp,zf=new jp,Ff=new jp,Bf=new Hp,Nf=new jp(1,0,0),Hf=new jp(0,1,0),jf=new jp(0,0,1),Gf={type:"added"},Uf={type:"removed"};function Vf(){Object.defineProperty(this,"id",{value:Rf++}),this.uuid=Ap.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Vf.DefaultUp.clone();const t=new jp,e=new Af,i=new Hp,n=new jp(1,1,1);e._onChange((function(){i.setFromEuler(e,!1)})),i._onChange((function(){e.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new _f},normalMatrix:{value:new Rp}}),this.matrix=new _f,this.matrixWorld=new _f,this.matrixAutoUpdate=Vf.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Lf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}Vf.DefaultUp=new jp(0,1,0),Vf.DefaultMatrixAutoUpdate=!0,Vf.prototype=Object.assign(Object.create(Ep.prototype),{constructor:Vf,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,e){return Df.setFromAxisAngle(t,e),this.quaternion.multiply(Df),this},rotateOnWorldAxis:function(t,e){return Df.setFromAxisAngle(t,e),this.quaternion.premultiply(Df),this},rotateX:function(t){return this.rotateOnAxis(Nf,t)},rotateY:function(t){return this.rotateOnAxis(Hf,t)},rotateZ:function(t){return this.rotateOnAxis(jf,t)},translateOnAxis:function(t,e){return Of.copy(t).applyQuaternion(this.quaternion),this.position.add(Of.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(Nf,t)},translateY:function(t){return this.translateOnAxis(Hf,t)},translateZ:function(t){return this.translateOnAxis(jf,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(If.copy(this.matrixWorld).invert())},lookAt:function(t,e,i){t.isVector3?kf.copy(t):kf.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),zf.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?If.lookAt(zf,kf,this.up):If.lookAt(kf,zf,this.up),this.quaternion.setFromRotationMatrix(If),n&&(If.extractRotation(n.matrixWorld),Df.setFromRotationMatrix(If),this.quaternion.premultiply(Df.invert()))},add:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Gf)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Uf)),this},clear:function(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(Uf)}return this.children.length=0,this},attach:function(t){return this.updateWorldMatrix(!0,!1),If.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),If.multiply(t.parent.matrixWorld)),t.applyMatrix4(If),this.add(t),t.updateWorldMatrix(!1,!0),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new jp),this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new Hp),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zf,t,Ff),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new jp),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(zf,Bf,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new jp),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()},raycast:function(){},traverse:function(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)},traverseVisible:function(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)},traverseAncestors:function(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)},updateWorldMatrix:function(t,e){const i=this.parent;if(!0===t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].updateWorldMatrix(!1,!0)}},toJSON:function(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const n={};function r(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const n=i[e];r(t.shapes,n)}else r(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(r(t.materials,this.material[i]));n.material=e}else n.material=r(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(r(t.animations,i))}}if(e){const e=o(t.geometries),n=o(t.materials),r=o(t.textures),s=o(t.images),a=o(t.shapes),h=o(t.skeletons),l=o(t.animations);e.length>0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),s.length>0&&(i.images=s),a.length>0&&(i.shapes=a),h.length>0&&(i.skeletons=h),l.length>0&&(i.animations=l)}return i.object=n,i;function o(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const i=t.children[e];this.add(i.clone())}return this}});const Wf=new jp,Zf=new jp,qf=new Rp;class Xf{constructor(t=new jp(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=Wf.subVectors(i,e).cross(Zf.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new jp),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new jp);const i=t.delta(Wf),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:e.copy(i).multiplyScalar(r).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new jp),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||qf.getNormalMatrix(t),n=this.coplanarPoint(Wf).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}Xf.prototype.isPlane=!0;const Yf=new jp,Jf=new jp,Qf=new jp,Kf=new jp,$f=new jp,tm=new jp,em=new jp,im=new jp,nm=new jp,rm=new jp;class om{constructor(t=new jp,e=new jp,i=new jp){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){void 0===n&&(console.warn("THREE.Triangle: .getNormal() target is now required"),n=new jp),n.subVectors(i,e),Yf.subVectors(t,e),n.cross(Yf);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){Yf.subVectors(n,e),Jf.subVectors(i,e),Qf.subVectors(t,e);const o=Yf.dot(Yf),s=Yf.dot(Jf),a=Yf.dot(Qf),h=Jf.dot(Jf),l=Jf.dot(Qf),c=o*h-s*s;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new jp),0===c)return r.set(-2,-1,-1);const u=1/c,d=(h*a-s*l)*u,p=(o*l-s*a)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,Kf),Kf.x>=0&&Kf.y>=0&&Kf.x+Kf.y<=1}static getUV(t,e,i,n,r,o,s,a){return this.getBarycoord(t,e,i,n,Kf),a.set(0,0),a.addScaledVector(r,Kf.x),a.addScaledVector(o,Kf.y),a.addScaledVector(s,Kf.z),a}static isFrontFacing(t,e,i,n){return Yf.subVectors(i,e),Jf.subVectors(t,e),Yf.cross(Jf).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Yf.subVectors(this.c,this.b),Jf.subVectors(this.a,this.b),.5*Yf.cross(Jf).length()}getMidpoint(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new jp),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return om.getNormal(this.a,this.b,this.c,t)}getPlane(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Xf),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return om.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,r){return om.getUV(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return om.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return om.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new jp);const i=this.a,n=this.b,r=this.c;let o,s;$f.subVectors(n,i),tm.subVectors(r,i),im.subVectors(t,i);const a=$f.dot(im),h=tm.dot(im);if(a<=0&&h<=0)return e.copy(i);nm.subVectors(t,n);const l=$f.dot(nm),c=tm.dot(nm);if(l>=0&&c<=l)return e.copy(n);const u=a*c-l*h;if(u<=0&&a>=0&&l<=0)return o=a/(a-l),e.copy(i).addScaledVector($f,o);rm.subVectors(t,r);const d=$f.dot(rm),p=tm.dot(rm);if(p>=0&&d<=p)return e.copy(r);const f=d*h-a*p;if(f<=0&&h>=0&&p<=0)return s=h/(h-p),e.copy(i).addScaledVector(tm,s);const m=l*p-d*c;if(m<=0&&c-l>=0&&d-p>=0)return em.subVectors(r,n),s=(c-l)/(c-l+(d-p)),e.copy(n).addScaledVector(em,s);const g=1/(m+f+u);return o=f*g,s=u*g,e.copy(i).addScaledVector($f,o).addScaledVector(tm,s)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let sm=0;function am(){Object.defineProperty(this,"id",{value:sm++}),this.uuid=Ap.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=Vc,this.side=Hc,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=ru,this.blendDst=ou,this.blendEquation=Yc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=fu,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=bp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=wp,this.stencilZFail=wp,this.stencilZPass=wp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}am.prototype=Object.assign(Object.create(Ep.prototype),{constructor:am,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}},toJSON:function(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,void 0!==this.combine&&(i.combine=this.combine),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Vc&&(i.blending=this.blending),this.side!==Hc&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.morphNormals&&(i.morphNormals=!0),!0===this.skinning&&(i.skinning=!0),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(am.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}});const hm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},lm={h:0,s:0,l:0},cm={h:0,s:0,l:0};function um(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}function dm(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function pm(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class fm{constructor(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,i){return this.r=t,this.g=e,this.b=i,this}setHSL(t,e,i){if(t=Ap.euclideanModulo(t,1),e=Ap.clamp(e,0,1),i=Ap.clamp(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=um(r,n,t+1/3),this.g=um(r,n,t),this.b=um(r,n,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const i=parseFloat(t[1])/360,n=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=i[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=hm[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=dm(t.r),this.g=dm(t.g),this.b=dm(t.b),this}copyLinearToSRGB(t){return this.r=pm(t.r),this.g=pm(t.g),this.b=pm(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});const e=this.r,i=this.g,n=this.b,r=Math.max(e,i,n),o=Math.min(e,i,n);let s,a;const h=(o+r)/2;if(o===r)s=0,a=0;else{const t=r-o;switch(a=h<=.5?t/(r+o):t/(2-r-o),r){case e:s=(i-n)/t+(i<n?6:0);break;case i:s=(n-e)/t+2;break;case n:s=(e-i)/t+4}s/=6}return t.h=s,t.s=a,t.l=h,t}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(t,e,i){return this.getHSL(lm),lm.h+=t,lm.s+=e,lm.l+=i,this.setHSL(lm.h,lm.s,lm.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(lm),t.getHSL(cm);const i=Ap.lerp(lm.h,cm.h,e),n=Ap.lerp(lm.s,cm.s,e),r=Ap.lerp(lm.l,cm.l,e);return this.setHSL(i,n,r),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),!0===t.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}fm.NAMES=hm,fm.prototype.isColor=!0,fm.prototype.r=1,fm.prototype.g=1,fm.prototype.b=1;class mm extends am{constructor(t){super(),this.type="MeshBasicMaterial",this.color=new fm(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=_u,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this}}mm.prototype.isMeshBasicMaterial=!0;const gm=new jp,vm=new Lp;function ym(t,e,i){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===i,this.usage=Mp,this.updateRange={offset:0,count:-1},this.version=0}function _m(t,e,i){ym.call(this,new Int8Array(t),e,i)}function xm(t,e,i){ym.call(this,new Uint8Array(t),e,i)}function wm(t,e,i){ym.call(this,new Uint8ClampedArray(t),e,i)}function bm(t,e,i){ym.call(this,new Int16Array(t),e,i)}function Mm(t,e,i){ym.call(this,new Uint16Array(t),e,i)}function Sm(t,e,i){ym.call(this,new Int32Array(t),e,i)}function Tm(t,e,i){ym.call(this,new Uint32Array(t),e,i)}function Em(t,e,i){ym.call(this,new Uint16Array(t),e,i)}function Cm(t,e,i){ym.call(this,new Float32Array(t),e,i)}function Pm(t,e,i){ym.call(this,new Float64Array(t),e,i)}function Am(t){if(0===t.length)return-1/0;let e=t[0];for(let i=1,n=t.length;i<n;++i)t[i]>e&&(e=t[i]);return e}Object.defineProperty(ym.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ym.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[t+n]=e.array[i+n];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),r=new fm),e[i++]=r.r,e[i++]=r.g,e[i++]=r.b}return this},copyVector2sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),r=new Lp),e[i++]=r.x,e[i++]=r.y}return this},copyVector3sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),r=new jp),e[i++]=r.x,e[i++]=r.y,e[i++]=r.z}return this},copyVector4sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),r=new Fp),e[i++]=r.x,e[i++]=r.y,e[i++]=r.z,e[i++]=r.w}return this},applyMatrix3:function(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)vm.fromBufferAttribute(this,e),vm.applyMatrix3(t),this.setXY(e,vm.x,vm.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)gm.fromBufferAttribute(this,e),gm.applyMatrix3(t),this.setXYZ(e,gm.x,gm.y,gm.z);return this},applyMatrix4:function(t){for(let e=0,i=this.count;e<i;e++)gm.x=this.getX(e),gm.y=this.getY(e),gm.z=this.getZ(e),gm.applyMatrix4(t),this.setXYZ(e,gm.x,gm.y,gm.z);return this},applyNormalMatrix:function(t){for(let e=0,i=this.count;e<i;e++)gm.x=this.getX(e),gm.y=this.getY(e),gm.z=this.getZ(e),gm.applyNormalMatrix(t),this.setXYZ(e,gm.x,gm.y,gm.z);return this},transformDirection:function(t){for(let e=0,i=this.count;e<i;e++)gm.x=this.getX(e),gm.y=this.getY(e),gm.z=this.getZ(e),gm.transformDirection(t),this.setXYZ(e,gm.x,gm.y,gm.z);return this},set:function(t,e=0){return this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this},setXYZ:function(t,e,i,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this},setXYZW:function(t,e,i,n,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Mp&&(t.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(t.updateRange=this.updateRange),t}}),_m.prototype=Object.create(ym.prototype),_m.prototype.constructor=_m,xm.prototype=Object.create(ym.prototype),xm.prototype.constructor=xm,wm.prototype=Object.create(ym.prototype),wm.prototype.constructor=wm,bm.prototype=Object.create(ym.prototype),bm.prototype.constructor=bm,Mm.prototype=Object.create(ym.prototype),Mm.prototype.constructor=Mm,Sm.prototype=Object.create(ym.prototype),Sm.prototype.constructor=Sm,Tm.prototype=Object.create(ym.prototype),Tm.prototype.constructor=Tm,Em.prototype=Object.create(ym.prototype),Em.prototype.constructor=Em,Em.prototype.isFloat16BufferAttribute=!0,Cm.prototype=Object.create(ym.prototype),Cm.prototype.constructor=Cm,Pm.prototype=Object.create(ym.prototype),Pm.prototype.constructor=Pm;const Lm={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Rm(t,e){return new Lm[t](e)}let Om=0;const Dm=new _f,Im=new Vf,km=new jp,zm=new Vp,Fm=new Vp,Bm=new jp;function Nm(){Object.defineProperty(this,"id",{value:Om++}),this.uuid=Ap.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}Nm.prototype=Object.assign(Object.create(Ep.prototype),{constructor:Nm,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){return Array.isArray(t)?this.index=new(Am(t)>65535?Tm:Mm)(t,1):this.index=t,this},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute:function(t){return delete this.attributes[t],this},hasAttribute:function(t){return void 0!==this.attributes[t]},addGroup:function(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix4:function(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new Rp).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return Dm.makeRotationX(t),this.applyMatrix4(Dm),this},rotateY:function(t){return Dm.makeRotationY(t),this.applyMatrix4(Dm),this},rotateZ:function(t){return Dm.makeRotationZ(t),this.applyMatrix4(Dm),this},translate:function(t,e,i){return Dm.makeTranslation(t,e,i),this.applyMatrix4(Dm),this},scale:function(t,e,i){return Dm.makeScale(t,e,i),this.applyMatrix4(Dm),this},lookAt:function(t){return Im.lookAt(t),Im.updateMatrix(),this.applyMatrix4(Im.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(km).negate(),this.translate(km.x,km.y,km.z),this},setFromPoints:function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new Cm(e,3)),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Vp);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new jp(-1/0,-1/0,-1/0),new jp(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];zm.setFromBufferAttribute(i),this.morphTargetsRelative?(Bm.addVectors(this.boundingBox.min,zm.min),this.boundingBox.expandByPoint(Bm),Bm.addVectors(this.boundingBox.max,zm.max),this.boundingBox.expandByPoint(Bm)):(this.boundingBox.expandByPoint(zm.min),this.boundingBox.expandByPoint(zm.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new cf);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new jp,1/0);if(t){const i=this.boundingSphere.center;if(zm.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];Fm.setFromBufferAttribute(i),this.morphTargetsRelative?(Bm.addVectors(zm.min,Fm.min),zm.expandByPoint(Bm),Bm.addVectors(zm.max,Fm.max),zm.expandByPoint(Bm)):(zm.expandByPoint(Fm.min),zm.expandByPoint(Fm.max))}zm.getCenter(i);let n=0;for(let e=0,r=t.count;e<r;e++)Bm.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(Bm));if(e)for(let r=0,o=e.length;r<o;r++){const o=e[r],s=this.morphTargetsRelative;for(let e=0,r=o.count;e<r;e++)Bm.fromBufferAttribute(o,e),s&&(km.fromBufferAttribute(t,e),Bm.add(km)),n=Math.max(n,i.distanceToSquared(Bm))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeTangents:function(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=t.array,n=e.position.array,r=e.normal.array,o=e.uv.array,s=n.length/3;void 0===e.tangent&&this.setAttribute("tangent",new ym(new Float32Array(4*s),4));const a=e.tangent.array,h=[],l=[];for(let t=0;t<s;t++)h[t]=new jp,l[t]=new jp;const c=new jp,u=new jp,d=new jp,p=new Lp,f=new Lp,m=new Lp,g=new jp,v=new jp;function y(t,e,i){c.fromArray(n,3*t),u.fromArray(n,3*e),d.fromArray(n,3*i),p.fromArray(o,2*t),f.fromArray(o,2*e),m.fromArray(o,2*i),u.sub(c),d.sub(c),f.sub(p),m.sub(p);const r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(r),v.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(r),h[t].add(g),h[e].add(g),h[i].add(g),l[t].add(v),l[e].add(v),l[i].add(v))}let _=this.groups;0===_.length&&(_=[{start:0,count:i.length}]);for(let t=0,e=_.length;t<e;++t){const e=_[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)y(i[t+0],i[t+1],i[t+2])}const x=new jp,w=new jp,b=new jp,M=new jp;function S(t){b.fromArray(r,3*t),M.copy(b);const e=h[t];x.copy(e),x.sub(b.multiplyScalar(b.dot(e))).normalize(),w.crossVectors(M,e);const i=w.dot(l[t])<0?-1:1;a[4*t]=x.x,a[4*t+1]=x.y,a[4*t+2]=x.z,a[4*t+3]=i}for(let t=0,e=_.length;t<e;++t){const e=_[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)S(i[t+0]),S(i[t+1]),S(i[t+2])}},computeVertexNormals:function(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i)i=new ym(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new jp,r=new jp,o=new jp,s=new jp,a=new jp,h=new jp,l=new jp,c=new jp;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),f=t.getX(u+2);n.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),o.fromBufferAttribute(e,f),l.subVectors(o,r),c.subVectors(n,r),l.cross(c),s.fromBufferAttribute(i,d),a.fromBufferAttribute(i,p),h.fromBufferAttribute(i,f),s.add(l),a.add(l),h.add(l),i.setXYZ(d,s.x,s.y,s.z),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(f,h.x,h.y,h.z)}else for(let t=0,s=e.count;t<s;t+=3)n.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),o.fromBufferAttribute(e,t+2),l.subVectors(o,r),c.subVectors(n,r),l.cross(c),i.setXYZ(t+0,l.x,l.y,l.z),i.setXYZ(t+1,l.x,l.y,l.z),i.setXYZ(t+2,l.x,l.y,l.z);this.normalizeNormals(),i.needsUpdate=!0}},merge:function(t,e){if(!t||!t.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);void 0===e&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const i=this.attributes;for(const n in i){if(void 0===t.attributes[n])continue;const r=i[n].array,o=t.attributes[n],s=o.array,a=o.itemSize*e,h=Math.min(s.length,r.length-a);for(let t=0,e=a;t<h;t++,e++)r[e]=s[t]}return this},normalizeNormals:function(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)Bm.fromBufferAttribute(t,e),Bm.normalize(),t.setXYZ(e,Bm.x,Bm.y,Bm.z)},toNonIndexed:function(){function t(t,e){const i=t.array,n=t.itemSize,r=t.normalized,o=new i.constructor(e.length*n);let s=0,a=0;for(let t=0,r=e.length;t<r;t++){s=e[t]*n;for(let t=0;t<n;t++)o[a++]=i[s++]}return new ym(o,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Nm,i=this.index.array,n=this.attributes;for(const r in n){const o=t(n[r],i);e.setAttribute(r,o)}const r=this.morphAttributes;for(const n in r){const o=[],s=r[n];for(let e=0,n=s.length;e<n;e++){const n=t(s[e],i);o.push(n)}e.morphAttributes[n]=o}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let t=0,i=o.length;t<i;t++){const i=o[t];e.addGroup(i.start,i.count,i.materialIndex)}return e},toJSON:function(){const t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const n=i[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],o=[];for(let e=0,n=i.length;e<n;e++){const n=i[e];o.push(n.toJSON(t.data))}o.length>0&&(n[e]=o,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const s=this.boundingSphere;return null!==s&&(t.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),t},clone:function(){return(new Nm).copy(this)},copy:function(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t<r;t++)i.push(n[t].clone(e));this.morphAttributes[t]=i}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let t=0,e=o.length;t<e;t++){const e=o[t];this.addGroup(e.start,e.count,e.materialIndex)}const s=t.boundingBox;null!==s&&(this.boundingBox=s.clone());const a=t.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});const Hm=new _f,jm=new yf,Gm=new cf,Um=new jp,Vm=new jp,Wm=new jp,Zm=new jp,qm=new jp,Xm=new jp,Ym=new jp,Jm=new jp,Qm=new jp,Km=new Lp,$m=new Lp,tg=new Lp,eg=new jp,ig=new jp;function ng(t=new Nm,e=new mm){Vf.call(this),this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}function rg(t,e,i,n,r,o,s,a,h,l,c,u){Um.fromBufferAttribute(r,l),Vm.fromBufferAttribute(r,c),Wm.fromBufferAttribute(r,u);const d=t.morphTargetInfluences;if(e.morphTargets&&o&&d){Ym.set(0,0,0),Jm.set(0,0,0),Qm.set(0,0,0);for(let t=0,e=o.length;t<e;t++){const e=d[t],i=o[t];0!==e&&(Zm.fromBufferAttribute(i,l),qm.fromBufferAttribute(i,c),Xm.fromBufferAttribute(i,u),s?(Ym.addScaledVector(Zm,e),Jm.addScaledVector(qm,e),Qm.addScaledVector(Xm,e)):(Ym.addScaledVector(Zm.sub(Um),e),Jm.addScaledVector(qm.sub(Vm),e),Qm.addScaledVector(Xm.sub(Wm),e)))}Um.add(Ym),Vm.add(Jm),Wm.add(Qm)}t.isSkinnedMesh&&e.skinning&&(t.boneTransform(l,Um),t.boneTransform(c,Vm),t.boneTransform(u,Wm));const p=function(t,e,i,n,r,o,s,a){let h;if(h=e.side===jc?n.intersectTriangle(s,o,r,!0,a):n.intersectTriangle(r,o,s,e.side!==Gc,a),null===h)return null;ig.copy(a),ig.applyMatrix4(t.matrixWorld);const l=i.ray.origin.distanceTo(ig);return l<i.near||l>i.far?null:{distance:l,point:ig.clone(),object:t}}(t,e,i,n,Um,Vm,Wm,eg);if(p){a&&(Km.fromBufferAttribute(a,l),$m.fromBufferAttribute(a,c),tg.fromBufferAttribute(a,u),p.uv=om.getUV(eg,Um,Vm,Wm,Km,$m,tg,new Lp)),h&&(Km.fromBufferAttribute(h,l),$m.fromBufferAttribute(h,c),tg.fromBufferAttribute(h,u),p.uv2=om.getUV(eg,Um,Vm,Wm,Km,$m,tg,new Lp));const t={a:l,b:c,c:u,normal:new jp,materialIndex:0};om.getNormal(Um,Vm,Wm,t.normal),p.face=t}return p}ng.prototype=Object.assign(Object.create(Vf.prototype),{constructor:ng,isMesh:!0,copy:function(t){return Vf.prototype.copy.call(this,t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),Gm.copy(i.boundingSphere),Gm.applyMatrix4(r),!1===t.ray.intersectsSphere(Gm))return;if(Hm.copy(r).invert(),jm.copy(t.ray).applyMatrix4(Hm),null!==i.boundingBox&&!1===jm.intersectsBox(i.boundingBox))return;let o;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position,a=i.morphAttributes.position,h=i.morphTargetsRelative,l=i.attributes.uv,c=i.attributes.uv2,u=i.groups,d=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,p=u.length;i<p;i++){const p=u[i],f=n[p.materialIndex];for(let i=Math.max(p.start,d.start),n=Math.min(p.start+p.count,d.start+d.count);i<n;i+=3){const n=r.getX(i),u=r.getX(i+1),d=r.getX(i+2);o=rg(this,f,t,jm,s,a,h,l,c,n,u,d),o&&(o.faceIndex=Math.floor(i/3),o.face.materialIndex=p.materialIndex,e.push(o))}}else{for(let i=Math.max(0,d.start),u=Math.min(r.count,d.start+d.count);i<u;i+=3){const u=r.getX(i),d=r.getX(i+1),p=r.getX(i+2);o=rg(this,n,t,jm,s,a,h,l,c,u,d,p),o&&(o.faceIndex=Math.floor(i/3),e.push(o))}}else if(void 0!==s)if(Array.isArray(n))for(let i=0,r=u.length;i<r;i++){const r=u[i],p=n[r.materialIndex];for(let i=Math.max(r.start,d.start),n=Math.min(r.start+r.count,d.start+d.count);i<n;i+=3){o=rg(this,p,t,jm,s,a,h,l,c,i,i+1,i+2),o&&(o.faceIndex=Math.floor(i/3),o.face.materialIndex=r.materialIndex,e.push(o))}}else{for(let i=Math.max(0,d.start),r=Math.min(s.count,d.start+d.count);i<r;i+=3){o=rg(this,n,t,jm,s,a,h,l,c,i,i+1,i+2),o&&(o.faceIndex=Math.floor(i/3),e.push(o))}}}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}});class og extends Nm{constructor(t=1,e=1,i=1,n=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:o};const s=this;n=Math.floor(n),r=Math.floor(r),o=Math.floor(o);const a=[],h=[],l=[],c=[];let u=0,d=0;function p(t,e,i,n,r,o,p,f,m,g,v){const y=o/m,_=p/g,x=o/2,w=p/2,b=f/2,M=m+1,S=g+1;let T=0,E=0;const C=new jp;for(let o=0;o<S;o++){const s=o*_-w;for(let a=0;a<M;a++){const u=a*y-x;C[t]=u*n,C[e]=s*r,C[i]=b,h.push(C.x,C.y,C.z),C[t]=0,C[e]=0,C[i]=f>0?1:-1,l.push(C.x,C.y,C.z),c.push(a/m),c.push(1-o/g),T+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const i=u+e+M*t,n=u+e+M*(t+1),r=u+(e+1)+M*(t+1),o=u+(e+1)+M*t;a.push(i,n,o),a.push(n,r,o),E+=6}s.addGroup(d,E,v),d+=E,u+=T}p("z","y","x",-1,-1,i,e,t,o,r,0),p("z","y","x",1,-1,i,e,-t,o,r,1),p("x","z","y",1,1,t,i,e,n,o,2),p("x","z","y",1,-1,t,i,-e,n,o,3),p("x","y","z",1,-1,t,e,i,n,r,4),p("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(a),this.setAttribute("position",new Cm(h,3)),this.setAttribute("normal",new Cm(l,3)),this.setAttribute("uv",new Cm(c,2))}}function sg(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const r=t[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?e[i][n]=r.clone():Array.isArray(r)?e[i][n]=r.slice():e[i][n]=r}}return e}function ag(t){const e={};for(let i=0;i<t.length;i++){const n=sg(t[i]);for(const t in n)e[t]=n[t]}return e}const hg={clone:sg,merge:ag};var lg="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",cg="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";function ug(t){am.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=lg,this.fragmentShader=cg,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function dg(){Vf.call(this),this.type="Camera",this.matrixWorldInverse=new _f,this.projectionMatrix=new _f,this.projectionMatrixInverse=new _f}function pg(t=50,e=1,i=.1,n=2e3){dg.call(this),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}ug.prototype=Object.create(am.prototype),ug.prototype.constructor=ug,ug.prototype.isShaderMaterial=!0,ug.prototype.copy=function(t){return am.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=sg(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this},ug.prototype.toJSON=function(t){const e=am.prototype.toJSON.call(this,t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},dg.prototype=Object.assign(Object.create(Vf.prototype),{constructor:dg,isCamera:!0,copy:function(t,e){return Vf.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new jp),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){Vf.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(t,e){Vf.prototype.updateWorldMatrix.call(this,t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return(new this.constructor).copy(this)}}),pg.prototype=Object.assign(Object.create(dg.prototype),{constructor:pg,isPerspectiveCamera:!0,copy:function(t,e){return dg.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Ap.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){const t=Math.tan(.5*Ap.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*Ap.RAD2DEG*Math.atan(Math.tan(.5*Ap.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,i,n,r,o){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const t=this.near;let e=t*Math.tan(.5*Ap.DEG2RAD*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n;const o=this.view;if(null!==this.view&&this.view.enabled){const t=o.fullWidth,s=o.fullHeight;r+=o.offsetX*n/t,e-=o.offsetY*i/s,n*=o.width/t,i*=o.height/s}const s=this.filmOffset;0!==s&&(r+=t*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(t){const e=Vf.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});const fg=90;class mg extends Vf{constructor(t,e,i){if(super(),this.type="CubeCamera",!0!==i.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=i;const n=new pg(fg,1,t,e);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new jp(1,0,0)),this.add(n);const r=new pg(fg,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new jp(-1,0,0)),this.add(r);const o=new pg(fg,1,t,e);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new jp(0,1,0)),this.add(o);const s=new pg(fg,1,t,e);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(new jp(0,-1,0)),this.add(s);const a=new pg(fg,1,t,e);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new jp(0,0,1)),this.add(a);const h=new pg(fg,1,t,e);h.layers=this.layers,h.up.set(0,-1,0),h.lookAt(new jp(0,0,-1)),this.add(h)}update(t,e){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget,[n,r,o,s,a,h]=this.children,l=t.xr.enabled,c=t.getRenderTarget();t.xr.enabled=!1;const u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0),t.render(e,n),t.setRenderTarget(i,1),t.render(e,r),t.setRenderTarget(i,2),t.render(e,o),t.setRenderTarget(i,3),t.render(e,s),t.setRenderTarget(i,4),t.render(e,a),i.texture.generateMipmaps=u,t.setRenderTarget(i,5),t.render(e,h),t.setRenderTarget(c),t.xr.enabled=l}}class gg extends kp{constructor(t,e,i,n,r,o,s,a,h,l){super(t=void 0!==t?t:[],e=void 0!==e?e:Au,i,n,r,o,s=void 0!==s?s:nd,a,h,l),this._needsFlipEnvMap=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}gg.prototype.isCubeTexture=!0;class vg extends Bp{constructor(t,e,i){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=i),super(t,t,e),e=e||{},this.texture=new gg(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:ju,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=rd,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new og(5,5,5),r=new ug({name:"CubemapFromEquirect",uniforms:sg(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:jc,blending:Uc});r.uniforms.tEquirect.value=e;const o=new ng(n,r),s=e.minFilter;e.minFilter===Uu&&(e.minFilter=ju);return new mg(1,10,this).update(t,o),e.minFilter=s,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,i,n){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}vg.prototype.isWebGLCubeRenderTarget=!0;class yg extends kp{constructor(t,e,i,n,r,o,s,a,h,l,c,u){super(null,o,s,a,h,l,n,r,c,u),this.image={data:t||null,width:e||1,height:i||1},this.magFilter=void 0!==h?h:Bu,this.minFilter=void 0!==l?l:Bu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}yg.prototype.isDataTexture=!0;const _g=new cf,xg=new jp;class wg{constructor(t=new Xf,e=new Xf,i=new Xf,n=new Xf,r=new Xf,o=new Xf){this.planes=[t,e,i,n,r,o]}set(t,e,i,n,r,o){const s=this.planes;return s[0].copy(t),s[1].copy(e),s[2].copy(i),s[3].copy(n),s[4].copy(r),s[5].copy(o),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t){const e=this.planes,i=t.elements,n=i[0],r=i[1],o=i[2],s=i[3],a=i[4],h=i[5],l=i[6],c=i[7],u=i[8],d=i[9],p=i[10],f=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return e[0].setComponents(s-n,c-a,f-u,y-m).normalize(),e[1].setComponents(s+n,c+a,f+u,y+m).normalize(),e[2].setComponents(s+r,c+h,f+d,y+g).normalize(),e[3].setComponents(s-r,c-h,f-d,y-g).normalize(),e[4].setComponents(s-o,c-l,f-p,y-v).normalize(),e[5].setComponents(s+o,c+l,f+p,y+v).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),_g.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(_g)}intersectsSprite(t){return _g.center.set(0,0,0),_g.radius=.7071067811865476,_g.applyMatrix4(t.matrixWorld),this.intersectsSphere(_g)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)<n)return!1}return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(xg.x=n.normal.x>0?t.max.x:t.min.x,xg.y=n.normal.y>0?t.max.y:t.min.y,xg.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(xg)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function bg(){let t=null,e=!1,i=null,n=null;function r(e,o){i(e,o),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Mg(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version<e.version)&&n.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const o=n.get(e);void 0===o?n.set(e,function(e,n){const r=e.array,o=e.usage,s=t.createBuffer();t.bindBuffer(n,s),t.bufferData(n,r,o),e.onUploadCallback();let a=5126;return r instanceof Float32Array?a=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?e.isFloat16BufferAttribute?i?a=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):a=5123:r instanceof Int16Array?a=5122:r instanceof Uint32Array?a=5125:r instanceof Int32Array?a=5124:r instanceof Int8Array?a=5120:r instanceof Uint8Array&&(a=5121),{buffer:s,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,r)):o.version<e.version&&(!function(e,n,r){const o=n.array,s=n.updateRange;t.bindBuffer(r,e),-1===s.count?t.bufferSubData(r,0,o):(i?t.bufferSubData(r,s.offset*o.BYTES_PER_ELEMENT,o,s.offset,s.count):t.bufferSubData(r,s.offset*o.BYTES_PER_ELEMENT,o.subarray(s.offset,s.offset+s.count)),s.count=-1)}(o.buffer,e,r),o.version=e.version)}}}class Sg extends Nm{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const r=t/2,o=e/2,s=Math.floor(i),a=Math.floor(n),h=s+1,l=a+1,c=t/s,u=e/a,d=[],p=[],f=[],m=[];for(let t=0;t<l;t++){const e=t*u-o;for(let i=0;i<h;i++){const n=i*c-r;p.push(n,-e,0),f.push(0,0,1),m.push(i/s),m.push(1-t/a)}}for(let t=0;t<a;t++)for(let e=0;e<s;e++){const i=e+h*t,n=e+h*(t+1),r=e+1+h*(t+1),o=e+1+h*t;d.push(i,n,o),d.push(n,r,o)}this.setIndex(d),this.setAttribute("position",new Cm(p,3)),this.setAttribute("normal",new Cm(f,3)),this.setAttribute("uv",new Cm(m,2))}}const Tg={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n\tuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <transmissionmap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\n\t#endif\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <transmissionmap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},Eg={common:{diffuse:{value:new fm(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Rp},uv2Transform:{value:new Rp},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Lp(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new fm(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new fm(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Rp}},sprite:{diffuse:{value:new fm(15658734)},opacity:{value:1},center:{value:new Lp(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Rp}}},Cg={basic:{uniforms:ag([Eg.common,Eg.specularmap,Eg.envmap,Eg.aomap,Eg.lightmap,Eg.fog]),vertexShader:Tg.meshbasic_vert,fragmentShader:Tg.meshbasic_frag},lambert:{uniforms:ag([Eg.common,Eg.specularmap,Eg.envmap,Eg.aomap,Eg.lightmap,Eg.emissivemap,Eg.fog,Eg.lights,{emissive:{value:new fm(0)}}]),vertexShader:Tg.meshlambert_vert,fragmentShader:Tg.meshlambert_frag},phong:{uniforms:ag([Eg.common,Eg.specularmap,Eg.envmap,Eg.aomap,Eg.lightmap,Eg.emissivemap,Eg.bumpmap,Eg.normalmap,Eg.displacementmap,Eg.fog,Eg.lights,{emissive:{value:new fm(0)},specular:{value:new fm(1118481)},shininess:{value:30}}]),vertexShader:Tg.meshphong_vert,fragmentShader:Tg.meshphong_frag},standard:{uniforms:ag([Eg.common,Eg.envmap,Eg.aomap,Eg.lightmap,Eg.emissivemap,Eg.bumpmap,Eg.normalmap,Eg.displacementmap,Eg.roughnessmap,Eg.metalnessmap,Eg.fog,Eg.lights,{emissive:{value:new fm(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Tg.meshphysical_vert,fragmentShader:Tg.meshphysical_frag},toon:{uniforms:ag([Eg.common,Eg.aomap,Eg.lightmap,Eg.emissivemap,Eg.bumpmap,Eg.normalmap,Eg.displacementmap,Eg.gradientmap,Eg.fog,Eg.lights,{emissive:{value:new fm(0)}}]),vertexShader:Tg.meshtoon_vert,fragmentShader:Tg.meshtoon_frag},matcap:{uniforms:ag([Eg.common,Eg.bumpmap,Eg.normalmap,Eg.displacementmap,Eg.fog,{matcap:{value:null}}]),vertexShader:Tg.meshmatcap_vert,fragmentShader:Tg.meshmatcap_frag},points:{uniforms:ag([Eg.points,Eg.fog]),vertexShader:Tg.points_vert,fragmentShader:Tg.points_frag},dashed:{uniforms:ag([Eg.common,Eg.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Tg.linedashed_vert,fragmentShader:Tg.linedashed_frag},depth:{uniforms:ag([Eg.common,Eg.displacementmap]),vertexShader:Tg.depth_vert,fragmentShader:Tg.depth_frag},normal:{uniforms:ag([Eg.common,Eg.bumpmap,Eg.normalmap,Eg.displacementmap,{opacity:{value:1}}]),vertexShader:Tg.normal_vert,fragmentShader:Tg.normal_frag},sprite:{uniforms:ag([Eg.sprite,Eg.fog]),vertexShader:Tg.sprite_vert,fragmentShader:Tg.sprite_frag},background:{uniforms:{uvTransform:{value:new Rp},t2D:{value:null}},vertexShader:Tg.background_vert,fragmentShader:Tg.background_frag},cube:{uniforms:ag([Eg.envmap,{opacity:{value:1}}]),vertexShader:Tg.cube_vert,fragmentShader:Tg.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Tg.equirect_vert,fragmentShader:Tg.equirect_frag},distanceRGBA:{uniforms:ag([Eg.common,Eg.displacementmap,{referencePosition:{value:new jp},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Tg.distanceRGBA_vert,fragmentShader:Tg.distanceRGBA_frag},shadow:{uniforms:ag([Eg.lights,Eg.fog,{color:{value:new fm(0)},opacity:{value:1}}]),vertexShader:Tg.shadow_vert,fragmentShader:Tg.shadow_frag}};function Pg(t,e,i,n,r){const o=new fm(0);let s,a,h=0,l=null,c=0,u=null;function d(t,e){i.buffers.color.setClear(t.r,t.g,t.b,e,r)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),h=e,d(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(t){h=t,d(o,h)},render:function(i,r,p,f){let m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=e.get(m));const g=t.xr,v=g.getSession&&g.getSession();v&&"additive"===v.environmentBlendMode&&(m=null),null===m?d(o,h):m&&m.isColor&&(d(m,1),f=!0),(t.autoClear||f)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),m&&(m.isCubeTexture||m.mapping===Du)?(void 0===a&&(a=new ng(new og(1,1,1),new ug({name:"BackgroundCubeMaterial",uniforms:sg(Cg.cube.uniforms),vertexShader:Cg.cube.vertexShader,fragmentShader:Cg.cube.fragmentShader,side:jc,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),a.geometry.deleteAttribute("uv"),a.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(a.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(a)),a.material.uniforms.envMap.value=m,a.material.uniforms.flipEnvMap.value=m.isCubeTexture&&m._needsFlipEnvMap?-1:1,l===m&&c===m.version&&u===t.toneMapping||(a.material.needsUpdate=!0,l=m,c=m.version,u=t.toneMapping),i.unshift(a,a.geometry,a.material,0,0,null)):m&&m.isTexture&&(void 0===s&&(s=new ng(new Sg(2,2),new ug({name:"BackgroundMaterial",uniforms:sg(Cg.background.uniforms),vertexShader:Cg.background.vertexShader,fragmentShader:Cg.background.fragmentShader,side:Hc,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(s)),s.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),s.material.uniforms.uvTransform.value.copy(m.matrix),l===m&&c===m.version&&u===t.toneMapping||(s.material.needsUpdate=!0,l=m,c=m.version,u=t.toneMapping),i.unshift(s,s.geometry,s.material,0,0,null))}}}function Ag(t,e,i,n){const r=t.getParameter(34921),o=n.isWebGL2?null:e.get("OES_vertex_array_object"),s=n.isWebGL2||null!==o,a={},h=d(null);let l=h;function c(e){return n.isWebGL2?t.bindVertexArray(e):o.bindVertexArrayOES(e)}function u(e){return n.isWebGL2?t.deleteVertexArray(e):o.deleteVertexArrayOES(e)}function d(t){const e=[],i=[],n=[];for(let t=0;t<r;t++)e[t]=0,i[t]=0,n[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:n,object:t,attributes:{},index:null}}function p(){const t=l.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function f(t){m(t,0)}function m(i,r){const o=l.newAttributes,s=l.enabledAttributes,a=l.attributeDivisors;if(o[i]=1,0===s[i]&&(t.enableVertexAttribArray(i),s[i]=1),a[i]!==r){(n.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),a[i]=r}}function g(){const e=l.newAttributes,i=l.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function v(e,i,r,o,s,a){!0!==n.isWebGL2||5124!==r&&5125!==r?t.vertexAttribPointer(e,i,r,o,s,a):t.vertexAttribIPointer(e,i,r,s,a)}function y(){_(),l!==h&&(l=h,c(l.object))}function _(){h.geometry=null,h.program=null,h.wireframe=!1}return{setup:function(r,h,u,y,_){let x=!1;if(s){const e=function(e,i,r){const s=!0===r.wireframe;let h=a[e.id];void 0===h&&(h={},a[e.id]=h);let l=h[i.id];void 0===l&&(l={},h[i.id]=l);let c=l[s];void 0===c&&(c=d(n.isWebGL2?t.createVertexArray():o.createVertexArrayOES()),l[s]=c);return c}(y,u,h);l!==e&&(l=e,c(l.object)),x=function(t,e){const i=l.attributes,n=t.attributes;let r=0;for(const t in n){const e=i[t],o=n[t];if(void 0===e)return!0;if(e.attribute!==o)return!0;if(e.data!==o.data)return!0;r++}return l.attributesNum!==r||l.index!==e}(y,_),x&&function(t,e){const i={},n=t.attributes;let r=0;for(const t in n){const e=n[t],o={};o.attribute=e,e.data&&(o.data=e.data),i[t]=o,r++}l.attributes=i,l.attributesNum=r,l.index=e}(y,_)}else{const t=!0===h.wireframe;l.geometry===y.id&&l.program===u.id&&l.wireframe===t||(l.geometry=y.id,l.program=u.id,l.wireframe=t,x=!0)}!0===r.isInstancedMesh&&(x=!0),null!==_&&i.update(_,34963),x&&(!function(r,o,s,a){if(!1===n.isWebGL2&&(r.isInstancedMesh||a.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;p();const h=a.attributes,l=s.getAttributes(),c=o.defaultAttributeValues;for(const e in l){const n=l[e];if(n>=0){const o=h[e];if(void 0!==o){const e=o.normalized,r=o.itemSize,s=i.get(o);if(void 0===s)continue;const h=s.buffer,l=s.type,c=s.bytesPerElement;if(o.isInterleavedBufferAttribute){const i=o.data,s=i.stride,u=o.offset;i&&i.isInstancedInterleavedBuffer?(m(n,i.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=i.meshPerAttribute*i.count)):f(n),t.bindBuffer(34962,h),v(n,r,l,e,s*c,u*c)}else o.isInstancedBufferAttribute?(m(n,o.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=o.meshPerAttribute*o.count)):f(n),t.bindBuffer(34962,h),v(n,r,l,e,0,0)}else if("instanceMatrix"===e){const e=i.get(r.instanceMatrix);if(void 0===e)continue;const o=e.buffer,s=e.type;m(n+0,1),m(n+1,1),m(n+2,1),m(n+3,1),t.bindBuffer(34962,o),t.vertexAttribPointer(n+0,4,s,!1,64,0),t.vertexAttribPointer(n+1,4,s,!1,64,16),t.vertexAttribPointer(n+2,4,s,!1,64,32),t.vertexAttribPointer(n+3,4,s,!1,64,48)}else if("instanceColor"===e){const e=i.get(r.instanceColor);if(void 0===e)continue;const o=e.buffer,s=e.type;m(n,1),t.bindBuffer(34962,o),t.vertexAttribPointer(n,3,s,!1,12,0)}else if(void 0!==c){const i=c[e];if(void 0!==i)switch(i.length){case 2:t.vertexAttrib2fv(n,i);break;case 3:t.vertexAttrib3fv(n,i);break;case 4:t.vertexAttrib4fv(n,i);break;default:t.vertexAttrib1fv(n,i)}}}}g()}(r,h,u,y),null!==_&&t.bindBuffer(34963,i.get(_).buffer))},reset:y,resetDefaultState:_,dispose:function(){y();for(const t in a){const e=a[t];for(const t in e){const i=e[t];for(const t in i)u(i[t].object),delete i[t];delete e[t]}delete a[t]}},releaseStatesOfGeometry:function(t){if(void 0===a[t.id])return;const e=a[t.id];for(const t in e){const i=e[t];for(const t in i)u(i[t].object),delete i[t];delete e[t]}delete a[t.id]},releaseStatesOfProgram:function(t){for(const e in a){const i=a[e];if(void 0===i[t.id])continue;const n=i[t.id];for(const t in n)u(n[t].object),delete n[t];delete i[t.id]}},initAttributes:p,enableAttribute:f,disableUnusedAttributes:g}}function Lg(t,e,i,n){const r=n.isWebGL2;let o;this.setMode=function(t){o=t},this.render=function(e,n){t.drawArrays(o,e,n),i.update(n,o,1)},this.renderInstances=function(n,s,a){if(0===a)return;let h,l;if(r)h=t,l="drawArraysInstanced";else if(h=e.get("ANGLE_instanced_arrays"),l="drawArraysInstancedANGLE",null===h)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[l](o,n,s,a),i.update(s,o,a)}}function Rg(t,e,i){let n;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let s=void 0!==i.precision?i.precision:"highp";const a=r(s);a!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",a,"instead."),s=a);const h=!0===i.logarithmicDepthBuffer,l=t.getParameter(34930),c=t.getParameter(35660),u=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),g=t.getParameter(36349),v=c>0,y=o||e.has("OES_texture_float");return{isWebGL2:o,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:h,maxTextures:l,maxVertexTextures:c,maxTextureSize:u,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:o?t.getParameter(36183):0}}function Og(t){const e=this;let i=null,n=0,r=!1,o=!1;const s=new Xf,a=new Rp,h={value:null,needsUpdate:!1};function l(){h.value!==i&&(h.value=i,h.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function c(t,i,n,r){const o=null!==t?t.length:0;let l=null;if(0!==o){if(l=h.value,!0!==r||null===l){const e=n+4*o,r=i.matrixWorldInverse;a.getNormalMatrix(r),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,i=n;e!==o;++e,i+=4)s.copy(t[e]).applyMatrix4(r,a),s.normal.toArray(l,i),l[i+3]=s.constant}h.value=l,h.needsUpdate=!0}return e.numPlanes=o,e.numIntersection=0,l}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e,o){const s=0!==t.length||e||0!==n||r;return r=e,i=c(t,o,0),n=t.length,s},this.beginShadows=function(){o=!0,c(null)},this.endShadows=function(){o=!1,l()},this.setState=function(e,s,a){const u=e.clippingPlanes,d=e.clipIntersection,p=e.clipShadows,f=t.get(e);if(!r||null===u||0===u.length||o&&!p)o?c(null):l();else{const t=o?0:n,e=4*t;let r=f.clippingState||null;h.value=r,r=c(u,s,e,a);for(let t=0;t!==e;++t)r[t]=i[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Dg(t){let e=new WeakMap;function i(t,e){return e===Ru?t.mapping=Au:e===Ou&&(t.mapping=Lu),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const o=r.mapping;if(o===Ru||o===Ou){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const o=r.image;if(o&&o.height>0){const s=t.getRenderTarget(),a=new vg(o.height/2);return a.fromEquirectangularTexture(t,r),e.set(r,a),t.setRenderTarget(s),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}function Ig(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(t){t.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(t){const e=i(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function kg(t,e,i,n){const r={},o=new WeakMap;function s(t){const a=t.target;null!==a.index&&e.remove(a.index);for(const t in a.attributes)e.remove(a.attributes[t]);a.removeEventListener("dispose",s),delete r[a.id];const h=o.get(a);h&&(e.remove(h),o.delete(a)),n.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,i.memory.geometries--}function a(t){const i=[],n=t.index,r=t.attributes.position;let s=0;if(null!==n){const t=n.array;s=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],o=t[e+2];i.push(n,r,r,o,o,n)}}else{const t=r.array;s=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}const a=new(Am(i)>65535?Tm:Mm)(i,1);a.version=s;const h=o.get(t);h&&e.remove(h),o.set(t,a)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",s),r[e.id]=!0,i.memory.geometries++),e},update:function(t){const i=t.attributes;for(const t in i)e.update(i[t],34962);const n=t.morphAttributes;for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t++)e.update(i[t],34962)}},getWireframeAttribute:function(t){const e=o.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&a(t)}else a(t);return o.get(t)}}}function zg(t,e,i,n){const r=n.isWebGL2;let o,s,a;this.setMode=function(t){o=t},this.setIndex=function(t){s=t.type,a=t.bytesPerElement},this.render=function(e,n){t.drawElements(o,n,s,e*a),i.update(n,o,1)},this.renderInstances=function(n,h,l){if(0===l)return;let c,u;if(r)c=t,u="drawElementsInstanced";else if(c=e.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===c)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[u](o,h,s,n*a,l),i.update(h,o,l)}}function Fg(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,i,n){switch(e.calls++,i){case 4:e.triangles+=n*(t/3);break;case 1:e.lines+=n*(t/2);break;case 3:e.lines+=n*(t-1);break;case 2:e.lines+=n*t;break;case 0:e.points+=n*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function Bg(t,e){return t[0]-e[0]}function Ng(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Hg(t){const e={},i=new Float32Array(8),n=[];for(let t=0;t<8;t++)n[t]=[t,0];return{update:function(r,o,s,a){const h=r.morphTargetInfluences,l=void 0===h?0:h.length;let c=e[o.id];if(void 0===c){c=[];for(let t=0;t<l;t++)c[t]=[t,0];e[o.id]=c}for(let t=0;t<l;t++){const e=c[t];e[0]=t,e[1]=h[t]}c.sort(Ng);for(let t=0;t<8;t++)t<l&&c[t][1]?(n[t][0]=c[t][0],n[t][1]=c[t][1]):(n[t][0]=Number.MAX_SAFE_INTEGER,n[t][1]=0);n.sort(Bg);const u=s.morphTargets&&o.morphAttributes.position,d=s.morphNormals&&o.morphAttributes.normal;let p=0;for(let t=0;t<8;t++){const e=n[t],r=e[0],s=e[1];r!==Number.MAX_SAFE_INTEGER&&s?(u&&o.getAttribute("morphTarget"+t)!==u[r]&&o.setAttribute("morphTarget"+t,u[r]),d&&o.getAttribute("morphNormal"+t)!==d[r]&&o.setAttribute("morphNormal"+t,d[r]),i[t]=s,p+=s):(u&&!0===o.hasAttribute("morphTarget"+t)&&o.deleteAttribute("morphTarget"+t),d&&!0===o.hasAttribute("morphNormal"+t)&&o.deleteAttribute("morphNormal"+t),i[t]=0)}const f=o.morphTargetsRelative?1:1-p;a.getUniforms().setValue(t,"morphTargetBaseInfluence",f),a.getUniforms().setValue(t,"morphTargetInfluences",i)}}}function jg(t,e,i,n){let r=new WeakMap;function o(t){const e=t.target;e.removeEventListener("dispose",o),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(t){const s=n.render.frame,a=t.geometry,h=e.get(t,a);return r.get(h)!==s&&(e.update(h),r.set(h,s)),t.isInstancedMesh&&(!1===t.hasEventListener("dispose",o)&&t.addEventListener("dispose",o),i.update(t.instanceMatrix,34962),null!==t.instanceColor&&i.update(t.instanceColor,34962)),h},dispose:function(){r=new WeakMap}}}Cg.physical={uniforms:ag([Cg.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Lp(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new fm(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:Tg.meshphysical_vert,fragmentShader:Tg.meshphysical_frag};class Gg extends kp{constructor(t=null,e=1,i=1,n=1){super(null),this.image={data:t,width:e,height:i,depth:n},this.magFilter=Bu,this.minFilter=Bu,this.wrapR=zu,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}}Gg.prototype.isDataTexture2DArray=!0;class Ug extends kp{constructor(t=null,e=1,i=1,n=1){super(null),this.image={data:t,width:e,height:i,depth:n},this.magFilter=Bu,this.minFilter=Bu,this.wrapR=zu,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}}Ug.prototype.isDataTexture3D=!0;const Vg=new kp,Wg=new Gg,Zg=new Ug,qg=new gg,Xg=[],Yg=[],Jg=new Float32Array(16),Qg=new Float32Array(9),Kg=new Float32Array(4);function $g(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let o=Xg[r];if(void 0===o&&(o=new Float32Array(r),Xg[r]=o),0!==e){n.toArray(o,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(o,r)}return o}function tv(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function ev(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function iv(t,e){let i=Yg[e];void 0===i&&(i=new Int32Array(e),Yg[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function nv(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function rv(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(tv(i,e))return;t.uniform2fv(this.addr,e),ev(i,e)}}function ov(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(tv(i,e))return;t.uniform3fv(this.addr,e),ev(i,e)}}function sv(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(tv(i,e))return;t.uniform4fv(this.addr,e),ev(i,e)}}function av(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(tv(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),ev(i,e)}else{if(tv(i,n))return;Kg.set(n),t.uniformMatrix2fv(this.addr,!1,Kg),ev(i,n)}}function hv(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(tv(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),ev(i,e)}else{if(tv(i,n))return;Qg.set(n),t.uniformMatrix3fv(this.addr,!1,Qg),ev(i,n)}}function lv(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(tv(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),ev(i,e)}else{if(tv(i,n))return;Jg.set(n),t.uniformMatrix4fv(this.addr,!1,Jg),ev(i,n)}}function cv(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function uv(t,e){const i=this.cache;tv(i,e)||(t.uniform2iv(this.addr,e),ev(i,e))}function dv(t,e){const i=this.cache;tv(i,e)||(t.uniform3iv(this.addr,e),ev(i,e))}function pv(t,e){const i=this.cache;tv(i,e)||(t.uniform4iv(this.addr,e),ev(i,e))}function fv(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function mv(t,e){const i=this.cache;tv(i,e)||(t.uniform2uiv(this.addr,e),ev(i,e))}function gv(t,e){const i=this.cache;tv(i,e)||(t.uniform3uiv(this.addr,e),ev(i,e))}function vv(t,e){const i=this.cache;tv(i,e)||(t.uniform4uiv(this.addr,e),ev(i,e))}function yv(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.safeSetTexture2D(e||Vg,r)}function _v(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||Zg,r)}function xv(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.safeSetTextureCube(e||qg,r)}function wv(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||Wg,r)}function bv(t,e){t.uniform1fv(this.addr,e)}function Mv(t,e){const i=$g(e,this.size,2);t.uniform2fv(this.addr,i)}function Sv(t,e){const i=$g(e,this.size,3);t.uniform3fv(this.addr,i)}function Tv(t,e){const i=$g(e,this.size,4);t.uniform4fv(this.addr,i)}function Ev(t,e){const i=$g(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Cv(t,e){const i=$g(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Pv(t,e){const i=$g(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function Av(t,e){t.uniform1iv(this.addr,e)}function Lv(t,e){t.uniform2iv(this.addr,e)}function Rv(t,e){t.uniform3iv(this.addr,e)}function Ov(t,e){t.uniform4iv(this.addr,e)}function Dv(t,e){t.uniform1uiv(this.addr,e)}function Iv(t,e){t.uniform2uiv(this.addr,e)}function kv(t,e){t.uniform3uiv(this.addr,e)}function zv(t,e){t.uniform4uiv(this.addr,e)}function Fv(t,e,i){const n=e.length,r=iv(i,n);t.uniform1iv(this.addr,r);for(let t=0;t!==n;++t)i.safeSetTexture2D(e[t]||Vg,r[t])}function Bv(t,e,i){const n=e.length,r=iv(i,n);t.uniform1iv(this.addr,r);for(let t=0;t!==n;++t)i.safeSetTextureCube(e[t]||qg,r[t])}function Nv(t,e,i){this.id=t,this.addr=i,this.cache=[],this.setValue=function(t){switch(t){case 5126:return nv;case 35664:return rv;case 35665:return ov;case 35666:return sv;case 35674:return av;case 35675:return hv;case 35676:return lv;case 5124:case 35670:return cv;case 35667:case 35671:return uv;case 35668:case 35672:return dv;case 35669:case 35673:return pv;case 5125:return fv;case 36294:return mv;case 36295:return gv;case 36296:return vv;case 35678:case 36198:case 36298:case 36306:case 35682:return yv;case 35679:case 36299:case 36307:return _v;case 35680:case 36300:case 36308:case 36293:return xv;case 36289:case 36303:case 36311:case 36292:return wv}}(e.type)}function Hv(t,e,i){this.id=t,this.addr=i,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return bv;case 35664:return Mv;case 35665:return Sv;case 35666:return Tv;case 35674:return Ev;case 35675:return Cv;case 35676:return Pv;case 5124:case 35670:return Av;case 35667:case 35671:return Lv;case 35668:case 35672:return Rv;case 35669:case 35673:return Ov;case 5125:return Dv;case 36294:return Iv;case 36295:return kv;case 36296:return zv;case 35678:case 36198:case 36298:case 36306:case 35682:return Fv;case 35680:case 36300:case 36308:case 36293:return Bv}}(e.type)}function jv(t){this.id=t,this.seq=[],this.map={}}Hv.prototype.updateCache=function(t){const e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),ev(e,t)},jv.prototype.setValue=function(t,e,i){const n=this.seq;for(let r=0,o=n.length;r!==o;++r){const o=n[r];o.setValue(t,e[o.id],i)}};const Gv=/(\w+)(\])?(\[|\.)?/g;function Uv(t,e){t.seq.push(e),t.map[e.id]=e}function Vv(t,e,i){const n=t.name,r=n.length;for(Gv.lastIndex=0;;){const o=Gv.exec(n),s=Gv.lastIndex;let a=o[1];const h="]"===o[2],l=o[3];if(h&&(a|=0),void 0===l||"["===l&&s+2===r){Uv(i,void 0===l?new Nv(a,t,e):new Hv(a,t,e));break}{let t=i.map[a];void 0===t&&(t=new jv(a),Uv(i,t)),i=t}}}function Wv(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,35718);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);Vv(i,t.getUniformLocation(e,i.name),this)}}function Zv(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}Wv.prototype.setValue=function(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)},Wv.prototype.setOptional=function(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)},Wv.upload=function(t,e,i,n){for(let r=0,o=e.length;r!==o;++r){const o=e[r],s=i[o.id];!1!==s.needsUpdate&&o.setValue(t,s.value,n)}},Wv.seqWithValue=function(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i};let qv=0;function Xv(t){switch(t){case cp:return["Linear","( value )"];case up:return["sRGB","( value )"];case pp:return["RGBE","( value )"];case mp:return["RGBM","( value, 7.0 )"];case gp:return["RGBM","( value, 16.0 )"];case vp:return["RGBD","( value, 256.0 )"];case dp:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case fp:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}function Yv(t,e,i){const n=t.getShaderParameter(e,35713),r=t.getShaderInfoLog(e).trim();if(n&&""===r)return"";return"THREE.WebGLShader: gl.getShaderInfoLog() "+i+"\n"+r+function(t){const e=t.split("\n");for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join("\n")}(t.getShaderSource(e))}function Jv(t,e){const i=Xv(e);return"vec4 "+t+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function Qv(t,e){const i=Xv(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function Kv(t,e){let i;switch(e){case Mu:i="Linear";break;case Su:i="Reinhard";break;case Tu:i="OptimizedCineon";break;case Eu:i="ACESFilmic";break;case Cu:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function $v(t){return""!==t}function ty(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ey(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const iy=/^[ \t]*#include +<([\w\d./]+)>/gm;function ny(t){return t.replace(iy,ry)}function ry(t,e){const i=Tg[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return ny(i)}const oy=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,sy=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ay(t){return t.replace(sy,ly).replace(oy,hy)}function hy(t,e,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),ly(t,e,i,n)}function ly(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function cy(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function uy(t,e,i,n){const r=t.getContext(),o=i.defines;let s=i.vertexShader,a=i.fragmentShader;const h=function(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===Fc?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Bc?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Nc&&(e="SHADOWMAP_TYPE_VSM"),e}(i),l=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Au:case Lu:e="ENVMAP_TYPE_CUBE";break;case Du:case Iu:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),c=function(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Lu:case Iu:e="ENVMAP_MODE_REFRACTION"}return e}(i),u=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case _u:e="ENVMAP_BLENDING_MULTIPLY";break;case xu:e="ENVMAP_BLENDING_MIX";break;case wu:e="ENVMAP_BLENDING_ADD"}return e}(i),d=t.gammaFactor>0?t.gammaFactor:1,p=i.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter($v).join("\n")}(i),f=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(o),m=r.createProgram();let g,v,y=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=[f].filter($v).join("\n"),g.length>0&&(g+="\n"),v=[p,f].filter($v).join("\n"),v.length>0&&(v+="\n")):(g=[cy(i),"#define SHADER_NAME "+i.shaderName,f,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter($v).join("\n"),v=[p,cy(i),"#define SHADER_NAME "+i.shaderName,f,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",i.envMap?"#define "+c:"",i.envMap?"#define "+u:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==bu?"#define TONE_MAPPING":"",i.toneMapping!==bu?Tg.tonemapping_pars_fragment:"",i.toneMapping!==bu?Kv("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",Tg.encodings_pars_fragment,i.map?Jv("mapTexelToLinear",i.mapEncoding):"",i.matcap?Jv("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?Jv("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?Jv("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMap?Jv("lightMapTexelToLinear",i.lightMapEncoding):"",Qv("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter($v).join("\n")),s=ny(s),s=ty(s,i),s=ey(s,i),a=ny(a),a=ty(a,i),a=ey(a,i),s=ay(s),a=ay(a),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(y="#version 300 es\n",g=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",i.glslVersion===Tp?"":"out highp vec4 pc_fragColor;",i.glslVersion===Tp?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const _=y+v+a,x=Zv(r,35633,y+g+s),w=Zv(r,35632,_);if(r.attachShader(m,x),r.attachShader(m,w),void 0!==i.index0AttributeName?r.bindAttribLocation(m,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),t.debug.checkShaderErrors){const t=r.getProgramInfoLog(m).trim(),e=r.getShaderInfoLog(x).trim(),i=r.getShaderInfoLog(w).trim();let n=!0,o=!0;if(!1===r.getProgramParameter(m,35714)){n=!1;const e=Yv(r,x,"vertex"),i=Yv(r,w,"fragment");console.error("THREE.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(m,35715),"gl.getProgramInfoLog",t,e,i)}else""!==t?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",t):""!==e&&""!==i||(o=!1);o&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:e,prefix:g},fragmentShader:{log:i,prefix:v}})}let b,M;return r.deleteShader(x),r.deleteShader(w),this.getUniforms=function(){return void 0===b&&(b=new Wv(r,m)),b},this.getAttributes=function(){return void 0===M&&(M=function(t,e){const i={},n=t.getProgramParameter(e,35721);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r).name;i[n]=t.getAttribLocation(e,n)}return i}(r,m)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.name=i.shaderName,this.id=qv++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=x,this.fragmentShader=w,this}function dy(t,e,i,n,r,o){const s=[],a=n.isWebGL2,h=n.logarithmicDepthBuffer,l=n.floatVertexTextures,c=n.maxVertexUniforms,u=n.vertexTextures;let d=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},f=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function m(t){let e;return t&&t.isTexture?e=t.encoding:t&&t.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e=t.texture.encoding):e=cp,e}return{getParameters:function(r,s,f,g,v){const y=g.fog,_=r.isMeshStandardMaterial?g.environment:null,x=e.get(r.envMap||_),w=p[r.type],b=v.isSkinnedMesh?function(t){const e=t.skeleton.bones;if(l)return 1024;{const t=c,i=Math.floor((t-20)/4),n=Math.min(i,e.length);return n<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+n+"."),0):n}}(v):0;let M,S;if(null!==r.precision&&(d=n.getMaxPrecision(r.precision),d!==r.precision&&console.warn("THREE.WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead.")),w){const t=Cg[w];M=t.vertexShader,S=t.fragmentShader}else M=r.vertexShader,S=r.fragmentShader;const T=t.getRenderTarget();return{isWebGL2:a,shaderID:w,shaderName:r.type,vertexShader:M,fragmentShader:S,defines:r.defines,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,instancing:!0===v.isInstancedMesh,instancingColor:!0===v.isInstancedMesh&&null!==v.instanceColor,supportsVertexTextures:u,outputEncoding:null!==T?m(T.texture):t.outputEncoding,map:!!r.map,mapEncoding:m(r.map),matcap:!!r.matcap,matcapEncoding:m(r.matcap),envMap:!!x,envMapMode:x&&x.mapping,envMapEncoding:m(x),envMapCubeUV:!!x&&(x.mapping===Du||x.mapping===Iu),lightMap:!!r.lightMap,lightMapEncoding:m(r.lightMap),aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,emissiveMapEncoding:m(r.emissiveMap),bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:r.normalMapType===xp,tangentSpaceNormalMap:r.normalMapType===_p,clearcoatMap:!!r.clearcoatMap,clearcoatRoughnessMap:!!r.clearcoatRoughnessMap,clearcoatNormalMap:!!r.clearcoatNormalMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,alphaMap:!!r.alphaMap,gradientMap:!!r.gradientMap,sheen:!!r.sheen,transmissionMap:!!r.transmissionMap,combine:r.combine,vertexTangents:r.normalMap&&r.vertexTangents,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&v.geometry.attributes.color&&4===v.geometry.attributes.color.itemSize,vertexUvs:!!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatMap||r.clearcoatRoughnessMap||r.clearcoatNormalMap||r.displacementMap||r.transmissionMap),uvsVertexOnly:!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatNormalMap||r.transmissionMap||!r.displacementMap),fog:!!y,useFog:r.fog,fogExp2:y&&y.isFogExp2,flatShading:!!r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:h,skinning:r.skinning&&b>0,maxBones:b,useVertexTexture:l,morphTargets:r.morphTargets,morphNormals:r.morphNormals,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&f.length>0,shadowMapType:t.shadowMap.type,toneMapping:r.toneMapped?t.toneMapping:bu,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:r.side===Gc,flipSided:r.side===jc,depthPacking:void 0!==r.depthPacking&&r.depthPacking,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:a||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:a||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:a||i.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t<f.length;t++)i.push(e[f[t]]);i.push(t.outputEncoding),i.push(t.gammaFactor)}return i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=p[t.type];let i;if(e){const t=Cg[e];i=hg.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=s.length;t<e;t++){const e=s[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new uy(t,i,e,r),s.push(n)),n},releaseProgram:function(t){if(0==--t.usedTimes){const e=s.indexOf(t);s[e]=s[s.length-1],s.pop(),t.destroy()}},programs:s}}function py(){let t=new WeakMap;return{get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function fy(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function my(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function gy(t){const e=[];let i=0;const n=[],r=[],o={id:-1};function s(n,r,s,a,h,l){let c=e[i];const u=t.get(s);return void 0===c?(c={id:n.id,object:n,geometry:r,material:s,program:u.program||o,groupOrder:a,renderOrder:n.renderOrder,z:h,group:l},e[i]=c):(c.id=n.id,c.object=n,c.geometry=r,c.material=s,c.program=u.program||o,c.groupOrder=a,c.renderOrder=n.renderOrder,c.z=h,c.group=l),i++,c}return{opaque:n,transparent:r,init:function(){i=0,n.length=0,r.length=0},push:function(t,e,i,o,a,h){const l=s(t,e,i,o,a,h);(!0===i.transparent?r:n).push(l)},unshift:function(t,e,i,o,a,h){const l=s(t,e,i,o,a,h);(!0===i.transparent?r:n).unshift(l)},finish:function(){for(let t=i,n=e.length;t<n;t++){const i=e[t];if(null===i.id)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.program=null,i.group=null}},sort:function(t,e){n.length>1&&n.sort(t||fy),r.length>1&&r.sort(e||my)}}}function vy(t){let e=new WeakMap;return{get:function(i,n){let r;return!1===e.has(i)?(r=new gy(t),e.set(i,[r])):n>=e.get(i).length?(r=new gy(t),e.get(i).push(r)):r=e.get(i)[n],r},dispose:function(){e=new WeakMap}}}function yy(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new jp,color:new fm};break;case"SpotLight":i={position:new jp,direction:new jp,color:new fm,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new jp,color:new fm,distance:0,decay:0};break;case"HemisphereLight":i={direction:new jp,skyColor:new fm,groundColor:new fm};break;case"RectAreaLight":i={color:new fm,position:new jp,halfWidth:new jp,halfHeight:new jp}}return t[e.id]=i,i}}}let _y=0;function xy(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function wy(t,e){const i=new yy,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Lp};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Lp,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let t=0;t<9;t++)r.probe.push(new jp);const o=new jp,s=new _f,a=new _f;return{setup:function(o){let s=0,a=0,h=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let l=0,c=0,u=0,d=0,p=0,f=0,m=0,g=0;o.sort(xy);for(let t=0,e=o.length;t<e;t++){const e=o[t],v=e.color,y=e.intensity,_=e.distance,x=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)s+=v.r*y,a+=v.g*y,h+=v.b*y;else if(e.isLightProbe)for(let t=0;t<9;t++)r.probe[t].addScaledVector(e.sh.coefficients[t],y);else if(e.isDirectionalLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity),e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,r.directionalShadow[l]=i,r.directionalShadowMap[l]=x,r.directionalShadowMatrix[l]=e.shadow.matrix,f++}r.directional[l]=t,l++}else if(e.isSpotLight){const t=i.get(e);if(t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(v).multiplyScalar(y),t.distance=_,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,r.spotShadow[u]=i,r.spotShadowMap[u]=x,r.spotShadowMatrix[u]=e.shadow.matrix,g++}r.spot[u]=t,u++}else if(e.isRectAreaLight){const t=i.get(e);t.color.copy(v).multiplyScalar(y),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),r.rectArea[d]=t,d++}else if(e.isPointLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,i.shadowCameraNear=t.camera.near,i.shadowCameraFar=t.camera.far,r.pointShadow[c]=i,r.pointShadowMap[c]=x,r.pointShadowMatrix[c]=e.shadow.matrix,m++}r.point[c]=t,c++}else if(e.isHemisphereLight){const t=i.get(e);t.skyColor.copy(e.color).multiplyScalar(y),t.groundColor.copy(e.groundColor).multiplyScalar(y),r.hemi[p]=t,p++}}d>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=Eg.LTC_FLOAT_1,r.rectAreaLTC2=Eg.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Eg.LTC_HALF_1,r.rectAreaLTC2=Eg.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=s,r.ambient[1]=a,r.ambient[2]=h;const v=r.hash;v.directionalLength===l&&v.pointLength===c&&v.spotLength===u&&v.rectAreaLength===d&&v.hemiLength===p&&v.numDirectionalShadows===f&&v.numPointShadows===m&&v.numSpotShadows===g||(r.directional.length=l,r.spot.length=u,r.rectArea.length=d,r.point.length=c,r.hemi.length=p,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=m,r.spotShadowMatrix.length=g,v.directionalLength=l,v.pointLength=c,v.spotLength=u,v.rectAreaLength=d,v.hemiLength=p,v.numDirectionalShadows=f,v.numPointShadows=m,v.numSpotShadows=g,r.version=_y++)},setupView:function(t,e){let i=0,n=0,h=0,l=0,c=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=r.directional[i];t.direction.setFromMatrixPosition(d.matrixWorld),o.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(o),t.direction.transformDirection(u),i++}else if(d.isSpotLight){const t=r.spot[h];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(d.matrixWorld),o.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(o),t.direction.transformDirection(u),h++}else if(d.isRectAreaLight){const t=r.rectArea[l];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),a.identity(),s.copy(d.matrixWorld),s.premultiply(u),a.extractRotation(s),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),l++}else if(d.isPointLight){const t=r.point[n];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),n++}else if(d.isHemisphereLight){const t=r.hemi[c];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(u),t.direction.normalize(),c++}}},state:r}}function by(t,e){const i=new wy(t,e),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(){i.setup(n)},setupLightsView:function(t){i.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){r.push(t)}}}function My(t,e){let i=new WeakMap;return{get:function(n,r=0){let o;return!1===i.has(n)?(o=new by(t,e),i.set(n,[o])):r>=i.get(n).length?(o=new by(t,e),i.get(n).push(o)):o=i.get(n)[r],o},dispose:function(){i=new WeakMap}}}class Sy extends am{constructor(t){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}Sy.prototype.isMeshDepthMaterial=!0;class Ty extends am{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new jp,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}Ty.prototype.isMeshDistanceMaterial=!0;var Ey="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}",Cy="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";function Py(t,e,i){let n=new wg;const r=new Lp,o=new Lp,s=new Fp,a=[],h=[],l={},c=i.maxTextureSize,u={0:jc,1:Hc,2:Gc},d=new ug({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Lp},radius:{value:4}},vertexShader:Cy,fragmentShader:Ey}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new Nm;f.setAttribute("position",new ym(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new ng(f,d),g=this;function v(i,n){const r=e.update(m);d.uniforms.shadow_pass.value=i.map.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,d,m,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,p,m,null)}function y(t,e,i){const n=t<<0|e<<1|i<<2;let r=a[n];return void 0===r&&(r=new Sy({depthPacking:yp,morphTargets:t,skinning:e}),a[n]=r),r}function _(t,e,i){const n=t<<0|e<<1|i<<2;let r=h[n];return void 0===r&&(r=new Ty({morphTargets:t,skinning:e}),h[n]=r),r}function x(e,i,n,r,o,s,a){let h=null,c=y,d=e.customDepthMaterial;if(!0===r.isPointLight&&(c=_,d=e.customDistanceMaterial),void 0===d){let t=!1;!0===n.morphTargets&&(t=i.morphAttributes&&i.morphAttributes.position&&i.morphAttributes.position.length>0);let r=!1;!0===e.isSkinnedMesh&&(!0===n.skinning?r=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e));h=c(t,r,!0===e.isInstancedMesh)}else h=d;if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){const t=h.uuid,e=n.uuid;let i=l[t];void 0===i&&(i={},l[t]=i);let r=i[e];void 0===r&&(r=h.clone(),i[e]=r),h=r}return h.visible=n.visible,h.wireframe=n.wireframe,h.side=a===Nc?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],h.clipShadows=n.clipShadows,h.clippingPlanes=n.clippingPlanes,h.clipIntersection=n.clipIntersection,h.wireframeLinewidth=n.wireframeLinewidth,h.linewidth=n.linewidth,!0===r.isPointLight&&!0===h.isMeshDistanceMaterial&&(h.referencePosition.setFromMatrixPosition(r.matrixWorld),h.nearDistance=o,h.farDistance=s),h}function w(i,r,o,s,a){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&a===Nc)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,i.matrixWorld);const n=e.update(i),r=i.material;if(Array.isArray(r)){const e=n.groups;for(let h=0,l=e.length;h<l;h++){const l=e[h],c=r[l.materialIndex];if(c&&c.visible){const e=x(i,n,c,s,o.near,o.far,a);t.renderBufferDirect(o,null,n,e,i,l)}}}else if(r.visible){const e=x(i,n,r,s,o.near,o.far,a);t.renderBufferDirect(o,null,n,e,i,null)}}const h=i.children;for(let t=0,e=h.length;t<e;t++)w(h[t],r,o,s,a)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Fc,this.render=function(e,i,a){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===e.length)return;const h=t.getRenderTarget(),l=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(Uc),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(let h=0,l=e.length;h<l;h++){const l=e[h],u=l.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const p=u.getFrameExtents();if(r.multiply(p),o.copy(u.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(o.x=Math.floor(c/p.x),r.x=o.x*p.x,u.mapSize.x=o.x),r.y>c&&(o.y=Math.floor(c/p.y),r.y=o.y*p.y,u.mapSize.y=o.y)),null===u.map&&!u.isPointLightShadow&&this.type===Nc){const t={minFilter:ju,magFilter:ju,format:rd};u.map=new Bp(r.x,r.y,t),u.map.texture.name=l.name+".shadowMap",u.mapPass=new Bp(r.x,r.y,t),u.camera.updateProjectionMatrix()}if(null===u.map){const t={minFilter:Bu,magFilter:Bu,format:rd};u.map=new Bp(r.x,r.y,t),u.map.texture.name=l.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const f=u.getViewportCount();for(let t=0;t<f;t++){const e=u.getViewport(t);s.set(o.x*e.x,o.y*e.y,o.x*e.z,o.y*e.w),d.viewport(s),u.updateMatrices(l,t),n=u.getFrustum(),w(i,a,u.camera,l,this.type)}u.isPointLightShadow||this.type!==Nc||v(u,a),u.needsUpdate=!1}g.needsUpdate=!1,t.setRenderTarget(h,l,u)}}function Ay(t,e,i){const n=i.isWebGL2;const r=new function(){let e=!1;const i=new Fp;let n=null;const r=new Fp(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,o,s,a){!0===a&&(e*=s,n*=s,o*=s),i.set(e,n,o,s),!1===r.equals(i)&&(t.clearColor(e,n,o,s),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},o=new function(){let e=!1,i=null,n=null,r=null;return{setTest:function(t){t?k(2929):z(2929)},setMask:function(n){i===n||e||(t.depthMask(n),i=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case uu:t.depthFunc(512);break;case du:t.depthFunc(519);break;case pu:t.depthFunc(513);break;case fu:t.depthFunc(515);break;case mu:t.depthFunc(514);break;case gu:t.depthFunc(518);break;case vu:t.depthFunc(516);break;case yu:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);n=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,i=null,n=null,r=null}}},s=new function(){let e=!1,i=null,n=null,r=null,o=null,s=null,a=null,h=null,l=null;return{setTest:function(t){e||(t?k(2960):z(2960))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,s){n===e&&r===i&&o===s||(t.stencilFunc(e,i,s),n=e,r=i,o=s)},setOp:function(e,i,n){s===e&&a===i&&h===n||(t.stencilOp(e,i,n),s=e,a=i,h=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,i=null,n=null,r=null,o=null,s=null,a=null,h=null,l=null}}};let a={},h=null,l={},c=null,u=!1,d=null,p=null,f=null,m=null,g=null,v=null,y=null,_=!1,x=null,w=null,b=null,M=null,S=null;const T=t.getParameter(35661);let E=!1,C=0;const P=t.getParameter(7938);-1!==P.indexOf("WebGL")?(C=parseFloat(/^WebGL (\d)/.exec(P)[1]),E=C>=1):-1!==P.indexOf("OpenGL ES")&&(C=parseFloat(/^OpenGL ES (\d)/.exec(P)[1]),E=C>=2);let A=null,L={};const R=new Fp(0,0,t.canvas.width,t.canvas.height),O=new Fp(0,0,t.canvas.width,t.canvas.height);function D(e,i,n){const r=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;e<n;e++)t.texImage2D(i+e,0,6408,1,1,0,6408,5121,r);return o}const I={};function k(e){!0!==a[e]&&(t.enable(e),a[e]=!0)}function z(e){!1!==a[e]&&(t.disable(e),a[e]=!1)}I[3553]=D(3553,3553,1),I[34067]=D(34067,34069,6),r.setClear(0,0,0,1),o.setClear(1),s.setClear(0),k(2929),o.setFunc(fu),H(!1),j(kc),k(2884),N(Uc);const F={[Yc]:32774,[Jc]:32778,[Qc]:32779};if(n)F[Kc]=32775,F[$c]=32776;else{const t=e.get("EXT_blend_minmax");null!==t&&(F[Kc]=t.MIN_EXT,F[$c]=t.MAX_EXT)}const B={[tu]:0,[eu]:1,[iu]:768,[ru]:770,[cu]:776,[hu]:774,[su]:772,[nu]:769,[ou]:771,[lu]:775,[au]:773};function N(e,i,n,r,o,s,a,h){if(e!==Uc){if(!1===u&&(k(3042),u=!0),e===Xc)o=o||i,s=s||n,a=a||r,i===p&&o===g||(t.blendEquationSeparate(F[i],F[o]),p=i,g=o),n===f&&r===m&&s===v&&a===y||(t.blendFuncSeparate(B[n],B[r],B[s],B[a]),f=n,m=r,v=s,y=a),d=e,_=null;else if(e!==d||h!==_){if(p===Yc&&g===Yc||(t.blendEquation(32774),p=Yc,g=Yc),h)switch(e){case Vc:t.blendFuncSeparate(1,771,1,771);break;case Wc:t.blendFunc(1,1);break;case Zc:t.blendFuncSeparate(0,0,769,771);break;case qc:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case Vc:t.blendFuncSeparate(770,771,1,771);break;case Wc:t.blendFunc(770,1);break;case Zc:t.blendFunc(0,769);break;case qc:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}f=null,m=null,v=null,y=null,d=e,_=h}}else!0===u&&(z(3042),u=!1)}function H(e){x!==e&&(e?t.frontFace(2304):t.frontFace(2305),x=e)}function j(e){e!==Ic?(k(2884),e!==w&&(e===kc?t.cullFace(1029):e===zc?t.cullFace(1028):t.cullFace(1032))):z(2884),w=e}function G(e,i,n){e?(k(32823),M===i&&S===n||(t.polygonOffset(i,n),M=i,S=n)):z(32823)}function U(e){void 0===e&&(e=33984+T-1),A!==e&&(t.activeTexture(e),A=e)}return{buffers:{color:r,depth:o,stencil:s},enable:k,disable:z,bindFramebuffer:function(e,i){null===i&&null!==h&&(i=h),l[e]!==i&&(t.bindFramebuffer(e,i),l[e]=i)},bindXRFramebuffer:function(e){e!==h&&(t.bindFramebuffer(36160,e),h=e)},useProgram:function(e){return c!==e&&(t.useProgram(e),c=e,!0)},setBlending:N,setMaterial:function(t,e){t.side===Gc?z(2884):k(2884);let i=t.side===jc;e&&(i=!i),H(i),t.blending===Vc&&!1===t.transparent?N(Uc):N(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),o.setFunc(t.depthFunc),o.setTest(t.depthTest),o.setMask(t.depthWrite),r.setMask(t.colorWrite);const n=t.stencilWrite;s.setTest(n),n&&(s.setMask(t.stencilWriteMask),s.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),s.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),G(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?k(32926):z(32926)},setFlipSided:H,setCullFace:j,setLineWidth:function(e){e!==b&&(E&&t.lineWidth(e),b=e)},setPolygonOffset:G,setScissorTest:function(t){t?k(3089):z(3089)},activeTexture:U,bindTexture:function(e,i){null===A&&U();let n=L[A];void 0===n&&(n={type:void 0,texture:void 0},L[A]=n),n.type===e&&n.texture===i||(t.bindTexture(e,i||I[e]),n.type=e,n.texture=i)},unbindTexture:function(){const e=L[A];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===R.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),R.copy(e))},viewport:function(e){!1===O.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),O.copy(e))},reset:function(){t.disable(3042),t.disable(2884),t.disable(2929),t.disable(32823),t.disable(3089),t.disable(2960),t.disable(32926),t.blendEquation(32774),t.blendFunc(1,0),t.blendFuncSeparate(1,0,1,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(513),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(519,0,4294967295),t.stencilOp(7680,7680,7680),t.clearStencil(0),t.cullFace(1029),t.frontFace(2305),t.polygonOffset(0,0),t.activeTexture(33984),t.bindFramebuffer(36160,null),!0===n&&(t.bindFramebuffer(36009,null),t.bindFramebuffer(36008,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),a={},A=null,L={},h=null,l={},c=null,u=!1,d=null,p=null,f=null,m=null,g=null,v=null,y=null,_=!1,x=null,w=null,b=null,M=null,S=null,R.set(0,0,t.canvas.width,t.canvas.height),O.set(0,0,t.canvas.width,t.canvas.height),r.reset(),o.reset(),s.reset()}}}function Ly(t,e,i,n,r,o,s){const a=r.isWebGL2,h=r.maxTextures,l=r.maxCubemapSize,c=r.maxTextureSize,u=r.maxSamples,d=new WeakMap;let p,f=!1;try{f="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return f?new OffscreenCanvas(t,e):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function g(t,e,i,n){let r=1;if((t.width>n||t.height>n)&&(r=n/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?Ap.floorPowerOfTwo:Math.floor,o=n(r*t.width),s=n(r*t.height);void 0===p&&(p=m(o,s));const a=i?m(o,s):p;a.width=o,a.height=s;return a.getContext("2d").drawImage(t,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function v(t){return Ap.isPowerOfTwo(t.width)&&Ap.isPowerOfTwo(t.height)}function y(t,e){return t.generateMipmaps&&e&&t.minFilter!==Bu&&t.minFilter!==ju}function _(e,i,r,o){t.generateMipmap(e);n.get(i).__maxMipLevel=Math.log2(Math.max(r,o))}function x(i,n,r){if(!1===a)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;return 6403===n&&(5126===r&&(o=33326),5131===r&&(o=33325),5121===r&&(o=33321)),6407===n&&(5126===r&&(o=34837),5131===r&&(o=34843),5121===r&&(o=32849)),6408===n&&(5126===r&&(o=34836),5131===r&&(o=34842),5121===r&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||e.get("EXT_color_buffer_float"),o}function w(t){return t===Bu||t===Nu||t===Hu?9728:9729}function b(e){const i=e.target;i.removeEventListener("dispose",b),function(e){const i=n.get(e);if(void 0===i.__webglInit)return;t.deleteTexture(i.__webglTexture),n.remove(e)}(i),i.isVideoTexture&&d.delete(i),s.memory.textures--}function M(e){const i=e.target;i.removeEventListener("dispose",M),function(e){const i=e.texture,r=n.get(e),o=n.get(i);if(!e)return;void 0!==o.__webglTexture&&t.deleteTexture(o.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(r.__webglFramebuffer[e]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[e]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&t.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&t.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&t.deleteRenderbuffer(r.__webglDepthRenderbuffer);n.remove(i),n.remove(e)}(i),s.memory.textures--}let S=0;function T(t,e){const r=n.get(t);if(t.isVideoTexture&&function(t){const e=s.render.frame;d.get(t)!==e&&(d.set(t,e),t.update())}(t),t.version>0&&r.__version!==t.version){const i=t.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void R(r,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+e),i.bindTexture(3553,r.__webglTexture)}function E(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?function(e,n,r){if(6!==n.image.length)return;L(e,n),i.activeTexture(33984+r),i.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment),t.pixelStorei(37443,0);const s=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),h=n.image[0]&&n.image[0].isDataTexture,c=[];for(let t=0;t<6;t++)c[t]=s||h?h?n.image[t].image:n.image[t]:g(n.image[t],!1,!0,l);const u=c[0],d=v(u)||a,p=o.convert(n.format),f=o.convert(n.type),m=x(n.internalFormat,p,f);let w;if(A(34067,n,d),s){for(let t=0;t<6;t++){w=c[t].mipmaps;for(let e=0;e<w.length;e++){const r=w[e];n.format!==rd&&n.format!==nd?null!==p?i.compressedTexImage2D(34069+t,e,m,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+t,e,m,r.width,r.height,0,p,f,r.data)}}e.__maxMipLevel=w.length-1}else{w=n.mipmaps;for(let t=0;t<6;t++)if(h){i.texImage2D(34069+t,0,m,c[t].width,c[t].height,0,p,f,c[t].data);for(let e=0;e<w.length;e++){const n=w[e].image[t].image;i.texImage2D(34069+t,e+1,m,n.width,n.height,0,p,f,n.data)}}else{i.texImage2D(34069+t,0,m,p,f,c[t]);for(let e=0;e<w.length;e++){const n=w[e];i.texImage2D(34069+t,e+1,m,p,f,n.image[t])}}e.__maxMipLevel=w.length}y(n,d)&&_(34067,n,u.width,u.height);e.__version=n.version,n.onUpdate&&n.onUpdate(n)}(s,e,r):(i.activeTexture(33984+r),i.bindTexture(34067,s.__webglTexture))}const C={[ku]:10497,[zu]:33071,[Fu]:33648},P={[Bu]:9728,[Nu]:9984,[Hu]:9986,[ju]:9729,[Gu]:9985,[Uu]:9987};function A(i,o,s){if(s?(t.texParameteri(i,10242,C[o.wrapS]),t.texParameteri(i,10243,C[o.wrapT]),32879!==i&&35866!==i||t.texParameteri(i,32882,C[o.wrapR]),t.texParameteri(i,10240,P[o.magFilter]),t.texParameteri(i,10241,P[o.minFilter])):(t.texParameteri(i,10242,33071),t.texParameteri(i,10243,33071),32879!==i&&35866!==i||t.texParameteri(i,32882,33071),o.wrapS===zu&&o.wrapT===zu||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(i,10240,w(o.magFilter)),t.texParameteri(i,10241,w(o.minFilter)),o.minFilter!==Bu&&o.minFilter!==ju&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===e.has("EXT_texture_filter_anisotropic")){const s=e.get("EXT_texture_filter_anisotropic");if(o.type===Ju&&!1===e.has("OES_texture_float_linear"))return;if(!1===a&&o.type===Qu&&!1===e.has("OES_texture_half_float_linear"))return;(o.anisotropy>1||n.get(o).__currentAnisotropy)&&(t.texParameterf(i,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),n.get(o).__currentAnisotropy=o.anisotropy)}}function L(e,i){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",b),e.__webglTexture=t.createTexture(),s.memory.textures++)}function R(e,n,r){let s=3553;n.isDataTexture2DArray&&(s=35866),n.isDataTexture3D&&(s=32879),L(e,n),i.activeTexture(33984+r),i.bindTexture(s,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment),t.pixelStorei(37443,0);const h=function(t){return!a&&(t.wrapS!==zu||t.wrapT!==zu||t.minFilter!==Bu&&t.minFilter!==ju)}(n)&&!1===v(n.image),l=g(n.image,h,!1,c),u=v(l)||a,d=o.convert(n.format);let p,f=o.convert(n.type),m=x(n.internalFormat,d,f);A(s,n,u);const w=n.mipmaps;if(n.isDepthTexture)m=6402,a?m=n.type===Ju?36012:n.type===Yu?33190:n.type===ed?35056:33189:n.type===Ju&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===hd&&6402===m&&n.type!==qu&&n.type!==Yu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=qu,f=o.convert(n.type)),n.format===ld&&6402===m&&(m=34041,n.type!==ed&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=ed,f=o.convert(n.type))),i.texImage2D(3553,0,m,l.width,l.height,0,d,f,null);else if(n.isDataTexture)if(w.length>0&&u){for(let t=0,e=w.length;t<e;t++)p=w[t],i.texImage2D(3553,t,m,p.width,p.height,0,d,f,p.data);n.generateMipmaps=!1,e.__maxMipLevel=w.length-1}else i.texImage2D(3553,0,m,l.width,l.height,0,d,f,l.data),e.__maxMipLevel=0;else if(n.isCompressedTexture){for(let t=0,e=w.length;t<e;t++)p=w[t],n.format!==rd&&n.format!==nd?null!==d?i.compressedTexImage2D(3553,t,m,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,t,m,p.width,p.height,0,d,f,p.data);e.__maxMipLevel=w.length-1}else if(n.isDataTexture2DArray)i.texImage3D(35866,0,m,l.width,l.height,l.depth,0,d,f,l.data),e.__maxMipLevel=0;else if(n.isDataTexture3D)i.texImage3D(32879,0,m,l.width,l.height,l.depth,0,d,f,l.data),e.__maxMipLevel=0;else if(w.length>0&&u){for(let t=0,e=w.length;t<e;t++)p=w[t],i.texImage2D(3553,t,m,d,f,p);n.generateMipmaps=!1,e.__maxMipLevel=w.length-1}else i.texImage2D(3553,0,m,d,f,l),e.__maxMipLevel=0;y(n,u)&&_(s,n,l.width,l.height),e.__version=n.version,n.onUpdate&&n.onUpdate(n)}function O(e,r,s,a){const h=r.texture,l=o.convert(h.format),c=o.convert(h.type),u=x(h.internalFormat,l,c);32879===a||35866===a?i.texImage3D(a,0,u,r.width,r.height,r.depth,0,l,c,null):i.texImage2D(a,0,u,r.width,r.height,0,l,c,null),i.bindFramebuffer(36160,e),t.framebufferTexture2D(36160,s,a,n.get(h).__webglTexture,0),i.bindFramebuffer(36160,null)}function D(e,i,n){if(t.bindRenderbuffer(36161,e),i.depthBuffer&&!i.stencilBuffer){let r=33189;if(n){const e=i.depthTexture;e&&e.isDepthTexture&&(e.type===Ju?r=36012:e.type===Yu&&(r=33190));const n=k(i);t.renderbufferStorageMultisample(36161,n,r,i.width,i.height)}else t.renderbufferStorage(36161,r,i.width,i.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(i.depthBuffer&&i.stencilBuffer){if(n){const e=k(i);t.renderbufferStorageMultisample(36161,e,35056,i.width,i.height)}else t.renderbufferStorage(36161,34041,i.width,i.height);t.framebufferRenderbuffer(36160,33306,36161,e)}else{const e=i.texture,r=o.convert(e.format),s=o.convert(e.type),a=x(e.internalFormat,r,s);if(n){const e=k(i);t.renderbufferStorageMultisample(36161,e,a,i.width,i.height)}else t.renderbufferStorage(36161,a,i.width,i.height)}t.bindRenderbuffer(36161,null)}function I(e){const r=n.get(e),o=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture){if(o)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),T(r.depthTexture,0);const o=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===hd)t.framebufferTexture2D(36160,36096,3553,o,0);else{if(r.depthTexture.format!==ld)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(36160,33306,3553,o,0)}}(r.__webglFramebuffer,e)}else if(o){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(36160,r.__webglFramebuffer[n]),r.__webglDepthbuffer[n]=t.createRenderbuffer(),D(r.__webglDepthbuffer[n],e,!1)}else i.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),D(r.__webglDepthbuffer,e,!1);i.bindFramebuffer(36160,null)}function k(t){return a&&t.isWebGLMultisampleRenderTarget?Math.min(u,t.samples):0}let z=!1,F=!1;this.allocateTextureUnit=function(){const t=S;return t>=h&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+h),S+=1,t},this.resetTextureUnits=function(){S=0},this.setTexture2D=T,this.setTexture2DArray=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?R(r,t,e):(i.activeTexture(33984+e),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?R(r,t,e):(i.activeTexture(33984+e),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=E,this.setupRenderTarget=function(e){const r=e.texture,h=n.get(e),l=n.get(r);e.addEventListener("dispose",M),l.__webglTexture=t.createTexture(),l.__version=r.version,s.memory.textures++;const c=!0===e.isWebGLCubeRenderTarget,u=!0===e.isWebGLMultisampleRenderTarget,d=r.isDataTexture3D||r.isDataTexture2DArray,p=v(e)||a;if(!a||r.format!==nd||r.type!==Ju&&r.type!==Qu||(r.format=rd,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),c){h.__webglFramebuffer=[];for(let e=0;e<6;e++)h.__webglFramebuffer[e]=t.createFramebuffer()}else if(h.__webglFramebuffer=t.createFramebuffer(),u)if(a){h.__webglMultisampledFramebuffer=t.createFramebuffer(),h.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,h.__webglColorRenderbuffer);const n=o.convert(r.format),s=o.convert(r.type),a=x(r.internalFormat,n,s),l=k(e);t.renderbufferStorageMultisample(36161,l,a,e.width,e.height),i.bindFramebuffer(36160,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,h.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),e.depthBuffer&&(h.__webglDepthRenderbuffer=t.createRenderbuffer(),D(h.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(c){i.bindTexture(34067,l.__webglTexture),A(34067,r,p);for(let t=0;t<6;t++)O(h.__webglFramebuffer[t],e,36064,34069+t);y(r,p)&&_(34067,r,e.width,e.height),i.bindTexture(34067,null)}else{let t=3553;if(d)if(a){t=r.isDataTexture3D?32879:35866}else console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.");i.bindTexture(t,l.__webglTexture),A(t,r,p),O(h.__webglFramebuffer,e,36064,t),y(r,p)&&_(3553,r,e.width,e.height),i.bindTexture(3553,null)}e.depthBuffer&&I(e)},this.updateRenderTargetMipmap=function(t){const e=t.texture;if(y(e,v(t)||a)){const r=t.isWebGLCubeRenderTarget?34067:3553,o=n.get(e).__webglTexture;i.bindTexture(r,o),_(r,e,t.width,t.height),i.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function(e){if(e.isWebGLMultisampleRenderTarget)if(a){const r=n.get(e);i.bindFramebuffer(36008,r.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,r.__webglFramebuffer);const o=e.width,s=e.height;let a=16384;e.depthBuffer&&(a|=256),e.stencilBuffer&&(a|=1024),t.blitFramebuffer(0,0,o,s,0,0,o,s,a,9728),i.bindFramebuffer(36160,r.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(t,e){t&&t.isWebGLRenderTarget&&(!1===z&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),z=!0),t=t.texture),T(t,e)},this.safeSetTextureCube=function(t,e){t&&t.isWebGLCubeRenderTarget&&(!1===F&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),F=!0),t=t.texture),E(t,e)}}function Ry(t,e,i){const n=i.isWebGL2;return{convert:function(t){let i;if(t===Vu)return 5121;if(t===Ku)return 32819;if(t===$u)return 32820;if(t===td)return 33635;if(t===Wu)return 5120;if(t===Zu)return 5122;if(t===qu)return 5123;if(t===Xu)return 5124;if(t===Yu)return 5125;if(t===Ju)return 5126;if(t===Qu)return n?5131:(i=e.get("OES_texture_half_float"),null!==i?i.HALF_FLOAT_OES:null);if(t===id)return 6406;if(t===nd)return 6407;if(t===rd)return 6408;if(t===od)return 6409;if(t===sd)return 6410;if(t===hd)return 6402;if(t===ld)return 34041;if(t===cd)return 6403;if(t===ud)return 36244;if(t===dd)return 33319;if(t===pd)return 33320;if(t===fd)return 36248;if(t===md)return 36249;if(t===gd||t===vd||t===yd||t===_d){if(i=e.get("WEBGL_compressed_texture_s3tc"),null===i)return null;if(t===gd)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===vd)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===yd)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===_d)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t===xd||t===wd||t===bd||t===Md){if(i=e.get("WEBGL_compressed_texture_pvrtc"),null===i)return null;if(t===xd)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===wd)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===bd)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===Md)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t===Sd)return i=e.get("WEBGL_compressed_texture_etc1"),null!==i?i.COMPRESSED_RGB_ETC1_WEBGL:null;if((t===Td||t===Ed)&&(i=e.get("WEBGL_compressed_texture_etc"),null!==i)){if(t===Td)return i.COMPRESSED_RGB8_ETC2;if(t===Ed)return i.COMPRESSED_RGBA8_ETC2_EAC}return t===Cd||t===Pd||t===Ad||t===Ld||t===Rd||t===Od||t===Dd||t===Id||t===kd||t===zd||t===Fd||t===Bd||t===Nd||t===Hd||t===Gd||t===Ud||t===Vd||t===Wd||t===Zd||t===qd||t===Xd||t===Yd||t===Jd||t===Qd||t===Kd||t===$d||t===tp||t===ep?(i=e.get("WEBGL_compressed_texture_astc"),null!==i?t:null):t===jd?(i=e.get("EXT_texture_compression_bptc"),null!==i?t:null):t===ed?n?34042:(i=e.get("WEBGL_depth_texture"),null!==i?i.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}class Oy extends pg{constructor(t=[]){super(),this.cameras=t}}Oy.prototype.isArrayCamera=!0;class Dy extends Vf{constructor(){super(),this.type="Group"}}function Iy(){this._targetRay=null,this._grip=null,this._hand=null}function ky(t,e){const i=this,n=t.state;let r=null,o=1,s=null,a="local-floor",h=null;const l=[],c=new Map,u=new pg;u.layers.enable(1),u.viewport=new Fp;const d=new pg;d.layers.enable(2),d.viewport=new Fp;const p=[u,d],f=new Oy;f.layers.enable(1),f.layers.enable(2);let m=null,g=null;function v(t){const e=c.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function y(){c.forEach((function(t,e){t.disconnect(e)})),c.clear(),m=null,g=null,n.bindXRFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),S.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function _(t){const e=r.inputSources;for(let t=0;t<l.length;t++)c.set(e[t],l[t]);for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=c.get(i);n&&(n.dispatchEvent({type:"disconnected",data:i}),c.delete(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e],n=c.get(i);n&&n.dispatchEvent({type:"connected",data:i})}}this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=l[t];return void 0===e&&(e=new Iy,l[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=l[t];return void 0===e&&(e=new Iy,l[t]=e),e.getGripSpace()},this.getHand=function(t){let e=l[t];return void 0===e&&(e=new Iy,l[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){o=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s},this.getSession=function(){return r},this.setSession=async function(t){if(r=t,null!==r){r.addEventListener("select",v),r.addEventListener("selectstart",v),r.addEventListener("selectend",v),r.addEventListener("squeeze",v),r.addEventListener("squeezestart",v),r.addEventListener("squeezeend",v),r.addEventListener("end",y),r.addEventListener("inputsourceschange",_);const t=e.getContextAttributes();!0!==t.xrCompatible&&await e.makeXRCompatible();const n={antialias:t.antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:o},h=new XRWebGLLayer(r,e,n);r.updateRenderState({baseLayer:h}),s=await r.requestReferenceSpace(a),S.setContext(r),S.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};const x=new jp,w=new jp;function b(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.getCamera=function(t){f.near=d.near=u.near=t.near,f.far=d.far=u.far=t.far,m===f.near&&g===f.far||(r.updateRenderState({depthNear:f.near,depthFar:f.far}),m=f.near,g=f.far);const e=t.parent,i=f.cameras;b(f,e);for(let t=0;t<i.length;t++)b(i[t],e);t.matrixWorld.copy(f.matrixWorld),t.matrix.copy(f.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale);const n=t.children;for(let t=0,e=n.length;t<e;t++)n[t].updateMatrixWorld(!0);return 2===i.length?function(t,e,i){x.setFromMatrixPosition(e.matrixWorld),w.setFromMatrixPosition(i.matrixWorld);const n=x.distanceTo(w),r=e.projectionMatrix.elements,o=i.projectionMatrix.elements,s=r[14]/(r[10]-1),a=r[14]/(r[10]+1),h=(r[9]+1)/r[5],l=(r[9]-1)/r[5],c=(r[8]-1)/r[0],u=(o[8]+1)/o[0],d=s*c,p=s*u,f=n/(-c+u),m=f*-c;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=s+f,v=a+f,y=d-m,_=p+(n-m),b=h*a/v*g,M=l*a/v*g;t.projectionMatrix.makePerspective(y,_,b,M,g,v)}(f,u,d):f.projectionMatrix.copy(u.projectionMatrix),f};let M=null;const S=new bg;S.setAnimationLoop((function(t,e){if(h=e.getViewerPose(s),null!==h){const t=h.views,e=r.renderState.baseLayer;n.bindXRFramebuffer(e.framebuffer);let i=!1;t.length!==f.cameras.length&&(f.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){const r=t[n],o=e.getViewport(r),s=p[n];s.matrix.fromArray(r.transform.matrix),s.projectionMatrix.fromArray(r.projectionMatrix),s.viewport.set(o.x,o.y,o.width,o.height),0===n&&f.matrix.copy(s.matrix),!0===i&&f.cameras.push(s)}}const i=r.inputSources;for(let t=0;t<l.length;t++){const n=l[t],r=i[t];n.update(r,e,s)}M&&M(t,e)})),this.setAnimationLoop=function(t){M=t},this.dispose=function(){}}function zy(t){function e(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map),i.alphaMap&&(e.alphaMap.value=i.alphaMap),i.specularMap&&(e.specularMap.value=i.specularMap);const n=t.get(i).envMap;if(n){e.envMap.value=n,e.flipEnvMap.value=n.isCubeTexture&&n._needsFlipEnvMap?-1:1,e.reflectivity.value=i.reflectivity,e.refractionRatio.value=i.refractionRatio;const r=t.get(n).__maxMipLevel;void 0!==r&&(e.maxMipLevel.value=r)}let r,o;i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap&&(r=i.clearcoatRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix)),i.aoMap?o=i.aoMap:i.lightMap&&(o=i.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),e.uv2Transform.value.copy(o.matrix))}function i(e,i){e.roughness.value=i.roughness,e.metalness.value=i.metalness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap),i.bumpMap&&(e.bumpMap.value=i.bumpMap,e.bumpScale.value=i.bumpScale,i.side===jc&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,e.normalScale.value.copy(i.normalScale),i.side===jc&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias);t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,n,r,o){n.isMeshBasicMaterial?e(t,n):n.isMeshLambertMaterial?(e(t,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,n)):n.isMeshToonMaterial?(e(t,n),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===jc&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===jc&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshPhongMaterial?(e(t,n),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===jc&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===jc&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshStandardMaterial?(e(t,n),n.isMeshPhysicalMaterial?function(t,e){i(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap);e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===jc&&t.clearcoatNormalScale.value.negate());t.transmission.value=e.transmission,e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap)}(t,n):i(t,n)):n.isMeshMatcapMaterial?(e(t,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===jc&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===jc&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDepthMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDistanceMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,n)):n.isMeshNormalMaterial?(e(t,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===jc&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===jc&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,n)):n.isPointsMaterial?function(t,e,i,n){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*n,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);let r;e.map?r=e.map:e.alphaMap&&(r=e.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}(t,n,r,o):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);let i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,n):n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Fy(t){const e=void 0!==(t=t||{}).canvas?t.canvas:function(){const t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.style.display="block",t}(),i=void 0!==t.context?t.context:null,n=void 0!==t.alpha&&t.alpha,r=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,s=void 0!==t.antialias&&t.antialias,a=void 0===t.premultipliedAlpha||t.premultipliedAlpha,h=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,l=void 0!==t.powerPreference?t.powerPreference:"default",c=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let u=null,d=null;const p=[],f=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=cp,this.physicallyCorrectLights=!1,this.toneMapping=bu,this.toneMappingExposure=1;const m=this;let g=!1,v=0,y=0,_=null,x=-1,w=null;const b=new Fp,M=new Fp;let S=null,T=e.width,E=e.height,C=1,P=null,A=null;const L=new Fp(0,0,T,E),R=new Fp(0,0,T,E);let O=!1;const D=new wg;let I=!1,k=!1;const z=new _f,F=new jp,B={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function N(){return null===_?C:1}let H,j,G,U,V,W,Z,q,X,Y,J,Q,K,$,tt,et,it,nt,rt,ot,st,at,ht=i;function lt(t,i){for(let n=0;n<t.length;n++){const r=t[n],o=e.getContext(r,i);if(null!==o)return o}return null}try{const t={alpha:n,depth:r,stencil:o,antialias:s,premultipliedAlpha:a,preserveDrawingBuffer:h,powerPreference:l,failIfMajorPerformanceCaveat:c};if(e.addEventListener("webglcontextlost",dt,!1),e.addEventListener("webglcontextrestored",pt,!1),null===ht){const e=["webgl2","webgl","experimental-webgl"];if(!0===m.isWebGL1Renderer&&e.shift(),ht=lt(e,t),null===ht)throw lt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===ht.getShaderPrecisionFormat&&(ht.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function ct(){H=new Ig(ht),j=new Rg(ht,H,t),H.init(j),st=new Ry(ht,H,j),G=new Ay(ht,H,j),U=new Fg,V=new py,W=new Ly(ht,H,G,V,j,st,U),Z=new Dg(m),q=new Mg(ht,j),at=new Ag(ht,H,q,j),X=new kg(ht,q,U,at),Y=new jg(ht,X,q,U),nt=new Hg(ht),tt=new Og(V),J=new dy(m,Z,H,j,at,tt),Q=new zy(V),K=new vy(V),$=new My(H,j),it=new Pg(m,Z,G,Y,a),et=new Py(m,Y,j),rt=new Lg(ht,H,U,j),ot=new zg(ht,H,U,j),U.programs=J.programs,m.capabilities=j,m.extensions=H,m.properties=V,m.renderLists=K,m.shadowMap=et,m.state=G,m.info=U}ct();const ut=new ky(m,ht);function dt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function pt(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;const t=U.autoReset,e=et.enabled,i=et.autoUpdate,n=et.needsUpdate,r=et.type;ct(),U.autoReset=t,et.enabled=e,et.autoUpdate=i,et.needsUpdate=n,et.type=r}function ft(t){const e=t.target;e.removeEventListener("dispose",ft),function(t){(function(t){const e=V.get(t).programs;void 0!==e&&e.forEach((function(t){J.releaseProgram(t)}))})(t),V.remove(t)}(e)}this.xr=ut,this.getContext=function(){return ht},this.getContextAttributes=function(){return ht.getContextAttributes()},this.forceContextLoss=function(){const t=H.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=H.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(t){void 0!==t&&(C=t,this.setSize(T,E,!1))},this.getSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),t=new Lp),t.set(T,E)},this.setSize=function(t,i,n){ut.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(T=t,E=i,e.width=Math.floor(t*C),e.height=Math.floor(i*C),!1!==n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),t=new Lp),t.set(T*C,E*C).floor()},this.setDrawingBufferSize=function(t,i,n){T=t,E=i,C=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),t=new Fp),t.copy(b)},this.getViewport=function(t){return t.copy(L)},this.setViewport=function(t,e,i,n){t.isVector4?L.set(t.x,t.y,t.z,t.w):L.set(t,e,i,n),G.viewport(b.copy(L).multiplyScalar(C).floor())},this.getScissor=function(t){return t.copy(R)},this.setScissor=function(t,e,i,n){t.isVector4?R.set(t.x,t.y,t.z,t.w):R.set(t,e,i,n),G.scissor(M.copy(R).multiplyScalar(C).floor())},this.getScissorTest=function(){return O},this.setScissorTest=function(t){G.setScissorTest(O=t)},this.setOpaqueSort=function(t){P=t},this.setTransparentSort=function(t){A=t},this.getClearColor=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getClearColor() now requires a Color as an argument"),t=new fm),t.copy(it.getClearColor())},this.setClearColor=function(){it.setClearColor.apply(it,arguments)},this.getClearAlpha=function(){return it.getClearAlpha()},this.setClearAlpha=function(){it.setClearAlpha.apply(it,arguments)},this.clear=function(t,e,i){let n=0;(void 0===t||t)&&(n|=16384),(void 0===e||e)&&(n|=256),(void 0===i||i)&&(n|=1024),ht.clear(n)},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",dt,!1),e.removeEventListener("webglcontextrestored",pt,!1),K.dispose(),$.dispose(),V.dispose(),Z.dispose(),Y.dispose(),at.dispose(),ut.dispose(),ut.removeEventListener("sessionstart",gt),ut.removeEventListener("sessionend",vt),yt.stop()},this.renderBufferImmediate=function(t,e){at.initAttributes();const i=V.get(t);t.hasPositions&&!i.position&&(i.position=ht.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=ht.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=ht.createBuffer()),t.hasColors&&!i.color&&(i.color=ht.createBuffer());const n=e.getAttributes();t.hasPositions&&(ht.bindBuffer(34962,i.position),ht.bufferData(34962,t.positionArray,35048),at.enableAttribute(n.position),ht.vertexAttribPointer(n.position,3,5126,!1,0,0)),t.hasNormals&&(ht.bindBuffer(34962,i.normal),ht.bufferData(34962,t.normalArray,35048),at.enableAttribute(n.normal),ht.vertexAttribPointer(n.normal,3,5126,!1,0,0)),t.hasUvs&&(ht.bindBuffer(34962,i.uv),ht.bufferData(34962,t.uvArray,35048),at.enableAttribute(n.uv),ht.vertexAttribPointer(n.uv,2,5126,!1,0,0)),t.hasColors&&(ht.bindBuffer(34962,i.color),ht.bufferData(34962,t.colorArray,35048),at.enableAttribute(n.color),ht.vertexAttribPointer(n.color,3,5126,!1,0,0)),at.disableUnusedAttributes(),ht.drawArrays(4,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,i,n,r,o){null===e&&(e=B);const s=r.isMesh&&r.matrixWorld.determinant()<0,a=St(t,e,n,r);G.setMaterial(n,s);let h=i.index;const l=i.attributes.position;if(null===h){if(void 0===l||0===l.count)return}else if(0===h.count)return;let c,u=1;!0===n.wireframe&&(h=X.getWireframeAttribute(i),u=2),(n.morphTargets||n.morphNormals)&&nt.update(r,i,n,a),at.setup(r,n,a,i,h);let d=rt;null!==h&&(c=q.get(h),d=ot,d.setIndex(c));const p=null!==h?h.count:l.count,f=i.drawRange.start*u,m=i.drawRange.count*u,g=null!==o?o.start*u:0,v=null!==o?o.count*u:1/0,y=Math.max(f,g),_=Math.min(p,f+m,g+v)-1,x=Math.max(0,_-y+1);if(0!==x){if(r.isMesh)!0===n.wireframe?(G.setLineWidth(n.wireframeLinewidth*N()),d.setMode(1)):d.setMode(4);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),G.setLineWidth(t*N()),r.isLineSegments?d.setMode(1):r.isLineLoop?d.setMode(2):d.setMode(3)}else r.isPoints?d.setMode(0):r.isSprite&&d.setMode(4);if(r.isInstancedMesh)d.renderInstances(y,x,r.count);else if(i.isInstancedBufferGeometry){const t=Math.min(i.instanceCount,i._maxInstanceCount);d.renderInstances(y,x,t)}else d.render(y,x)}},this.compile=function(t,e){d=$.get(t),d.init(),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(),t.traverse((function(e){const i=e.material;if(i)if(Array.isArray(i))for(let n=0;n<i.length;n++){bt(i[n],t,e)}else bt(i,t,e)}))};let mt=null;function gt(){yt.stop()}function vt(){yt.start()}const yt=new bg;function _t(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)d.pushLight(t),t.castShadow&&d.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||D.intersectsSprite(t)){n&&F.setFromMatrixPosition(t.matrixWorld).applyMatrix4(z);const e=Y.update(t),r=t.material;r.visible&&u.push(t,e,r,i,F.z,null)}}else if(t.isImmediateRenderObject)n&&F.setFromMatrixPosition(t.matrixWorld).applyMatrix4(z),u.push(t,null,t.material,i,F.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==U.render.frame&&(t.skeleton.update(),t.skeleton.frame=U.render.frame),!t.frustumCulled||D.intersectsObject(t))){n&&F.setFromMatrixPosition(t.matrixWorld).applyMatrix4(z);const e=Y.update(t),r=t.material;if(Array.isArray(r)){const n=e.groups;for(let o=0,s=n.length;o<s;o++){const s=n[o],a=r[s.materialIndex];a&&a.visible&&u.push(t,e,a,i,F.z,s)}}else r.visible&&u.push(t,e,r,i,F.z,null)}const r=t.children;for(let t=0,o=r.length;t<o;t++)_t(r[t],e,i,n)}function xt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,o=t.length;r<o;r++){const o=t[r],s=o.object,a=o.geometry,h=null===n?o.material:n,l=o.group;if(i.isArrayCamera){const t=i.cameras;for(let i=0,n=t.length;i<n;i++){const n=t[i];s.layers.test(n.layers)&&(G.viewport(b.copy(n.viewport)),d.setupLightsView(n),wt(s,e,n,a,h,l))}}else wt(s,e,i,a,h,l)}}function wt(t,e,i,n,r,o){if(t.onBeforeRender(m,e,i,n,r,o),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){const n=St(i,e,r,t);G.setMaterial(r),at.reset(),function(t,e){t.render((function(t){m.renderBufferImmediate(t,e)}))}(t,n)}else m.renderBufferDirect(i,e,n,r,t,o);t.onAfterRender(m,e,i,n,r,o)}function bt(t,e,i){!0!==e.isScene&&(e=B);const n=V.get(t),r=d.state.lights,o=d.state.shadowsArray,s=r.state.version,a=J.getParameters(t,r.state,o,e,i),h=J.getProgramCacheKey(a);let l=n.programs;n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=Z.get(t.envMap||n.environment),void 0===l&&(t.addEventListener("dispose",ft),l=new Map,n.programs=l);let c=l.get(h);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===s)return Mt(t,a),c}else a.uniforms=J.getUniforms(t),t.onBeforeCompile(a,m),c=J.acquireProgram(a,h),l.set(h,c),n.uniforms=a.uniforms;const u=n.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(u.clippingPlanes=tt.uniform),Mt(t,a),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=s,n.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotShadowMatrix.value=r.state.spotShadowMatrix,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=c.getUniforms(),f=Wv.seqWithValue(p.seq,u);return n.currentProgram=c,n.uniformsList=f,c}function Mt(t,e){const i=V.get(t);i.outputEncoding=e.outputEncoding,i.instancing=e.instancing,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas}function St(t,e,i,n){!0!==e.isScene&&(e=B),W.resetTextureUnits();const r=e.fog,o=i.isMeshStandardMaterial?e.environment:null,s=null===_?m.outputEncoding:_.texture.encoding,a=Z.get(i.envMap||o),h=!0===i.vertexColors&&n.geometry.attributes.color&&4===n.geometry.attributes.color.itemSize,l=V.get(i),c=d.state.lights;if(!0===I&&(!0===k||t!==w)){const e=t===w&&i.id===x;tt.setState(i,t,e)}let u=!1;i.version===l.__version?l.needsLights&&l.lightsStateVersion!==c.state.version||l.outputEncoding!==s||n.isInstancedMesh&&!1===l.instancing?u=!0:n.isInstancedMesh||!0!==l.instancing?l.envMap!==a||i.fog&&l.fog!==r?u=!0:void 0===l.numClippingPlanes||l.numClippingPlanes===tt.numPlanes&&l.numIntersection===tt.numIntersection?l.vertexAlphas!==h&&(u=!0):u=!0:u=!0:(u=!0,l.__version=i.version);let p=l.currentProgram;!0===u&&(p=bt(i,e,n));let f=!1,g=!1,v=!1;const y=p.getUniforms(),b=l.uniforms;if(G.useProgram(p.program)&&(f=!0,g=!0,v=!0),i.id!==x&&(x=i.id,g=!0),f||w!==t){if(y.setValue(ht,"projectionMatrix",t.projectionMatrix),j.logarithmicDepthBuffer&&y.setValue(ht,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),w!==t&&(w=t,g=!0,v=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const e=y.map.cameraPosition;void 0!==e&&e.setValue(ht,F.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&y.setValue(ht,"isOrthographic",!0===t.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||i.skinning)&&y.setValue(ht,"viewMatrix",t.matrixWorldInverse)}if(i.skinning){y.setOptional(ht,n,"bindMatrix"),y.setOptional(ht,n,"bindMatrixInverse");const t=n.skeleton;if(t){const e=t.bones;if(j.floatVertexTextures){if(null===t.boneTexture){let i=Math.sqrt(4*e.length);i=Ap.ceilPowerOfTwo(i),i=Math.max(i,4);const n=new Float32Array(i*i*4);n.set(t.boneMatrices);const r=new yg(n,i,i,rd,Ju);t.boneMatrices=n,t.boneTexture=r,t.boneTextureSize=i}y.setValue(ht,"boneTexture",t.boneTexture,W),y.setValue(ht,"boneTextureSize",t.boneTextureSize)}else y.setOptional(ht,t,"boneMatrices")}}var M,S;return(g||l.receiveShadow!==n.receiveShadow)&&(l.receiveShadow=n.receiveShadow,y.setValue(ht,"receiveShadow",n.receiveShadow)),g&&(y.setValue(ht,"toneMappingExposure",m.toneMappingExposure),l.needsLights&&(S=v,(M=b).ambientLightColor.needsUpdate=S,M.lightProbe.needsUpdate=S,M.directionalLights.needsUpdate=S,M.directionalLightShadows.needsUpdate=S,M.pointLights.needsUpdate=S,M.pointLightShadows.needsUpdate=S,M.spotLights.needsUpdate=S,M.spotLightShadows.needsUpdate=S,M.rectAreaLights.needsUpdate=S,M.hemisphereLights.needsUpdate=S),r&&i.fog&&Q.refreshFogUniforms(b,r),Q.refreshMaterialUniforms(b,i,C,E),Wv.upload(ht,l.uniformsList,b,W)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Wv.upload(ht,l.uniformsList,b,W),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&y.setValue(ht,"center",n.center),y.setValue(ht,"modelViewMatrix",n.modelViewMatrix),y.setValue(ht,"normalMatrix",n.normalMatrix),y.setValue(ht,"modelMatrix",n.matrixWorld),p}yt.setAnimationLoop((function(t){mt&&mt(t)})),"undefined"!=typeof window&&yt.setContext(window),this.setAnimationLoop=function(t){mt=t,ut.setAnimationLoop(t),null===t?yt.stop():yt.start()},ut.addEventListener("sessionstart",gt),ut.addEventListener("sessionend",vt),this.render=function(t,e){let i,n;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),i=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),n=arguments[3]),void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===g)return;!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),!0===ut.enabled&&!0===ut.isPresenting&&(e=ut.getCamera(e)),!0===t.isScene&&t.onBeforeRender(m,t,e,i||_),d=$.get(t,f.length),d.init(),f.push(d),z.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),D.setFromProjectionMatrix(z),k=this.localClippingEnabled,I=tt.init(this.clippingPlanes,k,e),u=K.get(t,p.length),u.init(),p.push(u),_t(t,e,0,m.sortObjects),u.finish(),!0===m.sortObjects&&u.sort(P,A),!0===I&&tt.beginShadows();const r=d.state.shadowsArray;et.render(r,t,e),d.setupLights(),d.setupLightsView(e),!0===I&&tt.endShadows(),!0===this.info.autoReset&&this.info.reset(),void 0!==i&&this.setRenderTarget(i),it.render(u,t,e,n);const o=u.opaque,s=u.transparent;o.length>0&&xt(o,t,e),s.length>0&&xt(s,t,e),null!==_&&(W.updateRenderTargetMipmap(_),W.updateMultisampleRenderTarget(_)),!0===t.isScene&&t.onAfterRender(m,t,e),G.buffers.depth.setTest(!0),G.buffers.depth.setMask(!0),G.buffers.color.setMask(!0),G.setPolygonOffset(!1),at.resetDefaultState(),x=-1,w=null,f.pop(),d=f.length>0?f[f.length-1]:null,p.pop(),u=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return _},this.setRenderTarget=function(t,e=0,i=0){_=t,v=e,y=i,t&&void 0===V.get(t).__webglFramebuffer&&W.setupRenderTarget(t);let n=null,r=!1,o=!1;if(t){const i=t.texture;(i.isDataTexture3D||i.isDataTexture2DArray)&&(o=!0);const s=V.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(n=s[e],r=!0):n=t.isWebGLMultisampleRenderTarget?V.get(t).__webglMultisampledFramebuffer:s,b.copy(t.viewport),M.copy(t.scissor),S=t.scissorTest}else b.copy(L).multiplyScalar(C).floor(),M.copy(R).multiplyScalar(C).floor(),S=O;if(G.bindFramebuffer(36160,n),G.viewport(b),G.scissor(M),G.setScissorTest(S),r){const n=V.get(t.texture);ht.framebufferTexture2D(36160,36064,34069+e,n.__webglTexture,i)}else if(o){const n=V.get(t.texture),r=e||0;ht.framebufferTextureLayer(36160,36064,n.__webglTexture,i||0,r)}},this.readRenderTargetPixels=function(t,e,i,n,r,o,s){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=V.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==s&&(a=a[s]),a){G.bindFramebuffer(36160,a);try{const s=t.texture,a=s.format,h=s.type;if(a!==rd&&st.convert(a)!==ht.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const l=h===Qu&&(H.has("EXT_color_buffer_half_float")||j.isWebGL2&&H.has("EXT_color_buffer_float"));if(!(h===Vu||st.convert(h)===ht.getParameter(35738)||h===Ju&&(j.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float"))||l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ht.checkFramebufferStatus(36160)?e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&ht.readPixels(e,i,n,r,st.convert(a),st.convert(h),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==_?V.get(_).__webglFramebuffer:null;G.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),r=Math.floor(e.image.width*n),o=Math.floor(e.image.height*n),s=st.convert(e.format);W.setTexture2D(e,0),ht.copyTexImage2D(3553,i,s,t.x,t.y,r,o,0),G.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const r=e.image.width,o=e.image.height,s=st.convert(i.format),a=st.convert(i.type);W.setTexture2D(i,0),ht.pixelStorei(37440,i.flipY),ht.pixelStorei(37441,i.premultiplyAlpha),ht.pixelStorei(3317,i.unpackAlignment),e.isDataTexture?ht.texSubImage2D(3553,n,t.x,t.y,r,o,s,a,e.image.data):e.isCompressedTexture?ht.compressedTexSubImage2D(3553,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,s,e.mipmaps[0].data):ht.texSubImage2D(3553,n,t.x,t.y,s,a,e.image),0===n&&i.generateMipmaps&&ht.generateMipmap(3553),G.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i,n,r=0){if(m.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const{width:o,height:s,data:a}=i.image,h=st.convert(n.format),l=st.convert(n.type);let c;if(n.isDataTexture3D)W.setTexture3D(n,0),c=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");W.setTexture2DArray(n,0),c=35866}ht.pixelStorei(37440,n.flipY),ht.pixelStorei(37441,n.premultiplyAlpha),ht.pixelStorei(3317,n.unpackAlignment);const u=ht.getParameter(3314),d=ht.getParameter(32878),p=ht.getParameter(3316),f=ht.getParameter(3315),g=ht.getParameter(32877);ht.pixelStorei(3314,o),ht.pixelStorei(32878,s),ht.pixelStorei(3316,t.min.x),ht.pixelStorei(3315,t.min.y),ht.pixelStorei(32877,t.min.z),ht.texSubImage3D(c,r,e.x,e.y,e.z,t.max.x-t.min.x+1,t.max.y-t.min.y+1,t.max.z-t.min.z+1,h,l,a),ht.pixelStorei(3314,u),ht.pixelStorei(32878,d),ht.pixelStorei(3316,p),ht.pixelStorei(3315,f),ht.pixelStorei(32877,g),0===r&&n.generateMipmaps&&ht.generateMipmap(c),G.unbindTexture()},this.initTexture=function(t){W.setTexture2D(t,0),G.unbindTexture()},this.resetState=function(){v=0,y=0,_=null,G.reset(),at.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Dy.prototype.isGroup=!0,Object.assign(Iy.prototype,{constructor:Iy,getHandSpace:function(){return null===this._hand&&(this._hand=new Dy,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new Dy,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new Dy,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this},disconnect:function(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this},update:function(t,e,i){let n=null,r=null,o=null;const s=this._targetRay,a=this._grip,h=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState)if(null!==s&&(n=e.getPose(t.targetRaySpace,i),null!==n&&(s.matrix.fromArray(n.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale))),h&&t.hand){o=!0;for(const n of t.hand.values()){const t=e.getJointPose(n,i);if(void 0===h.joints[n.jointName]){const t=new Dy;t.matrixAutoUpdate=!1,t.visible=!1,h.joints[n.jointName]=t,h.add(t)}const r=h.joints[n.jointName];null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=t.radius),r.visible=null!==t}const n=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],s=n.position.distanceTo(r.position),a=.02,l=.005;h.inputState.pinching&&s>a+l?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!h.inputState.pinching&&s<=a-l&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==a&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale)));return null!==s&&(s.visible=null!==n),null!==a&&(a.visible=null!==r),null!==h&&(h.visible=null!==o),this}}),Object.assign(ky.prototype,Ep.prototype);class By extends Fy{}By.prototype.isWebGL1Renderer=!0;class Ny{constructor(t,e=25e-5){this.name="",this.color=new fm(t),this.density=e}clone(){return new Ny(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Ny.prototype.isFogExp2=!0;class Hy{constructor(t,e=1,i=1e3){this.name="",this.color=new fm(t),this.near=e,this.far=i}clone(){return new Hy(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Hy.prototype.isFog=!0;class jy extends Vf{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.environment&&(e.object.environment=this.environment.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}function Gy(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Mp,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ap.generateUUID()}jy.prototype.isScene=!0,Object.defineProperty(Gy.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Gy.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;n<r;n++)this.array[t+n]=e.array[i+n];return this},set:function(t,e=0){return this.array.set(t,e),this},clone:function(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Ap.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new Gy(new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),this.stride);return e.setUsage(this.usage),e},onUpload:function(t){return this.onUploadCallback=t,this},toJSON:function(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Ap.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});const Uy=new jp;function Vy(t,e,i,n){this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=!0===n}Object.defineProperties(Vy.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(t){this.data.needsUpdate=t}}}),Object.assign(Vy.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(let e=0,i=this.data.count;e<i;e++)Uy.x=this.getX(e),Uy.y=this.getY(e),Uy.z=this.getZ(e),Uy.applyMatrix4(t),this.setXYZ(e,Uy.x,Uy.y,Uy.z);return this},applyNormalMatrix:function(t){for(let e=0,i=this.count;e<i;e++)Uy.x=this.getX(e),Uy.y=this.getY(e),Uy.z=this.getZ(e),Uy.applyNormalMatrix(t),this.setXYZ(e,Uy.x,Uy.y,Uy.z);return this},transformDirection:function(t){for(let e=0,i=this.count;e<i;e++)Uy.x=this.getX(e),Uy.y=this.getY(e),Uy.z=this.getZ(e),Uy.transformDirection(t),this.setXYZ(e,Uy.x,Uy.y,Uy.z);return this},setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this},setXYZ:function(t,e,i,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this},setXYZW:function(t,e,i,n,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=r,this},clone:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new ym(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Vy(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}});class Wy extends am{constructor(t){super(),this.type="SpriteMaterial",this.color=new fm(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this}}let Zy;Wy.prototype.isSpriteMaterial=!0;const qy=new jp,Xy=new jp,Yy=new jp,Jy=new Lp,Qy=new Lp,Ky=new _f,$y=new jp,t_=new jp,e_=new jp,i_=new Lp,n_=new Lp,r_=new Lp;class o_ extends Vf{constructor(t){if(super(),this.type="Sprite",void 0===Zy){Zy=new Nm;const t=new Gy(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Zy.setIndex([0,1,2,0,2,3]),Zy.setAttribute("position",new Vy(t,3,0,!1)),Zy.setAttribute("uv",new Vy(t,2,3,!1))}this.geometry=Zy,this.material=void 0!==t?t:new Wy,this.center=new Lp(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Xy.setFromMatrixScale(this.matrixWorld),Ky.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Yy.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Xy.multiplyScalar(-Yy.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const o=this.center;s_($y.set(-.5,-.5,0),Yy,o,Xy,n,r),s_(t_.set(.5,-.5,0),Yy,o,Xy,n,r),s_(e_.set(.5,.5,0),Yy,o,Xy,n,r),i_.set(0,0),n_.set(1,0),r_.set(1,1);let s=t.ray.intersectTriangle($y,t_,e_,!1,qy);if(null===s&&(s_(t_.set(-.5,.5,0),Yy,o,Xy,n,r),n_.set(0,1),s=t.ray.intersectTriangle($y,e_,t_,!1,qy),null===s))return;const a=t.ray.origin.distanceTo(qy);a<t.near||a>t.far||e.push({distance:a,point:qy.clone(),uv:om.getUV(qy,$y,t_,e_,i_,n_,r_,new Lp),face:null,object:this})}copy(t){return super.copy(t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function s_(t,e,i,n,r,o){Jy.subVectors(t,i).addScalar(.5).multiply(n),void 0!==r?(Qy.x=o*Jy.x-r*Jy.y,Qy.y=r*Jy.x+o*Jy.y):Qy.copy(Jy),t.copy(e),t.x+=Qy.x,t.y+=Qy.y,t.applyMatrix4(Ky)}o_.prototype.isSprite=!0;const a_=new jp,h_=new jp;class l_ extends Vf{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,i=e.length;t<i;t++){const i=e[t];this.addLevel(i.object.clone(),i.distance)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0){e=Math.abs(e);const i=this.levels;let n;for(n=0;n<i.length&&!(e<i[n].distance);n++);return i.splice(n,0,{distance:e,object:t}),this.add(t),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let i,n;for(i=1,n=e.length;i<n&&!(t<e[i].distance);i++);return e[i-1].object}return null}raycast(t,e){if(this.levels.length>0){a_.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(a_);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){a_.setFromMatrixPosition(t.matrixWorld),h_.setFromMatrixPosition(this.matrixWorld);const i=a_.distanceTo(h_)/t.zoom;let n,r;for(e[0].object.visible=!0,n=1,r=e.length;n<r&&i>=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(this._currentLevel=n-1;n<r;n++)e[n].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const i=this.levels;for(let t=0,n=i.length;t<n;t++){const n=i[t];e.object.levels.push({object:n.object.uuid,distance:n.distance})}return e}}const c_=new jp,u_=new Fp,d_=new Fp,p_=new jp,f_=new _f;function m_(t,e){ng.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new _f,this.bindMatrixInverse=new _f}function g_(){Vf.call(this),this.type="Bone"}m_.prototype=Object.assign(Object.create(ng.prototype),{constructor:m_,isSkinnedMesh:!0,copy:function(t){return ng.prototype.copy.call(this,t),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,this},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){const t=new Fp,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.x=e.getX(i),t.y=e.getY(i),t.z=e.getZ(i),t.w=e.getW(i);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(t){ng.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(t,e){const i=this.skeleton,n=this.geometry;u_.fromBufferAttribute(n.attributes.skinIndex,t),d_.fromBufferAttribute(n.attributes.skinWeight,t),c_.fromBufferAttribute(n.attributes.position,t).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const n=d_.getComponent(t);if(0!==n){const r=u_.getComponent(t);f_.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),e.addScaledVector(p_.copy(c_).applyMatrix4(f_),n)}}return e.applyMatrix4(this.bindMatrixInverse)}}),g_.prototype=Object.assign(Object.create(Vf.prototype),{constructor:g_,isBone:!0});const v_=new _f,y_=new _f;class __{constructor(t=[],e=[]){this.uuid=Ap.generateUUID(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new _f)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new _f;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let n=0,r=t.length;n<r;n++){const r=t[n]?t[n].matrixWorld:y_;v_.multiplyMatrices(r,e[n]),v_.toArray(i,16*n)}null!==n&&(n.needsUpdate=!0)}clone(){return new __(this.bones,this.boneInverses)}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const n=t.bones[i];let r=e[n];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new g_),this.bones.push(r),this.boneInverses.push((new _f).fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,r=e.length;n<r;n++){const r=e[n];t.bones.push(r.uuid);const o=i[n];t.boneInverses.push(o.toArray())}return t}}const x_=new _f,w_=new _f,b_=[],M_=new ng;function S_(t,e,i){ng.call(this,t,e),this.instanceMatrix=new ym(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}S_.prototype=Object.assign(Object.create(ng.prototype),{constructor:S_,isInstancedMesh:!0,copy:function(t){return ng.prototype.copy.call(this,t),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,this},getColorAt:function(t,e){e.fromArray(this.instanceColor.array,3*t)},getMatrixAt:function(t,e){e.fromArray(this.instanceMatrix.array,16*t)},raycast:function(t,e){const i=this.matrixWorld,n=this.count;if(M_.geometry=this.geometry,M_.material=this.material,void 0!==M_.material)for(let r=0;r<n;r++){this.getMatrixAt(r,x_),w_.multiplyMatrices(i,x_),M_.matrixWorld=w_,M_.raycast(t,b_);for(let t=0,i=b_.length;t<i;t++){const i=b_[t];i.instanceId=r,i.object=this,e.push(i)}b_.length=0}},setColorAt:function(t,e){null===this.instanceColor&&(this.instanceColor=new ym(new Float32Array(3*this.count),3)),e.toArray(this.instanceColor.array,3*t)},setMatrixAt:function(t,e){e.toArray(this.instanceMatrix.array,16*t)},updateMorphTargets:function(){},dispose:function(){this.dispatchEvent({type:"dispose"})}});class T_ extends am{constructor(t){super(),this.type="LineBasicMaterial",this.color=new fm(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.morphTargets=t.morphTargets,this}}T_.prototype.isLineBasicMaterial=!0;const E_=new jp,C_=new jp,P_=new _f,A_=new yf,L_=new cf;function R_(t=new Nm,e=new T_){Vf.call(this),this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}R_.prototype=Object.assign(Object.create(Vf.prototype),{constructor:R_,isLine:!0,copy:function(t){return Vf.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},computeLineDistances:function(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,i=[0];for(let t=1,n=e.count;t<n;t++)E_.fromBufferAttribute(e,t-1),C_.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=E_.distanceTo(C_);t.setAttribute("lineDistance",new Cm(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this},raycast:function(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Line.threshold,o=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),L_.copy(i.boundingSphere),L_.applyMatrix4(n),L_.radius+=r,!1===t.ray.intersectsSphere(L_))return;P_.copy(n).invert(),A_.copy(t.ray).applyMatrix4(P_);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s,h=new jp,l=new jp,c=new jp,u=new jp,d=this.isLineSegments?2:1;if(i.isBufferGeometry){const n=i.index,r=i.attributes.position;if(null!==n){for(let i=Math.max(0,o.start),s=Math.min(n.count,o.start+o.count)-1;i<s;i+=d){const o=n.getX(i),s=n.getX(i+1);h.fromBufferAttribute(r,o),l.fromBufferAttribute(r,s);if(A_.distanceSqToSegment(h,l,u,c)>a)continue;u.applyMatrix4(this.matrixWorld);const d=t.ray.origin.distanceTo(u);d<t.near||d>t.far||e.push({distance:d,point:c.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{for(let i=Math.max(0,o.start),n=Math.min(r.count,o.start+o.count)-1;i<n;i+=d){h.fromBufferAttribute(r,i),l.fromBufferAttribute(r,i+1);if(A_.distanceSqToSegment(h,l,u,c)>a)continue;u.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(u);n<t.near||n>t.far||e.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const O_=new jp,D_=new jp;function I_(t,e){R_.call(this,t,e),this.type="LineSegments"}I_.prototype=Object.assign(Object.create(R_.prototype),{constructor:I_,isLineSegments:!0,computeLineDistances:function(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,n=e.count;t<n;t+=2)O_.fromBufferAttribute(e,t),D_.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+O_.distanceTo(D_);t.setAttribute("lineDistance",new Cm(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}});class k_ extends R_{constructor(t,e){super(t,e),this.type="LineLoop"}}k_.prototype.isLineLoop=!0;class z_ extends am{constructor(t){super(),this.type="PointsMaterial",this.color=new fm(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this}}z_.prototype.isPointsMaterial=!0;const F_=new _f,B_=new yf,N_=new cf,H_=new jp;function j_(t=new Nm,e=new z_){Vf.call(this),this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}function G_(t,e,i,n,r,o,s){const a=B_.distanceSqToPoint(t);if(a<i){const i=new jp;B_.closestPointToPoint(t,i),i.applyMatrix4(n);const h=r.ray.origin.distanceTo(i);if(h<r.near||h>r.far)return;o.push({distance:h,distanceToRay:Math.sqrt(a),point:i,index:e,face:null,object:s})}}j_.prototype=Object.assign(Object.create(Vf.prototype),{constructor:j_,isPoints:!0,copy:function(t){return Vf.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},raycast:function(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Points.threshold,o=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),N_.copy(i.boundingSphere),N_.applyMatrix4(n),N_.radius+=r,!1===t.ray.intersectsSphere(N_))return;F_.copy(n).invert(),B_.copy(t.ray).applyMatrix4(F_);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=s*s;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position;if(null!==r){for(let i=Math.max(0,o.start),h=Math.min(r.count,o.start+o.count);i<h;i++){const o=r.getX(i);H_.fromBufferAttribute(s,o),G_(H_,o,a,n,t,e,this)}}else{for(let i=Math.max(0,o.start),r=Math.min(s.count,o.start+o.count);i<r;i++)H_.fromBufferAttribute(s,i),G_(H_,i,a,n,t,e,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});class U_ extends kp{constructor(t,e,i,n,r,o,s,a,h){super(t,e,i,n,r,o,s,a,h),this.format=void 0!==s?s:nd,this.minFilter=void 0!==o?o:ju,this.magFilter=void 0!==r?r:ju,this.generateMipmaps=!1;const l=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){l.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}U_.prototype.isVideoTexture=!0;class V_ extends kp{constructor(t,e,i,n,r,o,s,a,h,l,c,u){super(null,o,s,a,h,l,n,r,c,u),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}V_.prototype.isCompressedTexture=!0;class W_ extends kp{constructor(t,e,i,n,r,o,s,a,h){super(t,e,i,n,r,o,s,a,h),this.needsUpdate=!0}}W_.prototype.isCanvasTexture=!0;class Z_ extends kp{constructor(t,e,i,n,r,o,s,a,h,l){if((l=void 0!==l?l:hd)!==hd&&l!==ld)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&l===hd&&(i=qu),void 0===i&&l===ld&&(i=ed),super(null,n,r,o,s,a,l,i,h),this.image={width:t,height:e},this.magFilter=void 0!==s?s:Bu,this.minFilter=void 0!==a?a:Bu,this.flipY=!1,this.generateMipmaps=!1}}Z_.prototype.isDepthTexture=!0;class q_ extends Nm{constructor(t=1,e=8,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const r=[],o=[],s=[],a=[],h=new jp,l=new Lp;o.push(0,0,0),s.push(0,0,1),a.push(.5,.5);for(let r=0,c=3;r<=e;r++,c+=3){const u=i+r/e*n;h.x=t*Math.cos(u),h.y=t*Math.sin(u),o.push(h.x,h.y,h.z),s.push(0,0,1),l.x=(o[c]/t+1)/2,l.y=(o[c+1]/t+1)/2,a.push(l.x,l.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new Cm(o,3)),this.setAttribute("normal",new Cm(s,3)),this.setAttribute("uv",new Cm(a,2))}}class X_ extends Nm{constructor(t=1,e=1,i=1,n=8,r=1,o=!1,s=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:s,thetaLength:a};const h=this;n=Math.floor(n),r=Math.floor(r);const l=[],c=[],u=[],d=[];let p=0;const f=[],m=i/2;let g=0;function v(i){const r=p,o=new Lp,f=new jp;let v=0;const y=!0===i?t:e,_=!0===i?1:-1;for(let t=1;t<=n;t++)c.push(0,m*_,0),u.push(0,_,0),d.push(.5,.5),p++;const x=p;for(let t=0;t<=n;t++){const e=t/n*a+s,i=Math.cos(e),r=Math.sin(e);f.x=y*r,f.y=m*_,f.z=y*i,c.push(f.x,f.y,f.z),u.push(0,_,0),o.x=.5*i+.5,o.y=.5*r*_+.5,d.push(o.x,o.y),p++}for(let t=0;t<n;t++){const e=r+t,n=x+t;!0===i?l.push(n,n+1,e):l.push(n+1,n,e),v+=3}h.addGroup(g,v,!0===i?1:2),g+=v}!function(){const o=new jp,v=new jp;let y=0;const _=(e-t)/i;for(let h=0;h<=r;h++){const l=[],g=h/r,y=g*(e-t)+t;for(let t=0;t<=n;t++){const e=t/n,r=e*a+s,h=Math.sin(r),f=Math.cos(r);v.x=y*h,v.y=-g*i+m,v.z=y*f,c.push(v.x,v.y,v.z),o.set(h,_,f).normalize(),u.push(o.x,o.y,o.z),d.push(e,1-g),l.push(p++)}f.push(l)}for(let t=0;t<n;t++)for(let e=0;e<r;e++){const i=f[e][t],n=f[e+1][t],r=f[e+1][t+1],o=f[e][t+1];l.push(i,n,o),l.push(n,r,o),y+=6}h.addGroup(g,y,0),g+=y}(),!1===o&&(t>0&&v(!0),e>0&&v(!1)),this.setIndex(l),this.setAttribute("position",new Cm(c,3)),this.setAttribute("normal",new Cm(u,3)),this.setAttribute("uv",new Cm(d,2))}}class Y_ extends X_{constructor(t=1,e=1,i=8,n=1,r=!1,o=0,s=2*Math.PI){super(0,t,e,i,n,r,o,s),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:o,thetaLength:s}}}class J_ extends Nm{constructor(t,e,i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n};const r=[],o=[];function s(t,e,i,n){const r=n+1,o=[];for(let n=0;n<=r;n++){o[n]=[];const s=t.clone().lerp(i,n/r),a=e.clone().lerp(i,n/r),h=r-n;for(let t=0;t<=h;t++)o[n][t]=0===t&&n===r?s:s.clone().lerp(a,t/h)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const i=Math.floor(e/2);e%2==0?(a(o[t][i+1]),a(o[t+1][i]),a(o[t][i])):(a(o[t][i+1]),a(o[t+1][i+1]),a(o[t+1][i]))}}function a(t){r.push(t.x,t.y,t.z)}function h(e,i){const n=3*e;i.x=t[n+0],i.y=t[n+1],i.z=t[n+2]}function l(t,e,i,n){n<0&&1===t.x&&(o[e]=t.x-1),0===i.x&&0===i.z&&(o[e]=n/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}function u(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}!function(t){const i=new jp,n=new jp,r=new jp;for(let o=0;o<e.length;o+=3)h(e[o+0],i),h(e[o+1],n),h(e[o+2],r),s(i,n,r,t)}(n),function(t){const e=new jp;for(let i=0;i<r.length;i+=3)e.x=r[i+0],e.y=r[i+1],e.z=r[i+2],e.normalize().multiplyScalar(t),r[i+0]=e.x,r[i+1]=e.y,r[i+2]=e.z}(i),function(){const t=new jp;for(let e=0;e<r.length;e+=3){t.x=r[e+0],t.y=r[e+1],t.z=r[e+2];const i=c(t)/2/Math.PI+.5,n=u(t)/Math.PI+.5;o.push(i,1-n)}(function(){const t=new jp,e=new jp,i=new jp,n=new jp,s=new Lp,a=new Lp,h=new Lp;for(let u=0,d=0;u<r.length;u+=9,d+=6){t.set(r[u+0],r[u+1],r[u+2]),e.set(r[u+3],r[u+4],r[u+5]),i.set(r[u+6],r[u+7],r[u+8]),s.set(o[d+0],o[d+1]),a.set(o[d+2],o[d+3]),h.set(o[d+4],o[d+5]),n.copy(t).add(e).add(i).divideScalar(3);const p=c(n);l(s,d+0,t,p),l(a,d+2,e,p),l(h,d+4,i,p)}})(),function(){for(let t=0;t<o.length;t+=6){const e=o[t+0],i=o[t+2],n=o[t+4],r=Math.max(e,i,n),s=Math.min(e,i,n);r>.9&&s<.1&&(e<.2&&(o[t+0]+=1),i<.2&&(o[t+2]+=1),n<.2&&(o[t+4]+=1))}}()}(),this.setAttribute("position",new Cm(r,3)),this.setAttribute("normal",new Cm(r.slice(),3)),this.setAttribute("uv",new Cm(o,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}}class Q_ extends J_{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,n=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}}const K_=new jp,$_=new jp,tx=new jp,ex=new om;class ix extends Nm{constructor(t,e){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1,!0===t.isGeometry)return void console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const i=Math.pow(10,4),n=Math.cos(Ap.DEG2RAD*e),r=t.getIndex(),o=t.getAttribute("position"),s=r?r.count:o.count,a=[0,0,0],h=["a","b","c"],l=new Array(3),c={},u=[];for(let t=0;t<s;t+=3){r?(a[0]=r.getX(t),a[1]=r.getX(t+1),a[2]=r.getX(t+2)):(a[0]=t,a[1]=t+1,a[2]=t+2);const{a:e,b:s,c:d}=ex;if(e.fromBufferAttribute(o,a[0]),s.fromBufferAttribute(o,a[1]),d.fromBufferAttribute(o,a[2]),ex.getNormal(tx),l[0]=`${Math.round(e.x*i)},${Math.round(e.y*i)},${Math.round(e.z*i)}`,l[1]=`${Math.round(s.x*i)},${Math.round(s.y*i)},${Math.round(s.z*i)}`,l[2]=`${Math.round(d.x*i)},${Math.round(d.y*i)},${Math.round(d.z*i)}`,l[0]!==l[1]&&l[1]!==l[2]&&l[2]!==l[0])for(let t=0;t<3;t++){const e=(t+1)%3,i=l[t],r=l[e],o=ex[h[t]],s=ex[h[e]],d=`${i}_${r}`,p=`${r}_${i}`;p in c&&c[p]?(tx.dot(c[p].normal)<=n&&(u.push(o.x,o.y,o.z),u.push(s.x,s.y,s.z)),c[p]=null):d in c||(c[d]={index0:a[t],index1:a[e],normal:tx.clone()})}}for(const t in c)if(c[t]){const{index0:e,index1:i}=c[t];K_.fromBufferAttribute(o,e),$_.fromBufferAttribute(o,i),u.push(K_.x,K_.y,K_.z),u.push($_.x,$_.y,$_.z)}this.setAttribute("position",new Cm(u,3))}}const nx=function(t,e,i){i=i||2;const n=e&&e.length,r=n?e[0]*i:t.length;let o=rx(t,0,r,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,h,l,c,u,d,p;if(n&&(o=function(t,e,i,n){const r=[];let o,s,a,h,l;for(o=0,s=e.length;o<s;o++)a=e[o]*n,h=o<s-1?e[o+1]*n:t.length,l=rx(t,a,h,n,!1),l===l.next&&(l.steiner=!0),r.push(mx(l));for(r.sort(ux),o=0;o<r.length;o++)dx(r[o],i),i=ox(i,i.next);return i}(t,e,o,i)),t.length>80*i){a=l=t[0],h=c=t[1];for(let e=i;e<r;e+=i)u=t[e],d=t[e+1],u<a&&(a=u),d<h&&(h=d),u>l&&(l=u),d>c&&(c=d);p=Math.max(l-a,c-h),p=0!==p?1/p:0}return sx(o,s,i,a,h,p),s};function rx(t,e,i,n,r){let o,s;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o<i;o+=n)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}(t,e,i,n)>0)for(o=e;o<i;o+=n)s=Tx(o,t[o],t[o+1],s);else for(o=i-n;o>=e;o-=n)s=Tx(o,t[o],t[o+1],s);return s&&_x(s,s.next)&&(Ex(s),s=s.next),s}function ox(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!_x(n,n.next)&&0!==yx(n.prev,n,n.next))n=n.next;else{if(Ex(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function sx(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{null===r.z&&(r.z=fx(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i,n,r,o,s,a,h,l=1;do{for(i=t,t=null,o=null,s=0;i;){for(s++,n=i,a=0,e=0;e<l&&(a++,n=n.nextZ,n);e++);for(h=l;a>0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;i=n}o.nextZ=null,l*=2}while(s>1)}(r)}(t,n,r,o);let a,h,l=t;for(;t.prev!==t.next;)if(a=t.prev,h=t.next,o?hx(t,n,r,o):ax(t))e.push(a.i/i),e.push(t.i/i),e.push(h.i/i),Ex(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?sx(t=lx(ox(t),e,i),e,i,n,r,o,2):2===s&&cx(t,e,i,n,r,o):sx(ox(t),e,i,n,r,o,1);break}}function ax(t){const e=t.prev,i=t,n=t.next;if(yx(e,i,n)>=0)return!1;let r=t.next.next;for(;r!==t.prev;){if(gx(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&yx(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function hx(t,e,i,n){const r=t.prev,o=t,s=t.next;if(yx(r,o,s)>=0)return!1;const a=r.x<o.x?r.x<s.x?r.x:s.x:o.x<s.x?o.x:s.x,h=r.y<o.y?r.y<s.y?r.y:s.y:o.y<s.y?o.y:s.y,l=r.x>o.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,c=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,u=fx(a,h,e,i,n),d=fx(l,c,e,i,n);let p=t.prevZ,f=t.nextZ;for(;p&&p.z>=u&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&gx(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&yx(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&gx(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&yx(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&gx(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&yx(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&gx(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&yx(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function lx(t,e,i){let n=t;do{const r=n.prev,o=n.next.next;!_x(r,o)&&xx(r,n,n.next,o)&&Mx(r,o)&&Mx(o,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(o.i/i),Ex(n),Ex(n.next),n=t=o),n=n.next}while(n!==t);return ox(n)}function cx(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&vx(s,t)){let a=Sx(s,t);return s=ox(s,s.next),a=ox(a,a.next),sx(s,e,i,n,r,o),void sx(a,e,i,n,r,o)}t=t.next}s=s.next}while(s!==t)}function ux(t,e){return t.x-e.x}function dx(t,e){if(e=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>s){if(s=t,t===n){if(r===i.y)return i;if(r===i.next.y)return i.next}o=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!o)return null;if(n===s)return o;const a=o,h=o.x,l=o.y;let c,u=1/0;i=o;do{n>=i.x&&i.x>=h&&n!==i.x&&gx(r<l?n:s,r,h,l,r<l?s:n,r,i.x,i.y)&&(c=Math.abs(r-i.y)/(n-i.x),Mx(i,t)&&(c<u||c===u&&(i.x>o.x||i.x===o.x&&px(o,i)))&&(o=i,u=c)),i=i.next}while(i!==a);return o}(t,e),e){const i=Sx(e,t);ox(e,e.next),ox(i,i.next)}}function px(t,e){return yx(t.prev,t,e.prev)<0&&yx(e.next,t,t.next)<0}function fx(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function mx(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function gx(t,e,i,n,r,o,s,a){return(r-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(n-a)-(i-s)*(e-a)>=0&&(i-s)*(o-a)-(r-s)*(n-a)>=0}function vx(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&xx(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Mx(t,e)&&Mx(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(yx(t.prev,t,e.prev)||yx(t,e.prev,e))||_x(t,e)&&yx(t.prev,t,t.next)>0&&yx(e.prev,e,e.next)>0)}function yx(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function _x(t,e){return t.x===e.x&&t.y===e.y}function xx(t,e,i,n){const r=bx(yx(t,e,i)),o=bx(yx(t,e,n)),s=bx(yx(i,n,t)),a=bx(yx(i,n,e));return r!==o&&s!==a||(!(0!==r||!wx(t,i,e))||(!(0!==o||!wx(t,n,e))||(!(0!==s||!wx(i,t,n))||!(0!==a||!wx(i,e,n)))))}function wx(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function bx(t){return t>0?1:t<0?-1:0}function Mx(t,e){return yx(t.prev,t,t.next)<0?yx(t,e,t.next)>=0&&yx(t,t.prev,e)>=0:yx(t,e,t.prev)<0||yx(t,t.next,e)<0}function Sx(t,e){const i=new Cx(t.i,t.x,t.y),n=new Cx(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Tx(t,e,i,n){const r=new Cx(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Ex(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Cx(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}const Px={area:function(t){const e=t.length;let i=0;for(let n=e-1,r=0;r<e;n=r++)i+=t[n].x*t[r].y-t[r].x*t[n].y;return.5*i},isClockWise:function(t){return Px.area(t)<0},triangulateShape:function(t,e){const i=[],n=[],r=[];Ax(t),Lx(i,t);let o=t.length;e.forEach(Ax);for(let t=0;t<e.length;t++)n.push(o),o+=e[t].length,Lx(i,e[t]);const s=nx(i,n);for(let t=0;t<s.length;t+=3)r.push(s.slice(t,t+3));return r}};function Ax(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Lx(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class Rx extends Nm{constructor(t,e){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const i=this,n=[],r=[];for(let e=0,i=t.length;e<i;e++){o(t[e])}function o(t){const o=[],s=void 0!==e.curveSegments?e.curveSegments:12,a=void 0!==e.steps?e.steps:1;let h=void 0!==e.depth?e.depth:100,l=void 0===e.bevelEnabled||e.bevelEnabled,c=void 0!==e.bevelThickness?e.bevelThickness:6,u=void 0!==e.bevelSize?e.bevelSize:c-2,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const f=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:Ox;void 0!==e.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),h=e.amount);let g,v,y,_,x,w=!1;f&&(g=f.getSpacedPoints(a),w=!0,l=!1,v=f.computeFrenetFrames(a,!1),y=new jp,_=new jp,x=new jp),l||(p=0,c=0,u=0,d=0);const b=t.extractPoints(s);let M=b.shape;const S=b.holes;if(!Px.isClockWise(M)){M=M.reverse();for(let t=0,e=S.length;t<e;t++){const e=S[t];Px.isClockWise(e)&&(S[t]=e.reverse())}}const T=Px.triangulateShape(M,S),E=M;for(let t=0,e=S.length;t<e;t++){const e=S[t];M=M.concat(e)}function C(t,e,i){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(i).add(t)}const P=M.length,A=T.length;function L(t,e,i){let n,r,o;const s=t.x-e.x,a=t.y-e.y,h=i.x-t.x,l=i.y-t.y,c=s*s+a*a,u=s*l-a*h;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(h*h+l*l),p=e.x-a/u,f=e.y+s/u,m=((i.x-l/d-p)*l-(i.y+h/d-f)*h)/(s*l-a*h);n=p+s*m-t.x,r=f+a*m-t.y;const g=n*n+r*r;if(g<=2)return new Lp(n,r);o=Math.sqrt(g/2)}else{let t=!1;s>Number.EPSILON?h>Number.EPSILON&&(t=!0):s<-Number.EPSILON?h<-Number.EPSILON&&(t=!0):Math.sign(a)===Math.sign(l)&&(t=!0),t?(n=-a,r=s,o=Math.sqrt(c)):(n=s,r=a,o=Math.sqrt(c/2))}return new Lp(n/o,r/o)}const R=[];for(let t=0,e=E.length,i=e-1,n=t+1;t<e;t++,i++,n++)i===e&&(i=0),n===e&&(n=0),R[t]=L(E[t],E[i],E[n]);const O=[];let D,I=R.concat();for(let t=0,e=S.length;t<e;t++){const e=S[t];D=[];for(let t=0,i=e.length,n=i-1,r=t+1;t<i;t++,n++,r++)n===i&&(n=0),r===i&&(r=0),D[t]=L(e[t],e[n],e[r]);O.push(D),I=I.concat(D)}for(let t=0;t<p;t++){const e=t/p,i=c*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=E.length;t<e;t++){const e=C(E[t],R[t],n);F(e.x,e.y,-i)}for(let t=0,e=S.length;t<e;t++){const e=S[t];D=O[t];for(let t=0,r=e.length;t<r;t++){const r=C(e[t],D[t],n);F(r.x,r.y,-i)}}}const k=u+d;for(let t=0;t<P;t++){const e=l?C(M[t],I[t],k):M[t];w?(_.copy(v.normals[0]).multiplyScalar(e.x),y.copy(v.binormals[0]).multiplyScalar(e.y),x.copy(g[0]).add(_).add(y),F(x.x,x.y,x.z)):F(e.x,e.y,0)}for(let t=1;t<=a;t++)for(let e=0;e<P;e++){const i=l?C(M[e],I[e],k):M[e];w?(_.copy(v.normals[t]).multiplyScalar(i.x),y.copy(v.binormals[t]).multiplyScalar(i.y),x.copy(g[t]).add(_).add(y),F(x.x,x.y,x.z)):F(i.x,i.y,h/a*t)}for(let t=p-1;t>=0;t--){const e=t/p,i=c*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=E.length;t<e;t++){const e=C(E[t],R[t],n);F(e.x,e.y,h+i)}for(let t=0,e=S.length;t<e;t++){const e=S[t];D=O[t];for(let t=0,r=e.length;t<r;t++){const r=C(e[t],D[t],n);w?F(r.x,r.y+g[a-1].y,g[a-1].x+i):F(r.x,r.y,h+i)}}}function z(t,e){let i=t.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=a+2*p;t<i;t++){const i=P*t,o=P*(t+1);N(e+n+i,e+r+i,e+r+o,e+n+o)}}}function F(t,e,i){o.push(t),o.push(e),o.push(i)}function B(t,e,r){H(t),H(e),H(r);const o=n.length/3,s=m.generateTopUV(i,n,o-3,o-2,o-1);j(s[0]),j(s[1]),j(s[2])}function N(t,e,r,o){H(t),H(e),H(o),H(e),H(r),H(o);const s=n.length/3,a=m.generateSideWallUV(i,n,s-6,s-3,s-2,s-1);j(a[0]),j(a[1]),j(a[3]),j(a[1]),j(a[2]),j(a[3])}function H(t){n.push(o[3*t+0]),n.push(o[3*t+1]),n.push(o[3*t+2])}function j(t){r.push(t.x),r.push(t.y)}!function(){const t=n.length/3;if(l){let t=0,e=P*t;for(let t=0;t<A;t++){const i=T[t];B(i[2]+e,i[1]+e,i[0]+e)}t=a+2*p,e=P*t;for(let t=0;t<A;t++){const i=T[t];B(i[0]+e,i[1]+e,i[2]+e)}}else{for(let t=0;t<A;t++){const e=T[t];B(e[2],e[1],e[0])}for(let t=0;t<A;t++){const e=T[t];B(e[0]+P*a,e[1]+P*a,e[2]+P*a)}}i.addGroup(t,n.length/3-t,0)}(),function(){const t=n.length/3;let e=0;z(E,e),e+=E.length;for(let t=0,i=S.length;t<i;t++){const i=S[t];z(i,e),e+=i.length}i.addGroup(t,n.length/3-t,1)}()}this.setAttribute("position",new Cm(n,3)),this.setAttribute("uv",new Cm(r,2)),this.computeVertexNormals()}toJSON(){const t=Nm.prototype.toJSON.call(this);return function(t,e,i){if(i.shapes=[],Array.isArray(t))for(let e=0,n=t.length;e<n;e++){const n=t[e];i.shapes.push(n.uuid)}else i.shapes.push(t.uuid);void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON());return i}(this.parameters.shapes,this.parameters.options,t)}}const Ox={generateTopUV:function(t,e,i,n,r){const o=e[3*i],s=e[3*i+1],a=e[3*n],h=e[3*n+1],l=e[3*r],c=e[3*r+1];return[new Lp(o,s),new Lp(a,h),new Lp(l,c)]},generateSideWallUV:function(t,e,i,n,r,o){const s=e[3*i],a=e[3*i+1],h=e[3*i+2],l=e[3*n],c=e[3*n+1],u=e[3*n+2],d=e[3*r],p=e[3*r+1],f=e[3*r+2],m=e[3*o],g=e[3*o+1],v=e[3*o+2];return Math.abs(a-c)<.01?[new Lp(s,1-h),new Lp(l,1-u),new Lp(d,1-f),new Lp(m,1-v)]:[new Lp(a,1-h),new Lp(c,1-u),new Lp(p,1-f),new Lp(g,1-v)]}};class Dx extends J_{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}}class Ix extends Nm{constructor(t,e=12,i=0,n=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=Ap.clamp(n,0,2*Math.PI);const r=[],o=[],s=[],a=1/e,h=new jp,l=new Lp;for(let r=0;r<=e;r++){const c=i+r*a*n,u=Math.sin(c),d=Math.cos(c);for(let i=0;i<=t.length-1;i++)h.x=t[i].x*u,h.y=t[i].y,h.z=t[i].x*d,o.push(h.x,h.y,h.z),l.x=r/e,l.y=i/(t.length-1),s.push(l.x,l.y)}for(let i=0;i<e;i++)for(let e=0;e<t.length-1;e++){const n=e+i*t.length,o=n,s=n+t.length,a=n+t.length+1,h=n+1;r.push(o,s,h),r.push(s,a,h)}if(this.setIndex(r),this.setAttribute("position",new Cm(o,3)),this.setAttribute("uv",new Cm(s,2)),this.computeVertexNormals(),n===2*Math.PI){const i=this.attributes.normal.array,n=new jp,r=new jp,o=new jp,s=e*t.length*3;for(let e=0,a=0;e<t.length;e++,a+=3)n.x=i[a+0],n.y=i[a+1],n.z=i[a+2],r.x=i[s+a+0],r.y=i[s+a+1],r.z=i[s+a+2],o.addVectors(n,r).normalize(),i[a+0]=i[s+a+0]=o.x,i[a+1]=i[s+a+1]=o.y,i[a+2]=i[s+a+2]=o.z}}}class kx extends J_{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}}function zx(t,e,i){Nm.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i};const n=[],r=[],o=[],s=[],a=1e-5,h=new jp,l=new jp,c=new jp,u=new jp,d=new jp;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const p=e+1;for(let n=0;n<=i;n++){const p=n/i;for(let i=0;i<=e;i++){const n=i/e;t(n,p,l),r.push(l.x,l.y,l.z),n-a>=0?(t(n-a,p,c),u.subVectors(l,c)):(t(n+a,p,c),u.subVectors(c,l)),p-a>=0?(t(n,p-a,c),d.subVectors(l,c)):(t(n,p+a,c),d.subVectors(c,l)),h.crossVectors(u,d).normalize(),o.push(h.x,h.y,h.z),s.push(n,p)}}for(let t=0;t<i;t++)for(let i=0;i<e;i++){const e=t*p+i,r=t*p+i+1,o=(t+1)*p+i+1,s=(t+1)*p+i;n.push(e,r,s),n.push(r,o,s)}this.setIndex(n),this.setAttribute("position",new Cm(r,3)),this.setAttribute("normal",new Cm(o,3)),this.setAttribute("uv",new Cm(s,2))}zx.prototype=Object.create(Nm.prototype),zx.prototype.constructor=zx;class Fx extends Nm{constructor(t=.5,e=1,i=8,n=1,r=0,o=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:o},i=Math.max(3,i);const s=[],a=[],h=[],l=[];let c=t;const u=(e-t)/(n=Math.max(1,n)),d=new jp,p=new Lp;for(let t=0;t<=n;t++){for(let t=0;t<=i;t++){const n=r+t/i*o;d.x=c*Math.cos(n),d.y=c*Math.sin(n),a.push(d.x,d.y,d.z),h.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,l.push(p.x,p.y)}c+=u}for(let t=0;t<n;t++){const e=t*(i+1);for(let t=0;t<i;t++){const n=t+e,r=n,o=n+i+1,a=n+i+2,h=n+1;s.push(r,o,h),s.push(o,a,h)}}this.setIndex(s),this.setAttribute("position",new Cm(a,3)),this.setAttribute("normal",new Cm(h,3)),this.setAttribute("uv",new Cm(l,2))}}class Bx extends Nm{constructor(t,e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const i=[],n=[],r=[],o=[];let s=0,a=0;if(!1===Array.isArray(t))h(t);else for(let e=0;e<t.length;e++)h(t[e]),this.addGroup(s,a,e),s+=a,a=0;function h(t){const s=n.length/3,h=t.extractPoints(e);let l=h.shape;const c=h.holes;!1===Px.isClockWise(l)&&(l=l.reverse());for(let t=0,e=c.length;t<e;t++){const e=c[t];!0===Px.isClockWise(e)&&(c[t]=e.reverse())}const u=Px.triangulateShape(l,c);for(let t=0,e=c.length;t<e;t++){const e=c[t];l=l.concat(e)}for(let t=0,e=l.length;t<e;t++){const e=l[t];n.push(e.x,e.y,0),r.push(0,0,1),o.push(e.x,e.y)}for(let t=0,e=u.length;t<e;t++){const e=u[t],n=e[0]+s,r=e[1]+s,o=e[2]+s;i.push(n,r,o),a+=3}}this.setIndex(i),this.setAttribute("position",new Cm(n,3)),this.setAttribute("normal",new Cm(r,3)),this.setAttribute("uv",new Cm(o,2))}toJSON(){const t=Nm.prototype.toJSON.call(this);return function(t,e){if(e.shapes=[],Array.isArray(t))for(let i=0,n=t.length;i<n;i++){const n=t[i];e.shapes.push(n.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}}class Nx extends Nm{constructor(t=1,e=8,i=6,n=0,r=2*Math.PI,o=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:o,thetaLength:s},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const a=Math.min(o+s,Math.PI);let h=0;const l=[],c=new jp,u=new jp,d=[],p=[],f=[],m=[];for(let d=0;d<=i;d++){const g=[],v=d/i;let y=0;0==d&&0==o?y=.5/e:d==i&&a==Math.PI&&(y=-.5/e);for(let i=0;i<=e;i++){const a=i/e;c.x=-t*Math.cos(n+a*r)*Math.sin(o+v*s),c.y=t*Math.cos(o+v*s),c.z=t*Math.sin(n+a*r)*Math.sin(o+v*s),p.push(c.x,c.y,c.z),u.copy(c).normalize(),f.push(u.x,u.y,u.z),m.push(a+y,1-v),g.push(h++)}l.push(g)}for(let t=0;t<i;t++)for(let n=0;n<e;n++){const e=l[t][n+1],r=l[t][n],s=l[t+1][n],h=l[t+1][n+1];(0!==t||o>0)&&d.push(e,r,h),(t!==i-1||a<Math.PI)&&d.push(r,s,h)}this.setIndex(d),this.setAttribute("position",new Cm(p,3)),this.setAttribute("normal",new Cm(f,3)),this.setAttribute("uv",new Cm(m,2))}}class Hx extends J_{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}}class jx extends Rx{constructor(t,e={}){const i=e.font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Nm;const n=i.generateShapes(t,e.size);e.depth=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),super(n,e),this.type="TextGeometry"}}class Gx extends Nm{constructor(t=1,e=.4,i=8,n=6,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r},i=Math.floor(i),n=Math.floor(n);const o=[],s=[],a=[],h=[],l=new jp,c=new jp,u=new jp;for(let o=0;o<=i;o++)for(let d=0;d<=n;d++){const p=d/n*r,f=o/i*Math.PI*2;c.x=(t+e*Math.cos(f))*Math.cos(p),c.y=(t+e*Math.cos(f))*Math.sin(p),c.z=e*Math.sin(f),s.push(c.x,c.y,c.z),l.x=t*Math.cos(p),l.y=t*Math.sin(p),u.subVectors(c,l).normalize(),a.push(u.x,u.y,u.z),h.push(d/n),h.push(o/i)}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*t+e-1,r=(n+1)*(t-1)+e-1,s=(n+1)*(t-1)+e,a=(n+1)*t+e;o.push(i,r,a),o.push(r,s,a)}this.setIndex(o),this.setAttribute("position",new Cm(s,3)),this.setAttribute("normal",new Cm(a,3)),this.setAttribute("uv",new Cm(h,2))}}class Ux extends Nm{constructor(t=1,e=.4,i=64,n=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:n,p:r,q:o},i=Math.floor(i),n=Math.floor(n);const s=[],a=[],h=[],l=[],c=new jp,u=new jp,d=new jp,p=new jp,f=new jp,m=new jp,g=new jp;for(let s=0;s<=i;++s){const y=s/i*r*Math.PI*2;v(y,r,o,t,d),v(y+.01,r,o,t,p),m.subVectors(p,d),g.addVectors(p,d),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let t=0;t<=n;++t){const r=t/n*Math.PI*2,o=-e*Math.cos(r),p=e*Math.sin(r);c.x=d.x+(o*g.x+p*f.x),c.y=d.y+(o*g.y+p*f.y),c.z=d.z+(o*g.z+p*f.z),a.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),h.push(u.x,u.y,u.z),l.push(s/i),l.push(t/n)}}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),r=(n+1)*t+(e-1),o=(n+1)*t+e,a=(n+1)*(t-1)+e;s.push(i,r,a),s.push(r,o,a)}function v(t,e,i,n,r){const o=Math.cos(t),s=Math.sin(t),a=i/e*t,h=Math.cos(a);r.x=n*(2+h)*.5*o,r.y=n*(2+h)*s*.5,r.z=n*Math.sin(a)*.5}this.setIndex(s),this.setAttribute("position",new Cm(a,3)),this.setAttribute("normal",new Cm(h,3)),this.setAttribute("uv",new Cm(l,2))}}class Vx extends Nm{constructor(t,e=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:r};const o=t.computeFrenetFrames(e,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const s=new jp,a=new jp,h=new Lp;let l=new jp;const c=[],u=[],d=[],p=[];function f(r){l=t.getPointAt(r/e,l);const h=o.normals[r],d=o.binormals[r];for(let t=0;t<=n;t++){const e=t/n*Math.PI*2,r=Math.sin(e),o=-Math.cos(e);a.x=o*h.x+r*d.x,a.y=o*h.y+r*d.y,a.z=o*h.z+r*d.z,a.normalize(),u.push(a.x,a.y,a.z),s.x=l.x+i*a.x,s.y=l.y+i*a.y,s.z=l.z+i*a.z,c.push(s.x,s.y,s.z)}}!function(){for(let t=0;t<e;t++)f(t);f(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let i=0;i<=n;i++)h.x=t/e,h.y=i/n,d.push(h.x,h.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),r=(n+1)*t+(e-1),o=(n+1)*t+e,s=(n+1)*(t-1)+e;p.push(i,r,s),p.push(r,o,s)}}()}(),this.setIndex(p),this.setAttribute("position",new Cm(c,3)),this.setAttribute("normal",new Cm(u,3)),this.setAttribute("uv",new Cm(d,2))}toJSON(){const t=Nm.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t}}class Wx extends Nm{constructor(t){if(super(),this.type="WireframeGeometry",!0===t.isGeometry)return void console.error("THREE.WireframeGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const e=[],i=[0,0],n={},r=new jp;if(null!==t.index){const o=t.attributes.position,s=t.index;let a=t.groups;0===a.length&&(a=[{start:0,count:s.count,materialIndex:0}]);for(let t=0,e=a.length;t<e;++t){const e=a[t],r=e.start;for(let t=r,o=r+e.count;t<o;t+=3)for(let e=0;e<3;e++){const r=s.getX(t+e),o=s.getX(t+(e+1)%3);i[0]=Math.min(r,o),i[1]=Math.max(r,o);const a=i[0]+","+i[1];void 0===n[a]&&(n[a]={index1:i[0],index2:i[1]})}}for(const t in n){const i=n[t];r.fromBufferAttribute(o,i.index1),e.push(r.x,r.y,r.z),r.fromBufferAttribute(o,i.index2),e.push(r.x,r.y,r.z)}}else{const i=t.attributes.position;for(let t=0,n=i.count/3;t<n;t++)for(let n=0;n<3;n++){const o=3*t+n;r.fromBufferAttribute(i,o),e.push(r.x,r.y,r.z);const s=3*t+(n+1)%3;r.fromBufferAttribute(i,s),e.push(r.x,r.y,r.z)}}this.setAttribute("position",new Cm(e,3))}}var Zx=Object.freeze({__proto__:null,BoxGeometry:og,BoxBufferGeometry:og,CircleGeometry:q_,CircleBufferGeometry:q_,ConeGeometry:Y_,ConeBufferGeometry:Y_,CylinderGeometry:X_,CylinderBufferGeometry:X_,DodecahedronGeometry:Q_,DodecahedronBufferGeometry:Q_,EdgesGeometry:ix,ExtrudeGeometry:Rx,ExtrudeBufferGeometry:Rx,IcosahedronGeometry:Dx,IcosahedronBufferGeometry:Dx,LatheGeometry:Ix,LatheBufferGeometry:Ix,OctahedronGeometry:kx,OctahedronBufferGeometry:kx,ParametricGeometry:zx,ParametricBufferGeometry:zx,PlaneGeometry:Sg,PlaneBufferGeometry:Sg,PolyhedronGeometry:J_,PolyhedronBufferGeometry:J_,RingGeometry:Fx,RingBufferGeometry:Fx,ShapeGeometry:Bx,ShapeBufferGeometry:Bx,SphereGeometry:Nx,SphereBufferGeometry:Nx,TetrahedronGeometry:Hx,TetrahedronBufferGeometry:Hx,TextGeometry:jx,TextBufferGeometry:jx,TorusGeometry:Gx,TorusBufferGeometry:Gx,TorusKnotGeometry:Ux,TorusKnotBufferGeometry:Ux,TubeGeometry:Vx,TubeBufferGeometry:Vx,WireframeGeometry:Wx});class qx extends am{constructor(t){super(),this.type="ShadowMaterial",this.color=new fm(0),this.transparent=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this}}qx.prototype.isShadowMaterial=!0;class Xx extends ug{constructor(t){super(t),this.type="RawShaderMaterial"}}function Yx(t){am.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new fm(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new fm(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_p,this.normalScale=new Lp(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.vertexTangents=!1,this.setValues(t)}function Jx(t){Yx.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Lp(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(t){this.reflectivity=Ap.clamp(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(t)}Xx.prototype.isRawShaderMaterial=!0,Yx.prototype=Object.create(am.prototype),Yx.prototype.constructor=Yx,Yx.prototype.isMeshStandardMaterial=!0,Yx.prototype.copy=function(t){return am.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.flatShading=t.flatShading,this.vertexTangents=t.vertexTangents,this},Jx.prototype=Object.create(Yx.prototype),Jx.prototype.constructor=Jx,Jx.prototype.isMeshPhysicalMaterial=!0,Jx.prototype.copy=function(t){return Yx.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.reflectivity=t.reflectivity,t.sheen?this.sheen=(this.sheen||new fm).copy(t.sheen):this.sheen=null,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this};class Qx extends am{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new fm(16777215),this.specular=new fm(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new fm(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_p,this.normalScale=new Lp(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=_u,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.flatShading=t.flatShading,this}}Qx.prototype.isMeshPhongMaterial=!0;class Kx extends am{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new fm(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new fm(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_p,this.normalScale=new Lp(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this}}Kx.prototype.isMeshToonMaterial=!0;class $x extends am{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_p,this.normalScale=new Lp(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.flatShading=t.flatShading,this}}$x.prototype.isMeshNormalMaterial=!0;class tw extends am{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new fm(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new fm(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=_u,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this}}tw.prototype.isMeshLambertMaterial=!0;class ew extends am{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new fm(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=_p,this.normalScale=new Lp(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.flatShading=t.flatShading,this}}ew.prototype.isMeshMatcapMaterial=!0;class iw extends T_{constructor(t){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}iw.prototype.isLineDashedMaterial=!0;var nw=Object.freeze({__proto__:null,ShadowMaterial:qx,SpriteMaterial:Wy,RawShaderMaterial:Xx,ShaderMaterial:ug,PointsMaterial:z_,MeshPhysicalMaterial:Jx,MeshStandardMaterial:Yx,MeshPhongMaterial:Qx,MeshToonMaterial:Kx,MeshNormalMaterial:$x,MeshLambertMaterial:tw,MeshDepthMaterial:Sy,MeshDistanceMaterial:Ty,MeshBasicMaterial:mm,MeshMatcapMaterial:ew,LineDashedMaterial:iw,LineBasicMaterial:T_,Material:am});const rw={arraySlice:function(t,e,i){return rw.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i},sortedArray:function(t,e,i){const n=t.length,r=new t.constructor(n);for(let o=0,s=0;s!==n;++o){const n=i[o]*e;for(let i=0;i!==e;++i)r[s++]=t[n+i]}return r},flattenJSON:function(t,e,i,n){let r=1,o=t[0];for(;void 0!==o&&void 0===o[n];)o=t[r++];if(void 0===o)return;let s=o[n];if(void 0!==s)if(Array.isArray(s))do{s=o[n],void 0!==s&&(e.push(o.time),i.push.apply(i,s)),o=t[r++]}while(void 0!==o);else if(void 0!==s.toArray)do{s=o[n],void 0!==s&&(e.push(o.time),s.toArray(i,i.length)),o=t[r++]}while(void 0!==o);else do{s=o[n],void 0!==s&&(e.push(o.time),i.push(s)),o=t[r++]}while(void 0!==o)},subclip:function(t,e,i,n,r=30){const o=t.clone();o.name=e;const s=[];for(let t=0;t<o.tracks.length;++t){const e=o.tracks[t],a=e.getValueSize(),h=[],l=[];for(let t=0;t<e.times.length;++t){const o=e.times[t]*r;if(!(o<i||o>=n)){h.push(e.times[t]);for(let i=0;i<a;++i)l.push(e.values[t*a+i])}}0!==h.length&&(e.times=rw.convertArray(h,e.times.constructor),e.values=rw.convertArray(l,e.values.constructor),s.push(e))}o.tracks=s;let a=1/0;for(let t=0;t<o.tracks.length;++t)a>o.tracks[t].times[0]&&(a=o.tracks[t].times[0]);for(let t=0;t<o.tracks.length;++t)o.tracks[t].shift(-1*a);return o.resetDuration(),o},makeClipAdditive:function(t,e=0,i=t,n=30){n<=0&&(n=30);const r=i.tracks.length,o=e/n;for(let e=0;e<r;++e){const n=i.tracks[e],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const s=t.tracks.find((function(t){return t.name===n.name&&t.ValueTypeName===r}));if(void 0===s)continue;let a=0;const h=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(a=h/3);let l=0;const c=s.getValueSize();s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=c/3);const u=n.times.length-1;let d;if(o<=n.times[0]){const t=a,e=h-a;d=rw.arraySlice(n.values,t,e)}else if(o>=n.times[u]){const t=u*h+a,e=t+h-a;d=rw.arraySlice(n.values,t,e)}else{const t=n.createInterpolant(),e=a,i=h-a;t.evaluate(o),d=rw.arraySlice(t.resultBuffer,e,i)}if("quaternion"===r){(new Hp).fromArray(d).normalize().conjugate().toArray(d)}const p=s.times.length;for(let t=0;t<p;++t){const e=t*c+l;if("quaternion"===r)Hp.multiplyQuaternionsFlat(s.values,e,d,0,s.values,e);else{const t=c-2*l;for(let i=0;i<t;++i)s.values[e+i]-=d[i]}}}return t.blendMode=lp,t}};function ow(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i}function sw(t,e,i,n){ow.call(this,t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function aw(t,e,i,n){ow.call(this,t,e,i,n)}function hw(t,e,i,n){ow.call(this,t,e,i,n)}Object.assign(ow.prototype,{evaluate:function(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{let o;i:{n:if(!(t<n)){for(let o=i+2;;){if(void 0===n){if(t<r)break n;return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,t,r)}if(i===o)break;if(r=n,n=e[++i],t<n)break e}o=e.length;break i}if(t>=r)break t;{const s=e[1];t<s&&(i=2,r=s);for(let o=i-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(i===o)break;if(n=r,r=e[--i-1],t>=r)break e}o=i,i=0}}for(;i<o;){const n=i+o>>>1;t<e[n]?o=n:i=n+1}if(n=e[i],r=e[i-1],void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(void 0===n)return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,r,t)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,t,n)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n;for(let t=0;t!==n;++t)e[t]=i[r+t];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(ow.prototype,{beforeStart_:ow.prototype.copySampleValue_,afterEnd_:ow.prototype.copySampleValue_}),sw.prototype=Object.assign(Object.create(ow.prototype),{constructor:sw,DefaultSettings_:{endingStart:op,endingEnd:op},intervalChanged_:function(t,e,i){const n=this.parameterPositions;let r=t-2,o=t+1,s=n[r],a=n[o];if(void 0===s)switch(this.getSettings_().endingStart){case sp:r=t,s=2*e-i;break;case ap:r=n.length-2,s=e+n[r]-n[r+1];break;default:r=t,s=i}if(void 0===a)switch(this.getSettings_().endingEnd){case sp:o=t,a=2*i-e;break;case ap:o=1,a=i+n[1]-n[0];break;default:o=t-1,a=e}const h=.5*(i-e),l=this.valueSize;this._weightPrev=h/(e-s),this._weightNext=h/(a-i),this._offsetPrev=r*l,this._offsetNext=o*l},interpolate_:function(t,e,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=t*s,h=a-s,l=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-e)/(n-e),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,_=d*m-d*f;for(let t=0;t!==s;++t)r[t]=g*o[l+t]+v*o[h+t]+y*o[a+t]+_*o[c+t];return r}}),aw.prototype=Object.assign(Object.create(ow.prototype),{constructor:aw,interpolate_:function(t,e,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=t*s,h=a-s,l=(i-e)/(n-e),c=1-l;for(let t=0;t!==s;++t)r[t]=o[h+t]*c+o[a+t]*l;return r}}),hw.prototype=Object.assign(Object.create(ow.prototype),{constructor:hw,interpolate_:function(t){return this.copySampleValue_(t-1)}});class lw{constructor(t,e,i,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=rw.convertArray(e,this.TimeBufferType),this.values=rw.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:rw.convertArray(t.times,Array),values:rw.convertArray(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new hw(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new aw(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new sw(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case ip:e=this.InterpolantFactoryMethodDiscrete;break;case np:e=this.InterpolantFactoryMethodLinear;break;case rp:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ip;case this.InterpolantFactoryMethodLinear:return np;case this.InterpolantFactoryMethodSmooth:return rp}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let r=0,o=n-1;for(;r!==n&&i[r]<t;)++r;for(;-1!==o&&i[o]>e;)--o;if(++o,0!==r||o!==n){r>=o&&(o=Math.max(o,1),r=o-1);const t=this.getValueSize();this.times=rw.arraySlice(i,r,o),this.values=rw.arraySlice(this.values,r*t,o*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let e=0;e!==r;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==o&&o>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,o),t=!1;break}o=n}if(void 0!==n&&rw.isTypedArray(n))for(let e=0,i=n.length;e!==i;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){const t=rw.arraySlice(this.times),e=rw.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===rp,r=t.length-1;let o=1;for(let s=1;s<r;++s){let r=!1;const a=t[s];if(a!==t[s+1]&&(1!==s||a!==t[0]))if(n)r=!0;else{const t=s*i,n=t-i,o=t+i;for(let s=0;s!==i;++s){const i=e[t+s];if(i!==e[n+s]||i!==e[o+s]){r=!0;break}}}if(r){if(s!==o){t[o]=t[s];const n=s*i,r=o*i;for(let t=0;t!==i;++t)e[r+t]=e[n+t]}++o}}if(r>0){t[o]=t[r];for(let t=r*i,n=o*i,s=0;s!==i;++s)e[n+s]=e[t+s];++o}return o!==t.length?(this.times=rw.arraySlice(t,0,o),this.values=rw.arraySlice(e,0,o*i)):(this.times=t,this.values=e),this}clone(){const t=rw.arraySlice(this.times,0),e=rw.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}lw.prototype.TimeBufferType=Float32Array,lw.prototype.ValueBufferType=Float32Array,lw.prototype.DefaultInterpolation=np;class cw extends lw{}cw.prototype.ValueTypeName="bool",cw.prototype.ValueBufferType=Array,cw.prototype.DefaultInterpolation=ip,cw.prototype.InterpolantFactoryMethodLinear=void 0,cw.prototype.InterpolantFactoryMethodSmooth=void 0;class uw extends lw{}uw.prototype.ValueTypeName="color";class dw extends lw{}function pw(t,e,i,n){ow.call(this,t,e,i,n)}dw.prototype.ValueTypeName="number",pw.prototype=Object.assign(Object.create(ow.prototype),{constructor:pw,interpolate_:function(t,e,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(i-e)/(n-e);let h=t*s;for(let t=h+s;h!==t;h+=4)Hp.slerpFlat(r,0,o,h-s,o,h,a);return r}});class fw extends lw{InterpolantFactoryMethodLinear(t){return new pw(this.times,this.values,this.getValueSize(),t)}}fw.prototype.ValueTypeName="quaternion",fw.prototype.DefaultInterpolation=np,fw.prototype.InterpolantFactoryMethodSmooth=void 0;class mw extends lw{}mw.prototype.ValueTypeName="string",mw.prototype.ValueBufferType=Array,mw.prototype.DefaultInterpolation=ip,mw.prototype.InterpolantFactoryMethodLinear=void 0,mw.prototype.InterpolantFactoryMethodSmooth=void 0;class gw extends lw{}gw.prototype.ValueTypeName="vector";class vw{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Ap.generateUUID(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(yw(i[t]).scale(n));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=i.length;t!==n;++t)e.push(lw.toJSON(i[t]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const r=e.length,o=[];for(let t=0;t<r;t++){let s=[],a=[];s.push((t+r-1)%r,t,(t+1)%r),a.push(0,1,0);const h=rw.getKeyframeOrder(s);s=rw.sortedArray(s,1,h),a=rw.sortedArray(a,1,h),n||0!==s[0]||(s.push(r),a.push(a[0])),o.push(new dw(".morphTargetInfluences["+e[t].name+"]",s,a).scale(1/i))}return new this(t,-1,o)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const e=t;i=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<i.length;t++)if(i[t].name===e)return i[t];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,i=t.length;e<i;e++){const i=t[e],o=i.name.match(r);if(o&&o.length>1){const t=o[1];let e=n[t];e||(n[t]=e=[]),e.push(i)}}const o=[];for(const t in n)o.push(this.CreateFromMorphTargetSequence(t,n[t],e,i));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,n,r){if(0!==i.length){const o=[],s=[];rw.flattenJSON(i,o,s,n),0!==o.length&&r.push(new t(e,o,s))}},n=[],r=t.name||"default",o=t.fps||30,s=t.blendMode;let a=t.length||-1;const h=t.hierarchy||[];for(let t=0;t<h.length;t++){const r=h[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let i=0;i<r[e].morphTargets.length;i++)t[r[e].morphTargets[i]]=-1;for(const i in t){const t=[],o=[];for(let n=0;n!==r[e].morphTargets.length;++n){const n=r[e];t.push(n.time),o.push(n.morphTarget===i?1:0)}n.push(new dw(".morphTargetInfluence["+i+"]",t,o))}a=t.length*(o||1)}else{const o=".bones["+e[t].name+"]";i(gw,o+".position",r,"pos",n),i(fw,o+".quaternion",r,"rot",n),i(gw,o+".scale",r,"scl",n)}}if(0===n.length)return null;return new this(r,a,n,s)}resetDuration(){let t=0;for(let e=0,i=this.tracks.length;e!==i;++e){const i=this.tracks[e];t=Math.max(t,i.times[i.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function yw(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return dw;case"vector":case"vector2":case"vector3":case"vector4":return gw;case"color":return uw;case"quaternion":return fw;case"bool":case"boolean":return cw;case"string":return mw}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];rw.flattenJSON(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const _w={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function xw(t,e,i){const n=this;let r,o=!1,s=0,a=0;const h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){a++,!1===o&&void 0!==n.onStart&&n.onStart(t,s,a),o=!0},this.itemEnd=function(t){s++,void 0!==n.onProgress&&n.onProgress(t,s,a),s===a&&(o=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return h.push(t,e),this},this.removeHandler=function(t){const e=h.indexOf(t);return-1!==e&&h.splice(e,2),this},this.getHandler=function(t){for(let e=0,i=h.length;e<i;e+=2){const i=h[e],n=h[e+1];if(i.global&&(i.lastIndex=0),i.test(t))return n}return null}}const ww=new xw;function bw(t){this.manager=void 0!==t?t:ww,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(bw.prototype,{load:function(){},loadAsync:function(t,e){const i=this;return new Promise((function(n,r){i.load(t,n,e,r)}))},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}});const Mw={};function Sw(t){bw.call(this,t)}Sw.prototype=Object.assign(Object.create(bw.prototype),{constructor:Sw,load:function(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,o=_w.get(t);if(void 0!==o)return r.manager.itemStart(t),setTimeout((function(){e&&e(o),r.manager.itemEnd(t)}),0),o;if(void 0!==Mw[t])return void Mw[t].push({onLoad:e,onProgress:i,onError:n});const s=t.match(/^data:(.*?)(;base64)?,(.*)$/);let a;if(s){const i=s[1],o=!!s[2];let a=s[3];a=decodeURIComponent(a),o&&(a=atob(a));try{let n;const o=(this.responseType||"").toLowerCase();switch(o){case"arraybuffer":case"blob":const t=new Uint8Array(a.length);for(let e=0;e<a.length;e++)t[e]=a.charCodeAt(e);n="blob"===o?new Blob([t.buffer],{type:i}):t.buffer;break;case"document":const e=new DOMParser;n=e.parseFromString(a,i);break;case"json":n=JSON.parse(a);break;default:n=a}setTimeout((function(){e&&e(n),r.manager.itemEnd(t)}),0)}catch(e){setTimeout((function(){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}),0)}}else{Mw[t]=[],Mw[t].push({onLoad:e,onProgress:i,onError:n}),a=new XMLHttpRequest,a.open("GET",t,!0),a.addEventListener("load",(function(e){const i=this.response,n=Mw[t];if(delete Mw[t],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),_w.add(t,i);for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onLoad&&e.onLoad(i)}r.manager.itemEnd(t)}else{for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}}),!1),a.addEventListener("progress",(function(e){const i=Mw[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onProgress&&n.onProgress(e)}}),!1),a.addEventListener("error",(function(e){const i=Mw[t];delete Mw[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),a.addEventListener("abort",(function(e){const i=Mw[t];delete Mw[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),void 0!==this.responseType&&(a.responseType=this.responseType),void 0!==this.withCredentials&&(a.withCredentials=this.withCredentials),a.overrideMimeType&&a.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(const t in this.requestHeader)a.setRequestHeader(t,this.requestHeader[t]);a.send(null)}return r.manager.itemStart(t),a},setResponseType:function(t){return this.responseType=t,this},setMimeType:function(t){return this.mimeType=t,this}});function Tw(t){bw.call(this,t)}Tw.prototype=Object.assign(Object.create(bw.prototype),{constructor:Tw,load:function(t,e,i,n){const r=this,o=[],s=new V_,a=new Sw(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let h=0;function l(l){a.load(t[l],(function(t){const i=r.parse(t,!0);o[l]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},h+=1,6===h&&(1===i.mipmapCount&&(s.minFilter=ju),s.image=o,s.format=i.format,s.needsUpdate=!0,e&&e(s))}),i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)l(e);else a.load(t,(function(t){const i=r.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){o[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)o[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),o[e].format=i.format,o[e].width=i.width,o[e].height=i.height}s.image=o}else s.image.width=i.width,s.image.height=i.height,s.mipmaps=i.mipmaps;1===i.mipmapCount&&(s.minFilter=ju),s.format=i.format,s.needsUpdate=!0,e&&e(s)}),i,n);return s}});class Ew extends bw{constructor(t){super(t)}load(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,o=_w.get(t);if(void 0!==o)return r.manager.itemStart(t),setTimeout((function(){e&&e(o),r.manager.itemEnd(t)}),0),o;const s=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){s.removeEventListener("load",a,!1),s.removeEventListener("error",h,!1),_w.add(t,this),e&&e(this),r.manager.itemEnd(t)}function h(e){s.removeEventListener("load",a,!1),s.removeEventListener("error",h,!1),n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}return s.addEventListener("load",a,!1),s.addEventListener("error",h,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(t),s.src=t,s}}class Cw extends bw{constructor(t){super(t)}load(t,e,i,n){const r=new gg,o=new Ew(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let s=0;function a(i){o.load(t[i],(function(t){r.images[i]=t,s++,6===s&&(r.needsUpdate=!0,e&&e(r))}),void 0,n)}for(let e=0;e<t.length;++e)a(e);return r}}function Pw(t){bw.call(this,t)}function Aw(t){bw.call(this,t)}function Lw(){this.type="Curve",this.arcLengthDivisions=200}Pw.prototype=Object.assign(Object.create(bw.prototype),{constructor:Pw,load:function(t,e,i,n){const r=this,o=new yg,s=new Sw(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(t,(function(t){const i=r.parse(t);i&&(void 0!==i.image?o.image=i.image:void 0!==i.data&&(o.image.width=i.width,o.image.height=i.height,o.image.data=i.data),o.wrapS=void 0!==i.wrapS?i.wrapS:zu,o.wrapT=void 0!==i.wrapT?i.wrapT:zu,o.magFilter=void 0!==i.magFilter?i.magFilter:ju,o.minFilter=void 0!==i.minFilter?i.minFilter:ju,o.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.encoding&&(o.encoding=i.encoding),void 0!==i.flipY&&(o.flipY=i.flipY),void 0!==i.format&&(o.format=i.format),void 0!==i.type&&(o.type=i.type),void 0!==i.mipmaps&&(o.mipmaps=i.mipmaps,o.minFilter=Uu),1===i.mipmapCount&&(o.minFilter=ju),void 0!==i.generateMipmaps&&(o.generateMipmaps=i.generateMipmaps),o.needsUpdate=!0,e&&e(o,i))}),i,n),o}}),Aw.prototype=Object.assign(Object.create(bw.prototype),{constructor:Aw,load:function(t,e,i,n){const r=new kp,o=new Ew(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,(function(i){r.image=i;const n=t.search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/);r.format=n?nd:rd,r.needsUpdate=!0,void 0!==e&&e(r)}),i,n),r}}),Object.assign(Lw.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getSpacedPoints:function(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e},getLength:function(){const t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let i,n=this.getPoint(0),r=0;e.push(0);for(let o=1;o<=t;o++)i=this.getPoint(o/t),r+=i.distanceTo(n),e.push(r),n=i;return this.cacheArcLengths=e,e},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){const i=this.getLengths();let n=0;const r=i.length;let o;o=e||t*i[r-1];let s,a=0,h=r-1;for(;a<=h;)if(n=Math.floor(a+(h-a)/2),s=i[n]-o,s<0)a=n+1;else{if(!(s>0)){h=n;break}h=n-1}if(n=h,i[n]===o)return n/(r-1);const l=i[n];return(n+(o-l)/(i[n+1]-l))/(r-1)},getTangent:function(t,e){const i=1e-4;let n=t-i,r=t+i;n<0&&(n=0),r>1&&(r=1);const o=this.getPoint(n),s=this.getPoint(r),a=e||(o.isVector2?new Lp:new jp);return a.copy(s).sub(o).normalize(),a},getTangentAt:function(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)},computeFrenetFrames:function(t,e){const i=new jp,n=[],r=[],o=[],s=new jp,a=new _f;for(let e=0;e<=t;e++){const i=e/t;n[e]=this.getTangentAt(i,new jp),n[e].normalize()}r[0]=new jp,o[0]=new jp;let h=Number.MAX_VALUE;const l=Math.abs(n[0].x),c=Math.abs(n[0].y),u=Math.abs(n[0].z);l<=h&&(h=l,i.set(1,0,0)),c<=h&&(h=c,i.set(0,1,0)),u<=h&&i.set(0,0,1),s.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],s),o[0].crossVectors(n[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),o[e]=o[e-1].clone(),s.crossVectors(n[e-1],n[e]),s.length()>Number.EPSILON){s.normalize();const t=Math.acos(Ap.clamp(n[e-1].dot(n[e]),-1,1));r[e].applyMatrix4(a.makeRotationAxis(s,t))}o[e].crossVectors(n[e],r[e])}if(!0===e){let e=Math.acos(Ap.clamp(r[0].dot(r[t]),-1,1));e/=t,n[0].dot(s.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(a.makeRotationAxis(n[i],e*i)),o[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:o}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}});class Rw extends Lw{constructor(t=0,e=0,i=1,n=1,r=0,o=2*Math.PI,s=!1,a=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=s,this.aRotation=a}getPoint(t,e){const i=e||new Lp,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=o?0:n),!0!==this.aClockwise||o||(r===n?r=-n:r-=n);const s=this.aStartAngle+t*r;let a=this.aX+this.xRadius*Math.cos(s),h=this.aY+this.yRadius*Math.sin(s);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),i=a-this.aX,n=h-this.aY;a=i*t-n*e+this.aX,h=i*e+n*t+this.aY}return i.set(a,h)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}Rw.prototype.isEllipseCurve=!0;class Ow extends Rw{constructor(t,e,i,n,r,o){super(t,e,i,i,n,r,o),this.type="ArcCurve"}}function Dw(){let t=0,e=0,i=0,n=0;function r(r,o,s,a){t=r,e=s,i=-3*r+3*o-2*s-a,n=2*r-2*o+s+a}return{initCatmullRom:function(t,e,i,n,o){r(e,i,o*(i-t),o*(n-e))},initNonuniformCatmullRom:function(t,e,i,n,o,s,a){let h=(e-t)/o-(i-t)/(o+s)+(i-e)/s,l=(i-e)/s-(n-e)/(s+a)+(n-i)/a;h*=s,l*=s,r(e,i,h,l)},calc:function(r){const o=r*r;return t+e*r+i*o+n*(o*r)}}}Ow.prototype.isArcCurve=!0;const Iw=new jp,kw=new Dw,zw=new Dw,Fw=new Dw;class Bw extends Lw{constructor(t=[],e=!1,i="centripetal",n=.5){super(),this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=i,this.tension=n}getPoint(t,e=new jp){const i=e,n=this.points,r=n.length,o=(r-(this.closed?0:1))*t;let s,a,h=Math.floor(o),l=o-h;this.closed?h+=h>0?0:(Math.floor(Math.abs(h)/r)+1)*r:0===l&&h===r-1&&(h=r-2,l=1),this.closed||h>0?s=n[(h-1)%r]:(Iw.subVectors(n[0],n[1]).add(n[0]),s=Iw);const c=n[h%r],u=n[(h+1)%r];if(this.closed||h+2<r?a=n[(h+2)%r]:(Iw.subVectors(n[r-1],n[r-2]).add(n[r-1]),a=Iw),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(s.distanceToSquared(c),t),i=Math.pow(c.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(a),t);i<1e-4&&(i=1),e<1e-4&&(e=i),n<1e-4&&(n=i),kw.initNonuniformCatmullRom(s.x,c.x,u.x,a.x,e,i,n),zw.initNonuniformCatmullRom(s.y,c.y,u.y,a.y,e,i,n),Fw.initNonuniformCatmullRom(s.z,c.z,u.z,a.z,e,i,n)}else"catmullrom"===this.curveType&&(kw.initCatmullRom(s.x,c.x,u.x,a.x,this.tension),zw.initCatmullRom(s.y,c.y,u.y,a.y,this.tension),Fw.initCatmullRom(s.z,c.z,u.z,a.z,this.tension));return i.set(kw.calc(l),zw.calc(l),Fw.calc(l)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new jp).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Nw(t,e,i,n,r){const o=.5*(n-e),s=.5*(r-i),a=t*t;return(2*i-2*n+o+s)*(t*a)+(-3*i+3*n-2*o-s)*a+o*t+i}function Hw(t,e,i,n){return function(t,e){const i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,n)}function jw(t,e,i,n,r){return function(t,e){const i=1-t;return i*i*i*e}(t,e)+function(t,e){const i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,r)}Bw.prototype.isCatmullRomCurve3=!0;class Gw extends Lw{constructor(t=new Lp,e=new Lp,i=new Lp,n=new Lp){super(),this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new Lp){const i=e,n=this.v0,r=this.v1,o=this.v2,s=this.v3;return i.set(jw(t,n.x,r.x,o.x,s.x),jw(t,n.y,r.y,o.y,s.y)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}Gw.prototype.isCubicBezierCurve=!0;class Uw extends Lw{constructor(t=new jp,e=new jp,i=new jp,n=new jp){super(),this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new jp){const i=e,n=this.v0,r=this.v1,o=this.v2,s=this.v3;return i.set(jw(t,n.x,r.x,o.x,s.x),jw(t,n.y,r.y,o.y,s.y),jw(t,n.z,r.z,o.z,s.z)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}Uw.prototype.isCubicBezierCurve3=!0;class Vw extends Lw{constructor(t=new Lp,e=new Lp){super(),this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Lp){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){const i=e||new Lp;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}Vw.prototype.isLineCurve=!0;class Ww extends Lw{constructor(t=new jp,e=new jp){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=t,this.v2=e}getPoint(t,e=new jp){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Zw extends Lw{constructor(t=new Lp,e=new Lp,i=new Lp){super(),this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new Lp){const i=e,n=this.v0,r=this.v1,o=this.v2;return i.set(Hw(t,n.x,r.x,o.x),Hw(t,n.y,r.y,o.y)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}Zw.prototype.isQuadraticBezierCurve=!0;class qw extends Lw{constructor(t=new jp,e=new jp,i=new jp){super(),this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new jp){const i=e,n=this.v0,r=this.v1,o=this.v2;return i.set(Hw(t,n.x,r.x,o.x),Hw(t,n.y,r.y,o.y),Hw(t,n.z,r.z,o.z)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}qw.prototype.isQuadraticBezierCurve3=!0;class Xw extends Lw{constructor(t=[]){super(),this.type="SplineCurve",this.points=t}getPoint(t,e=new Lp){const i=e,n=this.points,r=(n.length-1)*t,o=Math.floor(r),s=r-o,a=n[0===o?o:o-1],h=n[o],l=n[o>n.length-2?n.length-1:o+1],c=n[o>n.length-3?n.length-1:o+2];return i.set(Nw(s,a.x,h.x,l.x,c.x),Nw(s,a.y,h.y,l.y,c.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new Lp).fromArray(i))}return this}}Xw.prototype.isSplineCurve=!0;var Yw=Object.freeze({__proto__:null,ArcCurve:Ow,CatmullRomCurve3:Bw,CubicBezierCurve:Gw,CubicBezierCurve3:Uw,EllipseCurve:Rw,LineCurve:Vw,LineCurve3:Ww,QuadraticBezierCurve:Zw,QuadraticBezierCurve3:qw,SplineCurve:Xw});class Jw extends Lw{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Vw(e,t))}getPoint(t){const e=t*this.getLength(),i=this.getCurveLengths();let n=0;for(;n<i.length;){if(i[n]>=e){const t=i[n]-e,r=this.curves[n],o=r.getLength(),s=0===o?0:1-t/o;return r.getPointAt(s)}n++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,n=this.curves.length;i<n;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const o=r[n],s=o&&o.isEllipseCurve?2*t:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?t*o.points.length:t,a=o.getPoints(s);for(let t=0;t<a.length;t++){const n=a[t];i&&i.equals(n)||(e.push(n),i=n)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,i=this.curves.length;e<i;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push((new Yw[i.type]).fromJSON(i))}return this}}class Qw extends Jw{constructor(t){super(),this.type="Path",this.currentPoint=new Lp,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,i=t.length;e<i;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const i=new Vw(this.currentPoint.clone(),new Lp(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,i,n){const r=new Zw(this.currentPoint.clone(),new Lp(t,e),new Lp(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(t,e,i,n,r,o){const s=new Gw(this.currentPoint.clone(),new Lp(t,e),new Lp(i,n),new Lp(r,o));return this.curves.push(s),this.currentPoint.set(r,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),i=new Xw(e);return this.curves.push(i),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,i,n,r,o){const s=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(t+s,e+a,i,n,r,o),this}absarc(t,e,i,n,r,o){return this.absellipse(t,e,i,i,n,r,o),this}ellipse(t,e,i,n,r,o,s,a){const h=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(t+h,e+l,i,n,r,o,s,a),this}absellipse(t,e,i,n,r,o,s,a){const h=new Rw(t,e,i,n,r,o,s,a);if(this.curves.length>0){const t=h.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(h);const l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Kw extends Qw{constructor(t){super(t),this.uuid=Ap.generateUUID(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,n=this.holes.length;i<n;i++)e[i]=this.holes[i].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,i=this.holes.length;e<i;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push((new Qw).fromJSON(i))}return this}}class $w extends Vf{constructor(t,e=1){super(),this.type="Light",this.color=new fm(t),this.intensity=e}copy(t){return super.copy(t),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}$w.prototype.isLight=!0;class tb extends $w{constructor(t,e,i){super(t,i),this.type="HemisphereLight",this.position.copy(Vf.DefaultUp),this.updateMatrix(),this.groundColor=new fm(e)}copy(t){return $w.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}tb.prototype.isHemisphereLight=!0;const eb=new _f,ib=new jp,nb=new jp;class rb{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new Lp(512,512),this.map=null,this.mapPass=null,this.matrix=new _f,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new wg,this._frameExtents=new Lp(1,1),this._viewportCount=1,this._viewports=[new Fp(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;ib.setFromMatrixPosition(t.matrixWorld),e.position.copy(ib),nb.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(nb),e.updateMatrixWorld(),eb.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(eb),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(e.projectionMatrix),i.multiply(e.matrixWorldInverse)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class ob extends rb{constructor(){super(new pg(50,1,.5,500)),this.focus=1}updateMatrices(t){const e=this.camera,i=2*Ap.RAD2DEG*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;i===e.fov&&n===e.aspect&&r===e.far||(e.fov=i,e.aspect=n,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}ob.prototype.isSpotLightShadow=!0;class sb extends $w{constructor(t,e,i=0,n=Math.PI/3,r=0,o=1){super(t,e),this.type="SpotLight",this.position.copy(Vf.DefaultUp),this.updateMatrix(),this.target=new Vf,this.distance=i,this.angle=n,this.penumbra=r,this.decay=o,this.shadow=new ob}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}copy(t){return super.copy(t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}sb.prototype.isSpotLight=!0;const ab=new _f,hb=new jp,lb=new jp;class cb extends rb{constructor(){super(new pg(90,1,.5,500)),this._frameExtents=new Lp(4,2),this._viewportCount=6,this._viewports=[new Fp(2,1,1,1),new Fp(0,1,1,1),new Fp(3,1,1,1),new Fp(1,1,1,1),new Fp(3,0,1,1),new Fp(1,0,1,1)],this._cubeDirections=[new jp(1,0,0),new jp(-1,0,0),new jp(0,0,1),new jp(0,0,-1),new jp(0,1,0),new jp(0,-1,0)],this._cubeUps=[new jp(0,1,0),new jp(0,1,0),new jp(0,1,0),new jp(0,1,0),new jp(0,0,1),new jp(0,0,-1)]}updateMatrices(t,e=0){const i=this.camera,n=this.matrix,r=t.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),hb.setFromMatrixPosition(t.matrixWorld),i.position.copy(hb),lb.copy(i.position),lb.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(lb),i.updateMatrixWorld(),n.makeTranslation(-hb.x,-hb.y,-hb.z),ab.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ab)}}cb.prototype.isPointLightShadow=!0;class ub extends $w{constructor(t,e,i=0,n=1){super(t,e),this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new cb}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}copy(t){return super.copy(t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}ub.prototype.isPointLight=!0;class db extends dg{constructor(t=-1,e=1,i=1,n=-1,r=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,r,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,o=i+t,s=n+e,a=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,o=r+t*this.view.width,s-=e*this.view.offsetY,a=s-e*this.view.height}this.projectionMatrix.makeOrthographic(r,o,s,a,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=Vf.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}db.prototype.isOrthographicCamera=!0;class pb extends rb{constructor(){super(new db(-5,5,5,-5,.5,500))}}pb.prototype.isDirectionalLightShadow=!0;class fb extends $w{constructor(t,e){super(t,e),this.type="DirectionalLight",this.position.copy(Vf.DefaultUp),this.updateMatrix(),this.target=new Vf,this.shadow=new pb}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}fb.prototype.isDirectionalLight=!0;class mb extends $w{constructor(t,e){super(t,e),this.type="AmbientLight"}}mb.prototype.isAmbientLight=!0;class gb extends $w{constructor(t,e,i=10,n=10){super(t,e),this.type="RectAreaLight",this.width=i,this.height=n}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}gb.prototype.isRectAreaLight=!0;class vb{constructor(){this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new jp)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,n=t.y,r=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*n),e.addScaledVector(o[2],.488603*r),e.addScaledVector(o[3],.488603*i),e.addScaledVector(o[4],i*n*1.092548),e.addScaledVector(o[5],n*r*1.092548),e.addScaledVector(o[6],.315392*(3*r*r-1)),e.addScaledVector(o[7],i*r*1.092548),e.addScaledVector(o[8],.546274*(i*i-n*n)),e}getIrradianceAt(t,e){const i=t.x,n=t.y,r=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],1.023328*n),e.addScaledVector(o[2],1.023328*r),e.addScaledVector(o[3],1.023328*i),e.addScaledVector(o[4],.858086*i*n),e.addScaledVector(o[5],.858086*n*r),e.addScaledVector(o[6],.743125*r*r-.247708),e.addScaledVector(o[7],.858086*i*r),e.addScaledVector(o[8],.429043*(i*i-n*n)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this}toArray(t=[],e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}static getBasisAt(t,e){const i=t.x,n=t.y,r=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*r,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*i*r,e[8]=.546274*(i*i-n*n)}}vb.prototype.isSphericalHarmonics3=!0;class yb extends $w{constructor(t=new vb,e=1){super(void 0,e),this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}yb.prototype.isLightProbe=!0;class _b extends bw{constructor(t){super(t),this.textures={}}load(t,e,i,n){const r=this,o=new Sw(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)}parse(t){const e=this.textures;function i(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}const n=new nw[t.type];if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&void 0!==n.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.sheen&&(n.sheen=(new fm).setHex(t.sheen)),void 0!==t.emissive&&void 0!==n.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==n.specular&&n.specular.setHex(t.specular),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearcoat&&(n.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(n.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.flatShading&&(n.flatShading=t.flatShading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.combine&&(n.combine=t.combine),void 0!==t.side&&(n.side=t.side),void 0!==t.shadowSide&&(n.shadowSide=t.shadowSide),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(n.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(n.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(n.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(n.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(n.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(n.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(n.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(n.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(n.rotation=t.rotation),1!==t.linewidth&&(n.linewidth=t.linewidth),void 0!==t.dashSize&&(n.dashSize=t.dashSize),void 0!==t.gapSize&&(n.gapSize=t.gapSize),void 0!==t.scale&&(n.scale=t.scale),void 0!==t.polygonOffset&&(n.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(n.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(n.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.skinning&&(n.skinning=t.skinning),void 0!==t.morphTargets&&(n.morphTargets=t.morphTargets),void 0!==t.morphNormals&&(n.morphNormals=t.morphNormals),void 0!==t.dithering&&(n.dithering=t.dithering),void 0!==t.alphaToCoverage&&(n.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(n.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.vertexTangents&&(n.vertexTangents=t.vertexTangents),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.toneMapped&&(n.toneMapped=t.toneMapped),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?n.vertexColors=t.vertexColors>0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(n.uniforms[e]={},r.type){case"t":n.uniforms[e].value=i(r.value);break;case"c":n.uniforms[e].value=(new fm).setHex(r.value);break;case"v2":n.uniforms[e].value=(new Lp).fromArray(r.value);break;case"v3":n.uniforms[e].value=(new jp).fromArray(r.value);break;case"v4":n.uniforms[e].value=(new Fp).fromArray(r.value);break;case"m3":n.uniforms[e].value=(new Rp).fromArray(r.value);break;case"m4":n.uniforms[e].value=(new _f).fromArray(r.value);break;default:n.uniforms[e].value=r.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)n.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(n.flatShading=1===t.shading),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new Lp).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new Lp).fromArray(t.clearcoatNormalScale)),void 0!==t.transmission&&(n.transmission=t.transmission),void 0!==t.transmissionMap&&(n.transmissionMap=i(t.transmissionMap)),n}setTextures(t){return this.textures=t,this}}const xb={decodeText:function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let i=0,n=t.length;i<n;i++)e+=String.fromCharCode(t[i]);try{return decodeURIComponent(escape(e))}catch(t){return e}},extractUrlBase:function(t){const e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)}};function wb(){Nm.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}function bb(t,e,i,n){"number"==typeof i&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),ym.call(this,t,e,i),this.meshPerAttribute=n||1}wb.prototype=Object.assign(Object.create(Nm.prototype),{constructor:wb,isInstancedBufferGeometry:!0,copy:function(t){return Nm.prototype.copy.call(this,t),this.instanceCount=t.instanceCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const t=Nm.prototype.toJSON.call(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}),bb.prototype=Object.assign(Object.create(ym.prototype),{constructor:bb,isInstancedBufferAttribute:!0,copy:function(t){return ym.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){const t=ym.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}});class Mb extends bw{constructor(t){super(t)}load(t,e,i,n){const r=this,o=new Sw(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)}parse(t){const e={},i={};function n(t,n){if(void 0!==e[n])return e[n];const r=t.interleavedBuffers[n],o=function(t,e){if(void 0!==i[e])return i[e];const n=t.arrayBuffers,r=n[e],o=new Uint32Array(r).buffer;return i[e]=o,o}(t,r.buffer),s=new Gy(Rm(r.type,o),r.stride);return s.uuid=r.uuid,e[n]=s,s}const r=t.isInstancedBufferGeometry?new wb:new Nm,o=t.data.index;if(void 0!==o){const t=Rm(o.type,o.array);r.setIndex(new ym(t,1))}const s=t.data.attributes;for(const e in s){const i=s[e];let o;if(i.isInterleavedBufferAttribute){o=new Vy(n(t.data,i.data),i.itemSize,i.offset,i.normalized)}else{const t=Rm(i.type,i.array);o=new(i.isInstancedBufferAttribute?bb:ym)(t,i.itemSize,i.normalized)}void 0!==i.name&&(o.name=i.name),void 0!==i.usage&&o.setUsage(i.usage),void 0!==i.updateRange&&(o.updateRange.offset=i.updateRange.offset,o.updateRange.count=i.updateRange.count),r.setAttribute(e,o)}const a=t.data.morphAttributes;if(a)for(const e in a){const i=a[e],o=[];for(let e=0,r=i.length;e<r;e++){const r=i[e];let s;if(r.isInterleavedBufferAttribute){s=new Vy(n(t.data,r.data),r.itemSize,r.offset,r.normalized)}else{s=new ym(Rm(r.type,r.array),r.itemSize,r.normalized)}void 0!==r.name&&(s.name=r.name),o.push(s)}r.morphAttributes[e]=o}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const h=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==h)for(let t=0,e=h.length;t!==e;++t){const e=h[t];r.addGroup(e.start,e.count,e.materialIndex)}const l=t.data.boundingSphere;if(void 0!==l){const t=new jp;void 0!==l.center&&t.fromArray(l.center),r.boundingSphere=new cf(t,l.radius)}return t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}const Sb={UVMapping:Pu,CubeReflectionMapping:Au,CubeRefractionMapping:Lu,EquirectangularReflectionMapping:Ru,EquirectangularRefractionMapping:Ou,CubeUVReflectionMapping:Du,CubeUVRefractionMapping:Iu},Tb={RepeatWrapping:ku,ClampToEdgeWrapping:zu,MirroredRepeatWrapping:Fu},Eb={NearestFilter:Bu,NearestMipmapNearestFilter:Nu,NearestMipmapLinearFilter:Hu,LinearFilter:ju,LinearMipmapNearestFilter:Gu,LinearMipmapLinearFilter:Uu};function Cb(t){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),bw.call(this,t),this.options={premultiplyAlpha:"none"}}Cb.prototype=Object.assign(Object.create(bw.prototype),{constructor:Cb,isImageBitmapLoader:!0,setOptions:function(t){return this.options=t,this},load:function(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,o=_w.get(t);if(void 0!==o)return r.manager.itemStart(t),setTimeout((function(){e&&e(o),r.manager.itemEnd(t)}),0),o;const s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,fetch(t,s).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(i){_w.add(t,i),e&&e(i),r.manager.itemEnd(t)})).catch((function(e){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)})),r.manager.itemStart(t)}});class Pb{constructor(){this.type="ShapePath",this.color=new fm,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Qw,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this}bezierCurveTo(t,e,i,n,r,o){return this.currentPath.bezierCurveTo(t,e,i,n,r,o),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t,e){function i(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],r=new Kw;r.curves=n.curves,e.push(r)}return e}function n(t,e){const i=e.length;let n=!1;for(let r=i-1,o=0;o<i;r=o++){let i=e[r],s=e[o],a=s.x-i.x,h=s.y-i.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(i=e[o],a=-a,s=e[r],h=-h),t.y<i.y||t.y>s.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=h*(t.x-i.x)-a*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(s.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=s.x)return!0}}return n}const r=Px.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return i(o);let s,a,h;const l=[];if(1===o.length)return a=o[0],h=new Kw,h.curves=a.curves,l.push(h),l;let c=!r(o[0].getPoints());c=t?!c:c;const u=[],d=[];let p,f,m=[],g=0;d[g]=void 0,m[g]=[];for(let e=0,i=o.length;e<i;e++)a=o[e],p=a.getPoints(),s=r(p),s=t?!s:s,s?(!c&&d[g]&&g++,d[g]={s:new Kw,p:p},d[g].s.curves=a.curves,c&&g++,m[g]=[]):m[g].push({h:a,p:p[0]});if(!d[0])return i(o);if(d.length>1){let t=!1;const e=[];for(let t=0,e=d.length;t<e;t++)u[t]=[];for(let i=0,r=d.length;i<r;i++){const r=m[i];for(let o=0;o<r.length;o++){const s=r[o];let a=!0;for(let r=0;r<d.length;r++)n(s.p,d[r].p)&&(i!==r&&e.push({froms:i,tos:r,hole:o}),a?(a=!1,u[r].push(s)):t=!0);a&&u[i].push(s)}}e.length>0&&(t||(m=u))}for(let t=0,e=d.length;t<e;t++){h=d[t].s,l.push(h),f=m[t];for(let t=0,e=f.length;t<e;t++)h.holes.push(f[t].h)}return l}}class Ab{constructor(t){this.type="Font",this.data=t}generateShapes(t,e=100){const i=[],n=function(t,e,i){const n=Array.from(t),r=e/i.resolution,o=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,s=[];let a=0,h=0;for(let t=0;t<n.length;t++){const e=n[t];if("\n"===e)a=0,h-=o;else{const t=Lb(e,r,a,h,i);a+=t.offsetX,s.push(t.path)}}return s}(t,e,this.data);for(let t=0,e=n.length;t<e;t++)Array.prototype.push.apply(i,n[t].toShapes());return i}}function Lb(t,e,i,n,r){const o=r.glyphs[t]||r.glyphs["?"];if(!o)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+r.familyName+".");const s=new Pb;let a,h,l,c,u,d,p,f;if(o.o){const t=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let r=0,o=t.length;r<o;){switch(t[r++]){case"m":a=t[r++]*e+i,h=t[r++]*e+n,s.moveTo(a,h);break;case"l":a=t[r++]*e+i,h=t[r++]*e+n,s.lineTo(a,h);break;case"q":l=t[r++]*e+i,c=t[r++]*e+n,u=t[r++]*e+i,d=t[r++]*e+n,s.quadraticCurveTo(u,d,l,c);break;case"b":l=t[r++]*e+i,c=t[r++]*e+n,u=t[r++]*e+i,d=t[r++]*e+n,p=t[r++]*e+i,f=t[r++]*e+n,s.bezierCurveTo(u,d,p,f,l,c)}}}return{offsetX:o.ha*e,path:s}}Ab.prototype.isFont=!0;let Rb;const Ob={getContext:function(){return void 0===Rb&&(Rb=new(window.AudioContext||window.webkitAudioContext)),Rb},setContext:function(t){Rb=t}};class Db extends bw{constructor(t){super(t)}load(t,e,i,n){const r=this,o=new Sw(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(i){try{const t=i.slice(0);Ob.getContext().decodeAudioData(t,(function(t){e(t)}))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)}}class Ib extends yb{constructor(t,e,i=1){super(void 0,i);const n=(new fm).set(t),r=(new fm).set(e),o=new jp(n.r,n.g,n.b),s=new jp(r.r,r.g,r.b),a=Math.sqrt(Math.PI),h=a*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(s).multiplyScalar(a),this.sh.coefficients[1].copy(o).sub(s).multiplyScalar(h)}}Ib.prototype.isHemisphereLightProbe=!0;class kb extends yb{constructor(t,e=1){super(void 0,e);const i=(new fm).set(t);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}}kb.prototype.isAmbientLightProbe=!0;const zb=new _f,Fb=new _f;class Bb{constructor(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Nb(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Nb();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Nb(){return("undefined"==typeof performance?Date:performance).now()}const Hb=new jp,jb=new Hp,Gb=new jp,Ub=new jp;class Vb extends Vf{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}const Wb=new jp,Zb=new Hp,qb=new jp,Xb=new jp;class Yb{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}}class Jb{constructor(t,e,i){let n,r,o;switch(this.binding=t,this.valueSize=i,e){case"quaternion":n=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,n=this.valueSize,r=t*n+n;let o=this.cumulativeWeight;if(0===o){for(let t=0;t!==n;++t)i[r+t]=i[t];o=e}else{o+=e;const t=e/o;this._mixBufferRegion(i,r,0,t,n)}this.cumulativeWeight=o}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,n=t*e+e,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(i,n,t,1-r,e)}o>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){s.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let t=i,r=n;t!==r;++t)e[t]=e[n+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,n,r){if(n>=.5)for(let n=0;n!==r;++n)t[e+n]=t[i+n]}_slerp(t,e,i,n){Hp.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,r){const o=this._workIndex*r;Hp.multiplyQuaternionsFlat(t,o,t,e,t,i),Hp.slerpFlat(t,e,t,e,t,o,n)}_lerp(t,e,i,n,r){const o=1-n;for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]*o+t[i+s]*n}}_lerpAdditive(t,e,i,n,r){for(let o=0;o!==r;++o){const r=e+o;t[r]=t[r]+t[i+o]*n}}}const Qb="\\[\\]\\.:\\/",Kb=new RegExp("["+Qb+"]","g"),$b="[^"+Qb+"]",tM="[^"+Qb.replace("\\.","")+"]",eM=/((?:WC+[\/:])*)/.source.replace("WC",$b),iM=/(WCOD+)?/.source.replace("WCOD",tM),nM=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",$b),rM=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",$b),oM=new RegExp("^"+eM+iM+nM+rM+"$"),sM=["material","materials","bones"];function aM(t,e,i){const n=i||hM.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}function hM(t,e,i){this.path=e,this.parsedPath=i||hM.parseTrackName(e),this.node=hM.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}Object.assign(aM.prototype,{getValue:function(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(t,e)},bind:function(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()},unbind:function(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}),Object.assign(hM,{Composite:aM,create:function(t,e,i){return t&&t.isAnimationObjectGroup?new hM.Composite(t,e,i):new hM(t,e,i)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(Kb,"")},parseTrackName:function(t){const e=oM.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==sM.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i},findNode:function(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n<t.length;n++){const r=t[n];if(r.name===e||r.uuid===e)return r;const o=i(r.children);if(o)return o}return null},n=i(t.children);if(n)return n}return null}}),Object.assign(hM.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)t[e++]=i[n]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++]},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let r=e.propertyIndex;if(t||(t=hM.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){let n=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===n){n=e;break}break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==n){if(void 0===t[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[n]}}const o=t[n];if(void 0===o){const i=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",t)}let s=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?s=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(s=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}a=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else void 0!==o.fromArray&&void 0!==o.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(a=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][s]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(hM.prototype,{_getValue_unbound:hM.prototype.getValue,_setValue_unbound:hM.prototype.setValue});class lM{constructor(){this.uuid=Ap.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,o=r.length;let s,a=t.length,h=this.nCachedObjects_;for(let l=0,c=arguments.length;l!==c;++l){const c=arguments[l],u=c.uuid;let d=e[u];if(void 0===d){d=a++,e[u]=d,t.push(c);for(let t=0,e=o;t!==e;++t)r[t].push(new hM(c,i[t],n[t]))}else if(d<h){s=t[d];const a=--h,l=t[a];e[l.uuid]=d,t[d]=l,e[u]=a,t[a]=c;for(let t=0,e=o;t!==e;++t){const e=r[t],o=e[a];let s=e[d];e[d]=o,void 0===s&&(s=new hM(c,i[t],n[t])),e[a]=s}}else t[d]!==s&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let o=0,s=arguments.length;o!==s;++o){const s=arguments[o],a=s.uuid,h=e[a];if(void 0!==h&&h>=r){const o=r++,l=t[o];e[l.uuid]=h,t[h]=l,e[a]=o,t[o]=s;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[o],r=e[h];e[h]=n,e[o]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=t.length;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s].uuid,h=e[a];if(void 0!==h)if(delete e[a],h<r){const s=--r,a=t[s],l=--o,c=t[l];e[a.uuid]=h,t[h]=a,e[c.uuid]=s,t[s]=c,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[s],r=e[l];e[h]=n,e[s]=r,e.pop()}}else{const r=--o,s=t[r];r>0&&(e[s.uuid]=h),t[h]=s,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[h]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const o=this._paths,s=this._parsedPaths,a=this._objects,h=a.length,l=this.nCachedObjects_,c=new Array(h);n=r.length,i[t]=n,o.push(t),s.push(e),r.push(c);for(let i=l,n=a.length;i!==n;++i){const n=a[i];c[i]=new hM(n,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s];e[t[s]]=i,o[i]=a,o.pop(),r[i]=r[s],r.pop(),n[i]=n[s],n.pop()}}}lM.prototype.isAnimationObjectGroup=!0;class cM{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const r=e.tracks,o=r.length,s=new Array(o),a={endingStart:op,endingEnd:op};for(let t=0;t!==o;++t){const e=r[t].createInterpolant(null);s[t]=e,e.settings=a}this._interpolantSettings=a,this._interpolants=s,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){const i=this._clip.duration,n=t._clip.duration,r=n/i,o=i/n;t.warp(1,r,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const n=this._mixer,r=n.time,o=this.timeScale;let s=this._timeScaleInterpolant;null===s&&(s=n._lendControlInterpolant(),this._timeScaleInterpolant=s);const a=s.parameterPositions,h=s.sampleValues;return a[0]=r,a[1]=r+i,h[0]=t/o,h[1]=e/o,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const n=(t-r)*i;if(n<0||0===i)return;this._startTime=null,e=i*n}e*=this._updateTimeScale(t);const o=this._updateTime(e),s=this._updateWeight(t);if(s>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===lp)for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(o),e[i].accumulateAdditive(s);else for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(o),e[i].accumulate(n,s)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,r=this._loopCount;const o=2202===i;if(0===t)return-1===r?n:o&&1==(1&r)?e-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,r+=Math.abs(i);const s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){const e=t<0;this._setEndings(e,!e,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(o&&1==(1&r))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=sp,n.endingEnd=sp):(n.endingStart=t?this.zeroSlopeAtStart?sp:op:ap,n.endingEnd=e?this.zeroSlopeAtEnd?sp:op:ap)}_scheduleFading(t,e,i){const n=this._mixer,r=n.time;let o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);const s=o.parameterPositions,a=o.sampleValues;return s[0]=r,a[0]=e,s[1]=r+t,a[1]=i,this}}class uM extends Ep{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,o=t._propertyBindings,s=t._interpolants,a=i.uuid,h=this._bindingsByRootAndName;let l=h[a];void 0===l&&(l={},h[a]=l);for(let t=0;t!==r;++t){const r=n[t],h=r.name;let c=l[h];if(void 0!==c)o[t]=c;else{if(c=o[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,a,h));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;c=new Jb(hM.create(i,h,n),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,a,h),o[t]=c}s[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,r=this._actionsByClip;let o=r[e];if(void 0===o)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=o;else{const e=o.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),o.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,o=this._actionsByClip,s=o[r],a=s.knownActions,h=a[a.length-1],l=t._byClipCacheIndex;h._byClipCacheIndex=l,a[l]=h,a.pop(),t._byClipCacheIndex=null;delete s.actionByRoot[(t._localRoot||this._root).uuid],0===a.length&&delete o[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,r=this._bindings;let o=n[e];void 0===o&&(o={},n[e]=o),o[i]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,o=this._bindingsByRootAndName,s=o[n],a=e[e.length-1],h=t._cacheIndex;a._cacheIndex=h,e[h]=a,e.pop(),delete s[r],0===Object.keys(s).length&&delete o[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new aw(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r}clipAction(t,e,i){const n=e||this._root,r=n.uuid;let o="string"==typeof t?vw.findByName(n,t):t;const s=null!==o?o.uuid:t,a=this._actionsByClip[s];let h=null;if(void 0===i&&(i=null!==o?o.blendMode:hp),void 0!==a){const t=a.actionByRoot[r];if(void 0!==t&&t.blendMode===i)return t;h=a.knownActions[0],null===o&&(o=h._clip)}if(null===o)return null;const l=new cM(this,o,e,i);return this._bindAction(l,h),this._addInactiveAction(l,s,r),l}existingAction(t,e){const i=e||this._root,n=i.uuid,r="string"==typeof t?vw.findByName(i,t):t,o=r?r.uuid:t,s=this._actionsByClip[o];return void 0!==s&&s.actionByRoot[n]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),o=this._accuIndex^=1;for(let s=0;s!==i;++s){e[s]._update(n,t,r,o)}const s=this._bindings,a=this._nActiveBindings;for(let t=0;t!==a;++t)s[t].apply(o);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const t=r.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const r=n._cacheIndex,o=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,o._cacheIndex=r,e[r]=o,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}uM.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class dM{constructor(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}clone(){return new dM(void 0===this.value.clone?this.value:this.value.clone())}}function pM(t,e,i){Gy.call(this,t,e),this.meshPerAttribute=i||1}function fM(t,e,i,n,r){this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}function mM(t,e,i=0,n=1/0){this.ray=new yf(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new Lf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function gM(t,e){return t.distance-e.distance}function vM(t,e,i,n){if(t.layers.test(e.layers)&&t.raycast(e,i),!0===n){const n=t.children;for(let t=0,r=n.length;t<r;t++)vM(n[t],e,i,!0)}}pM.prototype=Object.assign(Object.create(Gy.prototype),{constructor:pM,isInstancedInterleavedBuffer:!0,copy:function(t){return Gy.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},clone:function(t){const e=Gy.prototype.clone.call(this,t);return e.meshPerAttribute=this.meshPerAttribute,e},toJSON:function(t){const e=Gy.prototype.toJSON.call(this,t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}),Object.defineProperty(fM.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(fM.prototype,{isGLBufferAttribute:!0,setBuffer:function(t){return this.buffer=t,this},setType:function(t,e){return this.type=t,this.elementSize=e,this},setItemSize:function(t){return this.itemSize=t,this},setCount:function(t){return this.count=t,this}}),Object.assign(mM.prototype,{set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)},intersectObject:function(t,e=!1,i=[]){return vM(t,this,i,e),i.sort(gM),i},intersectObjects:function(t,e=!1,i=[]){for(let n=0,r=t.length;n<r;n++)vM(t[n],this,i,e);return i.sort(gM),i}});const yM=new Lp;class _M{constructor(t=new Lp(1/0,1/0),e=new Lp(-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=yM.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return void 0===t&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new Lp),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return void 0===t&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new Lp),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new Lp),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new Lp),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return yM.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}_M.prototype.isBox2=!0;const xM=new jp,wM=new jp;class bM{constructor(t=new jp,e=new jp){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new jp),t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new jp),t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new jp),this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){xM.subVectors(t,this.start),wM.subVectors(this.end,this.start);const i=wM.dot(wM);let n=wM.dot(xM)/i;return e&&(n=Ap.clamp(n,0,1)),n}closestPointToPoint(t,e,i){const n=this.closestPointToPointParameter(t,e);return void 0===i&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new jp),this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}function MM(t){Vf.call(this),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}MM.prototype=Object.create(Vf.prototype),MM.prototype.constructor=MM,MM.prototype.isImmediateRenderObject=!0;const SM=new jp;const TM=new jp,EM=new _f,CM=new _f;class PM extends I_{constructor(t){const e=AM(t),i=new Nm,n=[],r=[],o=new fm(0,0,1),s=new fm(0,1,0);for(let t=0;t<e.length;t++){const i=e[t];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(o.r,o.g,o.b),r.push(s.r,s.g,s.b))}i.setAttribute("position",new Cm(n,3)),i.setAttribute("color",new Cm(r,3));super(i,new T_({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,i=this.geometry,n=i.getAttribute("position");CM.copy(this.root.matrixWorld).invert();for(let t=0,i=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(EM.multiplyMatrices(CM,r.matrixWorld),TM.setFromMatrixPosition(EM),n.setXYZ(i,TM.x,TM.y,TM.z),EM.multiplyMatrices(CM,r.parent.matrixWorld),TM.setFromMatrixPosition(EM),n.setXYZ(i+1,TM.x,TM.y,TM.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}}function AM(t){const e=[];t&&t.isBone&&e.push(t);for(let i=0;i<t.children.length;i++)e.push.apply(e,AM(t.children[i]));return e}const LM=new jp,RM=new fm,OM=new fm;class DM extends I_{constructor(t=10,e=10,i=4473924,n=8947848){i=new fm(i),n=new fm(n);const r=e/2,o=t/e,s=t/2,a=[],h=[];for(let t=0,l=0,c=-s;t<=e;t++,c+=o){a.push(-s,0,c,s,0,c),a.push(c,0,-s,c,0,s);const e=t===r?i:n;e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3}const l=new Nm;l.setAttribute("position",new Cm(a,3)),l.setAttribute("color",new Cm(h,3));super(l,new T_({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}const IM=new jp,kM=new jp,zM=new jp;const FM=new jp,BM=new dg;function NM(t,e,i,n,r,o,s){FM.set(r,o,s).unproject(n);const a=e[t];if(void 0!==a){const t=i.getAttribute("position");for(let e=0,i=a.length;e<i;e++)t.setXYZ(a[e],FM.x,FM.y,FM.z)}}const HM=new Vp;class jM extends I_{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Float32Array(24),r=new Nm;r.setIndex(new ym(i,1)),r.setAttribute("position",new ym(n,3)),super(r,new T_({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&HM.setFromObject(this.object),HM.isEmpty())return;const e=HM.min,i=HM.max,n=this.geometry.attributes.position,r=n.array;r[0]=i.x,r[1]=i.y,r[2]=i.z,r[3]=e.x,r[4]=i.y,r[5]=i.z,r[6]=e.x,r[7]=e.y,r[8]=i.z,r[9]=i.x,r[10]=e.y,r[11]=i.z,r[12]=i.x,r[13]=i.y,r[14]=e.z,r[15]=e.x,r[16]=i.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=i.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t){return I_.prototype.copy.call(this,t),this.object=t.object,this}}const GM=new jp;let UM,VM;class WM extends I_{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new Nm;i.setAttribute("position",new Cm(e,3)),i.setAttribute("color",new Cm([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(i,new T_({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}}const ZM=new Float32Array(1),qM=new Int32Array(ZM.buffer),XM={toHalfFloat:function(t){ZM[0]=t;const e=qM[0];let i=e>>16&32768,n=e>>12&2047;const r=e>>23&255;return r<103?i:r>142?(i|=31744,i|=(255==r?0:1)&&8388607&e,i):r<113?(n|=2048,i|=(n>>114-r)+(n>>113-r&1),i):(i|=r-112<<10|n>>1,i+=1&n,i)}},YM=4,JM=8,QM=Math.pow(2,JM),KM=[.125,.215,.35,.446,.526,.582],$M=JM-YM+1+KM.length,tS=20,eS={[cp]:0,[up]:1,[pp]:2,[mp]:3,[gp]:4,[vp]:5,[dp]:6},iS=new mm({side:jc,depthWrite:!1,depthTest:!1}),nS=new ng(new og,iS),rS=new db,{_lodPlanes:oS,_sizeLods:sS,_sigmas:aS}=mS(),hS=new fm;let lS=null;const cS=(1+Math.sqrt(5))/2,uS=1/cS,dS=[new jp(1,1,1),new jp(-1,1,1),new jp(1,1,-1),new jp(-1,1,-1),new jp(0,cS,uS),new jp(0,cS,-uS),new jp(uS,0,cS),new jp(-uS,0,cS),new jp(cS,uS,0),new jp(-cS,uS,0)];function pS(t){const e=Math.max(t.r,t.g,t.b),i=Math.min(Math.max(Math.ceil(Math.log2(e)),-128),127);t.multiplyScalar(Math.pow(2,-i));return(i+128)/255}function fS(t){return void 0!==t&&t.type===Vu&&(t.encoding===cp||t.encoding===up||t.encoding===dp)}function mS(){const t=[],e=[],i=[];let n=JM;for(let r=0;r<$M;r++){const o=Math.pow(2,n);e.push(o);let s=1/o;r>JM-YM?s=KM[r-JM+YM-1]:0==r&&(s=0),i.push(s);const a=1/(o-1),h=-a/2,l=1+a/2,c=[h,h,l,h,l,l,h,h,l,l,h,l],u=6,d=6,p=3,f=2,m=1,g=new Float32Array(p*d*u),v=new Float32Array(f*d*u),y=new Float32Array(m*d*u);for(let t=0;t<u;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];g.set(n,p*d*t),v.set(c,f*d*t);const r=[t,t,t,t,t,t];y.set(r,m*d*t)}const _=new Nm;_.setAttribute("position",new ym(g,p)),_.setAttribute("uv",new ym(v,f)),_.setAttribute("faceIndex",new ym(y,m)),t.push(_),n>YM&&n--}return{_lodPlanes:t,_sizeLods:e,_sigmas:i}}function gS(t){const e=new Bp(3*QM,3*QM,t);return e.texture.mapping=Du,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function vS(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function yS(){const t=new Lp(1,1);return new Xx({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:t},inputEncoding:{value:eS[cp]},outputEncoding:{value:eS[cp]}},vertexShader:xS(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t${wS()}\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:Uc,depthTest:!1,depthWrite:!1})}function _S(){return new Xx({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:eS[cp]},outputEncoding:{value:eS[cp]}},vertexShader:xS(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t${wS()}\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:Uc,depthTest:!1,depthWrite:!1})}function xS(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function wS(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"}Lw.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Lw.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Qw.prototype.fromPoints=function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)},DM.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},PM.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},bw.prototype.extractUrlBase=function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),xb.extractUrlBase(t)},bw.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},_M.prototype.center=function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},_M.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},_M.prototype.isIntersectionBox=function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},_M.prototype.size=function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)},Vp.prototype.center=function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Vp.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Vp.prototype.isIntersectionBox=function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},Vp.prototype.isIntersectionSphere=function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},Vp.prototype.size=function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)},cf.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},wg.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)},bM.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Ap.random16=function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},Ap.nearestPowerOfTwo=function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),Ap.floorPowerOfTwo(t)},Ap.nextPowerOfTwo=function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),Ap.ceilPowerOfTwo(t)},Rp.prototype.flattenToArrayOffset=function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},Rp.prototype.multiplyVector3=function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},Rp.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},Rp.prototype.applyToBufferAttribute=function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},Rp.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},Rp.prototype.getInverse=function(t){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()},_f.prototype.extractPosition=function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},_f.prototype.flattenToArrayOffset=function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},_f.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new jp).setFromMatrixColumn(this,3)},_f.prototype.setRotationFromQuaternion=function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},_f.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},_f.prototype.multiplyVector3=function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},_f.prototype.multiplyVector4=function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},_f.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},_f.prototype.rotateAxis=function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},_f.prototype.crossVector=function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},_f.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},_f.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},_f.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},_f.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},_f.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},_f.prototype.applyToBufferAttribute=function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},_f.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},_f.prototype.makeFrustum=function(t,e,i,n,r,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,n,i,r,o)},_f.prototype.getInverse=function(t){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()},Xf.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},Hp.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Hp.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},yf.prototype.isIntersectionBox=function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},yf.prototype.isIntersectionPlane=function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},yf.prototype.isIntersectionSphere=function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},om.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},om.prototype.barycoordFromPoint=function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},om.prototype.midpoint=function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},om.prototypenormal=function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},om.prototype.plane=function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)},om.barycoordFromPoint=function(t,e,i,n,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),om.getBarycoord(t,e,i,n,r)},om.normal=function(t,e,i,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),om.getNormal(t,e,i,n)},Kw.prototype.extractAllPoints=function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},Kw.prototype.extrude=function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Rx(this,t)},Kw.prototype.makeGeometry=function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Bx(this,t)},Lp.prototype.fromAttribute=function(t,e,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},Lp.prototype.distanceToManhattan=function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},Lp.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},jp.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},jp.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},jp.prototype.getPositionFromMatrix=function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},jp.prototype.getScaleFromMatrix=function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},jp.prototype.getColumnFromMatrix=function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},jp.prototype.applyProjection=function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},jp.prototype.fromAttribute=function(t,e,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},jp.prototype.distanceToManhattan=function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},jp.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Fp.prototype.fromAttribute=function(t,e,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},Fp.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Vf.prototype.getChildByName=function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},Vf.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},Vf.prototype.translate=function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},Vf.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},Vf.prototype.applyMatrix=function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)},Object.defineProperties(Vf.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),ng.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(ng.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),m_.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(Lw.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),pg.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties($w.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(ym.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Sp},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Sp)}}}),ym.prototype.setDynamic=function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?Sp:Mp),this},ym.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},ym.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},Nm.prototype.addIndex=function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},Nm.prototype.addAttribute=function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new ym(arguments[1],arguments[2])))},Nm.prototype.addDrawCall=function(t,e,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},Nm.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},Nm.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},Nm.prototype.removeAttribute=function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},Nm.prototype.applyMatrix=function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)},Object.defineProperties(Nm.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(wb.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(t){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=t}}}),Object.defineProperties(mM.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(t){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=t}}}),Object.defineProperties(Gy.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===Sp},set:function(t){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(t)}}}),Gy.prototype.setDynamic=function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?Sp:Mp),this},Gy.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},Rx.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},Rx.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},Rx.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},jy.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},dM.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(am.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new fm}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}}}),Object.defineProperties(Jx.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(t){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=t}}}),Object.defineProperties(ug.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Fy.prototype.clearTarget=function(t,e,i,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,i,n)},Fy.prototype.animate=function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},Fy.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},Fy.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},Fy.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},Fy.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},Fy.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},Fy.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},Fy.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},Fy.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},Fy.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},Fy.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},Fy.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},Fy.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},Fy.prototype.enableScissorTest=function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},Fy.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},Fy.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},Fy.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},Fy.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},Fy.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},Fy.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},Fy.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},Fy.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},Fy.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},Fy.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(Fy.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===t?up:cp}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Py.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Bp.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Vb.prototype.load=function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const e=this;return(new Db).load(t,(function(t){e.setBuffer(t)})),this},Yb.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},mg.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)},mg.prototype.clear=function(t,e,i,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,i,n)},Dp.crossOrigin=void 0,Dp.loadTexture=function(t,e,i,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new Aw;r.setCrossOrigin(this.crossOrigin);const o=r.load(t,i,void 0,n);return e&&(o.mapping=e),o},Dp.loadTextureCube=function(t,e,i,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new Cw;r.setCrossOrigin(this.crossOrigin);const o=r.load(t,i,void 0,n);return e&&(o.mapping=e),o},Dp.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},Dp.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};const bS={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Dc}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Dc);var MS=Object.freeze({__proto__:null,ACESFilmicToneMapping:Eu,AddEquation:Yc,AddOperation:wu,AdditiveAnimationBlendMode:lp,AdditiveBlending:Wc,AlphaFormat:id,AlwaysDepth:du,AlwaysStencilFunc:bp,AmbientLight:mb,AmbientLightProbe:kb,AnimationClip:vw,AnimationLoader:class extends bw{constructor(t){super(t)}load(t,e,i,n){const r=this,o=new Sw(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)}parse(t){const e=[];for(let i=0;i<t.length;i++){const n=vw.parse(t[i]);e.push(n)}return e}},AnimationMixer:uM,AnimationObjectGroup:lM,AnimationUtils:rw,ArcCurve:Ow,ArrayCamera:Oy,ArrowHelper:class extends Vf{constructor(t=new jp(0,0,1),e=new jp(0,0,0),i=1,n=16776960,r=.2*i,o=.2*r){super(),this.type="ArrowHelper",void 0===UM&&(UM=new Nm,UM.setAttribute("position",new Cm([0,0,0,0,1,0],3)),VM=new X_(0,.5,1,5,1),VM.translate(0,-.5,0)),this.position.copy(e),this.line=new R_(UM,new T_({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ng(VM,new mm({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,r,o)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{GM.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(GM,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}},Audio:Vb,AudioAnalyser:Yb,AudioContext:Ob,AudioListener:class extends Vf{constructor(){super(),this.type="AudioListener",this.context=Ob.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Bb}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Hb,jb,Gb),Ub.set(0,0,-1).applyQuaternion(jb),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Hb.x,t),e.positionY.linearRampToValueAtTime(Hb.y,t),e.positionZ.linearRampToValueAtTime(Hb.z,t),e.forwardX.linearRampToValueAtTime(Ub.x,t),e.forwardY.linearRampToValueAtTime(Ub.y,t),e.forwardZ.linearRampToValueAtTime(Ub.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)}else e.setPosition(Hb.x,Hb.y,Hb.z),e.setOrientation(Ub.x,Ub.y,Ub.z,i.x,i.y,i.z)}},AudioLoader:Db,AxesHelper:WM,AxisHelper:function(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new WM(t)},BackSide:jc,BasicDepthPacking:3200,BasicShadowMap:0,BinaryTextureLoader:function(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Pw(t)},Bone:g_,BooleanKeyframeTrack:cw,BoundingBoxHelper:function(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new jM(t,e)},Box2:_M,Box3:Vp,Box3Helper:class extends I_{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),n=new Nm;n.setIndex(new ym(i,1)),n.setAttribute("position",new Cm([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(n,new T_({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}},BoxBufferGeometry:og,BoxGeometry:og,BoxHelper:jM,BufferAttribute:ym,BufferGeometry:Nm,BufferGeometryLoader:Mb,ByteType:Wu,Cache:_w,Camera:dg,CameraHelper:class extends I_{constructor(t){const e=new Nm,i=new T_({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],o={},s=new fm(16755200),a=new fm(16711680),h=new fm(43775),l=new fm(16777215),c=new fm(3355443);function u(t,e,i){d(t,i),d(e,i)}function d(t,e){n.push(0,0,0),r.push(e.r,e.g,e.b),void 0===o[t]&&(o[t]=[]),o[t].push(n.length/3-1)}u("n1","n2",s),u("n2","n4",s),u("n4","n3",s),u("n3","n1",s),u("f1","f2",s),u("f2","f4",s),u("f4","f3",s),u("f3","f1",s),u("n1","f1",s),u("n2","f2",s),u("n3","f3",s),u("n4","f4",s),u("p","n1",a),u("p","n2",a),u("p","n3",a),u("p","n4",a),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h),u("c","t",l),u("p","c",c),u("cn1","cn2",c),u("cn3","cn4",c),u("cf1","cf2",c),u("cf3","cf4",c),e.setAttribute("position",new Cm(n,3)),e.setAttribute("color",new Cm(r,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){const t=this.geometry,e=this.pointMap;BM.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),NM("c",e,t,BM,0,0,-1),NM("t",e,t,BM,0,0,1),NM("n1",e,t,BM,-1,-1,-1),NM("n2",e,t,BM,1,-1,-1),NM("n3",e,t,BM,-1,1,-1),NM("n4",e,t,BM,1,1,-1),NM("f1",e,t,BM,-1,-1,1),NM("f2",e,t,BM,1,-1,1),NM("f3",e,t,BM,-1,1,1),NM("f4",e,t,BM,1,1,1),NM("u1",e,t,BM,.7,1.1,-1),NM("u2",e,t,BM,-.7,1.1,-1),NM("u3",e,t,BM,0,2,-1),NM("cf1",e,t,BM,-1,0,1),NM("cf2",e,t,BM,1,0,1),NM("cf3",e,t,BM,0,-1,1),NM("cf4",e,t,BM,0,1,1),NM("cn1",e,t,BM,-1,0,-1),NM("cn2",e,t,BM,1,0,-1),NM("cn3",e,t,BM,0,-1,-1),NM("cn4",e,t,BM,0,1,-1),t.getAttribute("position").needsUpdate=!0}},CanvasRenderer:function(){console.error("THREE.CanvasRenderer has been removed")},CanvasTexture:W_,CatmullRomCurve3:Bw,CineonToneMapping:Tu,CircleBufferGeometry:q_,CircleGeometry:q_,ClampToEdgeWrapping:zu,Clock:Bb,Color:fm,ColorKeyframeTrack:uw,CompressedTexture:V_,CompressedTextureLoader:Tw,ConeBufferGeometry:Y_,ConeGeometry:Y_,CubeCamera:mg,CubeReflectionMapping:Au,CubeRefractionMapping:Lu,CubeTexture:gg,CubeTextureLoader:Cw,CubeUVReflectionMapping:Du,CubeUVRefractionMapping:Iu,CubicBezierCurve:Gw,CubicBezierCurve3:Uw,CubicInterpolant:sw,CullFaceBack:kc,CullFaceFront:zc,CullFaceFrontBack:3,CullFaceNone:Ic,Curve:Lw,CurvePath:Jw,CustomBlending:Xc,CustomToneMapping:Cu,CylinderBufferGeometry:X_,CylinderGeometry:X_,Cylindrical:class{constructor(t=1,e=0,i=0){return this.radius=t,this.theta=e,this.y=i,this}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return(new this.constructor).copy(this)}},DataTexture:yg,DataTexture2DArray:Gg,DataTexture3D:Ug,DataTextureLoader:Pw,DataUtils:XM,DecrementStencilOp:7683,DecrementWrapStencilOp:34056,DefaultLoadingManager:ww,DepthFormat:hd,DepthStencilFormat:ld,DepthTexture:Z_,DirectionalLight:fb,DirectionalLightHelper:class extends Vf{constructor(t,e,i){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,void 0===e&&(e=1);let n=new Nm;n.setAttribute("position",new Cm([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new T_({fog:!1,toneMapped:!1});this.lightPlane=new R_(n,r),this.add(this.lightPlane),n=new Nm,n.setAttribute("position",new Cm([0,0,0,0,0,1],3)),this.targetLine=new R_(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){IM.setFromMatrixPosition(this.light.matrixWorld),kM.setFromMatrixPosition(this.light.target.matrixWorld),zM.subVectors(kM,IM),this.lightPlane.lookAt(kM),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(kM),this.targetLine.scale.z=zM.length()}},DiscreteInterpolant:hw,DodecahedronBufferGeometry:Q_,DodecahedronGeometry:Q_,DoubleSide:Gc,DstAlphaFactor:su,DstColorFactor:hu,DynamicBufferAttribute:function(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new ym(t,e).setUsage(Sp)},DynamicCopyUsage:35050,DynamicDrawUsage:Sp,DynamicReadUsage:35049,EdgesGeometry:ix,EdgesHelper:function(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new I_(new ix(t.geometry),new T_({color:void 0!==e?e:16777215}))},EllipseCurve:Rw,EqualDepth:mu,EqualStencilFunc:514,EquirectangularReflectionMapping:Ru,EquirectangularRefractionMapping:Ou,Euler:Af,EventDispatcher:Ep,ExtrudeBufferGeometry:Rx,ExtrudeGeometry:Rx,FaceColors:1,FileLoader:Sw,FlatShading:1,Float16BufferAttribute:Em,Float32Attribute:function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new Cm(t,e)},Float32BufferAttribute:Cm,Float64Attribute:function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new Pm(t,e)},Float64BufferAttribute:Pm,FloatType:Ju,Fog:Hy,FogExp2:Ny,Font:Ab,FontLoader:class extends bw{constructor(t){super(t)}load(t,e,i,n){const r=this,o=new Sw(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,(function(t){let i;try{i=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(t.substring(65,t.length-2))}const n=r.parse(i);e&&e(n)}),i,n)}parse(t){return new Ab(t)}},FrontSide:Hc,Frustum:wg,GLBufferAttribute:fM,GLSL1:"100",GLSL3:Tp,GammaEncoding:dp,GreaterDepth:vu,GreaterEqualDepth:gu,GreaterEqualStencilFunc:518,GreaterStencilFunc:516,GridHelper:DM,Group:Dy,HalfFloatType:Qu,HemisphereLight:tb,HemisphereLightHelper:class extends Vf{constructor(t,e,i){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;const n=new kx(e);n.rotateY(.5*Math.PI),this.material=new mm({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),o=new Float32Array(3*r.count);n.setAttribute("color",new ym(o,3)),this.add(new ng(n,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");RM.copy(this.light.color),OM.copy(this.light.groundColor);for(let t=0,i=e.count;t<i;t++){const n=t<i/2?RM:OM;e.setXYZ(t,n.r,n.g,n.b)}e.needsUpdate=!0}t.lookAt(LM.setFromMatrixPosition(this.light.matrixWorld).negate())}},HemisphereLightProbe:Ib,IcosahedronBufferGeometry:Dx,IcosahedronGeometry:Dx,ImageBitmapLoader:Cb,ImageLoader:Ew,ImageUtils:Dp,ImmediateRenderObject:MM,IncrementStencilOp:7682,IncrementWrapStencilOp:34055,InstancedBufferAttribute:bb,InstancedBufferGeometry:wb,InstancedInterleavedBuffer:pM,InstancedMesh:S_,Int16Attribute:function(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new bm(t,e)},Int16BufferAttribute:bm,Int32Attribute:function(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new Sm(t,e)},Int32BufferAttribute:Sm,Int8Attribute:function(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new _m(t,e)},Int8BufferAttribute:_m,IntType:Xu,InterleavedBuffer:Gy,InterleavedBufferAttribute:Vy,Interpolant:ow,InterpolateDiscrete:ip,InterpolateLinear:np,InterpolateSmooth:rp,InvertStencilOp:5386,JSONLoader:function(){console.error("THREE.JSONLoader has been removed.")},KeepStencilOp:wp,KeyframeTrack:lw,LOD:l_,LatheBufferGeometry:Ix,LatheGeometry:Ix,Layers:Lf,LensFlare:function(){console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")},LessDepth:pu,LessEqualDepth:fu,LessEqualStencilFunc:515,LessStencilFunc:513,Light:$w,LightProbe:yb,Line:R_,Line3:bM,LineBasicMaterial:T_,LineCurve:Vw,LineCurve3:Ww,LineDashedMaterial:iw,LineLoop:k_,LinePieces:1,LineSegments:I_,LineStrip:0,LinearEncoding:cp,LinearFilter:ju,LinearInterpolant:aw,LinearMipMapLinearFilter:1008,LinearMipMapNearestFilter:1007,LinearMipmapLinearFilter:Uu,LinearMipmapNearestFilter:Gu,LinearToneMapping:Mu,Loader:bw,LoaderUtils:xb,LoadingManager:xw,LogLuvEncoding:fp,LoopOnce:2200,LoopPingPong:2202,LoopRepeat:2201,LuminanceAlphaFormat:sd,LuminanceFormat:od,MOUSE:{LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Material:am,MaterialLoader:_b,Math:Ap,MathUtils:Ap,Matrix3:Rp,Matrix4:_f,MaxEquation:$c,Mesh:ng,MeshBasicMaterial:mm,MeshDepthMaterial:Sy,MeshDistanceMaterial:Ty,MeshFaceMaterial:function(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t},MeshLambertMaterial:tw,MeshMatcapMaterial:ew,MeshNormalMaterial:$x,MeshPhongMaterial:Qx,MeshPhysicalMaterial:Jx,MeshStandardMaterial:Yx,MeshToonMaterial:Kx,MinEquation:Kc,MirroredRepeatWrapping:Fu,MixOperation:xu,MultiMaterial:function(t=[]){return console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),t.isMultiMaterial=!0,t.materials=t,t.clone=function(){return t.slice()},t},MultiplyBlending:qc,MultiplyOperation:_u,NearestFilter:Bu,NearestMipMapLinearFilter:1005,NearestMipMapNearestFilter:1004,NearestMipmapLinearFilter:Hu,NearestMipmapNearestFilter:Nu,NeverDepth:uu,NeverStencilFunc:512,NoBlending:Uc,NoColors:0,NoToneMapping:bu,NormalAnimationBlendMode:hp,NormalBlending:Vc,NotEqualDepth:yu,NotEqualStencilFunc:517,NumberKeyframeTrack:dw,Object3D:Vf,ObjectLoader:class extends bw{constructor(t){super(t)}load(t,e,i,n){const r=this,o=""===this.path?xb.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||o;const s=new Sw(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,(function(i){let o=null;try{o=JSON.parse(i)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const s=o.metadata;void 0!==s&&void 0!==s.type&&"geometry"!==s.type.toLowerCase()?r.parse(o,e):console.error("THREE.ObjectLoader: Can't load "+t)}),i,n)}parse(t,e){const i=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,n),o=this.parseImages(t.images,(function(){void 0!==e&&e(h)})),s=this.parseTextures(t.textures,o),a=this.parseMaterials(t.materials,s),h=this.parseObject(t.object,r,a,i),l=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,l),void 0!==e){let t=!1;for(const e in o)if(o[e]instanceof HTMLImageElement){t=!0;break}!1===t&&e(h)}return h}parseShapes(t){const e={};if(void 0!==t)for(let i=0,n=t.length;i<n;i++){const n=(new Kw).fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},n={};if(e.traverse((function(t){t.isBone&&(n[t.uuid]=t)})),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new __).fromJSON(t[e],n);i[r.uuid]=r}return i}parseGeometries(t,e){const i={};let n;if(void 0!==t){const r=new Mb;for(let o=0,s=t.length;o<s;o++){let s;const a=t[o];switch(a.type){case"PlaneGeometry":case"PlaneBufferGeometry":s=new Zx[a.type](a.width,a.height,a.widthSegments,a.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":s=new Zx[a.type](a.width,a.height,a.depth,a.widthSegments,a.heightSegments,a.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":s=new Zx[a.type](a.radius,a.segments,a.thetaStart,a.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":s=new Zx[a.type](a.radiusTop,a.radiusBottom,a.height,a.radialSegments,a.heightSegments,a.openEnded,a.thetaStart,a.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":s=new Zx[a.type](a.radius,a.height,a.radialSegments,a.heightSegments,a.openEnded,a.thetaStart,a.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":s=new Zx[a.type](a.radius,a.widthSegments,a.heightSegments,a.phiStart,a.phiLength,a.thetaStart,a.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":s=new Zx[a.type](a.radius,a.detail);break;case"RingGeometry":case"RingBufferGeometry":s=new Zx[a.type](a.innerRadius,a.outerRadius,a.thetaSegments,a.phiSegments,a.thetaStart,a.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":s=new Zx[a.type](a.radius,a.tube,a.radialSegments,a.tubularSegments,a.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":s=new Zx[a.type](a.radius,a.tube,a.tubularSegments,a.radialSegments,a.p,a.q);break;case"TubeGeometry":case"TubeBufferGeometry":s=new Zx[a.type]((new Yw[a.path.type]).fromJSON(a.path),a.tubularSegments,a.radius,a.radialSegments,a.closed);break;case"LatheGeometry":case"LatheBufferGeometry":s=new Zx[a.type](a.points,a.segments,a.phiStart,a.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":s=new Zx[a.type](a.vertices,a.indices,a.radius,a.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":n=[];for(let t=0,i=a.shapes.length;t<i;t++){const i=e[a.shapes[t]];n.push(i)}s=new Zx[a.type](n,a.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":n=[];for(let t=0,i=a.shapes.length;t<i;t++){const i=e[a.shapes[t]];n.push(i)}const t=a.options.extrudePath;void 0!==t&&(a.options.extrudePath=(new Yw[t.type]).fromJSON(t)),s=new Zx[a.type](n,a.options);break;case"BufferGeometry":case"InstancedBufferGeometry":s=r.parse(a);break;case"Geometry":console.error('THREE.ObjectLoader: Loading "Geometry" is not supported anymore.');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+a.type+'"');continue}s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),!0===s.isBufferGeometry&&void 0!==a.userData&&(s.userData=a.userData),i[a.uuid]=s}}return i}parseMaterials(t,e){const i={},n={};if(void 0!==t){const r=new _b;r.setTextures(e);for(let e=0,o=t.length;e<o;e++){const o=t[e];if("MultiMaterial"===o.type){const t=[];for(let e=0;e<o.materials.length;e++){const n=o.materials[e];void 0===i[n.uuid]&&(i[n.uuid]=r.parse(n)),t.push(i[n.uuid])}n[o.uuid]=t}else void 0===i[o.uuid]&&(i[o.uuid]=r.parse(o)),n[o.uuid]=i[o.uuid]}}return n}parseAnimations(t){const e={};if(void 0!==t)for(let i=0;i<t.length;i++){const n=t[i],r=vw.parse(n);e[r.uuid]=r}return e}parseImages(t,e){const i=this,n={};let r;function o(t){if("string"==typeof t){const e=t;return function(t){return i.manager.itemStart(t),r.load(t,(function(){i.manager.itemEnd(t)}),void 0,(function(){i.manager.itemError(t),i.manager.itemEnd(t)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:i.resourcePath+e)}return t.data?{data:Rm(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const i=new xw(e);r=new Ew(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],r=i.url;if(Array.isArray(r)){n[i.uuid]=[];for(let t=0,e=r.length;t<e;t++){const e=o(r[t]);null!==e&&(e instanceof HTMLImageElement?n[i.uuid].push(e):n[i.uuid].push(new yg(e.data,e.width,e.height)))}}else{const t=o(i.url);null!==t&&(n[i.uuid]=t)}}}return n}parseTextures(t,e){function i(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const n={};if(void 0!==t)for(let r=0,o=t.length;r<o;r++){const o=t[r];let s;void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===e[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const a=e[o.image];Array.isArray(a)?(s=new gg(a),6===a.length&&(s.needsUpdate=!0)):(s=a&&a.data?new yg(a.data,a.width,a.height):new kp(a),a&&(s.needsUpdate=!0)),s.uuid=o.uuid,void 0!==o.name&&(s.name=o.name),void 0!==o.mapping&&(s.mapping=i(o.mapping,Sb)),void 0!==o.offset&&s.offset.fromArray(o.offset),void 0!==o.repeat&&s.repeat.fromArray(o.repeat),void 0!==o.center&&s.center.fromArray(o.center),void 0!==o.rotation&&(s.rotation=o.rotation),void 0!==o.wrap&&(s.wrapS=i(o.wrap[0],Tb),s.wrapT=i(o.wrap[1],Tb)),void 0!==o.format&&(s.format=o.format),void 0!==o.type&&(s.type=o.type),void 0!==o.encoding&&(s.encoding=o.encoding),void 0!==o.minFilter&&(s.minFilter=i(o.minFilter,Eb)),void 0!==o.magFilter&&(s.magFilter=i(o.magFilter,Eb)),void 0!==o.anisotropy&&(s.anisotropy=o.anisotropy),void 0!==o.flipY&&(s.flipY=o.flipY),void 0!==o.premultiplyAlpha&&(s.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(s.unpackAlignment=o.unpackAlignment),n[o.uuid]=s}return n}parseObject(t,e,i,n){let r,o,s;function a(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function h(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];void 0===i[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),e.push(i[r])}return e}return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),i[t]}}switch(t.type){case"Scene":r=new jy,void 0!==t.background&&Number.isInteger(t.background)&&(r.background=new fm(t.background)),void 0!==t.fog&&("Fog"===t.fog.type?r.fog=new Hy(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(r.fog=new Ny(t.fog.color,t.fog.density)));break;case"PerspectiveCamera":r=new pg(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(r.focus=t.focus),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.filmGauge&&(r.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(r.filmOffset=t.filmOffset),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new db(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(r.zoom=t.zoom),void 0!==t.view&&(r.view=Object.assign({},t.view));break;case"AmbientLight":r=new mb(t.color,t.intensity);break;case"DirectionalLight":r=new fb(t.color,t.intensity);break;case"PointLight":r=new ub(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new gb(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new sb(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":r=new tb(t.color,t.groundColor,t.intensity);break;case"LightProbe":r=(new yb).fromJSON(t);break;case"SkinnedMesh":o=a(t.geometry),s=h(t.material),r=new m_(o,s),void 0!==t.bindMode&&(r.bindMode=t.bindMode),void 0!==t.bindMatrix&&r.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(r.skeleton=t.skeleton);break;case"Mesh":o=a(t.geometry),s=h(t.material),r=new ng(o,s);break;case"InstancedMesh":o=a(t.geometry),s=h(t.material);const e=t.count,i=t.instanceMatrix,n=t.instanceColor;r=new S_(o,s,e),r.instanceMatrix=new ym(new Float32Array(i.array),16),void 0!==n&&(r.instanceColor=new ym(new Float32Array(n.array),n.itemSize));break;case"LOD":r=new l_;break;case"Line":r=new R_(a(t.geometry),h(t.material));break;case"LineLoop":r=new k_(a(t.geometry),h(t.material));break;case"LineSegments":r=new I_(a(t.geometry),h(t.material));break;case"PointCloud":case"Points":r=new j_(a(t.geometry),h(t.material));break;case"Sprite":r=new o_(h(t.material));break;case"Group":r=new Dy;break;case"Bone":r=new g_;break;default:r=new Vf}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(r.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.children){const o=t.children;for(let t=0;t<o.length;t++)r.add(this.parseObject(o[t],e,i,n))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const i=e[t];r.animations.push(n[i])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(r.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const i=e[t],n=r.getObjectByProperty("uuid",i.object);void 0!==n&&r.addLevel(n,i.distance)}}return r}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse((function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const i=e[t.skeleton];void 0===i?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(i,t.bindMatrix)}}))}setTexturePath(t){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(t)}},ObjectSpaceNormalMap:xp,OctahedronBufferGeometry:kx,OctahedronGeometry:kx,OneFactor:eu,OneMinusDstAlphaFactor:au,OneMinusDstColorFactor:lu,OneMinusSrcAlphaFactor:ou,OneMinusSrcColorFactor:nu,OrthographicCamera:db,PCFShadowMap:Fc,PCFSoftShadowMap:Bc,PMREMGenerator:class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=function(t){const e=new Float32Array(t),i=new jp(0,1,0);return new Xx({name:"SphericalGaussianBlur",defines:{n:t},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:eS[cp]},outputEncoding:{value:eS[cp]}},vertexShader:xS(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t${wS()}\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:Uc,depthTest:!1,depthWrite:!1})}(tS),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100){lS=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(t,i,n,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=_S(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=yS(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let t=0;t<oS.length;t++)oS[t].dispose()}_cleanup(t){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(lS),t.scissorTest=!1,vS(t,0,0,t.width,t.height)}_fromTexture(t){lS=this._renderer.getRenderTarget();const e=this._allocateTargets(t);return this._textureToCubeUV(t,e),this._applyPMREM(e),this._cleanup(e),e}_allocateTargets(t){const e={magFilter:Bu,minFilter:Bu,generateMipmaps:!1,type:Vu,format:ad,encoding:fS(t)?t.encoding:pp,depthBuffer:!1},i=gS(e);return i.depthBuffer=!t,this._pingPongRenderTarget=gS(e),i}_compileMaterial(t){const e=new ng(oS[0],t);this._renderer.compile(e,rS)}_sceneToCubeUV(t,e,i,n){const r=new pg(90,1,e,i),o=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],a=this._renderer,h=a.autoClear,l=a.outputEncoding,c=a.toneMapping;a.getClearColor(hS),a.toneMapping=bu,a.outputEncoding=cp,a.autoClear=!1;let u=!1;const d=t.background;if(d){if(d.isColor){iS.color.copy(d).convertSRGBToLinear(),t.background=null;const e=pS(iS.color);iS.opacity=e,u=!0}}else{iS.color.copy(hS).convertSRGBToLinear();const t=pS(iS.color);iS.opacity=t,u=!0}for(let e=0;e<6;e++){const i=e%3;0==i?(r.up.set(0,o[e],0),r.lookAt(s[e],0,0)):1==i?(r.up.set(0,0,o[e]),r.lookAt(0,s[e],0)):(r.up.set(0,o[e],0),r.lookAt(0,0,s[e])),vS(n,i*QM,e>2?QM:0,QM,QM),a.setRenderTarget(n),u&&a.render(nS,r),a.render(t,r)}a.toneMapping=c,a.outputEncoding=l,a.autoClear=h}_textureToCubeUV(t,e){const i=this._renderer;t.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=_S()):null==this._equirectShader&&(this._equirectShader=yS());const n=t.isCubeTexture?this._cubemapShader:this._equirectShader,r=new ng(oS[0],n),o=n.uniforms;o.envMap.value=t,t.isCubeTexture||o.texelSize.value.set(1/t.image.width,1/t.image.height),o.inputEncoding.value=eS[t.encoding],o.outputEncoding.value=eS[e.texture.encoding],vS(e,0,0,3*QM,2*QM),i.setRenderTarget(e),i.render(r,rS)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let e=1;e<$M;e++){const i=Math.sqrt(aS[e]*aS[e]-aS[e-1]*aS[e-1]),n=dS[(e-1)%dS.length];this._blur(t,e-1,e,i,n)}e.autoClear=i}_blur(t,e,i,n,r){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,i,n,"latitudinal",r),this._halfBlur(o,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,o,s){const a=this._renderer,h=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");const l=new ng(oS[n],h),c=h.uniforms,u=sS[i]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,f=isFinite(r)?1+Math.floor(3*p):tS;f>tS&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<tS;++t){const e=t/p,i=Math.exp(-e*e/2);m.push(i),0==t?g+=i:t<f&&(g+=2*i)}for(let t=0;t<m.length;t++)m[t]=m[t]/g;c.envMap.value=t.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===o,s&&(c.poleAxis.value=s),c.dTheta.value=d,c.mipInt.value=JM-i,c.inputEncoding.value=eS[t.texture.encoding],c.outputEncoding.value=eS[t.texture.encoding];const v=sS[n];vS(e,3*Math.max(0,QM-2*v),(0===n?0:2*QM)+2*v*(n>JM-YM?n-JM+YM:0),3*v,2*v),a.setRenderTarget(e),a.render(l,rS)}},ParametricBufferGeometry:zx,ParametricGeometry:zx,Particle:function(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new o_(t)},ParticleBasicMaterial:function(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new z_(t)},ParticleSystem:function(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new j_(t,e)},ParticleSystemMaterial:function(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new z_(t)},Path:Qw,PerspectiveCamera:pg,Plane:Xf,PlaneBufferGeometry:Sg,PlaneGeometry:Sg,PlaneHelper:class extends R_{constructor(t,e=1,i=16776960){const n=i,r=new Nm;r.setAttribute("position",new Cm([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),r.computeBoundingSphere(),super(r,new T_({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const o=new Nm;o.setAttribute("position",new Cm([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),o.computeBoundingSphere(),this.add(new ng(o,new mm({color:n,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){let e=-this.plane.constant;Math.abs(e)<1e-8&&(e=1e-8),this.scale.set(.5*this.size,.5*this.size,e),this.children[0].material.side=e<0?jc:Hc,this.lookAt(this.plane.normal),super.updateMatrixWorld(t)}},PointCloud:function(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new j_(t,e)},PointCloudMaterial:function(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new z_(t)},PointLight:ub,PointLightHelper:class extends ng{constructor(t,e,i){super(new Nx(e,4,2),new mm({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.light.updateMatrixWorld(),this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Points:j_,PointsMaterial:z_,PolarGridHelper:class extends I_{constructor(t=10,e=16,i=8,n=64,r=4473924,o=8947848){r=new fm(r),o=new fm(o);const s=[],a=[];for(let i=0;i<=e;i++){const n=i/e*(2*Math.PI),h=Math.sin(n)*t,l=Math.cos(n)*t;s.push(0,0,0),s.push(h,0,l);const c=1&i?r:o;a.push(c.r,c.g,c.b),a.push(c.r,c.g,c.b)}for(let e=0;e<=i;e++){const h=1&e?r:o,l=t-t/i*e;for(let t=0;t<n;t++){let e=t/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l;s.push(i,0,r),a.push(h.r,h.g,h.b),e=(t+1)/n*(2*Math.PI),i=Math.sin(e)*l,r=Math.cos(e)*l,s.push(i,0,r),a.push(h.r,h.g,h.b)}}const h=new Nm;h.setAttribute("position",new Cm(s,3)),h.setAttribute("color",new Cm(a,3));super(h,new T_({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}},PolyhedronBufferGeometry:J_,PolyhedronGeometry:J_,PositionalAudio:class extends Vb{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Wb,Zb,qb),Xb.set(0,0,1).applyQuaternion(Zb);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(Wb.x,t),e.positionY.linearRampToValueAtTime(Wb.y,t),e.positionZ.linearRampToValueAtTime(Wb.z,t),e.orientationX.linearRampToValueAtTime(Xb.x,t),e.orientationY.linearRampToValueAtTime(Xb.y,t),e.orientationZ.linearRampToValueAtTime(Xb.z,t)}else e.setPosition(Wb.x,Wb.y,Wb.z),e.setOrientation(Xb.x,Xb.y,Xb.z)}},PropertyBinding:hM,PropertyMixer:Jb,QuadraticBezierCurve:Zw,QuadraticBezierCurve3:qw,Quaternion:Hp,QuaternionKeyframeTrack:fw,QuaternionLinearInterpolant:pw,REVISION:Dc,RGBADepthPacking:yp,RGBAFormat:rd,RGBAIntegerFormat:md,RGBA_ASTC_10x10_Format:Bd,RGBA_ASTC_10x5_Format:kd,RGBA_ASTC_10x6_Format:zd,RGBA_ASTC_10x8_Format:Fd,RGBA_ASTC_12x10_Format:Nd,RGBA_ASTC_12x12_Format:Hd,RGBA_ASTC_4x4_Format:Cd,RGBA_ASTC_5x4_Format:Pd,RGBA_ASTC_5x5_Format:Ad,RGBA_ASTC_6x5_Format:Ld,RGBA_ASTC_6x6_Format:Rd,RGBA_ASTC_8x5_Format:Od,RGBA_ASTC_8x6_Format:Dd,RGBA_ASTC_8x8_Format:Id,RGBA_BPTC_Format:jd,RGBA_ETC2_EAC_Format:Ed,RGBA_PVRTC_2BPPV1_Format:Md,RGBA_PVRTC_4BPPV1_Format:bd,RGBA_S3TC_DXT1_Format:vd,RGBA_S3TC_DXT3_Format:yd,RGBA_S3TC_DXT5_Format:_d,RGBDEncoding:vp,RGBEEncoding:pp,RGBEFormat:ad,RGBFormat:nd,RGBIntegerFormat:fd,RGBM16Encoding:gp,RGBM7Encoding:mp,RGB_ETC1_Format:Sd,RGB_ETC2_Format:Td,RGB_PVRTC_2BPPV1_Format:wd,RGB_PVRTC_4BPPV1_Format:xd,RGB_S3TC_DXT1_Format:gd,RGFormat:dd,RGIntegerFormat:pd,RawShaderMaterial:Xx,Ray:yf,Raycaster:mM,RectAreaLight:gb,RedFormat:cd,RedIntegerFormat:ud,ReinhardToneMapping:Su,RepeatWrapping:ku,ReplaceStencilOp:7681,ReverseSubtractEquation:Qc,RingBufferGeometry:Fx,RingGeometry:Fx,SRGB8_ALPHA8_ASTC_10x10_Format:$d,SRGB8_ALPHA8_ASTC_10x5_Format:Jd,SRGB8_ALPHA8_ASTC_10x6_Format:Qd,SRGB8_ALPHA8_ASTC_10x8_Format:Kd,SRGB8_ALPHA8_ASTC_12x10_Format:tp,SRGB8_ALPHA8_ASTC_12x12_Format:ep,SRGB8_ALPHA8_ASTC_4x4_Format:Gd,SRGB8_ALPHA8_ASTC_5x4_Format:Ud,SRGB8_ALPHA8_ASTC_5x5_Format:Vd,SRGB8_ALPHA8_ASTC_6x5_Format:Wd,SRGB8_ALPHA8_ASTC_6x6_Format:Zd,SRGB8_ALPHA8_ASTC_8x5_Format:qd,SRGB8_ALPHA8_ASTC_8x6_Format:Xd,SRGB8_ALPHA8_ASTC_8x8_Format:Yd,Scene:jy,SceneUtils:bS,ShaderChunk:Tg,ShaderLib:Cg,ShaderMaterial:ug,ShadowMaterial:qx,Shape:Kw,ShapeBufferGeometry:Bx,ShapeGeometry:Bx,ShapePath:Pb,ShapeUtils:Px,ShortType:Zu,Skeleton:__,SkeletonHelper:PM,SkinnedMesh:m_,SmoothShading:2,Sphere:cf,SphereBufferGeometry:Nx,SphereGeometry:Nx,Spherical:class{constructor(t=1,e=0,i=0){return this.radius=t,this.phi=e,this.theta=i,this}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(Ap.clamp(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},SphericalHarmonics3:vb,SplineCurve:Xw,SpotLight:sb,SpotLightHelper:class extends Vf{constructor(t,e){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e;const i=new Nm,n=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,i=32;t<i;t++,e++){const r=t/i*Math.PI*2,o=e/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(o),Math.sin(o),1)}i.setAttribute("position",new Cm(n,3));const r=new T_({fog:!1,toneMapped:!1});this.cone=new I_(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),SM.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(SM),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sprite:o_,SpriteMaterial:Wy,SrcAlphaFactor:ru,SrcAlphaSaturateFactor:cu,SrcColorFactor:iu,StaticCopyUsage:35046,StaticDrawUsage:Mp,StaticReadUsage:35045,StereoCamera:class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new pg,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new pg,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep;const i=t.projectionMatrix.clone(),n=e.eyeSep/2,r=n*e.near/e.focus,o=e.near*Math.tan(Ap.DEG2RAD*e.fov*.5)/e.zoom;let s,a;Fb.elements[12]=-n,zb.elements[12]=n,s=-o*e.aspect+r,a=o*e.aspect+r,i.elements[0]=2*e.near/(a-s),i.elements[8]=(a+s)/(a-s),this.cameraL.projectionMatrix.copy(i),s=-o*e.aspect-r,a=o*e.aspect-r,i.elements[0]=2*e.near/(a-s),i.elements[8]=(a+s)/(a-s),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Fb),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(zb)}},StreamCopyUsage:35042,StreamDrawUsage:35040,StreamReadUsage:35041,StringKeyframeTrack:mw,SubtractEquation:Jc,SubtractiveBlending:Zc,TOUCH:{ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},TangentSpaceNormalMap:_p,TetrahedronBufferGeometry:Hx,TetrahedronGeometry:Hx,TextBufferGeometry:jx,TextGeometry:jx,Texture:kp,TextureLoader:Aw,TorusBufferGeometry:Gx,TorusGeometry:Gx,TorusKnotBufferGeometry:Ux,TorusKnotGeometry:Ux,Triangle:om,TriangleFanDrawMode:2,TriangleStripDrawMode:1,TrianglesDrawMode:0,TubeBufferGeometry:Vx,TubeGeometry:Vx,UVMapping:Pu,Uint16Attribute:function(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new Mm(t,e)},Uint16BufferAttribute:Mm,Uint32Attribute:function(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new Tm(t,e)},Uint32BufferAttribute:Tm,Uint8Attribute:function(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new xm(t,e)},Uint8BufferAttribute:xm,Uint8ClampedAttribute:function(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new wm(t,e)},Uint8ClampedBufferAttribute:wm,Uniform:dM,UniformsLib:Eg,UniformsUtils:hg,UnsignedByteType:Vu,UnsignedInt248Type:ed,UnsignedIntType:Yu,UnsignedShort4444Type:Ku,UnsignedShort5551Type:$u,UnsignedShort565Type:td,UnsignedShortType:qu,VSMShadowMap:Nc,Vector2:Lp,Vector3:jp,Vector4:Fp,VectorKeyframeTrack:gw,Vertex:function(t,e,i){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new jp(t,e,i)},VertexColors:2,VideoTexture:U_,WebGL1Renderer:By,WebGLCubeRenderTarget:vg,WebGLMultisampleRenderTarget:Np,WebGLRenderTarget:Bp,WebGLRenderTargetCube:function(t,e,i){return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."),new vg(t,i)},WebGLRenderer:Fy,WebGLUtils:Ry,WireframeGeometry:Wx,WireframeHelper:function(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new I_(new Wx(t.geometry),new T_({color:void 0!==e?e:16777215}))},WrapAroundEnding:ap,XHRLoader:function(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new Sw(t)},ZeroCurvatureEnding:op,ZeroFactor:tu,ZeroSlopeEnding:sp,ZeroStencilOp:0,sRGBEncoding:up});const SS=parseInt(Dc.replace("dev",""));function TS(t,e,i){return SS>109?t.setAttribute(e,i):t.addAttribute(e,i),t}function ES(){var t;const e=null!==(t=null==MS?void 0:2)&&void 0!==t&&t;return e||!0}console.log(`maptalks.three log: current three.js version is %c${SS}`,"color:red;font-size: 16px;font-weight: bold;");class CS extends wb{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),TS(this,"position",new Cm([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),TS(this,"uv",new Cm([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix(t){var e=this.attributes.instanceStart,i=this.attributes.instanceEnd;return void 0!==e&&(t.applyToBufferAttribute(e),t.applyToBufferAttribute(i),e.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var i=new pM(e,6,1);return TS(this,"instanceStart",new Vy(i,3,0)),TS(this,"instanceEnd",new Vy(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var i=new pM(e,6,1);return TS(this,"instanceColorStart",new Vy(i,3,0)),TS(this,"instanceColorEnd",new Vy(i,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new Wx(t.geometry)),this}fromLineSegements(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this}computeBoundingBox(){var t=new Vp;null===this.boundingBox&&(this.boundingBox=new Vp);var e=this.attributes.instanceStart,i=this.attributes.instanceEnd;void 0!==e&&void 0!==i&&(this.boundingBox.setFromBufferAttribute(e),t.setFromBufferAttribute(i),this.boundingBox.union(t))}computeBoundingSphere(){var t=new jp;null===this.boundingSphere&&(this.boundingSphere=new cf),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart,i=this.attributes.instanceEnd;if(void 0!==e&&void 0!==i){var n=this.boundingSphere.center;this.boundingBox.getCenter(n);for(var r=0,o=0,s=e.count;o<s;o++)t.fromBufferAttribute(e,o),r=Math.max(r,n.distanceToSquared(t)),t.fromBufferAttribute(i,o),r=Math.max(r,n.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}copy(t){return this}}const PS={},AS={};PS.line={linewidth:{value:1},resolution:{value:new Lp(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},AS.line={uniforms:hg.merge([Eg.common,Eg.fog,PS.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"};class LS extends ug{constructor(t){super({uniforms:hg.clone(AS.line.uniforms),vertexShader:AS.line.vertexShader,fragmentShader:AS.line.fragmentShader}),this.dashed=!0,this.isLineMaterial=!0,this.type="LineMaterial",Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}}}),this.setValues(t)}}class RS extends ng{constructor(t,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2",this.geometry=void 0!==t?t:new CS,this.material=void 0!==e?e:new LS({color:16777215*Math.random()})}computeLineDistances(){var t=new jp,e=new jp,i=this.geometry,n=i.attributes.instanceStart,r=i.attributes.instanceEnd;if(!n||!r)return this;for(var o=new Float32Array(2*n.data.count),s=0,a=0,h=n.data.count;s<h;s++,a+=2)t.fromBufferAttribute(n,s),e.fromBufferAttribute(r,s),o[a]=0===a?0:o[a-1],o[a+1]=o[a]+t.distanceTo(e);var l=new pM(o,2,1);return TS(i,"instanceDistanceStart",new Vy(l,1,0)),TS(i,"instanceDistanceEnd",new Vy(l,1,1)),this}}class OS extends CS{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}fromLine(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this}}class DS extends RS{constructor(t,e){super(t,e),this.isLine2=!0,this.type="Line2",this.geometry=void 0!==t?t:new OS,this.material=void 0!==e?e:new LS({color:16777215*Math.random()})}copy(t){return this}}const IS={interactive:!0,altitude:0,minZoom:0,maxZoom:30,asynchronous:!1,bloom:!1,pickWeight:-1};function kS(){}class zS extends(Cn(kS)){constructor(t){super(),this.isAdd=!1,this._mouseover=!1,this._visible=!0,this._zoomVisible=!0,this.picked=!1,this.isBaseObject=!0,void 0===t&&(t=Ii.GUID()),this.id=t}addTo(t){return t&&"ThreeLayer"===t.type?t.addMesh([this]):console.error("layer only support maptalks.ThreeLayer"),this}remove(){const t=this.getLayer();return t&&t.removeMesh([this]),this}getObject3d(){return this.object3d}getId(){return this.id}setId(t){const e=this.getId();return this.id=t,this._fire("idchange",{old:e,new:t,target:this}),this}getType(){return this.type}getOptions(){return this.options}getProperties(){return(this.options||{}).properties}setProperties(t){const e=Object.assign({},this.getProperties());return this.options.properties=t,this._fire("propertieschange",{old:e,new:t,target:this}),this}getLayer(){return this.options.layer}getMap(){const t=this.getLayer();if(t)return t.getMap()}getCenter(){const t=this.getOptions(),{coordinate:e,lineString:i,polygon:n}=t;if(e)return e instanceof Hn?e:new Hn(e);{const t=n||i;if(t&&t.getCenter)return t.getCenter()}}getAltitude(){return this.getOptions().altitude}setAltitude(t){if(Ii.isNumber(t)){const e=this.getLayer().altitudeToVector3(t,t).x;if(this.getObject3d().position.z=e,this.options.altitude=t,this.pickObject3d&&(this.pickObject3d.position.z=e),this._baseObjects&&Array.isArray(this._baseObjects))for(let t=0,i=this._baseObjects.length;t<i;t++)this._baseObjects[t]&&(this._baseObjects[t].getObject3d().position.z=e)}return this}supportHeight(){return this.getOptions().heightEnable}getHeight(){const{height:t}=this.getOptions();return Ii.isNumber(t)?t:0}setHeight(t){if(!Ii.isNumber(t)||this._baseObjects||!this.supportHeight())return this;const e=this.getLayer();if(!e)return this;const{geometry:i}=this.getObject3d();if(i instanceof Nm){const{position:n}=i.attributes||{};if(!n)return this;const r=n.array;let o=1/0,s=-1/0;for(let t=0,e=r.length;t<e;t+=3){const e=r[t+2];o=Math.min(e,o),s=Math.max(e,s)}const a=(o+s)/2;let h=e.altitudeToVector3(t,t).x;h=Math.max(h,1e-6);for(let t=0,e=r.length;t<e;t+=3)r[t+2]>a&&(r[t+2]=h);i.attributes.position.needsUpdate=!0,i.computeBoundingBox(),i.computeBoundingSphere(),this.getOptions().height=t}return this}show(){return this._zoomVisible&&(this.getObject3d().visible=!0,this._fire("show")),this._visible=!0,this}hide(){return this.getObject3d().visible=!1,this._fire("hide"),this._visible=!1,this._hideUI(),this}isVisible(){return!!this.getObject3d().visible}getSymbol(){return this.getObject3d().material}setSymbol(t){if(t&&t instanceof am){t.needsUpdate=!0,t.vertexColors=this.getObject3d().material.vertexColors;const e=this.getObject3d().material.clone();this.getObject3d().material=t,this._fire("symbolchange",{old:e,new:t,target:this})}return this}setInfoWindow(t){return this.removeInfoWindow(),this.infoWindow=new Ih.InfoWindow(t),this.infoWindow.addTo(this),this}getInfoWindow(){return this.infoWindow}openInfoWindow(t){return(t=t||this.getCenter())instanceof Hn||(t=new Hn(t)),t&&this.infoWindow&&this.infoWindow.show(t),this}closeInfoWindow(){return this.infoWindow&&this.infoWindow.hide(),this}removeInfoWindow(){return this.infoWindow&&(this.infoWindow.remove(),delete this.infoWindow),this}setToolTip(t,e){return this.removeToolTip(),this.toolTip=new Ih.ToolTip(t,e),this.toolTip.addTo(this),this}getToolTip(){return this.toolTip}openToolTip(t){return(t=t||this.getCenter())instanceof Hn||(t=new Hn(t)),t&&this.toolTip&&this.toolTip.show(t),this}closeToolTip(){return this.toolTip&&this.toolTip.hide(),this}removeToolTip(){return this.toolTip&&(this.toolTip.remove(),delete this.toolTip),this}_hideUI(){return this.closeInfoWindow(),this.closeToolTip(),this}animateShow(t={},e){this._showPlayer&&this._showPlayer.cancel(),Ii.isFunction(t)&&(e=t={});const i=t.duration||1e3,n=t.easing||"out",r=this._showPlayer=Bs.Animation.animate({scale:1},{duration:i,easing:n},(t=>{const i=t.styles.scale;i>0&&(this.getObject3d().scale.z=i),e&&e(t,i)}));return r.play(),r}getMinZoom(){return this.getOptions().minZoom}getMaxZoom(){return this.getOptions().maxZoom}isAsynchronous(){return this.getOptions().asynchronous}get bloom(){return this.getOptions().bloom}fire(t,e){return this._fire(t,e),this._vt&&this._vt.onSelectMesh&&this._vt.onSelectMesh(t,e),this}config(){return this}setPickObject3d(t){return this.pickObject3d=t,this.pickObject3d.__parent=this,this}_initOptions(t){return this.options=Ii.extend({},IS,t),this}_createMesh(t,e){return this.object3d=new ng(t,e),this.object3d.__parent=this,this}_createInstancedMesh(t,e,i){return this.object3d=new S_(t,e,i),this.object3d.__parent=this,this}_createGroup(){return this.object3d=new Dy,this.object3d.__parent=this,this}_createLine(t,e){return this.object3d=new R_(t,e),this._computeLineDistances(t),this.object3d.__parent=this,this}_createLine2(t,e){return this.object3d=new DS(t,e),this.object3d.computeLineDistances(),this.object3d.__parent=this,this}_createPoints(t,e){return this.object3d=new j_(t,e),this.object3d.__parent=this,this}_createLineSegments(t,e){return this.object3d=new I_(t,e),this._computeLineDistances(t),this.object3d.__parent=this,this}_computeLineDistances(t){const e=t.attributes.position.array,i=t.attributes.position.count,n=new Float32Array(i);n[0]=0;const r=new jp(0,0,0),o=new jp(0,0,0);for(let t=1;t<i;t++){const i=3*(t-1);r.x=e[i],r.y=e[i+1],r.z=e[i+2];const s=3*t;o.x=e[s],o.y=e[s+1],o.z=e[s+2];const a=o.distanceTo(r);n[t]=n[t-1]+a}TS(t,"lineDistance",new ym(n,1))}}const FS=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"];function BS(t){return t.geometry?t.geometry.type:null}function NS(t){const e=BS(t);if(e)for(let t=0,i=FS.length;t<i;t++)if(FS[t]===e)return!0;return!1}function HS(t){const e=BS(t);return!(!e||e!==FS[4]&&e!==FS[5])}function jS(t){const e=BS(t);return!(!e||e!==FS[2]&&e!==FS[3])}function GS(t){const e=BS(t);return!(!e||e!==FS[0]&&e!==FS[1])}function US(t){const e=BS(t);return!!(e&&e.indexOf("Multi")>-1)}function VS(t){return t.geometry?t.geometry.coordinates:[]}function WS(t,e){const i=BS(t);if(!i||!t.geometry)return null;const n=t.geometry.coordinates;if(!n)return null;let r=0,o=0,s=0;switch(i){case"Point":r=n[0],o=n[1],s++;break;case"MultiPoint":case"LineString":for(let t=0,e=n.length;t<e;t++)r+=n[t][0],o+=n[t][1],s++;break;case"MultiLineString":case"Polygon":for(let t=0,e=n.length;t<e;t++)for(let e=0,i=n[t].length;e<i;e++)r+=n[t][e][0],o+=n[t][e][1],s++;break;case"MultiPolygon":for(let t=0,e=n.length;t<e;t++)for(let e=0,i=n[t].length;e<i;e++)for(let i=0,a=n[t][e].length;i<a;i++)r+=n[t][e][i][0],o+=n[t][e][i][1],s++}const a=r/s,h=o/s;return e?(e.x=a,e.y=h,e):new Hn(a,h)}function ZS(t){const e=BS(t);if(!e||!t.geometry)return null;const i=t.geometry,n=t.properties||{},r=i.coordinates;if(!r)return null;const o=[];let s;switch(e){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}if(s)for(let t=0,e=r.length;t<e;t++)o.push({type:"Feature",geometry:{type:s,coordinates:r[t]},properties:n});else o.push(t);return o}
|
|
1
|
+
import*as t from"maptalks";import*as e from"three";const n=parseInt(e.REVISION.replace("dev",""));function i(t,e,i){return n>109?t.setAttribute(e,i):t.addAttribute(e,i),t}function r(){var t;const n=null!==(t=null==e?void 0:e.VertexColors)&&void 0!==t&&t;return n||!0}console.log(`maptalks.three log: current three.js version is %c${n}`,"color:red;font-size: 16px;font-weight: bold;");class o extends e.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),i(this,"position",new e.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),i(this,"uv",new e.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix(t){var e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(t.applyToBufferAttribute(e),t.applyToBufferAttribute(n),e.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){var n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));var r=new e.InstancedInterleavedBuffer(n,6,1);return i(this,"instanceStart",new e.InterleavedBufferAttribute(r,3,0)),i(this,"instanceEnd",new e.InterleavedBufferAttribute(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){var n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));var r=new e.InstancedInterleavedBuffer(n,6,1);return i(this,"instanceColorStart",new e.InterleavedBufferAttribute(r,3,0)),i(this,"instanceColorEnd",new e.InterleavedBufferAttribute(r,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new e.WireframeGeometry(t.geometry)),this}fromLineSegements(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this}computeBoundingBox(){var t=new e.Box3;null===this.boundingBox&&(this.boundingBox=new e.Box3);var n=this.attributes.instanceStart,i=this.attributes.instanceEnd;void 0!==n&&void 0!==i&&(this.boundingBox.setFromBufferAttribute(n),t.setFromBufferAttribute(i),this.boundingBox.union(t))}computeBoundingSphere(){var t=new e.Vector3;null===this.boundingSphere&&(this.boundingSphere=new e.Sphere),null===this.boundingBox&&this.computeBoundingBox();var n=this.attributes.instanceStart,i=this.attributes.instanceEnd;if(void 0!==n&&void 0!==i){var r=this.boundingSphere.center;this.boundingBox.getCenter(r);for(var o=0,s=0,a=n.count;s<a;s++)t.fromBufferAttribute(n,s),o=Math.max(o,r.distanceToSquared(t)),t.fromBufferAttribute(i,s),o=Math.max(o,r.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}copy(t){return this}}const s={},a={};s.line={linewidth:{value:1},resolution:{value:new e.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},a.line={uniforms:e.UniformsUtils.merge([e.UniformsLib.common,e.UniformsLib.fog,s.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"};class h extends e.ShaderMaterial{constructor(t){super({uniforms:e.UniformsUtils.clone(a.line.uniforms),vertexShader:a.line.vertexShader,fragmentShader:a.line.fragmentShader}),this.dashed=!0,this.isLineMaterial=!0,this.type="LineMaterial",Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}}}),this.setValues(t)}}class c extends e.Mesh{constructor(t,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2",this.geometry=void 0!==t?t:new o,this.material=void 0!==e?e:new h({color:16777215*Math.random()})}computeLineDistances(){var t=new e.Vector3,n=new e.Vector3,r=this.geometry,o=r.attributes.instanceStart,s=r.attributes.instanceEnd;if(!o||!s)return this;for(var a=new Float32Array(2*o.data.count),h=0,c=0,l=o.data.count;h<l;h++,c+=2)t.fromBufferAttribute(o,h),n.fromBufferAttribute(s,h),a[c]=0===c?0:a[c-1],a[c+1]=a[c]+t.distanceTo(n);var u=new e.InstancedInterleavedBuffer(a,2,1);return i(r,"instanceDistanceStart",new e.InterleavedBufferAttribute(u,1,0)),i(r,"instanceDistanceEnd",new e.InterleavedBufferAttribute(u,1,1)),this}}class l extends o{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}fromLine(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this}}class u extends c{constructor(t,e){super(t,e),this.isLine2=!0,this.type="Line2",this.geometry=void 0!==t?t:new l,this.material=void 0!==e?e:new h({color:16777215*Math.random()})}copy(t){return this}}const d={interactive:!0,altitude:0,minZoom:0,maxZoom:30,asynchronous:!1,bloom:!1,pickWeight:-1};function p(){}class f extends(t.Eventable(p)){constructor(e){super(),this.isAdd=!1,this._mouseover=!1,this._visible=!0,this._zoomVisible=!0,this.picked=!1,this.isBaseObject=!0,void 0===e&&(e=t.Util.GUID()),this.id=e}addTo(t){return t&&"ThreeLayer"===t.type?t.addMesh([this]):console.error("layer only support maptalks.ThreeLayer"),this}remove(){const t=this.getLayer();return t&&t.removeMesh([this]),this}getObject3d(){return this.object3d}getId(){return this.id}setId(t){const e=this.getId();return this.id=t,this._fire("idchange",{old:e,new:t,target:this}),this}getType(){return this.type}getOptions(){return this.options}getProperties(){return(this.options||{}).properties}setProperties(t){const e=Object.assign({},this.getProperties());return this.options.properties=t,this._fire("propertieschange",{old:e,new:t,target:this}),this}getLayer(){return this.options.layer}getMap(){const t=this.getLayer();if(t)return t.getMap()}getCenter(){const e=this.getOptions(),{coordinate:n,lineString:i,polygon:r}=e;if(n)return n instanceof t.Coordinate?n:new t.Coordinate(n);{const t=r||i;if(t&&t.getCenter)return t.getCenter()}}getAltitude(){return this.getOptions().altitude}setAltitude(e){if(t.Util.isNumber(e)){const t=this.getLayer().altitudeToVector3(e,e).x;if(this.getObject3d().position.z=t,this.options.altitude=e,this.pickObject3d&&(this.pickObject3d.position.z=t),this._baseObjects&&Array.isArray(this._baseObjects))for(let e=0,n=this._baseObjects.length;e<n;e++)this._baseObjects[e]&&(this._baseObjects[e].getObject3d().position.z=t)}return this}supportHeight(){return this.getOptions().heightEnable}getHeight(){const{height:e}=this.getOptions();return t.Util.isNumber(e)?e:0}setHeight(n){if(!t.Util.isNumber(n)||this._baseObjects||!this.supportHeight())return this;const i=this.getLayer();if(!i)return this;const{geometry:r}=this.getObject3d();if(r instanceof e.BufferGeometry){const{position:t}=r.attributes||{};if(!t)return this;const e=t.array;let o=1/0,s=-1/0;for(let t=0,n=e.length;t<n;t+=3){const n=e[t+2];o=Math.min(n,o),s=Math.max(n,s)}const a=(o+s)/2;let h=i.altitudeToVector3(n,n).x;h=Math.max(h,1e-6);for(let t=0,n=e.length;t<n;t+=3)e[t+2]>a&&(e[t+2]=h);r.attributes.position.needsUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere(),this.getOptions().height=n}return this}show(){return this._zoomVisible&&(this.getObject3d().visible=!0,this._fire("show")),this._visible=!0,this}hide(){return this.getObject3d().visible=!1,this._fire("hide"),this._visible=!1,this._hideUI(),this}isVisible(){return!!this.getObject3d().visible}getSymbol(){return this.getObject3d().material}setSymbol(t){if(t&&t instanceof e.Material){t.needsUpdate=!0,t.vertexColors=this.getObject3d().material.vertexColors;const e=this.getObject3d().material.clone();this.getObject3d().material=t,this._fire("symbolchange",{old:e,new:t,target:this})}return this}setInfoWindow(e){return this.removeInfoWindow(),this.infoWindow=new t.ui.InfoWindow(e),this.infoWindow.addTo(this),this}getInfoWindow(){return this.infoWindow}openInfoWindow(e){return(e=e||this.getCenter())instanceof t.Coordinate||(e=new t.Coordinate(e)),e&&this.infoWindow&&this.infoWindow.show(e),this}closeInfoWindow(){return this.infoWindow&&this.infoWindow.hide(),this}removeInfoWindow(){return this.infoWindow&&(this.infoWindow.remove(),delete this.infoWindow),this}setToolTip(e,n){return this.removeToolTip(),this.toolTip=new t.ui.ToolTip(e,n),this.toolTip.addTo(this),this}getToolTip(){return this.toolTip}openToolTip(e){return(e=e||this.getCenter())instanceof t.Coordinate||(e=new t.Coordinate(e)),e&&this.toolTip&&this.toolTip.show(e),this}closeToolTip(){return this.toolTip&&this.toolTip.hide(),this}removeToolTip(){return this.toolTip&&(this.toolTip.remove(),delete this.toolTip),this}_hideUI(){return this.closeInfoWindow(),this.closeToolTip(),this}animateShow(e={},n){this._showPlayer&&this._showPlayer.cancel(),t.Util.isFunction(e)&&(n=e={});const i=e.duration||1e3,r=e.easing||"out",o=this._showPlayer=t.animation.Animation.animate({scale:1},{duration:i,easing:r},(t=>{const e=t.styles.scale;e>0&&(this.getObject3d().scale.z=e),n&&n(t,e)}));return o.play(),o}getMinZoom(){return this.getOptions().minZoom}getMaxZoom(){return this.getOptions().maxZoom}isAsynchronous(){return this.getOptions().asynchronous}get bloom(){return this.getOptions().bloom}fire(t,e){return this._fire(t,e),this._vt&&this._vt.onSelectMesh&&this._vt.onSelectMesh(t,e),this}config(){return this}setPickObject3d(t){return this.pickObject3d=t,this.pickObject3d.__parent=this,this}_initOptions(e){return this.options=t.Util.extend({},d,e),this}_createMesh(t,n){return this.object3d=new e.Mesh(t,n),this.object3d.__parent=this,this}_createInstancedMesh(t,n,i){return this.object3d=new e.InstancedMesh(t,n,i),this.object3d.__parent=this,this}_createGroup(){return this.object3d=new e.Group,this.object3d.__parent=this,this}_createLine(t,n){return this.object3d=new e.Line(t,n),this._computeLineDistances(t),this.object3d.__parent=this,this}_createLine2(t,e){return this.object3d=new u(t,e),this.object3d.computeLineDistances(),this.object3d.__parent=this,this}_createPoints(t,n){return this.object3d=new e.Points(t,n),this.object3d.__parent=this,this}_createLineSegments(t,n){return this.object3d=new e.LineSegments(t,n),this._computeLineDistances(t),this.object3d.__parent=this,this}_computeLineDistances(t){const n=t.attributes.position.array,r=t.attributes.position.count,o=new Float32Array(r);o[0]=0;const s=new e.Vector3(0,0,0),a=new e.Vector3(0,0,0);for(let t=1;t<r;t++){const e=3*(t-1);s.x=n[e],s.y=n[e+1],s.z=n[e+2];const i=3*t;a.x=n[i],a.y=n[i+1],a.z=n[i+2];const r=a.distanceTo(s);o[t]=o[t-1]+r}i(t,"lineDistance",new e.BufferAttribute(o,1))}}const g=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"];function y(t){return t.geometry?t.geometry.type:null}function x(t){const e=y(t);if(e)for(let t=0,n=g.length;t<n;t++)if(g[t]===e)return!0;return!1}function m(t){const e=y(t);return!(!e||e!==g[4]&&e!==g[5])}function v(t){const e=y(t);return!(!e||e!==g[2]&&e!==g[3])}function b(t){const e=y(t);return!(!e||e!==g[0]&&e!==g[1])}function _(t){const e=y(t);return!!(e&&e.indexOf("Multi")>-1)}function w(t){return t.geometry?t.geometry.coordinates:[]}function M(e,n){const i=y(e);if(!i||!e.geometry)return null;const r=e.geometry.coordinates;if(!r)return null;let o=0,s=0,a=0;switch(i){case"Point":o=r[0],s=r[1],a++;break;case"MultiPoint":case"LineString":for(let t=0,e=r.length;t<e;t++)o+=r[t][0],s+=r[t][1],a++;break;case"MultiLineString":case"Polygon":for(let t=0,e=r.length;t<e;t++)for(let e=0,n=r[t].length;e<n;e++)o+=r[t][e][0],s+=r[t][e][1],a++;break;case"MultiPolygon":for(let t=0,e=r.length;t<e;t++)for(let e=0,n=r[t].length;e<n;e++)for(let n=0,i=r[t][e].length;n<i;n++)o+=r[t][e][n][0],s+=r[t][e][n][1],a++}const h=o/a,c=s/a;return n?(n.x=h,n.y=c,n):new t.Coordinate(h,c)}function A(t){const e=y(t);if(!e||!t.geometry)return null;const n=t.geometry,i=t.properties||{},r=n.coordinates;if(!r)return null;const o=[];let s;switch(e){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}if(s)for(let t=0,e=r.length;t<e;t++)o.push({type:"Feature",geometry:{type:s,coordinates:r[t]},properties:i});else o.push(t);return o}
|
|
17
2
|
/*!
|
|
18
3
|
* poly-extrude v0.2.0
|
|
19
|
-
*/var qS={exports:{}};function XS(t,e,i){i=i||2;var n,r,o,s,a,h,l,c=e&&e.length,u=c?e[0]*i:t.length,d=YS(t,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=function(t,e,i,n){var r,o,s,a=[];for(r=0,o=e.length;r<o;r++)(s=YS(t,e[r]*n,r<o-1?e[r+1]*n:t.length,n,!1))===s.next&&(s.steiner=!0),a.push(sT(s));for(a.sort(iT),r=0;r<a.length;r++)i=nT(a[r],i);return i}(t,e,d,i)),t.length>80*i){n=o=t[0],r=s=t[1];for(var f=i;f<u;f+=i)(a=t[f])<n&&(n=a),(h=t[f+1])<r&&(r=h),a>o&&(o=a),h>s&&(s=h);l=0!==(l=Math.max(o-n,s-r))?32767/l:0}return QS(d,p,i,n,r,l,0),p}function YS(t,e,i,n,r){var o,s;if(r===_T(t,e,i,n)>0)for(o=e;o<i;o+=n)s=gT(o,t[o],t[o+1],s);else for(o=i-n;o>=e;o-=n)s=gT(o,t[o],t[o+1],s);return s&&cT(s,s.next)&&(vT(s),s=s.next),s}function JS(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!cT(n,n.next)&&0!==lT(n.prev,n,n.next))n=n.next;else{if(vT(n),(n=e=n.prev)===n.next)break;i=!0}}while(i||n!==e);return e}function QS(t,e,i,n,r,o,s){if(t){!s&&o&&function(t,e,i,n){var r=t;do{0===r.z&&(r.z=oT(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,i,n,r,o,s,a,h,l=1;do{for(i=t,t=null,o=null,s=0;i;){for(s++,n=i,a=0,e=0;e<l&&(a++,n=n.nextZ);e++);for(h=l;a>0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;i=n}o.nextZ=null,l*=2}while(s>1)}(r)}(t,n,r,o);for(var a,h,l=t;t.prev!==t.next;)if(a=t.prev,h=t.next,o?$S(t,n,r,o):KS(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(h.i/i|0),vT(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?QS(t=tT(JS(t),e,i),e,i,n,r,o,2):2===s&&eT(t,e,i,n,r,o):QS(JS(t),e,i,n,r,o,1);break}}}function KS(t){var e=t.prev,i=t,n=t.next;if(lT(e,i,n)>=0)return!1;for(var r=e.x,o=i.x,s=n.x,a=e.y,h=i.y,l=n.y,c=r<o?r<s?r:s:o<s?o:s,u=a<h?a<l?a:l:h<l?h:l,d=r>o?r>s?r:s:o>s?o:s,p=a>h?a>l?a:l:h>l?h:l,f=n.next;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&aT(r,a,o,h,s,l,f.x,f.y)&&lT(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function $S(t,e,i,n){var r=t.prev,o=t,s=t.next;if(lT(r,o,s)>=0)return!1;for(var a=r.x,h=o.x,l=s.x,c=r.y,u=o.y,d=s.y,p=a<h?a<l?a:l:h<l?h:l,f=c<u?c<d?c:d:u<d?u:d,m=a>h?a>l?a:l:h>l?h:l,g=c>u?c>d?c:d:u>d?u:d,v=oT(p,f,e,i,n),y=oT(m,g,e,i,n),_=t.prevZ,x=t.nextZ;_&&_.z>=v&&x&&x.z<=y;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&aT(a,c,h,u,l,d,_.x,_.y)&&lT(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&aT(a,c,h,u,l,d,x.x,x.y)&&lT(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;_&&_.z>=v;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&aT(a,c,h,u,l,d,_.x,_.y)&&lT(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&aT(a,c,h,u,l,d,x.x,x.y)&&lT(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function tT(t,e,i){var n=t;do{var r=n.prev,o=n.next.next;!cT(r,o)&&uT(r,n,n.next,o)&&fT(r,o)&&fT(o,r)&&(e.push(r.i/i|0),e.push(n.i/i|0),e.push(o.i/i|0),vT(n),vT(n.next),n=t=o),n=n.next}while(n!==t);return JS(n)}function eT(t,e,i,n,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&hT(s,a)){var h=mT(s,a);return s=JS(s,s.next),h=JS(h,h.next),QS(s,e,i,n,r,o,0),void QS(h,e,i,n,r,o,0)}a=a.next}s=s.next}while(s!==t)}function iT(t,e){return t.x-e.x}function nT(t,e){var i=function(t,e){var i,n=e,r=t.x,o=t.y,s=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var a=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>s&&(s=a,i=n.x<n.next.x?n:n.next,a===r))return i}n=n.next}while(n!==e);if(!i)return null;var h,l=i,c=i.x,u=i.y,d=1/0;n=i;do{r>=n.x&&n.x>=c&&r!==n.x&&aT(o<u?r:s,o,c,u,o<u?s:r,o,n.x,n.y)&&(h=Math.abs(o-n.y)/(r-n.x),fT(n,t)&&(h<d||h===d&&(n.x>i.x||n.x===i.x&&rT(i,n)))&&(i=n,d=h)),n=n.next}while(n!==l);return i}(t,e);if(!i)return e;var n=mT(i,t);return JS(n,n.next),JS(i,i.next)}function rT(t,e){return lT(t.prev,t,e.prev)<0&&lT(e.next,t,t.next)<0}function oT(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function sT(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function aT(t,e,i,n,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function hT(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&uT(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(fT(t,e)&&fT(e,t)&&function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(lT(t.prev,t,e.prev)||lT(t,e.prev,e))||cT(t,e)&&lT(t.prev,t,t.next)>0&&lT(e.prev,e,e.next)>0)}function lT(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function cT(t,e){return t.x===e.x&&t.y===e.y}function uT(t,e,i,n){var r=pT(lT(t,e,i)),o=pT(lT(t,e,n)),s=pT(lT(i,n,t)),a=pT(lT(i,n,e));return r!==o&&s!==a||(!(0!==r||!dT(t,i,e))||(!(0!==o||!dT(t,n,e))||(!(0!==s||!dT(i,t,n))||!(0!==a||!dT(i,e,n)))))}function dT(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function pT(t){return t>0?1:t<0?-1:0}function fT(t,e){return lT(t.prev,t,t.next)<0?lT(t,e,t.next)>=0&&lT(t,t.prev,e)>=0:lT(t,e,t.prev)<0||lT(t,t.next,e)<0}function mT(t,e){var i=new yT(t.i,t.x,t.y),n=new yT(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function gT(t,e,i,n){var r=new yT(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function vT(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function yT(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function _T(t,e,i,n){for(var r=0,o=e,s=i-n;o<i;o+=n)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}qS.exports=XS,qS.exports.default=XS,XS.deviation=function(t,e,i,n){var r=e&&e.length,o=r?e[0]*i:t.length,s=Math.abs(_T(t,0,o,i));if(r)for(var a=0,h=e.length;a<h;a++){var l=e[a]*i,c=a<h-1?e[a+1]*i:t.length;s-=Math.abs(_T(t,l,c,i))}var u=0;for(a=0;a<n.length;a+=3){var d=n[a]*i,p=n[a+1]*i,f=n[a+2]*i;u+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},XS.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},n=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)i.vertices.push(t[r][o][s]);r>0&&(n+=t[r-1].length,i.holes.push(n))}return i};var xT=qS.exports;function wT(t){for(var e,i,n=0,r=1,o=t.length;r<o;)e=i||t[0],n+=((i=t[r])[0]-e[0])*(i[1]+e[1]),r++;return n>0}function bT(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function MT(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[0],a=i[1],h=i[2];return t[0]=r*h-o*a,t[1]=o*s-n*h,t[2]=n*a-r*s,t}function ST(t,e){function i(t,e,i,n){t[0]=e,t[1]=i,t[2]=n}for(var n=[],r=[],o=[],s=[],a=[],h=[],l=t.length,c=new Float32Array(e.length),u=0;u<l;){var d=3*t[u],p=3*t[u+1],f=3*t[u+2];i(n,e[d],e[d+1],e[d+2]),i(r,e[p],e[p+1],e[p+2]),i(o,e[f],e[f+1],e[f+2]),bT(a,o,r),bT(s,n,r),MT(h,a,s);for(var m=0;m<3;m++)c[d+m]+=h[m],c[p+m]+=h[m],c[f+m]+=h[m];u+=3}for(var g,v,y,_,x,w,b=0,M=c.length;b<M;)i(h,c[b],c[b+1],c[b+2]),g=h,y=void 0,_=void 0,x=void 0,w=void 0,y=(v=h)[0],_=v[1],x=v[2],w=Math.sqrt(y*y+_*_+x*x)||1,g[0]=y/w,g[1]=_/w,g[2]=x/w,c[b]=h[0]||0,c[b+1]=h[1]||0,c[b+2]=h[2]||0,b+=3;return c}function TT(t){if(1===t.length)return{position:t[0].position,normal:t[0].normal,uv:t[0].uv,indices:t[0].indices,results:t};for(var e=0,i=0,n=0,r=t.length;n<r;n++){var o=t[n],s=o.position,a=o.indices;e+=s.length,i+=a.length}for(var h={position:new Float32Array(e),normal:new Float32Array(e),uv:new Float32Array(e/3*2),indices:new Uint32Array(i),results:t},l=0,c=0,u=0,d=0,p=0,f=t.length;p<f;p++){var m=t[p],g=m.position,v=m.indices,y=m.normal,_=m.uv;h.position.set(g,l),h.normal.set(y,l),h.uv.set(_,d);for(var x=0,w=v.length;x<w;){var b=v[x]+c;h.indices[u]=b,u++,x++}d+=_.length,l+=g.length,c+=g.length/3}return h}function ET(t){return 180*t/Math.PI}function CT(t){return t/180*Math.PI}function PT(t,e,i,n,r,o){var s=3*i,a=3*n,h=3*r,l=3*o,c=e[s],u=e[s+1],d=e[s+2],p=e[a],f=e[a+1],m=e[a+2],g=e[h],v=e[h+1],y=e[h+2],_=e[l],x=e[l+1],w=e[l+2];Math.abs(u-f)<Math.abs(c-p)?(t.push(c,1-d),t.push(p,1-m),t.push(g,1-y),t.push(_,1-w)):(t.push(u,1-d),t.push(f,1-m),t.push(v,1-y),t.push(x,1-w))}function AT(t,e){e=Object.assign({},{depth:2},e);var i=t.map((function(t){for(var i=0,n=t.length;i<n;i++){var r=t[i];LT(r),0===i?wT(r)||(t[i]=r.reverse()):wT(r)&&(t[i]=r.reverse()),RT(r)&&r.splice(r.length-1,1)}var o=function(t,e){for(var i=function(t){var e=0,i=0,n=t.length;for(;i<n;)e+=t[i].length,i++;return e}(t),n=t.length,r=[],o=new Float32Array(2*i),s=[],a=[],h=3*i,l=2*i,c=e.depth,u=0,d=0,p=0,f=0;f<n;f++){var m=t[f];f>0&&r.push(u/2);for(var g=0,v=m.length;g<v;){var y=m[g],_=y[0],x=y[1];o[u++]=_,o[u++]=x,s[d]=_,s[d+1]=x,s[d+2]=c,s[h+d]=_,s[h+d+1]=x,s[h+d+2]=0,a[p]=_,a[p+1]=x,a[l+p]=_,a[l+p+1]=x,d+=3,p+=2,g++}}return{flatVertices:o,holes:r,points:s,count:i,uvs:a}}(t,e);return o.polygon=t,function(t,e){for(var i=[],n=t.count,r=0,o=e.length;r<o;r+=3){var s=e[r],a=e[r+1],h=e[r+2];i[r]=s,i[r+1]=a,i[r+2]=h;var l=o+r,c=n+s,u=n+a,d=n+h;i[l]=c,i[l+1]=u,i[l+2]=d}t.index=i}(o,xT(o.flatVertices,o.holes,2)),function(t,e){for(var i=t.points,n=t.index,r=t.polygon,o=t.uvs,s=e.depth,a=0,h=r.length;a<h;a++)for(var l=r[a],c=0,u=l.length;c<u;){var d=l[c],p=l[c+1];c===u-1&&(p=l[0]);var f=i.length/3,m=d[0],g=d[1],v=p[0],y=p[1];i.push(m,g,s,v,y,s,m,g,0,v,y,0);var _=f+2,x=f+3,w=f,b=f+1;n.push(_,w,x,w,b,x),PT(o,i,_,x,w,b),c++}}(o,e),o.position=new Float32Array(o.points),o.indices=new Uint32Array(o.index),o.uv=new Float32Array(o.uvs),o.normal=ST(o.indices,o.position),o})),n=TT(i);return n.polygons=t,n}function LT(t){RT(t)||t.push(t[0])}function RT(t){var e=t.length,i=t[0],n=i[0],r=i[1],o=t[e-1],s=o[0],a=o[1];return n===s&&r===a}function OT(t,e){e=Object.assign({},{depth:2,lineWidth:1},e);var i=t.map((function(t){var i=function(t,e){var i=0,n=e.lineWidth/2,r=[],o=[],s=[],a=t.length,h=0;for(;h<a-1;){var l=t[h],c=t[h+1],u=c[1]-l[1],d=c[0]-l[0],p=0,f=ET(Math.atan(u/d));if(i=f,0===h)p=f,p-=90;else{var m=t[h-1];DT.x=m[0]-l[0],DT.y=m[1]-l[1],IT.x=c[0]-l[0],IT.y=c[1]-l[1],p=f-zT(DT,IT)/2}var g=kT(CT(p),n,l),v=g[0],y=g[1];r.push(v,y),FT(v,l,c)?(o.push(v),s.push(y)):(o.push(y),s.push(v)),h++}var _=i,x=CT(_-=90),w=t[a-2],b=t[a-1],M=kT(x,n,b),S=M[0],T=M[1];r.push(S,T),FT(S,w,b)?(o.push(S),s.push(T)):(o.push(T),s.push(S));return{offsetPoints:r,leftPoints:o,rightPoints:s}}(t,e);return i.line=t,function(t,e){var i=e.depth,n=[],r=[],o=[],s=t.leftPoints,a=t.rightPoints,h=0,l=s.length;for(;h<l;){var c=3*h,u=s[h],d=u[0],p=u[1],f=u[2];n[c]=d,n[c+1]=p,n[c+2]=i+f;var m=a[h],g=m[0],v=m[1],y=m[2],_=3*l+c;n[_]=g,n[_+1]=v,n[_+2]=i+y;var x=2*l*3+c;n[x]=d,n[x+1]=p,n[x+2]=f;var w=2*l*3+3*l+c;n[w]=g,n[w+1]=v,n[w+2]=y,h++}h=0,l=n.length;for(;h<l;){var b=n[h],M=n[h+1];o.push(b,M),h+=3}h=0,l=s.length;for(;h<l-1;){var S=h,T=h+1,E=S+l,C=T+l;r.push(S,E,T),r.push(E,C,T);var P=h+2*l,A=P+1,L=P+l,R=A+l;r.push(P,L,A),r.push(L,R,A),h++}t.index=r,t.points=n,t.uvs=o}(i,e),function(t,e){var i=t.points,n=t.index,r=t.leftPoints,o=t.rightPoints,s=t.uvs,a=e.depth,h=[r,o];function l(t,e){var r=i.length/3;i.push(t[0],t[1],a+t[2],e[0],e[1],a+e[2],t[0],t[1],t[2],e[0],e[1],e[2]);var o=r+2,h=r+3,l=r,c=r+1;n.push(o,l,h,l,c,h),PT(s,i,o,h,l,c)}for(var c=0,u=h.length;c<u;c++){var d=h[c];c>0&&(d=d.map((function(t){return t})),d=d.reverse());for(var p=0,f=d.length-1;p<f;){l(d[p],d[p+1]),p++}}for(var m=r.length,g=[o[0],r[0],r[m-1],o[m-1]],v=0;v<g.length;v+=2){l(g[v],g[v+1])}}(i,e),i.position=new Float32Array(i.points),i.indices=new Uint32Array(i.index),i.uv=new Float32Array(i.uvs),i.normal=ST(i.indices,i.position),i})),n=TT(i);return n.lines=t,n}var DT={x:0,y:0},IT={x:0,y:0};function kT(t,e,i){var n=i[0],r=i[1],o=i[2]||0,s=[n+Math.cos(t)*e,r+Math.sin(t)*e,o],a=t+=Math.PI;return[s,[n+Math.cos(a)*e,r+Math.sin(a)*e,o]]}var zT=function(t,e){var i=t.x,n=t.y,r=e.x,o=e.y,s=i*r+n*o,a=i*o-n*r;return(Math.atan2(a,s)/Math.PI*180+360)%360};function FT(t,e,i){var n=e[0],r=e[1],o=i[0],s=i[1];return(r-s)*t[0]+(o-n)*t[1]+n*s-o*r>0}function BT(t,e,i={}){return void 0===i[t]&&(i[t]=e.distanceToVector3(t,t).x),i[t]}function NT(t,e,i={}){return void 0===i[t]&&(i[t]=e.altitudeToVector3(t,t).x),i[t]}function HT(t=[]){let e=0,i=0;const n=t.length;for(let r=0;r<n;r++){const{coordinate:n,lnglat:o,lnglats:s,xy:a,xys:h}=t[r],l=n||o||s||a||h||t[r];let c,u;Array.isArray(l)?(c=l[0],u=l[1]):l instanceof Hn&&(c=l.x,u=l.y),e+=c,i+=u}return new Hn(e/n,i/n)}function jT(t,e,i,n){if(void 0===e||"number"!=typeof e||0===e)return 0;let r;r=t instanceof Nm?t.attributes.position.array:Array.isArray(t)||t instanceof Float32Array?t:t.position;let o=0;if(r){n?(void 0===n[e]&&(n[e]=i.altitudeToVector3(e,e).x),o=n[e]):o=i.altitudeToVector3(e,e).x;const t=r.length;if(r[0]instanceof jp)for(let e=0;e<t;e++)r[e].z+=o;else for(let e=0;e<t;e+=3)r[e+2]+=o}return o}function GT(t){const e=t.length;let i=0;for(let n=0;n<e;n++){const{count:e}=t[n].position;i+=e}return new Float32Array(3*i)}function UT(t=[]){const e=t.length,i=new Float64Array(2*e);for(let n=0;n<e;n++){let e,r;const o=t[n];o.x?(e=o.x,r=o.y):(e=o[0],r=o[1]),i[2*n]=e,i[2*n+1]=r}return i.buffer}const VT=new fm("#fff"),WT=new fm("#fff");function ZT(t,e,i,n,r,o){const s=XT(t,i,n,r,!1);if(!s)return null;o?(null==o[e]&&(o[e]=i.altitudeToVector3(e,e).x),e=o[e]):e=i.altitudeToVector3(e,e).x;const{position:a,normal:h,uv:l,indices:c}=AT(s,{depth:e});return{position:a,normal:h,uv:l,indices:c}}function qT(t,e,i,n){void 0===n&&(n=0);const r=t.attributes.position.array,o=r.length;let s;if(WT.setStyle(e),VT.setStyle(i),Array.isArray(n)){let t=0;for(let e=0,i=n.length;e<i;e++){const{count:i}=n[e].position;t+=3*i}s=new Float32Array(t)}else s=new Float32Array(r.length);if(Array.isArray(n))for(let t=0,e=n.length;t<e;t++){const{middleZ:e,start:i,end:o}=n[t].position;for(let t=i;t<o;t+=3){r[t+2]>e?(s[t]=VT.r,s[t+1]=VT.g,s[t+2]=VT.b):(s[t]=WT.r,s[t+1]=WT.g,s[t+2]=WT.b)}}else for(let t=0;t<o;t+=3){r[t+2]>n?(s[t]=VT.r,s[t+1]=VT.g,s[t+2]=VT.b):(s[t]=WT.r,s[t+1]=WT.g,s[t+2]=WT.b)}return TS(t,"color",new ym(s,3,!0)),s}function XT(t,e,i,n,r=!1){if(!t)return null;let o=[];if(t instanceof ta)o=t.getGeometries().map((o=>YT(o,e,i||t.getCenter(),n,r)));else if(t instanceof js){const s=YT(t,e,i||t.getCenter(),n,r);o.push(s)}else if(HS(t))if(US(t)){const s=ZS(t);for(let a=0,h=s.length;a<h;a++)o.push(YT(s[a],e,i||WS(t),n,r))}else{const s=YT(t,e,i||WS(t),n,r);o.push(s)}return o}function YT(t,e,i,n,r=!1){let o,s,a;if(HS(t)){const e=VS(t);o=e[0],s=e.slice(1,e.length),i=i||WS(t)}else t instanceof js&&(o=t.getShell(),s=t.getHoles(),i=i||t.getCenter());n=n||e.coordinateToVector3(i),a=r?e.coordinatiesToGLFloatArray(o,n).positons2d:e.coordinatiesToGLArray(o,n);const h=[r?a.buffer:a];if(s&&s.length>0)for(let t=0,i=s.length;t<i;t++){let i;i=r?e.coordinatiesToGLFloatArray(s[t],n).positons2d:e.coordinatiesToGLArray(s[t],n),h.push(r?i.buffer:i)}return h}function JT(t){if(!t)return null;let e=[];if(t instanceof ta)e=t.getGeometries().map((t=>QT(t,!1)));else if(t instanceof js){const i=QT(t,!1);e.push(i)}else if(HS(t))if(US(t)){const i=ZS(t);for(let t=0,n=i.length;t<n;t++)e.push(QT(i[t],!0))}else{const i=QT(t,!0);e.push(i)}return e}function QT(t,e){let i,n;if(e){const e=VS(t);i=e[0],n=e.slice(1,e.length)}else t instanceof js&&(i=t.getShell(),n=t.getHoles());const r=[UT(i)];if(n&&n.length>0)for(let t=0,e=n.length;t<e;t++){const e=UT(n[t]);r.push(e)}return r}function KT(t,e,i,n=!0){let r,o,s=[];if(Array.isArray(t)&&t[0]instanceof jp)s=t;else{Array.isArray(t)&&(t=new Zs(t));const a=0;let h,l;NS(t)?(h=VS(t),i||(l=WS(t))):t instanceof Zs&&(h=t.getCoordinates(),i||(l=t.getCenter()));const c=e.coordinateToVector3(i||l);if(n)for(let t=0,i=h.length;t<i;t++){const i=h[t],n=e.coordinateToVector3(i,a).sub(c);s.push(n)}else{const t=e.coordinatiesToGLFloatArray(h,c);r=t.positions,o=t.positons2d}}if(!n)return{positions:r,positionsV:s,positions2d:o,arrayBuffer:o.buffer};o=new Float32Array(2*s.length),r=new Float32Array(3*s.length);for(let t=0,e=s.length;t<e;t++){const e=3*t,i=s[t];r[e]=i.x,r[e+1]=i.y,r[e+2]=i.z;const n=2*t;o[n]=i.x,o[n+1]=i.y}return{positions:r,positionsV:s,positions2d:o,arrayBuffer:o.buffer}}function $T(t,e,i,n){const r=[],o=[],s=[];let a,h;for(let i=0,l=t.length;i<l;i++){const l=t[i];for(let t=0,i=l.length;t<i;t++){const i=l[t],c=i.join(",").toString();a?(c!==a&&(h=e.coordinateToVector3(i,0).sub(n),r.push(h.x,h.y,h.z),o.push(h),s.push(i)),a=c):(s.push(i),a=c,h=e.coordinateToVector3(i,0).sub(n),r.push(h.x,h.y,h.z),o.push(h))}}return{positions:r,positionsV:o,lnglats:s}}function tE(t){let e;const i=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];for(let t=0,n=r.length;t<n;t++){const n=r[t],o=n.join(",").toString();e?(o!==e&&i.push(n),e=o):(i.push(n),e=o)}}return i}function eE(t,e=1,i=1,n,r){const o=KT(t,n,r).positionsV,s=[];for(let t=0,e=o.length;t<e;t++){const e=o[t];s.push([e.x,e.y])}const{indices:a,position:h,normal:l,uv:c}=OT([s],{lineWidth:e,depth:i});return{position:h,normal:l,indices:a,uv:c}}function iE(t){let e,i=[];return t instanceof $s?(i=t.getGeometries(),e=t.getCenter()):t instanceof Zs?(i.push(t),e=t.getCenter()):NS(t)&&(e=WS(t),US(t)?i=ZS(t):i.push(t)),{lineStrings:i,center:e}}function nE(t){const e=new Float32Array(2*t.length-6);let i=0;for(let n=0,r=t.length/3;n<r;n++){const o=t[3*n],s=t[3*n+1],a=t[3*n+2];if(n>0&&n<r-1){const t=3*i;e[t]=o,e[t+1]=s,e[t+2]=a,i++}const h=3*i;e[h]=o,e[h+1]=s,e[h+2]=a,i++}return e}function rE(t){let e=0;const i=t.length;if(1===i)return t[0];for(let n=0;n<i;n++)e+=t[n].length;const n=new Float32Array(e);let r=0;for(let e=0;e<i;e++)n.set(t[e],r),r+=t[e].length;return n}function oE(t){return t instanceof Zs?UT(t.getCoordinates()):jS(t)?UT(t.geometry.coordinates):void 0}let sE;function aE(){return sE||(sE=new Nm,TS(sE,"position",new ym(new Float32Array(3),3))),sE}const hE="__maptalks.three__";let lE;var cE;function uE(){return Oc||console.error("maptalks.worker is not defined,You can't use ThreeVectorTileLayer"),!cE&&lE&&(cE=new lE(hE)),cE}function dE(t,e,i={}){return void 0!==t&&"number"==typeof t&&0!==t?(void 0===i[t]&&(i[t]=e.distanceToVector3(t,t).x),i[t]):0}function pE(t,e,i={}){return void 0!==t&&"number"==typeof t&&0!==t?(void 0===i[t]&&(i[t]=e.altitudeToVector3(t,t).x),i[t]):0}function fE(t,e,i,n,r=[]){const o=i.isMercator();let s,a,h;if(o){const t=i.getMap();s=t.getGLRes(),a=t.getSpatialReference().getTransformation().matrix}e&&(h=i.coordinateToVector3(e));const l=[],c=[],u={},d={},p=t.length;for(let s=0;s<p;s++){const a=t[s],p=r[s]?r[s]:jS(n[s])?n[s].properties:n[s].getProperties()||{};e||(h=i.coordinateToVector3(p.center));let f=p.width||1,m=p.height||1,g=p.bottomHeight||0;f=dE(f,i,u),m=pE(m,i,d),g=pE(g,i,d);const v=[];for(let t=0,n=a.length;t<n;t++){const n=a[t];let r;r=o?oE(n):KT(n,i,e,!1).arrayBuffer,c.push(r),v.push(r)}const y={id:p.id,data:v,height:m,width:f,bottomHeight:g};o&&(y.center=[h.x,h.y]),l.push(y)}return{datas:l,transfer:c,glRes:s,matrix:a,center:o?[h.x,h.y]:null}}function mE(t,e,i,n,r=[]){const o=i.isMercator();let s,a,h;if(o){const t=i.getMap();s=t.getGLRes(),a=t.getSpatialReference().getTransformation().matrix}e&&(h=i.coordinateToVector3(e));const l=[],c=[],u={},d=t.length;for(let s=0;s<d;s++){const a=t[s],d=r[s]?r[s]:jS(n[s])?n[s].properties:n[s].getProperties()||{};e||(h=i.coordinateToVector3(d.center));let p=d.bottomHeight||0;p=pE(p,i,u);const f=[];for(let t=0,n=a.length;t<n;t++){const n=a[t];if(o){const t=oE(n);f.push(t),f.push(t)}else{const t=KT(n,i,e,!1).arrayBuffer;c.push(t),f.push(t)}}const m={id:d.id,data:f,bottomHeight:p};o&&(m.center=[h.x,h.y]),l.push(m)}return{datas:l,transfer:c,glRes:s,matrix:a,center:o?[h.x,h.y]:null}}function gE(t){return t.map((t=>t.data))}function vE(t){return t.map((t=>t.option||t.baseObject.getOptions()))}Oc&&(lE=class extends Oc.Actor{test(t,e){this.send(t,null,e)}pushQueue(t={}){const{type:e,data:i,callback:n,layer:r,key:o,center:s,lineStrings:a,options:h,id:l}=t;let c;e.indexOf("ExtrudePolygon")>-1?c=function(t=[],e,i,n=[]){const r=i.isMercator();let o,s,a;if(r){const t=i.getMap();o=t.getGLRes(),s=t.getSpatialReference().getTransformation().matrix}e&&(a=i.coordinateToVector3(e));const h=t.length,l=[],c=[],u={};for(let o=0;o<h;o++){const s=t[o],h=s,d=n[o]?n[o]:HS(h)?h.properties:h.getProperties()||{};let p;e||(a=i.coordinateToVector3(d.center)),p=r?JT(s):XT(s,i,d.center||e,a,!0);for(let t=0,e=p.length;t<e;t++){const e=p[t];for(let t=0,i=e.length;t<i;t++)c.push(e[t])}let f=d.height||1,m=d.bottomHeight||0;f=pE(f,i,u),m=pE(m,i,u);const g={id:d.id,data:p,height:f,bottomHeight:m};r&&(g.center=[a.x,a.y]),l.push(g),h._properties&&delete h._properties}return{datas:l,transfer:c,glRes:o,matrix:s,center:r?[a.x,a.y]:null}}(i,s,r,h):"ExtrudeLines"===e?c=fE(i,s,r,a):"Point"===e||("Line"===e||"FatLine"===e?c=mE(i,s,r,a,h):"Lines"===e||"FatLines"===e?c=mE(i,s,r,a):"ExtrudeLine"===e?c=fE(i,s,r,a,h):"Bar"!==e&&"Bars"!==e||(c=function(t){const e=t.length,i=new Float32Array(7*e);let n=0;for(let r=0;r<e;r++){let{center:e,radialSegments:o,radius:s,height:a,altitude:h,id:l}=t[r];e=e||[0,0],i[n]=e[0],i[n+1]=e[1],i[n+2]=o||6,i[n+3]=s||1,i[n+4]=a,i[n+5]=h||0,i[n+6]=l,n+=7}const r=i.buffer;return{datas:r,transfer:[r]}}(i))),c?this.send({type:e,datas:c.datas,glRes:c.glRes,matrix:c.matrix,center:c.center},c.transfer,(function(t,e){t&&console.error(t),e.key=o,e.id=l,n(e)})):console.error(`not support '${e}' worker`)}});class yE{constructor(){this.queueMap={},this.tempQueue=[],this.time=this.getCurrentTime(),this.deQueueCount=5,this.resultQueue=[]}getActor(){return uE()}getCurrentTime(){return Ii.now()}loop(){this.deQueue()}push(t){return this.tempQueue.push(t),t.id&&(this.queueMap[t.id]=t),this}reset(){return this.time=this.getCurrentTime(),this.tempQueue=[],this}pushResult(t){if(t)return Array.isArray(t)||(t=[t]),t.forEach((t=>{this.resultQueue.push(t)})),this}deQueue(){if(!this.resultQueue.length)return this;const t=this.deQueueCount;return(this.resultQueue.slice(0,t)||[]).forEach((t=>{const{id:e}=t;if(this.queueMap[e]){const{baseObject:i}=this.queueMap[e];i&&i._workerLoad&&i._workerLoad(t),delete this.queueMap[e]}})),this.resultQueue.splice(0,t),this}}const _E=new class extends yE{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){uE().pushQueue({type:"ExtrudePolygon",layer:this.tempQueue[0].layer,data:gE(this.tempQueue),options:vE(this.tempQueue),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},xE=new class extends yE{loop(){if(this.tempQueue.length){const t=uE();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"ExtrudePolygons",layer:e.layer,data:e.data,key:e.key,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},wE=new class extends yE{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){uE().pushQueue({type:"ExtrudeLine",layer:this.tempQueue[0].layer,data:gE(this.tempQueue),options:vE(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},bE=new class extends yE{loop(){if(this.tempQueue.length){const t=uE();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"ExtrudeLines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},ME=new class extends yE{constructor(){super(),this.deQueueCount=200}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){uE().pushQueue({type:"Line",layer:this.tempQueue[0].layer,data:gE(this.tempQueue),options:vE(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},SE=new class extends yE{loop(){if(this.tempQueue.length){const t=uE();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"Lines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},TE=new class extends yE{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){uE().pushQueue({type:"FatLine",layer:this.tempQueue[0].layer,data:gE(this.tempQueue),options:vE(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},EE=new class extends yE{loop(){if(this.tempQueue.length){const t=uE();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"FatLines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},CE=new class extends yE{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){uE().pushQueue({type:"Bar",layer:this.tempQueue[0].layer,data:gE(this.tempQueue),options:vE(this.tempQueue),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},PE=new class extends yE{constructor(){super(),this.deQueueCount=1}loop(){if(this.tempQueue.length){const t=uE();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"Bars",layer:e.layer,data:e.data,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},AE={isRunning:!1,tasks:[],addTask:t=>{t&&AE.tasks.push(t)},removeTask:t=>{AE.tasks.splice(AE.tasks.indexOf(t),1)},loop(){_E.loop(),xE.loop(),wE.loop(),bE.loop(),ME.loop(),SE.loop(),TE.loop(),EE.loop(),CE.loop(),PE.loop(),AE.tasks.forEach((t=>{t&&t.loop&&t.loop()})),Ii.requestAnimFrame(AE.loop)},star(){AE.isRunning||(AE.isRunning=!0,AE.loop())}};function LE(t){const{position:e,normal:i,uv:n,indices:r}=RE(t),o=new Nm,s=new Float32Array(e.length);return s.fill(1,0,e.length),TS(o,"color",new ym(s,3)),TS(o,"normal",new ym(i,3)),TS(o,"position",new ym(e,3)),n&&n.length&&TS(o,"uv",new ym(n,2)),o.setIndex(new ym(r,1)),o}function RE(t){const e={},i={};for(let n=0;n<t.length;++n){const r=t[n];for(const t in r)void 0===e[t]&&(e[t]=[],i[t]=0),e[t].push(r[t]),i[t]+=r[t].length}const n={};let r=0;const o=new Uint32Array(i.indices);for(const t in e)if("indices"===t){const i=e[t];let n=0;for(let t=0,s=i.length;t<s;t++){const s=i[t];for(let t=0,e=s.length;t<e;t++)o[n]=s[t]+r,n++;r+=e.position[t].length/3}}else{const r=OE(e[t],i[t]);if(!r)return null;n[t]=r}return n.indices=o,n}function OE(t,e){const i=new Float32Array(e);let n=0;for(let e=0;e<t.length;++e)i.set(t[e],n),n+=t[e].length;return i}function DE(t){const{position:e,normal:i,uv:n,indices:r}=t,o=new Nm;return TS(o,"normal",new ym(new Float32Array(i),3)),TS(o,"position",new ym(new Float32Array(e),3)),TS(o,"uv",new ym(new Float32Array(n),2)),o.setIndex(new ym(new Uint32Array(r),1)),o}function IE(t){const e=new Nm;return TS(e,"normal",t.getAttribute("normal")),TS(e,"position",t.getAttribute("position").clone()),e.setIndex(t.getIndex()),e}let kE;function zE(){if(!kE){const t=1e-6;kE=new og(t,t,t)}return kE}zE();const FE=new og(1,1,1);FE.translate(0,0,.5);const BE=new fm("#fff"),NE=new fm("#fff");function HE(t){const{position:e,normal:i,uv:n,indices:r}=function(t,e){void 0===e&&(e={}),e=Object.assign({},{radius:1,height:2,radialSegments:6},e);for(var i=Math.round(Math.max(4,e.radialSegments)),n=e,r=n.radius,o=n.height,s=360/i/360*Math.PI*2,a=i+1,h=new Float32Array(3*a*2),l=t[0],c=t[1],u=0,d=0,p=3*a,f=2*a,m=[],g=[],v=-1;v<i;v++){var y,_,x=s*v,w=Math.cos(x)*r+l,b=Math.sin(x)*r+c;h[u]=w,h[u+1]=b,h[u+2]=0,h[u+p]=w,h[u+1+p]=b,h[u+2+p]=o,y=.5+w/r/2,_=.5+b/r/2,g[d]=y,g[d+1]=_,g[d+f]=y,g[d+1+f]=_,u+=3,d+=2,v>1&&m.push(0,v-1,v)}h[u-=3]=h[0],h[u+1]=h[1],h[u+2]=h[2];var M=h.length;h[M-3]=h[0],h[M-2]=h[1],h[M-1]=o;for(var S=m.length,T=0;T<S;T++){var E=m[T];m.push(E+a)}var C=new Float32Array(2*(3*a*2-6)),P=-1;u=2*a,d=0;for(var A=0,L=h.length/2;A<L-3;A+=3){var R=h[A],O=h[A+1],D=h[A+3],I=h[A+4];C[++P]=R,C[++P]=O,C[++P]=o,C[++P]=D,C[++P]=I,C[++P]=o,C[++P]=R,C[++P]=O,C[++P]=0,C[++P]=D,C[++P]=I,C[++P]=0;var k=u+2,z=u+3,F=u,B=u+1;m.push(F,k,B,k,z,B),u+=4;var N=d/a,H=(d+1)/a;g.push(N,o/r/2,H,o/r/2,N,0,H,0),d++}var j=new Float32Array(h.length+C.length);j.set(h,0),j.set(C,h.length);var G=ST(m,j);return{points:h,indices:new Uint32Array(m),position:j,normal:G,uv:new Float32Array(g)}}(t.center||[0,0],t),o=new Nm;return TS(o,"normal",new ym(i,3)),TS(o,"position",new ym(e,3)),TS(o,"uv",new ym(n,2)),o.setIndex(new ym(r,1)),o}function jE(t){const e=Object.assign({},t);return e._radius&&(e.radius=e._radius),HE(e)}function GE(t,e,i,n="y",r=0){let o=0;"y"===n?o=1:"z"===n&&(o=2);const s=t.attributes.position.array,a=s.length;NE.setStyle(e),BE.setStyle(i);const h=new Float32Array(a);if(Array.isArray(r))for(let t=0,e=r.length;t<e;t++){const{middleZ:e,start:i,end:n}=r[t].position;for(let t=i;t<n;t+=3){s[t+2]>e?(h[t]=BE.r,h[t+1]=BE.g,h[t+2]=BE.b):(h[t]=NE.r,h[t+1]=NE.g,h[t+2]=NE.b)}}else for(let t=0;t<a;t+=3){s[t+o]>r?(h[t]=BE.r,h[t+1]=BE.g,h[t+2]=BE.b):(h[t]=NE.r,h[t+1]=NE.g,h[t+2]=NE.b)}return TS(t,"color",new ym(h,3,!0)),h}function UE(t){const e=[],i=t.length;let n=0;for(let e=0;e<i;e++){const{color:i}=t[e].attributes;i&&(n+=i.array.length)}const r=new Float32Array(n);let o=0;for(let i=0,n=t.length;i<n;i++){const{color:n,normal:s,position:a,uv:h}=t[i].attributes,l=t[i].index;n&&(r.set(n.array,o),o+=n.array.length),e.push({normal:s.array,uv:h.array,position:a.array,indices:l.array})}const s=LE(e);r.length&&TS(s,"color",new ym(r,3,!0));for(let e=0,i=t.length;e<i;e++)t[e].dispose();return s}function VE(){return FE}const WE={radius:10,height:100,radialSegments:6,altitude:0,topColor:"",bottomColor:"#2d2f61",heightEnable:!0};class ZE extends zS{constructor(t,e,i,n){e=Ii.extend({},WE,e,{layer:n,coordinate:t}),super(),this._initOptions(e);const{height:r,radius:o,topColor:s,bottomColor:a,altitude:h,asynchronous:l}=e;let c;if(e.height=n.altitudeToVector3(r,r).x,e.radius=n.distanceToVector3(o,o).x,l){c=zE();const t=Ii.GUID();this.getOptions().id=t,CE.push({data:{radius:e.radius,height:e.height,radialSegments:e.radialSegments,id:t},layer:n,id:t,baseObject:this})}else c=jE(e),s&&(GE(c,a,s,"z",e.height/2),i.vertexColors=ES());this._createMesh(c,i);const u=n.altitudeToVector3(h,h).x,d=n.coordinateToVector3(t,u);this.getObject3d().position.copy(d),this.type="Bar"}_workerLoad(t){const e=DE(t),{topColor:i,bottomColor:n,height:r}=this.getOptions(),o=this.getObject3d(),s=o.material;if(i){GE(e,n,i,"z",this.getLayer().altitudeToVector3(r,r).x/2),s.vertexColors=ES()}o.geometry=e,o.material.needsUpdate=!0,this._fire("workerload",{target:this})}}function qE(t){const e=[];return t&&t.length&&t.forEach((t=>{t=t instanceof fm?t:new fm(t),e.push(t.r,t.g,t.b)})),e}const XE={altitude:0,bottomHeight:0,colors:null};class YE extends zS{constructor(t,e,i,n){e=Ii.extend({},XE,e,{layer:n,lineString:t}),super(),this._initOptions(e);const{lineStrings:r,center:o}=iE(t),{asynchronous:s}=e;let a;if(s){a=aE();const i=Ii.GUID();this.getOptions().id=i,this.getOptions().center=o,ME.push({id:i,data:r,layer:n,key:e.key,lineString:t,baseObject:this})}else{const t=[];for(let e=0,i=r.length;e<i;e++){const i=r[e],{positions:s}=KT(i,n,o,!1);t.push(nE(s))}const s=rE(t);a=new Nm,TS(a,"position",new ym(s,3)),jT(a,e.bottomHeight,n);const h=qE(e.colors);h&&h.length&&(TS(a,"color",new Cm(h,3)),i.vertexColors=ES())}this._createLineSegments(a,i);const{altitude:h}=e,l=n.altitudeToVector3(h,h).x,c=n.coordinateToVector3(o,l);this.getObject3d().position.copy(c),this.type="Line"}_workerLoad(t){const e=new Nm;TS(e,"position",new ym(new Float32Array(t.position),3));const i=qE(this.getOptions().colors),n=this.getObject3d(),r=n.material;i&&i.length&&(TS(e,"color",new Cm(i,3)),r.vertexColors=ES()),this._computeLineDistances(e),n.geometry=e,n.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const JE={bottomHeight:0,width:3,height:1,altitude:0,topColor:null,bottomColor:"#2d2f61",heightEnable:!0};class QE extends zS{constructor(t,e,i,n){e=Ii.extend({},JE,e,{layer:n,lineString:t}),super(),this._initOptions(e);const{height:r,width:o,bottomColor:s,topColor:a,bottomHeight:h,altitude:l,asynchronous:c}=e,u=n.altitudeToVector3(r,r).x,d=n.distanceToVector3(o,o).x,{lineStrings:p,center:f}=iE(t);let m;if(c){m=zE();const e=Ii.GUID();this.getOptions().id=e,this.getOptions().center=f,wE.push({id:e,data:p,layer:n,center:f,lineString:t,baseObject:this})}else{const t=[];let e=0;const r={};for(let i=0,o=p.length;i<o;i++){const o=eE(p[i],d,u,n,f);e=jT(o,h,n,r),t.push(o)}m=LE(t),a&&(qT(m,s,a,e+u/2),i.vertexColors=ES())}this._createMesh(m,i);const g=n.altitudeToVector3(l,l).x,v=n.coordinateToVector3(f,g);this.getObject3d().position.copy(v),this.type="ExtrudeLine"}_workerLoad(t){const e=DE(t),{topColor:i,bottomColor:n,bottomHeight:r,height:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(i){const t=this.getLayer();qT(e,n,i,t.altitudeToVector3(r,r).x+t.altitudeToVector3(o,o).x/2),a.vertexColors=ES()}s.geometry=e,s.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const KE={altitude:0,height:1,bottomHeight:0,topColor:null,bottomColor:"#2d2f61",heightEnable:!0};class $E extends zS{constructor(t,e,i,n){e=Ii.extend({},KE,e,{layer:n,polygon:t}),super(),this._initOptions(e);const{height:r,topColor:o,bottomColor:s,altitude:a,bottomHeight:h,asynchronous:l}=e;let c;const u=HS(t)?WS(t):t.getCenter();if(l){c=zE();const e=Ii.GUID();this.getOptions().id=e,this.getOptions().center=u,_E.push({data:t,layer:n,id:e,baseObject:this})}else{c=function(t,e,i,n){const{position:r,normal:o,uv:s,indices:a}=ZT(t,e,i,n),h=new Float32Array(r.length);h.fill(1,0,r.length);const l=new Nm;return TS(l,"color",new ym(h,3)),TS(l,"normal",new ym(o,3)),TS(l,"position",new ym(r,3)),TS(l,"uv",new ym(s,2)),l.setIndex(new ym(a,1)),l}(t,r,n);const e=jT(c,h,n);if(o){qT(c,s,o,e+n.altitudeToVector3(r,r).x/2),i.vertexColors=ES()}}this._createMesh(c,i);const d=n.altitudeToVector3(a,a).x,p=n.coordinateToVector3(u,d);this.getObject3d().position.copy(p),this.type="ExtrudePolygon"}_workerLoad(t){const e=DE(t),{topColor:i,bottomColor:n,bottomHeight:r,height:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(i){const t=this.getLayer();qT(e,n,i,t.altitudeToVector3(r,r).x+t.altitudeToVector3(o,o).x/2),a.vertexColors=ES()}s.geometry=e,s.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const tC={altitude:0,coordinate:null};class eC extends zS{constructor(t,e={},i){e.coordinate||(console.warn("coordinate is null,it is important to locate the model"),e.coordinate=i.getMap().getCenter()),e=Ii.extend({},tC,e,{layer:i,model:t}),super(),this._initOptions(e),this._createGroup(),this.getObject3d().add(t);const{altitude:n,coordinate:r}=e,o=i.altitudeToVector3(n,n).x,s=i.coordinateToVector3(r,o);this.getObject3d().position.copy(s),this.type="Model"}}const iC=Math.PI/180,nC=6378137;function rC(t){return t*iC}function oC(t,e){if(!t||!e)return 0;Array.isArray(t)||(t=t.toArray()),Array.isArray(e)||(e=e.toArray());let i=rC(t[1]);const n=rC(e[1]),r=i-n,o=rC(t[0])-rC(e[0]);return i=2*Math.asin(Math.sqrt(Math.pow(Math.sin(r/2),2)+Math.cos(i)*Math.cos(n)*Math.pow(Math.sin(o/2),2))),i*=nC,Math.round(1e5*i)/1e5}function sC(t,e){const{len:i,c1:n,c2:r}=t,o=r[0]-n[0],s=r[1]-n[1],a=e/i;return[n[0]+a*o,n[1]+a*s]}const aC=1e3;const hC={trail:5,chunkLength:50,width:2,height:1,speed:1,altitude:0,interactive:!1,heightEnable:!0};class lC extends zS{constructor(t,e,i,n){e=Ii.extend({},hC,e,{layer:n,lineString:t}),super(),this._initOptions(e);const{width:r,height:o,altitude:s,speed:a,chunkLength:h,trail:l}=e;let c,u;NS(t)?(c=WS(t),u=VS(t)):(c=t.getCenter(),u=t);const d=function(t,e=10){e=Math.max(e,.1),Array.isArray(t)||(t=t.getCoordinates().map((t=>t.toArray())));const i=t.length;let n=[],r=0;for(let e=0;e<i-1;e++){const i=oC(t[e],t[e+1]),o=Math.floor(i);n.push({c1:t[e],len:o,c2:t[e+1]}),r+=o}if(r<=e)return n.map((t=>[t.c1,t.c2]));if(1===n.length&&n[0].len<=e)return[[n[0].c1,n[0].c2]];const o=n.length;let s,a=0,h=0;const l=[];let c=[n[0].c1];for(;a<o;){const{len:t,c2:i}=n[a];if(h+=t,h<e&&(c.push(i),a===o-1&&l.push(c),a++),h===e&&(c.push(i),h=0,l.push(c),c=[i],a++),h>e){const i=t-h+e;s=sC(n[a],i),c.push(s),l.push(c),h=0,n[a].c1=s,n[a].len=t-i,c=[],c.push(s)}}return l}(u,h),p=n.coordinateToVector3(c),f=new Nm,m=new Float32Array(3e3),g=new Float32Array(3e3),v=new Uint16Array(aC);TS(f,"position",new ym(m,3)),TS(f,"normal",new ym(g,3)),f.setIndex(new ym(v,1));const y=n.distanceToVector3(r,r).x,_=n.altitudeToVector3(o,o).x;this._createMesh(f,i);const x=n.altitudeToVector3(s,s).x,w=n.coordinateToVector3(c,x);this.getObject3d().position.copy(w),this._params={index:0,chunkLines:d,geometries:[],layer:n,trail:Math.max(1,l),lineWidth:y,depth:_,speed:Math.min(1,a),idx:0,loaded:!0,center:c,centerPt:p,workerInitCount:0},this._init(this._params),this.type="ExtrudeLineTrail"}_init(t){const{layer:e,trail:i,lineWidth:n,depth:r,chunkLines:o,positionMap:s,centerPt:a,center:h}=t,l=o.length,c=[];if(this.options.asynchronous){t.loaded=!1;const n=Ii.GUID();for(let t=0;t<l;t++){const r={type:"Feature",geometry:{type:"LineString",coordinates:tE(o.slice(t,t+i))}},s=`${n}-${t}`,a=Ii.extend({},this.options);a.id=s,a.center=h,wE.push({id:s,data:[r],layer:e,center:h,lineString:r,baseObject:this,option:a})}}else for(let t=0;t<l;t++){const s=$T(o.slice(t,t+i),e,0,a).positionsV;c.push(eE(s,n,r,e))}}_animation(){const{index:t,geometries:e,speed:i,idx:n,chunkLines:r,trail:o,lineWidth:s,depth:a,loaded:h,layer:l,positionMap:c,centerPt:u}=this._params;if(!h)return;const d=Math.round(t);if(d>n){this._params.idx++;let t=e[d];if(!t){t=eE($T(r.slice(d,d+o),l,0,u).positionsV,s,a,l),e[d]=t}const i=this.getObject3d();!function(t,e,i,n){const r=e.length;t.attributes.normal.count=r,t.attributes.position.count=r;const o=t.attributes.position.array,s=t.attributes.normal.array;for(let t=0;t<r;t++)o[t]=e[t],s[t]=i[t];t.index.count=n.length;for(let e=0,i=n.length;e<i;e++)t.index.array[e]=n[e]}(i.geometry,t.position,t.normal,t.indices),i.geometry.attributes.position.needsUpdate=!0,i.geometry.attributes.normal.needsUpdate=!0,i.geometry.index.needsUpdate=!0}t>=r.length-1&&(this._params.index=-1,this._params.idx=-1),this._params.index+=i}_workerLoad(t){if(!t)return this;const{id:e,indices:i,position:n,normal:r,uv:o}=t;if(!(e&&i&&n&&r&&o))return;let s=e.split("-")[1];if(s=parseInt(s),Ii.isNumber(s)){this._params.geometries[s]={indices:new Uint32Array(i),position:new Float32Array(n),uv:new Float32Array(o),normal:new Float32Array(r)},this._params.workerInitCount++}this._params.workerInitCount===this._params.chunkLines.length&&(this._params.loaded=!0,this._fire("workerload",{target:this}))}}const cC=["click","mousemove","mousedown","mouseup","dblclick","contextmenu"].join(" ").toString(),uC=new mm;uC.vertexColors=ES();const dC=t=>class extends t{_initBaseObjectsEvent(t){if(t&&Array.isArray(t)&&t.length)for(let e=0,i=t.length;e<i;e++){const i=t[e];this._proxyEvent(i)}return this}_proxyEvent(t){t.on("add",(t=>{this._showGeometry(t.target,!0)})),t.on("remove",(t=>{this._showGeometry(t.target,!1)})),t.on("mouseout",(t=>{this._mouseover=!1,this.fire("mouseout",Object.assign({},t,{target:this,selectMesh:this.getSelectMesh?this.getSelectMesh():null}))})),t.on(cC,(t=>{this.fire(t.type,Object.assign({},t,{target:this,selectMesh:this.getSelectMesh?this.getSelectMesh():null}))}))}_getHideGeometryIndex(t){const e=[];let i=0;for(let n=0,r=this._geometriesAttributes.length;n<r;n++)!0===this._geometriesAttributes[n].hide&&(e.push(n),i+=this._geometriesAttributes[n][t].count);return{indexs:e,count:i}}_updateAttribute(t,e){const{indexs:i}=this._getHideGeometryIndex(e),n=this._geometryCache.attributes[e].array,r=n.length;for(let e=0;e<r;e++)t.array[e]=n[e];let o=NaN;this.getObject3d()instanceof I_&&(o=0);for(let n=0;n<i.length;n++){const r=i[n],{start:s,end:a}=this._geometriesAttributes[r][e];for(let e=s;e<a;e++)t.array[e]=o}return this}_showGeometry(t,e){let i;if(t&&(i=t.getOptions().index),null!=i){const t=this._geometriesAttributes[i],{hide:n}=t;if(n===e)return this;t.hide=e;const r=this.getObject3d().geometry;this._updateAttribute(r.attributes.position,"position"),r.attributes.position.needsUpdate=!0,this.isHide=e}return this}getSelectMesh(){const t=this._getIndex();if(null!=t)return{data:this._datas[t],baseObject:this._baseObjects[t]}}_getIndex(t){return null==t&&(t=this.faceIndex||this.index),t}_init(){const t=this.getLayer().getPick();this.on("add",(()=>{t.add(this.pickObject3d)})),this.on("remove",(()=>{t.remove(this.pickObject3d)}))}_setPickObject3d(){if(!this._colorMap)return;const t=this._geometryCache||this.getObject3d().geometry.clone(),e=this.getLayer().getPick(),{_geometriesAttributes:i}=this,n=i.length,r=GT(i);let o=0;for(let t=0;t<n;t++){const n=e.getColor(),s=n.getHex();this._colorMap[s]=t;const{count:a}=i[t].position;this._datas[t].colorIndex=s;for(let t=0;t<a;t++)r[o]=n.r,r[o+1]=n.g,r[o+2]=n.b,o+=3}TS(t,"color",new ym(r,3,!0));const s=e.getColor().getHex(),a=new ng(t,uC);a.position.copy(this.getObject3d().position),a._colorIndex=s,this.setPickObject3d(a)}},pC={altitude:0,height:1,bottomHeight:0,topColor:null,bottomColor:"#2d2f61"},fC=new Hn(0,0);class mC extends(dC(zS)){constructor(t,e,i,n){Array.isArray(t)||(t=[t]);const r=t.length;0===r&&console.error("polygons is empty");let o=1/0,s=1/0,a=-1/0,h=-1/0;for(let e=0;e<r;e++){const i=t[e],n=i.getCenter?i.getCenter():WS(i,fC);let r,l;Array.isArray(n)?(r=n[0],l=n[1]):n instanceof Hn&&(r=n.x,l=n.y),o=Math.min(o,r),s=Math.min(s,l),a=Math.max(a,r),h=Math.max(h,l)}const l=new Hn((o+a)/2,(s+h)/2);e=Ii.extend({},pC,e,{layer:n,polygons:t,coordinate:l});const{topColor:c,bottomColor:u,altitude:d,asynchronous:p}=e;let f;const m=[],g=[];if(super(),p)f=zE(),xE.push({id:Ii.GUID(),layer:n,key:e.key,center:l,data:t,baseObject:this});else{const e=n.coordinateToVector3(l),o=[];let s=0;const a={};for(let i=0;i<r;i++){const r=t[i],h=HS(r)?r.properties:r.getProperties()||{},c=h.height||1,u=h.bottomHeight||0,d=ZT(r,c,n,l,e,a);o.push(d);const p=jT(d,u,n,a),{position:f,normal:m,uv:v,indices:y}=d;y.length;const _=f.length/3;m.length,v.length,g[i]={position:{middleZ:p+a[c]/2,count:_,start:s,end:s+3*_},hide:!1},s+=3*_}f=LE(o),c&&(qT(f,u,c,g),i.vertexColors=ES())}this._initOptions(e),this._createMesh(f,i);const v=n.altitudeToVector3(d,d).x,y=n.coordinateToVector3(l,v);this.getObject3d().position.copy(y),this._baseObjects=m,this._datas=t,this._geometriesAttributes=g,this.faceIndex=null,this._geometryCache=IE(f),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(m),p||(this._setPickObject3d(),this._init()),this.type="ExtrudePolygons"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],i=Object.assign({},this.options,HS(e)?e.properties:e.getProperties(),{index:t});this._baseObjects[t]=new $E(e,i,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){return this.picked}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const i=DE(t);this._geometryCache=IE(i);const{topColor:n,bottomColor:r}=this.getOptions(),o=this.getObject3d(),s=o.material;if(n&&(qT(i,r,n,e),s.vertexColors=ES()),o.geometry=i,o.material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}function gC(t,e,i){const n=t.project(i),r=e.width/2,o=e.height/2;return{x:Math.round(n.x*r+r),y:Math.round(-n.y*o+o)}}const vC={altitude:0,height:0,color:null},yC=new jp;class _C extends zS{constructor(t,e,i,n){e=Ii.extend({},vC,e,{layer:n,coordinate:t}),super();let{height:r,altitude:o,color:s,size:a}=e;const h=[],l=[];s&&(s=s instanceof fm?s:new fm(s),l.push(s.r,s.g,s.b));const c=n.altitudeToVector3(r,r).x,u=n.coordinateToVector3(t,c);h.push(0,0,u.z);const d=new Nm;TS(d,"position",new Cm(h,3,!0)),l.length&&TS(d,"color",new Cm(l,3,!0)),void 0!==a&&TS(d,"size",new Cm([a],1,!0)),e.positions=u,this._initOptions(e),this._createPoints(d,i);const p=n.altitudeToVector3(o,o).x,f=new jp(u.x,u.y,p);this.getObject3d().position.copy(f),this.type="Point"}identify(t){const e=this.getLayer(),i=this.getMap().getSize(),n=this.getLayer().getCamera(),r=this.getOptions().positions,o=this.getOptions().altitude;let s=this.getObject3d().material.size;void 0===s&&(s=this.options.size||1);const a=this.getMap().coordToContainerPoint(t),h=e.altitudeToVector3(o,o).x;yC.x=r.x,yC.y=r.y,yC.z=r.z+h;const l=gC(yC,i,n);return Math.sqrt(Math.pow(a.x-l.x,2)+Math.pow(a.y-l.y,2))<=s/2}}function xC(t,e){const{minx:i,miny:n,maxx:r,maxy:o}=t,[s,a]=e;return i<=s&&s<=r&&n<=a&&a<=o}class wC{constructor(t,e,i,n){this.minlng=t,this.minlat=e,this.maxlng=i,this.maxlat=n,this.minx=1/0,this.miny=1/0,this.maxx=-1/0,this.maxy=-1/0,this.coordinates=[],this.positions=[],this.indexs=[],this.key=null}updateBBoxPixel(t){let e=1/0,i=1/0,n=-1/0,r=-1/0;const{minlng:o,minlat:s,maxlng:a,maxlat:h}=this;return[[o,s],[o,h],[a,s],[a,h]].map((t=>new Hn(t))).map((e=>t.coordToContainerPoint(e))).forEach((t=>{e=Math.min(e,t.x),i=Math.min(i,t.y),n=Math.max(n,t.x),r=Math.max(r,t.y)})),this.minx=e,this.miny=i,this.maxx=n,this.maxy=r,this}containsCoordinate(t){let e,i;Array.isArray(t)?(e=t[0],i=t[1]):t instanceof Hn&&(e=t.x,i=t.y);const{minlng:n,minlat:r,maxlng:o,maxlat:s}=this;return n<=e&&e<=o&&r<=i&&i<=s}isRecCross(t,e){const{x:i,y:n}=t,r={minx:i-e/2,miny:n-e/2,maxx:i+e/2,maxy:n+e/2},{minx:o,miny:s,maxx:a,maxy:h}=r;return!!(xC(this,[o,s])||xC(this,[o,h])||xC(this,[a,s])||xC(this,[a,h])||xC(r,[this.minx,this.miny])||xC(r,[this.minx,this.maxy])||xC(r,[this.maxx,this.miny])||xC(r,[this.maxx,this.maxy]))}static initGrids(t,e,i,n){const r=[],o=(i-t)/30,s=(n-e)/30;let a=t,h=e;for(let i=0;i<30;i++){a=t+i*o;for(let t=0;t<30;t++){h=e+t*s;const n=new wC(a,h,a+o,h+s);n.key=t+"-"+i,r.push(n)}}return{grids:r,averageX:o,averageY:s,ROWS:30,COLS:30}}}const bC={altitude:0},MC=new jp;function SC(t,e){const i=Math.pow(10,e);return Math.round(t*i)/i}class TC extends(dC(zS)){constructor(t,e,i,n){Array.isArray(t)||(t=[t]),e=Ii.extend({},bC,e,{layer:n,points:t});let r=1/0,o=1/0,s=-1/0,a=-1/0;for(let e=0,i=t.length;e<i;e++){const{coordinate:i}=t[e];let n,h;Array.isArray(i)?(n=i[0],h=i[1]):i instanceof Hn&&(n=i.x,h=i.y),t[e].coords=[n,h],r=Math.min(r,n),o=Math.min(o,h),s=Math.max(s,n),a=Math.max(a,h)}const h=n.coordinateToVector3([(r+s)/2,(o+a)/2]),{grids:l,averageX:c,averageY:u,ROWS:d,COLS:p}=wC.initGrids(r,o,s,a);l.length;const f=new Float32Array(3*t.length),m=[],g=new Float32Array(3*t.length),v=new Float32Array(t.length),y=[],_=[],x={};let w=0,b=!1,M=!1;const S=new jp(0,0,0);for(let e=0,i=t.length;e<i;e++){let{coordinate:i,height:s,color:a,size:p,coords:y}=t[e];const T=3*e;a&&(b=!0,a=a instanceof fm?a:new fm(a),g[T]=a.r,g[T+1]=a.g,g[T+2]=a.b),p&&(M=!0,v[e]=p,w=Math.max(w,p));const E=NT(s,n,x),C=n.coordinateToVector3(i,E);S.x=C.x,S.y=C.y,S.z=C.z,S.sub(h),f[T]=S.x,f[T+1]=S.y,f[T+2]=S.z,m.push(C),_[e]={position:{count:1,start:3*e,end:3*e+3},hide:!1};let P=SC((y[1]-o)/u,4),A=SC((y[0]-r)/c,4);P-=1,A-=1,P=Math.max(0,P),A=Math.max(0,A),P=Math.ceil(P),A=Math.ceil(A);const L=A*d+P;l[L]&&(l[L].positions.push(C),l[L].indexs.push(e))}const T=new Nm;TS(T,"position",new ym(f,3,!0)),b&&TS(T,"color",new ym(g,3,!0)),M&&TS(T,"size",new ym(v,1,!0)),e.positions=m,super(),this._initOptions(e),this._createPoints(T,i);const E=e.altitude,C=n.altitudeToVector3(E,E).x,P=h.clone();P.z=C,this.getObject3d().position.copy(P),this._baseObjects=y,this._datas=t,this.faceIndex=null,this._geometriesAttributes=_,this._geometryCache=T.clone(),this.isHide=!1,this._initBaseObjectsEvent(y),this._grids=l,this._bindMapEvents(),this.type="Points",this.maxSize=w}_bindMapEvents(){const t=this.getMap(),e="zoomstart zooming zoomend movestart moving moveend pitch rotate";this.on("add",(()=>{this._updateGrids(),t.on(e,this._updateGrids,this)})),this.on("remove",(()=>{t.off(e,this._updateGrids,this)}))}_updateGrids(){const t=this.getMap();this._grids.forEach((e=>{e.indexs.length&&e.updateBBoxPixel(t)}))}getSelectMesh(){const t=this.faceIndex;if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],{coordinate:i,height:n,color:r,size:o}=e;this._baseObjects[t]=new _C(i,{height:n,index:t,color:r,size:o},this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){const e=this.getLayer(),i=this.getMap().getSize(),n=this.getLayer().getCamera(),r=this.getOptions().altitude,o=this.getMap(),s=e.altitudeToVector3(r,r).x;let a=this.getObject3d().material.size;const h=void 0===a,l=o.coordToContainerPoint(t),c=[];if(this._grids.forEach((t=>{t.indexs.length&&t.isRecCross(l,h?this.maxSize:a)&&c.push(t)})),c.length<1)return!1;for(let t=0,e=c.length;t<e;t++)for(let e=c[t].positions.length-1;e>=0;e--){h&&(a=this._datas[c[t].indexs[e]].size||1);const r=c[t].positions[e];MC.x=r.x,MC.y=r.y,MC.z=r.z+s;const o=gC(MC,i,n);if(Math.sqrt(Math.pow(l.x-o.x,2)+Math.pow(l.y-o.y,2))<=a/2)return this.faceIndex=c[t].indexs[e],!0}return!1}}const EC={coordinate:"",radius:10,height:100,radialSegments:6,altitude:0,topColor:"",bottomColor:"#2d2f61"};class CC extends(dC(zS)){constructor(t,e,i,n){Array.isArray(t)||(t=[t]);const r=t.length,o=HT(t),s=n.coordinateToVector3(o),a=[],h=[],l=[];let c=0;const u={},d={};let p;super(),e=Ii.extend({},{altitude:0,layer:n,points:t},EC,e),this._initOptions(e);const f=new jp;if(e.asynchronous){p=zE();const e=Ii.GUID();this.getOptions().id=e;const i=[];for(let e=0;e<r;e++){const r=Ii.extend({index:e},EC,t[e]),{radius:o,radialSegments:a,altitude:h,height:l,coordinate:c}=r,p=BT(o,n,u);t[e]._radius=p;const m=NT(l,n,d),g=NT(h,n,d),v=n.coordinateToVector3(c,0,f).sub(s);i.push({radialSegments:a,radius:p,height:m,center:[v.x,v.y],altitude:g})}PE.push({id:e,data:i,layer:n,baseObject:this})}else{for(let e=0;e<r;e++){const r=Ii.extend({index:e},EC,t[e]),{radius:o,radialSegments:p,altitude:m,topColor:g,bottomColor:v,height:y,coordinate:_}=r,x=BT(o,n,u),w=NT(y,n,d),b=NT(m,n,d),M=n.coordinateToVector3(_,0,f).sub(s),S=jE({radius:x,height:w,radialSegments:p,center:[M.x,M.y]});g&&(GE(S,v,g,"z",w/2),i.vertexColors=ES());const T=S.attributes.position.array;for(let t=0,e=T.length;t<e;t+=3)T[t+2]+=b;a.push(S);const E=new ZE(_,r,i,n);h.push(E),S.index.count;const C=S.attributes.position.count;S.attributes.normal.count,S.attributes.uv.count,l[e]={position:{count:C,start:c,end:c+3*C},hide:!1},c+=3*C}p=UE(a)}this._createMesh(p,i);const m=e.altitude,g=n.altitudeToVector3(m,m).x,v=s.clone();v.z=g,this.getObject3d().position.copy(v),this._baseObjects=h,this._datas=t,this._geometriesAttributes=l,this.faceIndex=null,this._geometryCache=IE(p),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(h),e.asynchronous||(this._setPickObject3d(),this._init()),this.type="Bars"}identify(){return this.picked}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],i=Object.assign({},this.options,e,{index:t,asynchronous:!1});this._baseObjects[t]=new ZE(e.coordinate,i,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const i=DE(t);this._geometryCache=IE(i);const{topColor:n,bottomColor:r}=this.getOptions(),o=this.getObject3d(),s=o.material;if(n&&(GE(i,r,n,"z",e),s.vertexColors=ES()),o.geometry=i,o.material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const PC={width:3,height:1,altitude:0,topColor:null,bottomColor:"#2d2f61"};class AC extends(dC(zS)){constructor(t,e,i,n){Array.isArray(t)||(t=[t]);const r=[],o=[],s=t.length;for(let e=0;e<s;e++){const i=iE(t[e]);r.push(i.center),o.push(i.lineStrings)}const a=HT(r);e=Ii.extend({},PC,e,{layer:n,lineStrings:t,coordinate:a});const{altitude:h,topColor:l,bottomColor:c,asynchronous:u}=e;let d;const p=[],f=[];if(super(),u)d=zE(),bE.push({id:Ii.GUID(),layer:n,key:e.key,center:a,data:o,lineStrings:t,baseObject:this});else{const e=[];let r=0;const h={},u={};for(let i=0;i<s;i++){const s=t[i],l=Ii.extend({},PC,NS(s)?s.properties:s.getProperties(),{index:i}),{height:c,width:d,bottomHeight:p}=l,m=BT(d,n,h),g=NT(c,n,u),v=o[i],y=[];let _=0;for(let t=0,e=v.length;t<e;t++){const e=eE(v[t],m,g,n,a);_=jT(e,p,n,h),y.push(e)}const x=RE(y);e.push(x);const{position:w,normal:b,indices:M}=x;M.length;const S=w.length/3;b.length,f[i]={position:{middleZ:_+g/2,count:S,start:r,end:r+3*S},hide:!1},r+=3*S}d=LE(e),l&&(qT(d,c,l,f),i.vertexColors=ES())}this._initOptions(e),this._createMesh(d,i);const m=n.altitudeToVector3(h,h).x,g=n.coordinateToVector3(a,m);this.getObject3d().position.copy(g),this._baseObjects=p,this._datas=t,this._geometriesAttributes=f,this.faceIndex=null,this._geometryCache=IE(d),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(p),u||(this._setPickObject3d(),this._init()),this.type="ExtrudeLines"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],i=Object.assign({},this.options,jS(e)?e.properties:e.getProperties(),{index:t});this._baseObjects[t]=new QE(e,i,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){return this.picked}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const i=DE(t);this._geometryCache=IE(i);const{topColor:n,bottomColor:r,bottomHeight:o,height:s}=this.getOptions(),a=this.getObject3d().material;if(n&&(qT(i,r,n,e),a.vertexColors=ES()),this.getObject3d().geometry=i,this.getObject3d().material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const LC={altitude:0,colors:null};class RC extends(dC(zS)){constructor(t,e,i,n){Array.isArray(t)||(t=[t]);const r=[],o=[],s=t.length;for(let e=0;e<s;e++){const i=iE(t[e]);r.push(i.center),o.push(i.lineStrings)}const a=HT(r);e=Ii.extend({},LC,e,{layer:n,lineStrings:t,coordinate:a}),super(),this._initOptions(e);const{asynchronous:h}=e;let l;const c=[],u={};let d=[],p=0,f=[];if(h)l=aE(),SE.push({id:Ii.GUID(),layer:n,key:e.key,center:a,data:o,lineStrings:t,baseObject:this});else{for(let t=0;t<s;t++){const e=o[t];let i=0;for(let t=0,r=e.length;t<r;t++){const r=jS(e[t])?e[t].properties:e[t].getProperties()||{},{positions:o}=KT(e[t],n,a,!1);jT(o,r.bottomHeight,n,u),i+=o.length/3*2-2,f.push(nE(o))}d[t]={position:{count:i,start:p,end:p+3*i},hide:!1},p+=3*i}const t=rE(f);l=new Nm,TS(l,"position",new ym(t,3))}this._createLineSegments(l,i);const{altitude:m}=e,g=n.altitudeToVector3(m,m).x,v=n.coordinateToVector3(a,g);this.getObject3d().position.copy(v),this._baseObjects=c,this._datas=t,this._geometriesAttributes=d,this.faceIndex=null,this.index=null,this._geometryCache=l.clone(),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(c),h||(this._setPickObject3d(),this._init()),this.type="Lines"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],i=Ii.extend({},this.getOptions(),{index:t},jS(e)?e.properties:e.getProperties());this._baseObjects[t]=new YE(e,i,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_setPickObject3d(){if(!this._colorMap)return;const t=this._geometryCache||this.getObject3d().geometry.clone(),e=this.getLayer().getPick(),{_geometriesAttributes:i}=this,n=i.length,r=GT(i);let o=0;for(let t=0;t<n;t++){const n=e.getColor(),s=n.getHex();this._colorMap[s]=t;const{count:a}=i[t].position;this._datas[t].colorIndex=s;for(let t=0;t<a;t++)r[o]=n.r,r[o+1]=n.g,r[o+2]=n.b,o+=3}TS(t,"color",new ym(r,3,!0));const s=this.getObject3d().material.clone();s.color.set("#fff"),s.vertexColors=ES();const a=e.getColor().getHex(),h=new I_(t,s);h.position.copy(this.getObject3d().position),h._colorIndex=a,this.setPickObject3d(h)}identify(t){return this.picked}_workerLoad(t){const{position:e,geometriesAttributes:i}=t;this._geometriesAttributes=i;const n=new Nm;if(TS(n,"position",new ym(new Float32Array(e),3)),this._computeLineDistances(n),this._geometryCache=n.clone(),this.getObject3d().geometry=n,this.getObject3d().material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const OC=[],DC=[];function IC(){return{waitingQueue:OC,currentQueue:DC}}function kC(t,e){for(let i=0,n=t.length;i<n;i++){const n=t[i];if(n){const{key:r,callback:o}=n;if(e===r)return t.splice(i,1),o}}return null}const zC=document.createElement("canvas");let FC;function BC(t,e=!1){if(FC)return FC;const i=zC.getContext("2d");return i.clearRect(0,0,256,256),i.save(),FC=zC.toDataURL(),FC}function NC(t=1,e=1){let i;return"undefined"==typeof document||(i=document.createElement("canvas"),t&&(i.width=t),e&&(i.height=e)),i}zC.width=zC.height=256;class HC extends ll{constructor(t,e={}){super(Ii.GUID(),Ii.extend({urlTemplate:t},e)),this._opts=null,this._layer=null,this.material=null,this.getMaterial=null,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._layerLaodTime=(new Date).getTime()}isAsynchronous(){return this._opts.worker}getBaseObjects(){const t=this._loadTiles,e=[];for(let i in t){const t=this._baseObjectKeys[i];if(t&&Array.isArray(t)&&t.length)for(let i=0,n=t.length;i<n;i++)e.push(t[i])}return e}onSelectMesh(t,e){}formatBaseObjects(t,e){return[]}loopMessage(t){}getTileData(t){const{key:e,url:i,callback:n,img:r}=t;gn.getJSON(i,{},(function(t,i){t?(console.error(t),n(e,null,r)):n(e,i,r)}))}_getCurentTileKeys(){const t=this.getTiles().tileGrids||[],e=[],i={};for(let n=0,r=t.length;n<r;n++){const r=t[n].tiles||[];for(let t=0,n=r.length;t<n;t++){const{id:n}=r[t];e.push(n),i[n]=!0}}return{keys:e,keysMap:i}}_isLoad(){const{keys:t}=this._getCurentTileKeys(),e=Object.keys(this._renderer.tilesInView);return t.length===e.length}_layerOnLoad(){const t=(new Date).getTime();if(t-this._layerLaodTime<20)return;this._layerLaodTime=t;const e=this._renderer.tilesInView,i=this._loadTiles,n=this._layer,r=this._baseObjectKeys,o=Object.keys(e).length,s=Object.keys(i).length,a=[];if(o&&s)for(let t in i)e[t]||r[t]&&(r[t]||[]).forEach((t=>{a.push(t)}));if(a.length&&n.removeMesh(a,!1),o&&s)for(let t in e)if(!i[t])if(r[t]){const e=r[t];n.addMesh(e)}else{const{x:e,y:i,z:n}=this._getXYZOfIndex(t);this.getTileUrl(e,i,n)}this._loadTiles=Object.assign({},e),this._diffCache()}_init(){}_workerLoad(t){const e=t.target._img;e.currentCount++,e.currentCount===e.needCount&&(e.src=BC(e._key,this._opts.debug))}_generateBaseObjects(t,e,i){if(e&&i){const{keysMap:n}=this._getCurentTileKeys();if(!n[t])return void(i.src=BC(0,this._opts.debug));const r=this.formatBaseObjects(t,e);if(r.length){i.needCount=r.length,i.currentCount=0;for(let e=0,n=r.length;e<n;e++){const n=r[e];n._img=i,n._vt=this,this.isVisible()||n.hide(),this._cachetile(t,n),n.isAsynchronous()||i.currentCount++}this._layer.addMesh(r,!1),i.needCount===i.currentCount&&(i.src=BC(0,this._opts.debug)),this.isAsynchronous()?r.filter((t=>t.isAsynchronous())).forEach((t=>{t.on("workerload",this._workerLoad,this)})):i.src=BC(0,this._opts.debug)}else i.src=BC(0,this._opts.debug);this._loadTiles[t]=!0}else i&&(i.src=BC(0,this._opts.debug))}_diffCache(){if(Object.keys(this._baseObjectKeys).length>this._renderer.tileCache.max){const t=this._renderer.tileCache.data,e=this._renderer.tilesInView,i=[];for(let n in this._baseObjectKeys)t[n]||e[n]||((this._baseObjectKeys[n]||[]).forEach((t=>{t.isAdd&&i.push(t)})),this._diposeBaseObject(n),delete this._baseObjectKeys[n]);i.length&&this._layer.removeMesh(i,!1)}}_diposeBaseObject(t){const e=this._baseObjectKeys[t];e&&e.length&&e.forEach((t=>{t.getObject3d().geometry.dispose(),t._geometryCache&&t._geometryCache.dispose();const e=t._baseObjects;e&&e.length&&e.forEach((t=>{t.getObject3d().geometry.dispose(),t=null})),t._datas=null,t._geometriesAttributes=null,t._faceMap=null,t._colorMap=null,t.pickObject3d&&t.pickObject3d.geometry.dispose(),t=null}))}_cachetile(t,e){this._baseObjectKeys[t]||(this._baseObjectKeys[t]=[]),this._baseObjectKeys[t].push(e)}_getXYZOfIndex(t){const e=t.indexOf("_")>-1?"_":"-";let[i,n,r]=t.split(e).slice(1,4);return{x:parseInt(n),y:parseInt(i),z:parseInt(r)}}_getTileExtent(t,e,i){const n=this.getMap()._getResolution(i);return this._getTileConfig().getTilePrjExtent(t,e,n)}_getTileLngLatExtent(t,e,i){const n=this._getTileExtent(t,e,i);let r=n.getMax(),o=n.getMin();const s=this.getMap().getProjection();return o=s.unproject(o),r=s.unproject(r),new tr(o,r)}}const jC={worker:!1};class GC extends HC{constructor(t,e={},i,n){super(Ii.GUID(),Ii.extend({urlTemplate:t},jC,e)),this._opts=e,this._layer=n,this.getMaterial=i,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._layerLaodTime=(new Date).getTime(),this._init()}formatBaseObjects(t,e){const i=this._opts,n=[],r=this.isAsynchronous();for(let o in e){const s=e[o]||{};let a;if(Array.isArray(s)?a=s:"FeatureCollection"===s.type&&(a=s.features),a&&a.length){const e=[],h=[],l=[];for(let t=0,i=a.length;t<i;t++){const i=a[t];if(HS(i))e.push(i);else if(jS(i)){const t=ZS(i);for(let e=0,i=t.length;e<i;e++)h.push(t[e])}else if(GS(i)){const t=ZS(i);for(let e=0,i=t.length;e<i;e++)l.push(Ii.extend({},t[e].properties,t[e],{coordinate:VS(t[e])}))}}if(e.length){const a=this._getMaterial(o,e,t,s);if(a){const s=this._layer.toExtrudePolygons(e,Ii.extend({},{topColor:"#fff",layerName:o,asynchronous:r,key:t},i),a);n.push(s)}}if(h.length){const e=this._getMaterial(o,h,t,s);if(e&&(e instanceof T_||e instanceof iw)){const t=this._layer.toLines(h,Ii.extend({},{layerName:o,asynchronous:r},i),e);n.push(t)}}if(l.length){const e=this._getMaterial(o,l,t,s);if(e&&e instanceof z_){const t=this._layer.toPoints(l,Ii.extend({},{layerName:o,asynchronous:r},i),e);n.push(t)}}}}return n}loopMessage(t){const{currentQueue:e}=IC();e.length>0&&this.getTileData(t)}_init(){this.on("layerload",this._layerOnLoad),this.on("add",(()=>{if(!1===this._add){const t=this.getBaseObjects();this._layer.addMesh(t)}this._add=!0,this.intervalId=setInterval((()=>{this._isLoad()&&!this._layer.getMap().isInteracting()&&this.fire("layerload")}),1e3)})),this.on("remove",(()=>{this._add=!1;const t=this.getBaseObjects();this._layer.removeMesh(t),clearInterval(this.intervalId)})),this.on("show",(()=>{this.getBaseObjects().forEach((t=>{t.show()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.show()}))}})),this.on("hide",(()=>{this.getBaseObjects().forEach((t=>{t.hide()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.hide()}))}})),this.on("renderercreate",(t=>{t.renderer.loadTile=function(t){var e=this.layer.getTileSize(),i=new Image;return i.width=e.width,i.height=e.height,i.onload=this.onTileLoad.bind(this,i,t),i.onerror=this.onTileError.bind(this,i,t),this.loadTileImage(i,t.url,t.id),i},t.renderer.deleteTile=function(t){if(!t||!t.image)return;t.image.onload=null,t.image.onerror=null;!function(t){const e=kC(OC,t);e&&e(t)}((t.info||{}).id)},t.renderer.loadTileImage=(t,e,i)=>{t._key=i,function(t,e,i,n,r){const o={key:t,url:e,callback:i,img:n,vt:r};DC.length<10?(DC.push(o),r.loopMessage(o)):OC.push(o)}(i,e,((t,e,i)=>{this._generateBaseObjects(t,e,i),function(t,e){if(kC(DC,t),OC.length){DC.push(OC[0]),OC.splice(0,1);const t=DC[DC.length-1];e.loopMessage(t)}}(t,this)}),t,this)}}))}_getMaterial(t,e,i,n){return this.getMaterial&&Ii.isFunction(this.getMaterial)?this.getMaterial(t,e,i,n):null}}function UC(t,e,i,n){const{position:r,uv:o,normal:s,indexs:a}=function(t,e,i,n){const r=t/i,o=e/n,s=-t/2,a=e/2,h=-e/2,l=(i+1)*(n+1),c=new Float32Array(3*l),u=new Float32Array(2*l),d=new Float32Array(3*l),p=new Uint32Array(10*l);let f=0,m=0,g=0;for(let l=0;l<=n;l++)for(let v=0;v<=i;v++){const y=s+r*v,_=a-o*l;c[f]=y,c[f+1]=_,c[f+2]=0,d[f]=0,d[f+1]=0,d[f+2]=1;const x=(y-s)/t,w=(_-h)/e;if(u[m]=x,u[m+1]=w,f+=3,m+=2,v<i&&l<n){const t=l*(i+1)+v,e=t+1,n=(i+1)*(l+1)+v,r=n+1;p[g]=t,p[g+1]=n,p[g+2]=e,p[g+3]=n,p[g+4]=r,p[g+5]=e,g+=6}}const v=new Uint32Array(g);for(let t=0,e=v.length;t<e;t++)v[t]=p[t];return{position:c,uv:u,normal:d,indexs:v}}(t,e,i,n),h=new Nm;return TS(h,"position",new ym(r,3)),TS(h,"normal",new ym(s,3)),TS(h,"uv",new ym(o,2)),h.setIndex(new ym(a,1)),h}const VC=new Aw,WC=document.createElement("canvas"),ZC=256;function qC(t){if(!t)return null;let e;return"string"==typeof t?(e=new Image,e.src=t):t instanceof HTMLCanvasElement?(e=new Image,e.src=t.toDataURL()):t instanceof Image&&(e=new Image,e.src=t.src,e.crossOrigin=t.crossOrigin),e&&!e.crossOrigin&&(e.crossOrigin="Anonymous"),e}const XC=new Map;function YC(t,e,i,n){if(!e||!i)return;const{imageWidth:r,imageHeight:o}=n;let s;if(s=t instanceof Uint32Array||t instanceof Uint8ClampedArray?t:function(t,e=ZC,i=ZC){WC.width=e,WC.height=i;const n=WC.getContext("2d");return n.drawImage(t,0,0,e,i),n.getImageData(0,0,e,i).data}(t,r,o),!s)return void console.error("image is error type data",t);let a=0,h=0,l=0;const c=new jp,u=XC;for(let t=0,n=s.length;t<n;t+=4){const n=.1*(256*s[t]*256+256*s[t+1]+s[t+2])-1e4;let d=0;if(0!==h&&h+1!==o&&0!==l&&l+1!==r){const t=u.get(n);void 0!==t?d=t:(d=i.altitudeToVector3(n,n,null,c).x,u.set(n,d))}e.attributes.position.array[3*a+2]=d,a++,l++,l===r&&(h++,l=0)}e.attributes.position.needsUpdate=!0}const JC={interactive:!1,altitude:0,image:null,imageWidth:256,imageHeight:256,texture:null};class QC extends zS{constructor(t,e,i,n){e=Ii.extend({},JC,e,{layer:n,extent:t});const{texture:r,image:o,altitude:s,imageHeight:a,imageWidth:h}=e;t instanceof tr||(t=new tr(t));const{xmin:l,ymin:c,xmax:u,ymax:d}=t;let p=1/0,f=1/0,m=-1/0,g=-1/0;[[l,c],[l,d],[u,d],[u,c]].forEach((t=>{const e=n.coordinateToVector3(t),{x:i,y:r}=e;p=Math.min(i,p),f=Math.min(r,f),m=Math.max(i,m),g=Math.max(r,g)}));const v=(m-p)/h,y=(g-f)/a;p-=v,m+=v,f-=y,g+=y;const _=Math.abs(m-p),x=Math.abs(g-f),w=qC(o),b=qC(r),M=UC(_,x,h-1,a-1);super(),this._initOptions(e),this._createMesh(M,i);const S=n.altitudeToVector3(s,s).x,T=n.coordinateToVector3(t.getCenter(),S);this.getObject3d().position.copy(T),i.transparent=!0,w&&(w.onload=()=>{YC(w,M,n,{imageWidth:h,imageHeight:a})},w.onerror=function(){console.error(`not load ${w.src}`)}),b?(i.opacity=0,VC.load(b.src,(t=>{i.map=t,i.opacity=1,i.needsUpdate=!0}))):i.opacity=1,this.type="Terrain"}updateData(t){return YC(t,this.getObject3d().geometry,this.getLayer(),this.getOptions()),this}}const KC={scale:1,tileDivisor:4};class $C extends HC{constructor(t,e={},i,n){super(Ii.GUID(),Ii.extend({urlTemplate:t},KC,e)),this._opts=e,this._layer=n,this.material=i,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._imgQueue={},this._layerLaodTime=(new Date).getTime(),this._init()}isAsynchronous(){return!1}formatBaseObjects(t,e){const i=this.options,n=[],{scale:r,tileDivisor:o}=i,{x:s,y:a,z:h}=this._getXYZOfIndex(t),l=this.getMap().getZoom(),c=this.getTileUrl(s,a,h),[u,d]=this.options.tileSize,p=this._getTileLngLatExtent(s,a,h),f=this.material.clone();if(h+1>=Math.round(l)){const t=new QC(p,{image:e,imageWidth:u/o,imageHeight:d/o,texture:c},f,this._layer);t.getObject3d().scale.set(r,r,1),n.push(t)}return n}loopMessage(t){this.getTileData(t)}_init(){this.on("layerload",this._layerOnLoad),this.on("add",(()=>{if(!1===this._add){const t=this.getBaseObjects();this._layer.addMesh(t)}this._add=!0,this.intervalId=setInterval((()=>{this._isLoad()&&!this._layer.getMap().isInteracting()&&this.fire("layerload")}),1e3)})),this.on("remove",(()=>{this._add=!1;const t=this.getBaseObjects();this._layer.removeMesh(t),clearInterval(this.intervalId)})),this.on("show",(()=>{this.getBaseObjects().forEach((t=>{t.show()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.show()}))}})),this.on("hide",(()=>{this.getBaseObjects().forEach((t=>{t.hide()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.hide()}))}})),this.on("renderercreate",(t=>{t.renderer.loadTile=function(t){var e=this.layer.getTileSize(),i=new Image;return i.width=e.width,i.height=e.height,i.onload=this.onTileLoad.bind(this,i,t),i.onerror=this.onTileError.bind(this,i,t),this.loadTileImage(i,t.url,t.id),i},t.renderer.deleteTile=t=>{if(!t||!t.image)return;t.image.onload=null,t.image.onerror=null;const e=t.info||{},i=this._imgQueue[e.id];i&&(i.src="",i.onload=null,i.onerror=null,delete this._imgQueue[e.id])},t.renderer.loadTileImage=(t,e,i)=>{t._key=i;const n=new Image;this._imgQueue[i]=n;const r={key:i,url:e,rgbImage:n,callback:(t,e,i)=>{this._generateBaseObjects(t,e,i)},img:t,vt:this};this.loopMessage(r)}}))}}
|
|
4
|
+
*/var O={exports:{}};function j(t,e,n){n=n||2;var i,r,o,s,a,h,c,l=e&&e.length,u=l?e[0]*n:t.length,d=T(t,0,u,n,!0),p=[];if(!d||d.next===d.prev)return p;if(l&&(d=function(t,e,n,i){var r,o,s,a=[];for(r=0,o=e.length;r<o;r++)(s=T(t,e[r]*i,r<o-1?e[r+1]*i:t.length,i,!1))===s.next&&(s.steiner=!0),a.push(F(s));for(a.sort(B),r=0;r<a.length;r++)n=E(a[r],n);return n}(t,e,d,n)),t.length>80*n){i=o=t[0],r=s=t[1];for(var f=n;f<u;f+=n)(a=t[f])<i&&(i=a),(h=t[f+1])<r&&(r=h),a>o&&(o=a),h>s&&(s=h);c=0!==(c=Math.max(o-i,s-r))?32767/c:0}return S(d,p,n,i,r,c,0),p}function T(t,e,n,i,r){var o,s;if(r===Y(t,e,n,i)>0)for(o=e;o<n;o+=i)s=K(o,t[o],t[o+1],s);else for(o=n-i;o>=e;o-=i)s=K(o,t[o],t[o+1],s);return s&&G(s,s.next)&&(q(s),s=s.next),s}function C(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!G(i,i.next)&&0!==R(i.prev,i,i.next))i=i.next;else{if(q(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function S(t,e,n,i,r,o,s){if(t){!s&&o&&function(t,e,n,i){var r=t;do{0===r.z&&(r.z=z(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,h,c=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ);e++);for(h=c;a>0||h>0&&i;)0!==a&&(0===h||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(s>1)}(r)}(t,i,r,o);for(var a,h,c=t;t.prev!==t.next;)if(a=t.prev,h=t.next,o?k(t,i,r,o):L(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(h.i/n|0),q(t),t=h.next,c=h.next;else if((t=h)===c){s?1===s?S(t=I(C(t),e,n),e,n,i,r,o,2):2===s&&P(t,e,n,i,r,o):S(C(t),e,n,i,r,o,1);break}}}function L(t){var e=t.prev,n=t,i=t.next;if(R(e,n,i)>=0)return!1;for(var r=e.x,o=n.x,s=i.x,a=e.y,h=n.y,c=i.y,l=r<o?r<s?r:s:o<s?o:s,u=a<h?a<c?a:c:h<c?h:c,d=r>o?r>s?r:s:o>s?o:s,p=a>h?a>c?a:c:h>c?h:c,f=i.next;f!==e;){if(f.x>=l&&f.x<=d&&f.y>=u&&f.y<=p&&V(r,a,o,h,s,c,f.x,f.y)&&R(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function k(t,e,n,i){var r=t.prev,o=t,s=t.next;if(R(r,o,s)>=0)return!1;for(var a=r.x,h=o.x,c=s.x,l=r.y,u=o.y,d=s.y,p=a<h?a<c?a:c:h<c?h:c,f=l<u?l<d?l:d:u<d?u:d,g=a>h?a>c?a:c:h>c?h:c,y=l>u?l>d?l:d:u>d?u:d,x=z(p,f,e,n,i),m=z(g,y,e,n,i),v=t.prevZ,b=t.nextZ;v&&v.z>=x&&b&&b.z<=m;){if(v.x>=p&&v.x<=g&&v.y>=f&&v.y<=y&&v!==r&&v!==s&&V(a,l,h,u,c,d,v.x,v.y)&&R(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,b.x>=p&&b.x<=g&&b.y>=f&&b.y<=y&&b!==r&&b!==s&&V(a,l,h,u,c,d,b.x,b.y)&&R(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;v&&v.z>=x;){if(v.x>=p&&v.x<=g&&v.y>=f&&v.y<=y&&v!==r&&v!==s&&V(a,l,h,u,c,d,v.x,v.y)&&R(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=m;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=y&&b!==r&&b!==s&&V(a,l,h,u,c,d,b.x,b.y)&&R(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function I(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;!G(r,o)&&D(r,i,i.next,o)&&W(r,o)&&W(o,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),q(i),q(i.next),i=t=o),i=i.next}while(i!==t);return C(i)}function P(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Z(s,a)){var h=N(s,a);return s=C(s,s.next),h=C(h,h.next),S(s,e,n,i,r,o,0),void S(h,e,n,i,r,o,0)}a=a.next}s=s.next}while(s!==t)}function B(t,e){return t.x-e.x}function E(t,e){var n=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==e);if(!n)return null;var h,c=n,l=n.x,u=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=l&&r!==i.x&&V(o<u?r:s,o,l,u,o<u?s:r,o,i.x,i.y)&&(h=Math.abs(o-i.y)/(r-i.x),W(i,t)&&(h<d||h===d&&(i.x>n.x||i.x===n.x&&U(n,i)))&&(n=i,d=h)),i=i.next}while(i!==c);return n}(t,e);if(!n)return e;var i=N(n,t);return C(i,i.next),C(n,n.next)}function U(t,e){return R(t.prev,t,e.prev)<0&&R(e.next,t,t.next)<0}function z(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function F(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function V(t,e,n,i,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(i-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function Z(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&D(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(W(t,e)&&W(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(R(t.prev,t,e.prev)||R(t,e.prev,e))||G(t,e)&&R(t.prev,t,t.next)>0&&R(e.prev,e,e.next)>0)}function R(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function G(t,e){return t.x===e.x&&t.y===e.y}function D(t,e,n,i){var r=Q(R(t,e,n)),o=Q(R(t,e,i)),s=Q(R(n,i,t)),a=Q(R(n,i,e));return r!==o&&s!==a||(!(0!==r||!H(t,n,e))||(!(0!==o||!H(t,i,e))||(!(0!==s||!H(n,t,i))||!(0!==a||!H(n,e,i)))))}function H(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Q(t){return t>0?1:t<0?-1:0}function W(t,e){return R(t.prev,t,t.next)<0?R(t,e,t.next)>=0&&R(t,t.prev,e)>=0:R(t,e,t.prev)<0||R(t,t.next,e)<0}function N(t,e){var n=new $(t.i,t.x,t.y),i=new $(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function K(t,e,n,i){var r=new $(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function q(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function $(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Y(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}O.exports=j,O.exports.default=j,j.deviation=function(t,e,n,i){var r=e&&e.length,o=r?e[0]*n:t.length,s=Math.abs(Y(t,0,o,n));if(r)for(var a=0,h=e.length;a<h;a++){var c=e[a]*n,l=a<h-1?e[a+1]*n:t.length;s-=Math.abs(Y(t,c,l,n))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*n,p=i[a+1]*n,f=i[a+2]*n;u+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},j.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);r>0&&(i+=t[r-1].length,n.holes.push(i))}return n};var X=O.exports;function J(t){for(var e,n,i=0,r=1,o=t.length;r<o;)e=n||t[0],i+=((n=t[r])[0]-e[0])*(n[1]+e[1]),r++;return i>0}function tt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function et(t,e){var n=e[0],i=e[1],r=e[2],o=Math.sqrt(n*n+i*i+r*r)||1;return t[0]=n/o,t[1]=i/o,t[2]=r/o,t}function nt(t,e){function n(t,e,n,i){t[0]=e,t[1]=n,t[2]=i}for(var i,r,o,s,a,h,c,l,u,d=[],p=[],f=[],g=[],y=[],x=[],m=t.length,v=new Float32Array(e.length),b=0;b<m;){var _=3*t[b],w=3*t[b+1],M=3*t[b+2];n(d,e[_],e[_+1],e[_+2]),n(p,e[w],e[w+1],e[w+2]),n(f,e[M],e[M+1],e[M+2]),tt(y,f,p),tt(g,d,p),i=x,o=g,s=void 0,a=void 0,h=void 0,c=void 0,l=void 0,u=void 0,s=(r=y)[0],a=r[1],h=r[2],c=o[0],l=o[1],u=o[2],i[0]=a*u-h*l,i[1]=h*c-s*u,i[2]=s*l-a*c;for(var A=0;A<3;A++)v[_+A]+=x[A],v[w+A]+=x[A],v[M+A]+=x[A];b+=3}for(var O=0,j=v.length;O<j;)n(x,v[O],v[O+1],v[O+2]),et(x,x),v[O]=x[0]||0,v[O+1]=x[1]||0,v[O+2]=x[2]||0,O+=3;return v}function it(t){if(1===t.length)return{position:t[0].position,normal:t[0].normal,uv:t[0].uv,indices:t[0].indices,results:t};for(var e=0,n=0,i=0,r=t.length;i<r;i++){var o=t[i],s=o.position,a=o.indices;e+=s.length,n+=a.length}for(var h={position:new Float32Array(e),normal:new Float32Array(e),uv:new Float32Array(e/3*2),indices:new Uint32Array(n),results:t},c=0,l=0,u=0,d=0,p=0,f=t.length;p<f;p++){var g=t[p],y=g.position,x=g.indices,m=g.normal,v=g.uv;h.position.set(y,c),h.normal.set(m,c),h.uv.set(v,d);for(var b=0,_=x.length;b<_;){var w=x[b]+l;h.indices[u]=w,u++,b++}d+=v.length,c+=y.length,l+=y.length/3}return h}function rt(t){return 180*t/Math.PI}function ot(t){return t/180*Math.PI}function st(t,e,n,i,r,o){var s=3*n,a=3*i,h=3*r,c=3*o,l=e[s],u=e[s+1],d=e[s+2],p=e[a],f=e[a+1],g=e[a+2],y=e[h],x=e[h+1],m=e[h+2],v=e[c],b=e[c+1],_=e[c+2];Math.abs(u-f)<Math.abs(l-p)?(t.push(l,1-d),t.push(p,1-g),t.push(y,1-m),t.push(v,1-_)):(t.push(u,1-d),t.push(f,1-g),t.push(x,1-m),t.push(b,1-_))}function at(t,e){e=Object.assign({},{depth:2},e);var n=t.map((function(t){for(var n=0,i=t.length;n<i;n++){var r=t[n];ht(r),0===n?J(r)||(t[n]=r.reverse()):J(r)&&(t[n]=r.reverse()),ct(r)&&r.splice(r.length-1,1)}var o=function(t,e){for(var n=function(t){var e=0,n=0,i=t.length;for(;n<i;)e+=t[n].length,n++;return e}(t),i=t.length,r=[],o=new Float32Array(2*n),s=[],a=[],h=3*n,c=2*n,l=e.depth,u=0,d=0,p=0,f=0;f<i;f++){var g=t[f];f>0&&r.push(u/2);for(var y=0,x=g.length;y<x;){var m=g[y],v=m[0],b=m[1];o[u++]=v,o[u++]=b,s[d]=v,s[d+1]=b,s[d+2]=l,s[h+d]=v,s[h+d+1]=b,s[h+d+2]=0,a[p]=v,a[p+1]=b,a[c+p]=v,a[c+p+1]=b,d+=3,p+=2,y++}}return{flatVertices:o,holes:r,points:s,count:n,uvs:a}}(t,e);return o.polygon=t,function(t,e){for(var n=[],i=t.count,r=0,o=e.length;r<o;r+=3){var s=e[r],a=e[r+1],h=e[r+2];n[r]=s,n[r+1]=a,n[r+2]=h;var c=o+r,l=i+s,u=i+a,d=i+h;n[c]=l,n[c+1]=u,n[c+2]=d}t.index=n}(o,X(o.flatVertices,o.holes,2)),function(t,e){for(var n=t.points,i=t.index,r=t.polygon,o=t.uvs,s=e.depth,a=0,h=r.length;a<h;a++)for(var c=r[a],l=0,u=c.length;l<u;){var d=c[l],p=c[l+1];l===u-1&&(p=c[0]);var f=n.length/3,g=d[0],y=d[1],x=p[0],m=p[1];n.push(g,y,s,x,m,s,g,y,0,x,m,0);var v=f+2,b=f+3,_=f,w=f+1;i.push(v,_,b,_,w,b),st(o,n,v,b,_,w),l++}}(o,e),o.position=new Float32Array(o.points),o.indices=new Uint32Array(o.index),o.uv=new Float32Array(o.uvs),o.normal=nt(o.indices,o.position),o})),i=it(n);return i.polygons=t,i}function ht(t){ct(t)||t.push(t[0])}function ct(t){var e=t.length,n=t[0],i=n[0],r=n[1],o=t[e-1],s=o[0],a=o[1];return i===s&&r===a}function lt(t,e){e=Object.assign({},{depth:2,lineWidth:1},e);var n=t.map((function(t){var n=function(t,e){var n=0,i=e.lineWidth/2,r=[],o=[],s=[],a=t.length,h=0;for(;h<a-1;){var c=t[h],l=t[h+1],u=l[1]-c[1],d=l[0]-c[0],p=0,f=rt(Math.atan(u/d));if(n=f,0===h)p=f,p-=90;else{var g=t[h-1];ut.x=g[0]-c[0],ut.y=g[1]-c[1],dt.x=l[0]-c[0],dt.y=l[1]-c[1],p=f-ft(ut,dt)/2}var y=pt(ot(p),i,c),x=y[0],m=y[1];r.push(x,m),gt(x,c,l)?(o.push(x),s.push(m)):(o.push(m),s.push(x)),h++}var v=n,b=ot(v-=90),_=t[a-2],w=t[a-1],M=pt(b,i,w),A=M[0],O=M[1];r.push(A,O),gt(A,_,w)?(o.push(A),s.push(O)):(o.push(O),s.push(A));return{offsetPoints:r,leftPoints:o,rightPoints:s}}(t,e);return n.line=t,function(t,e){var n=e.depth,i=[],r=[],o=[],s=t.leftPoints,a=t.rightPoints,h=0,c=s.length;for(;h<c;){var l=3*h,u=s[h],d=u[0],p=u[1],f=u[2];i[l]=d,i[l+1]=p,i[l+2]=n+f;var g=a[h],y=g[0],x=g[1],m=g[2],v=3*c+l;i[v]=y,i[v+1]=x,i[v+2]=n+m;var b=2*c*3+l;i[b]=d,i[b+1]=p,i[b+2]=f;var _=2*c*3+3*c+l;i[_]=y,i[_+1]=x,i[_+2]=m,h++}h=0,c=i.length;for(;h<c;){var w=i[h],M=i[h+1];o.push(w,M),h+=3}h=0,c=s.length;for(;h<c-1;){var A=h,O=h+1,j=A+c,T=O+c;r.push(A,j,O),r.push(j,T,O);var C=h+2*c,S=C+1,L=C+c,k=S+c;r.push(C,L,S),r.push(L,k,S),h++}t.index=r,t.points=i,t.uvs=o}(n,e),function(t,e){var n=t.points,i=t.index,r=t.leftPoints,o=t.rightPoints,s=t.uvs,a=e.depth,h=[r,o];function c(t,e){var r=n.length/3;n.push(t[0],t[1],a+t[2],e[0],e[1],a+e[2],t[0],t[1],t[2],e[0],e[1],e[2]);var o=r+2,h=r+3,c=r,l=r+1;i.push(o,c,h,c,l,h),st(s,n,o,h,c,l)}for(var l=0,u=h.length;l<u;l++){var d=h[l];l>0&&(d=(d=d.map((function(t){return t}))).reverse());for(var p=0,f=d.length-1;p<f;){c(d[p],d[p+1]),p++}}for(var g=r.length,y=[o[0],r[0],r[g-1],o[g-1]],x=0;x<y.length;x+=2){c(y[x],y[x+1])}}(n,e),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.index),n.uv=new Float32Array(n.uvs),n.normal=nt(n.indices,n.position),n})),i=it(n);return i.lines=t,i}var ut={x:0,y:0},dt={x:0,y:0};function pt(t,e,n){var i=n[0],r=n[1],o=n[2]||0,s=[i+Math.cos(t)*e,r+Math.sin(t)*e,o],a=t+=Math.PI;return[s,[i+Math.cos(a)*e,r+Math.sin(a)*e,o]]}var ft=function(t,e){var n=t.x,i=t.y,r=e.x,o=e.y,s=n*r+i*o,a=n*o-i*r;return(Math.atan2(a,s)/Math.PI*180+360)%360};function gt(t,e,n){var i=e[0],r=e[1],o=n[0],s=n[1];return(r-s)*t[0]+(o-i)*t[1]+i*s-o*r>0}function yt(t,e,n={}){return void 0===n[t]&&(n[t]=e.distanceToVector3(t,t).x),n[t]}function xt(t,e,n={}){return void 0===n[t]&&(n[t]=e.altitudeToVector3(t,t).x),n[t]}function mt(e=[]){let n=0,i=0;const r=e.length;for(let o=0;o<r;o++){const{coordinate:r,lnglat:s,lnglats:a,xy:h,xys:c}=e[o],l=r||s||a||h||c||e[o];let u,d;Array.isArray(l)?(u=l[0],d=l[1]):l instanceof t.Coordinate&&(u=l.x,d=l.y),n+=u,i+=d}return new t.Coordinate(n/r,i/r)}function vt(t,n,i,r){if(void 0===n||"number"!=typeof n||0===n)return 0;let o;o=t instanceof e.BufferGeometry?t.attributes.position.array:Array.isArray(t)||t instanceof Float32Array?t:t.position;let s=0;if(o){r?(void 0===r[n]&&(r[n]=i.altitudeToVector3(n,n).x),s=r[n]):s=i.altitudeToVector3(n,n).x;const t=o.length;if(o[0]instanceof e.Vector3)for(let e=0;e<t;e++)o[e].z+=s;else for(let e=0;e<t;e+=3)o[e+2]+=s}return s}function bt(t){const e=t.length;let n=0;for(let i=0;i<e;i++){const{count:e}=t[i].position;n+=e}return new Float32Array(3*n)}function _t(t=[]){const e=t.length,n=new Float64Array(2*e);for(let i=0;i<e;i++){let e,r;const o=t[i];o.x?(e=o.x,r=o.y):(e=o[0],r=o[1]),n[2*i]=e,n[2*i+1]=r}return n.buffer}const wt=new e.Color("#fff"),Mt=new e.Color("#fff");function At(t,e,n,i,r,o){const s=jt(t,n,i,r,!1);if(!s)return null;o?(null==o[e]&&(o[e]=n.altitudeToVector3(e,e).x),e=o[e]):e=n.altitudeToVector3(e,e).x;const{position:a,normal:h,uv:c,indices:l}=at(s,{depth:e});return{position:a,normal:h,uv:c,indices:l}}function Ot(t,n,r,o){void 0===o&&(o=0);const s=t.attributes.position.array,a=s.length;let h;if(Mt.setStyle(n),wt.setStyle(r),Array.isArray(o)){let t=0;for(let e=0,n=o.length;e<n;e++){const{count:n}=o[e].position;t+=3*n}h=new Float32Array(t)}else h=new Float32Array(s.length);if(Array.isArray(o))for(let t=0,e=o.length;t<e;t++){const{middleZ:e,start:n,end:i}=o[t].position;for(let t=n;t<i;t+=3){s[t+2]>e?(h[t]=wt.r,h[t+1]=wt.g,h[t+2]=wt.b):(h[t]=Mt.r,h[t+1]=Mt.g,h[t+2]=Mt.b)}}else for(let t=0;t<a;t+=3){s[t+2]>o?(h[t]=wt.r,h[t+1]=wt.g,h[t+2]=wt.b):(h[t]=Mt.r,h[t+1]=Mt.g,h[t+2]=Mt.b)}return i(t,"color",new e.BufferAttribute(h,3,!0)),h}function jt(e,n,i,r,o=!1){if(!e)return null;let s=[];if(e instanceof t.MultiPolygon)s=e.getGeometries().map((t=>Tt(t,n,i||e.getCenter(),r,o)));else if(e instanceof t.Polygon){const t=Tt(e,n,i||e.getCenter(),r,o);s.push(t)}else if(m(e))if(_(e)){const t=A(e);for(let a=0,h=t.length;a<h;a++)s.push(Tt(t[a],n,i||M(e),r,o))}else{const t=Tt(e,n,i||M(e),r,o);s.push(t)}return s}function Tt(e,n,i,r,o=!1){let s,a,h;if(m(e)){const t=w(e);s=t[0],a=t.slice(1,t.length),i=i||M(e)}else e instanceof t.Polygon&&(s=e.getShell(),a=e.getHoles(),i=i||e.getCenter());r=r||n.coordinateToVector3(i),h=o?n.coordinatiesToGLFloatArray(s,r).positons2d:n.coordinatiesToGLArray(s,r);const c=[o?h.buffer:h];if(a&&a.length>0)for(let t=0,e=a.length;t<e;t++){let e;e=o?n.coordinatiesToGLFloatArray(a[t],r).positons2d:n.coordinatiesToGLArray(a[t],r),c.push(o?e.buffer:e)}return c}function Ct(e){if(!e)return null;let n=[];if(e instanceof t.MultiPolygon)n=e.getGeometries().map((t=>St(t,!1)));else if(e instanceof t.Polygon){const t=St(e,!1);n.push(t)}else if(m(e))if(_(e)){const t=A(e);for(let e=0,i=t.length;e<i;e++)n.push(St(t[e],!0))}else{const t=St(e,!0);n.push(t)}return n}function St(e,n){let i,r;if(n){const t=w(e);i=t[0],r=t.slice(1,t.length)}else e instanceof t.Polygon&&(i=e.getShell(),r=e.getHoles());const o=[_t(i)];if(r&&r.length>0)for(let t=0,e=r.length;t<e;t++){const e=_t(r[t]);o.push(e)}return o}function Lt(n,i,r,o=!0){let s,a,h=[];if(Array.isArray(n)&&n[0]instanceof e.Vector3)h=n;else{Array.isArray(n)&&(n=new t.LineString(n));const e=0;let c,l;x(n)?(c=w(n),r||(l=M(n))):n instanceof t.LineString&&(c=n.getCoordinates(),r||(l=n.getCenter()));const u=i.coordinateToVector3(r||l);if(o)for(let t=0,n=c.length;t<n;t++){const n=c[t],r=i.coordinateToVector3(n,e).sub(u);h.push(r)}else{const t=i.coordinatiesToGLFloatArray(c,u);s=t.positions,a=t.positons2d}}if(!o)return{positions:s,positionsV:h,positions2d:a,arrayBuffer:a.buffer};a=new Float32Array(2*h.length),s=new Float32Array(3*h.length);for(let t=0,e=h.length;t<e;t++){const e=3*t,n=h[t];s[e]=n.x,s[e+1]=n.y,s[e+2]=n.z;const i=2*t;a[i]=n.x,a[i+1]=n.y}return{positions:s,positionsV:h,positions2d:a,arrayBuffer:a.buffer}}function kt(t,e,n,i){const r=[],o=[],s=[];let a,h;for(let n=0,c=t.length;n<c;n++){const c=t[n];for(let t=0,n=c.length;t<n;t++){const n=c[t],l=n.join(",").toString();a?(l!==a&&(h=e.coordinateToVector3(n,0).sub(i),r.push(h.x,h.y,h.z),o.push(h),s.push(n)),a=l):(s.push(n),a=l,h=e.coordinateToVector3(n,0).sub(i),r.push(h.x,h.y,h.z),o.push(h))}}return{positions:r,positionsV:o,lnglats:s}}function It(t){let e;const n=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];for(let t=0,i=r.length;t<i;t++){const i=r[t],o=i.join(",").toString();e?(o!==e&&n.push(i),e=o):(n.push(i),e=o)}}return n}function Pt(t,e=1,n=1,i,r){const o=Lt(t,i,r).positionsV,s=[];for(let t=0,e=o.length;t<e;t++){const e=o[t];s.push([e.x,e.y])}const{indices:a,position:h,normal:c,uv:l}=lt([s],{lineWidth:e,depth:n});return{position:h,normal:c,indices:a,uv:l}}function Bt(e){let n,i=[];return e instanceof t.MultiLineString?(i=e.getGeometries(),n=e.getCenter()):e instanceof t.LineString?(i.push(e),n=e.getCenter()):x(e)&&(n=M(e),_(e)?i=A(e):i.push(e)),{lineStrings:i,center:n}}function Et(t){const e=new Float32Array(2*t.length-6);let n=0;for(let i=0,r=t.length/3;i<r;i++){const o=t[3*i],s=t[3*i+1],a=t[3*i+2];if(i>0&&i<r-1){const t=3*n;e[t]=o,e[t+1]=s,e[t+2]=a,n++}const h=3*n;e[h]=o,e[h+1]=s,e[h+2]=a,n++}return e}function Ut(t){let e=0;const n=t.length;if(1===n)return t[0];for(let i=0;i<n;i++)e+=t[i].length;const i=new Float32Array(e);let r=0;for(let e=0;e<n;e++)i.set(t[e],r),r+=t[e].length;return i}function zt(e){return e instanceof t.LineString?_t(e.getCoordinates()):v(e)?_t(e.geometry.coordinates):void 0}let Ft;function Vt(){return Ft||(Ft=new e.BufferGeometry,i(Ft,"position",new e.BufferAttribute(new Float32Array(3),3))),Ft}const Zt="__maptalks.three__";let Rt;var Gt;function Dt(){return t.worker||console.error("maptalks.worker is not defined,You can't use ThreeVectorTileLayer"),!Gt&&Rt&&(Gt=new Rt(Zt)),Gt}function Ht(t,e,n={}){return void 0!==t&&"number"==typeof t&&0!==t?(void 0===n[t]&&(n[t]=e.distanceToVector3(t,t).x),n[t]):0}function Qt(t,e,n={}){return void 0!==t&&"number"==typeof t&&0!==t?(void 0===n[t]&&(n[t]=e.altitudeToVector3(t,t).x),n[t]):0}function Wt(t,e,n,i,r=[]){const o=n.isMercator();let s,a,h;if(o){const t=n.getMap();s=t.getGLRes(),a=t.getSpatialReference().getTransformation().matrix}e&&(h=n.coordinateToVector3(e));const c=[],l=[],u={},d={},p=t.length;for(let s=0;s<p;s++){const a=t[s],p=r[s]?r[s]:v(i[s])?i[s].properties:i[s].getProperties()||{};e||(h=n.coordinateToVector3(p.center));let f=p.width||1,g=p.height||1,y=p.bottomHeight||0;f=Ht(f,n,u),g=Qt(g,n,d),y=Qt(y,n,d);const x=[];for(let t=0,i=a.length;t<i;t++){const i=a[t];let r;r=o?zt(i):Lt(i,n,e,!1).arrayBuffer,l.push(r),x.push(r)}const m={id:p.id,data:x,height:g,width:f,bottomHeight:y};o&&(m.center=[h.x,h.y]),c.push(m)}return{datas:c,transfer:l,glRes:s,matrix:a,center:o?[h.x,h.y]:null}}function Nt(t,e,n,i,r=[]){const o=n.isMercator();let s,a,h;if(o){const t=n.getMap();s=t.getGLRes(),a=t.getSpatialReference().getTransformation().matrix}e&&(h=n.coordinateToVector3(e));const c=[],l=[],u={},d=t.length;for(let s=0;s<d;s++){const a=t[s],d=r[s]?r[s]:v(i[s])?i[s].properties:i[s].getProperties()||{};e||(h=n.coordinateToVector3(d.center));let p=d.bottomHeight||0;p=Qt(p,n,u);const f=[];for(let t=0,i=a.length;t<i;t++){const i=a[t];if(o){const t=zt(i);f.push(t),f.push(t)}else{const t=Lt(i,n,e,!1).arrayBuffer;l.push(t),f.push(t)}}const g={id:d.id,data:f,bottomHeight:p};o&&(g.center=[h.x,h.y]),c.push(g)}return{datas:c,transfer:l,glRes:s,matrix:a,center:o?[h.x,h.y]:null}}function Kt(t){return t.map((t=>t.data))}function qt(t){return t.map((t=>t.option||t.baseObject.getOptions()))}t.worker&&(Rt=class extends t.worker.Actor{test(t,e){this.send(t,null,e)}pushQueue(t={}){const{type:e,data:n,callback:i,layer:r,key:o,center:s,lineStrings:a,options:h,id:c}=t;let l;e.indexOf("ExtrudePolygon")>-1?l=function(t=[],e,n,i=[]){const r=n.isMercator();let o,s,a;if(r){const t=n.getMap();o=t.getGLRes(),s=t.getSpatialReference().getTransformation().matrix}e&&(a=n.coordinateToVector3(e));const h=t.length,c=[],l=[],u={};for(let o=0;o<h;o++){const s=t[o],h=s,d=i[o]?i[o]:m(h)?h.properties:h.getProperties()||{};let p;e||(a=n.coordinateToVector3(d.center)),p=r?Ct(s):jt(s,n,d.center||e,a,!0);for(let t=0,e=p.length;t<e;t++){const e=p[t];for(let t=0,n=e.length;t<n;t++)l.push(e[t])}let f=d.height||1,g=d.bottomHeight||0;f=Qt(f,n,u),g=Qt(g,n,u);const y={id:d.id,data:p,height:f,bottomHeight:g};r&&(y.center=[a.x,a.y]),c.push(y),h._properties&&delete h._properties}return{datas:c,transfer:l,glRes:o,matrix:s,center:r?[a.x,a.y]:null}}(n,s,r,h):"ExtrudeLines"===e?l=Wt(n,s,r,a):"Point"===e||("Line"===e||"FatLine"===e?l=Nt(n,s,r,a,h):"Lines"===e||"FatLines"===e?l=Nt(n,s,r,a):"ExtrudeLine"===e?l=Wt(n,s,r,a,h):"Bar"!==e&&"Bars"!==e||(l=function(t){const e=t.length,n=new Float32Array(7*e);let i=0;for(let r=0;r<e;r++){let{center:e,radialSegments:o,radius:s,height:a,altitude:h,id:c}=t[r];e=e||[0,0],n[i]=e[0],n[i+1]=e[1],n[i+2]=o||6,n[i+3]=s||1,n[i+4]=a,n[i+5]=h||0,n[i+6]=c,i+=7}const r=n.buffer;return{datas:r,transfer:[r]}}(n))),l?this.send({type:e,datas:l.datas,glRes:l.glRes,matrix:l.matrix,center:l.center},l.transfer,(function(t,e){t&&console.error(t),e.key=o,e.id=c,i(e)})):console.error(`not support '${e}' worker`)}});class $t{constructor(){this.queueMap={},this.tempQueue=[],this.time=this.getCurrentTime(),this.deQueueCount=5,this.resultQueue=[]}getActor(){return Dt()}getCurrentTime(){return t.Util.now()}loop(){this.deQueue()}push(t){return this.tempQueue.push(t),t.id&&(this.queueMap[t.id]=t),this}reset(){return this.time=this.getCurrentTime(),this.tempQueue=[],this}pushResult(t){if(t)return Array.isArray(t)||(t=[t]),t.forEach((t=>{this.resultQueue.push(t)})),this}deQueue(){if(!this.resultQueue.length)return this;const t=this.deQueueCount;return(this.resultQueue.slice(0,t)||[]).forEach((t=>{const{id:e}=t;if(this.queueMap[e]){const{baseObject:n}=this.queueMap[e];n&&n._workerLoad&&n._workerLoad(t),delete this.queueMap[e]}})),this.resultQueue.splice(0,t),this}}const Yt=new class extends $t{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Dt().pushQueue({type:"ExtrudePolygon",layer:this.tempQueue[0].layer,data:Kt(this.tempQueue),options:qt(this.tempQueue),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},Xt=new class extends $t{loop(){if(this.tempQueue.length){const t=Dt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"ExtrudePolygons",layer:e.layer,data:e.data,key:e.key,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},Jt=new class extends $t{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Dt().pushQueue({type:"ExtrudeLine",layer:this.tempQueue[0].layer,data:Kt(this.tempQueue),options:qt(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},te=new class extends $t{loop(){if(this.tempQueue.length){const t=Dt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"ExtrudeLines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},ee=new class extends $t{constructor(){super(),this.deQueueCount=200}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Dt().pushQueue({type:"Line",layer:this.tempQueue[0].layer,data:Kt(this.tempQueue),options:qt(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},ne=new class extends $t{loop(){if(this.tempQueue.length){const t=Dt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"Lines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},ie=new class extends $t{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Dt().pushQueue({type:"FatLine",layer:this.tempQueue[0].layer,data:Kt(this.tempQueue),options:qt(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},re=new class extends $t{loop(){if(this.tempQueue.length){const t=Dt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"FatLines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},oe=new class extends $t{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Dt().pushQueue({type:"Bar",layer:this.tempQueue[0].layer,data:Kt(this.tempQueue),options:qt(this.tempQueue),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},se=new class extends $t{constructor(){super(),this.deQueueCount=1}loop(){if(this.tempQueue.length){const t=Dt();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"Bars",layer:e.layer,data:e.data,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},ae={isRunning:!1,tasks:[],addTask:t=>{t&&ae.tasks.push(t)},removeTask:t=>{ae.tasks.splice(ae.tasks.indexOf(t),1)},loop(){Yt.loop(),Xt.loop(),Jt.loop(),te.loop(),ee.loop(),ne.loop(),ie.loop(),re.loop(),oe.loop(),se.loop(),ae.tasks.forEach((t=>{t&&t.loop&&t.loop()})),t.Util.requestAnimFrame(ae.loop)},star(){ae.isRunning||(ae.isRunning=!0,ae.loop())}};function he(t){const{position:n,normal:r,uv:o,indices:s}=ce(t),a=new e.BufferGeometry,h=new Float32Array(n.length);return h.fill(1,0,n.length),i(a,"color",new e.BufferAttribute(h,3)),i(a,"normal",new e.BufferAttribute(r,3)),i(a,"position",new e.BufferAttribute(n,3)),o&&o.length&&i(a,"uv",new e.BufferAttribute(o,2)),a.setIndex(new e.BufferAttribute(s,1)),a}function ce(t){const e={},n={};for(let i=0;i<t.length;++i){const r=t[i];for(const t in r)void 0===e[t]&&(e[t]=[],n[t]=0),e[t].push(r[t]),n[t]+=r[t].length}const i={};let r=0;const o=new Uint32Array(n.indices);for(const t in e)if("indices"===t){const n=e[t];let i=0;for(let t=0,s=n.length;t<s;t++){const s=n[t];for(let t=0,e=s.length;t<e;t++)o[i]=s[t]+r,i++;r+=e.position[t].length/3}}else{const r=le(e[t],n[t]);if(!r)return null;i[t]=r}return i.indices=o,i}function le(t,e){const n=new Float32Array(e);let i=0;for(let e=0;e<t.length;++e)n.set(t[e],i),i+=t[e].length;return n}function ue(t){const{position:n,normal:r,uv:o,indices:s}=t,a=new e.BufferGeometry;return i(a,"normal",new e.BufferAttribute(new Float32Array(r),3)),i(a,"position",new e.BufferAttribute(new Float32Array(n),3)),i(a,"uv",new e.BufferAttribute(new Float32Array(o),2)),a.setIndex(new e.BufferAttribute(new Uint32Array(s),1)),a}function de(t){const n=new e.BufferGeometry;return i(n,"normal",t.getAttribute("normal")),i(n,"position",t.getAttribute("position").clone()),n.setIndex(t.getIndex()),n}let pe;function fe(){if(!pe){const t=1e-6;pe=new e.BoxBufferGeometry(t,t,t)}return pe}fe();const ge=new e.BoxBufferGeometry(1,1,1);ge.translate(0,0,.5);const ye=new e.Color("#fff"),xe=new e.Color("#fff");function me(t){const{position:n,normal:r,uv:o,indices:s}=function(t,e){void 0===e&&(e={}),e=Object.assign({},{radius:1,height:2,radialSegments:6},e);for(var n=Math.round(Math.max(4,e.radialSegments)),i=e,r=i.radius,o=i.height,s=360/n/360*Math.PI*2,a=n+1,h=new Float32Array(3*a*2),c=t[0],l=t[1],u=0,d=0,p=3*a,f=2*a,g=[],y=[],x=-1;x<n;x++){var m,v,b=s*x,_=Math.cos(b)*r+c,w=Math.sin(b)*r+l;h[u]=_,h[u+1]=w,h[u+2]=0,h[u+p]=_,h[u+1+p]=w,h[u+2+p]=o,m=.5+_/r/2,v=.5+w/r/2,y[d]=m,y[d+1]=v,y[d+f]=m,y[d+1+f]=v,u+=3,d+=2,x>1&&g.push(0,x-1,x)}h[u-=3]=h[0],h[u+1]=h[1],h[u+2]=h[2];var M=h.length;h[M-3]=h[0],h[M-2]=h[1],h[M-1]=o;for(var A=g.length,O=0;O<A;O++){var j=g[O];g.push(j+a)}var T=new Float32Array(2*(3*a*2-6)),C=-1;u=2*a,d=0;for(var S=0,L=h.length/2;S<L-3;S+=3){var k=h[S],I=h[S+1],P=h[S+3],B=h[S+4];T[++C]=k,T[++C]=I,T[++C]=o,T[++C]=P,T[++C]=B,T[++C]=o,T[++C]=k,T[++C]=I,T[++C]=0,T[++C]=P,T[++C]=B,T[++C]=0;var E=u+2,U=u+3,z=u,F=u+1;g.push(z,E,F,E,U,F),u+=4;var V=d/a,Z=(d+1)/a;y.push(V,o/r/2,Z,o/r/2,V,0,Z,0),d++}var R=new Float32Array(h.length+T.length);R.set(h,0),R.set(T,h.length);var G=nt(g,R);return{points:h,indices:new Uint32Array(g),position:R,normal:G,uv:new Float32Array(y)}}(t.center||[0,0],t),a=new e.BufferGeometry;return i(a,"normal",new e.BufferAttribute(r,3)),i(a,"position",new e.BufferAttribute(n,3)),i(a,"uv",new e.BufferAttribute(o,2)),a.setIndex(new e.BufferAttribute(s,1)),a}function ve(t){const e=Object.assign({},t);return e._radius&&(e.radius=e._radius),me(e)}function be(t,n,r,o="y",s=0){let a=0;"y"===o?a=1:"z"===o&&(a=2);const h=t.attributes.position.array,c=h.length;xe.setStyle(n),ye.setStyle(r);const l=new Float32Array(c);if(Array.isArray(s))for(let t=0,e=s.length;t<e;t++){const{middleZ:e,start:n,end:i}=s[t].position;for(let t=n;t<i;t+=3){h[t+2]>e?(l[t]=ye.r,l[t+1]=ye.g,l[t+2]=ye.b):(l[t]=xe.r,l[t+1]=xe.g,l[t+2]=xe.b)}}else for(let t=0;t<c;t+=3){h[t+a]>s?(l[t]=ye.r,l[t+1]=ye.g,l[t+2]=ye.b):(l[t]=xe.r,l[t+1]=xe.g,l[t+2]=xe.b)}return i(t,"color",new e.BufferAttribute(l,3,!0)),l}function _e(t){const n=[],r=t.length;let o=0;for(let e=0;e<r;e++){const{color:n}=t[e].attributes;n&&(o+=n.array.length)}const s=new Float32Array(o);let a=0;for(let e=0,i=t.length;e<i;e++){const{color:i,normal:r,position:o,uv:h}=t[e].attributes,c=t[e].index;i&&(s.set(i.array,a),a+=i.array.length),n.push({normal:r.array,uv:h.array,position:o.array,indices:c.array})}const h=he(n);s.length&&i(h,"color",new e.BufferAttribute(s,3,!0));for(let e=0,n=t.length;e<n;e++)t[e].dispose();return h}function we(){return ge}const Me={radius:10,height:100,radialSegments:6,altitude:0,topColor:"",bottomColor:"#2d2f61",heightEnable:!0};class Ae extends f{constructor(e,n,i,o){n=t.Util.extend({},Me,n,{layer:o,coordinate:e}),super(),this._initOptions(n);const{height:s,radius:a,topColor:h,bottomColor:c,altitude:l,asynchronous:u}=n;let d;if(n.height=o.altitudeToVector3(s,s).x,n.radius=o.distanceToVector3(a,a).x,u){d=fe();const e=t.Util.GUID();this.getOptions().id=e,oe.push({data:{radius:n.radius,height:n.height,radialSegments:n.radialSegments,id:e},layer:o,id:e,baseObject:this})}else d=ve(n),h&&(be(d,c,h,"z",n.height/2),i.vertexColors=r());this._createMesh(d,i);const p=o.altitudeToVector3(l,l).x,f=o.coordinateToVector3(e,p);this.getObject3d().position.copy(f),this.type="Bar"}_workerLoad(t){const e=ue(t),{topColor:n,bottomColor:i,height:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(n){be(e,i,n,"z",this.getLayer().altitudeToVector3(o,o).x/2),a.vertexColors=r()}s.geometry=e,s.material.needsUpdate=!0,this._fire("workerload",{target:this})}}function Oe(t){const n=[];return t&&t.length&&t.forEach((t=>{t=t instanceof e.Color?t:new e.Color(t),n.push(t.r,t.g,t.b)})),n}const je={altitude:0,bottomHeight:0,colors:null};class Te extends f{constructor(n,o,s,a){o=t.Util.extend({},je,o,{layer:a,lineString:n}),super(),this._initOptions(o);const{lineStrings:h,center:c}=Bt(n),{asynchronous:l}=o;let u;if(l){u=Vt();const e=t.Util.GUID();this.getOptions().id=e,this.getOptions().center=c,ee.push({id:e,data:h,layer:a,key:o.key,lineString:n,baseObject:this})}else{const t=[];for(let e=0,n=h.length;e<n;e++){const n=h[e],{positions:i}=Lt(n,a,c,!1);t.push(Et(i))}const n=Ut(t);u=new e.BufferGeometry,i(u,"position",new e.BufferAttribute(n,3)),vt(u,o.bottomHeight,a);const l=Oe(o.colors);l&&l.length&&(i(u,"color",new e.Float32BufferAttribute(l,3)),s.vertexColors=r())}this._createLineSegments(u,s);const{altitude:d}=o,p=a.altitudeToVector3(d,d).x,f=a.coordinateToVector3(c,p);this.getObject3d().position.copy(f),this.type="Line"}_workerLoad(t){const n=new e.BufferGeometry;i(n,"position",new e.BufferAttribute(new Float32Array(t.position),3));const o=Oe(this.getOptions().colors),s=this.getObject3d(),a=s.material;o&&o.length&&(i(n,"color",new e.Float32BufferAttribute(o,3)),a.vertexColors=r()),this._computeLineDistances(n),s.geometry=n,s.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const Ce={bottomHeight:0,width:3,height:1,altitude:0,topColor:null,bottomColor:"#2d2f61",heightEnable:!0};class Se extends f{constructor(e,n,i,o){n=t.Util.extend({},Ce,n,{layer:o,lineString:e}),super(),this._initOptions(n);const{height:s,width:a,bottomColor:h,topColor:c,bottomHeight:l,altitude:u,asynchronous:d}=n,p=o.altitudeToVector3(s,s).x,f=o.distanceToVector3(a,a).x,{lineStrings:g,center:y}=Bt(e);let x;if(d){x=fe();const n=t.Util.GUID();this.getOptions().id=n,this.getOptions().center=y,Jt.push({id:n,data:g,layer:o,center:y,lineString:e,baseObject:this})}else{const t=[];let e=0;const n={};for(let i=0,r=g.length;i<r;i++){const r=Pt(g[i],f,p,o,y);e=vt(r,l,o,n),t.push(r)}x=he(t),c&&(Ot(x,h,c,e+p/2),i.vertexColors=r())}this._createMesh(x,i);const m=o.altitudeToVector3(u,u).x,v=o.coordinateToVector3(y,m);this.getObject3d().position.copy(v),this.type="ExtrudeLine"}_workerLoad(t){const e=ue(t),{topColor:n,bottomColor:i,bottomHeight:o,height:s}=this.getOptions(),a=this.getObject3d(),h=a.material;if(n){const t=this.getLayer();Ot(e,i,n,t.altitudeToVector3(o,o).x+t.altitudeToVector3(s,s).x/2),h.vertexColors=r()}a.geometry=e,a.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const Le={altitude:0,height:1,bottomHeight:0,topColor:null,bottomColor:"#2d2f61",heightEnable:!0};class ke extends f{constructor(n,o,s,a){o=t.Util.extend({},Le,o,{layer:a,polygon:n}),super(),this._initOptions(o);const{height:h,topColor:c,bottomColor:l,altitude:u,bottomHeight:d,asynchronous:p}=o;let f;const g=m(n)?M(n):n.getCenter();if(p){f=fe();const e=t.Util.GUID();this.getOptions().id=e,this.getOptions().center=g,Yt.push({data:n,layer:a,id:e,baseObject:this})}else{f=function(t,n,r,o){const{position:s,normal:a,uv:h,indices:c}=At(t,n,r,o),l=new Float32Array(s.length);l.fill(1,0,s.length);const u=new e.BufferGeometry;return i(u,"color",new e.BufferAttribute(l,3)),i(u,"normal",new e.BufferAttribute(a,3)),i(u,"position",new e.BufferAttribute(s,3)),i(u,"uv",new e.BufferAttribute(h,2)),u.setIndex(new e.BufferAttribute(c,1)),u}(n,h,a);const t=vt(f,d,a);if(c){Ot(f,l,c,t+a.altitudeToVector3(h,h).x/2),s.vertexColors=r()}}this._createMesh(f,s);const y=a.altitudeToVector3(u,u).x,x=a.coordinateToVector3(g,y);this.getObject3d().position.copy(x),this.type="ExtrudePolygon"}_workerLoad(t){const e=ue(t),{topColor:n,bottomColor:i,bottomHeight:o,height:s}=this.getOptions(),a=this.getObject3d(),h=a.material;if(n){const t=this.getLayer();Ot(e,i,n,t.altitudeToVector3(o,o).x+t.altitudeToVector3(s,s).x/2),h.vertexColors=r()}a.geometry=e,a.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const Ie={altitude:0,coordinate:null};class Pe extends f{constructor(e,n={},i){n.coordinate||(console.warn("coordinate is null,it is important to locate the model"),n.coordinate=i.getMap().getCenter()),n=t.Util.extend({},Ie,n,{layer:i,model:e}),super(),this._initOptions(n),this._createGroup(),this.getObject3d().add(e);const{altitude:r,coordinate:o}=n,s=i.altitudeToVector3(r,r).x,a=i.coordinateToVector3(o,s);this.getObject3d().position.copy(a),this.type="Model"}}const Be=Math.PI/180,Ee=6378137;function Ue(t){return t*Be}function ze(t,e){if(!t||!e)return 0;Array.isArray(t)||(t=t.toArray()),Array.isArray(e)||(e=e.toArray());let n=Ue(t[1]);const i=Ue(e[1]),r=n-i,o=Ue(t[0])-Ue(e[0]);return n=2*Math.asin(Math.sqrt(Math.pow(Math.sin(r/2),2)+Math.cos(n)*Math.cos(i)*Math.pow(Math.sin(o/2),2))),n*=Ee,Math.round(1e5*n)/1e5}function Fe(t,e){const{len:n,c1:i,c2:r}=t,o=r[0]-i[0],s=r[1]-i[1],a=e/n;return[i[0]+a*o,i[1]+a*s]}const Ve=1e3;const Ze={trail:5,chunkLength:50,width:2,height:1,speed:1,altitude:0,interactive:!1,heightEnable:!0};class Re extends f{constructor(n,r,o,s){r=t.Util.extend({},Ze,r,{layer:s,lineString:n}),super(),this._initOptions(r);const{width:a,height:h,altitude:c,speed:l,chunkLength:u,trail:d}=r;let p,f;x(n)?(p=M(n),f=w(n)):(p=n.getCenter(),f=n);const g=function(t,e=10){e=Math.max(e,.1),Array.isArray(t)||(t=t.getCoordinates().map((t=>t.toArray())));const n=t.length;let i=[],r=0;for(let e=0;e<n-1;e++){const n=ze(t[e],t[e+1]),o=Math.floor(n);i.push({c1:t[e],len:o,c2:t[e+1]}),r+=o}if(r<=e)return i.map((t=>[t.c1,t.c2]));if(1===i.length&&i[0].len<=e)return[[i[0].c1,i[0].c2]];const o=i.length;let s,a=0,h=0;const c=[];let l=[i[0].c1];for(;a<o;){const{len:t,c2:n}=i[a];if(h+=t,h<e&&(l.push(n),a===o-1&&c.push(l),a++),h===e&&(l.push(n),h=0,c.push(l),l=[n],a++),h>e){const n=t-h+e;s=Fe(i[a],n),l.push(s),c.push(l),h=0,i[a].c1=s,i[a].len=t-n,l=[],l.push(s)}}return c}(f,u),y=s.coordinateToVector3(p),m=new e.BufferGeometry,v=new Float32Array(3e3),b=new Float32Array(3e3),_=new Uint16Array(Ve);i(m,"position",new e.BufferAttribute(v,3)),i(m,"normal",new e.BufferAttribute(b,3)),m.setIndex(new e.BufferAttribute(_,1));const A=s.distanceToVector3(a,a).x,O=s.altitudeToVector3(h,h).x;this._createMesh(m,o);const j=s.altitudeToVector3(c,c).x,T=s.coordinateToVector3(p,j);this.getObject3d().position.copy(T),this._params={index:0,chunkLines:g,geometries:[],layer:s,trail:Math.max(1,d),lineWidth:A,depth:O,speed:Math.min(1,l),idx:0,loaded:!0,center:p,centerPt:y,workerInitCount:0},this._init(this._params),this.type="ExtrudeLineTrail"}_init(e){const{layer:n,trail:i,lineWidth:r,depth:o,chunkLines:s,positionMap:a,centerPt:h,center:c}=e,l=s.length,u=[];if(this.options.asynchronous){e.loaded=!1;const r=t.Util.GUID();for(let e=0;e<l;e++){const o={type:"Feature",geometry:{type:"LineString",coordinates:It(s.slice(e,e+i))}},a=`${r}-${e}`,h=t.Util.extend({},this.options);h.id=a,h.center=c,Jt.push({id:a,data:[o],layer:n,center:c,lineString:o,baseObject:this,option:h})}}else for(let t=0;t<l;t++){const e=kt(s.slice(t,t+i),n,0,h).positionsV;u.push(Pt(e,r,o,n))}}_animation(){const{index:t,geometries:e,speed:n,idx:i,chunkLines:r,trail:o,lineWidth:s,depth:a,loaded:h,layer:c,positionMap:l,centerPt:u}=this._params;if(!h)return;const d=Math.round(t);if(d>i){this._params.idx++;let t=e[d];if(!t){t=Pt(kt(r.slice(d,d+o),c,0,u).positionsV,s,a,c),e[d]=t}const n=this.getObject3d();!function(t,e,n,i){const r=e.length;t.attributes.normal.count=r,t.attributes.position.count=r;const o=t.attributes.position.array,s=t.attributes.normal.array;for(let t=0;t<r;t++)o[t]=e[t],s[t]=n[t];t.index.count=i.length;for(let e=0,n=i.length;e<n;e++)t.index.array[e]=i[e]}(n.geometry,t.position,t.normal,t.indices),n.geometry.attributes.position.needsUpdate=!0,n.geometry.attributes.normal.needsUpdate=!0,n.geometry.index.needsUpdate=!0}t>=r.length-1&&(this._params.index=-1,this._params.idx=-1),this._params.index+=n}_workerLoad(e){if(!e)return this;const{id:n,indices:i,position:r,normal:o,uv:s}=e;if(!(n&&i&&r&&o&&s))return;let a=n.split("-")[1];if(a=parseInt(a),t.Util.isNumber(a)){this._params.geometries[a]={indices:new Uint32Array(i),position:new Float32Array(r),uv:new Float32Array(s),normal:new Float32Array(o)},this._params.workerInitCount++}this._params.workerInitCount===this._params.chunkLines.length&&(this._params.loaded=!0,this._fire("workerload",{target:this}))}}const Ge=["click","mousemove","mousedown","mouseup","dblclick","contextmenu"].join(" ").toString(),De=new e.MeshBasicMaterial;De.vertexColors=r();const He=t=>class extends t{_initBaseObjectsEvent(t){if(t&&Array.isArray(t)&&t.length)for(let e=0,n=t.length;e<n;e++){const n=t[e];this._proxyEvent(n)}return this}_proxyEvent(t){t.on("add",(t=>{this._showGeometry(t.target,!0)})),t.on("remove",(t=>{this._showGeometry(t.target,!1)})),t.on("mouseout",(t=>{this._mouseover=!1,this.fire("mouseout",Object.assign({},t,{target:this,selectMesh:this.getSelectMesh?this.getSelectMesh():null}))})),t.on(Ge,(t=>{this.fire(t.type,Object.assign({},t,{target:this,selectMesh:this.getSelectMesh?this.getSelectMesh():null}))}))}_getHideGeometryIndex(t){const e=[];let n=0;for(let i=0,r=this._geometriesAttributes.length;i<r;i++)!0===this._geometriesAttributes[i].hide&&(e.push(i),n+=this._geometriesAttributes[i][t].count);return{indexs:e,count:n}}_updateAttribute(t,n){const{indexs:i}=this._getHideGeometryIndex(n),r=this._geometryCache.attributes[n].array,o=r.length;for(let e=0;e<o;e++)t.array[e]=r[e];let s=NaN;this.getObject3d()instanceof e.LineSegments&&(s=0);for(let e=0;e<i.length;e++){const r=i[e],{start:o,end:a}=this._geometriesAttributes[r][n];for(let e=o;e<a;e++)t.array[e]=s}return this}_showGeometry(t,e){let n;if(t&&(n=t.getOptions().index),null!=n){const t=this._geometriesAttributes[n],{hide:i}=t;if(i===e)return this;t.hide=e;const r=this.getObject3d().geometry;this._updateAttribute(r.attributes.position,"position"),r.attributes.position.needsUpdate=!0,this.isHide=e}return this}getSelectMesh(){const t=this._getIndex();if(null!=t)return{data:this._datas[t],baseObject:this._baseObjects[t]}}_getIndex(t){return null==t&&(t=this.faceIndex||this.index),t}_init(){const t=this.getLayer().getPick();this.on("add",(()=>{t.add(this.pickObject3d)})),this.on("remove",(()=>{t.remove(this.pickObject3d)}))}_setPickObject3d(){if(!this._colorMap)return;const t=this._geometryCache||this.getObject3d().geometry.clone(),n=this.getLayer().getPick(),{_geometriesAttributes:r}=this,o=r.length,s=bt(r);let a=0;for(let t=0;t<o;t++){const e=n.getColor(),i=e.getHex();this._colorMap[i]=t;const{count:o}=r[t].position;this._datas[t].colorIndex=i;for(let t=0;t<o;t++)s[a]=e.r,s[a+1]=e.g,s[a+2]=e.b,a+=3}i(t,"color",new e.BufferAttribute(s,3,!0));const h=n.getColor().getHex(),c=new e.Mesh(t,De);c.position.copy(this.getObject3d().position),c._colorIndex=h,this.setPickObject3d(c)}},Qe={altitude:0,height:1,bottomHeight:0,topColor:null,bottomColor:"#2d2f61"},We=new t.Coordinate(0,0);class Ne extends(He(f)){constructor(e,n,i,o){Array.isArray(e)||(e=[e]);const s=e.length;0===s&&console.error("polygons is empty");let a=1/0,h=1/0,c=-1/0,l=-1/0;for(let n=0;n<s;n++){const i=e[n],r=i.getCenter?i.getCenter():M(i,We);let o,s;Array.isArray(r)?(o=r[0],s=r[1]):r instanceof t.Coordinate&&(o=r.x,s=r.y),a=Math.min(a,o),h=Math.min(h,s),c=Math.max(c,o),l=Math.max(l,s)}const u=new t.Coordinate((a+c)/2,(h+l)/2);n=t.Util.extend({},Qe,n,{layer:o,polygons:e,coordinate:u});const{topColor:d,bottomColor:p,altitude:f,asynchronous:g}=n;let y;const x=[],v=[];if(super(),g)y=fe(),Xt.push({id:t.Util.GUID(),layer:o,key:n.key,center:u,data:e,baseObject:this});else{const t=o.coordinateToVector3(u),n=[];let a=0;const h={};for(let i=0;i<s;i++){const r=e[i],s=m(r)?r.properties:r.getProperties()||{},c=s.height||1,l=s.bottomHeight||0,d=At(r,c,o,u,t,h);n.push(d);const p=vt(d,l,o,h),{position:f,normal:g,uv:y,indices:x}=d;x.length;const b=f.length/3;g.length,y.length,v[i]={position:{middleZ:p+h[c]/2,count:b,start:a,end:a+3*b},hide:!1},a+=3*b}y=he(n),d&&(Ot(y,p,d,v),i.vertexColors=r())}this._initOptions(n),this._createMesh(y,i);const b=o.altitudeToVector3(f,f).x,_=o.coordinateToVector3(u,b);this.getObject3d().position.copy(_),this._baseObjects=x,this._datas=e,this._geometriesAttributes=v,this.faceIndex=null,this._geometryCache=de(y),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(x),g||(this._setPickObject3d(),this._init()),this.type="ExtrudePolygons"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=Object.assign({},this.options,m(e)?e.properties:e.getProperties(),{index:t});this._baseObjects[t]=new ke(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){return this.picked}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const n=ue(t);this._geometryCache=de(n);const{topColor:i,bottomColor:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(i&&(Ot(n,o,i,e),a.vertexColors=r()),s.geometry=n,s.material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}function Ke(t,e,n){const i=t.project(n),r=e.width/2,o=e.height/2;return{x:Math.round(i.x*r+r),y:Math.round(-i.y*o+o)}}const qe={altitude:0,height:0,color:null},$e=new e.Vector3;class Ye extends f{constructor(n,r,o,s){r=t.Util.extend({},qe,r,{layer:s,coordinate:n}),super();let{height:a,altitude:h,color:c,size:l}=r;const u=[],d=[];c&&(c=c instanceof e.Color?c:new e.Color(c),d.push(c.r,c.g,c.b));const p=s.altitudeToVector3(a,a).x,f=s.coordinateToVector3(n,p);u.push(0,0,f.z);const g=new e.BufferGeometry;i(g,"position",new e.Float32BufferAttribute(u,3,!0)),d.length&&i(g,"color",new e.Float32BufferAttribute(d,3,!0)),void 0!==l&&i(g,"size",new e.Float32BufferAttribute([l],1,!0)),r.positions=f,this._initOptions(r),this._createPoints(g,o);const y=s.altitudeToVector3(h,h).x,x=new e.Vector3(f.x,f.y,y);this.getObject3d().position.copy(x),this.type="Point"}identify(t){const e=this.getLayer(),n=this.getMap().getSize(),i=this.getLayer().getCamera(),r=this.getOptions().positions,o=this.getOptions().altitude;let s=this.getObject3d().material.size;void 0===s&&(s=this.options.size||1);const a=this.getMap().coordToContainerPoint(t),h=e.altitudeToVector3(o,o).x;$e.x=r.x,$e.y=r.y,$e.z=r.z+h;const c=Ke($e,n,i);return Math.sqrt(Math.pow(a.x-c.x,2)+Math.pow(a.y-c.y,2))<=s/2}}function Xe(t,e){const{minx:n,miny:i,maxx:r,maxy:o}=t,[s,a]=e;return n<=s&&s<=r&&i<=a&&a<=o}class Je{constructor(t,e,n,i){this.minlng=t,this.minlat=e,this.maxlng=n,this.maxlat=i,this.minx=1/0,this.miny=1/0,this.maxx=-1/0,this.maxy=-1/0,this.coordinates=[],this.positions=[],this.indexs=[],this.key=null}updateBBoxPixel(e){let n=1/0,i=1/0,r=-1/0,o=-1/0;const{minlng:s,minlat:a,maxlng:h,maxlat:c}=this;return[[s,a],[s,c],[h,a],[h,c]].map((e=>new t.Coordinate(e))).map((t=>e.coordToContainerPoint(t))).forEach((t=>{n=Math.min(n,t.x),i=Math.min(i,t.y),r=Math.max(r,t.x),o=Math.max(o,t.y)})),this.minx=n,this.miny=i,this.maxx=r,this.maxy=o,this}containsCoordinate(e){let n,i;Array.isArray(e)?(n=e[0],i=e[1]):e instanceof t.Coordinate&&(n=e.x,i=e.y);const{minlng:r,minlat:o,maxlng:s,maxlat:a}=this;return r<=n&&n<=s&&o<=i&&i<=a}isRecCross(t,e){const{x:n,y:i}=t,r={minx:n-e/2,miny:i-e/2,maxx:n+e/2,maxy:i+e/2},{minx:o,miny:s,maxx:a,maxy:h}=r;return!!(Xe(this,[o,s])||Xe(this,[o,h])||Xe(this,[a,s])||Xe(this,[a,h])||Xe(r,[this.minx,this.miny])||Xe(r,[this.minx,this.maxy])||Xe(r,[this.maxx,this.miny])||Xe(r,[this.maxx,this.maxy]))}static initGrids(t,e,n,i){const r=[],o=(n-t)/30,s=(i-e)/30;let a=t,h=e;for(let n=0;n<30;n++){a=t+n*o;for(let t=0;t<30;t++){h=e+t*s;const i=new Je(a,h,a+o,h+s);i.key=t+"-"+n,r.push(i)}}return{grids:r,averageX:o,averageY:s,ROWS:30,COLS:30}}}const tn={altitude:0},en=new e.Vector3;function nn(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}class rn extends(He(f)){constructor(n,r,o,s){Array.isArray(n)||(n=[n]),r=t.Util.extend({},tn,r,{layer:s,points:n});let a=1/0,h=1/0,c=-1/0,l=-1/0;for(let e=0,i=n.length;e<i;e++){const{coordinate:i}=n[e];let r,o;Array.isArray(i)?(r=i[0],o=i[1]):i instanceof t.Coordinate&&(r=i.x,o=i.y),n[e].coords=[r,o],a=Math.min(a,r),h=Math.min(h,o),c=Math.max(c,r),l=Math.max(l,o)}const u=s.coordinateToVector3([(a+c)/2,(h+l)/2]),{grids:d,averageX:p,averageY:f,ROWS:g,COLS:y}=Je.initGrids(a,h,c,l);d.length;const x=new Float32Array(3*n.length),m=[],v=new Float32Array(3*n.length),b=new Float32Array(n.length),_=[],w=[],M={};let A=0,O=!1,j=!1;const T=new e.Vector3(0,0,0);for(let t=0,i=n.length;t<i;t++){let{coordinate:i,height:r,color:o,size:c,coords:l}=n[t];const y=3*t;o&&(O=!0,o=o instanceof e.Color?o:new e.Color(o),v[y]=o.r,v[y+1]=o.g,v[y+2]=o.b),c&&(j=!0,b[t]=c,A=Math.max(A,c));const _=xt(r,s,M),C=s.coordinateToVector3(i,_);T.x=C.x,T.y=C.y,T.z=C.z,T.sub(u),x[y]=T.x,x[y+1]=T.y,x[y+2]=T.z,m.push(C),w[t]={position:{count:1,start:3*t,end:3*t+3},hide:!1};let S=nn((l[1]-h)/f,4),L=nn((l[0]-a)/p,4);S-=1,L-=1,S=Math.max(0,S),L=Math.max(0,L),S=Math.ceil(S),L=Math.ceil(L);const k=L*g+S;d[k]&&(d[k].positions.push(C),d[k].indexs.push(t))}const C=new e.BufferGeometry;i(C,"position",new e.BufferAttribute(x,3,!0)),O&&i(C,"color",new e.BufferAttribute(v,3,!0)),j&&i(C,"size",new e.BufferAttribute(b,1,!0)),r.positions=m,super(),this._initOptions(r),this._createPoints(C,o);const S=r.altitude,L=s.altitudeToVector3(S,S).x,k=u.clone();k.z=L,this.getObject3d().position.copy(k),this._baseObjects=_,this._datas=n,this.faceIndex=null,this._geometriesAttributes=w,this._geometryCache=C.clone(),this.isHide=!1,this._initBaseObjectsEvent(_),this._grids=d,this._bindMapEvents(),this.type="Points",this.maxSize=A}_bindMapEvents(){const t=this.getMap(),e="zoomstart zooming zoomend movestart moving moveend pitch rotate";this.on("add",(()=>{this._updateGrids(),t.on(e,this._updateGrids,this)})),this.on("remove",(()=>{t.off(e,this._updateGrids,this)}))}_updateGrids(){const t=this.getMap();this._grids.forEach((e=>{e.indexs.length&&e.updateBBoxPixel(t)}))}getSelectMesh(){const t=this.faceIndex;if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],{coordinate:n,height:i,color:r,size:o}=e;this._baseObjects[t]=new Ye(n,{height:i,index:t,color:r,size:o},this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){const e=this.getLayer(),n=this.getMap().getSize(),i=this.getLayer().getCamera(),r=this.getOptions().altitude,o=this.getMap(),s=e.altitudeToVector3(r,r).x;let a=this.getObject3d().material.size;const h=void 0===a,c=o.coordToContainerPoint(t),l=[];if(this._grids.forEach((t=>{t.indexs.length&&t.isRecCross(c,h?this.maxSize:a)&&l.push(t)})),l.length<1)return!1;for(let t=0,e=l.length;t<e;t++)for(let e=l[t].positions.length-1;e>=0;e--){h&&(a=this._datas[l[t].indexs[e]].size||1);const r=l[t].positions[e];en.x=r.x,en.y=r.y,en.z=r.z+s;const o=Ke(en,n,i);if(Math.sqrt(Math.pow(c.x-o.x,2)+Math.pow(c.y-o.y,2))<=a/2)return this.faceIndex=l[t].indexs[e],!0}return!1}}const on={coordinate:"",radius:10,height:100,radialSegments:6,altitude:0,topColor:"",bottomColor:"#2d2f61"};class sn extends(He(f)){constructor(n,i,o,s){Array.isArray(n)||(n=[n]);const a=n.length,h=mt(n),c=s.coordinateToVector3(h),l=[],u=[],d=[];let p=0;const f={},g={};let y;super(),i=t.Util.extend({},{altitude:0,layer:s,points:n},on,i),this._initOptions(i);const x=new e.Vector3;if(i.asynchronous){y=fe();const e=t.Util.GUID();this.getOptions().id=e;const i=[];for(let e=0;e<a;e++){const r=t.Util.extend({index:e},on,n[e]),{radius:o,radialSegments:a,altitude:h,height:l,coordinate:u}=r,d=yt(o,s,f);n[e]._radius=d;const p=xt(l,s,g),y=xt(h,s,g),m=s.coordinateToVector3(u,0,x).sub(c);i.push({radialSegments:a,radius:d,height:p,center:[m.x,m.y],altitude:y})}se.push({id:e,data:i,layer:s,baseObject:this})}else{for(let e=0;e<a;e++){const i=t.Util.extend({index:e},on,n[e]),{radius:a,radialSegments:h,altitude:y,topColor:m,bottomColor:v,height:b,coordinate:_}=i,w=yt(a,s,f),M=xt(b,s,g),A=xt(y,s,g),O=s.coordinateToVector3(_,0,x).sub(c),j=ve({radius:w,height:M,radialSegments:h,center:[O.x,O.y]});m&&(be(j,v,m,"z",M/2),o.vertexColors=r());const T=j.attributes.position.array;for(let t=0,e=T.length;t<e;t+=3)T[t+2]+=A;l.push(j);const C=new Ae(_,i,o,s);u.push(C),j.index.count;const S=j.attributes.position.count;j.attributes.normal.count,j.attributes.uv.count,d[e]={position:{count:S,start:p,end:p+3*S},hide:!1},p+=3*S}y=_e(l)}this._createMesh(y,o);const m=i.altitude,v=s.altitudeToVector3(m,m).x,b=c.clone();b.z=v,this.getObject3d().position.copy(b),this._baseObjects=u,this._datas=n,this._geometriesAttributes=d,this.faceIndex=null,this._geometryCache=de(y),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(u),i.asynchronous||(this._setPickObject3d(),this._init()),this.type="Bars"}identify(){return this.picked}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=Object.assign({},this.options,e,{index:t,asynchronous:!1});this._baseObjects[t]=new Ae(e.coordinate,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const n=ue(t);this._geometryCache=de(n);const{topColor:i,bottomColor:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(i&&(be(n,o,i,"z",e),a.vertexColors=r()),s.geometry=n,s.material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const an={width:3,height:1,altitude:0,topColor:null,bottomColor:"#2d2f61"};class hn extends(He(f)){constructor(e,n,i,o){Array.isArray(e)||(e=[e]);const s=[],a=[],h=e.length;for(let t=0;t<h;t++){const n=Bt(e[t]);s.push(n.center),a.push(n.lineStrings)}const c=mt(s);n=t.Util.extend({},an,n,{layer:o,lineStrings:e,coordinate:c});const{altitude:l,topColor:u,bottomColor:d,asynchronous:p}=n;let f;const g=[],y=[];if(super(),p)f=fe(),te.push({id:t.Util.GUID(),layer:o,key:n.key,center:c,data:a,lineStrings:e,baseObject:this});else{const n=[];let s=0;const l={},p={};for(let i=0;i<h;i++){const r=e[i],h=t.Util.extend({},an,x(r)?r.properties:r.getProperties(),{index:i}),{height:u,width:d,bottomHeight:f}=h,g=yt(d,o,l),m=xt(u,o,p),v=a[i],b=[];let _=0;for(let t=0,e=v.length;t<e;t++){const e=Pt(v[t],g,m,o,c);_=vt(e,f,o,l),b.push(e)}const w=ce(b);n.push(w);const{position:M,normal:A,indices:O}=w;O.length;const j=M.length/3;A.length,y[i]={position:{middleZ:_+m/2,count:j,start:s,end:s+3*j},hide:!1},s+=3*j}f=he(n),u&&(Ot(f,d,u,y),i.vertexColors=r())}this._initOptions(n),this._createMesh(f,i);const m=o.altitudeToVector3(l,l).x,v=o.coordinateToVector3(c,m);this.getObject3d().position.copy(v),this._baseObjects=g,this._datas=e,this._geometriesAttributes=y,this.faceIndex=null,this._geometryCache=de(f),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(g),p||(this._setPickObject3d(),this._init()),this.type="ExtrudeLines"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=Object.assign({},this.options,v(e)?e.properties:e.getProperties(),{index:t});this._baseObjects[t]=new Se(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){return this.picked}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const n=ue(t);this._geometryCache=de(n);const{topColor:i,bottomColor:o,bottomHeight:s,height:a}=this.getOptions(),h=this.getObject3d().material;if(i&&(Ot(n,o,i,e),h.vertexColors=r()),this.getObject3d().geometry=n,this.getObject3d().material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const cn={altitude:0,colors:null};class ln extends(He(f)){constructor(n,r,o,s){Array.isArray(n)||(n=[n]);const a=[],h=[],c=n.length;for(let t=0;t<c;t++){const e=Bt(n[t]);a.push(e.center),h.push(e.lineStrings)}const l=mt(a);r=t.Util.extend({},cn,r,{layer:s,lineStrings:n,coordinate:l}),super(),this._initOptions(r);const{asynchronous:u}=r;let d;const p=[],f={};let g=[],y=0,x=[];if(u)d=Vt(),ne.push({id:t.Util.GUID(),layer:s,key:r.key,center:l,data:h,lineStrings:n,baseObject:this});else{for(let t=0;t<c;t++){const e=h[t];let n=0;for(let t=0,i=e.length;t<i;t++){const i=v(e[t])?e[t].properties:e[t].getProperties()||{},{positions:r}=Lt(e[t],s,l,!1);vt(r,i.bottomHeight,s,f),n+=r.length/3*2-2,x.push(Et(r))}g[t]={position:{count:n,start:y,end:y+3*n},hide:!1},y+=3*n}const t=Ut(x);d=new e.BufferGeometry,i(d,"position",new e.BufferAttribute(t,3))}this._createLineSegments(d,o);const{altitude:m}=r,b=s.altitudeToVector3(m,m).x,_=s.coordinateToVector3(l,b);this.getObject3d().position.copy(_),this._baseObjects=p,this._datas=n,this._geometriesAttributes=g,this.faceIndex=null,this.index=null,this._geometryCache=d.clone(),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(p),u||(this._setPickObject3d(),this._init()),this.type="Lines"}getSelectMesh(){const e=this._getIndex();if(null!=e){if(!this._baseObjects[e]){const n=this._datas[e],i=t.Util.extend({},this.getOptions(),{index:e},v(n)?n.properties:n.getProperties());this._baseObjects[e]=new Te(n,i,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[e])}return{data:this._datas[e],baseObject:this._baseObjects[e]}}}_setPickObject3d(){if(!this._colorMap)return;const t=this._geometryCache||this.getObject3d().geometry.clone(),n=this.getLayer().getPick(),{_geometriesAttributes:o}=this,s=o.length,a=bt(o);let h=0;for(let t=0;t<s;t++){const e=n.getColor(),i=e.getHex();this._colorMap[i]=t;const{count:r}=o[t].position;this._datas[t].colorIndex=i;for(let t=0;t<r;t++)a[h]=e.r,a[h+1]=e.g,a[h+2]=e.b,h+=3}i(t,"color",new e.BufferAttribute(a,3,!0));const c=this.getObject3d().material.clone();c.color.set("#fff"),c.vertexColors=r();const l=n.getColor().getHex(),u=new e.LineSegments(t,c);u.position.copy(this.getObject3d().position),u._colorIndex=l,this.setPickObject3d(u)}identify(t){return this.picked}_workerLoad(t){const{position:n,geometriesAttributes:r}=t;this._geometriesAttributes=r;const o=new e.BufferGeometry;if(i(o,"position",new e.BufferAttribute(new Float32Array(n),3)),this._computeLineDistances(o),this._geometryCache=o.clone(),this.getObject3d().geometry=o,this.getObject3d().material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const un=[],dn=[];function pn(){return{waitingQueue:un,currentQueue:dn}}function fn(t,e){for(let n=0,i=t.length;n<i;n++){const i=t[n];if(i){const{key:r,callback:o}=i;if(e===r)return t.splice(n,1),o}}return null}const gn=document.createElement("canvas");let yn;function xn(t,e=!1){if(yn)return yn;const n=gn.getContext("2d");return n.clearRect(0,0,256,256),n.save(),yn=gn.toDataURL(),yn}function mn(t=1,e=1){let n;return"undefined"==typeof document||(n=document.createElement("canvas"),t&&(n.width=t),e&&(n.height=e)),n}gn.width=gn.height=256;class vn extends t.TileLayer{constructor(e,n={}){super(t.Util.GUID(),t.Util.extend({urlTemplate:e},n)),this._opts=null,this._layer=null,this.material=null,this.getMaterial=null,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._layerLaodTime=(new Date).getTime()}isAsynchronous(){return this._opts.worker}getBaseObjects(){const t=this._loadTiles,e=[];for(let n in t){const t=this._baseObjectKeys[n];if(t&&Array.isArray(t)&&t.length)for(let n=0,i=t.length;n<i;n++)e.push(t[n])}return e}onSelectMesh(t,e){}formatBaseObjects(t,e){return[]}loopMessage(t){}getTileData(e){const{key:n,url:i,callback:r,img:o}=e;t.Ajax.getJSON(i,{},(function(t,e){t?(console.error(t),r(n,null,o)):r(n,e,o)}))}_getCurentTileKeys(){const t=this.getTiles().tileGrids||[],e=[],n={};for(let i=0,r=t.length;i<r;i++){const r=t[i].tiles||[];for(let t=0,i=r.length;t<i;t++){const{id:i}=r[t];e.push(i),n[i]=!0}}return{keys:e,keysMap:n}}_isLoad(){const{keys:t}=this._getCurentTileKeys(),e=Object.keys(this._renderer.tilesInView);return t.length===e.length}_layerOnLoad(){const t=(new Date).getTime();if(t-this._layerLaodTime<20)return;this._layerLaodTime=t;const e=this._renderer.tilesInView,n=this._loadTiles,i=this._layer,r=this._baseObjectKeys,o=Object.keys(e).length,s=Object.keys(n).length,a=[];if(o&&s)for(let t in n)e[t]||r[t]&&(r[t]||[]).forEach((t=>{a.push(t)}));if(a.length&&i.removeMesh(a,!1),o&&s)for(let t in e)if(!n[t])if(r[t]){const e=r[t];i.addMesh(e)}else{const{x:e,y:n,z:i}=this._getXYZOfIndex(t);this.getTileUrl(e,n,i)}this._loadTiles=Object.assign({},e),this._diffCache()}_init(){}_workerLoad(t){const e=t.target._img;e.currentCount++,e.currentCount===e.needCount&&(e.src=xn(e._key,this._opts.debug))}_generateBaseObjects(t,e,n){if(e&&n){const{keysMap:i}=this._getCurentTileKeys();if(!i[t])return void(n.src=xn(0,this._opts.debug));const r=this.formatBaseObjects(t,e);if(r.length){n.needCount=r.length,n.currentCount=0;for(let e=0,i=r.length;e<i;e++){const i=r[e];i._img=n,i._vt=this,this.isVisible()||i.hide(),this._cachetile(t,i),i.isAsynchronous()||n.currentCount++}this._layer.addMesh(r,!1),n.needCount===n.currentCount&&(n.src=xn(0,this._opts.debug)),this.isAsynchronous()?r.filter((t=>t.isAsynchronous())).forEach((t=>{t.on("workerload",this._workerLoad,this)})):n.src=xn(0,this._opts.debug)}else n.src=xn(0,this._opts.debug);this._loadTiles[t]=!0}else n&&(n.src=xn(0,this._opts.debug))}_diffCache(){if(Object.keys(this._baseObjectKeys).length>this._renderer.tileCache.max){const t=this._renderer.tileCache.data,e=this._renderer.tilesInView,n=[];for(let i in this._baseObjectKeys)t[i]||e[i]||((this._baseObjectKeys[i]||[]).forEach((t=>{t.isAdd&&n.push(t)})),this._diposeBaseObject(i),delete this._baseObjectKeys[i]);n.length&&this._layer.removeMesh(n,!1)}}_diposeBaseObject(t){const e=this._baseObjectKeys[t];e&&e.length&&e.forEach((t=>{t.getObject3d().geometry.dispose(),t._geometryCache&&t._geometryCache.dispose();const e=t._baseObjects;e&&e.length&&e.forEach((t=>{t.getObject3d().geometry.dispose(),t=null})),t._datas=null,t._geometriesAttributes=null,t._faceMap=null,t._colorMap=null,t.pickObject3d&&t.pickObject3d.geometry.dispose(),t=null}))}_cachetile(t,e){this._baseObjectKeys[t]||(this._baseObjectKeys[t]=[]),this._baseObjectKeys[t].push(e)}_getXYZOfIndex(t){const e=t.indexOf("_")>-1?"_":"-";let[n,i,r]=t.split(e).slice(1,4);return{x:parseInt(i),y:parseInt(n),z:parseInt(r)}}_getTileExtent(t,e,n){const i=this.getMap()._getResolution(n);return this._getTileConfig().getTilePrjExtent(t,e,i)}_getTileLngLatExtent(e,n,i){const r=this._getTileExtent(e,n,i);let o=r.getMax(),s=r.getMin();const a=this.getMap().getProjection();return s=a.unproject(s),o=a.unproject(o),new t.Extent(s,o)}}const bn={worker:!1};class _n extends vn{constructor(e,n={},i,r){super(t.Util.GUID(),t.Util.extend({urlTemplate:e},bn,n)),this._opts=n,this._layer=r,this.getMaterial=i,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._layerLaodTime=(new Date).getTime(),this._init()}formatBaseObjects(n,i){const r=this._opts,o=[],s=this.isAsynchronous();for(let a in i){const h=i[a]||{};let c;if(Array.isArray(h)?c=h:"FeatureCollection"===h.type&&(c=h.features),c&&c.length){const i=[],l=[],u=[];for(let e=0,n=c.length;e<n;e++){const n=c[e];if(m(n))i.push(n);else if(v(n)){const t=A(n);for(let e=0,n=t.length;e<n;e++)l.push(t[e])}else if(b(n)){const e=A(n);for(let n=0,i=e.length;n<i;n++)u.push(t.Util.extend({},e[n].properties,e[n],{coordinate:w(e[n])}))}}if(i.length){const e=this._getMaterial(a,i,n,h);if(e){const h=this._layer.toExtrudePolygons(i,t.Util.extend({},{topColor:"#fff",layerName:a,asynchronous:s,key:n},r),e);o.push(h)}}if(l.length){const i=this._getMaterial(a,l,n,h);if(i&&(i instanceof e.LineBasicMaterial||i instanceof e.LineDashedMaterial)){const e=this._layer.toLines(l,t.Util.extend({},{layerName:a,asynchronous:s},r),i);o.push(e)}}if(u.length){const i=this._getMaterial(a,u,n,h);if(i&&i instanceof e.PointsMaterial){const e=this._layer.toPoints(u,t.Util.extend({},{layerName:a,asynchronous:s},r),i);o.push(e)}}}}return o}loopMessage(t){const{currentQueue:e}=pn();e.length>0&&this.getTileData(t)}_init(){this.on("layerload",this._layerOnLoad),this.on("add",(()=>{if(!1===this._add){const t=this.getBaseObjects();this._layer.addMesh(t)}this._add=!0,this.intervalId=setInterval((()=>{this._isLoad()&&!this._layer.getMap().isInteracting()&&this.fire("layerload")}),1e3)})),this.on("remove",(()=>{this._add=!1;const t=this.getBaseObjects();this._layer.removeMesh(t),clearInterval(this.intervalId)})),this.on("show",(()=>{this.getBaseObjects().forEach((t=>{t.show()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.show()}))}})),this.on("hide",(()=>{this.getBaseObjects().forEach((t=>{t.hide()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.hide()}))}})),this.on("renderercreate",(t=>{t.renderer.loadTile=function(t){var e=this.layer.getTileSize(),n=new Image;return n.width=e.width,n.height=e.height,n.onload=this.onTileLoad.bind(this,n,t),n.onerror=this.onTileError.bind(this,n,t),this.loadTileImage(n,t.url,t.id),n},t.renderer.deleteTile=function(t){if(!t||!t.image)return;t.image.onload=null,t.image.onerror=null;!function(t){const e=fn(un,t);e&&e(t)}((t.info||{}).id)},t.renderer.loadTileImage=(t,e,n)=>{t._key=n,function(t,e,n,i,r){const o={key:t,url:e,callback:n,img:i,vt:r};dn.length<10?(dn.push(o),r.loopMessage(o)):un.push(o)}(n,e,((t,e,n)=>{this._generateBaseObjects(t,e,n),function(t,e){if(fn(dn,t),un.length){dn.push(un[0]),un.splice(0,1);const t=dn[dn.length-1];e.loopMessage(t)}}(t,this)}),t,this)}}))}_getMaterial(e,n,i,r){return this.getMaterial&&t.Util.isFunction(this.getMaterial)?this.getMaterial(e,n,i,r):null}}function wn(t,n,r,o){const{position:s,uv:a,normal:h,indexs:c}=function(t,e,n,i){const r=t/n,o=e/i,s=-t/2,a=e/2,h=-e/2,c=(n+1)*(i+1),l=new Float32Array(3*c),u=new Float32Array(2*c),d=new Float32Array(3*c),p=new Uint32Array(10*c);let f=0,g=0,y=0;for(let c=0;c<=i;c++)for(let x=0;x<=n;x++){const m=s+r*x,v=a-o*c;l[f]=m,l[f+1]=v,l[f+2]=0,d[f]=0,d[f+1]=0,d[f+2]=1;const b=(m-s)/t,_=(v-h)/e;if(u[g]=b,u[g+1]=_,f+=3,g+=2,x<n&&c<i){const t=c*(n+1)+x,e=t+1,i=(n+1)*(c+1)+x,r=i+1;p[y]=t,p[y+1]=i,p[y+2]=e,p[y+3]=i,p[y+4]=r,p[y+5]=e,y+=6}}const x=new Uint32Array(y);for(let t=0,e=x.length;t<e;t++)x[t]=p[t];return{position:l,uv:u,normal:d,indexs:x}}(t,n,r,o),l=new e.BufferGeometry;return i(l,"position",new e.BufferAttribute(s,3)),i(l,"normal",new e.BufferAttribute(h,3)),i(l,"uv",new e.BufferAttribute(a,2)),l.setIndex(new e.BufferAttribute(c,1)),l}const Mn=new e.TextureLoader,An=document.createElement("canvas"),On=256;function jn(t){if(!t)return null;let e;return"string"==typeof t?(e=new Image,e.src=t):t instanceof HTMLCanvasElement?(e=new Image,e.src=t.toDataURL()):t instanceof Image&&(e=new Image,e.src=t.src,e.crossOrigin=t.crossOrigin),e&&!e.crossOrigin&&(e.crossOrigin="Anonymous"),e}const Tn=new Map;function Cn(t,n,i,r){if(!n||!i)return;const{imageWidth:o,imageHeight:s}=r;let a;if(a=t instanceof Uint32Array||t instanceof Uint8ClampedArray?t:function(t,e=On,n=On){An.width=e,An.height=n;const i=An.getContext("2d");return i.drawImage(t,0,0,e,n),i.getImageData(0,0,e,n).data}(t,o,s),!a)return void console.error("image is error type data",t);let h=0,c=0,l=0;const u=new e.Vector3,d=Tn;for(let t=0,e=a.length;t<e;t+=4){const e=.1*(256*a[t]*256+256*a[t+1]+a[t+2])-1e4;let r=0;if(0!==c&&c+1!==s&&0!==l&&l+1!==o){const t=d.get(e);void 0!==t?r=t:(r=i.altitudeToVector3(e,e,null,u).x,d.set(e,r))}n.attributes.position.array[3*h+2]=r,h++,l++,l===o&&(c++,l=0)}n.attributes.position.needsUpdate=!0}const Sn={interactive:!1,altitude:0,image:null,imageWidth:256,imageHeight:256,texture:null};class Ln extends f{constructor(e,n,i,r){n=t.Util.extend({},Sn,n,{layer:r,extent:e});const{texture:o,image:s,altitude:a,imageHeight:h,imageWidth:c}=n;e instanceof t.Extent||(e=new t.Extent(e));const{xmin:l,ymin:u,xmax:d,ymax:p}=e;let f=1/0,g=1/0,y=-1/0,x=-1/0;[[l,u],[l,p],[d,p],[d,u]].forEach((t=>{const e=r.coordinateToVector3(t),{x:n,y:i}=e;f=Math.min(n,f),g=Math.min(i,g),y=Math.max(n,y),x=Math.max(i,x)}));const m=(y-f)/c,v=(x-g)/h;f-=m,y+=m,g-=v,x+=v;const b=Math.abs(y-f),_=Math.abs(x-g),w=jn(s),M=jn(o),A=wn(b,_,c-1,h-1);super(),this._initOptions(n),this._createMesh(A,i);const O=r.altitudeToVector3(a,a).x,j=r.coordinateToVector3(e.getCenter(),O);this.getObject3d().position.copy(j),i.transparent=!0,w&&(w.onload=()=>{Cn(w,A,r,{imageWidth:c,imageHeight:h})},w.onerror=function(){console.error(`not load ${w.src}`)}),M?(i.opacity=0,Mn.load(M.src,(t=>{i.map=t,i.opacity=1,i.needsUpdate=!0}))):i.opacity=1,this.type="Terrain"}updateData(t){return Cn(t,this.getObject3d().geometry,this.getLayer(),this.getOptions()),this}}const kn={scale:1,tileDivisor:4};class In extends vn{constructor(e,n={},i,r){super(t.Util.GUID(),t.Util.extend({urlTemplate:e},kn,n)),this._opts=n,this._layer=r,this.material=i,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._imgQueue={},this._layerLaodTime=(new Date).getTime(),this._init()}isAsynchronous(){return!1}formatBaseObjects(t,e){const n=this.options,i=[],{scale:r,tileDivisor:o}=n,{x:s,y:a,z:h}=this._getXYZOfIndex(t),c=this.getMap().getZoom(),l=this.getTileUrl(s,a,h),[u,d]=this.options.tileSize,p=this._getTileLngLatExtent(s,a,h),f=this.material.clone();if(h+1>=Math.round(c)){const t=new Ln(p,{image:e,imageWidth:u/o,imageHeight:d/o,texture:l},f,this._layer);t.getObject3d().scale.set(r,r,1),i.push(t)}return i}loopMessage(t){this.getTileData(t)}_init(){this.on("layerload",this._layerOnLoad),this.on("add",(()=>{if(!1===this._add){const t=this.getBaseObjects();this._layer.addMesh(t)}this._add=!0,this.intervalId=setInterval((()=>{this._isLoad()&&!this._layer.getMap().isInteracting()&&this.fire("layerload")}),1e3)})),this.on("remove",(()=>{this._add=!1;const t=this.getBaseObjects();this._layer.removeMesh(t),clearInterval(this.intervalId)})),this.on("show",(()=>{this.getBaseObjects().forEach((t=>{t.show()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.show()}))}})),this.on("hide",(()=>{this.getBaseObjects().forEach((t=>{t.hide()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.hide()}))}})),this.on("renderercreate",(t=>{t.renderer.loadTile=function(t){var e=this.layer.getTileSize(),n=new Image;return n.width=e.width,n.height=e.height,n.onload=this.onTileLoad.bind(this,n,t),n.onerror=this.onTileError.bind(this,n,t),this.loadTileImage(n,t.url,t.id),n},t.renderer.deleteTile=t=>{if(!t||!t.image)return;t.image.onload=null,t.image.onerror=null;const e=t.info||{},n=this._imgQueue[e.id];n&&(n.src="",n.onload=null,n.onerror=null,delete this._imgQueue[e.id])},t.renderer.loadTileImage=(t,e,n)=>{t._key=n;const i=new Image;this._imgQueue[n]=i;const r={key:n,url:e,rgbImage:i,callback:(t,e,n)=>{this._generateBaseObjects(t,e,n)},img:t,vt:this};this.loopMessage(r)}}))}}
|
|
20
5
|
/*!
|
|
21
6
|
* Code from baidu mapv
|
|
22
7
|
* License: BSD-3
|
|
23
8
|
* https://github.com/huiyan-fe/mapv
|
|
24
9
|
*
|
|
25
|
-
*/function
|
|
10
|
+
*/function Pn(t){t=t||{},this.gradient=t.gradient||{.25:"rgba(0, 0, 255, 1)",.55:"rgba(0, 255, 0, 1)",.85:"rgba(255, 255, 0, 1)",1:"rgba(255, 0, 0, 1)"},this.maxSize=t.maxSize||35,this.minSize=t.minSize||0,this.max=t.max||100,this.min=t.min||0,this.initPalette()}function Bn(t,e,n){var i=En(n),r=function(t){var e=t.min||0;return e}(n),o=i-r,s=n.range||null,a=0,h=1024;s&&2===s.length&&(a=(s[0]-r)/o*1024),s&&2===s.length&&(h=(s[1]-r)/o*1024);for(var c,l=n.maxOpacity||.8,u=n.minOpacity||0,d=3,p=t.length;d<p;d+=4)c=4*t[d],t[d]/256>l&&(t[d]=256*l),t[d]/256<u&&(t[d]=256*u),c&&c>=a&&c<=h?(t[d-3]=e[c],t[d-2]=e[c+1],t[d-1]=e[c+2]):t[d]=0}function En(t){return t.max||100}function Un(t,e,n){var i=En(n),r=
|
|
26
11
|
/*!
|
|
27
12
|
* Code from baidu mapv
|
|
28
13
|
* License: BSD-3
|
|
29
14
|
* https://github.com/huiyan-fe/mapv
|
|
30
15
|
*
|
|
31
16
|
*/
|
|
32
|
-
function(t){var e=t/2,i=t+e,n=1e4,r=NC(2*i,2*i),o=r.getContext("2d");return o.shadowBlur=e,o.shadowColor="black",o.shadowOffsetX=o.shadowOffsetY=n,o.beginPath(),o.arc(i-n,i-n,t,0,2*Math.PI,!0),o.closePath(),o.fill(),r}(i._size||i.size||13),o=r.width/2,s=r.height/2,a=e,h={};for(var l in a.forEach((function(t){var e=void 0===t.count?1:t.count,i=Math.min(1,e/n).toFixed(2);h[i]=h[i]||[],h[i].push(t)})),h)if(!isNaN(l)){var c=h[l];t.beginPath(),i.withoutAlpha||(t.globalAlpha=l),c.forEach((function(e){var i=e.coordinate,a=void 0===e.count?1:e.count;t.globalAlpha=a/n,t.drawImage(r,i[0]-o,i[1]-s)}))}}tP.prototype.setMax=function(t){this.max=t||100},tP.prototype.setMin=function(t){this.min=t||0},tP.prototype.setMaxSize=function(t){this.maxSize=t||35},tP.prototype.setMinSize=function(t){this.minSize=t||0},tP.prototype.initPalette=function(){var t=this.gradient,e=NC(256,1),i=this.paletteCtx=e.getContext("2d"),n=i.createLinearGradient(0,0,256,1);for(var r in t)n.addColorStop(parseFloat(r),t[r]);i.fillStyle=n,i.fillRect(0,0,256,1)},tP.prototype.getColor=function(t){var e=this.getImageData(t);return"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]/256+")"},tP.prototype.getImageData=function(t){var e=this.paletteCtx.getImageData(0,0,256,1).data;if(void 0===t)return e;var i=this.max,n=this.min;t>i&&(t=i),t<n&&(t=n);var r=4*Math.floor((t-n)/(i-n)*255);return[e[r],e[r+1],e[r+2],e[r+3]]},tP.prototype.getSize=function(t){var e=this.max,i=this.min,n=this.maxSize,r=this.minSize;return t>e&&(t=e),t<i&&(t=i),e>i?r+(t-i)/(e-i)*(n-r):n},tP.prototype.getLegend=function(t){var e=this.gradient,i=t.width||20,n=t.height||180,r=NC(i,n),o=r.getContext("2d"),s=o.createLinearGradient(0,n,0,0);for(var a in e)s.addColorStop(parseFloat(a),e[a]);return o.fillStyle=s,o.fillRect(0,0,i,n),r};var rP={draw:function(t,e,i){if(!(t.canvas.width<=0||t.canvas.height<=0)){var n=i.strength||.3;t.strokeStyle="rgba(0,0,0,"+n+")";var r=NC(t.canvas.width,t.canvas.height),o=r.getContext("2d");o.scale(devicePixelRatio,devicePixelRatio),i=i||{},t.save();var s=new tP({gradient:i.gradient});if(nP(o,e,i),!i.absolute){var a=o.getImageData(0,0,t.canvas.width,t.canvas.height);eP(a.data,s.getImageData(),i),t.putImageData(a,0,0),t.restore()}s=null,r=null}},drawGray:nP,colorize:eP};const oP={altitude:0,interactive:!1,min:0,max:100,size:13,gradient:{.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},gridScale:.5},sP=2048;class aP extends zS{constructor(t,e,i,n){Array.isArray(t)||(t=[t]);let r=1/0,o=1/0,s=-1/0,a=-1/0;const h=[];for(let e=0,i=t.length;e<i;e++){const{coordinate:i,lnglat:l,xy:c}=t[e],u=i||l||c;if(!u){console.warn("not find coordinate");continue}const d=n.coordinateToVector3(u);h.push(d);const{x:p,y:f}=d;r=Math.min(r,p),o=Math.min(o,f),s=Math.max(s,p),a=Math.max(a,f)}e=Ii.extend({},oP,e,{layer:n,points:t});let{gridScale:l,altitude:c}=e;const u=Math.abs(s-r),d=Math.abs(a-o),p=Math.max(u*l,d*l);if(p>sP){console.warn(`gridScale: ${l} it's too big. I hope it's a smaller value,canvas max size is 2048* 2048`);l=sP/(p/l)}const f=Math.ceil(u*l),m=Math.ceil(d*l),g=f/u,v=m/d,y=[];for(let e=0,i=h.length;e<i;e++){const i=h[e];i.x-=r,i.y-=o,i.x*=g,i.y*=v,i.y=m-i.y,y.push({coordinate:[i.x,i.y],count:t[e].count})}let _=NC(f,m),x=_.getContext("2d");rP.drawGray(x,y,e);const w=x.getImageData(0,0,x.canvas.width,x.canvas.height);let b=-1/0;const M=new Float32Array(w.data.length/4),S=new Float32Array(w.data.length/4);for(let t=3,e=w.data.length,i=0;t<e;t+=4){const e=w.data[t];b=Math.max(b,e),S[i]=e,e<=0&&(M[i]=1),i++}const T=new tP({gradient:e.gradient});rP.colorize(w.data,T.getImageData(),e),_=null,x=null;const E=UC(u,d,f-1,m-1),C=E.getIndex().array,P=E.attributes.position.array,A=new Float32Array(P.length),L=new Uint32Array(6*P.length),R=new fm;let O=0;for(let t=0,e=P.length,i=0,n=C.length,r=0,o=w.data.length,s=0;t<Math.max(e,n,o);t+=3){if(t<e){const e=S[s];e>0&&(P[t+2]=e/b)}if(i<n){const t=C[i],e=C[i+1],n=C[i+2];M[t]&&M[e]&&M[n]||(L[O]=t,L[O+1]=e,L[O+2]=n,O+=3)}if(r<o){const t=`rgb(${w.data[r]},${w.data[r+1]},${w.data[r+2]})`;R.setStyle(t),A[i]=R.r,A[i+1]=R.g,A[i+2]=R.b}i+=3,r+=4,s++}const D=new Uint32Array(O);for(let t=0;t<O;t++)D[t]=L[t];E.setIndex(new ym(D,1)),TS(E,"color",new ym(A,3,!0)),i.vertexColors=ES(),super(),this._initOptions(e),this._createMesh(E,i);const I=n.altitudeToVector3(c,c).x;this.getObject3d().position.copy(new jp((r+s)/2,(o+a)/2,I)),this.type="HeatMap"}}const hP=new fm;let lP=1;class cP{constructor(t){this.object3ds=[],this.layer=t,this.camera=t.getCamera(),this.renderer=t.getThreeRenderer(),this.pickingTexture=new Bp(1,1),this.pickingScene=new jy}getColor(){return hP.setHex(lP),lP++,hP}add(t){if(t){const e=t._colorIndex;e&&(this.object3ds[e]=t,this.pickingScene.add(t))}return this}remove(t){if(t){const e=t._colorIndex;e&&(this.object3ds[e]=null,this.pickingScene.remove(t))}return this}isEmpty(){if(0===this.pickingScene.children.length)return!0;for(let t=0,e=this.pickingScene.children.length;t<e;t++){const e=this.pickingScene.children[t];if(e){const t=e.__parent;if(t&&!0===t.getOptions().interactive)return!1}}return!0}pick(t){if(!t)return;if(this.isEmpty())return;const{camera:e,renderer:i,pickingTexture:n,pickingScene:r,object3ds:o,layer:s}=this,a=this.pickingScene.children.length;for(let t=0;t<a;t++){const e=this.pickingScene.children[t];e&&e.__parent&&(e.__parent.picked=!1)}const{width:h,height:l}=s._getRenderer().canvas,c=n.width,u=n.height;h===c&&l===u||n.setSize(h,l),i.setRenderTarget(n),i.clear(),e&&e.layers&&this.camera.layers.set(0),i.render(r,e);const d=new Uint8Array(4),{x:p,y:f}=t;let m=window.devicePixelRatio;const g=s.getMap();g&&(m=g.getDevicePixelRatio?g.getDevicePixelRatio():g.options.devicePixelRatio);const v=p*m,y=n.height-f*m;i.readRenderTargetPixels(n,Math.round(v),Math.round(y),1,1,d);const _=d[0]<<16|d[1]<<8|d[2],x=o[_];if(x)x.__parent&&(o[_].__parent.picked=!0);else for(let t=0;t<a;t++){const e=this.pickingScene.children[t];if(e&&e.__parent){const t=e.__parent;if(t._colorMap&&null!=t._colorMap[_]){t.picked=!0,t.index=t._colorMap[_];break}}}i.setRenderTarget(null)}}const uP={bottomHeight:0,altitude:0};class dP extends zS{constructor(t,e,i,n){e=Ii.extend({},uP,e,{layer:n,lineString:t}),super(),this._initOptions(e);const{asynchronous:r}=e,{lineStrings:o,center:s}=iE(t),a=new OS;let h;if(r){const e=Ii.GUID();this.getOptions().id=e,this.getOptions().center=s,TE.push({id:e,data:o,lineString:t,center:s,layer:n,baseObject:this})}else{const t=[],i={};for(let r=0,a=o.length;r<a;r++){const a=KT(o[r],n,s,!1).positions;jT(a,e.bottomHeight,n,i),t.push(nE(a))}h=rE(t),a.setPositions(h)}this._setMaterialRes(n,i),this._createLine2(a,i);const{altitude:l}=e,c=n.altitudeToVector3(l,l).x,u=n.coordinateToVector3(s,c);this.getObject3d().position.copy(u),r||(this._setPickObject3d(h,i.linewidth),this._init()),this.type="FatLine"}_init(){const t=this.getLayer().getPick();this.on("add",(()=>{t.add(this.pickObject3d)})),this.on("remove",(()=>{t.remove(this.pickObject3d)}))}_setMaterialRes(t,e){const i=t.getMap().getSize(),n=i.width,r=i.height;e.resolution.set(n,r)}_setPickObject3d(t,e){const i=new OS;i.setPositions(t);const n=this.getLayer().getPick().getColor(),r=[];for(let e=0,i=t.length/3;e<i;e++)r.push(n.r,n.g,n.b);i.setColors(r);const o=new LS({color:"#fff",linewidth:e,vertexColors:ES()});this._setMaterialRes(this.getLayer(),o);const s=n.getHex(),a=new DS(i,o);a.position.copy(this.getObject3d().position),a._colorIndex=s,this.setPickObject3d(a)}identify(t){return this.picked}setSymbol(t){if(t&&t instanceof am){t.needsUpdate=!0;const e=this.getMap().getSize(),i=e.width,n=e.height;t.resolution.set(i,n),this.getObject3d().material=t}return this}_workerLoad(t){const e=new Float32Array(t.position),i=this.getObject3d();if(i.geometry.setPositions(e),i.computeLineDistances(),this._setPickObject3d(e,i.material.linewidth),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const pP={altitude:0,colors:null};class fP extends(dC(zS)){constructor(t,e,i,n){Array.isArray(t)||(t=[t]);const r=[],o=[],s=t.length;for(let e=0;e<s;e++){const i=iE(t[e]);r.push(i.center),o.push(i.lineStrings)}const a=HT(r);e=Ii.extend({},pP,e,{layer:n,lineStrings:t,coordinate:a}),super(),this._initOptions(e);const{asynchronous:h}=e,l=new OS,c=[],u={};let d,p,f=[],m=0,g=[];if(h)EE.push({id:Ii.GUID(),data:o,key:e.key,center:a,layer:n,baseObject:this,lineStrings:t});else{for(let t=0;t<s;t++){const e=o[t];let i=0;for(let t=0,r=e.length;t<r;t++){const r=jS(e[t])?e[t].properties:e[t].getProperties()||{},{positions:o}=KT(e[t],n,a,!1);jT(o,r.bottomHeight,n,u),i+=o.length/3*2-2,g.push(nE(o))}f[t]={position:{count:i,start:m,end:m+3*i},instanceStart:{count:i,start:m,end:m+3*i},instanceEnd:{count:i,start:m,end:m+3*i},hide:!1},m+=3*i}d=rE(g),l.setPositions(d)}this._setMaterialRes(n,i),this._createLine2(l,i);const{altitude:v}=e,y=n.altitudeToVector3(v,v).x,_=n.coordinateToVector3(a,y);this.getObject3d().position.copy(_),this._baseObjects=c,this._datas=t,this._geometriesAttributes=f,this.faceIndex=null,this.index=null,this._geometryCache=new OS,h||(p=new Float32Array(d),this._geometryCache.setPositions(p)),this._colorMap={},this.isHide=!1,this._initBaseObjectsEvent(c),h||(this._setPickObject3d(p,i.linewidth),this._init()),this.type="FatLines"}_setMaterialRes(t,e){const i=t.getMap().getSize(),n=i.width,r=i.height;e.resolution.set(n,r)}_setPickObject3d(t,e){if(!this._colorMap)return;const i=this._geometryCache||new OS;i.setPositions(t);const n=this.getLayer().getPick(),{_geometriesAttributes:r}=this,o=GT(r);let s=0;for(let t=0,e=r.length;t<e;t++){const e=n.getColor(),i=e.getHex();this._colorMap[i]=t;const{count:a}=r[t].position;this._datas[t].colorIndex=i;for(let t=0;t<a;t++)o[s]=e.r,o[s+1]=e.g,o[s+2]=e.b,s+=3}i.setColors(o);const a=new LS({color:"#fff",linewidth:e,vertexColors:ES()});this._setMaterialRes(this.getLayer(),a);const h=n.getColor().getHex(),l=new DS(i,a);l.position.copy(this.getObject3d().position),l._colorIndex=h,this.setPickObject3d(l)}identify(t){return this.picked}setSymbol(t){if(t&&t instanceof am){t.needsUpdate=!0;const e=this.getMap().getSize(),i=e.width,n=e.height;t.resolution.set(i,n),this.getObject3d().material=t}return this}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],i=Ii.extend({},this.getOptions(),{index:t},jS(e)?e.properties:e.getProperties());this._baseObjects[t]=new dP(e,i,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_updateAttribute(t,e){const{indexs:i}=this._getHideGeometryIndex(e),n=this._geometryCache.attributes[e].array,r=n.length;for(let e=0;e<r;e++)t.array[e]=n[e];for(let n=0;n<i.length;n++){const r=i[n],{start:o,end:s}=this._geometriesAttributes[r][e];for(let e=o;e<s;e++)t.array[e]=-1e5}return this}_showGeometry(t,e){let i;if(t&&(i=t.getOptions().index),null!=i){const t=this._geometriesAttributes[i],{hide:n}=t;if(n===e)return this;t.hide=e;const r=this.getObject3d().geometry;this._updateAttribute(r.attributes.instanceStart,"instanceStart"),this._updateAttribute(r.attributes.instanceEnd,"instanceEnd"),r.attributes.instanceStart.data.needsUpdate=!0,r.attributes.instanceEnd.data.needsUpdate=!0,this.isHide=e}return this}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const i=this.getObject3d(),n=new Float32Array(t.position),r=new Float32Array(n);if(i.geometry.setPositions(new Float32Array(n)),this._geometryCache.setPositions(r),this._setPickObject3d(r,i.material.linewidth),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const mP={radius:10,height:100,altitude:0,topColor:"",bottomColor:"#2d2f61",heightEnable:!0};class gP extends zS{constructor(t,e,i,n){e=Ii.extend({},mP,e,{layer:n,coordinate:t}),super(),this._initOptions(e);const{height:r,radius:o,topColor:s,bottomColor:a,altitude:h}=e,l=n.altitudeToVector3(r,r).x,c=n.distanceToVector3(o,o).x,u=VE().clone();u.scale(2*c,2*c,l),s&&(GE(u,a,s,"z",l/2),i.vertexColors=ES()),this._createMesh(u,i);const d=n.altitudeToVector3(h,h).x,p=n.coordinateToVector3(t,d);this.getObject3d().position.copy(p),this.type="Box"}}const vP={radius:10,height:100,altitude:0,topColor:null,bottomColor:"#2d2f61"};class yP extends(dC(zS)){constructor(t,e,i,n){Array.isArray(t)||(t=[t]);const r=t.length,o=HT(t),s=n.coordinateToVector3(o),a=[],h=[],l=[];let c=0;const u={},d={};for(let e=0;e<r;e++){const r=Ii.extend({index:e},vP,t[e]),{radius:o,altitude:p,topColor:f,bottomColor:m,height:g,coordinate:v}=r,y=BT(o,n,u),_=NT(g,n,d),x=NT(p,n,d),w=VE().clone();w.scale(2*y,2*y,_),f&&(GE(w,m,f,"z",_/2),i.vertexColors=ES());const b=n.coordinateToVector3(v).sub(s),M=w.attributes.position.array;for(let t=0,e=M.length;t<e;t+=3)M[t+2]+=x,M[t]+=b.x,M[t+1]+=b.y,M[t+2]+=b.z;a.push(w);const S=new gP(v,r,i,n);h.push(S),w.index.count;const T=w.attributes.position.count;w.attributes.normal.count,w.attributes.uv.count,l[e]={position:{count:T,start:c,end:c+3*T},hide:!1},c+=3*T}super(),e=Ii.extend({},{altitude:0,layer:n,points:t},e),this._initOptions(e);const p=UE(a);this._createMesh(p,i);const f=e.altitude,m=n.altitudeToVector3(f,f).x,g=s.clone();g.z=m,this.getObject3d().position.copy(g),this._baseObjects=h,this._datas=t,this._geometriesAttributes=l,this.faceIndex=null,this._geometryCache=IE(p),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(h),this._setPickObject3d(),this._init(),this.type="Boxs"}identify(t){return this.picked}}var _P={exports:{}};function xP(t,e,i){i=i||2;var n,r,o,s,a,h,l,c=e&&e.length,u=c?e[0]*i:t.length,d=wP(t,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=function(t,e,i,n){var r,o,s,a=[];for(r=0,o=e.length;r<o;r++)(s=wP(t,e[r]*n,r<o-1?e[r+1]*n:t.length,n,!1))===s.next&&(s.steiner=!0),a.push(OP(s));for(a.sort(PP),r=0;r<a.length;r++)i=AP(a[r],i);return i}(t,e,d,i)),t.length>80*i){n=o=t[0],r=s=t[1];for(var f=i;f<u;f+=i)(a=t[f])<n&&(n=a),(h=t[f+1])<r&&(r=h),a>o&&(o=a),h>s&&(s=h);l=0!==(l=Math.max(o-n,s-r))?32767/l:0}return MP(d,p,i,n,r,l,0),p}function wP(t,e,i,n,r){var o,s;if(r===WP(t,e,i,n)>0)for(o=e;o<i;o+=n)s=GP(o,t[o],t[o+1],s);else for(o=i-n;o>=e;o-=n)s=GP(o,t[o],t[o+1],s);return s&&zP(s,s.next)&&(UP(s),s=s.next),s}function bP(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!zP(n,n.next)&&0!==kP(n.prev,n,n.next))n=n.next;else{if(UP(n),(n=e=n.prev)===n.next)break;i=!0}}while(i||n!==e);return e}function MP(t,e,i,n,r,o,s){if(t){!s&&o&&function(t,e,i,n){var r=t;do{0===r.z&&(r.z=RP(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,i,n,r,o,s,a,h,l=1;do{for(i=t,t=null,o=null,s=0;i;){for(s++,n=i,a=0,e=0;e<l&&(a++,n=n.nextZ);e++);for(h=l;a>0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;i=n}o.nextZ=null,l*=2}while(s>1)}(r)}(t,n,r,o);for(var a,h,l=t;t.prev!==t.next;)if(a=t.prev,h=t.next,o?TP(t,n,r,o):SP(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(h.i/i|0),UP(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?MP(t=EP(bP(t),e,i),e,i,n,r,o,2):2===s&&CP(t,e,i,n,r,o):MP(bP(t),e,i,n,r,o,1);break}}}function SP(t){var e=t.prev,i=t,n=t.next;if(kP(e,i,n)>=0)return!1;for(var r=e.x,o=i.x,s=n.x,a=e.y,h=i.y,l=n.y,c=r<o?r<s?r:s:o<s?o:s,u=a<h?a<l?a:l:h<l?h:l,d=r>o?r>s?r:s:o>s?o:s,p=a>h?a>l?a:l:h>l?h:l,f=n.next;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&DP(r,a,o,h,s,l,f.x,f.y)&&kP(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function TP(t,e,i,n){var r=t.prev,o=t,s=t.next;if(kP(r,o,s)>=0)return!1;for(var a=r.x,h=o.x,l=s.x,c=r.y,u=o.y,d=s.y,p=a<h?a<l?a:l:h<l?h:l,f=c<u?c<d?c:d:u<d?u:d,m=a>h?a>l?a:l:h>l?h:l,g=c>u?c>d?c:d:u>d?u:d,v=RP(p,f,e,i,n),y=RP(m,g,e,i,n),_=t.prevZ,x=t.nextZ;_&&_.z>=v&&x&&x.z<=y;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&DP(a,c,h,u,l,d,_.x,_.y)&&kP(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&DP(a,c,h,u,l,d,x.x,x.y)&&kP(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;_&&_.z>=v;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&DP(a,c,h,u,l,d,_.x,_.y)&&kP(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&DP(a,c,h,u,l,d,x.x,x.y)&&kP(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function EP(t,e,i){var n=t;do{var r=n.prev,o=n.next.next;!zP(r,o)&&FP(r,n,n.next,o)&&HP(r,o)&&HP(o,r)&&(e.push(r.i/i|0),e.push(n.i/i|0),e.push(o.i/i|0),UP(n),UP(n.next),n=t=o),n=n.next}while(n!==t);return bP(n)}function CP(t,e,i,n,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&IP(s,a)){var h=jP(s,a);return s=bP(s,s.next),h=bP(h,h.next),MP(s,e,i,n,r,o,0),void MP(h,e,i,n,r,o,0)}a=a.next}s=s.next}while(s!==t)}function PP(t,e){return t.x-e.x}function AP(t,e){var i=function(t,e){var i,n=e,r=t.x,o=t.y,s=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var a=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>s&&(s=a,i=n.x<n.next.x?n:n.next,a===r))return i}n=n.next}while(n!==e);if(!i)return null;var h,l=i,c=i.x,u=i.y,d=1/0;n=i;do{r>=n.x&&n.x>=c&&r!==n.x&&DP(o<u?r:s,o,c,u,o<u?s:r,o,n.x,n.y)&&(h=Math.abs(o-n.y)/(r-n.x),HP(n,t)&&(h<d||h===d&&(n.x>i.x||n.x===i.x&&LP(i,n)))&&(i=n,d=h)),n=n.next}while(n!==l);return i}(t,e);if(!i)return e;var n=jP(i,t);return bP(n,n.next),bP(i,i.next)}function LP(t,e){return kP(t.prev,t,e.prev)<0&&kP(e.next,t,t.next)<0}function RP(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function OP(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function DP(t,e,i,n,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function IP(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&FP(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(HP(t,e)&&HP(e,t)&&function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(kP(t.prev,t,e.prev)||kP(t,e.prev,e))||zP(t,e)&&kP(t.prev,t,t.next)>0&&kP(e.prev,e,e.next)>0)}function kP(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function zP(t,e){return t.x===e.x&&t.y===e.y}function FP(t,e,i,n){var r=NP(kP(t,e,i)),o=NP(kP(t,e,n)),s=NP(kP(i,n,t)),a=NP(kP(i,n,e));return r!==o&&s!==a||(!(0!==r||!BP(t,i,e))||(!(0!==o||!BP(t,n,e))||(!(0!==s||!BP(i,t,n))||!(0!==a||!BP(i,e,n)))))}function BP(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function NP(t){return t>0?1:t<0?-1:0}function HP(t,e){return kP(t.prev,t,t.next)<0?kP(t,e,t.next)>=0&&kP(t,t.prev,e)>=0:kP(t,e,t.prev)<0||kP(t,t.next,e)<0}function jP(t,e){var i=new VP(t.i,t.x,t.y),n=new VP(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function GP(t,e,i,n){var r=new VP(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function UP(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function VP(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function WP(t,e,i,n){for(var r=0,o=e,s=i-n;o<i;o+=n)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}_P.exports=xP,_P.exports.default=xP,xP.deviation=function(t,e,i,n){var r=e&&e.length,o=r?e[0]*i:t.length,s=Math.abs(WP(t,0,o,i));if(r)for(var a=0,h=e.length;a<h;a++){var l=e[a]*i,c=a<h-1?e[a+1]*i:t.length;s-=Math.abs(WP(t,l,c,i))}var u=0;for(a=0;a<n.length;a+=3){var d=n[a]*i,p=n[a+1]*i,f=n[a+2]*i;u+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},xP.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},n=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)i.vertices.push(t[r][o][s]);r>0&&(n+=t[r-1].length,i.holes.push(n))}return i};const ZP=Math.PI/180,qP=[[4e3,220],[2e3,100],[1e3,30],[500,15],[100,5],[50,2],[10,1],[5,.7],[2,.1],[1,.05],[.5,.02],[.4,.01],[.1,.005],[.05,.002],[.01,.001]],XP=["mouseout","mousemove","click","mousedown","mouseup","dblclick","contextmenu","touchstart","touchmove","touchend"],YP=new Hn(0,0),JP=new Bt(0,0),QP="__webglFramebuffer";class KP extends Fl{constructor(t,e){super(t,e),this._animationBaseObjectMap={},this._needsUpdate=!0,this._mousemoveTimeOut=0,this._mousedownTime=0,this._baseObjects=[],this._delayMeshes=[],this.type="ThreeLayer"}isMercator(){const t=this.getMap();if(!t)return!1;const e=t.getSpatialReference(),i=e._projection,n=e._resolutions;return!!(i&&"EPSG:3857"===i.code&&n&&n.length&&156543===Math.floor(n[0])&&t.getGLRes)}isRendering(){const t=this.getMap();return!!t&&(t.isInteracting()||t.isAnimating())}prepareToDraw(...t){}draw(t,e,i,n,r,o){this.renderScene(o,this)}drawOnInteracting(t,e,i,n,r,o,s){this.renderScene(s,this)}coordinateToVector3(t,e=0,i){const n=this.getMap();if(!n)return null;const r=Array.isArray(t);r?(YP.x=t[0],YP.y=t[1]):t instanceof Hn||(t=new Hn(t));const o=iA(n),s=nA(n,r?YP:t,o,JP);return i&&(i.x=s.x,i.y=s.y,i.z=e),new jp(s.x,s.y,e)}coordinatiesToGLFloatArray(t,e){const i=this.getMap();if(!i)return null;const n=iA(i),r=t.length,o=new Float32Array(2*r),s=new Float32Array(3*r);for(let a=0;a<r;a++){let r=t[a];const h=Array.isArray(r);h?(YP.x=r[0],YP.y=r[1]):r instanceof Hn||(r=new Hn(r));const l=nA(i,h?YP:r,n,JP);l.x-=e.x,l.y-=e.y;const c=2*a;o[c]=l.x,o[c+1]=l.y;const u=3*a;s[u]=l.x,s[u+1]=l.y,s[u+2]=0}return{positions:s,positons2d:o}}coordinatiesToGLArray(t,e){const i=this.getMap();if(!i)return null;const n=iA(i),r=t.length,o=new Array(r);for(let s=0;s<r;s++){let r=t[s];const a=Array.isArray(r);a?(YP.x=r[0],YP.y=r[1]):r instanceof Hn||(r=new Hn(r));const h=nA(i,a?YP:r,n,JP);h.x-=e.x,h.y-=e.y,o[s]=[h.x,h.y]}return o}distanceToVector3(t,e,i){if(0===t&&0===e||!Ii.isNumber(t)||!Ii.isNumber(e))return new jp(0,0,0);const n=this.getMap(),r=iA(n);let o=i||n.getCenter();o instanceof Hn||(o=new Hn(o));const s=n.locate(o,t,e),a=nA(n,o,r),h=nA(n,s,r),l=Math.abs(h.x-a.x)*Ii.sign(t),c=Math.abs(h.y-a.y)*Ii.sign(e);return new jp(l,c,0)}altitudeToVector3(t,e,i,n){if(0===t||!Ii.isNumber(t))return new jp(0,0,0);const r=this.getMap();if(r.altitudeToPoint){const e=iA(r);let i=r.altitudeToPoint(t,e);return t<0&&i>0&&(i=-i),n?(n.x=i,n.y=i,n.z=0,n):new jp(i,i,0)}return this.distanceToVector3(t,t,i)}toShape(t){if(!t)return null;if(t instanceof ta)return t.getGeometries().map((t=>this.toShape(t)));const e=t.getCenter(),i=this.coordinateToVector3(e),n=t.getShell().map((t=>{const e=this.coordinateToVector3(t).sub(i);return new Lp(e.x,e.y)})),r=new Kw(n),o=t.getHoles();return o&&o.length>0&&(r.holes=o.map((t=>{const e=t.map((t=>{const e=this.coordinateToVector3(t).sub(i);return new Lp(e.x,e.y)}));return new Kw(e)}))),r}toExtrudeMesh(t,e,i,n){if(!t)return null;if(t instanceof ta)return t.getGeometries().map((t=>this.toExtrudeMesh(t,e,i,n)));const r=t.getCoordinates();r.forEach((t=>{for(let e=t.length-1;e>=1;e--)t[e].equals(t[e-1])&&t.splice(e,1)})),t.setCoordinates(r);const o=this.toShape(t),s=this.coordinateToVector3(t.getCenter());n=Ii.isNumber(n)?n:e,n=this.altitudeToVector3(n,n).x;const a=this.altitudeToVector3(e,e).x,h={bevelEnabled:!1,bevelSize:1};h[parseInt(Dc)>=93?"depth":"amount"]=n;const l=new Rx(o,h);let c=l;Nm.prototype.fromGeometry&&(c=new Nm,c.fromGeometry(l));const u=new ng(c,i);return u.position.set(s.x,s.y,a-n),u}toExtrudePolygon(t,e,i){return new $E(t,e,i,this)}toBar(t,e,i){return new ZE(t,e,i,this)}toLine(t,e,i){return new YE(t,e,i,this)}toExtrudeLine(t,e,i){return new QE(t,e,i,this)}toModel(t,e){return new eC(t,e,this)}toExtrudeLineTrail(t,e,i){return new lC(t,e,i,this)}toExtrudePolygons(t,e,i){return new mC(t,e,i,this)}toPoint(t,e,i){return new _C(t,e,i,this)}toPoints(t,e,i){return new TC(t,e,i,this)}toBars(t,e,i){return new CC(t,e,i,this)}toExtrudeLines(t,e,i){return new AC(t,e,i,this)}toLines(t,e,i){return new RC(t,e,i,this)}toThreeVectorTileLayer(t,e,i){return new GC(t,e,i,this)}toTerrain(t,e,i){return new QC(t,e,i,this)}toTerrainVectorTileLayer(t,e,i){return new $C(t,e,i,this)}toHeatMap(t,e,i){return new aP(t,e,i,this)}toFatLine(t,e,i){return new dP(t,e,i,this)}toFatLines(t,e,i){return new fP(t,e,i,this)}toBox(t,e,i){return new gP(t,e,i,this)}toBoxs(t,e,i){return new yP(t,e,i,this)}getBaseObjects(){return this.getMeshes().filter((t=>t instanceof zS))}getMeshes(){const t=this.getScene();if(!t)return[];const e=[];for(let i=0,n=t.children.length;i<n;i++){const n=t.children[i];n instanceof Vf&&!(n instanceof dg)&&e.push(n.__parent||n)}return e}clear(){return this.clearMesh()}clearMesh(){const t=this.getScene();if(!t)return this;for(let e=t.children.length-1;e>=0;e--){const i=t.children[e];if(i instanceof Vf&&!(i instanceof dg)){t.remove(i);const e=i.__parent;e&&e instanceof zS&&(e.isAdd=!1,e.options.layer=null,e._fire("remove",{target:e}),delete this._animationBaseObjectMap[i.uuid],e._hideUI())}}return this}lookAt(t){const e=this._getRenderer();return e&&e.context.lookAt(t),this}getCamera(){const t=this._getRenderer();return t?t.camera:null}getScene(){const t=this._getRenderer();return t?t.scene:null}renderScene(t,e){const i=this._getRenderer();return i&&(i.clearCanvas(),i.renderScene(t),e||i.setToRedraw()),this}loop(t=!1){const e=this._delayMeshes;if(!e.length)return;const i=this.getMap();if(!i||i.isAnimating()||i.isInteracting())return;const n=this.options.loopRenderCount||50,r=e.slice(0,n);r&&this.addMesh(r,t),e.splice(0,n)}renderPickScene(){const t=this._getRenderer();if(t){const e=t.pick;e&&e.pick(this._containerPoint)}return this}getThreeRenderer(){const t=this._getRenderer();return t?t.context:null}getPick(){const t=this._getRenderer();return t?t.pick:null}delayAddMesh(t){if(!t)return this;Array.isArray(t)||(t=[t]);for(let e=0,i=t.length;e<i;e++)this._delayMeshes.push(t[e]);return this}addMesh(t,e=!0){if(!t)return this;Array.isArray(t)||(t=[t]);const i=this.getScene();if(t.forEach((t=>{t instanceof zS?(i.add(t.getObject3d()),t.isAdd||(t.isAdd=!0,t.options.layer=this,t._fire("add",{target:t})),t._animation&&Ii.isFunction(t._animation)&&(this._animationBaseObjectMap[t.getObject3d().uuid]=t)):t instanceof Vf&&i.add(t)})),this._zoomend(),e){const t=this._getRenderer();t&&t.setToRedraw()}return this}removeMesh(t,e=!0){if(!t)return this;Array.isArray(t)||(t=[t]);const i=this.getScene();if(t.forEach((t=>{if(t instanceof zS){i.remove(t.getObject3d()),t.isAdd&&(t.isAdd=!1,t.options.layer=null,t._fire("remove",{target:t}),t._hideUI()),t._animation&&Ii.isFunction(t._animation)&&delete this._animationBaseObjectMap[t.getObject3d().uuid];const e=this._delayMeshes;if(e.length)for(let i=0,n=e.length;i<n;i++)if(e[i]===t){e.splice(i,1);break}}else t instanceof Vf&&i.remove(t)})),e){const t=this._getRenderer();t&&t.setToRedraw()}return this}_initRaycaster(){return this._raycaster||(this._raycaster=new mM,this._mouse=new Lp),this}getRaycaster(){return this._raycaster}identify(t,e){if(!t)return console.error("coordinate is null,it should be Coordinate"),[];if(Array.isArray(t)&&(t=new Hn(t)),!(t instanceof Hn))return console.error("coordinate type is error,it should be Coordinate"),[];const i=this.getMap().coordToContainerPoint(t);this._containerPoint=i;const{x:n,y:r}=i;this._initRaycaster(),this.fire("identify",{coordinate:t,options:e});const o=this._raycaster,s=this._mouse,a=this.getCamera(),h=this.getScene(),l=this.getMap().getSize();if(!h)return[];const c=l.width,u=l.height;s.x=n/c*2-1,s.y=-r/u*2+1,o.setFromCamera(s,a),o.layers&&o.layers.enableAll&&o.layers.enableAll(),function(t,e){SS>113?t.params.Line.threshold=e:t.linePrecision=e}(o,this._getLinePrecision(this.getMap().getResolution()));const d=[],p=[];h.children.forEach((t=>{const e=t.__parent;if(e&&e.getOptions){const i=e;i.getOptions().interactive&&i.isVisible()&&(i.identify&&Ii.isFunction(i.identify)?p.push(i):d.push(t))}else(t instanceof ng||t instanceof Dy)&&d.push(t)}));let f=[];const m=o.intersectObjects(d,!0);m&&Array.isArray(m)&&m.length&&(f=m.map((t=>{let e=t.object;const i=t.instanceId;e=this._recursionMesh(e)||{};const n=e.__parent||e;return n.faceIndex=t.faceIndex,n.index=t.index,n.intersect=t,Ii.isNumber(i)&&(n.instanceId=i),n}))),this.renderPickScene(),p.length&&p.forEach((e=>{e.identify(t)&&f.push(e)}));const g=f.length;for(let t=0;t<g;t++)if(f[t])for(let e=t+1;e<g;e++)f[t]===f[e]&&f.splice(e,1);let v=f.filter((t=>t instanceof zS));v=v.sort(((t,e)=>t.options.pickWeight-e.options.pickWeight)),f.forEach((t=>{t instanceof zS||v.push(t)}));const y=(e=Ii.extend({},e)).count;return Ii.isNumber(y)&&y>0?v.slice(0,y):f}_recursionMesh(t){for(;t&&t.parent!==this.getScene();)t=t.parent;return t}_getLinePrecision(t=10){for(let e=0,i=qP.length;e<i;e++){const[i,n]=qP[e];if(t>i)return n}return.01}_identifyBaseObjectEvents(t){if(!this.options.geometryEvents)return this;const e=this.map||this.getMap();if(e.isInteracting()||!e.options.geometryEvents||e._ignoreEvent(t))return this;const i=t.type,n=e._getEventParams?e._getEventParams(t):this._getEventParams(t);n.type=i;const{type:r,coordinate:o}=n,s=Ii.now();if(this._mousemoveTimeOut&&"mousemove"===r&&s-this._mousemoveTimeOut<64)return this;this._mousemoveTimeOut=s,"mousedown"!==r&&"touchstart"!==r||(this._mousedownTime=Ii.now());let a=!1;if("click"===r||"touchend"===r){const t=e.options.clickTimeThreshold||280;a=Ii.now()-this._mousedownTime<t}if("click"===r&&!a)return this;const h=this.options.identifyCountOnEvent;let l=Math.max(0,Ii.isNumber(h)?h:0);0===l&&(l=1/0);const c=t=>{const e=[];this._baseObjects&&this._baseObjects.forEach((i=>{let n=!0;t.forEach((t=>{i===t&&(n=!1)})),n&&e.push(i)})),e.forEach((t=>{t&&t instanceof zS&&(t.getSelectMesh?t.isHide||(t._mouseover=!1,t.fire("mouseout",Object.assign({},n,{target:t,type:"mouseout",selectMesh:null})),t.closeToolTip()):(t._mouseover=!1,t.fire("mouseout",Object.assign({},n,{target:t,type:"mouseout"})),t.closeToolTip()))}))};if("mouseout"===r)return c([]),this._baseObjects=[],this;const u=this.identify(o,{count:l}),d=this.getScene();if(0===u.length&&d)for(let t=0,e=d.children.length;t<e;t++){const e=(d.children[t]||{}).__parent;e&&e.fire("empty",Object.assign({},n,{target:e}))}function p(t,e){e=e||r;const i=t.getInfoWindow();i&&!i._owner&&i.addTo(t);((i?i.options:{}).autoOpenOn||"click")===e&&(t.openInfoWindow(o),t.fire("showinfowindow",{infoWindow:i}))}if("mousemove"===r?(c(u),u.forEach((t=>{if(t instanceof zS){t._mouseover||(t.fire("mouseover",Object.assign({},n,{target:t,type:"mouseover",selectMesh:t.getSelectMesh?t.getSelectMesh():null})),t._mouseover=!0,p(t,"mouseover")),t.fire(r,Object.assign({},n,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null}));const e=t.getToolTip();e&&!e._owner&&e.addTo(t),t.openToolTip(o),p(t)}})),this._baseObjects=u):u.forEach((t=>{t instanceof zS&&(t.fire(r,Object.assign({},n,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null})),p(t))})),"touchend"===r&&a){const e=Ii.extend({},n,{domEvent:t});u.forEach((t=>{t instanceof zS&&(t.fire("click",Object.assign({},e,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null})),p(t,"click"))}))}return this}_getEventParams(t){const e=this.getMap(),i={domEvent:t};if(!e)return i;const n=t.touches&&t.touches.length>0?t.touches[0]:t.changedTouches&&t.changedTouches.length>0?t.changedTouches[0]:t;if(n){const t=(0,un.getEventContainerPoint)(n,e._containerDOM);i.coordinate=e.containerPointToCoordinate(t),i.containerPoint=t,i.viewPoint=e.containerPointToViewPoint(t),i.pont2d=e._containerPointToPoint(t)}return i}_zoomend(){const t=this.getScene();if(!t)return;const e=this.getMap().getZoom();t.children.forEach((t=>{const i=t.__parent;if(i&&i.getOptions){const t=i;t.zoomChange&&Ii.isFunction(t.zoomChange)&&t.zoomChange(e);const n=t.getMinZoom(),r=t.getMaxZoom();e<n||e>r?(t.isVisible()&&(t.getObject3d().visible=!1),t._zoomVisible=!1):n<=e&&e<=r&&(t._visible&&(t.getObject3d().visible=!0),t._zoomVisible=!0)}}))}_getGeometryEventMapPanel(){const t=this.map||this.getMap();return t._panels.allLayers||t._containerDOM}onAdd(){super.onAdd();const t=this.map||this.getMap();if(!t)return this;const e=this._getGeometryEventMapPanel();return this._identifyBaseObjectEventsThis||(this._identifyBaseObjectEventsThis=this._identifyBaseObjectEvents.bind(this)),this._zoomendThis||(this._zoomendThis=this._zoomend.bind(this)),un.on(e,XP.join(" "),this._identifyBaseObjectEventsThis,this),this._needsUpdate=!0,this._animationBaseObjectMap||(this._animationBaseObjectMap={}),t.on("zooming zoomend",this._zoomendThis,this),this}onRemove(){super.onRemove();const t=this.map||this.getMap();if(!t)return this;const e=this._getGeometryEventMapPanel();return un.off(e,XP.join(" "),this._identifyBaseObjectEventsThis,this),t.off("zooming zoomend",this._zoomendThis,this),this.clear(),this}_callbackBaseObjectAnimation(){const t=this;if(t._animationBaseObjectMap)for(const e in t._animationBaseObjectMap){t._animationBaseObjectMap[e]._animation()}return this}_getFovRatio(){const t=this.getMap().getFov();return Math.tan(t/2*ZP)}}KP.mergeOptions({renderer:"gl",doubleBuffer:!1,glOptions:null,geometryEvents:!0,identifyCountOnEvent:0,forceRenderOnZooming:!0,loopRenderCount:50});const $P={bloom:!0};class tA extends Ec.CanvasLayerRenderer{constructor(){super(...arguments),this._renderTime=0,this._renderTarget=null}getPrepareParams(){return[this.scene,this.camera]}getDrawParams(){return[this.scene,this.camera]}_drawLayer(){super._drawLayer.apply(this,arguments)}hitDetect(){return!1}createCanvas(){super.createCanvas(),this.createContext()}createContext(){if(this.canvas.gl&&this.canvas.gl.wrap)this.gl=this.canvas.gl.wrap();else{const t=this.layer.options.glOptions||{alpha:!0,depth:!0,antialias:!0,stencil:!0,preserveDrawingBuffer:!1};t.preserveDrawingBuffer=!0,this.gl=this.gl||this._createGLContext(this.canvas,t)}this._initThreeRenderer(),this.layer.onCanvasCreate(this.context,this.scene,this.camera)}_initThreeRenderer(){this.matrix4=new _f;const t=new Fy({context:this.gl,alpha:!0});t.autoClear=!1,t.setClearColor(new fm(1,1,1),0),t.setSize(this.canvas.width,this.canvas.height),t.clear(),this.context=t;const e=this.scene=new jy,i=this.layer.getMap(),n=i.getFov()*Math.PI/180,r=this.camera=new pg(n,i.width/i.height,i.cameraNear,i.cameraFar);r.matrixAutoUpdate=!1,this._syncCamera(),e.add(r),this.pick=new cP(this.layer),AE.star()}onCanvasCreate(){super.onCanvasCreate()}resizeCanvas(t){if(!this.canvas)return;let e,i=this.getMap();e=t||i.getSize();const n=i.getDevicePixelRatio?i.getDevicePixelRatio():Ot.retina?2:1,r=this.canvas,{width:o,height:s,cssWidth:a,cssHeight:h}=Ii.calCanvasSize(e,n);if(!this.layer._canvas||r.style.width===a&&r.style.height===h||(r.style.width=a,r.style.height=h),r.width===o&&r.height===s)return this;r.width=o,r.height=s,this.context.setSize(r.width,r.height)}clearCanvas(){this.canvas&&this.context.clear()}prepareCanvas(){return this.canvas?this.clearCanvas():this.createCanvas(),this.layer.fire("renderstart",{context:this.context}),null}renderScene(t){if(this.layer._callbackBaseObjectAnimation(),this._syncCamera(),t&&t.renderTarget){const{width:e,height:i}=t.renderTarget.fbo;this._renderTarget?(this._renderTarget.viewport.set(0,0,e,i),this._renderTarget.scissor.set(0,0,e,i)):(this._renderTarget=new Bp(e,i,{depthBuffer:!1}),this.context.setRenderTarget(this._renderTarget),this.context.render(this.scene,this.camera));const n=this.context.properties.get(this._renderTarget),r=n[QP];n[QP]=t.renderTarget.getFramebuffer(t.renderTarget.fbo),this.context.setRenderTarget(this._renderTarget);const o=1===t.bloom&&t.sceneFilter,s=this.scene.children||[];let a=!1;if(o){const e=t.sceneFilter;a=e($P);for(let t=0,i=s.length;t<i;t++){if(!s[t]||!s[t].layers)continue;const i=s[t].__parent;s[t].bloom=!1,i&&(s[t].bloom=i.bloom);let n=0;(s[t]&&e(s[t])||!i)&&a&&(n=1),s[t].__layer!==n&&(eA(s[t],n),s[t].__layer=n)}}else for(let t=0,e=s.length;t<e;t++)s[t]&&s[t].layers&&0!==s[t].__layer&&(eA(s[t],0),s[t].__layer=0);this.camera.layers.set(a?1:0),this.context.render(this.scene,this.camera),n[QP]=r}else this.context.render(this.scene,this.camera);this.context.setRenderTarget(null),this.completeRender()}remove(){delete this._drawContext,this._renderTarget&&(this._renderTarget.dispose(),delete this._renderTarget),super.remove()}_syncCamera(){const t=this.getMap(),e=this.camera;e.matrix.elements=t.cameraWorldMatrix,e.projectionMatrix.elements=t.projMatrix,this.matrix4.invert?e.projectionMatrixInverse.elements=this.matrix4.copy(e.projectionMatrix).invert().elements:e.projectionMatrixInverse&&(e.projectionMatrixInverse.elements=this.matrix4.getInverse(e.projectionMatrix).elements)}_createGLContext(t,e){const i=["webgl2","webgl","experimental-webgl"];let n=null;for(let r=0;r<i.length;++r){try{n=t.getContext(i[r],e)}catch(t){}if(n)break}return n}}function eA(t,e){if(!t)return;t.layers&&t.layers.set(e);const i=t.children;if(i&&i.length)for(let t=0,n=i.length;t<n;t++)eA(i[t],e)}function iA(t){return t.getGLRes?t.getGLRes():t.getGLZoom()}function nA(t,e,i,n){return t.coordToPointAtRes?t.coordToPointAtRes(e,i,n):t.coordinateToPoint(e,i,n)}function rA(t,e){return rA=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rA(t,e)}function oA(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function sA(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return oA(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?oA(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function aA(){return"iep"+"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))+"layer"}KP.registerRenderer("gl",tA),Mr&&(Mr("__maptalks.three__",'(function(n){"use strict";\n/*!\n * poly-extrude v0.1.0\n */var t={exports:{}};function r(n,t,r){r=r||2;var i,o,u,v,s,l,x,c=t&&t.length,d=c?t[0]*r:n.length,g=e(n,0,d,r,!0),y=[];if(!g||g.next===g.prev)return y;if(c&&(g=function(n,t,r,i){var a,o,u,v=[];for(a=0,o=t.length;a<o;a++)(u=e(n,t[a]*i,a<o-1?t[a+1]*i:n.length,i,!1))===u.next&&(u.steiner=!0),v.push(p(u));for(v.sort(h),a=0;a<v.length;a++)r=f(v[a],r);return r}(n,t,g,r)),n.length>80*r){i=u=n[0],o=v=n[1];for(var m=r;m<d;m+=r)(s=n[m])<i&&(i=s),(l=n[m+1])<o&&(o=l),s>u&&(u=s),l>v&&(v=l);x=0!==(x=Math.max(u-i,v-o))?32767/x:0}return a(g,y,r,i,o,x,0),y}function e(n,t,r,e,i){var a,o;if(i===z(n,t,r,e)>0)for(a=t;a<r;a+=e)o=Z(a,n[a],n[a+1],o);else for(a=r-e;a>=t;a-=e)o=Z(a,n[a],n[a+1],o);return o&&y(o,o.next)&&(F(o),o=o.next),o}function i(n,t){if(!n)return n;t||(t=n);var r,e=n;do{if(r=!1,e.steiner||!y(e,e.next)&&0!==g(e.prev,e,e.next))e=e.next;else{if(F(e),(e=t=e.prev)===e.next)break;r=!0}}while(r||e!==t);return t}function a(n,t,r,e,h,f,l){if(n){!l&&f&&function(n,t,r,e){var i=n;do{0===i.z&&(i.z=x(i.x,i.y,t,r,e)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,function(n){var t,r,e,i,a,o,u,v,s=1;do{for(r=n,n=null,a=null,o=0;r;){for(o++,e=r,u=0,t=0;t<s&&(u++,e=e.nextZ);t++);for(v=s;u>0||v>0&&e;)0!==u&&(0===v||!e||r.z<=e.z)?(i=r,r=r.nextZ,u--):(i=e,e=e.nextZ,v--),a?a.nextZ=i:n=i,i.prevZ=a,a=i;r=e}a.nextZ=null,s*=2}while(o>1)}(i)}(n,e,h,f);for(var p,c,d=n;n.prev!==n.next;)if(p=n.prev,c=n.next,f?u(n,e,h,f):o(n))t.push(p.i/r|0),t.push(n.i/r|0),t.push(c.i/r|0),F(n),n=c.next,d=c.next;else if((n=c)===d){l?1===l?a(n=v(i(n),t,r),t,r,e,h,f,2):2===l&&s(n,t,r,e,h,f):a(i(n),t,r,e,h,f,1);break}}}function o(n){var t=n.prev,r=n,e=n.next;if(g(t,r,e)>=0)return!1;for(var i=t.x,a=r.x,o=e.x,u=t.y,v=r.y,s=e.y,h=i<a?i<o?i:o:a<o?a:o,f=u<v?u<s?u:s:v<s?v:s,l=i>a?i>o?i:o:a>o?a:o,x=u>v?u>s?u:s:v>s?v:s,p=e.next;p!==t;){if(p.x>=h&&p.x<=l&&p.y>=f&&p.y<=x&&c(i,u,a,v,o,s,p.x,p.y)&&g(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function u(n,t,r,e){var i=n.prev,a=n,o=n.next;if(g(i,a,o)>=0)return!1;for(var u=i.x,v=a.x,s=o.x,h=i.y,f=a.y,l=o.y,p=u<v?u<s?u:s:v<s?v:s,d=h<f?h<l?h:l:f<l?f:l,y=u>v?u>s?u:s:v>s?v:s,m=h>f?h>l?h:l:f>l?f:l,w=x(p,d,t,r,e),M=x(y,m,t,r,e),b=n.prevZ,A=n.nextZ;b&&b.z>=w&&A&&A.z<=M;){if(b.x>=p&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&c(u,h,v,f,s,l,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,A.x>=p&&A.x<=y&&A.y>=d&&A.y<=m&&A!==i&&A!==o&&c(u,h,v,f,s,l,A.x,A.y)&&g(A.prev,A,A.next)>=0)return!1;A=A.nextZ}for(;b&&b.z>=w;){if(b.x>=p&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&c(u,h,v,f,s,l,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;A&&A.z<=M;){if(A.x>=p&&A.x<=y&&A.y>=d&&A.y<=m&&A!==i&&A!==o&&c(u,h,v,f,s,l,A.x,A.y)&&g(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function v(n,t,r){var e=n;do{var a=e.prev,o=e.next.next;!y(a,o)&&m(a,e,e.next,o)&&b(a,o)&&b(o,a)&&(t.push(a.i/r|0),t.push(e.i/r|0),t.push(o.i/r|0),F(e),F(e.next),e=n=o),e=e.next}while(e!==n);return i(e)}function s(n,t,r,e,o,u){var v=n;do{for(var s=v.next.next;s!==v.prev;){if(v.i!==s.i&&d(v,s)){var h=A(v,s);return v=i(v,v.next),h=i(h,h.next),a(v,t,r,e,o,u,0),void a(h,t,r,e,o,u,0)}s=s.next}v=v.next}while(v!==n)}function h(n,t){return n.x-t.x}function f(n,t){var r=function(n,t){var r,e=t,i=n.x,a=n.y,o=-1/0;do{if(a<=e.y&&a>=e.next.y&&e.next.y!==e.y){var u=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=i&&u>o&&(o=u,r=e.x<e.next.x?e:e.next,u===i))return r}e=e.next}while(e!==t);if(!r)return null;var v,s=r,h=r.x,f=r.y,x=1/0;e=r;do{i>=e.x&&e.x>=h&&i!==e.x&&c(a<f?i:o,a,h,f,a<f?o:i,a,e.x,e.y)&&(v=Math.abs(a-e.y)/(i-e.x),b(e,n)&&(v<x||v===x&&(e.x>r.x||e.x===r.x&&l(r,e)))&&(r=e,x=v)),e=e.next}while(e!==s);return r}(n,t);if(!r)return t;var e=A(r,n);return i(e,e.next),i(r,r.next)}function l(n,t){return g(n.prev,n,t.prev)<0&&g(t.next,n,n.next)<0}function x(n,t,r,e,i){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*i|0)|n<<8))|n<<4))|n<<2))|n<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-e)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function p(n){var t=n,r=n;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==n);return r}function c(n,t,r,e,i,a,o,u){return(i-o)*(t-u)>=(n-o)*(a-u)&&(n-o)*(e-u)>=(r-o)*(t-u)&&(r-o)*(a-u)>=(i-o)*(e-u)}function d(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!function(n,t){var r=n;do{if(r.i!==n.i&&r.next.i!==n.i&&r.i!==t.i&&r.next.i!==t.i&&m(r,r.next,n,t))return!0;r=r.next}while(r!==n);return!1}(n,t)&&(b(n,t)&&b(t,n)&&function(n,t){var r=n,e=!1,i=(n.x+t.x)/2,a=(n.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(e=!e),r=r.next}while(r!==n);return e}(n,t)&&(g(n.prev,n,t.prev)||g(n,t.prev,t))||y(n,t)&&g(n.prev,n,n.next)>0&&g(t.prev,t,t.next)>0)}function g(n,t,r){return(t.y-n.y)*(r.x-t.x)-(t.x-n.x)*(r.y-t.y)}function y(n,t){return n.x===t.x&&n.y===t.y}function m(n,t,r,e){var i=M(g(n,t,r)),a=M(g(n,t,e)),o=M(g(r,e,n)),u=M(g(r,e,t));return i!==a&&o!==u||(!(0!==i||!w(n,r,t))||(!(0!==a||!w(n,e,t))||(!(0!==o||!w(r,n,e))||!(0!==u||!w(r,t,e)))))}function w(n,t,r){return t.x<=Math.max(n.x,r.x)&&t.x>=Math.min(n.x,r.x)&&t.y<=Math.max(n.y,r.y)&&t.y>=Math.min(n.y,r.y)}function M(n){return n>0?1:n<0?-1:0}function b(n,t){return g(n.prev,n,n.next)<0?g(n,t,n.next)>=0&&g(n,n.prev,t)>=0:g(n,t,n.prev)<0||g(n,n.next,t)<0}function A(n,t){var r=new P(n.i,n.x,n.y),e=new P(t.i,t.x,t.y),i=n.next,a=t.prev;return n.next=t,t.prev=n,r.next=i,i.prev=r,e.next=r,r.prev=e,a.next=e,e.prev=a,e}function Z(n,t,r,e){var i=new P(n,t,r);return e?(i.next=e.next,i.prev=e,e.next.prev=i,e.next=i):(i.prev=i,i.next=i),i}function F(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function P(n,t,r){this.i=n,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function z(n,t,r,e){for(var i=0,a=t,o=r-e;a<r;a+=e)i+=(n[o]-n[a])*(n[a+1]+n[o+1]),o=a;return i}t.exports=r,t.exports.default=r,r.deviation=function(n,t,r,e){var i=t&&t.length,a=i?t[0]*r:n.length,o=Math.abs(z(n,0,a,r));if(i)for(var u=0,v=t.length;u<v;u++){var s=t[u]*r,h=u<v-1?t[u+1]*r:n.length;o-=Math.abs(z(n,s,h,r))}var f=0;for(u=0;u<e.length;u+=3){var l=e[u]*r,x=e[u+1]*r,p=e[u+2]*r;f+=Math.abs((n[l]-n[p])*(n[x+1]-n[l+1])-(n[l]-n[x])*(n[p+1]-n[l+1]))}return 0===o&&0===f?0:Math.abs((f-o)/o)},r.flatten=function(n){for(var t=n[0][0].length,r={vertices:[],holes:[],dimensions:t},e=0,i=0;i<n.length;i++){for(var a=0;a<n[i].length;a++)for(var o=0;o<t;o++)r.vertices.push(n[i][a][o]);i>0&&(e+=n[i-1].length,r.holes.push(e))}return r};var I=t.exports;function E(n){for(var t,r,e=0,i=1,a=n.length;i<a;)t=r||n[0],e+=((r=n[i])[0]-t[0])*(r[1]+t[1]),i++;return e>0}function L(n,t,r){return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],n}function H(n,t){var r=t[0],e=t[1],i=t[2],a=Math.sqrt(r*r+e*e+i*i)||1;return n[0]=r/a,n[1]=e/a,n[2]=i/a,n}function U(n,t){function r(n,t,r,e){n[0]=t,n[1]=r,n[2]=e}for(var e,i,a,o,u,v,s,h,f,l=[],x=[],p=[],c=[],d=[],g=[],y=n.length,m=new Float32Array(t.length),w=0;w<y;){var M=3*n[w],b=3*n[w+1],A=3*n[w+2];r(l,t[M],t[M+1],t[M+2]),r(x,t[b],t[b+1],t[b+2]),r(p,t[A],t[A+1],t[A+2]),L(d,p,x),L(c,l,x),e=g,a=c,o=void 0,u=void 0,v=void 0,s=void 0,h=void 0,f=void 0,o=(i=d)[0],u=i[1],v=i[2],s=a[0],h=a[1],f=a[2],e[0]=u*f-v*h,e[1]=v*s-o*f,e[2]=o*h-u*s;for(var Z=0;Z<3;Z++)m[M+Z]+=g[Z],m[b+Z]+=g[Z],m[A+Z]+=g[Z];w+=3}for(var F=0,P=m.length;F<P;)r(g,m[F],m[F+1],m[F+2]),H(g,g),m[F]=g[0]||0,m[F+1]=g[1]||0,m[F+2]=g[2]||0,F+=3;return m}function j(n){if(1===n.length)return{position:n[0].position,normal:n[0].normal,uv:n[0].uv,indices:n[0].indices,results:n};for(var t=0,r=0,e=0,i=n.length;e<i;e++){var a=n[e],o=a.position,u=a.indices;t+=o.length,r+=u.length}for(var v={position:new Float32Array(t),normal:new Float32Array(t),uv:new Float32Array(t/3*2),indices:new Uint32Array(r),results:n},s=0,h=0,f=0,l=0,x=0,p=n.length;x<p;x++){var c=n[x],d=c.position,g=c.indices,y=c.normal,m=c.uv;v.position.set(d,s),v.normal.set(y,s),v.uv.set(m,l);for(var w=0,M=g.length;w<M;){var b=g[w]+h;v.indices[f]=b,f++,w++}l+=m.length,s+=d.length,h+=d.length/3}return v}function O(n){return 180*n/Math.PI}function S(n){return n/180*Math.PI}function W(n,t,r,e,i,a){var o=3*r,u=3*e,v=3*i,s=3*a,h=t[o],f=t[o+1],l=t[o+2],x=t[u],p=t[u+1],c=t[u+2],d=t[v],g=t[v+1],y=t[v+2],m=t[s],w=t[s+1],M=t[s+2];Math.abs(f-p)<Math.abs(h-x)?(n.push(h,1-l),n.push(x,1-c),n.push(d,1-y),n.push(m,1-M)):(n.push(f,1-l),n.push(p,1-c),n.push(g,1-y),n.push(w,1-M))}function k(n,t){t=Object.assign({},{depth:2},t);var r=n.map((function(n){for(var r=0,e=n.length;r<e;r++){var i=n[r];B(i),0===r?E(i)||(n[r]=i.reverse()):E(i)&&(n[r]=i.reverse()),V(i)&&i.splice(i.length-1,1)}var a=function(n,t){for(var r=function(n){var t=0,r=0,e=n.length;for(;r<e;)t+=n[r].length,r++;return t}(n),e=n.length,i=[],a=new Float32Array(2*r),o=[],u=[],v=3*r,s=2*r,h=t.depth,f=0,l=0,x=0,p=0;p<e;p++){var c=n[p];p>0&&i.push(f/2);for(var d=0,g=c.length;d<g;){var y=c[d],m=y[0],w=y[1];a[f++]=m,a[f++]=w,o[l]=m,o[l+1]=w,o[l+2]=h,o[v+l]=m,o[v+l+1]=w,o[v+l+2]=0,u[x]=m,u[x+1]=w,u[s+x]=m,u[s+x+1]=w,l+=3,x+=2,d++}}return{flatVertices:a,holes:i,points:o,count:r,uvs:u}}(n,t);return a.polygon=n,function(n,t){for(var r=[],e=n.count,i=0,a=t.length;i<a;i+=3){var o=t[i],u=t[i+1],v=t[i+2];r[i]=o,r[i+1]=u,r[i+2]=v;var s=a+i,h=e+o,f=e+u,l=e+v;r[s]=h,r[s+1]=f,r[s+2]=l}n.index=r}(a,I(a.flatVertices,a.holes,2)),function(n,t){for(var r=n.points,e=n.index,i=n.polygon,a=n.uvs,o=t.depth,u=0,v=i.length;u<v;u++)for(var s=i[u],h=0,f=s.length;h<f;){var l=s[h],x=s[h+1];h===f-1&&(x=s[0]);var p=r.length/3,c=l[0],d=l[1],g=x[0],y=x[1];r.push(c,d,o,g,y,o,c,d,0,g,y,0);var m=p+2,w=p+3,M=p,b=p+1;e.push(m,M,w,M,b,w),W(a,r,m,w,M,b),h++}}(a,t),a.position=new Float32Array(a.points),a.indices=new Uint32Array(a.index),a.uv=new Float32Array(a.uvs),a.normal=U(a.indices,a.position),a})),e=j(r);return e.polygons=n,e}function B(n){V(n)||n.push(n[0])}function V(n){var t=n.length,r=n[0],e=r[0],i=r[1],a=n[t-1],o=a[0],u=a[1];return e===o&&i===u}function _(n,t){t=Object.assign({},{depth:2,lineWidth:1},t);var r=n.map((function(n){var r=function(n,t){var r=0,e=t.lineWidth/2,i=[],a=[],o=[],u=n.length,v=0;for(;v<u-1;){var s=n[v],h=n[v+1],f=h[1]-s[1],l=h[0]-s[0],x=0,p=O(Math.atan(f/l));if(r=p,0===v)x=p,x-=90;else{var c=n[v-1];q.x=c[0]-s[0],q.y=c[1]-s[1],R.x=h[0]-s[0],R.y=h[1]-s[1],x=p-D(q,R)/2}var d=C(S(x),e,s),g=d[0],y=d[1];i.push(g,y),G(g,s,h)?(a.push(g),o.push(y)):(a.push(y),o.push(g)),v++}var m=r,w=S(m-=90),M=n[u-2],b=n[u-1],A=C(w,e,b),Z=A[0],F=A[1];i.push(Z,F),G(Z,M,b)?(a.push(Z),o.push(F)):(a.push(F),o.push(Z));return{offsetPoints:i,leftPoints:a,rightPoints:o}}(n,t);return r.line=n,function(n,t){var r=t.depth,e=[],i=[],a=[],o=n.leftPoints,u=n.rightPoints,v=0,s=o.length;for(;v<s;){var h=3*v,f=o[v],l=f[0],x=f[1];e[h]=l,e[h+1]=x,e[h+2]=r;var p=u[v],c=p[0],d=p[1],g=3*s+h;e[g]=c,e[g+1]=d,e[g+2]=r;var y=2*s*3+h;e[y]=l,e[y+1]=x,e[y+2]=0;var m=2*s*3+3*s+h;e[m]=c,e[m+1]=d,e[m+2]=0,v++}v=0,s=e.length;for(;v<s;){var w=e[v],M=e[v+1];a.push(w,M),v+=3}v=0,s=o.length;for(;v<s-1;){var b=v,A=v+1,Z=b+s,F=A+s;i.push(b,Z,A),i.push(Z,F,A);var P=v+2*s,z=P+1,I=P+s,E=z+s;i.push(P,I,z),i.push(I,E,z),v++}n.index=i,n.points=e,n.uvs=a}(r,t),function(n,t){var r=n.points,e=n.index,i=n.leftPoints,a=n.rightPoints,o=n.uvs,u=t.depth,v=[i,a];function s(n,t){var i=r.length/3;r.push(n[0],n[1],u,t[0],t[1],u,n[0],n[1],0,t[0],t[1],0);var a=i+2,v=i+3,s=i,h=i+1;e.push(a,s,v,s,h,v),W(o,r,a,v,s,h)}for(var h=0,f=v.length;h<f;h++){var l=v[h];h>0&&(l=(l=l.map((function(n){return n}))).reverse());for(var x=0,p=l.length-1;x<p;){s(l[x],l[x+1]),x++}}for(var c=i.length,d=[a[0],i[0],i[c-1],a[c-1]],g=0;g<d.length;g+=2){s(d[g],d[g+1])}}(r,t),r.position=new Float32Array(r.points),r.indices=new Uint32Array(r.index),r.uv=new Float32Array(r.uvs),r.normal=U(r.indices,r.position),r})),e=j(r);return e.lines=n,e}var q={x:0,y:0},R={x:0,y:0};function C(n,t,r){var e=r[0],i=r[1],a=[e+Math.cos(n)*t,i+Math.sin(n)*t],o=n+=Math.PI;return[a,[e+Math.cos(o)*t,i+Math.sin(o)*t]]}var D=function(n,t){var r=n.x,e=n.y,i=t.x,a=t.y,o=r*i+e*a,u=r*a-e*i;return(Math.atan2(u,o)/Math.PI*180+360)%360};function G(n,t,r){var e=t[0],i=t[1],a=r[0],o=r[1];return(i-o)*n[0]+(a-e)*n[1]+e*o-a*i>0}function J(n,t){void 0===t&&(t={}),t=Object.assign({},{radius:1,height:2,radialSegments:6},t);for(var r=Math.round(Math.max(4,t.radialSegments)),e=t,i=e.radius,a=e.height,o=360/r/360*Math.PI*2,u=r+1,v=new Float32Array(3*u*2),s=n[0],h=n[1],f=0,l=0,x=3*u,p=2*u,c=[],d=[],g=-1;g<r;g++){var y=o*g,m=Math.cos(y)*i+s,w=Math.sin(y)*i+h;v[f]=m,v[f+1]=w,v[f+2]=0,v[f+x]=m,v[f+1+x]=w,v[f+2+x]=a;var M,b;M=.5+m/i/2,b=.5+w/i/2,d[l]=M,d[l+1]=b,d[l+p]=M,d[l+1+p]=b,f+=3,l+=2,g>1&&c.push(0,g-1,g)}v[f-=3]=v[0],v[f+1]=v[1],v[f+2]=v[2];var A=v.length;v[A-3]=v[0],v[A-2]=v[1],v[A-1]=a;for(var Z=c.length,F=0;F<Z;F++){var P=c[F];c.push(P+u)}var z=new Float32Array(2*(3*u*2-6)),I=-1;f=2*u,l=0;for(var E=0,L=v.length/2;E<L-3;E+=3){var H=v[E],j=v[E+1],O=v[E+3],S=v[E+4];z[++I]=H,z[++I]=j,z[++I]=a,z[++I]=O,z[++I]=S,z[++I]=a,z[++I]=H,z[++I]=j,z[++I]=0,z[++I]=O,z[++I]=S,z[++I]=0;var W=f+2,k=f+3,B=f,V=f+1;c.push(B,W,V,W,k,V),f+=4;var _=l/u,q=(l+1)/u;d.push(_,a/i/2,q,a/i/2,_,0,q,0),l++}var R=new Float32Array(v.length+z.length);R.set(v,0),R.set(z,v.length);var C=U(c,R);return{points:v,indices:new Uint32Array(c),position:R,normal:C,uv:new Float32Array(d)}}var K={x:0,y:0},N={x:0,y:0};function Q(n,t,r,e){for(var i=n.length,a=0;a<i;a++){var o=n[a].data;t=n[a].center||t;for(var u=0,v=o.length;u<v;u++)for(var s=o[u],h=0,f=s.length;h<f;h++)n[a].data[u][h]=T(s[h],t,r,e)}}function T(n,t,r,e){for(var i,a=[],o=0,u=(i=r?new Float64Array(n):new Float32Array(n)).length;o<u;o+=2){var v=i[o],s=i[o+1];if(t&&r&&e){K.x=v,K.y=s;var h=un(K,N);K.x=h.x,K.y=h.y,v=(h=vn(e,K,r,N)).x,s=h.y,v-=t[0],s-=t[1]}a.push([v,s])}return a}function X(n,t){void 0===t&&(t=!1);for(var r=n.length,e=[],i=[],a=0,o=0;o<r;o++){var u=t?$(n[o]):Y(n[o]),v=n[o].bottomHeight||0,s=u.position;i.push(u);var h=s.length/3;e[o]={position:{middleZ:v+(n[o].height||0)/2,count:h,start:a,end:a+3*h},hide:!1},a+=3*h}var f=tn(i),l=f.position,x=f.normal,p=f.uv,c=f.indices;return{position:l.buffer,normal:x.buffer,uv:p.buffer,indices:c.buffer,geometriesAttributes:e}}function Y(n){var t=n.data,r=n.height,e=n.bottomHeight,i=k(t,{depth:r}),a=i.position,o=i.normal,u=i.uv,v=i.indices;return rn(a,e),{position:a,normal:o,uv:u,indices:v}}function $(n){var t=n.data,r=n.height,e=n.width,i=n.bottomHeight,a=_(t,{lineWidth:e,depth:r}),o=a.position,u=a.normal,v=a.uv,s=a.indices;return rn(o,i),{position:o,normal:u,uv:v,indices:s}}function nn(n,t){for(var r=new Float32Array(t),e=0,i=0;i<n.length;++i)r.set(n[i],e),e+=n[i].length;return r}function tn(n){for(var t={},r={},e=0;e<n.length;++e){var i=n[e];for(var a in i)void 0===t[a]&&(t[a]=[],r[a]=0),t[a].push(i[a]),r[a]+=i[a].length}var o={},u=0,v=[];for(var s in t)if("indices"===s)for(var h=t[s],f=0,l=h.length;f<l;f++){for(var x=h[f],p=0,c=x.length;p<c;p++)v.push(x[p]+u);u+=t.position[f].length/3}else{var d=nn(t[s],r[s]);if(!d)return null;o[s]=d}return o.indices=new Uint32Array(v),o}function rn(n,t){if(void 0!==t&&"number"==typeof t&&0!==t)for(var r=0,e=n.length;r<e;r+=3)n[r+2]+=t}function en(n){for(var t=[],r=0,e=n.length;r<e;r+=7){var i=n[r],a=n[r+1],o=n[r+2],u=n[r+3],v=n[r+4],s=n[r+5];t.push({radialSegments:o,radius:u,height:v,altitude:s,center:[i,a]})}for(var h=t.length,f=[],l=[],x=0,p=0;p<h;p++){var c=J(t[p].center||[0,0],t[p]),d=c.position;if(t[p].altitude)for(var g=t[p].altitude,y=0,m=d.length;y<m;y+=3)c[y+2]+=g;l.push(c);var w=d.length/3;f[p]={position:{middleZ:t[p].height/2,count:w,start:x,end:x+3*w},hide:!1},x+=3*w}var M=tn(l),b=M.position,A=M.normal,Z=M.uv,F=M.indices;return{position:b.buffer,normal:A.buffer,uv:Z.buffer,indices:F.buffer,geometriesAttributes:f}}var an=Math.PI/180,on=6378137*Math.PI/180;function un(n,t){var r,e=85.0511287798,i=n.x,a=Math.max(Math.min(e,n.y),-e);r=0===a?0:Math.log(Math.tan((90+a)*an/2))/an;var o=i*on,u=r*on;return t?(t.x=o,t.y=u,t):{x:o,y:u}}function vn(n,t,r,e){var i=n[0]*(t.x-n[2])/r,a=-n[1]*(t.y-n[3])/r;return e?(e.x=i,e.y=a,e):{x:i,y:a}}function sn(n){void 0===n&&(n=[]);for(var t=n.length,r=new Float32Array(3*t),e=0;e<t;e++){var i=n[e],a=3*e;r[a]=i[0],r[a+1]=i[1]}return r}function hn(n){for(var t=new Float32Array(2*n.length-6),r=0,e=0,i=n.length/3;e<i;e++){var a=n[3*e],o=n[3*e+1],u=n[3*e+2];if(e>0&&e<i-1){var v=3*r;t[v]=a,t[v+1]=o,t[v+2]=u,r++}var s=3*r;t[s]=a,t[s+1]=o,t[s+2]=u,r++}return t}function fn(n){var t=0,r=n.length;if(1===r)return n[0];for(var e=0;e<r;e++)t+=n[e].length;for(var i=new Float32Array(t),a=0,o=0;o<r;o++)i.set(n[o],a),a+=n[o].length;return i}n.initialize=function(){},n.onmessage=function(n,t){var r=n.data,e=r.type,i=r.datas,a=r.glRes,o=r.matrix,u=r.center;if("ExtrudePolygons"===e){Q(i,u,a,o);var v=X(i);t(null,v,[v.position,v.normal,v.uv,v.indices])}else if("ExtrudeLines"===e){for(var s=0,h=i.length;s<h;s++)for(var f=0,l=i[s].data.length;f<l;f++)i[s].data[f]=T(i[s].data[f],i[s].center||u,a,o);var x=X(i,!0);t(null,x,[x.position,x.normal,x.uv,x.indices])}else if("ExtrudePolygon"===e){var p=[],c=[];i.forEach((function(n){var t=[n];Q(t,u,a,o);var r=X(t),e=r.position,i=r.normal,v=r.uv,s=r.indices;p.push({id:n.id,position:e,normal:i,uv:v,indices:s}),c.push(e,i,v,s)})),t(null,p,c)}else if("Line"===e||"FatLine"===e){for(var d=[],g=[],y=0,m=i.length;y<m;y++){for(var w=[],M=0,b=i[y].data.length;M<b;M++){i[y].data[M]=T(i[y].data[M],i[y].center||u,a,o);var A=sn(i[y].data[M]);w.push(hn(A))}var Z=fn(w);rn(Z,i[y].bottomHeight),d.push({id:i[y].id,position:Z.buffer}),g.push(Z.buffer)}t(null,d,g)}else if("Lines"===e||"FatLines"===e){for(var F=0,P=[],z=[],I=0,E=[],L=0,H=i.length;L<H;L++){for(var U=0,j=0,O=i[L].data.length;j<O;j++){i[L].data[j]=T(i[L].data[j],i[L].center||u,a,o);var S=sn(i[L].data[j]);rn(S,i[L].bottomHeight),U+=S.length/3*2-2,E.push(hn(S))}var W=U;P[L]=[F,F+W],F+=W,z[L]={position:{count:U,start:I,end:I+3*U},hide:!1},"FatLines"===e&&(z[L].instanceStart={count:U,start:I,end:I+3*U},z[L].instanceEnd={count:U,start:I,end:I+3*U}),I+=3*U}var k=fn(E);t(null,{id:i.id,position:k.buffer,geometriesAttributes:z,faceMap:P},[k.buffer])}else if("ExtrudeLine"===e){for(var B=0,V=i.length;B<V;B++)for(var _=0,q=i[B].data.length;_<q;_++)i[B].data[_]=T(i[B].data[_],i[B].center||u,a,o);var R=[],C=[];i.forEach((function(n){var t=X([n],!0),r=t.position,e=t.normal,i=t.uv,a=t.indices;R.push({id:n.id,position:r,normal:e,uv:i,indices:a}),C.push(r,e,i,a)})),t(null,R,C)}else if("Bar"===e){for(var D=[],G=[],J=(i=new Float32Array(i)).length/7,K=0;K<J;){var N=i.slice(7*K,7*(K+1)),Y=en(N),$=Y.position,nn=Y.normal,tn=Y.uv,an=Y.indices;D.push({id:parseInt(N[6]),position:$,normal:nn,uv:tn,indices:an}),G.push($,nn,tn,an),K++}t(null,D,G)}else if("Bars"===e){var on=en(i=new Float32Array(i));t(null,on,[on.position,on.normal,on.uv,on.indices])}},Object.defineProperty(n,"__esModule",{value:!0})})'),Mr("__maptalks.three.fetchdata__",(function(t){const e=[],i=[],n=5;function r(t){t.abort?(i.splice(i.indexOf(t),1),e.length&&(i.push(e[0]),e.splice(0,1),o(i[i.length-1]))):i.length<n?(i.push(t),o(t)):e.push(t)}function o(t){fetch(t.url).then((t=>t.text())).then((e=>{new Blob([e],{type:"application/json"}).arrayBuffer().then((e=>{t.postResponse(null,e,[e]),t.abort=!0,r(t)}))})).catch((e=>{console.error(e),t.abort=!0,r(t)}))}t.initialize=function(){},t.onmessage=function(t,e){r({url:t.data,postResponse:e,abort:!1})}})));var hA={altitude:0,imageWidth:512,imageHeight:512,texture:null},lA=function(t){var e,i;function n(e,i,n,r){var o,s=i=Ii.extend({},hA,i),a=s.altitude;s.imageHeight,s.imageWidth,e instanceof tr||(e=new tr(e));var h=e,l=h.xmin,c=h.ymin,u=h.xmax,d=h.ymax,p=1/0,f=1/0,m=-1/0,g=-1/0;[[l,c],[l,d],[u,d],[u,c]].forEach((function(t){var e=r.coordinateToVector3(t),i=e.x,n=e.y;p=Math.min(i,p),f=Math.min(n,f),m=Math.max(i,m),g=Math.max(n,g)}));var v=Math.abs(m-p),y=Math.abs(g-f),_=new Sg(v,y);(o=t.call(this)||this)._initOptions(i),o._createMesh(_,n);var x=r.distanceToVector3(a,a).x,w=r.coordinateToVector3(e.getCenter(),x);return o.getObject3d().position.copy(w),o.parent=null,o.type="Image",o}return i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,rA(e,i),n}(zS),cA=function(){function t(t,e,i,n,r){var o=this;this.threelayer=r,this.map=r.map,this.textureLoader=new Aw;var s=t.split(","),a=e.split(","),h=parseFloat(s[0]),l=parseFloat(s[1]),c=parseFloat(a[0]),u=parseFloat(a[1]),d=n.maxZoom||11,p=n.renderOrder||0,f=n.opacity||1,m=n.minZoom||3,g=new tr(h,l,c,u);this.xmin_g=h,this.ymin_g=l,this.xmax_g=c,this.ymax_g=u,this.textureLoader.load(i,(function(t){var e=new mm({map:t,transparent:!0,opacity:f}),i=new lA(g,{imageWidth:512,imageHeight:512,maxZoom:d,minZoom:m,interactive:void 0!==n.interactive&&n.interactive},e,o.threelayer);i.object3d.renderOrder=p,o.imgMesh=i,o.imgMesh.parent=o,o.m=e,o.texture=t,o.threelayer.addMesh(o.imgMesh),n.opacityItems&&n.opacityItems.length>0&&!isNaN(n.opacityItems[0])&&!isNaN(n.opacityItems[1])&&n.opacityItems[0]>3&&n.opacityItems[0]<=18&&n.opacityItems[1]>=0&&n.opacityItems[1]<=1&&(o.opacityItems=n.opacityItems,o._bindMapEvents(),o._viewChange())}))}var e=t.prototype;return e._bindMapEvents=function(){this.map.on("viewchange",this._viewChange,this)},e._viewChange=function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1},e._closeEvent=function(){this.map.off("viewchange",this._viewChange,this)},e.updateImage=function(t,e){var i=this;if(e&&e.leftbottom&&e.righttop){var n=parseFloat(e.leftbottom[0]),r=parseFloat(e.leftbottom[1]),o=parseFloat(e.righttop[0]),s=parseFloat(e.righttop[1]);if(n!==this.xmin_g||r!==this.ymin_g||o!==this.xmax_g||s!==this.ymax_g){var a=new tr(n,r,o,s),h=1/0,l=1/0,c=-1/0,u=-1/0;[[n,r],[n,s],[o,s],[o,r]].forEach((function(t){var e=i.threelayer.coordinateToVector3(t),n=e.x,r=e.y;h=Math.min(n,h),l=Math.min(r,l),c=Math.max(n,c),u=Math.max(r,u)}));for(var d=Math.abs(c-h),p=Math.abs(u-l),f=new Sg(d,p),m=f.attributes.position.array,g=this.imgMesh.object3d.geometry.attributes.position.array,v=0;v<g.length;v++)g[v]=m[v];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var y=this.threelayer.coordinateToVector3(a.getCenter(),0);this.imgMesh.getObject3d().position.copy(y),f.dispose(),this.xmin_g=n,this.ymin_g=r,this.xmax_g=o,this.ymax_g=s}}this.textureLoader.load(t,(function(t){i.texture&&i.texture.dispose(),delete i.texture,t.magFilter=Bu,t.minFilter=Bu,i.imgMesh.object3d.material.map=t,i.imgMesh.object3d.material.map.needsUpdate=!0,i.texture=t,!1===i.imgMesh.isAdd&&(i.threelayer.addMesh(i.imgMesh),i.opacityItems&&i._bindMapEvents())}))},e.clearImage=function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())},e.dispose=function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader},t}(),uA=function(){function t(t,e){var i=this;this.map=e,this.animationId=null,this.updatables=[];var n=aA();this.threeLayer=new KP(n,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new Bb;var r=function t(){var e,n;(i.threeLayer._needsUpdate=!i.threeLayer._needsUpdate,i.threeLayer._needsUpdate)&&(null==(e=i.threeLayer)||null==(n=e.getRenderer())||n.clearCanvas(),i.threeLayer.renderScene());for(var r,o=i.clock.getDelta(),s=sA(i.updatables);!(r=s()).done;){r.value.tick(o)}i.animationId=requestAnimationFrame(t)};this.threeLayer.prepareToDraw=function(t,e,i){var n=new fb(16777215);n.position.set(0,-10,10).normalize(),e.add(n),r()},this.threeLayer.addTo(e),this.layerId=n,this.layerName=t,this.dirty=!1,this.initFlag=!1}var e=t.prototype;return e.getLayerId=function(){return this.layerId},e.changeLayerId=function(){if(this.threeLayer){var t=aA();this.threeLayer.setId(t),this.layerId=t}},e.setVisible=function(t,e){this.threeLayer&&(!0===t?(this.threeLayer.show(),e&&e()):(this.threeLayer.hide(),e&&e()))},e.prepareToDraw=function(){var t=this,e=function e(){var i,n;(t.threeLayer._needsUpdate=!t.threeLayer._needsUpdate,t.threeLayer._needsUpdate)&&(null==(i=t.threeLayer)||null==(n=i.getRenderer())||n.clearCanvas(),t.threeLayer.renderScene());for(var r,o=t.clock.getDelta(),s=sA(t.updatables);!(r=s()).done;){r.value.tick(o)}t.animationId=requestAnimationFrame(e)};return new Promise((function(i){t.threeLayer.prepareToDraw=function(t,n,r){var o=new fb(16777215);o.position.set(0,-10,10).normalize(),n.add(o),n.add(new mb(16777215)),e(),i()}}))},e.drawImage=function(t,e,i,n){var r=this;return new Promise((function(o){if(r.threeLayer.getScene()){var s=new cA(t,e,i,n,r.threeLayer);o(s)}else r.initFlag=!0,r.prepareToDraw().then((function(){var s=new cA(t,e,i,n,r.threeLayer);o(s)}))}))},e.dispose=function(){this.animationId&&cancelAnimationFrame(this.animationId);var t=this.threeLayer.getMeshes();this.threeLayer.clear(),t.forEach((function(t){}));var e=this.threeLayer.getCamera(),i=this.threeLayer.getScene(),n=this.threeLayer.getPick(),r=n.pickingTexture;n.pickingScene;var o=this.threeLayer.getRenderer();i.remove(e),e=null,i=null,r.dispose(),r=null,o.context.dispose(),o.context.forceContextLoss(),o.context=null,o.remove(),o=null,this.map.removeLayer(this.threeLayer)},t}();export{zS as BaseObject,KP as ThreeLayer,cA as imgClass,uA as layerClass};
|
|
17
|
+
function(t){var e=t/2,n=t+e,i=1e4,r=mn(2*n,2*n),o=r.getContext("2d");return o.shadowBlur=e,o.shadowColor="black",o.shadowOffsetX=o.shadowOffsetY=i,o.beginPath(),o.arc(n-i,n-i,t,0,2*Math.PI,!0),o.closePath(),o.fill(),r}(n._size||n.size||13),o=r.width/2,s=r.height/2,a=e,h={};for(var c in a.forEach((function(t){var e=void 0===t.count?1:t.count,n=Math.min(1,e/i).toFixed(2);h[n]=h[n]||[],h[n].push(t)})),h)if(!isNaN(c)){var l=h[c];t.beginPath(),n.withoutAlpha||(t.globalAlpha=c),l.forEach((function(e){var n=e.coordinate,a=void 0===e.count?1:e.count;t.globalAlpha=a/i,t.drawImage(r,n[0]-o,n[1]-s)}))}}Pn.prototype.setMax=function(t){this.max=t||100},Pn.prototype.setMin=function(t){this.min=t||0},Pn.prototype.setMaxSize=function(t){this.maxSize=t||35},Pn.prototype.setMinSize=function(t){this.minSize=t||0},Pn.prototype.initPalette=function(){var t=this.gradient,e=mn(256,1),n=this.paletteCtx=e.getContext("2d"),i=n.createLinearGradient(0,0,256,1);for(var r in t)i.addColorStop(parseFloat(r),t[r]);n.fillStyle=i,n.fillRect(0,0,256,1)},Pn.prototype.getColor=function(t){var e=this.getImageData(t);return"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]/256+")"},Pn.prototype.getImageData=function(t){var e=this.paletteCtx.getImageData(0,0,256,1).data;if(void 0===t)return e;var n=this.max,i=this.min;t>n&&(t=n),t<i&&(t=i);var r=4*Math.floor((t-i)/(n-i)*255);return[e[r],e[r+1],e[r+2],e[r+3]]},Pn.prototype.getSize=function(t){var e=this.max,n=this.min,i=this.maxSize,r=this.minSize;return t>e&&(t=e),t<n&&(t=n),e>n?r+(t-n)/(e-n)*(i-r):i},Pn.prototype.getLegend=function(t){var e=this.gradient,n=t.width||20,i=t.height||180,r=mn(n,i),o=r.getContext("2d"),s=o.createLinearGradient(0,i,0,0);for(var a in e)s.addColorStop(parseFloat(a),e[a]);return o.fillStyle=s,o.fillRect(0,0,n,i),r};var zn={draw:function(t,e,n){if(!(t.canvas.width<=0||t.canvas.height<=0)){var i=n.strength||.3;t.strokeStyle="rgba(0,0,0,"+i+")";var r=mn(t.canvas.width,t.canvas.height),o=r.getContext("2d");o.scale(devicePixelRatio,devicePixelRatio),n=n||{},t.save();var s=new Pn({gradient:n.gradient});if(Un(o,e,n),!n.absolute){var a=o.getImageData(0,0,t.canvas.width,t.canvas.height);Bn(a.data,s.getImageData(),n),t.putImageData(a,0,0),t.restore()}s=null,r=null}},drawGray:Un,colorize:Bn};const Fn={altitude:0,interactive:!1,min:0,max:100,size:13,gradient:{.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},gridScale:.5},Vn=2048;class Zn extends f{constructor(n,o,s,a){Array.isArray(n)||(n=[n]);let h=1/0,c=1/0,l=-1/0,u=-1/0;const d=[];for(let t=0,e=n.length;t<e;t++){const{coordinate:e,lnglat:i,xy:r}=n[t],o=e||i||r;if(!o){console.warn("not find coordinate");continue}const s=a.coordinateToVector3(o);d.push(s);const{x:p,y:f}=s;h=Math.min(h,p),c=Math.min(c,f),l=Math.max(l,p),u=Math.max(u,f)}o=t.Util.extend({},Fn,o,{layer:a,points:n});let{gridScale:p,altitude:f}=o;const g=Math.abs(l-h),y=Math.abs(u-c),x=Math.max(g*p,y*p);if(x>Vn){console.warn(`gridScale: ${p} it's too big. I hope it's a smaller value,canvas max size is 2048* 2048`);p=Vn/(x/p)}const m=Math.ceil(g*p),v=Math.ceil(y*p),b=m/g,_=v/y,w=[];for(let t=0,e=d.length;t<e;t++){const e=d[t];e.x-=h,e.y-=c,e.x*=b,e.y*=_,e.y=v-e.y,w.push({coordinate:[e.x,e.y],count:n[t].count})}let M=mn(m,v),A=M.getContext("2d");zn.drawGray(A,w,o);const O=A.getImageData(0,0,A.canvas.width,A.canvas.height);let j=-1/0;const T=new Float32Array(O.data.length/4),C=new Float32Array(O.data.length/4);for(let t=3,e=O.data.length,n=0;t<e;t+=4){const e=O.data[t];j=Math.max(j,e),C[n]=e,e<=0&&(T[n]=1),n++}const S=new Pn({gradient:o.gradient});zn.colorize(O.data,S.getImageData(),o),M=null,A=null;const L=wn(g,y,m-1,v-1),k=L.getIndex().array,I=L.attributes.position.array,P=new Float32Array(I.length),B=new Uint32Array(6*I.length),E=new e.Color;let U=0;for(let t=0,e=I.length,n=0,i=k.length,r=0,o=O.data.length,s=0;t<Math.max(e,i,o);t+=3){if(t<e){const e=C[s];e>0&&(I[t+2]=e/j)}if(n<i){const t=k[n],e=k[n+1],i=k[n+2];T[t]&&T[e]&&T[i]||(B[U]=t,B[U+1]=e,B[U+2]=i,U+=3)}if(r<o){const t=`rgb(${O.data[r]},${O.data[r+1]},${O.data[r+2]})`;E.setStyle(t),P[n]=E.r,P[n+1]=E.g,P[n+2]=E.b}n+=3,r+=4,s++}const z=new Uint32Array(U);for(let t=0;t<U;t++)z[t]=B[t];L.setIndex(new e.BufferAttribute(z,1)),i(L,"color",new e.BufferAttribute(P,3,!0)),s.vertexColors=r(),super(),this._initOptions(o),this._createMesh(L,s);const F=a.altitudeToVector3(f,f).x;this.getObject3d().position.copy(new e.Vector3((h+l)/2,(c+u)/2,F)),this.type="HeatMap"}}const Rn=new e.Color;let Gn=1;class Dn{constructor(t){this.object3ds=[],this.layer=t,this.camera=t.getCamera(),this.renderer=t.getThreeRenderer(),this.pickingTexture=new e.WebGLRenderTarget(1,1),this.pickingScene=new e.Scene}getColor(){return Rn.setHex(Gn),Gn++,Rn}add(t){if(t){const e=t._colorIndex;e&&(this.object3ds[e]=t,this.pickingScene.add(t))}return this}remove(t){if(t){const e=t._colorIndex;e&&(this.object3ds[e]=null,this.pickingScene.remove(t))}return this}isEmpty(){if(0===this.pickingScene.children.length)return!0;for(let t=0,e=this.pickingScene.children.length;t<e;t++){const e=this.pickingScene.children[t];if(e){const t=e.__parent;if(t&&!0===t.getOptions().interactive)return!1}}return!0}pick(t){if(!t)return;if(this.isEmpty())return;const{camera:e,renderer:n,pickingTexture:i,pickingScene:r,object3ds:o,layer:s}=this,a=this.pickingScene.children.length;for(let t=0;t<a;t++){const e=this.pickingScene.children[t];e&&e.__parent&&(e.__parent.picked=!1)}const{width:h,height:c}=s._getRenderer().canvas,l=i.width,u=i.height;h===l&&c===u||i.setSize(h,c),n.setRenderTarget(i),n.clear(),e&&e.layers&&this.camera.layers.set(0),n.render(r,e);const d=new Uint8Array(4),{x:p,y:f}=t;let g=window.devicePixelRatio;const y=s.getMap();y&&(g=y.getDevicePixelRatio?y.getDevicePixelRatio():y.options.devicePixelRatio);const x=p*g,m=i.height-f*g;n.readRenderTargetPixels(i,Math.round(x),Math.round(m),1,1,d);const v=d[0]<<16|d[1]<<8|d[2],b=o[v];if(b)b.__parent&&(o[v].__parent.picked=!0);else for(let t=0;t<a;t++){const e=this.pickingScene.children[t];if(e&&e.__parent){const t=e.__parent;if(t._colorMap&&null!=t._colorMap[v]){t.picked=!0,t.index=t._colorMap[v];break}}}n.setRenderTarget(null)}}const Hn={bottomHeight:0,altitude:0};class Qn extends f{constructor(e,n,i,r){n=t.Util.extend({},Hn,n,{layer:r,lineString:e}),super(),this._initOptions(n);const{asynchronous:o}=n,{lineStrings:s,center:a}=Bt(e),h=new l;let c;if(o){const n=t.Util.GUID();this.getOptions().id=n,this.getOptions().center=a,ie.push({id:n,data:s,lineString:e,center:a,layer:r,baseObject:this})}else{const t=[],e={};for(let i=0,o=s.length;i<o;i++){const o=Lt(s[i],r,a,!1).positions;vt(o,n.bottomHeight,r,e),t.push(Et(o))}c=Ut(t),h.setPositions(c)}this._setMaterialRes(r,i),this._createLine2(h,i);const{altitude:u}=n,d=r.altitudeToVector3(u,u).x,p=r.coordinateToVector3(a,d);this.getObject3d().position.copy(p),o||(this._setPickObject3d(c,i.linewidth),this._init()),this.type="FatLine"}_init(){const t=this.getLayer().getPick();this.on("add",(()=>{t.add(this.pickObject3d)})),this.on("remove",(()=>{t.remove(this.pickObject3d)}))}_setMaterialRes(t,e){const n=t.getMap().getSize(),i=n.width,r=n.height;e.resolution.set(i,r)}_setPickObject3d(t,e){const n=new l;n.setPositions(t);const i=this.getLayer().getPick().getColor(),o=[];for(let e=0,n=t.length/3;e<n;e++)o.push(i.r,i.g,i.b);n.setColors(o);const s=new h({color:"#fff",linewidth:e,vertexColors:r()});this._setMaterialRes(this.getLayer(),s);const a=i.getHex(),c=new u(n,s);c.position.copy(this.getObject3d().position),c._colorIndex=a,this.setPickObject3d(c)}identify(t){return this.picked}setSymbol(t){if(t&&t instanceof e.Material){t.needsUpdate=!0;const e=this.getMap().getSize(),n=e.width,i=e.height;t.resolution.set(n,i),this.getObject3d().material=t}return this}_workerLoad(t){const e=new Float32Array(t.position),n=this.getObject3d();if(n.geometry.setPositions(e),n.computeLineDistances(),this._setPickObject3d(e,n.material.linewidth),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const Wn={altitude:0,colors:null};class Nn extends(He(f)){constructor(e,n,i,r){Array.isArray(e)||(e=[e]);const o=[],s=[],a=e.length;for(let t=0;t<a;t++){const n=Bt(e[t]);o.push(n.center),s.push(n.lineStrings)}const h=mt(o);n=t.Util.extend({},Wn,n,{layer:r,lineStrings:e,coordinate:h}),super(),this._initOptions(n);const{asynchronous:c}=n,u=new l,d=[],p={};let f,g,y=[],x=0,m=[];if(c)re.push({id:t.Util.GUID(),data:s,key:n.key,center:h,layer:r,baseObject:this,lineStrings:e});else{for(let t=0;t<a;t++){const e=s[t];let n=0;for(let t=0,i=e.length;t<i;t++){const i=v(e[t])?e[t].properties:e[t].getProperties()||{},{positions:o}=Lt(e[t],r,h,!1);vt(o,i.bottomHeight,r,p),n+=o.length/3*2-2,m.push(Et(o))}y[t]={position:{count:n,start:x,end:x+3*n},instanceStart:{count:n,start:x,end:x+3*n},instanceEnd:{count:n,start:x,end:x+3*n},hide:!1},x+=3*n}f=Ut(m),u.setPositions(f)}this._setMaterialRes(r,i),this._createLine2(u,i);const{altitude:b}=n,_=r.altitudeToVector3(b,b).x,w=r.coordinateToVector3(h,_);this.getObject3d().position.copy(w),this._baseObjects=d,this._datas=e,this._geometriesAttributes=y,this.faceIndex=null,this.index=null,this._geometryCache=new l,c||(g=new Float32Array(f),this._geometryCache.setPositions(g)),this._colorMap={},this.isHide=!1,this._initBaseObjectsEvent(d),c||(this._setPickObject3d(g,i.linewidth),this._init()),this.type="FatLines"}_setMaterialRes(t,e){const n=t.getMap().getSize(),i=n.width,r=n.height;e.resolution.set(i,r)}_setPickObject3d(t,e){if(!this._colorMap)return;const n=this._geometryCache||new l;n.setPositions(t);const i=this.getLayer().getPick(),{_geometriesAttributes:o}=this,s=bt(o);let a=0;for(let t=0,e=o.length;t<e;t++){const e=i.getColor(),n=e.getHex();this._colorMap[n]=t;const{count:r}=o[t].position;this._datas[t].colorIndex=n;for(let t=0;t<r;t++)s[a]=e.r,s[a+1]=e.g,s[a+2]=e.b,a+=3}n.setColors(s);const c=new h({color:"#fff",linewidth:e,vertexColors:r()});this._setMaterialRes(this.getLayer(),c);const d=i.getColor().getHex(),p=new u(n,c);p.position.copy(this.getObject3d().position),p._colorIndex=d,this.setPickObject3d(p)}identify(t){return this.picked}setSymbol(t){if(t&&t instanceof e.Material){t.needsUpdate=!0;const e=this.getMap().getSize(),n=e.width,i=e.height;t.resolution.set(n,i),this.getObject3d().material=t}return this}getSelectMesh(){const e=this._getIndex();if(null!=e){if(!this._baseObjects[e]){const n=this._datas[e],i=t.Util.extend({},this.getOptions(),{index:e},v(n)?n.properties:n.getProperties());this._baseObjects[e]=new Qn(n,i,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[e])}return{data:this._datas[e],baseObject:this._baseObjects[e]}}}_updateAttribute(t,e){const{indexs:n}=this._getHideGeometryIndex(e),i=this._geometryCache.attributes[e].array,r=i.length;for(let e=0;e<r;e++)t.array[e]=i[e];for(let i=0;i<n.length;i++){const r=n[i],{start:o,end:s}=this._geometriesAttributes[r][e];for(let e=o;e<s;e++)t.array[e]=-1e5}return this}_showGeometry(t,e){let n;if(t&&(n=t.getOptions().index),null!=n){const t=this._geometriesAttributes[n],{hide:i}=t;if(i===e)return this;t.hide=e;const r=this.getObject3d().geometry;this._updateAttribute(r.attributes.instanceStart,"instanceStart"),this._updateAttribute(r.attributes.instanceEnd,"instanceEnd"),r.attributes.instanceStart.data.needsUpdate=!0,r.attributes.instanceEnd.data.needsUpdate=!0,this.isHide=e}return this}_workerLoad(t){const{geometriesAttributes:e}=t;this._geometriesAttributes=e;const n=this.getObject3d(),i=new Float32Array(t.position),r=new Float32Array(i);if(n.geometry.setPositions(new Float32Array(i)),this._geometryCache.setPositions(r),this._setPickObject3d(r,n.material.linewidth),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const Kn={radius:10,height:100,altitude:0,topColor:"",bottomColor:"#2d2f61",heightEnable:!0};class qn extends f{constructor(e,n,i,o){n=t.Util.extend({},Kn,n,{layer:o,coordinate:e}),super(),this._initOptions(n);const{height:s,radius:a,topColor:h,bottomColor:c,altitude:l}=n,u=o.altitudeToVector3(s,s).x,d=o.distanceToVector3(a,a).x,p=we().clone();p.scale(2*d,2*d,u),h&&(be(p,c,h,"z",u/2),i.vertexColors=r()),this._createMesh(p,i);const f=o.altitudeToVector3(l,l).x,g=o.coordinateToVector3(e,f);this.getObject3d().position.copy(g),this.type="Box"}}const $n={radius:10,height:100,altitude:0,topColor:null,bottomColor:"#2d2f61"};class Yn extends(He(f)){constructor(e,n,i,o){Array.isArray(e)||(e=[e]);const s=e.length,a=mt(e),h=o.coordinateToVector3(a),c=[],l=[],u=[];let d=0;const p={},f={};for(let n=0;n<s;n++){const s=t.Util.extend({index:n},$n,e[n]),{radius:a,altitude:g,topColor:y,bottomColor:x,height:m,coordinate:v}=s,b=yt(a,o,p),_=xt(m,o,f),w=xt(g,o,f),M=we().clone();M.scale(2*b,2*b,_),y&&(be(M,x,y,"z",_/2),i.vertexColors=r());const A=o.coordinateToVector3(v).sub(h),O=M.attributes.position.array;for(let t=0,e=O.length;t<e;t+=3)O[t+2]+=w,O[t]+=A.x,O[t+1]+=A.y,O[t+2]+=A.z;c.push(M);const j=new qn(v,s,i,o);l.push(j),M.index.count;const T=M.attributes.position.count;M.attributes.normal.count,M.attributes.uv.count,u[n]={position:{count:T,start:d,end:d+3*T},hide:!1},d+=3*T}super(),n=t.Util.extend({},{altitude:0,layer:o,points:e},n),this._initOptions(n);const g=_e(c);this._createMesh(g,i);const y=n.altitude,x=o.altitudeToVector3(y,y).x,m=h.clone();m.z=x,this.getObject3d().position.copy(m),this._baseObjects=l,this._datas=e,this._geometriesAttributes=u,this.faceIndex=null,this._geometryCache=de(g),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(l),this._setPickObject3d(),this._init(),this.type="Boxs"}identify(t){return this.picked}}var Xn={exports:{}};function Jn(t,e,n){n=n||2;var i,r,o,s,a,h,c,l=e&&e.length,u=l?e[0]*n:t.length,d=ti(t,0,u,n,!0),p=[];if(!d||d.next===d.prev)return p;if(l&&(d=function(t,e,n,i){var r,o,s,a=[];for(r=0,o=e.length;r<o;r++)(s=ti(t,e[r]*i,r<o-1?e[r+1]*i:t.length,i,!1))===s.next&&(s.steiner=!0),a.push(ui(s));for(a.sort(ai),r=0;r<a.length;r++)n=hi(a[r],n);return n}(t,e,d,n)),t.length>80*n){i=o=t[0],r=s=t[1];for(var f=n;f<u;f+=n)(a=t[f])<i&&(i=a),(h=t[f+1])<r&&(r=h),a>o&&(o=a),h>s&&(s=h);c=0!==(c=Math.max(o-i,s-r))?32767/c:0}return ni(d,p,n,i,r,c,0),p}function ti(t,e,n,i,r){var o,s;if(r===Ai(t,e,n,i)>0)for(o=e;o<n;o+=i)s=_i(o,t[o],t[o+1],s);else for(o=n-i;o>=e;o-=i)s=_i(o,t[o],t[o+1],s);return s&&gi(s,s.next)&&(wi(s),s=s.next),s}function ei(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!gi(i,i.next)&&0!==fi(i.prev,i,i.next))i=i.next;else{if(wi(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function ni(t,e,n,i,r,o,s){if(t){!s&&o&&function(t,e,n,i){var r=t;do{0===r.z&&(r.z=li(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,h,c=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e<c&&(a++,i=i.nextZ);e++);for(h=c;a>0||h>0&&i;)0!==a&&(0===h||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,c*=2}while(s>1)}(r)}(t,i,r,o);for(var a,h,c=t;t.prev!==t.next;)if(a=t.prev,h=t.next,o?ri(t,i,r,o):ii(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(h.i/n|0),wi(t),t=h.next,c=h.next;else if((t=h)===c){s?1===s?ni(t=oi(ei(t),e,n),e,n,i,r,o,2):2===s&&si(t,e,n,i,r,o):ni(ei(t),e,n,i,r,o,1);break}}}function ii(t){var e=t.prev,n=t,i=t.next;if(fi(e,n,i)>=0)return!1;for(var r=e.x,o=n.x,s=i.x,a=e.y,h=n.y,c=i.y,l=r<o?r<s?r:s:o<s?o:s,u=a<h?a<c?a:c:h<c?h:c,d=r>o?r>s?r:s:o>s?o:s,p=a>h?a>c?a:c:h>c?h:c,f=i.next;f!==e;){if(f.x>=l&&f.x<=d&&f.y>=u&&f.y<=p&&di(r,a,o,h,s,c,f.x,f.y)&&fi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ri(t,e,n,i){var r=t.prev,o=t,s=t.next;if(fi(r,o,s)>=0)return!1;for(var a=r.x,h=o.x,c=s.x,l=r.y,u=o.y,d=s.y,p=a<h?a<c?a:c:h<c?h:c,f=l<u?l<d?l:d:u<d?u:d,g=a>h?a>c?a:c:h>c?h:c,y=l>u?l>d?l:d:u>d?u:d,x=li(p,f,e,n,i),m=li(g,y,e,n,i),v=t.prevZ,b=t.nextZ;v&&v.z>=x&&b&&b.z<=m;){if(v.x>=p&&v.x<=g&&v.y>=f&&v.y<=y&&v!==r&&v!==s&&di(a,l,h,u,c,d,v.x,v.y)&&fi(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,b.x>=p&&b.x<=g&&b.y>=f&&b.y<=y&&b!==r&&b!==s&&di(a,l,h,u,c,d,b.x,b.y)&&fi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;v&&v.z>=x;){if(v.x>=p&&v.x<=g&&v.y>=f&&v.y<=y&&v!==r&&v!==s&&di(a,l,h,u,c,d,v.x,v.y)&&fi(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=m;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=y&&b!==r&&b!==s&&di(a,l,h,u,c,d,b.x,b.y)&&fi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function oi(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;!gi(r,o)&&yi(r,i,i.next,o)&&vi(r,o)&&vi(o,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),wi(i),wi(i.next),i=t=o),i=i.next}while(i!==t);return ei(i)}function si(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&pi(s,a)){var h=bi(s,a);return s=ei(s,s.next),h=ei(h,h.next),ni(s,e,n,i,r,o,0),void ni(h,e,n,i,r,o,0)}a=a.next}s=s.next}while(s!==t)}function ai(t,e){return t.x-e.x}function hi(t,e){var n=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}i=i.next}while(i!==e);if(!n)return null;var h,c=n,l=n.x,u=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=l&&r!==i.x&&di(o<u?r:s,o,l,u,o<u?s:r,o,i.x,i.y)&&(h=Math.abs(o-i.y)/(r-i.x),vi(i,t)&&(h<d||h===d&&(i.x>n.x||i.x===n.x&&ci(n,i)))&&(n=i,d=h)),i=i.next}while(i!==c);return n}(t,e);if(!n)return e;var i=bi(n,t);return ei(i,i.next),ei(n,n.next)}function ci(t,e){return fi(t.prev,t,e.prev)<0&&fi(e.next,t,t.next)<0}function li(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ui(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function di(t,e,n,i,r,o,s,a){return(r-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(i-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function pi(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&yi(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(vi(t,e)&&vi(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(fi(t.prev,t,e.prev)||fi(t,e.prev,e))||gi(t,e)&&fi(t.prev,t,t.next)>0&&fi(e.prev,e,e.next)>0)}function fi(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function gi(t,e){return t.x===e.x&&t.y===e.y}function yi(t,e,n,i){var r=mi(fi(t,e,n)),o=mi(fi(t,e,i)),s=mi(fi(n,i,t)),a=mi(fi(n,i,e));return r!==o&&s!==a||(!(0!==r||!xi(t,n,e))||(!(0!==o||!xi(t,i,e))||(!(0!==s||!xi(n,t,i))||!(0!==a||!xi(n,e,i)))))}function xi(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function mi(t){return t>0?1:t<0?-1:0}function vi(t,e){return fi(t.prev,t,t.next)<0?fi(t,e,t.next)>=0&&fi(t,t.prev,e)>=0:fi(t,e,t.prev)<0||fi(t,t.next,e)<0}function bi(t,e){var n=new Mi(t.i,t.x,t.y),i=new Mi(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function _i(t,e,n,i){var r=new Mi(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function wi(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Mi(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ai(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}Xn.exports=Jn,Xn.exports.default=Jn,Jn.deviation=function(t,e,n,i){var r=e&&e.length,o=r?e[0]*n:t.length,s=Math.abs(Ai(t,0,o,n));if(r)for(var a=0,h=e.length;a<h;a++){var c=e[a]*n,l=a<h-1?e[a+1]*n:t.length;s-=Math.abs(Ai(t,c,l,n))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*n,p=i[a+1]*n,f=i[a+2]*n;u+=Math.abs((t[d]-t[f])*(t[p+1]-t[d+1])-(t[d]-t[p])*(t[f+1]-t[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},Jn.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);r>0&&(i+=t[r-1].length,n.holes.push(i))}return n};const Oi=Math.PI/180,ji=[[4e3,220],[2e3,100],[1e3,30],[500,15],[100,5],[50,2],[10,1],[5,.7],[2,.1],[1,.05],[.5,.02],[.4,.01],[.1,.005],[.05,.002],[.01,.001]],Ti=["mouseout","mousemove","click","mousedown","mouseup","dblclick","contextmenu","touchstart","touchmove","touchend"],Ci=new t.Coordinate(0,0),Si=new t.Point(0,0),Li="__webglFramebuffer";class ki extends t.CanvasLayer{constructor(t,e){super(t,e),this._animationBaseObjectMap={},this._needsUpdate=!0,this._mousemoveTimeOut=0,this._mousedownTime=0,this._baseObjects=[],this._delayMeshes=[],this.type="ThreeLayer"}isMercator(){const t=this.getMap();if(!t)return!1;const e=t.getSpatialReference(),n=e._projection,i=e._resolutions;return!!(n&&"EPSG:3857"===n.code&&i&&i.length&&156543===Math.floor(i[0])&&t.getGLRes)}isRendering(){const t=this.getMap();return!!t&&(t.isInteracting()||t.isAnimating())}prepareToDraw(...t){}draw(t,e,n,i,r,o){this.renderScene(o,this)}drawOnInteracting(t,e,n,i,r,o,s){this.renderScene(s,this)}coordinateToVector3(n,i=0,r){const o=this.getMap();if(!o)return null;const s=Array.isArray(n);s?(Ci.x=n[0],Ci.y=n[1]):n instanceof t.Coordinate||(n=new t.Coordinate(n));const a=Ei(o),h=Ui(o,s?Ci:n,a,Si);return r&&(r.x=h.x,r.y=h.y,r.z=i),new e.Vector3(h.x,h.y,i)}coordinatiesToGLFloatArray(e,n){const i=this.getMap();if(!i)return null;const r=Ei(i),o=e.length,s=new Float32Array(2*o),a=new Float32Array(3*o);for(let h=0;h<o;h++){let o=e[h];const c=Array.isArray(o);c?(Ci.x=o[0],Ci.y=o[1]):o instanceof t.Coordinate||(o=new t.Coordinate(o));const l=Ui(i,c?Ci:o,r,Si);l.x-=n.x,l.y-=n.y;const u=2*h;s[u]=l.x,s[u+1]=l.y;const d=3*h;a[d]=l.x,a[d+1]=l.y,a[d+2]=0}return{positions:a,positons2d:s}}coordinatiesToGLArray(e,n){const i=this.getMap();if(!i)return null;const r=Ei(i),o=e.length,s=new Array(o);for(let a=0;a<o;a++){let o=e[a];const h=Array.isArray(o);h?(Ci.x=o[0],Ci.y=o[1]):o instanceof t.Coordinate||(o=new t.Coordinate(o));const c=Ui(i,h?Ci:o,r,Si);c.x-=n.x,c.y-=n.y,s[a]=[c.x,c.y]}return s}distanceToVector3(n,i,r){if(0===n&&0===i||!t.Util.isNumber(n)||!t.Util.isNumber(i))return new e.Vector3(0,0,0);const o=this.getMap(),s=Ei(o);let a=r||o.getCenter();a instanceof t.Coordinate||(a=new t.Coordinate(a));const h=o.locate(a,n,i),c=Ui(o,a,s),l=Ui(o,h,s),u=Math.abs(l.x-c.x)*t.Util.sign(n),d=Math.abs(l.y-c.y)*t.Util.sign(i);return new e.Vector3(u,d,0)}altitudeToVector3(n,i,r,o){if(0===n||!t.Util.isNumber(n))return new e.Vector3(0,0,0);const s=this.getMap();if(s.altitudeToPoint){const t=Ei(s);let i=s.altitudeToPoint(n,t);return n<0&&i>0&&(i=-i),o?(o.x=i,o.y=i,o.z=0,o):new e.Vector3(i,i,0)}return this.distanceToVector3(n,n,r)}toShape(n){if(!n)return null;if(n instanceof t.MultiPolygon)return n.getGeometries().map((t=>this.toShape(t)));const i=n.getCenter(),r=this.coordinateToVector3(i),o=n.getShell().map((t=>{const n=this.coordinateToVector3(t).sub(r);return new e.Vector2(n.x,n.y)})),s=new e.Shape(o),a=n.getHoles();return a&&a.length>0&&(s.holes=a.map((t=>{const n=t.map((t=>{const n=this.coordinateToVector3(t).sub(r);return new e.Vector2(n.x,n.y)}));return new e.Shape(n)}))),s}toExtrudeMesh(n,i,r,o){if(!n)return null;if(n instanceof t.MultiPolygon)return n.getGeometries().map((t=>this.toExtrudeMesh(t,i,r,o)));const s=n.getCoordinates();s.forEach((t=>{for(let e=t.length-1;e>=1;e--)t[e].equals(t[e-1])&&t.splice(e,1)})),n.setCoordinates(s);const a=this.toShape(n),h=this.coordinateToVector3(n.getCenter());o=t.Util.isNumber(o)?o:i,o=this.altitudeToVector3(o,o).x;const c=this.altitudeToVector3(i,i).x,l={bevelEnabled:!1,bevelSize:1};l[parseInt(e.REVISION)>=93?"depth":"amount"]=o;const u=new e.ExtrudeGeometry(a,l);let d=u;e.BufferGeometry.prototype.fromGeometry&&(d=new e.BufferGeometry,d.fromGeometry(u));const p=new e.Mesh(d,r);return p.position.set(h.x,h.y,c-o),p}toExtrudePolygon(t,e,n){return new ke(t,e,n,this)}toBar(t,e,n){return new Ae(t,e,n,this)}toLine(t,e,n){return new Te(t,e,n,this)}toExtrudeLine(t,e,n){return new Se(t,e,n,this)}toModel(t,e){return new Pe(t,e,this)}toExtrudeLineTrail(t,e,n){return new Re(t,e,n,this)}toExtrudePolygons(t,e,n){return new Ne(t,e,n,this)}toPoint(t,e,n){return new Ye(t,e,n,this)}toPoints(t,e,n){return new rn(t,e,n,this)}toBars(t,e,n){return new sn(t,e,n,this)}toExtrudeLines(t,e,n){return new hn(t,e,n,this)}toLines(t,e,n){return new ln(t,e,n,this)}toThreeVectorTileLayer(t,e,n){return new _n(t,e,n,this)}toTerrain(t,e,n){return new Ln(t,e,n,this)}toTerrainVectorTileLayer(t,e,n){return new In(t,e,n,this)}toHeatMap(t,e,n){return new Zn(t,e,n,this)}toFatLine(t,e,n){return new Qn(t,e,n,this)}toFatLines(t,e,n){return new Nn(t,e,n,this)}toBox(t,e,n){return new qn(t,e,n,this)}toBoxs(t,e,n){return new Yn(t,e,n,this)}getBaseObjects(){return this.getMeshes().filter((t=>t instanceof f))}getMeshes(){const t=this.getScene();if(!t)return[];const n=[];for(let i=0,r=t.children.length;i<r;i++){const r=t.children[i];r instanceof e.Object3D&&!(r instanceof e.Camera)&&n.push(r.__parent||r)}return n}clear(){return this.clearMesh()}clearMesh(){const t=this.getScene();if(!t)return this;for(let n=t.children.length-1;n>=0;n--){const i=t.children[n];if(i instanceof e.Object3D&&!(i instanceof e.Camera)){t.remove(i);const e=i.__parent;e&&e instanceof f&&(e.isAdd=!1,e.options.layer=null,e._fire("remove",{target:e}),delete this._animationBaseObjectMap[i.uuid],e._hideUI())}}return this}lookAt(t){const e=this._getRenderer();return e&&e.context.lookAt(t),this}getCamera(){const t=this._getRenderer();return t?t.camera:null}getScene(){const t=this._getRenderer();return t?t.scene:null}renderScene(t,e){const n=this._getRenderer();return n&&(n.clearCanvas(),n.renderScene(t),e||n.setToRedraw()),this}loop(t=!1){const e=this._delayMeshes;if(!e.length)return;const n=this.getMap();if(!n||n.isAnimating()||n.isInteracting())return;const i=this.options.loopRenderCount||50,r=e.slice(0,i);r&&this.addMesh(r,t),e.splice(0,i)}renderPickScene(){const t=this._getRenderer();if(t){const e=t.pick;e&&e.pick(this._containerPoint)}return this}getThreeRenderer(){const t=this._getRenderer();return t?t.context:null}getPick(){const t=this._getRenderer();return t?t.pick:null}delayAddMesh(t){if(!t)return this;Array.isArray(t)||(t=[t]);for(let e=0,n=t.length;e<n;e++)this._delayMeshes.push(t[e]);return this}addMesh(n,i=!0){if(!n)return this;Array.isArray(n)||(n=[n]);const r=this.getScene();if(n.forEach((n=>{n instanceof f?(r.add(n.getObject3d()),n.isAdd||(n.isAdd=!0,n.options.layer=this,n._fire("add",{target:n})),n._animation&&t.Util.isFunction(n._animation)&&(this._animationBaseObjectMap[n.getObject3d().uuid]=n)):n instanceof e.Object3D&&r.add(n)})),this._zoomend(),i){const t=this._getRenderer();t&&t.setToRedraw()}return this}removeMesh(n,i=!0){if(!n)return this;Array.isArray(n)||(n=[n]);const r=this.getScene();if(n.forEach((n=>{if(n instanceof f){r.remove(n.getObject3d()),n.isAdd&&(n.isAdd=!1,n.options.layer=null,n._fire("remove",{target:n}),n._hideUI()),n._animation&&t.Util.isFunction(n._animation)&&delete this._animationBaseObjectMap[n.getObject3d().uuid];const e=this._delayMeshes;if(e.length)for(let t=0,i=e.length;t<i;t++)if(e[t]===n){e.splice(t,1);break}}else n instanceof e.Object3D&&r.remove(n)})),i){const t=this._getRenderer();t&&t.setToRedraw()}return this}_initRaycaster(){return this._raycaster||(this._raycaster=new e.Raycaster,this._mouse=new e.Vector2),this}getRaycaster(){return this._raycaster}identify(i,r){if(!i)return console.error("coordinate is null,it should be Coordinate"),[];if(Array.isArray(i)&&(i=new t.Coordinate(i)),!(i instanceof t.Coordinate))return console.error("coordinate type is error,it should be Coordinate"),[];const o=this.getMap().coordToContainerPoint(i);this._containerPoint=o;const{x:s,y:a}=o;this._initRaycaster(),this.fire("identify",{coordinate:i,options:r});const h=this._raycaster,c=this._mouse,l=this.getCamera(),u=this.getScene(),d=this.getMap().getSize();if(!u)return[];const p=d.width,g=d.height;c.x=s/p*2-1,c.y=-a/g*2+1,h.setFromCamera(c,l),h.layers&&h.layers.enableAll&&h.layers.enableAll(),function(t,e){n>113?t.params.Line.threshold=e:t.linePrecision=e}(h,this._getLinePrecision(this.getMap().getResolution()));const y=[],x=[];u.children.forEach((n=>{const i=n.__parent;if(i&&i.getOptions){const e=i;e.getOptions().interactive&&e.isVisible()&&(e.identify&&t.Util.isFunction(e.identify)?x.push(e):y.push(n))}else(n instanceof e.Mesh||n instanceof e.Group)&&y.push(n)}));let m=[];const v=h.intersectObjects(y,!0);v&&Array.isArray(v)&&v.length&&(m=v.map((e=>{let n=e.object;const i=e.instanceId;n=this._recursionMesh(n)||{};const r=n.__parent||n;return r.faceIndex=e.faceIndex,r.index=e.index,r.intersect=e,t.Util.isNumber(i)&&(r.instanceId=i),r}))),this.renderPickScene(),x.length&&x.forEach((t=>{t.identify(i)&&m.push(t)}));const b=m.length;for(let t=0;t<b;t++)if(m[t])for(let e=t+1;e<b;e++)m[t]===m[e]&&m.splice(e,1);let _=m.filter((t=>t instanceof f));_=_.sort(((t,e)=>t.options.pickWeight-e.options.pickWeight)),m.forEach((t=>{t instanceof f||_.push(t)}));const w=(r=t.Util.extend({},r)).count;return t.Util.isNumber(w)&&w>0?_.slice(0,w):m}_recursionMesh(t){for(;t&&t.parent!==this.getScene();)t=t.parent;return t}_getLinePrecision(t=10){for(let e=0,n=ji.length;e<n;e++){const[n,i]=ji[e];if(t>n)return i}return.01}_identifyBaseObjectEvents(e){if(!this.options.geometryEvents)return this;const n=this.map||this.getMap();if(n.isInteracting()||!n.options.geometryEvents||n._ignoreEvent(e))return this;const i=e.type,r=n._getEventParams?n._getEventParams(e):this._getEventParams(e);r.type=i;const{type:o,coordinate:s}=r,a=t.Util.now();if(this._mousemoveTimeOut&&"mousemove"===o&&a-this._mousemoveTimeOut<64)return this;this._mousemoveTimeOut=a,"mousedown"!==o&&"touchstart"!==o||(this._mousedownTime=t.Util.now());let h=!1;if("click"===o||"touchend"===o){const e=n.options.clickTimeThreshold||280;h=t.Util.now()-this._mousedownTime<e}if("click"===o&&!h)return this;const c=this.options.identifyCountOnEvent;let l=Math.max(0,t.Util.isNumber(c)?c:0);0===l&&(l=1/0);const u=t=>{const e=[];this._baseObjects&&this._baseObjects.forEach((n=>{let i=!0;t.forEach((t=>{n===t&&(i=!1)})),i&&e.push(n)})),e.forEach((t=>{t&&t instanceof f&&(t.getSelectMesh?t.isHide||(t._mouseover=!1,t.fire("mouseout",Object.assign({},r,{target:t,type:"mouseout",selectMesh:null})),t.closeToolTip()):(t._mouseover=!1,t.fire("mouseout",Object.assign({},r,{target:t,type:"mouseout"})),t.closeToolTip()))}))};if("mouseout"===o)return u([]),this._baseObjects=[],this;const d=this.identify(s,{count:l}),p=this.getScene();if(0===d.length&&p)for(let t=0,e=p.children.length;t<e;t++){const e=(p.children[t]||{}).__parent;e&&e.fire("empty",Object.assign({},r,{target:e}))}function g(t,e){e=e||o;const n=t.getInfoWindow();n&&!n._owner&&n.addTo(t);((n?n.options:{}).autoOpenOn||"click")===e&&(t.openInfoWindow(s),t.fire("showinfowindow",{infoWindow:n}))}if("mousemove"===o?(u(d),d.forEach((t=>{if(t instanceof f){t._mouseover||(t.fire("mouseover",Object.assign({},r,{target:t,type:"mouseover",selectMesh:t.getSelectMesh?t.getSelectMesh():null})),t._mouseover=!0,g(t,"mouseover")),t.fire(o,Object.assign({},r,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null}));const e=t.getToolTip();e&&!e._owner&&e.addTo(t),t.openToolTip(s),g(t)}})),this._baseObjects=d):d.forEach((t=>{t instanceof f&&(t.fire(o,Object.assign({},r,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null})),g(t))})),"touchend"===o&&h){const n=t.Util.extend({},r,{domEvent:e});d.forEach((t=>{t instanceof f&&(t.fire("click",Object.assign({},n,{target:t,selectMesh:t.getSelectMesh?t.getSelectMesh():null})),g(t,"click"))}))}return this}_getEventParams(e){const n=this.getMap(),i={domEvent:e};if(!n)return i;const r=e.touches&&e.touches.length>0?e.touches[0]:e.changedTouches&&e.changedTouches.length>0?e.changedTouches[0]:e;if(r){const e=(0,t.DomUtil.getEventContainerPoint)(r,n._containerDOM);i.coordinate=n.containerPointToCoordinate(e),i.containerPoint=e,i.viewPoint=n.containerPointToViewPoint(e),i.pont2d=n._containerPointToPoint(e)}return i}_zoomend(){const e=this.getScene();if(!e)return;const n=this.getMap().getZoom();e.children.forEach((e=>{const i=e.__parent;if(i&&i.getOptions){const e=i;e.zoomChange&&t.Util.isFunction(e.zoomChange)&&e.zoomChange(n);const r=e.getMinZoom(),o=e.getMaxZoom();n<r||n>o?(e.isVisible()&&(e.getObject3d().visible=!1),e._zoomVisible=!1):r<=n&&n<=o&&(e._visible&&(e.getObject3d().visible=!0),e._zoomVisible=!0)}}))}_getGeometryEventMapPanel(){const t=this.map||this.getMap();return t._panels.allLayers||t._containerDOM}onAdd(){super.onAdd();const e=this.map||this.getMap();if(!e)return this;const n=this._getGeometryEventMapPanel();return this._identifyBaseObjectEventsThis||(this._identifyBaseObjectEventsThis=this._identifyBaseObjectEvents.bind(this)),this._zoomendThis||(this._zoomendThis=this._zoomend.bind(this)),t.DomUtil.on(n,Ti.join(" "),this._identifyBaseObjectEventsThis,this),this._needsUpdate=!0,this._animationBaseObjectMap||(this._animationBaseObjectMap={}),e.on("zooming zoomend",this._zoomendThis,this),this}onRemove(){super.onRemove();const e=this.map||this.getMap();if(!e)return this;const n=this._getGeometryEventMapPanel();return t.DomUtil.off(n,Ti.join(" "),this._identifyBaseObjectEventsThis,this),e.off("zooming zoomend",this._zoomendThis,this),this.clear(),this}_callbackBaseObjectAnimation(){const t=this;if(t._animationBaseObjectMap)for(const e in t._animationBaseObjectMap){t._animationBaseObjectMap[e]._animation()}return this}_getFovRatio(){const t=this.getMap().getFov();return Math.tan(t/2*Oi)}}ki.mergeOptions({renderer:"gl",doubleBuffer:!1,glOptions:null,geometryEvents:!0,identifyCountOnEvent:0,forceRenderOnZooming:!0,loopRenderCount:50});const Ii={bloom:!0};class Pi extends t.renderer.CanvasLayerRenderer{constructor(){super(...arguments),this._renderTime=0,this._renderTarget=null}getPrepareParams(){return[this.scene,this.camera]}getDrawParams(){return[this.scene,this.camera]}_drawLayer(){super._drawLayer.apply(this,arguments)}hitDetect(){return!1}createCanvas(){super.createCanvas(),this.createContext()}createContext(){if(this.canvas.gl&&this.canvas.gl.wrap)this.gl=this.canvas.gl.wrap();else{const t=this.layer.options.glOptions||{alpha:!0,depth:!0,antialias:!0,stencil:!0,preserveDrawingBuffer:!1};t.preserveDrawingBuffer=!0,this.gl=this.gl||this._createGLContext(this.canvas,t)}this._initThreeRenderer(),this.layer.onCanvasCreate(this.context,this.scene,this.camera)}_initThreeRenderer(){this.matrix4=new e.Matrix4;const t=new e.WebGLRenderer({context:this.gl,alpha:!0});t.autoClear=!1,t.setClearColor(new e.Color(1,1,1),0),t.setSize(this.canvas.width,this.canvas.height),t.clear(),this.context=t;const n=this.scene=new e.Scene,i=this.layer.getMap(),r=i.getFov()*Math.PI/180,o=this.camera=new e.PerspectiveCamera(r,i.width/i.height,i.cameraNear,i.cameraFar);o.matrixAutoUpdate=!1,this._syncCamera(),n.add(o),this.pick=new Dn(this.layer),ae.star()}onCanvasCreate(){super.onCanvasCreate()}resizeCanvas(e){if(!this.canvas)return;let n,i=this.getMap();n=e||i.getSize();const r=i.getDevicePixelRatio?i.getDevicePixelRatio():t.Browser.retina?2:1,o=this.canvas,{width:s,height:a,cssWidth:h,cssHeight:c}=t.Util.calCanvasSize(n,r);if(!this.layer._canvas||o.style.width===h&&o.style.height===c||(o.style.width=h,o.style.height=c),o.width===s&&o.height===a)return this;o.width=s,o.height=a,this.context.setSize(o.width,o.height)}clearCanvas(){this.canvas&&this.context.clear()}prepareCanvas(){return this.canvas?this.clearCanvas():this.createCanvas(),this.layer.fire("renderstart",{context:this.context}),null}renderScene(t){if(this.layer._callbackBaseObjectAnimation(),this._syncCamera(),t&&t.renderTarget){const{width:n,height:i}=t.renderTarget.fbo;this._renderTarget?(this._renderTarget.viewport.set(0,0,n,i),this._renderTarget.scissor.set(0,0,n,i)):(this._renderTarget=new e.WebGLRenderTarget(n,i,{depthBuffer:!1}),this.context.setRenderTarget(this._renderTarget),this.context.render(this.scene,this.camera));const r=this.context.properties.get(this._renderTarget),o=r[Li];r[Li]=t.renderTarget.getFramebuffer(t.renderTarget.fbo),this.context.setRenderTarget(this._renderTarget);const s=1===t.bloom&&t.sceneFilter,a=this.scene.children||[];let h=!1;if(s){const e=t.sceneFilter;h=e(Ii);for(let t=0,n=a.length;t<n;t++){if(!a[t]||!a[t].layers)continue;const n=a[t].__parent;a[t].bloom=!1,n&&(a[t].bloom=n.bloom);let i=0;(a[t]&&e(a[t])||!n)&&h&&(i=1),a[t].__layer!==i&&(Bi(a[t],i),a[t].__layer=i)}}else for(let t=0,e=a.length;t<e;t++)a[t]&&a[t].layers&&0!==a[t].__layer&&(Bi(a[t],0),a[t].__layer=0);this.camera.layers.set(h?1:0),this.context.render(this.scene,this.camera),r[Li]=o}else this.context.render(this.scene,this.camera);this.context.setRenderTarget(null),this.completeRender()}remove(){delete this._drawContext,this._renderTarget&&(this._renderTarget.dispose(),delete this._renderTarget),super.remove()}_syncCamera(){const t=this.getMap(),e=this.camera;e.matrix.elements=t.cameraWorldMatrix,e.projectionMatrix.elements=t.projMatrix,this.matrix4.invert?e.projectionMatrixInverse.elements=this.matrix4.copy(e.projectionMatrix).invert().elements:e.projectionMatrixInverse&&(e.projectionMatrixInverse.elements=this.matrix4.getInverse(e.projectionMatrix).elements)}_createGLContext(t,e){const n=["webgl2","webgl","experimental-webgl"];let i=null;for(let r=0;r<n.length;++r){try{i=t.getContext(n[r],e)}catch(t){}if(i)break}return i}}function Bi(t,e){if(!t)return;t.layers&&t.layers.set(e);const n=t.children;if(n&&n.length)for(let t=0,i=n.length;t<i;t++)Bi(n[t],e)}function Ei(t){return t.getGLRes?t.getGLRes():t.getGLZoom()}function Ui(t,e,n,i){return t.coordToPointAtRes?t.coordToPointAtRes(e,n,i):t.coordinateToPoint(e,n,i)}function zi(t,e){return zi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},zi(t,e)}function Fi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Vi(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Fi(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Fi(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Zi(){return"iep"+"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))+"layer"}ki.registerRenderer("gl",Pi),t.registerWorkerAdapter&&(t.registerWorkerAdapter("__maptalks.three__",'(function(n){"use strict";\n/*!\n * poly-extrude v0.1.0\n */var t={exports:{}};function r(n,t,r){r=r||2;var i,o,u,v,s,l,x,c=t&&t.length,d=c?t[0]*r:n.length,g=e(n,0,d,r,!0),y=[];if(!g||g.next===g.prev)return y;if(c&&(g=function(n,t,r,i){var a,o,u,v=[];for(a=0,o=t.length;a<o;a++)(u=e(n,t[a]*i,a<o-1?t[a+1]*i:n.length,i,!1))===u.next&&(u.steiner=!0),v.push(p(u));for(v.sort(h),a=0;a<v.length;a++)r=f(v[a],r);return r}(n,t,g,r)),n.length>80*r){i=u=n[0],o=v=n[1];for(var m=r;m<d;m+=r)(s=n[m])<i&&(i=s),(l=n[m+1])<o&&(o=l),s>u&&(u=s),l>v&&(v=l);x=0!==(x=Math.max(u-i,v-o))?32767/x:0}return a(g,y,r,i,o,x,0),y}function e(n,t,r,e,i){var a,o;if(i===z(n,t,r,e)>0)for(a=t;a<r;a+=e)o=Z(a,n[a],n[a+1],o);else for(a=r-e;a>=t;a-=e)o=Z(a,n[a],n[a+1],o);return o&&y(o,o.next)&&(F(o),o=o.next),o}function i(n,t){if(!n)return n;t||(t=n);var r,e=n;do{if(r=!1,e.steiner||!y(e,e.next)&&0!==g(e.prev,e,e.next))e=e.next;else{if(F(e),(e=t=e.prev)===e.next)break;r=!0}}while(r||e!==t);return t}function a(n,t,r,e,h,f,l){if(n){!l&&f&&function(n,t,r,e){var i=n;do{0===i.z&&(i.z=x(i.x,i.y,t,r,e)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,function(n){var t,r,e,i,a,o,u,v,s=1;do{for(r=n,n=null,a=null,o=0;r;){for(o++,e=r,u=0,t=0;t<s&&(u++,e=e.nextZ);t++);for(v=s;u>0||v>0&&e;)0!==u&&(0===v||!e||r.z<=e.z)?(i=r,r=r.nextZ,u--):(i=e,e=e.nextZ,v--),a?a.nextZ=i:n=i,i.prevZ=a,a=i;r=e}a.nextZ=null,s*=2}while(o>1)}(i)}(n,e,h,f);for(var p,c,d=n;n.prev!==n.next;)if(p=n.prev,c=n.next,f?u(n,e,h,f):o(n))t.push(p.i/r|0),t.push(n.i/r|0),t.push(c.i/r|0),F(n),n=c.next,d=c.next;else if((n=c)===d){l?1===l?a(n=v(i(n),t,r),t,r,e,h,f,2):2===l&&s(n,t,r,e,h,f):a(i(n),t,r,e,h,f,1);break}}}function o(n){var t=n.prev,r=n,e=n.next;if(g(t,r,e)>=0)return!1;for(var i=t.x,a=r.x,o=e.x,u=t.y,v=r.y,s=e.y,h=i<a?i<o?i:o:a<o?a:o,f=u<v?u<s?u:s:v<s?v:s,l=i>a?i>o?i:o:a>o?a:o,x=u>v?u>s?u:s:v>s?v:s,p=e.next;p!==t;){if(p.x>=h&&p.x<=l&&p.y>=f&&p.y<=x&&c(i,u,a,v,o,s,p.x,p.y)&&g(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function u(n,t,r,e){var i=n.prev,a=n,o=n.next;if(g(i,a,o)>=0)return!1;for(var u=i.x,v=a.x,s=o.x,h=i.y,f=a.y,l=o.y,p=u<v?u<s?u:s:v<s?v:s,d=h<f?h<l?h:l:f<l?f:l,y=u>v?u>s?u:s:v>s?v:s,m=h>f?h>l?h:l:f>l?f:l,w=x(p,d,t,r,e),M=x(y,m,t,r,e),b=n.prevZ,A=n.nextZ;b&&b.z>=w&&A&&A.z<=M;){if(b.x>=p&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&c(u,h,v,f,s,l,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,A.x>=p&&A.x<=y&&A.y>=d&&A.y<=m&&A!==i&&A!==o&&c(u,h,v,f,s,l,A.x,A.y)&&g(A.prev,A,A.next)>=0)return!1;A=A.nextZ}for(;b&&b.z>=w;){if(b.x>=p&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&c(u,h,v,f,s,l,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;A&&A.z<=M;){if(A.x>=p&&A.x<=y&&A.y>=d&&A.y<=m&&A!==i&&A!==o&&c(u,h,v,f,s,l,A.x,A.y)&&g(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function v(n,t,r){var e=n;do{var a=e.prev,o=e.next.next;!y(a,o)&&m(a,e,e.next,o)&&b(a,o)&&b(o,a)&&(t.push(a.i/r|0),t.push(e.i/r|0),t.push(o.i/r|0),F(e),F(e.next),e=n=o),e=e.next}while(e!==n);return i(e)}function s(n,t,r,e,o,u){var v=n;do{for(var s=v.next.next;s!==v.prev;){if(v.i!==s.i&&d(v,s)){var h=A(v,s);return v=i(v,v.next),h=i(h,h.next),a(v,t,r,e,o,u,0),void a(h,t,r,e,o,u,0)}s=s.next}v=v.next}while(v!==n)}function h(n,t){return n.x-t.x}function f(n,t){var r=function(n,t){var r,e=t,i=n.x,a=n.y,o=-1/0;do{if(a<=e.y&&a>=e.next.y&&e.next.y!==e.y){var u=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=i&&u>o&&(o=u,r=e.x<e.next.x?e:e.next,u===i))return r}e=e.next}while(e!==t);if(!r)return null;var v,s=r,h=r.x,f=r.y,x=1/0;e=r;do{i>=e.x&&e.x>=h&&i!==e.x&&c(a<f?i:o,a,h,f,a<f?o:i,a,e.x,e.y)&&(v=Math.abs(a-e.y)/(i-e.x),b(e,n)&&(v<x||v===x&&(e.x>r.x||e.x===r.x&&l(r,e)))&&(r=e,x=v)),e=e.next}while(e!==s);return r}(n,t);if(!r)return t;var e=A(r,n);return i(e,e.next),i(r,r.next)}function l(n,t){return g(n.prev,n,t.prev)<0&&g(t.next,n,n.next)<0}function x(n,t,r,e,i){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*i|0)|n<<8))|n<<4))|n<<2))|n<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-e)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function p(n){var t=n,r=n;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==n);return r}function c(n,t,r,e,i,a,o,u){return(i-o)*(t-u)>=(n-o)*(a-u)&&(n-o)*(e-u)>=(r-o)*(t-u)&&(r-o)*(a-u)>=(i-o)*(e-u)}function d(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!function(n,t){var r=n;do{if(r.i!==n.i&&r.next.i!==n.i&&r.i!==t.i&&r.next.i!==t.i&&m(r,r.next,n,t))return!0;r=r.next}while(r!==n);return!1}(n,t)&&(b(n,t)&&b(t,n)&&function(n,t){var r=n,e=!1,i=(n.x+t.x)/2,a=(n.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(e=!e),r=r.next}while(r!==n);return e}(n,t)&&(g(n.prev,n,t.prev)||g(n,t.prev,t))||y(n,t)&&g(n.prev,n,n.next)>0&&g(t.prev,t,t.next)>0)}function g(n,t,r){return(t.y-n.y)*(r.x-t.x)-(t.x-n.x)*(r.y-t.y)}function y(n,t){return n.x===t.x&&n.y===t.y}function m(n,t,r,e){var i=M(g(n,t,r)),a=M(g(n,t,e)),o=M(g(r,e,n)),u=M(g(r,e,t));return i!==a&&o!==u||(!(0!==i||!w(n,r,t))||(!(0!==a||!w(n,e,t))||(!(0!==o||!w(r,n,e))||!(0!==u||!w(r,t,e)))))}function w(n,t,r){return t.x<=Math.max(n.x,r.x)&&t.x>=Math.min(n.x,r.x)&&t.y<=Math.max(n.y,r.y)&&t.y>=Math.min(n.y,r.y)}function M(n){return n>0?1:n<0?-1:0}function b(n,t){return g(n.prev,n,n.next)<0?g(n,t,n.next)>=0&&g(n,n.prev,t)>=0:g(n,t,n.prev)<0||g(n,n.next,t)<0}function A(n,t){var r=new P(n.i,n.x,n.y),e=new P(t.i,t.x,t.y),i=n.next,a=t.prev;return n.next=t,t.prev=n,r.next=i,i.prev=r,e.next=r,r.prev=e,a.next=e,e.prev=a,e}function Z(n,t,r,e){var i=new P(n,t,r);return e?(i.next=e.next,i.prev=e,e.next.prev=i,e.next=i):(i.prev=i,i.next=i),i}function F(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function P(n,t,r){this.i=n,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function z(n,t,r,e){for(var i=0,a=t,o=r-e;a<r;a+=e)i+=(n[o]-n[a])*(n[a+1]+n[o+1]),o=a;return i}t.exports=r,t.exports.default=r,r.deviation=function(n,t,r,e){var i=t&&t.length,a=i?t[0]*r:n.length,o=Math.abs(z(n,0,a,r));if(i)for(var u=0,v=t.length;u<v;u++){var s=t[u]*r,h=u<v-1?t[u+1]*r:n.length;o-=Math.abs(z(n,s,h,r))}var f=0;for(u=0;u<e.length;u+=3){var l=e[u]*r,x=e[u+1]*r,p=e[u+2]*r;f+=Math.abs((n[l]-n[p])*(n[x+1]-n[l+1])-(n[l]-n[x])*(n[p+1]-n[l+1]))}return 0===o&&0===f?0:Math.abs((f-o)/o)},r.flatten=function(n){for(var t=n[0][0].length,r={vertices:[],holes:[],dimensions:t},e=0,i=0;i<n.length;i++){for(var a=0;a<n[i].length;a++)for(var o=0;o<t;o++)r.vertices.push(n[i][a][o]);i>0&&(e+=n[i-1].length,r.holes.push(e))}return r};var I=t.exports;function E(n){for(var t,r,e=0,i=1,a=n.length;i<a;)t=r||n[0],e+=((r=n[i])[0]-t[0])*(r[1]+t[1]),i++;return e>0}function L(n,t,r){return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],n}function H(n,t){var r=t[0],e=t[1],i=t[2],a=Math.sqrt(r*r+e*e+i*i)||1;return n[0]=r/a,n[1]=e/a,n[2]=i/a,n}function U(n,t){function r(n,t,r,e){n[0]=t,n[1]=r,n[2]=e}for(var e,i,a,o,u,v,s,h,f,l=[],x=[],p=[],c=[],d=[],g=[],y=n.length,m=new Float32Array(t.length),w=0;w<y;){var M=3*n[w],b=3*n[w+1],A=3*n[w+2];r(l,t[M],t[M+1],t[M+2]),r(x,t[b],t[b+1],t[b+2]),r(p,t[A],t[A+1],t[A+2]),L(d,p,x),L(c,l,x),e=g,a=c,o=void 0,u=void 0,v=void 0,s=void 0,h=void 0,f=void 0,o=(i=d)[0],u=i[1],v=i[2],s=a[0],h=a[1],f=a[2],e[0]=u*f-v*h,e[1]=v*s-o*f,e[2]=o*h-u*s;for(var Z=0;Z<3;Z++)m[M+Z]+=g[Z],m[b+Z]+=g[Z],m[A+Z]+=g[Z];w+=3}for(var F=0,P=m.length;F<P;)r(g,m[F],m[F+1],m[F+2]),H(g,g),m[F]=g[0]||0,m[F+1]=g[1]||0,m[F+2]=g[2]||0,F+=3;return m}function j(n){if(1===n.length)return{position:n[0].position,normal:n[0].normal,uv:n[0].uv,indices:n[0].indices,results:n};for(var t=0,r=0,e=0,i=n.length;e<i;e++){var a=n[e],o=a.position,u=a.indices;t+=o.length,r+=u.length}for(var v={position:new Float32Array(t),normal:new Float32Array(t),uv:new Float32Array(t/3*2),indices:new Uint32Array(r),results:n},s=0,h=0,f=0,l=0,x=0,p=n.length;x<p;x++){var c=n[x],d=c.position,g=c.indices,y=c.normal,m=c.uv;v.position.set(d,s),v.normal.set(y,s),v.uv.set(m,l);for(var w=0,M=g.length;w<M;){var b=g[w]+h;v.indices[f]=b,f++,w++}l+=m.length,s+=d.length,h+=d.length/3}return v}function O(n){return 180*n/Math.PI}function S(n){return n/180*Math.PI}function W(n,t,r,e,i,a){var o=3*r,u=3*e,v=3*i,s=3*a,h=t[o],f=t[o+1],l=t[o+2],x=t[u],p=t[u+1],c=t[u+2],d=t[v],g=t[v+1],y=t[v+2],m=t[s],w=t[s+1],M=t[s+2];Math.abs(f-p)<Math.abs(h-x)?(n.push(h,1-l),n.push(x,1-c),n.push(d,1-y),n.push(m,1-M)):(n.push(f,1-l),n.push(p,1-c),n.push(g,1-y),n.push(w,1-M))}function k(n,t){t=Object.assign({},{depth:2},t);var r=n.map((function(n){for(var r=0,e=n.length;r<e;r++){var i=n[r];B(i),0===r?E(i)||(n[r]=i.reverse()):E(i)&&(n[r]=i.reverse()),V(i)&&i.splice(i.length-1,1)}var a=function(n,t){for(var r=function(n){var t=0,r=0,e=n.length;for(;r<e;)t+=n[r].length,r++;return t}(n),e=n.length,i=[],a=new Float32Array(2*r),o=[],u=[],v=3*r,s=2*r,h=t.depth,f=0,l=0,x=0,p=0;p<e;p++){var c=n[p];p>0&&i.push(f/2);for(var d=0,g=c.length;d<g;){var y=c[d],m=y[0],w=y[1];a[f++]=m,a[f++]=w,o[l]=m,o[l+1]=w,o[l+2]=h,o[v+l]=m,o[v+l+1]=w,o[v+l+2]=0,u[x]=m,u[x+1]=w,u[s+x]=m,u[s+x+1]=w,l+=3,x+=2,d++}}return{flatVertices:a,holes:i,points:o,count:r,uvs:u}}(n,t);return a.polygon=n,function(n,t){for(var r=[],e=n.count,i=0,a=t.length;i<a;i+=3){var o=t[i],u=t[i+1],v=t[i+2];r[i]=o,r[i+1]=u,r[i+2]=v;var s=a+i,h=e+o,f=e+u,l=e+v;r[s]=h,r[s+1]=f,r[s+2]=l}n.index=r}(a,I(a.flatVertices,a.holes,2)),function(n,t){for(var r=n.points,e=n.index,i=n.polygon,a=n.uvs,o=t.depth,u=0,v=i.length;u<v;u++)for(var s=i[u],h=0,f=s.length;h<f;){var l=s[h],x=s[h+1];h===f-1&&(x=s[0]);var p=r.length/3,c=l[0],d=l[1],g=x[0],y=x[1];r.push(c,d,o,g,y,o,c,d,0,g,y,0);var m=p+2,w=p+3,M=p,b=p+1;e.push(m,M,w,M,b,w),W(a,r,m,w,M,b),h++}}(a,t),a.position=new Float32Array(a.points),a.indices=new Uint32Array(a.index),a.uv=new Float32Array(a.uvs),a.normal=U(a.indices,a.position),a})),e=j(r);return e.polygons=n,e}function B(n){V(n)||n.push(n[0])}function V(n){var t=n.length,r=n[0],e=r[0],i=r[1],a=n[t-1],o=a[0],u=a[1];return e===o&&i===u}function _(n,t){t=Object.assign({},{depth:2,lineWidth:1},t);var r=n.map((function(n){var r=function(n,t){var r=0,e=t.lineWidth/2,i=[],a=[],o=[],u=n.length,v=0;for(;v<u-1;){var s=n[v],h=n[v+1],f=h[1]-s[1],l=h[0]-s[0],x=0,p=O(Math.atan(f/l));if(r=p,0===v)x=p,x-=90;else{var c=n[v-1];q.x=c[0]-s[0],q.y=c[1]-s[1],R.x=h[0]-s[0],R.y=h[1]-s[1],x=p-D(q,R)/2}var d=C(S(x),e,s),g=d[0],y=d[1];i.push(g,y),G(g,s,h)?(a.push(g),o.push(y)):(a.push(y),o.push(g)),v++}var m=r,w=S(m-=90),M=n[u-2],b=n[u-1],A=C(w,e,b),Z=A[0],F=A[1];i.push(Z,F),G(Z,M,b)?(a.push(Z),o.push(F)):(a.push(F),o.push(Z));return{offsetPoints:i,leftPoints:a,rightPoints:o}}(n,t);return r.line=n,function(n,t){var r=t.depth,e=[],i=[],a=[],o=n.leftPoints,u=n.rightPoints,v=0,s=o.length;for(;v<s;){var h=3*v,f=o[v],l=f[0],x=f[1];e[h]=l,e[h+1]=x,e[h+2]=r;var p=u[v],c=p[0],d=p[1],g=3*s+h;e[g]=c,e[g+1]=d,e[g+2]=r;var y=2*s*3+h;e[y]=l,e[y+1]=x,e[y+2]=0;var m=2*s*3+3*s+h;e[m]=c,e[m+1]=d,e[m+2]=0,v++}v=0,s=e.length;for(;v<s;){var w=e[v],M=e[v+1];a.push(w,M),v+=3}v=0,s=o.length;for(;v<s-1;){var b=v,A=v+1,Z=b+s,F=A+s;i.push(b,Z,A),i.push(Z,F,A);var P=v+2*s,z=P+1,I=P+s,E=z+s;i.push(P,I,z),i.push(I,E,z),v++}n.index=i,n.points=e,n.uvs=a}(r,t),function(n,t){var r=n.points,e=n.index,i=n.leftPoints,a=n.rightPoints,o=n.uvs,u=t.depth,v=[i,a];function s(n,t){var i=r.length/3;r.push(n[0],n[1],u,t[0],t[1],u,n[0],n[1],0,t[0],t[1],0);var a=i+2,v=i+3,s=i,h=i+1;e.push(a,s,v,s,h,v),W(o,r,a,v,s,h)}for(var h=0,f=v.length;h<f;h++){var l=v[h];h>0&&(l=(l=l.map((function(n){return n}))).reverse());for(var x=0,p=l.length-1;x<p;){s(l[x],l[x+1]),x++}}for(var c=i.length,d=[a[0],i[0],i[c-1],a[c-1]],g=0;g<d.length;g+=2){s(d[g],d[g+1])}}(r,t),r.position=new Float32Array(r.points),r.indices=new Uint32Array(r.index),r.uv=new Float32Array(r.uvs),r.normal=U(r.indices,r.position),r})),e=j(r);return e.lines=n,e}var q={x:0,y:0},R={x:0,y:0};function C(n,t,r){var e=r[0],i=r[1],a=[e+Math.cos(n)*t,i+Math.sin(n)*t],o=n+=Math.PI;return[a,[e+Math.cos(o)*t,i+Math.sin(o)*t]]}var D=function(n,t){var r=n.x,e=n.y,i=t.x,a=t.y,o=r*i+e*a,u=r*a-e*i;return(Math.atan2(u,o)/Math.PI*180+360)%360};function G(n,t,r){var e=t[0],i=t[1],a=r[0],o=r[1];return(i-o)*n[0]+(a-e)*n[1]+e*o-a*i>0}function J(n,t){void 0===t&&(t={}),t=Object.assign({},{radius:1,height:2,radialSegments:6},t);for(var r=Math.round(Math.max(4,t.radialSegments)),e=t,i=e.radius,a=e.height,o=360/r/360*Math.PI*2,u=r+1,v=new Float32Array(3*u*2),s=n[0],h=n[1],f=0,l=0,x=3*u,p=2*u,c=[],d=[],g=-1;g<r;g++){var y=o*g,m=Math.cos(y)*i+s,w=Math.sin(y)*i+h;v[f]=m,v[f+1]=w,v[f+2]=0,v[f+x]=m,v[f+1+x]=w,v[f+2+x]=a;var M,b;M=.5+m/i/2,b=.5+w/i/2,d[l]=M,d[l+1]=b,d[l+p]=M,d[l+1+p]=b,f+=3,l+=2,g>1&&c.push(0,g-1,g)}v[f-=3]=v[0],v[f+1]=v[1],v[f+2]=v[2];var A=v.length;v[A-3]=v[0],v[A-2]=v[1],v[A-1]=a;for(var Z=c.length,F=0;F<Z;F++){var P=c[F];c.push(P+u)}var z=new Float32Array(2*(3*u*2-6)),I=-1;f=2*u,l=0;for(var E=0,L=v.length/2;E<L-3;E+=3){var H=v[E],j=v[E+1],O=v[E+3],S=v[E+4];z[++I]=H,z[++I]=j,z[++I]=a,z[++I]=O,z[++I]=S,z[++I]=a,z[++I]=H,z[++I]=j,z[++I]=0,z[++I]=O,z[++I]=S,z[++I]=0;var W=f+2,k=f+3,B=f,V=f+1;c.push(B,W,V,W,k,V),f+=4;var _=l/u,q=(l+1)/u;d.push(_,a/i/2,q,a/i/2,_,0,q,0),l++}var R=new Float32Array(v.length+z.length);R.set(v,0),R.set(z,v.length);var C=U(c,R);return{points:v,indices:new Uint32Array(c),position:R,normal:C,uv:new Float32Array(d)}}var K={x:0,y:0},N={x:0,y:0};function Q(n,t,r,e){for(var i=n.length,a=0;a<i;a++){var o=n[a].data;t=n[a].center||t;for(var u=0,v=o.length;u<v;u++)for(var s=o[u],h=0,f=s.length;h<f;h++)n[a].data[u][h]=T(s[h],t,r,e)}}function T(n,t,r,e){for(var i,a=[],o=0,u=(i=r?new Float64Array(n):new Float32Array(n)).length;o<u;o+=2){var v=i[o],s=i[o+1];if(t&&r&&e){K.x=v,K.y=s;var h=un(K,N);K.x=h.x,K.y=h.y,v=(h=vn(e,K,r,N)).x,s=h.y,v-=t[0],s-=t[1]}a.push([v,s])}return a}function X(n,t){void 0===t&&(t=!1);for(var r=n.length,e=[],i=[],a=0,o=0;o<r;o++){var u=t?$(n[o]):Y(n[o]),v=n[o].bottomHeight||0,s=u.position;i.push(u);var h=s.length/3;e[o]={position:{middleZ:v+(n[o].height||0)/2,count:h,start:a,end:a+3*h},hide:!1},a+=3*h}var f=tn(i),l=f.position,x=f.normal,p=f.uv,c=f.indices;return{position:l.buffer,normal:x.buffer,uv:p.buffer,indices:c.buffer,geometriesAttributes:e}}function Y(n){var t=n.data,r=n.height,e=n.bottomHeight,i=k(t,{depth:r}),a=i.position,o=i.normal,u=i.uv,v=i.indices;return rn(a,e),{position:a,normal:o,uv:u,indices:v}}function $(n){var t=n.data,r=n.height,e=n.width,i=n.bottomHeight,a=_(t,{lineWidth:e,depth:r}),o=a.position,u=a.normal,v=a.uv,s=a.indices;return rn(o,i),{position:o,normal:u,uv:v,indices:s}}function nn(n,t){for(var r=new Float32Array(t),e=0,i=0;i<n.length;++i)r.set(n[i],e),e+=n[i].length;return r}function tn(n){for(var t={},r={},e=0;e<n.length;++e){var i=n[e];for(var a in i)void 0===t[a]&&(t[a]=[],r[a]=0),t[a].push(i[a]),r[a]+=i[a].length}var o={},u=0,v=[];for(var s in t)if("indices"===s)for(var h=t[s],f=0,l=h.length;f<l;f++){for(var x=h[f],p=0,c=x.length;p<c;p++)v.push(x[p]+u);u+=t.position[f].length/3}else{var d=nn(t[s],r[s]);if(!d)return null;o[s]=d}return o.indices=new Uint32Array(v),o}function rn(n,t){if(void 0!==t&&"number"==typeof t&&0!==t)for(var r=0,e=n.length;r<e;r+=3)n[r+2]+=t}function en(n){for(var t=[],r=0,e=n.length;r<e;r+=7){var i=n[r],a=n[r+1],o=n[r+2],u=n[r+3],v=n[r+4],s=n[r+5];t.push({radialSegments:o,radius:u,height:v,altitude:s,center:[i,a]})}for(var h=t.length,f=[],l=[],x=0,p=0;p<h;p++){var c=J(t[p].center||[0,0],t[p]),d=c.position;if(t[p].altitude)for(var g=t[p].altitude,y=0,m=d.length;y<m;y+=3)c[y+2]+=g;l.push(c);var w=d.length/3;f[p]={position:{middleZ:t[p].height/2,count:w,start:x,end:x+3*w},hide:!1},x+=3*w}var M=tn(l),b=M.position,A=M.normal,Z=M.uv,F=M.indices;return{position:b.buffer,normal:A.buffer,uv:Z.buffer,indices:F.buffer,geometriesAttributes:f}}var an=Math.PI/180,on=6378137*Math.PI/180;function un(n,t){var r,e=85.0511287798,i=n.x,a=Math.max(Math.min(e,n.y),-e);r=0===a?0:Math.log(Math.tan((90+a)*an/2))/an;var o=i*on,u=r*on;return t?(t.x=o,t.y=u,t):{x:o,y:u}}function vn(n,t,r,e){var i=n[0]*(t.x-n[2])/r,a=-n[1]*(t.y-n[3])/r;return e?(e.x=i,e.y=a,e):{x:i,y:a}}function sn(n){void 0===n&&(n=[]);for(var t=n.length,r=new Float32Array(3*t),e=0;e<t;e++){var i=n[e],a=3*e;r[a]=i[0],r[a+1]=i[1]}return r}function hn(n){for(var t=new Float32Array(2*n.length-6),r=0,e=0,i=n.length/3;e<i;e++){var a=n[3*e],o=n[3*e+1],u=n[3*e+2];if(e>0&&e<i-1){var v=3*r;t[v]=a,t[v+1]=o,t[v+2]=u,r++}var s=3*r;t[s]=a,t[s+1]=o,t[s+2]=u,r++}return t}function fn(n){var t=0,r=n.length;if(1===r)return n[0];for(var e=0;e<r;e++)t+=n[e].length;for(var i=new Float32Array(t),a=0,o=0;o<r;o++)i.set(n[o],a),a+=n[o].length;return i}n.initialize=function(){},n.onmessage=function(n,t){var r=n.data,e=r.type,i=r.datas,a=r.glRes,o=r.matrix,u=r.center;if("ExtrudePolygons"===e){Q(i,u,a,o);var v=X(i);t(null,v,[v.position,v.normal,v.uv,v.indices])}else if("ExtrudeLines"===e){for(var s=0,h=i.length;s<h;s++)for(var f=0,l=i[s].data.length;f<l;f++)i[s].data[f]=T(i[s].data[f],i[s].center||u,a,o);var x=X(i,!0);t(null,x,[x.position,x.normal,x.uv,x.indices])}else if("ExtrudePolygon"===e){var p=[],c=[];i.forEach((function(n){var t=[n];Q(t,u,a,o);var r=X(t),e=r.position,i=r.normal,v=r.uv,s=r.indices;p.push({id:n.id,position:e,normal:i,uv:v,indices:s}),c.push(e,i,v,s)})),t(null,p,c)}else if("Line"===e||"FatLine"===e){for(var d=[],g=[],y=0,m=i.length;y<m;y++){for(var w=[],M=0,b=i[y].data.length;M<b;M++){i[y].data[M]=T(i[y].data[M],i[y].center||u,a,o);var A=sn(i[y].data[M]);w.push(hn(A))}var Z=fn(w);rn(Z,i[y].bottomHeight),d.push({id:i[y].id,position:Z.buffer}),g.push(Z.buffer)}t(null,d,g)}else if("Lines"===e||"FatLines"===e){for(var F=0,P=[],z=[],I=0,E=[],L=0,H=i.length;L<H;L++){for(var U=0,j=0,O=i[L].data.length;j<O;j++){i[L].data[j]=T(i[L].data[j],i[L].center||u,a,o);var S=sn(i[L].data[j]);rn(S,i[L].bottomHeight),U+=S.length/3*2-2,E.push(hn(S))}var W=U;P[L]=[F,F+W],F+=W,z[L]={position:{count:U,start:I,end:I+3*U},hide:!1},"FatLines"===e&&(z[L].instanceStart={count:U,start:I,end:I+3*U},z[L].instanceEnd={count:U,start:I,end:I+3*U}),I+=3*U}var k=fn(E);t(null,{id:i.id,position:k.buffer,geometriesAttributes:z,faceMap:P},[k.buffer])}else if("ExtrudeLine"===e){for(var B=0,V=i.length;B<V;B++)for(var _=0,q=i[B].data.length;_<q;_++)i[B].data[_]=T(i[B].data[_],i[B].center||u,a,o);var R=[],C=[];i.forEach((function(n){var t=X([n],!0),r=t.position,e=t.normal,i=t.uv,a=t.indices;R.push({id:n.id,position:r,normal:e,uv:i,indices:a}),C.push(r,e,i,a)})),t(null,R,C)}else if("Bar"===e){for(var D=[],G=[],J=(i=new Float32Array(i)).length/7,K=0;K<J;){var N=i.slice(7*K,7*(K+1)),Y=en(N),$=Y.position,nn=Y.normal,tn=Y.uv,an=Y.indices;D.push({id:parseInt(N[6]),position:$,normal:nn,uv:tn,indices:an}),G.push($,nn,tn,an),K++}t(null,D,G)}else if("Bars"===e){var on=en(i=new Float32Array(i));t(null,on,[on.position,on.normal,on.uv,on.indices])}},Object.defineProperty(n,"__esModule",{value:!0})})'),t.registerWorkerAdapter("__maptalks.three.fetchdata__",(function(t){const e=[],n=[],i=5;function r(t){t.abort?(n.splice(n.indexOf(t),1),e.length&&(n.push(e[0]),e.splice(0,1),o(n[n.length-1]))):n.length<i?(n.push(t),o(t)):e.push(t)}function o(t){fetch(t.url).then((t=>t.text())).then((e=>{new Blob([e],{type:"application/json"}).arrayBuffer().then((e=>{t.postResponse(null,e,[e]),t.abort=!0,r(t)}))})).catch((e=>{console.error(e),t.abort=!0,r(t)}))}t.initialize=function(){},t.onmessage=function(t,e){r({url:t.data,postResponse:e,abort:!1})}})));var Ri={altitude:0,imageWidth:512,imageHeight:512,texture:null},Gi=function(n){var i,r;function o(i,r,o,s){var a,h=r=t.Util.extend({},Ri,r),c=h.altitude;h.imageHeight,h.imageWidth,i instanceof t.Extent||(i=new t.Extent(i));var l=i,u=l.xmin,d=l.ymin,p=l.xmax,f=l.ymax,g=1/0,y=1/0,x=-1/0,m=-1/0;[[u,d],[u,f],[p,f],[p,d]].forEach((function(t){var e=s.coordinateToVector3(t),n=e.x,i=e.y;g=Math.min(n,g),y=Math.min(i,y),x=Math.max(n,x),m=Math.max(i,m)}));var v=Math.abs(x-g),b=Math.abs(m-y),_=new e.PlaneBufferGeometry(v,b);(a=n.call(this)||this)._initOptions(r),a._createMesh(_,o);var w=s.distanceToVector3(c,c).x,M=s.coordinateToVector3(i.getCenter(),w);return a.getObject3d().position.copy(M),a.parent=null,a.type="Image",a}return r=n,(i=o).prototype=Object.create(r.prototype),i.prototype.constructor=i,zi(i,r),o}(f),Di=function(){function n(n,i,r,o,s){var a=this;this.threelayer=s,this.map=s.map,this.textureLoader=new e.TextureLoader;var h=n.split(","),c=i.split(","),l=parseFloat(h[0]),u=parseFloat(h[1]),d=parseFloat(c[0]),p=parseFloat(c[1]),f=o.maxZoom||11,g=o.renderOrder||0,y=o.opacity||1,x=o.minZoom||3,m=new t.Extent(l,u,d,p);this.xmin_g=l,this.ymin_g=u,this.xmax_g=d,this.ymax_g=p,this.textureLoader.load(r,(function(t){var n=new e.MeshBasicMaterial({map:t,transparent:!0,opacity:y}),i=new Gi(m,{imageWidth:512,imageHeight:512,maxZoom:f,minZoom:x,interactive:void 0!==o.interactive&&o.interactive},n,a.threelayer);i.object3d.renderOrder=g,a.imgMesh=i,a.imgMesh.parent=a,a.m=n,a.texture=t,a.threelayer.addMesh(a.imgMesh),o.opacityItems&&o.opacityItems.length>0&&!isNaN(o.opacityItems[0])&&!isNaN(o.opacityItems[1])&&o.opacityItems[0]>3&&o.opacityItems[0]<=18&&o.opacityItems[1]>=0&&o.opacityItems[1]<=1&&(a.opacityItems=o.opacityItems,a._bindMapEvents(),a._viewChange())}))}var i=n.prototype;return i._bindMapEvents=function(){this.map.on("viewchange",this._viewChange,this)},i._viewChange=function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1},i._closeEvent=function(){this.map.off("viewchange",this._viewChange,this)},i.updateImage=function(n,i){var r=this;if(i&&i.leftbottom&&i.righttop){var o=parseFloat(i.leftbottom[0]),s=parseFloat(i.leftbottom[1]),a=parseFloat(i.righttop[0]),h=parseFloat(i.righttop[1]);if(o!==this.xmin_g||s!==this.ymin_g||a!==this.xmax_g||h!==this.ymax_g){var c=new t.Extent(o,s,a,h),l=1/0,u=1/0,d=-1/0,p=-1/0;[[o,s],[o,h],[a,h],[a,s]].forEach((function(t){var e=r.threelayer.coordinateToVector3(t),n=e.x,i=e.y;l=Math.min(n,l),u=Math.min(i,u),d=Math.max(n,d),p=Math.max(i,p)}));for(var f=Math.abs(d-l),g=Math.abs(p-u),y=new e.PlaneBufferGeometry(f,g),x=y.attributes.position.array,m=this.imgMesh.object3d.geometry.attributes.position.array,v=0;v<m.length;v++)m[v]=x[v];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(c.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),y.dispose(),this.xmin_g=o,this.ymin_g=s,this.xmax_g=a,this.ymax_g=h}}this.textureLoader.load(n,(function(t){r.texture&&r.texture.dispose(),delete r.texture,t.magFilter=e.NearestFilter,t.minFilter=e.NearestFilter,r.imgMesh.object3d.material.map=t,r.imgMesh.object3d.material.map.needsUpdate=!0,r.texture=t,!1===r.imgMesh.isAdd&&(r.threelayer.addMesh(r.imgMesh),r.opacityItems&&r._bindMapEvents())}))},i.clearImage=function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())},i.dispose=function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader},n}(),Hi=function(){function t(t,n){var i=this;this.map=n,this.animationId=null,this.updatables=[];var r=Zi();this.threeLayer=new ki(r,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new e.Clock;var o=function t(){var e,n;(i.threeLayer._needsUpdate=!i.threeLayer._needsUpdate,i.threeLayer._needsUpdate)&&(null==(e=i.threeLayer)||null==(n=e.getRenderer())||n.clearCanvas(),i.threeLayer.renderScene());for(var r,o=i.clock.getDelta(),s=Vi(i.updatables);!(r=s()).done;){r.value.tick(o)}i.animationId=requestAnimationFrame(t)};this.threeLayer.prepareToDraw=function(t,n,i){var r=new e.DirectionalLight(16777215);r.position.set(0,-10,10).normalize(),n.add(r),o()},this.threeLayer.addTo(n),this.layerId=r,this.layerName=t,this.dirty=!1,this.initFlag=!1}var n=t.prototype;return n.getLayerId=function(){return this.layerId},n.changeLayerId=function(){if(this.threeLayer){var t=Zi();this.threeLayer.setId(t),this.layerId=t}},n.setVisible=function(t,e){this.threeLayer&&(!0===t?(this.threeLayer.show(),e&&e()):(this.threeLayer.hide(),e&&e()))},n.prepareToDraw=function(){var t=this,n=function e(){var n,i;(t.threeLayer._needsUpdate=!t.threeLayer._needsUpdate,t.threeLayer._needsUpdate)&&(null==(n=t.threeLayer)||null==(i=n.getRenderer())||i.clearCanvas(),t.threeLayer.renderScene());for(var r,o=t.clock.getDelta(),s=Vi(t.updatables);!(r=s()).done;){r.value.tick(o)}t.animationId=requestAnimationFrame(e)};return new Promise((function(i){t.threeLayer.prepareToDraw=function(t,r,o){var s=new e.DirectionalLight(16777215);s.position.set(0,-10,10).normalize(),r.add(s),r.add(new e.AmbientLight(16777215)),n(),i()}}))},n.drawImage=function(t,e,n,i){var r=this;return new Promise((function(o){if(r.threeLayer.getScene()){var s=new Di(t,e,n,i,r.threeLayer);o(s)}else r.initFlag=!0,r.prepareToDraw().then((function(){var s=new Di(t,e,n,i,r.threeLayer);o(s)}))}))},n.dispose=function(){this.animationId&&cancelAnimationFrame(this.animationId);var t=this.threeLayer.getMeshes();this.threeLayer.clear(),t.forEach((function(t){}));var e=this.threeLayer.getCamera(),n=this.threeLayer.getScene(),i=this.threeLayer.getPick(),r=i.pickingTexture;i.pickingScene;var o=this.threeLayer.getRenderer();n.remove(e),e=null,n=null,r.dispose(),r=null,o.context.dispose(),o.context.forceContextLoss(),o.context=null,o.remove(),o=null,this.map.removeLayer(this.threeLayer)},t}();export{f as BaseObject,ki as ThreeLayer,Di as imgClass,Hi as layerClass};
|