!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],e):"object"==typeof exports?exports["echarts-gl"]=e(require("echarts")):t["echarts-gl"]=e(t.echarts)}(self,(function(t){return(()=>{"use strict";var e={583:(t,e,r)=>{r.r(e);var i=r(83);function n(t,e,r){"object"==typeof e&&(r=e,e=null);var i,n=this;if(!(t instanceof Function))for(var s in i=[],t)t.hasOwnProperty(s)&&i.push(s);var l=function(e){if(n.apply(this,arguments),t instanceof Function?a(this,t.call(this,e)):o(this,t,i),this.constructor===l)for(var r=l.__initializers__,s=0;s<r.length;s++)r[s].apply(this,arguments)};l.__super__=n,n.__initializers__?l.__initializers__=n.__initializers__.slice():l.__initializers__=[],e&&l.__initializers__.push(e);var h=function(){};return h.prototype=n.prototype,l.prototype=new h,l.prototype.constructor=l,a(l.prototype,r),l.extend=n.extend,l.derive=n.extend,l}function a(t,e){if(e)for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])}function o(t,e,r){for(var i=0;i<r.length;i++){var n=r[i];t[n]=e[n]}}const s={extend:n,derive:n};function l(t,e){this.action=t,this.context=e}const h={trigger:function(t){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(t)){var e=this.__handlers__[t],r=e.length,i=-1,n=arguments;switch(n.length){case 1:for(;++i<r;)e[i].action.call(e[i].context);return;case 2:for(;++i<r;)e[i].action.call(e[i].context,n[1]);return;case 3:for(;++i<r;)e[i].action.call(e[i].context,n[1],n[2]);return;case 4:for(;++i<r;)e[i].action.call(e[i].context,n[1],n[2],n[3]);return;case 5:for(;++i<r;)e[i].action.call(e[i].context,n[1],n[2],n[3],n[4]);return;default:for(;++i<r;)e[i].action.apply(e[i].context,Array.prototype.slice.call(n,1));return}}},on:function(t,e,r){if(t&&e){var i=this.__handlers__||(this.__handlers__={});if(i[t]){if(this.has(t,e))return}else i[t]=[];var n=new l(e,r||this);return i[t].push(n),this}},once:function(t,e,r){if(t&&e){var i=this;return this.on(t,(function r(){i.off(t,r),e.apply(this,arguments)}),r)}},before:function(t,e,r){if(t&&e)return t="before"+t,this.on(t,e,r)},after:function(t,e,r){if(t&&e)return t="after"+t,this.on(t,e,r)},success:function(t,e){return this.once("success",t,e)},error:function(t,e){return this.once("error",t,e)},off:function(t,e){var r=this.__handlers__||(this.__handlers__={});if(e){if(r[t]){for(var i=r[t],n=[],a=0;a<i.length;a++)e&&i[a].action!==e&&n.push(i[a]);r[t]=n}return this}r[t]=[]},has:function(t,e){var r=this.__handlers__;if(!r||!r[t])return!1;for(var i=r[t],n=0;n<i.length;n++)if(i[n].action===e)return!0}};var u=0,c=Array.prototype.forEach,d={genGUID:function(){return++u},relative2absolute:function(t,e){if(!e||t.match(/^\//))return t;for(var r=t.split("/"),i=e.split("/"),n=r[0];"."===n||".."===n;)".."===n&&i.pop(),r.shift(),n=r[0];return i.join("/")+"/"+r.join("/")},extend:function(t,e){if(e)for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t},defaults:function(t,e){if(e)for(var r in e)void 0===t[r]&&(t[r]=e[r]);return t},extendWithPropList:function(t,e,r){if(e)for(var i=0;i<r.length;i++){var n=r[i];t[n]=e[n]}return t},defaultsWithPropList:function(t,e,r){if(e)for(var i=0;i<r.length;i++){var n=r[i];null==t[n]&&(t[n]=e[n])}return t},each:function(t,e,r){if(t&&e)if(t.forEach&&t.forEach===c)t.forEach(e,r);else if(t.length===+t.length)for(var i=0,n=t.length;i<n;i++)e.call(r,t[i],i,t);else for(var a in t)t.hasOwnProperty(a)&&e.call(r,t[a],a,t)},isObject:function(t){return t===Object(t)},isArray:function(t){return Array.isArray(t)},isArrayLike:function(t){return!!t&&t.length===+t.length},clone:function(t){if(d.isObject(t)){if(d.isArray(t))return t.slice();if(d.isArrayLike(t)){for(var e=new t.constructor(t.length),r=0;r<t.length;r++)e[r]=t[r];return e}return d.extend({},t)}return t}};const f=d;var p=function(){this.__uid__=f.genGUID()};p.__initializers__=[function(t){f.extend(this,t)}],f.extend(p,s),f.extend(p.prototype,h);const m=p;var g=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers","EXT_frag_depth","EXT_sRGB","ANGLE_instanced_arrays"],_=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"];const v=function(t){for(var e={},r={},i=0;i<g.length;i++)a(g[i]);for(i=0;i<_.length;i++){var n=_[i];r[n]=t.getParameter(t[n])}function a(r){if(t.getExtension){var i=t.getExtension(r);i||(i=t.getExtension("MOZ_"+r)),i||(i=t.getExtension("WEBKIT_"+r)),e[r]=i}}this.getExtension=function(t){return t in e||a(t),e[t]},this.getParameter=function(t){return r[t]}},y=1028,x=1029,b=2304,w=2305,T=5121,S=5126,M=6402,A=6408,C=9728,E=9729,D=9984,L=9985,P=9986,O=9987,N=10497,I=33071,R=33306,B={get:function(t){var e=new XMLHttpRequest;e.open("get",t.url),e.responseType=t.responseType||"text",t.onprogress&&(e.onprogress=function(e){if(e.lengthComputable){var r=e.loaded/e.total;t.onprogress(r,e.loaded,e.total)}else t.onprogress(null)}),e.onload=function(r){e.status>=400?t.onerror&&t.onerror():t.onload&&t.onload(e.response)},t.onerror&&(e.onerror=t.onerror),e.send(null)}};var F,z={supportWebGL:function(){if(null==F)try{var t=document.createElement("canvas");if(!t.getContext("webgl")&&!t.getContext("experimental-webgl"))throw new Error}catch(t){F=!1}return F}};z.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,z.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,z.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,z.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,z.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,z.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,z.Float64Array="undefined"==typeof Float64Array?Array:Float64Array;var k={};"undefined"!=typeof window?k=window:void 0!==r.g&&(k=r.g),z.requestAnimationFrame=k.requestAnimationFrame||k.msRequestAnimationFrame||k.mozRequestAnimationFrame||k.webkitRequestAnimationFrame||function(t){setTimeout(t,16)},z.createCanvas=function(){return document.createElement("canvas")},z.createImage=function(){return new k.Image},z.request={get:B.get},z.addEventListener=function(t,e,r,i){t.addEventListener(e,r,i)},z.removeEventListener=function(t,e,r){t.removeEventListener(e,r)};const G=z;var U=function(){this.head=null,this.tail=null,this._length=0};U.prototype.insert=function(t){var e=new U.Entry(t);return this.insertEntry(e),e},U.prototype.insertAt=function(t,e){if(!(t<0)){for(var r=this.head,i=0;r&&i!=t;)r=r.next,i++;if(r){var n=new U.Entry(e),a=r.prev;a?(a.next=n,n.prev=a):this.head=n,n.next=r,r.prev=n}else this.insert(e)}},U.prototype.insertBeforeEntry=function(t,e){var r=new U.Entry(t),i=e.prev;i?(i.next=r,r.prev=i):this.head=r,r.next=e,e.prev=r,this._length++},U.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,this.tail=t):this.head=this.tail=t,this._length++},U.prototype.remove=function(t){var e=t.prev,r=t.next;e?e.next=r:this.head=r,r?r.prev=e:this.tail=e,t.next=t.prev=null,this._length--},U.prototype.removeAt=function(t){if(!(t<0)){for(var e=this.head,r=0;e&&r!=t;)e=e.next,r++;return e?(this.remove(e),e.value):void 0}},U.prototype.getHead=function(){if(this.head)return this.head.value},U.prototype.getTail=function(){if(this.tail)return this.tail.value},U.prototype.getAt=function(t){if(!(t<0)){for(var e=this.head,r=0;e&&r!=t;)e=e.next,r++;return e.value}},U.prototype.indexOf=function(t){for(var e=this.head,r=0;e;){if(e.value===t)return r;e=e.next,r++}},U.prototype.length=function(){return this._length},U.prototype.isEmpty=function(){return 0===this._length},U.prototype.forEach=function(t,e){for(var r=this.head,i=0,n=void 0!==e;r;)n?t.call(e,r.value,i):t(r.value,i),r=r.next,i++},U.prototype.clear=function(){this.tail=this.head=null,this._length=0},U.Entry=function(t){this.value=t,this.next=null,this.prev=null};const H=U;var V=function(t){this._list=new H,this._map={},this._maxSize=t||10};V.prototype.setMaxSize=function(t){this._maxSize=t},V.prototype.put=function(t,e){if(!this._map.hasOwnProperty(t)){var r=this._list.length();if(r>=this._maxSize&&r>0){var i=this._list.head;this._list.remove(i),delete this._map[i.key]}var n=this._list.insert(e);n.key=t,this._map[t]=n}},V.prototype.get=function(t){var e=this._map[t];if(this._map.hasOwnProperty(t))return e!==this._list.tail&&(this._list.remove(e),this._list.insertEntry(e)),e.value},V.prototype.remove=function(t){var e=this._map[t];void 0!==e&&(delete this._map[t],this._list.remove(e))},V.prototype.clear=function(){this._list.clear(),this._map={}};const W=V;var j={},X={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function q(t){return(t=Math.round(t))<0?0:t>255?255:t}function Z(t){return t<0?0:t>1?1:t}function Y(t){return t.length&&"%"===t.charAt(t.length-1)?q(parseFloat(t)/100*255):q(parseInt(t,10))}function K(t){return t.length&&"%"===t.charAt(t.length-1)?Z(parseFloat(t)/100):Z(parseFloat(t))}function Q(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}function J(t,e,r){return t+(e-t)*r}function $(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t}function tt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}var et=new W(20),rt=null;function it(t,e){rt&&tt(rt,e),rt=et.put(t,rt||e.slice())}function nt(t,e){var r=(parseFloat(t[0])%360+360)%360/360,i=K(t[1]),n=K(t[2]),a=n<=.5?n*(i+1):n+i-n*i,o=2*n-a;return $(e=e||[],q(255*Q(o,a,r+1/3)),q(255*Q(o,a,r)),q(255*Q(o,a,r-1/3)),1),4===t.length&&(e[3]=t[3]),e}j.parse=function(t,e){if(t){e=e||[];var r=et.get(t);if(r)return tt(e,r);var i,n=(t+="").replace(/ /g,"").toLowerCase();if(n in X)return tt(e,X[n]),it(t,e),e;if("#"===n.charAt(0))return 4===n.length?(i=parseInt(n.substr(1),16))>=0&&i<=4095?($(e,(3840&i)>>4|(3840&i)>>8,240&i|(240&i)>>4,15&i|(15&i)<<4,1),it(t,e),e):void $(e,0,0,0,1):7===n.length?(i=parseInt(n.substr(1),16))>=0&&i<=16777215?($(e,(16711680&i)>>16,(65280&i)>>8,255&i,1),it(t,e),e):void $(e,0,0,0,1):void 0;var a=n.indexOf("("),o=n.indexOf(")");if(-1!==a&&o+1===n.length){var s=n.substr(0,a),l=n.substr(a+1,o-(a+1)).split(","),h=1;switch(s){case"rgba":if(4!==l.length)return void $(e,0,0,0,1);h=K(l.pop());case"rgb":return 3!==l.length?void $(e,0,0,0,1):($(e,Y(l[0]),Y(l[1]),Y(l[2]),h),it(t,e),e);case"hsla":return 4!==l.length?void $(e,0,0,0,1):(l[3]=K(l[3]),nt(l,e),it(t,e),e);case"hsl":return 3!==l.length?void $(e,0,0,0,1):(nt(l,e),it(t,e),e);default:return}}$(e,0,0,0,1)}},j.parseToFloat=function(t,e){if(e=j.parse(t,e))return e[0]/=255,e[1]/=255,e[2]/=255,e},j.lift=function(t,e){var r=j.parse(t);if(r){for(var i=0;i<3;i++)r[i]=e<0?r[i]*(1-e)|0:(255-r[i])*e+r[i]|0;return j.stringify(r,4===r.length?"rgba":"rgb")}},j.toHex=function(t){var e=j.parse(t);if(e)return((1<<24)+(e[0]<<16)+(e[1]<<8)+ +e[2]).toString(16).slice(1)},j.fastLerp=function(t,e,r){if(e&&e.length&&t>=0&&t<=1){r=r||[];var i=t*(e.length-1),n=Math.floor(i),a=Math.ceil(i),o=e[n],s=e[a],l=i-n;return r[0]=q(J(o[0],s[0],l)),r[1]=q(J(o[1],s[1],l)),r[2]=q(J(o[2],s[2],l)),r[3]=Z(J(o[3],s[3],l)),r}},j.fastMapToColor=j.fastLerp,j.lerp=function(t,e,r){if(e&&e.length&&t>=0&&t<=1){var i=t*(e.length-1),n=Math.floor(i),a=Math.ceil(i),o=j.parse(e[n]),s=j.parse(e[a]),l=i-n,h=j.stringify([q(J(o[0],s[0],l)),q(J(o[1],s[1],l)),q(J(o[2],s[2],l)),Z(J(o[3],s[3],l))],"rgba");return r?{color:h,leftIndex:n,rightIndex:a,value:i}:h}},j.mapToColor=j.lerp,j.modifyHSL=function(t,e,r,i){if(t=j.parse(t))return t=function(t){if(t){var e,r,i=t[0]/255,n=t[1]/255,a=t[2]/255,o=Math.min(i,n,a),s=Math.max(i,n,a),l=s-o,h=(s+o)/2;if(0===l)e=0,r=0;else{r=h<.5?l/(s+o):l/(2-s-o);var u=((s-i)/6+l/2)/l,c=((s-n)/6+l/2)/l,d=((s-a)/6+l/2)/l;i===s?e=d-c:n===s?e=1/3+u-d:a===s&&(e=2/3+c-u),e<0&&(e+=1),e>1&&(e-=1)}var f=[360*e,r,h];return null!=t[3]&&f.push(t[3]),f}}(t),null!=e&&(t[0]=(n=e,(n=Math.round(n))<0?0:n>360?360:n)),null!=r&&(t[1]=K(r)),null!=i&&(t[2]=K(i)),j.stringify(nt(t),"rgba");var n},j.modifyAlpha=function(t,e){if((t=j.parse(t))&&null!=e)return t[3]=Z(e),j.stringify(t,"rgba")},j.stringify=function(t,e){if(t&&t.length){var r=t[0]+","+t[1]+","+t[2];return"rgba"!==e&&"hsva"!==e&&"hsla"!==e||(r+=","+t[3]),e+"("+r+")"}};var at=j.parseToFloat,ot={};function st(t){var e=Object.keys(t);e.sort();for(var r=[],i=0;i<e.length;i++){var n=e[i],a=t[n];null===a?r.push(n):r.push(n+" "+a.toString())}return r.join("\n")}const lt=m.extend((function(){return{name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null,autoUpdateTextureStatus:!0,uniforms:{},vertexDefines:{},fragmentDefines:{},_textureStatus:{},_enabledUniforms:null}}),(function(){this.name||(this.name="MATERIAL_"+this.__uid__),this.shader&&this.attachShader(this.shader,!0)}),{precision:"highp",setUniform:function(t,e){void 0===e&&console.warn('Uniform value "'+t+'" is undefined');var r=this.uniforms[t];r&&("string"==typeof e&&(e=at(e)||e),r.value=e,this.autoUpdateTextureStatus&&"t"===r.type&&(e?this.enableTexture(t):this.disableTexture(t)))},setUniforms:function(t){for(var e in t){var r=t[e];this.setUniform(e,r)}},isUniformEnabled:function(t){return this._enabledUniforms.indexOf(t)>=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(t,e){if("object"==typeof t)for(var r in t){var i=t[r];this.setUniform(r,i)}else this.setUniform(t,e)},get:function(t){var e=this.uniforms[t];if(e)return e.value},attachShader:function(t,e){var r=this.uniforms;this.uniforms=t.createUniforms(),this.shader=t;var i=this.uniforms;this._enabledUniforms=Object.keys(i),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter((function(t){var e=this.uniforms[t].type;return"t"===e||"tv"===e}),this);var n=this.vertexDefines,a=this.fragmentDefines;if(this.vertexDefines=f.clone(t.vertexDefines),this.fragmentDefines=f.clone(t.fragmentDefines),e){for(var o in r)i[o]&&(i[o].value=r[o].value);f.defaults(this.vertexDefines,n),f.defaults(this.fragmentDefines,a)}var s={};for(var l in t.textures)s[l]={shaderType:t.textures[l].shaderType,type:t.textures[l].type,enabled:!(!e||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=s,this._programKey=""},clone:function(){var t=new this.constructor({name:this.name,shader:this.shader});for(var e in this.uniforms)t.uniforms[e].value=this.uniforms[e].value;return t.depthTest=this.depthTest,t.depthMask=this.depthMask,t.transparent=this.transparent,t.blend=this.blend,t.vertexDefines=f.clone(this.vertexDefines),t.fragmentDefines=f.clone(this.fragmentDefines),t.enableTexture(this.getEnabledTextures()),t.precision=this.precision,t},define:function(t,e,r){var i=this.vertexDefines,n=this.fragmentDefines;"vertex"!==t&&"fragment"!==t&&"both"!==t&&arguments.length<3&&(r=e,e=t,t="both"),r=null!=r?r:null,"vertex"!==t&&"both"!==t||i[e]!==r&&(i[e]=r,this._programKey=""),"fragment"!==t&&"both"!==t||n[e]!==r&&(n[e]=r,"both"!==t&&(this._programKey=""))},undefine:function(t,e){"vertex"!==t&&"fragment"!==t&&"both"!==t&&arguments.length<2&&(e=t,t="both"),"vertex"!==t&&"both"!==t||this.isDefined("vertex",e)&&(delete this.vertexDefines[e],this._programKey=""),"fragment"!==t&&"both"!==t||this.isDefined("fragment",e)&&(delete this.fragmentDefines[e],"both"!==t&&(this._programKey=""))},isDefined:function(t,e){switch(t){case"vertex":return void 0!==this.vertexDefines[e];case"fragment":return void 0!==this.fragmentDefines[e]}},getDefine:function(t,e){switch(t){case"vertex":return this.vertexDefines[e];case"fragment":return this.fragmentDefines[e]}},enableTexture:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this.enableTexture(t[e]);else{var r=this._textureStatus[t];r&&(r.enabled||(r.enabled=!0,this._programKey=""))}},enableTexturesAll:function(){var t=this._textureStatus;for(var e in t)t[e].enabled=!0;this._programKey=""},disableTexture:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this.disableTexture(t[e]);else{var r=this._textureStatus[t];r&&(!r.enabled||(r.enabled=!1,this._programKey=""))}},disableTexturesAll:function(){var t=this._textureStatus;for(var e in t)t[e].enabled=!1;this._programKey=""},isTextureEnabled:function(t){var e=this._textureStatus;return!!e[t]&&e[t].enabled},getEnabledTextures:function(){var t=[],e=this._textureStatus;for(var r in e)e[r].enabled&&t.push(r);return t},dirtyDefines:function(){this._programKey=""},getProgramKey:function(){return this._programKey||(this._programKey=function(t,e,r){r.sort();for(var i=[],n=0;n<r.length;n++){var a=r[n];i.push(a)}var o=st(t)+"\n"+st(e)+"\n"+i.join("\n");if(ot[o])return ot[o];var s=f.genGUID();return ot[o]=s,s}(this.vertexDefines,this.fragmentDefines,this.getEnabledTextures())),this._programKey}});var ht,ut=1e-6,ct=Array,dt=Math.random,ft={create:function(){var t=new ct(2);return t[0]=0,t[1]=0,t},clone:function(t){var e=new ct(2);return e[0]=t[0],e[1]=t[1],e},fromValues:function(t,e){var r=new ct(2);return r[0]=t,r[1]=e,r},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},set:function(t,e,r){return t[0]=e,t[1]=r,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},subtract:function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}};ft.sub=ft.subtract,ft.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t},ft.mul=ft.multiply,ft.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},ft.div=ft.divide,ft.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},ft.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},ft.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},ft.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t},ft.distance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)},ft.dist=ft.distance,ft.squaredDistance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i},ft.sqrDist=ft.squaredDistance,ft.length=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},ft.len=ft.length,ft.squaredLength=function(t){var e=t[0],r=t[1];return e*e+r*r},ft.sqrLen=ft.squaredLength,ft.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},ft.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},ft.normalize=function(t,e){var r=e[0],i=e[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},ft.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},ft.cross=function(t,e,r){var i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t},ft.lerp=function(t,e,r,i){var n=e[0],a=e[1];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t},ft.random=function(t,e){e=e||1;var r=2*GLMAT_RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},ft.transformMat2=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n,t[1]=r[1]*i+r[3]*n,t},ft.transformMat2d=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n+r[4],t[1]=r[1]*i+r[3]*n+r[5],t},ft.transformMat3=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[3]*n+r[6],t[1]=r[1]*i+r[4]*n+r[7],t},ft.transformMat4=function(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[4]*n+r[12],t[1]=r[1]*i+r[5]*n+r[13],t},ft.forEach=(ht=ft.create(),function(t,e,r,i,n,a){var o,s;for(e||(e=2),r||(r=0),s=i?Math.min(i*e+r,t.length):t.length,o=r;o<s;o+=e)ht[0]=t[o],ht[1]=t[o+1],n(ht,ht,a),t[o]=ht[0],t[o+1]=ht[1];return t});const pt=ft;var mt=function(t,e){t=t||0,e=e||0,this.array=pt.fromValues(t,e),this._dirty=!0};if(mt.prototype={constructor:mt,add:function(t){return pt.add(this.array,this.array,t.array),this._dirty=!0,this},set:function(t,e){return this.array[0]=t,this.array[1]=e,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this._dirty=!0,this},clone:function(){return new mt(this.x,this.y)},copy:function(t){return pt.copy(this.array,t.array),this._dirty=!0,this},cross:function(t,e){return pt.cross(t.array,this.array,e.array),t._dirty=!0,this},dist:function(t){return pt.dist(this.array,t.array)},distance:function(t){return pt.distance(this.array,t.array)},div:function(t){return pt.div(this.array,this.array,t.array),this._dirty=!0,this},divide:function(t){return pt.divide(this.array,this.array,t.array),this._dirty=!0,this},dot:function(t){return pt.dot(this.array,t.array)},len:function(){return pt.len(this.array)},length:function(){return pt.length(this.array)},lerp:function(t,e,r){return pt.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},min:function(t){return pt.min(this.array,this.array,t.array),this._dirty=!0,this},max:function(t){return pt.max(this.array,this.array,t.array),this._dirty=!0,this},mul:function(t){return pt.mul(this.array,this.array,t.array),this._dirty=!0,this},multiply:function(t){return pt.multiply(this.array,this.array,t.array),this._dirty=!0,this},negate:function(){return pt.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return pt.normalize(this.array,this.array),this._dirty=!0,this},random:function(t){return pt.random(this.array,t),this._dirty=!0,this},scale:function(t){return pt.scale(this.array,this.array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return pt.scaleAndAdd(this.array,this.array,t.array,e),this._dirty=!0,this},sqrDist:function(t){return pt.sqrDist(this.array,t.array)},squaredDistance:function(t){return pt.squaredDistance(this.array,t.array)},sqrLen:function(){return pt.sqrLen(this.array)},squaredLength:function(){return pt.squaredLength(this.array)},sub:function(t){return pt.sub(this.array,this.array,t.array),this._dirty=!0,this},subtract:function(t){return pt.subtract(this.array,this.array,t.array),this._dirty=!0,this},transformMat2:function(t){return pt.transformMat2(this.array,this.array,t.array),this._dirty=!0,this},transformMat2d:function(t){return pt.transformMat2d(this.array,this.array,t.array),this._dirty=!0,this},transformMat3:function(t){return pt.transformMat3(this.array,this.array,t.array),this._dirty=!0,this},transformMat4:function(t){return pt.transformMat4(this.array,this.array,t.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Object.defineProperty){var gt=mt.prototype;Object.defineProperty(gt,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),Object.defineProperty(gt,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}})}mt.add=function(t,e,r){return pt.add(t.array,e.array,r.array),t._dirty=!0,t},mt.set=function(t,e,r){return pt.set(t.array,e,r),t._dirty=!0,t},mt.copy=function(t,e){return pt.copy(t.array,e.array),t._dirty=!0,t},mt.cross=function(t,e,r){return pt.cross(t.array,e.array,r.array),t._dirty=!0,t},mt.distance=mt.dist=function(t,e){return pt.distance(t.array,e.array)},mt.divide=mt.div=function(t,e,r){return pt.divide(t.array,e.array,r.array),t._dirty=!0,t},mt.dot=function(t,e){return pt.dot(t.array,e.array)},mt.len=function(t){return pt.length(t.array)},mt.lerp=function(t,e,r,i){return pt.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},mt.min=function(t,e,r){return pt.min(t.array,e.array,r.array),t._dirty=!0,t},mt.max=function(t,e,r){return pt.max(t.array,e.array,r.array),t._dirty=!0,t},mt.multiply=mt.mul=function(t,e,r){return pt.multiply(t.array,e.array,r.array),t._dirty=!0,t},mt.negate=function(t,e){return pt.negate(t.array,e.array),t._dirty=!0,t},mt.normalize=function(t,e){return pt.normalize(t.array,e.array),t._dirty=!0,t},mt.random=function(t,e){return pt.random(t.array,e),t._dirty=!0,t},mt.scale=function(t,e,r){return pt.scale(t.array,e.array,r),t._dirty=!0,t},mt.scaleAndAdd=function(t,e,r,i){return pt.scaleAndAdd(t.array,e.array,r.array,i),t._dirty=!0,t},mt.squaredDistance=mt.sqrDist=function(t,e){return pt.sqrDist(t.array,e.array)},mt.squaredLength=mt.sqrLen=function(t){return pt.sqrLen(t.array)},mt.subtract=mt.sub=function(t,e,r){return pt.subtract(t.array,e.array,r.array),t._dirty=!0,t},mt.transformMat2=function(t,e,r){return pt.transformMat2(t.array,e.array,r.array),t._dirty=!0,t},mt.transformMat2d=function(t,e,r){return pt.transformMat2d(t.array,e.array,r.array),t._dirty=!0,t},mt.transformMat3=function(t,e,r){return pt.transformMat3(t.array,e.array,r.array),t._dirty=!0,t},mt.transformMat4=function(t,e,r){return pt.transformMat4(t.array,e.array,r.array),t._dirty=!0,t};const _t=mt;var vt={};function yt(t){for(var e=t.split("\n"),r=0,i=e.length;r<i;r++)e[r]=r+1+": "+e[r];return e.join("\n")}function xt(t,e,r){if(!t.getShaderParameter(e,t.COMPILE_STATUS))return[t.getShaderInfoLog(e),yt(r)].join("\n")}var bt=new G.Float32Array(16);const wt=m.extend({uniformSemantics:{},attributes:{}},(function(){this._locations={},this._textureSlot=0,this._program=null}),{bind:function(t){this._textureSlot=0,t.gl.useProgram(this._program)},hasUniform:function(t){return null!=this._locations[t]},useTextureSlot:function(t,e,r){e&&(t.gl.activeTexture(t.gl.TEXTURE0+r),e.isRenderable()?e.bind(t):e.unbind(t))},currentTextureSlot:function(){return this._textureSlot},resetTextureSlot:function(t){this._textureSlot=t||0},takeCurrentTextureSlot:function(t,e){var r=this._textureSlot;return this.useTextureSlot(t,e,r),this._textureSlot++,r},setUniform:function(t,e,r,i){var n=this._locations[r];if(null==n)return!1;switch(e){case"m4":if(!(i instanceof Float32Array)){for(var a=0;a<i.length;a++)bt[a]=i[a];i=bt}t.uniformMatrix4fv(n,!1,i);break;case"2i":t.uniform2i(n,i[0],i[1]);break;case"2f":t.uniform2f(n,i[0],i[1]);break;case"3i":t.uniform3i(n,i[0],i[1],i[2]);break;case"3f":t.uniform3f(n,i[0],i[1],i[2]);break;case"4i":t.uniform4i(n,i[0],i[1],i[2],i[3]);break;case"4f":t.uniform4f(n,i[0],i[1],i[2],i[3]);break;case"1i":t.uniform1i(n,i);break;case"1f":t.uniform1f(n,i);break;case"1fv":t.uniform1fv(n,i);break;case"1iv":t.uniform1iv(n,i);break;case"2iv":t.uniform2iv(n,i);break;case"2fv":t.uniform2fv(n,i);break;case"3iv":t.uniform3iv(n,i);break;case"3fv":t.uniform3fv(n,i);break;case"4iv":t.uniform4iv(n,i);break;case"4fv":t.uniform4fv(n,i);break;case"m2":case"m2v":t.uniformMatrix2fv(n,!1,i);break;case"m3":case"m3v":t.uniformMatrix3fv(n,!1,i);break;case"m4v":if(Array.isArray(i)&&Array.isArray(i[0])){var o=new G.Float32Array(16*i.length),s=0;for(a=0;a<i.length;a++)for(var l=i[a],h=0;h<16;h++)o[s++]=l[h];t.uniformMatrix4fv(n,!1,o)}else t.uniformMatrix4fv(n,!1,i)}return!0},setUniformOfSemantic:function(t,e,r){var i=this.uniformSemantics[e];return!!i&&this.setUniform(t,i.type,i.symbol,r)},enableAttributes:function(t,e,r){var i,n=t.gl,a=this._program,o=this._locations;(i=r?r.__enabledAttributeList:vt[t.__uid__])||(i=r?r.__enabledAttributeList=[]:vt[t.__uid__]=[]);for(var s=[],l=0;l<e.length;l++){var h=e[l];if(this.attributes[h]){var u=o[h];if(null==u){if(-1===(u=n.getAttribLocation(a,h))){s[l]=-1;continue}o[h]=u}s[l]=u,i[u]?i[u]=2:i[u]=1}else s[l]=-1}for(l=0;l<i.length;l++)switch(i[l]){case 1:n.enableVertexAttribArray(l),i[l]=3;break;case 2:i[l]=3;break;case 3:n.disableVertexAttribArray(l),i[l]=0}return s},getAttribLocation:function(t,e){var r=this._locations,i=r[e];return null==i&&(i=t.getAttribLocation(this._program,e),r[e]=i),i},buildProgram:function(t,e,r,i){var n=t.createShader(t.VERTEX_SHADER),a=t.createProgram();t.shaderSource(n,r),t.compileShader(n);var o=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(o,i),t.compileShader(o);var s=xt(t,n,r);if(s)return s;if(s=xt(t,o,i))return s;if(t.attachShader(a,n),t.attachShader(a,o),e.attributeSemantics.POSITION)t.bindAttribLocation(a,0,e.attributeSemantics.POSITION.symbol);else{var l=Object.keys(this.attributes);t.bindAttribLocation(a,0,l[0])}if(t.linkProgram(a),t.deleteShader(n),t.deleteShader(o),this._program=a,this.vertexCode=r,this.fragmentCode=i,!t.getProgramParameter(a,t.LINK_STATUS))return"Could not link program\n"+t.getProgramInfoLog(a);for(var h=0;h<e.uniforms.length;h++){var u=e.uniforms[h];this._locations[u]=t.getUniformLocation(a,u)}}});var Tt=/for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;function St(t,e,r){var i={};for(var n in r)i[n+"_COUNT"]=r[n];return t.replace(Tt,(function(t,r,n,a){var o="";isNaN(r)&&(r=r in e?e[r]:i[r]),isNaN(n)&&(n=n in e?e[n]:i[n]);for(var s=parseInt(r);s<parseInt(n);s++)o+="{"+a.replace(/float\s*\(\s*_idx_\s*\)/g,s.toFixed(1)).replace(/_idx_/g,s)+"}";return o}))}function Mt(t,e,r){var i=[];if(e)for(var n in e){var a=e[n];a>0&&i.push("#define "+n.toUpperCase()+"_COUNT "+a)}if(r)for(var o=0;o<r.length;o++){var s=r[o];i.push("#define "+s.toUpperCase()+"_ENABLED")}for(var s in t){var l=t[s];null===l?i.push("#define "+s):i.push("#define "+s+" "+l.toString())}return i.join("\n")}function At(t){this._renderer=t,this._cache={}}At.prototype.getProgram=function(t,e,r){var i=this._cache,n=t.isSkinnedMesh&&t.isSkinnedMesh(),a=t.isInstancedMesh&&t.isInstancedMesh(),o="s"+e.shader.shaderID+"m"+e.getProgramKey();if(r&&(o+="se"+r.getProgramKey(t.lightGroup)),n&&(o+=",sk"+t.joints.length),a&&(o+=",is"),v=i[o])return v;var s=r?r.getLightsNumbers(t.lightGroup):{},l=this._renderer,h=l.gl,u=e.getEnabledTextures(),c="";if(n){var d={SKINNING:null,JOINT_COUNT:t.joints.length};t.joints.length>l.getMaxJointNumber()&&(d.USE_SKIN_MATRICES_TEXTURE=null),c+="\n"+Mt(d)+"\n"}a&&(c+="\n#define INSTANCING\n");var f=c+Mt(e.vertexDefines,s,u),p=c+Mt(e.fragmentDefines,s,u),m=f+"\n"+e.shader.vertex,g=["OES_standard_derivatives","EXT_shader_texture_lod"].filter((function(t){return null!=l.getGLExtension(t)}));g.indexOf("EXT_shader_texture_lod")>=0&&(p+="\n#define SUPPORT_TEXTURE_LOD"),g.indexOf("OES_standard_derivatives")>=0&&(p+="\n#define SUPPORT_STANDARD_DERIVATIVES");var _,v,y=function(t){for(var e=[],r=0;r<t.length;r++)e.push("#extension GL_"+t[r]+" : enable");return e.join("\n")}(g)+"\n"+["precision",_=e.precision,"float"].join(" ")+";\n"+["precision",_,"int"].join(" ")+";\n"+["precision",_,"sampler2D"].join(" ")+";\n\n"+p+"\n"+e.shader.fragment,x=St(m,e.vertexDefines,s),b=St(y,e.fragmentDefines,s);(v=new wt).uniformSemantics=e.shader.uniformSemantics,v.attributes=e.shader.attributes;var w=v.buildProgram(h,e.shader,x,b);return v.__error=w,i[o]=v,v};const Ct=At;var Et=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,Dt=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,Lt=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,Pt={bool:"1i",int:"1i",sampler2D:"t",samplerCube:"t",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"};function Ot(t){for(var e=[],r=0;r<t;r++)e[r]=0;return e}var Nt={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return Ot(2)},vec3:function(){return Ot(3)},vec4:function(){return Ot(4)},ivec2:function(){return Ot(2)},ivec3:function(){return Ot(3)},ivec4:function(){return Ot(4)},mat2:function(){return Ot(4)},mat3:function(){return Ot(9)},mat4:function(){return Ot(16)},array:function(){return[]}},It=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],Rt=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],Bt=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],Ft={vec4:4,vec3:3,vec2:2,float:1},zt={},kt={};function Gt(t){return t.replace(/[ \t]*\/\/.*\n/g,"").replace(/[ \t]*\/\*[\s\S]*?\*\//g,"")}function Ut(){console.error("Wrong uniform/attributes syntax")}function Ht(t,e){for(var r=/[,=\(\):]/,i=e.replace(/:\s*\[\s*(.*)\s*\]/g,"="+t+"($1)").replace(/\s+/g,"").split(/(?=[,=\(\):])/g),n=[],a=0;a<i.length;a++)i[a].match(r)?n.push(i[a].charAt(0),i[a].slice(1)):n.push(i[a]);var o,s=0,l={},h=null;function u(t){t||Ut();var e=t.match(/\[(.*?)\]/);o=t.replace(/\[(.*?)\]/,""),l[o]={},e&&(l[o].isArray=!0,l[o].arraySize=e[1])}for(u((i=n)[0]),a=1;a<i.length;a++){var c=i[a];if(c)if("="!==c)if(":"!==c)if(","!==c)if(")"!==c)if("("!==c)if(c.indexOf("vec")>=0){if(1!==s&&4!==s){Ut();break}s=2,h=[]}else if(1!==s)if(4!==s)u(c),s=0;else{var d=c;It.indexOf(d)>=0||Rt.indexOf(d)>=0||Bt.indexOf(d)>=0?l[o].semantic=d:"ignore"===d||"unconfigurable"===d?l[o].ignore=!0:l[o].value="bool"===t?"true"===d:parseFloat(d)}else l[o].value="bool"===t?"true"===c:parseFloat(c),h=null;else{if(2!==s){Ut();break}if(!(h instanceof Array)){Ut();break}h.push(+i[++a])}else l[o].value=new G.Float32Array(h),h=null,s=5;else if(2===s){if(!(h instanceof Array)){Ut();break}h.push(+i[++a])}else s=5;else s=4;else{if(0!==s&&3!==s){Ut();break}s=1}}return l}function Vt(t,e){"object"==typeof t&&(e=t.fragment,t=t.vertex),t=Gt(t),e=Gt(e),this._shaderID=function(t,e){var r="vertex:"+t+"fragment:"+e;if(zt[r])return zt[r];var i=f.genGUID();return zt[r]=i,kt[i]={vertex:t,fragment:e},i}(t,e),this._vertexCode=Vt.parseImport(t),this._fragmentCode=Vt.parseImport(e),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}Vt.prototype={constructor:Vt,createUniforms:function(){var t={};for(var e in this.uniformTemplates){var r=this.uniformTemplates[e];t[e]={type:r.type,value:r.value()}}return t},_parseImport:function(){this._vertexCode=Vt.parseImport(this.vertex),this._fragmentCode=Vt.parseImport(this.fragment)},_addSemanticUniform:function(t,e,r){if(It.indexOf(r)>=0)this.attributeSemantics[r]={symbol:t,type:e};else if(Bt.indexOf(r)>=0){var i=!1,n=r;r.match(/TRANSPOSE$/)&&(i=!0,n=r.slice(0,-9)),this.matrixSemantics[r]={symbol:t,type:e,isTranspose:i,semanticNoTranspose:n}}else Rt.indexOf(r)>=0&&(this.uniformSemantics[r]={symbol:t,type:e})},_addMaterialUniform:function(t,e,r,i,n,a){a[t]={type:r,value:n?Nt.array:i||Nt[e],semantic:null}},_parseUniforms:function(){var t={},e=this;function r(t){return null!=t?function(){return t}:null}function i(i,n,a){var o=Ht(n,a),s=[];for(var l in o){var h=o[l],u=h.semantic,c=l,d=Pt[n],f=r(o[l].value);o[l].isArray&&(c+="["+o[l].arraySize+"]",d+="v"),s.push(c),e._uniformList.push(l),h.ignore||("sampler2D"!==n&&"samplerCube"!==n||(e.textures[l]={shaderType:"fragment",type:n}),u?e._addSemanticUniform(l,d,u):e._addMaterialUniform(l,n,d,f,o[l].isArray,t))}return s.length>0?"uniform "+n+" "+s.join(",")+";\n":""}this._uniformList=[],this._vertexCode=this._vertexCode.replace(Et,i),this._fragmentCode=this._fragmentCode.replace(Et,i),e.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseAttributes:function(){var t={},e=this;this._vertexCode=this._vertexCode.replace(Dt,(function(r,i,n){var a=Ht(i,n),o=Ft[i]||1,s=[];for(var l in a){var h=a[l].semantic;if(t[l]={type:"float",size:o,semantic:h||null},h){if(It.indexOf(h)<0)throw new Error('Unkown semantic "'+h+'"');e.attributeSemantics[h]={symbol:l,type:i}}s.push(l)}return"attribute "+i+" "+s.join(",")+";\n"})),this.attributes=t},_parseDefines:function(){var t=this;function e(e,r,i){var n=t.fragmentDefines;return n[r]||(n[r]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}this._vertexCode=this._vertexCode.replace(Lt,e),this._fragmentCode=this._fragmentCode.replace(Lt,e)},clone:function(){var t=kt[this._shaderID];return new Vt(t.vertex,t.fragment)}},Object.defineProperty&&(Object.defineProperty(Vt.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(Vt.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(Vt.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(Vt.prototype,"uniforms",{get:function(){return this._uniformList}}));var Wt=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;Vt.parseImport=function(t){return t.replace(Wt,(function(t,e,r){return(t=Vt.source(r))?Vt.parseImport(t):(console.error('Shader chunk "'+r+'" not existed in library'),"")}))};var jt=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;Vt.import=function(t){t.replace(jt,(function(t,e,r,i){if(i=i.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"")){for(var n,a=r.split("."),o=Vt.codes,s=0;s<a.length-1;)o[n=a[s++]]||(o[n]={}),o=o[n];o[n=a[s]]=i}return i}))},Vt.codes={},Vt.source=function(t){for(var e=t.split("."),r=Vt.codes,i=0;r&&i<e.length;)r=r[e[i++]];return"string"!=typeof r?(console.error('Shader "'+t+'" not existed in library'),""):r};const Xt=Vt,qt="@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec4 P = vec4(pos, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = WVP * P;\n v_Texcoord = uv * uvRepeat + uvOffset;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end";var Zt={create:function(){var t=new ct(16);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},clone:function(t){var e=new ct(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},copy:function(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},identity:function(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},transpose:function(t,e){if(t===e){var r=e[1],i=e[2],n=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=a,t[11]=e[14],t[12]=n,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15],v=r*s-i*o,y=r*l-n*o,x=r*h-a*o,b=i*l-n*s,w=i*h-a*s,T=n*h-a*l,S=u*m-c*p,M=u*g-d*p,A=u*_-f*p,C=c*g-d*m,E=c*_-f*m,D=d*_-f*g,L=v*D-y*E+x*C+b*A-w*M+T*S;return L?(L=1/L,t[0]=(s*D-l*E+h*C)*L,t[1]=(n*E-i*D-a*C)*L,t[2]=(m*T-g*w+_*b)*L,t[3]=(d*w-c*T-f*b)*L,t[4]=(l*A-o*D-h*M)*L,t[5]=(r*D-n*A+a*M)*L,t[6]=(g*x-p*T-_*y)*L,t[7]=(u*T-d*x+f*y)*L,t[8]=(o*E-s*A+h*S)*L,t[9]=(i*A-r*E-a*S)*L,t[10]=(p*w-m*x+_*v)*L,t[11]=(c*x-u*w-f*v)*L,t[12]=(s*M-o*C-l*S)*L,t[13]=(r*C-i*M+n*S)*L,t[14]=(m*y-p*b-g*v)*L,t[15]=(u*b-c*y+d*v)*L,t):null},adjoint:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15];return t[0]=s*(d*_-f*g)-c*(l*_-h*g)+m*(l*f-h*d),t[1]=-(i*(d*_-f*g)-c*(n*_-a*g)+m*(n*f-a*d)),t[2]=i*(l*_-h*g)-s*(n*_-a*g)+m*(n*h-a*l),t[3]=-(i*(l*f-h*d)-s*(n*f-a*d)+c*(n*h-a*l)),t[4]=-(o*(d*_-f*g)-u*(l*_-h*g)+p*(l*f-h*d)),t[5]=r*(d*_-f*g)-u*(n*_-a*g)+p*(n*f-a*d),t[6]=-(r*(l*_-h*g)-o*(n*_-a*g)+p*(n*h-a*l)),t[7]=r*(l*f-h*d)-o*(n*f-a*d)+u*(n*h-a*l),t[8]=o*(c*_-f*m)-u*(s*_-h*m)+p*(s*f-h*c),t[9]=-(r*(c*_-f*m)-u*(i*_-a*m)+p*(i*f-a*c)),t[10]=r*(s*_-h*m)-o*(i*_-a*m)+p*(i*h-a*s),t[11]=-(r*(s*f-h*c)-o*(i*f-a*c)+u*(i*h-a*s)),t[12]=-(o*(c*g-d*m)-u*(s*g-l*m)+p*(s*d-l*c)),t[13]=r*(c*g-d*m)-u*(i*g-n*m)+p*(i*d-n*c),t[14]=-(r*(s*g-l*m)-o*(i*g-n*m)+p*(i*l-n*s)),t[15]=r*(s*d-l*c)-o*(i*d-n*c)+u*(i*l-n*s),t},determinant:function(t){var e=t[0],r=t[1],i=t[2],n=t[3],a=t[4],o=t[5],s=t[6],l=t[7],h=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],m=t[14],g=t[15];return(e*o-r*a)*(c*g-d*m)-(e*s-i*a)*(u*g-d*p)+(e*l-n*a)*(u*m-c*p)+(r*s-i*o)*(h*g-d*f)-(r*l-n*o)*(h*m-c*f)+(i*l-n*s)*(h*p-u*f)},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],m=e[12],g=e[13],_=e[14],v=e[15],y=r[0],x=r[1],b=r[2],w=r[3];return t[0]=y*i+x*s+b*c+w*m,t[1]=y*n+x*l+b*d+w*g,t[2]=y*a+x*h+b*f+w*_,t[3]=y*o+x*u+b*p+w*v,y=r[4],x=r[5],b=r[6],w=r[7],t[4]=y*i+x*s+b*c+w*m,t[5]=y*n+x*l+b*d+w*g,t[6]=y*a+x*h+b*f+w*_,t[7]=y*o+x*u+b*p+w*v,y=r[8],x=r[9],b=r[10],w=r[11],t[8]=y*i+x*s+b*c+w*m,t[9]=y*n+x*l+b*d+w*g,t[10]=y*a+x*h+b*f+w*_,t[11]=y*o+x*u+b*p+w*v,y=r[12],x=r[13],b=r[14],w=r[15],t[12]=y*i+x*s+b*c+w*m,t[13]=y*n+x*l+b*d+w*g,t[14]=y*a+x*h+b*f+w*_,t[15]=y*o+x*u+b*p+w*v,t},multiplyAffine:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[4],s=e[5],l=e[6],h=e[8],u=e[9],c=e[10],d=e[12],f=e[13],p=e[14],m=r[0],g=r[1],_=r[2];return t[0]=m*i+g*o+_*h,t[1]=m*n+g*s+_*u,t[2]=m*a+g*l+_*c,m=r[4],g=r[5],_=r[6],t[4]=m*i+g*o+_*h,t[5]=m*n+g*s+_*u,t[6]=m*a+g*l+_*c,m=r[8],g=r[9],_=r[10],t[8]=m*i+g*o+_*h,t[9]=m*n+g*s+_*u,t[10]=m*a+g*l+_*c,m=r[12],g=r[13],_=r[14],t[12]=m*i+g*o+_*h+d,t[13]=m*n+g*s+_*u+f,t[14]=m*a+g*l+_*c+p,t}};Zt.mul=Zt.multiply,Zt.mulAffine=Zt.multiplyAffine,Zt.translate=function(t,e,r){var i,n,a,o,s,l,h,u,c,d,f,p,m=r[0],g=r[1],_=r[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*_+e[12],t[13]=e[1]*m+e[5]*g+e[9]*_+e[13],t[14]=e[2]*m+e[6]*g+e[10]*_+e[14],t[15]=e[3]*m+e[7]*g+e[11]*_+e[15]):(i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=h,t[7]=u,t[8]=c,t[9]=d,t[10]=f,t[11]=p,t[12]=i*m+s*g+c*_+e[12],t[13]=n*m+l*g+d*_+e[13],t[14]=a*m+h*g+f*_+e[14],t[15]=o*m+u*g+p*_+e[15]),t},Zt.scale=function(t,e,r){var i=r[0],n=r[1],a=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},Zt.rotate=function(t,e,r,i){var n,a,o,s,l,h,u,c,d,f,p,m,g,_,v,y,x,b,w,T,S,M,A,C,E=i[0],D=i[1],L=i[2],P=Math.sqrt(E*E+D*D+L*L);return Math.abs(P)<ut?null:(E*=P=1/P,D*=P,L*=P,n=Math.sin(r),o=1-(a=Math.cos(r)),s=e[0],l=e[1],h=e[2],u=e[3],c=e[4],d=e[5],f=e[6],p=e[7],m=e[8],g=e[9],_=e[10],v=e[11],y=E*E*o+a,x=D*E*o+L*n,b=L*E*o-D*n,w=E*D*o-L*n,T=D*D*o+a,S=L*D*o+E*n,M=E*L*o+D*n,A=D*L*o-E*n,C=L*L*o+a,t[0]=s*y+c*x+m*b,t[1]=l*y+d*x+g*b,t[2]=h*y+f*x+_*b,t[3]=u*y+p*x+v*b,t[4]=s*w+c*T+m*S,t[5]=l*w+d*T+g*S,t[6]=h*w+f*T+_*S,t[7]=u*w+p*T+v*S,t[8]=s*M+c*A+m*C,t[9]=l*M+d*A+g*C,t[10]=h*M+f*A+_*C,t[11]=u*M+p*A+v*C,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},Zt.rotateX=function(t,e,r){var i=Math.sin(r),n=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],h=e[8],u=e[9],c=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*n+h*i,t[5]=o*n+u*i,t[6]=s*n+c*i,t[7]=l*n+d*i,t[8]=h*n-a*i,t[9]=u*n-o*i,t[10]=c*n-s*i,t[11]=d*n-l*i,t},Zt.rotateY=function(t,e,r){var i=Math.sin(r),n=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],h=e[8],u=e[9],c=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*n-h*i,t[1]=o*n-u*i,t[2]=s*n-c*i,t[3]=l*n-d*i,t[8]=a*i+h*n,t[9]=o*i+u*n,t[10]=s*i+c*n,t[11]=l*i+d*n,t},Zt.rotateZ=function(t,e,r){var i=Math.sin(r),n=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],h=e[4],u=e[5],c=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*n+h*i,t[1]=o*n+u*i,t[2]=s*n+c*i,t[3]=l*n+d*i,t[4]=h*n-a*i,t[5]=u*n-o*i,t[6]=c*n-s*i,t[7]=d*n-l*i,t},Zt.fromRotationTranslation=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=i+i,l=n+n,h=a+a,u=i*s,c=i*l,d=i*h,f=n*l,p=n*h,m=a*h,g=o*s,_=o*l,v=o*h;return t[0]=1-(f+m),t[1]=c+v,t[2]=d-_,t[3]=0,t[4]=c-v,t[5]=1-(u+m),t[6]=p+g,t[7]=0,t[8]=d+_,t[9]=p-g,t[10]=1-(u+f),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},Zt.fromQuat=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r+r,s=i+i,l=n+n,h=r*o,u=i*o,c=i*s,d=n*o,f=n*s,p=n*l,m=a*o,g=a*s,_=a*l;return t[0]=1-c-p,t[1]=u+_,t[2]=d-g,t[3]=0,t[4]=u-_,t[5]=1-h-p,t[6]=f+m,t[7]=0,t[8]=d+g,t[9]=f-m,t[10]=1-h-c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},Zt.frustum=function(t,e,r,i,n,a,o){var s=1/(r-e),l=1/(n-i),h=1/(a-o);return t[0]=2*a*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*a*l,t[6]=0,t[7]=0,t[8]=(r+e)*s,t[9]=(n+i)*l,t[10]=(o+a)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*a*2*h,t[15]=0,t},Zt.perspective=function(t,e,r,i,n){var a=1/Math.tan(e/2),o=1/(i-n);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(n+i)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*n*i*o,t[15]=0,t},Zt.ortho=function(t,e,r,i,n,a,o){var s=1/(e-r),l=1/(i-n),h=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+r)*s,t[13]=(n+i)*l,t[14]=(o+a)*h,t[15]=1,t},Zt.lookAt=function(t,e,r,i){var n,a,o,s,l,h,u,c,d,f,p=e[0],m=e[1],g=e[2],_=i[0],v=i[1],y=i[2],x=r[0],b=r[1],w=r[2];return Math.abs(p-x)<ut&&Math.abs(m-b)<ut&&Math.abs(g-w)<ut?Zt.identity(t):(u=p-x,c=m-b,d=g-w,n=v*(d*=f=1/Math.sqrt(u*u+c*c+d*d))-y*(c*=f),a=y*(u*=f)-_*d,o=_*c-v*u,(f=Math.sqrt(n*n+a*a+o*o))?(n*=f=1/f,a*=f,o*=f):(n=0,a=0,o=0),s=c*o-d*a,l=d*n-u*o,h=u*a-c*n,(f=Math.sqrt(s*s+l*l+h*h))?(s*=f=1/f,l*=f,h*=f):(s=0,l=0,h=0),t[0]=n,t[1]=s,t[2]=u,t[3]=0,t[4]=a,t[5]=l,t[6]=c,t[7]=0,t[8]=o,t[9]=h,t[10]=d,t[11]=0,t[12]=-(n*p+a*m+o*g),t[13]=-(s*p+l*m+h*g),t[14]=-(u*p+c*m+d*g),t[15]=1,t)},Zt.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2)+Math.pow(t[9],2)+Math.pow(t[10],2)+Math.pow(t[11],2)+Math.pow(t[12],2)+Math.pow(t[13],2)+Math.pow(t[14],2)+Math.pow(t[15],2))};const Yt=Zt;var Kt={create:function(){var t=new ct(3);return t[0]=0,t[1]=0,t[2]=0,t},clone:function(t){var e=new ct(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},fromValues:function(t,e,r){var i=new ct(3);return i[0]=t,i[1]=e,i[2]=r,i},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},set:function(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},subtract:function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}};Kt.sub=Kt.subtract,Kt.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t},Kt.mul=Kt.multiply,Kt.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t},Kt.div=Kt.divide,Kt.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},Kt.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},Kt.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},Kt.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t},Kt.distance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2];return Math.sqrt(r*r+i*i+n*n)},Kt.dist=Kt.distance,Kt.squaredDistance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2];return r*r+i*i+n*n},Kt.sqrDist=Kt.squaredDistance,Kt.length=function(t){var e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)},Kt.len=Kt.length,Kt.squaredLength=function(t){var e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i},Kt.sqrLen=Kt.squaredLength,Kt.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},Kt.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},Kt.normalize=function(t,e){var r=e[0],i=e[1],n=e[2],a=r*r+i*i+n*n;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t},Kt.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},Kt.cross=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=n*l-a*s,t[1]=a*o-i*l,t[2]=i*s-n*o,t},Kt.lerp=function(t,e,r,i){var n=e[0],a=e[1],o=e[2];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t[2]=o+i*(r[2]-o),t},Kt.random=function(t,e){e=e||1;var r=2*dt()*Math.PI,i=2*dt()-1,n=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=i*e,t},Kt.transformMat4=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[3]*i+r[7]*n+r[11]*a+r[15];return o=o||1,t[0]=(r[0]*i+r[4]*n+r[8]*a+r[12])/o,t[1]=(r[1]*i+r[5]*n+r[9]*a+r[13])/o,t[2]=(r[2]*i+r[6]*n+r[10]*a+r[14])/o,t},Kt.transformMat3=function(t,e,r){var i=e[0],n=e[1],a=e[2];return t[0]=i*r[0]+n*r[3]+a*r[6],t[1]=i*r[1]+n*r[4]+a*r[7],t[2]=i*r[2]+n*r[5]+a*r[8],t},Kt.transformQuat=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2],h=r[3],u=h*i+s*a-l*n,c=h*n+l*i-o*a,d=h*a+o*n-s*i,f=-o*i-s*n-l*a;return t[0]=u*h+f*-o+c*-l-d*-s,t[1]=c*h+f*-s+d*-o-u*-l,t[2]=d*h+f*-l+u*-s-c*-o,t},Kt.rotateX=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[0],a[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),a[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Kt.rotateY=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),a[1]=n[1],a[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Kt.rotateZ=function(t,e,r,i){var n=[],a=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],a[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),a[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),a[2]=n[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},Kt.forEach=function(){var t=Kt.create();return function(e,r,i,n,a,o){var s,l;for(r||(r=3),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,s=i;s<l;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2];return e}}(),Kt.angle=function(t,e){var r=Kt.fromValues(t[0],t[1],t[2]),i=Kt.fromValues(e[0],e[1],e[2]);Kt.normalize(r,r),Kt.normalize(i,i);var n=Kt.dot(r,i);return n>1?0:Math.acos(n)};const Qt=Kt;Xt.import(qt);var Jt=Yt.create,$t={};function te(t){return t.material}function ee(t,e,r){return e.uniforms[r].value}function re(t,e,r,i){return r!==i}function ie(t){return!0}function ne(){}var ae={float:S,byte:5120,ubyte:T,short:5122,ushort:5123};function oe(t,e,r){this.availableAttributes=t,this.availableAttributeSymbols=e,this.indicesBuffer=r,this.vao=null}function se(t){var e,r;this.bind=function(t){e||((e=G.createCanvas()).width=e.height=1,e.getContext("2d"));var i=t.gl,n=!r;n&&(r=i.createTexture()),i.bindTexture(i.TEXTURE_2D,r),n&&i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e)},this.unbind=function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var le=m.extend((function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},maxJointNumber:20,__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}}),(function(){this.canvas||(this.canvas=G.createCanvas());var t=this.canvas;try{var e={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!this.gl)throw new Error;this._glinfo=new v(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(t){throw"Error creating WebGL Context "+t}this._programMgr=new Ct(this),this._placeholderTexture=new se(this)}),{resize:function(t,e){var r=this.canvas,i=this.devicePixelRatio;null!=t?(r.style&&(r.style.width=t+"px",r.style.height=e+"px"),r.width=t*i,r.height=e*i,this._width=t,this._height=e):(this._width=r.width/i,this._height=r.height/i),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var t=this.viewport;return t.width/t.height},setDevicePixelRatio:function(t){this.devicePixelRatio=t,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(t){return this._glinfo.getExtension(t)},getGLParameter:function(t){return this._glinfo.getParameter(t)},setViewport:function(t,e,r,i,n){if("object"==typeof t){var a=t;t=a.x,e=a.y,r=a.width,i=a.height,n=a.devicePixelRatio}n=n||this.devicePixelRatio,this.gl.viewport(t*n,e*n,r*n,i*n),this.viewport={x:t,y:e,width:r,height:i,devicePixelRatio:n}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var t=this._clearStack.pop();this.clearColor=t.clearColor,this.clearBit=t.clearBit}},bindSceneRendering:function(t){this._sceneRendering=t},render:function(t,e,r,i){var n=this.gl,a=this.clearColor;if(this.clearBit){n.colorMask(!0,!0,!0,!0),n.depthMask(!0);var o=this.viewport,s=!1,l=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||l&&l!==this.devicePixelRatio||o.x||o.y)&&(s=!0,n.enable(n.SCISSOR_TEST),n.scissor(o.x*l,o.y*l,o.width*l,o.height*l)),n.clearColor(a[0],a[1],a[2],a[3]),n.clear(this.clearBit),s&&n.disable(n.SCISSOR_TEST)}if(r||t.update(!1),t.updateLights(),e=e||t.getMainCamera()){e.update();var h=t.updateRenderList(e,!0);this._sceneRendering=t;var u=h.opaque,c=h.transparent,d=t.material;t.trigger("beforerender",this,t,e,h),i?(this.renderPreZ(u,t,e),n.depthFunc(n.LEQUAL)):n.depthFunc(n.LESS);for(var f=Jt(),p=Qt.create(),m=0;m<c.length;m++){var g=c[m];Yt.multiplyAffine(f,e.viewMatrix.array,g.worldTransform.array),Qt.transformMat4(p,g.position.array,f),g.__depth=p[2]}this.renderPass(u,e,{getMaterial:function(t){return d||t.material},sortCompare:this.opaqueSortCompare}),this.renderPass(c,e,{getMaterial:function(t){return d||t.material},sortCompare:this.transparentSortCompare}),t.trigger("afterrender",this,t,e,h),this._sceneRendering=null}else console.error("Can't find camera in the scene.")},getProgram:function(t,e,r){return e=e||t.material,this._programMgr.getProgram(t,e,r)},validateProgram:function(t){if(t.__error){var e=t.__error;if($t[t.__uid__])return;if($t[t.__uid__]=!0,this.throwError)throw new Error(e);this.trigger("error",e)}},updatePrograms:function(t,e,r){var i=r&&r.getMaterial||te;e=e||null;for(var n=0;n<t.length;n++){var a=t[n],o=i.call(this,a);if(n>0){var s=t[n-1],l=s.joints?s.joints.length:0;if((a.joints?a.joints.length:0)===l&&a.material===s.material&&a.lightGroup===s.lightGroup){a.__program=s.__program;continue}}var h=this._programMgr.getProgram(a,o,e);this.validateProgram(h),a.__program=h}},renderPass:function(t,e,r){this.trigger("beforerenderpass",this,t,e,r),(r=r||{}).getMaterial=r.getMaterial||te,r.getUniform=r.getUniform||ee,r.isMaterialChanged=r.isMaterialChanged||re,r.beforeRender=r.beforeRender||ne,r.afterRender=r.afterRender||ne;var i=r.ifRender||ie;this.updatePrograms(t,this._sceneRendering,r),r.sortCompare&&t.sort(r.sortCompare);var n=this.viewport,a=n.devicePixelRatio,o=[n.x*a,n.y*a,n.width*a,n.height*a],s=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*s,this._height*s],h=[o[2],o[3]],u=Date.now();e?(Yt.copy(he.VIEW,e.viewMatrix.array),Yt.copy(he.PROJECTION,e.projectionMatrix.array),Yt.copy(he.VIEWINVERSE,e.worldTransform.array)):(Yt.identity(he.VIEW),Yt.identity(he.PROJECTION),Yt.identity(he.VIEWINVERSE)),Yt.multiply(he.VIEWPROJECTION,he.PROJECTION,he.VIEW),Yt.invert(he.PROJECTIONINVERSE,he.PROJECTION),Yt.invert(he.VIEWPROJECTIONINVERSE,he.VIEWPROJECTION);for(var c,d,f,p,m,g,_,v,y,x,b,w,T=this.gl,S=this._sceneRendering,M=0;M<t.length;M++){var A,C=t[M],E=null!=C.worldTransform;if(i(C)){E&&(A=C.isSkinnedMesh&&C.isSkinnedMesh()?C.offsetMatrix?C.offsetMatrix.array:he.IDENTITY:C.worldTransform.array);var D=C.geometry,L=r.getMaterial.call(this,C),P=C.__program,O=L.shader,N=D.__uid__+"-"+P.__uid__,I=N!==x;x=N,E&&(Yt.copy(he.WORLD,A),Yt.multiply(he.WORLDVIEWPROJECTION,he.VIEWPROJECTION,A),Yt.multiplyAffine(he.WORLDVIEW,he.VIEW,A),(O.matrixSemantics.WORLDINVERSE||O.matrixSemantics.WORLDINVERSETRANSPOSE)&&Yt.invert(he.WORLDINVERSE,A),(O.matrixSemantics.WORLDVIEWINVERSE||O.matrixSemantics.WORLDVIEWINVERSETRANSPOSE)&&Yt.invert(he.WORLDVIEWINVERSE,he.WORLDVIEW),(O.matrixSemantics.WORLDVIEWPROJECTIONINVERSE||O.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE)&&Yt.invert(he.WORLDVIEWPROJECTIONINVERSE,he.WORLDVIEWPROJECTION)),C.beforeRender&&C.beforeRender(this),r.beforeRender.call(this,C,L,c);var R=P!==d;R?(P.bind(this),P.setUniformOfSemantic(T,"VIEWPORT",o),P.setUniformOfSemantic(T,"WINDOW_SIZE",l),e&&(P.setUniformOfSemantic(T,"NEAR",e.near),P.setUniformOfSemantic(T,"FAR",e.far)),P.setUniformOfSemantic(T,"DEVICEPIXELRATIO",a),P.setUniformOfSemantic(T,"TIME",u),P.setUniformOfSemantic(T,"VIEWPORT_SIZE",h),S&&S.setLightUniforms(P,C.lightGroup,this)):P=d,(R||r.isMaterialChanged(C,f,L,c))&&(L.depthTest!==p&&(L.depthTest?T.enable(T.DEPTH_TEST):T.disable(T.DEPTH_TEST),p=L.depthTest),L.depthMask!==m&&(T.depthMask(L.depthMask),m=L.depthMask),L.transparent!==y&&(L.transparent?T.enable(T.BLEND):T.disable(T.BLEND),y=L.transparent),L.transparent&&(L.blend?L.blend(T):(T.blendEquationSeparate(T.FUNC_ADD,T.FUNC_ADD),T.blendFuncSeparate(T.SRC_ALPHA,T.ONE_MINUS_SRC_ALPHA,T.ONE,T.ONE_MINUS_SRC_ALPHA))),w=this._bindMaterial(C,L,P,f||null,c||null,d||null,r.getUniform),c=L);var B=O.matrixSemanticKeys;if(E)for(var F=0;F<B.length;F++){var z=B[F],k=O.matrixSemantics[z],G=he[z];if(k.isTranspose){var U=he[k.semanticNoTranspose];Yt.transpose(G,U)}P.setUniform(T,k.type,k.symbol,G)}C.cullFace!==_&&(_=C.cullFace,T.cullFace(_)),C.frontFace!==v&&(v=C.frontFace,T.frontFace(v)),C.culling!==g&&((g=C.culling)?T.enable(T.CULL_FACE):T.disable(T.CULL_FACE)),this._updateSkeleton(C,P,w),I&&(b=this._bindVAO(null,O,D,P)),this._renderObject(C,b,P),r.afterRender(this,C),C.afterRender&&C.afterRender(this),d=P,f=C}}this.trigger("afterrenderpass",this,t,e,r)},getMaxJointNumber:function(){return this.maxJointNumber},_updateSkeleton:function(t,e,r){var i=this.gl,n=t.skeleton;if(n)if(n.update(),t.joints.length>this.getMaxJointNumber()){var a=n.getSubSkinMatricesTexture(t.__uid__,t.joints);e.useTextureSlot(this,a,r),e.setUniform(i,"1i","skinMatricesTexture",r),e.setUniform(i,"1f","skinMatricesTextureSize",a.width)}else{var o=n.getSubSkinMatrices(t.__uid__,t.joints);e.setUniformOfSemantic(i,"SKIN_MATRIX",o)}},_renderObject:function(t,e,r){var i=this.gl,n=t.geometry,a=t.mode;null==a&&(a=4);var o=null,s=t.isInstancedMesh&&t.isInstancedMesh();if(!s||(o=this.getGLExtension("ANGLE_instanced_arrays"))){var l;if(s&&(l=this._bindInstancedAttributes(t,r,o)),e.indicesBuffer){var h=this.getGLExtension("OES_element_index_uint")&&n.indices instanceof Uint32Array?i.UNSIGNED_INT:i.UNSIGNED_SHORT;s?o.drawElementsInstancedANGLE(a,e.indicesBuffer.count,h,0,t.getInstanceCount()):i.drawElements(a,e.indicesBuffer.count,h,0)}else s?o.drawArraysInstancedANGLE(a,0,n.vertexCount,t.getInstanceCount()):i.drawArrays(a,0,n.vertexCount);if(s)for(var u=0;u<l.length;u++)i.disableVertexAttribArray(l[u])}else console.warn("Device not support ANGLE_instanced_arrays extension")},_bindInstancedAttributes:function(t,e,r){for(var i=this.gl,n=t.getInstancedAttributesBuffers(this),a=[],o=0;o<n.length;o++){var s=n[o],l=e.getAttribLocation(i,s.symbol);if(!(l<0)){var h=ae[s.type]||i.FLOAT;i.enableVertexAttribArray(l),i.bindBuffer(i.ARRAY_BUFFER,s.buffer),i.vertexAttribPointer(l,s.size,h,!1,0,0),r.vertexAttribDivisorANGLE(l,s.divisor),a.push(l)}}return a},_bindMaterial:function(t,e,r,i,n,a,o){for(var s=this.gl,l=a===r,h=r.currentTextureSlot(),u=e.getEnabledUniforms(),c=e.getTextureUniforms(),d=this._placeholderTexture,f=0;f<c.length;f++){var p=o(t,e,_=c[f]);if("t"===(g=e.uniforms[_].type)&&p)p.__slot=-1;else if("tv"===g)for(var m=0;m<p.length;m++)p[m]&&(p[m].__slot=-1)}for(d.__slot=-1,f=0;f<u.length;f++){var g,_=u[f],v=e.uniforms[_],y=(p=o(t,e,_),"t"===(g=v.type));if(y&&(p&&p.isRenderable()||(p=d)),n&&l){var x=o(i,n,_);if(y&&(x&&x.isRenderable()||(x=d)),x===p){if(y)r.takeCurrentTextureSlot(this,null);else if("tv"===g&&p)for(m=0;m<p.length;m++)r.takeCurrentTextureSlot(this,null);continue}}if(null!=p)if(y)if(p.__slot<0){var b=r.currentTextureSlot();r.setUniform(s,"1i",_,b)&&(r.takeCurrentTextureSlot(this,p),p.__slot=b)}else r.setUniform(s,"1i",_,p.__slot);else if(Array.isArray(p)){if(0===p.length)continue;if("tv"===g){if(!r.hasUniform(_))continue;var w=[];for(m=0;m<p.length;m++){var T=p[m];T.__slot<0?(b=r.currentTextureSlot(),w.push(b),r.takeCurrentTextureSlot(this,T),T.__slot=b):w.push(T.__slot)}r.setUniform(s,"1iv",_,w)}else r.setUniform(s,v.type,_,p)}else r.setUniform(s,v.type,_,p)}var S=r.currentTextureSlot();return r.resetTextureSlot(h),S},_bindVAO:function(t,e,r,i){var n=!r.dynamic,a=this.gl,o=this.__uid__+"-"+i.__uid__,s=r.__vaoCache[o];if(!s){var l=r.getBufferChunks(this);if(!l||!l.length)return;for(var h=l[0],u=h.attributeBuffers,c=h.indicesBuffer,d=[],f=[],p=0;p<u.length;p++){var m,g=(w=u[p]).name,_=w.semantic;if(_){var v=e.attributeSemantics[_];m=v&&v.symbol}else m=g;m&&i.attributes[m]&&(d.push(w),f.push(m))}s=new oe(d,f,c),n&&(r.__vaoCache[o]=s)}var y=!0;if(t&&n&&(null==s.vao?s.vao=t.createVertexArrayOES():y=!1,t.bindVertexArrayOES(s.vao)),d=s.availableAttributes,c=s.indicesBuffer,y){var x=i.enableAttributes(this,s.availableAttributeSymbols,t&&n&&s);for(p=0;p<d.length;p++){var b=x[p];if(-1!==b){var w,T=(w=d[p]).buffer,S=w.size,M=ae[w.type]||a.FLOAT;a.bindBuffer(a.ARRAY_BUFFER,T),a.vertexAttribPointer(b,S,M,!1,0,0)}}r.isUseIndices()&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,c.buffer)}return s},renderPreZ:function(t,e,r){var i=this.gl,n=this._prezMaterial||new lt({shader:new Xt(Xt.source("clay.prez.vertex"),Xt.source("clay.prez.fragment"))});this._prezMaterial=n,i.colorMask(!1,!1,!1,!1),i.depthMask(!0),this.renderPass(t,r,{ifRender:function(t){return!t.ignorePreZ},isMaterialChanged:function(t,e){var r=t.material,i=e.material;return r.get("diffuseMap")!==i.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(i.get("alphaCutoff")||0)},getUniform:function(t,e,r){return"alphaMap"===r?t.material.get("diffuseMap"):"alphaCutoff"===r?t.material.isDefined("fragment","ALPHA_TEST")&&t.material.get("diffuseMap")&&t.material.get("alphaCutoff")||0:"uvRepeat"===r?t.material.get("uvRepeat"):"uvOffset"===r?t.material.get("uvOffset"):e.get(r)},getMaterial:function(){return n},sort:this.opaqueSortCompare}),i.colorMask(!0,!0,!0,!0),i.depthMask(!0)},disposeScene:function(t){this.disposeNode(t,!0,!0),t.dispose()},disposeNode:function(t,e,r){t.getParent()&&t.getParent().remove(t);var i={};t.traverse((function(t){var n=t.material;if(t.geometry&&e&&t.geometry.dispose(this),r&&n&&!i[n.__uid__]){for(var a=n.getTextureUniforms(),o=0;o<a.length;o++){var s=a[o],l=n.uniforms[s].value,h=n.uniforms[s].type;if(l)if("t"===h)l.dispose&&l.dispose(this);else if("tv"===h)for(var u=0;u<l.length;u++)l[u]&&l[u].dispose&&l[u].dispose(this)}i[n.__uid__]=!0}t.dispose&&t.dispose(this)}),this)},disposeGeometry:function(t){t.dispose(this)},disposeTexture:function(t){t.dispose(this)},disposeFrameBuffer:function(t){t.dispose(this)},dispose:function(){},screenToNDC:function(t,e,r){r||(r=new _t),e=this._height-e;var i=this.viewport,n=r.array;return n[0]=(t-i.x)/i.width,n[0]=2*n[0]-1,n[1]=(e-i.y)/i.height,n[1]=2*n[1]-1,r}});le.opaqueSortCompare=le.prototype.opaqueSortCompare=function(t,e){return t.renderOrder===e.renderOrder?t.__program===e.__program?t.material===e.material?t.geometry.__uid__-e.geometry.__uid__:t.material.__uid__-e.material.__uid__:t.__program&&e.__program?t.__program.__uid__-e.__program.__uid__:0:t.renderOrder-e.renderOrder},le.transparentSortCompare=le.prototype.transparentSortCompare=function(t,e){return t.renderOrder===e.renderOrder?t.__depth===e.__depth?t.__program===e.__program?t.material===e.material?t.geometry.__uid__-e.geometry.__uid__:t.material.__uid__-e.material.__uid__:t.__program&&e.__program?t.__program.__uid__-e.__program.__uid__:0:t.__depth-e.__depth:t.renderOrder-e.renderOrder};var he={IDENTITY:Jt(),WORLD:Jt(),VIEW:Jt(),PROJECTION:Jt(),WORLDVIEW:Jt(),VIEWPROJECTION:Jt(),WORLDVIEWPROJECTION:Jt(),WORLDINVERSE:Jt(),VIEWINVERSE:Jt(),PROJECTIONINVERSE:Jt(),WORLDVIEWINVERSE:Jt(),VIEWPROJECTIONINVERSE:Jt(),WORLDVIEWPROJECTIONINVERSE:Jt(),WORLDTRANSPOSE:Jt(),VIEWTRANSPOSE:Jt(),PROJECTIONTRANSPOSE:Jt(),WORLDVIEWTRANSPOSE:Jt(),VIEWPROJECTIONTRANSPOSE:Jt(),WORLDVIEWPROJECTIONTRANSPOSE:Jt(),WORLDINVERSETRANSPOSE:Jt(),VIEWINVERSETRANSPOSE:Jt(),PROJECTIONINVERSETRANSPOSE:Jt(),WORLDVIEWINVERSETRANSPOSE:Jt(),VIEWPROJECTIONINVERSETRANSPOSE:Jt(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:Jt()};le.COLOR_BUFFER_BIT=16384,le.DEPTH_BUFFER_BIT=256,le.STENCIL_BUFFER_BIT=1024;const ue=le;var ce=function(t,e,r){t=t||0,e=e||0,r=r||0,this.array=Qt.fromValues(t,e,r),this._dirty=!0};ce.prototype={constructor:ce,add:function(t){return Qt.add(this.array,this.array,t.array),this._dirty=!0,this},set:function(t,e,r){return this.array[0]=t,this.array[1]=e,this.array[2]=r,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this.array[2]=t[2],this._dirty=!0,this},clone:function(){return new ce(this.x,this.y,this.z)},copy:function(t){return Qt.copy(this.array,t.array),this._dirty=!0,this},cross:function(t,e){return Qt.cross(this.array,t.array,e.array),this._dirty=!0,this},dist:function(t){return Qt.dist(this.array,t.array)},distance:function(t){return Qt.distance(this.array,t.array)},div:function(t){return Qt.div(this.array,this.array,t.array),this._dirty=!0,this},divide:function(t){return Qt.divide(this.array,this.array,t.array),this._dirty=!0,this},dot:function(t){return Qt.dot(this.array,t.array)},len:function(){return Qt.len(this.array)},length:function(){return Qt.length(this.array)},lerp:function(t,e,r){return Qt.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},min:function(t){return Qt.min(this.array,this.array,t.array),this._dirty=!0,this},max:function(t){return Qt.max(this.array,this.array,t.array),this._dirty=!0,this},mul:function(t){return Qt.mul(this.array,this.array,t.array),this._dirty=!0,this},multiply:function(t){return Qt.multiply(this.array,this.array,t.array),this._dirty=!0,this},negate:function(){return Qt.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Qt.normalize(this.array,this.array),this._dirty=!0,this},random:function(t){return Qt.random(this.array,t),this._dirty=!0,this},scale:function(t){return Qt.scale(this.array,this.array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return Qt.scaleAndAdd(this.array,this.array,t.array,e),this._dirty=!0,this},sqrDist:function(t){return Qt.sqrDist(this.array,t.array)},squaredDistance:function(t){return Qt.squaredDistance(this.array,t.array)},sqrLen:function(){return Qt.sqrLen(this.array)},squaredLength:function(){return Qt.squaredLength(this.array)},sub:function(t){return Qt.sub(this.array,this.array,t.array),this._dirty=!0,this},subtract:function(t){return Qt.subtract(this.array,this.array,t.array),this._dirty=!0,this},transformMat3:function(t){return Qt.transformMat3(this.array,this.array,t.array),this._dirty=!0,this},transformMat4:function(t){return Qt.transformMat4(this.array,this.array,t.array),this._dirty=!0,this},transformQuat:function(t){return Qt.transformQuat(this.array,this.array,t.array),this._dirty=!0,this},applyProjection:function(t){var e=this.array;if(0===(t=t.array)[15]){var r=-1/e[2];e[0]=t[0]*e[0]*r,e[1]=t[5]*e[1]*r,e[2]=(t[10]*e[2]+t[14])*r}else e[0]=t[0]*e[0]+t[12],e[1]=t[5]*e[1]+t[13],e[2]=t[10]*e[2]+t[14];return this._dirty=!0,this},eulerFromQuat:function(t,e){ce.eulerFromQuat(this,t,e)},eulerFromMat3:function(t,e){ce.eulerFromMat3(this,t,e)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var de=Object.defineProperty;if(de){var fe=ce.prototype;de(fe,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),de(fe,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}}),de(fe,"z",{get:function(){return this.array[2]},set:function(t){this.array[2]=t,this._dirty=!0}})}function pe(t,e,r){return t<e?e:t>r?r:t}ce.add=function(t,e,r){return Qt.add(t.array,e.array,r.array),t._dirty=!0,t},ce.set=function(t,e,r,i){Qt.set(t.array,e,r,i),t._dirty=!0},ce.copy=function(t,e){return Qt.copy(t.array,e.array),t._dirty=!0,t},ce.cross=function(t,e,r){return Qt.cross(t.array,e.array,r.array),t._dirty=!0,t},ce.distance=ce.dist=function(t,e){return Qt.distance(t.array,e.array)},ce.divide=ce.div=function(t,e,r){return Qt.divide(t.array,e.array,r.array),t._dirty=!0,t},ce.dot=function(t,e){return Qt.dot(t.array,e.array)},ce.len=function(t){return Qt.length(t.array)},ce.lerp=function(t,e,r,i){return Qt.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},ce.min=function(t,e,r){return Qt.min(t.array,e.array,r.array),t._dirty=!0,t},ce.max=function(t,e,r){return Qt.max(t.array,e.array,r.array),t._dirty=!0,t},ce.multiply=ce.mul=function(t,e,r){return Qt.multiply(t.array,e.array,r.array),t._dirty=!0,t},ce.negate=function(t,e){return Qt.negate(t.array,e.array),t._dirty=!0,t},ce.normalize=function(t,e){return Qt.normalize(t.array,e.array),t._dirty=!0,t},ce.random=function(t,e){return Qt.random(t.array,e),t._dirty=!0,t},ce.scale=function(t,e,r){return Qt.scale(t.array,e.array,r),t._dirty=!0,t},ce.scaleAndAdd=function(t,e,r,i){return Qt.scaleAndAdd(t.array,e.array,r.array,i),t._dirty=!0,t},ce.squaredDistance=ce.sqrDist=function(t,e){return Qt.sqrDist(t.array,e.array)},ce.squaredLength=ce.sqrLen=function(t){return Qt.sqrLen(t.array)},ce.subtract=ce.sub=function(t,e,r){return Qt.subtract(t.array,e.array,r.array),t._dirty=!0,t},ce.transformMat3=function(t,e,r){return Qt.transformMat3(t.array,e.array,r.array),t._dirty=!0,t},ce.transformMat4=function(t,e,r){return Qt.transformMat4(t.array,e.array,r.array),t._dirty=!0,t},ce.transformQuat=function(t,e,r){return Qt.transformQuat(t.array,e.array,r.array),t._dirty=!0,t};var me=Math.atan2,ge=Math.asin,_e=Math.abs;ce.eulerFromQuat=function(t,e,r){t._dirty=!0,e=e.array;var i=t.array,n=e[0],a=e[1],o=e[2],s=e[3],l=n*n,h=a*a,u=o*o,c=s*s;switch(r=(r||"XYZ").toUpperCase()){case"XYZ":i[0]=me(2*(n*s-a*o),c-l-h+u),i[1]=ge(pe(2*(n*o+a*s),-1,1)),i[2]=me(2*(o*s-n*a),c+l-h-u);break;case"YXZ":i[0]=ge(pe(2*(n*s-a*o),-1,1)),i[1]=me(2*(n*o+a*s),c-l-h+u),i[2]=me(2*(n*a+o*s),c-l+h-u);break;case"ZXY":i[0]=ge(pe(2*(n*s+a*o),-1,1)),i[1]=me(2*(a*s-o*n),c-l-h+u),i[2]=me(2*(o*s-n*a),c-l+h-u);break;case"ZYX":i[0]=me(2*(n*s+o*a),c-l-h+u),i[1]=ge(pe(2*(a*s-n*o),-1,1)),i[2]=me(2*(n*a+o*s),c+l-h-u);break;case"YZX":i[0]=me(2*(n*s-o*a),c-l+h-u),i[1]=me(2*(a*s-n*o),c+l-h-u),i[2]=ge(pe(2*(n*a+o*s),-1,1));break;case"XZY":i[0]=me(2*(n*s+a*o),c-l+h-u),i[1]=me(2*(n*o+a*s),c+l-h-u),i[2]=ge(pe(2*(o*s-n*a),-1,1));break;default:console.warn("Unkown order: "+r)}return t},ce.eulerFromMat3=function(t,e,r){var i=e.array,n=i[0],a=i[3],o=i[6],s=i[1],l=i[4],h=i[7],u=i[2],c=i[5],d=i[8],f=t.array;switch(r=(r||"XYZ").toUpperCase()){case"XYZ":f[1]=ge(pe(o,-1,1)),_e(o)<.99999?(f[0]=me(-h,d),f[2]=me(-a,n)):(f[0]=me(c,l),f[2]=0);break;case"YXZ":f[0]=ge(-pe(h,-1,1)),_e(h)<.99999?(f[1]=me(o,d),f[2]=me(s,l)):(f[1]=me(-u,n),f[2]=0);break;case"ZXY":f[0]=ge(pe(c,-1,1)),_e(c)<.99999?(f[1]=me(-u,d),f[2]=me(-a,l)):(f[1]=0,f[2]=me(s,n));break;case"ZYX":f[1]=ge(-pe(u,-1,1)),_e(u)<.99999?(f[0]=me(c,d),f[2]=me(s,n)):(f[0]=0,f[2]=me(-a,l));break;case"YZX":f[2]=ge(pe(s,-1,1)),_e(s)<.99999?(f[0]=me(-h,l),f[1]=me(-u,n)):(f[0]=0,f[1]=me(o,d));break;case"XZY":f[2]=ge(-pe(a,-1,1)),_e(a)<.99999?(f[0]=me(c,l),f[1]=me(o,n)):(f[0]=me(-h,d),f[1]=0);break;default:console.warn("Unkown order: "+r)}return t._dirty=!0,t},Object.defineProperties(ce,{POSITIVE_X:{get:function(){return new ce(1,0,0)}},NEGATIVE_X:{get:function(){return new ce(-1,0,0)}},POSITIVE_Y:{get:function(){return new ce(0,1,0)}},NEGATIVE_Y:{get:function(){return new ce(0,-1,0)}},POSITIVE_Z:{get:function(){return new ce(0,0,1)}},NEGATIVE_Z:{get:function(){return new ce(0,0,-1)}},UP:{get:function(){return new ce(0,1,0)}},ZERO:{get:function(){return new ce}}});const ve=ce;var ye,xe,be,we,Te,Se=function(t,e){this.origin=t||new ve,this.direction=e||new ve};Se.prototype={constructor:Se,intersectPlane:function(t,e){var r=t.normal.array,i=t.distance,n=this.origin.array,a=this.direction.array,o=Qt.dot(r,a);if(0===o)return null;e||(e=new ve);var s=(Qt.dot(r,n)-i)/o;return Qt.scaleAndAdd(e.array,n,a,-s),e._dirty=!0,e},mirrorAgainstPlane:function(t){var e=Qt.dot(t.normal.array,this.direction.array);Qt.scaleAndAdd(this.direction.array,this.direction.array,t.normal.array,2*-e),this.direction._dirty=!0},distanceToPoint:(Te=Qt.create(),function(t){Qt.sub(Te,t,this.origin.array);var e=Qt.dot(Te,this.direction.array);if(e<0)return Qt.distance(this.origin.array,t);var r=Qt.lenSquared(Te);return Math.sqrt(r-e*e)}),intersectSphere:function(){var t=Qt.create();return function(e,r,i){var n=this.origin.array,a=this.direction.array;e=e.array,Qt.sub(t,e,n);var o=Qt.dot(t,a),s=Qt.squaredLength(t)-o*o,l=r*r;if(!(s>l)){var h=Math.sqrt(l-s),u=o-h,c=o+h;return i||(i=new ve),u<0?c<0?null:(Qt.scaleAndAdd(i.array,n,a,c),i):(Qt.scaleAndAdd(i.array,n,a,u),i)}}}(),intersectBoundingBox:function(t,e){var r,i,n,a,o,s,l=this.direction.array,h=this.origin.array,u=t.min.array,c=t.max.array,d=1/l[0],f=1/l[1],p=1/l[2];if(d>=0?(r=(u[0]-h[0])*d,i=(c[0]-h[0])*d):(i=(u[0]-h[0])*d,r=(c[0]-h[0])*d),f>=0?(n=(u[1]-h[1])*f,a=(c[1]-h[1])*f):(a=(u[1]-h[1])*f,n=(c[1]-h[1])*f),r>a||n>i)return null;if((n>r||r!=r)&&(r=n),(a<i||i!=i)&&(i=a),p>=0?(o=(u[2]-h[2])*p,s=(c[2]-h[2])*p):(s=(u[2]-h[2])*p,o=(c[2]-h[2])*p),r>s||o>i)return null;if((o>r||r!=r)&&(r=o),(s<i||i!=i)&&(i=s),i<0)return null;var m=r>=0?r:i;return e||(e=new ve),Qt.scaleAndAdd(e.array,h,l,m),e},intersectTriangle:(ye=Qt.create(),xe=Qt.create(),be=Qt.create(),we=Qt.create(),function(t,e,r,i,n,a){var o=this.direction.array,s=this.origin.array;t=t.array,e=e.array,r=r.array,Qt.sub(ye,e,t),Qt.sub(xe,r,t),Qt.cross(we,xe,o);var l=Qt.dot(ye,we);if(i){if(l>-1e-5)return null}else if(l>-1e-5&&l<1e-5)return null;Qt.sub(be,s,t);var h=Qt.dot(we,be)/l;if(h<0||h>1)return null;Qt.cross(we,ye,be);var u=Qt.dot(o,we)/l;if(u<0||u>1||h+u>1)return null;Qt.cross(we,ye,xe);var c=-Qt.dot(be,we)/l;return c<0?null:(n||(n=new ve),a&&ve.set(a,1-h-u,h,u),Qt.scaleAndAdd(n.array,s,o,c),n)}),applyTransform:function(t){ve.add(this.direction,this.direction,this.origin),ve.transformMat4(this.origin,this.origin,t),ve.transformMat4(this.direction,this.direction,t),ve.sub(this.direction,this.direction,this.origin),ve.normalize(this.direction,this.direction)},copy:function(t){ve.copy(this.origin,t.origin),ve.copy(this.direction,t.direction)},clone:function(){var t=new Se;return t.copy(this),t}};const Me=Se;var Ae={create:function(){var t=new ct(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},clone:function(t){var e=new ct(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},fromValues:function(t,e,r,i){var n=new ct(4);return n[0]=t,n[1]=e,n[2]=r,n[3]=i,n},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},set:function(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t},add:function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},subtract:function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}};Ae.sub=Ae.subtract,Ae.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},Ae.mul=Ae.multiply,Ae.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t},Ae.div=Ae.divide,Ae.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},Ae.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t},Ae.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},Ae.scaleAndAdd=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t},Ae.distance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(r*r+i*i+n*n+a*a)},Ae.dist=Ae.distance,Ae.squaredDistance=function(t,e){var r=e[0]-t[0],i=e[1]-t[1],n=e[2]-t[2],a=e[3]-t[3];return r*r+i*i+n*n+a*a},Ae.sqrDist=Ae.squaredDistance,Ae.length=function(t){var e=t[0],r=t[1],i=t[2],n=t[3];return Math.sqrt(e*e+r*r+i*i+n*n)},Ae.len=Ae.length,Ae.squaredLength=function(t){var e=t[0],r=t[1],i=t[2],n=t[3];return e*e+r*r+i*i+n*n},Ae.sqrLen=Ae.squaredLength,Ae.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},Ae.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},Ae.normalize=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r*r+i*i+n*n+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t[3]=e[3]*o),t},Ae.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},Ae.lerp=function(t,e,r,i){var n=e[0],a=e[1],o=e[2],s=e[3];return t[0]=n+i*(r[0]-n),t[1]=a+i*(r[1]-a),t[2]=o+i*(r[2]-o),t[3]=s+i*(r[3]-s),t},Ae.random=function(t,e){return e=e||1,t[0]=dt(),t[1]=dt(),t[2]=dt(),t[3]=dt(),Ae.normalize(t,t),Ae.scale(t,t,e),t},Ae.transformMat4=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3];return t[0]=r[0]*i+r[4]*n+r[8]*a+r[12]*o,t[1]=r[1]*i+r[5]*n+r[9]*a+r[13]*o,t[2]=r[2]*i+r[6]*n+r[10]*a+r[14]*o,t[3]=r[3]*i+r[7]*n+r[11]*a+r[15]*o,t},Ae.transformQuat=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2],h=r[3],u=h*i+s*a-l*n,c=h*n+l*i-o*a,d=h*a+o*n-s*i,f=-o*i-s*n-l*a;return t[0]=u*h+f*-o+c*-l-d*-s,t[1]=c*h+f*-s+d*-o-u*-l,t[2]=d*h+f*-l+u*-s-c*-o,t},Ae.forEach=function(){var t=Ae.create();return function(e,r,i,n,a,o){var s,l;for(r||(r=4),i||(i=0),l=n?Math.min(n*r+i,e.length):e.length,s=i;s<l;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],t[3]=e[s+3],a(t,t,o),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2],e[s+3]=t[3];return e}}();const Ce=Ae;var Ee={create:function(){var t=new ct(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},fromMat4:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},clone:function(t){var e=new ct(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},copy:function(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},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},transpose:function(t,e){if(t===e){var r=e[1],i=e[2],n=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=i,t[7]=n}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=u*o-s*h,d=-u*a+s*l,f=h*a-o*l,p=r*c+i*d+n*f;return p?(p=1/p,t[0]=c*p,t[1]=(-u*i+n*h)*p,t[2]=(s*i-n*o)*p,t[3]=d*p,t[4]=(u*r-n*l)*p,t[5]=(-s*r+n*a)*p,t[6]=f*p,t[7]=(-h*r+i*l)*p,t[8]=(o*r-i*a)*p,t):null},adjoint:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8];return t[0]=o*u-s*h,t[1]=n*h-i*u,t[2]=i*s-n*o,t[3]=s*l-a*u,t[4]=r*u-n*l,t[5]=n*a-r*s,t[6]=a*h-o*l,t[7]=i*l-r*h,t[8]=r*o-i*a,t},determinant:function(t){var e=t[0],r=t[1],i=t[2],n=t[3],a=t[4],o=t[5],s=t[6],l=t[7],h=t[8];return e*(h*a-o*l)+r*(-h*n+o*s)+i*(l*n-a*s)},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=r[0],f=r[1],p=r[2],m=r[3],g=r[4],_=r[5],v=r[6],y=r[7],x=r[8];return t[0]=d*i+f*o+p*h,t[1]=d*n+f*s+p*u,t[2]=d*a+f*l+p*c,t[3]=m*i+g*o+_*h,t[4]=m*n+g*s+_*u,t[5]=m*a+g*l+_*c,t[6]=v*i+y*o+x*h,t[7]=v*n+y*s+x*u,t[8]=v*a+y*l+x*c,t}};Ee.mul=Ee.multiply,Ee.translate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=r[0],f=r[1];return t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=d*i+f*o+h,t[7]=d*n+f*s+u,t[8]=d*a+f*l+c,t},Ee.rotate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=Math.sin(r),f=Math.cos(r);return t[0]=f*i+d*o,t[1]=f*n+d*s,t[2]=f*a+d*l,t[3]=f*o-d*i,t[4]=f*s-d*n,t[5]=f*l-d*a,t[6]=h,t[7]=u,t[8]=c,t},Ee.scale=function(t,e,r){var i=r[0],n=r[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=n*e[3],t[4]=n*e[4],t[5]=n*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},Ee.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},Ee.fromQuat=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r+r,s=i+i,l=n+n,h=r*o,u=i*o,c=i*s,d=n*o,f=n*s,p=n*l,m=a*o,g=a*s,_=a*l;return t[0]=1-c-p,t[3]=u-_,t[6]=d+g,t[1]=u+_,t[4]=1-h-p,t[7]=f-m,t[2]=d-g,t[5]=f+m,t[8]=1-h-c,t},Ee.normalFromMat4=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15],v=r*s-i*o,y=r*l-n*o,x=r*h-a*o,b=i*l-n*s,w=i*h-a*s,T=n*h-a*l,S=u*m-c*p,M=u*g-d*p,A=u*_-f*p,C=c*g-d*m,E=c*_-f*m,D=d*_-f*g,L=v*D-y*E+x*C+b*A-w*M+T*S;return L?(L=1/L,t[0]=(s*D-l*E+h*C)*L,t[1]=(l*A-o*D-h*M)*L,t[2]=(o*E-s*A+h*S)*L,t[3]=(n*E-i*D-a*C)*L,t[4]=(r*D-n*A+a*M)*L,t[5]=(i*A-r*E-a*S)*L,t[6]=(m*T-g*w+_*b)*L,t[7]=(g*x-p*T-_*y)*L,t[8]=(p*w-m*x+_*v)*L,t):null},Ee.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2))};const De=Ee;var Le,Pe,Oe,Ne,Ie={create:function(){var t=new ct(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}};Ie.rotationTo=(Le=Qt.create(),Pe=Qt.fromValues(1,0,0),Oe=Qt.fromValues(0,1,0),function(t,e,r){var i=Qt.dot(e,r);return i<-.999999?(Qt.cross(Le,Pe,e),Qt.length(Le)<1e-6&&Qt.cross(Le,Oe,e),Qt.normalize(Le,Le),Ie.setAxisAngle(t,Le,Math.PI),t):i>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(Qt.cross(Le,e,r),t[0]=Le[0],t[1]=Le[1],t[2]=Le[2],t[3]=1+i,Ie.normalize(t,t))}),Ie.setAxes=(Ne=De.create(),function(t,e,r,i){return Ne[0]=r[0],Ne[3]=r[1],Ne[6]=r[2],Ne[1]=i[0],Ne[4]=i[1],Ne[7]=i[2],Ne[2]=-e[0],Ne[5]=-e[1],Ne[8]=-e[2],Ie.normalize(t,Ie.fromMat3(t,Ne))}),Ie.clone=Ce.clone,Ie.fromValues=Ce.fromValues,Ie.copy=Ce.copy,Ie.set=Ce.set,Ie.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},Ie.setAxisAngle=function(t,e,r){r*=.5;var i=Math.sin(r);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(r),t},Ie.add=Ce.add,Ie.multiply=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],h=r[2],u=r[3];return t[0]=i*u+o*s+n*h-a*l,t[1]=n*u+o*l+a*s-i*h,t[2]=a*u+o*h+i*l-n*s,t[3]=o*u-i*s-n*l-a*h,t},Ie.mul=Ie.multiply,Ie.scale=Ce.scale,Ie.rotateX=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l+o*s,t[1]=n*l+a*s,t[2]=a*l-n*s,t[3]=o*l-i*s,t},Ie.rotateY=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l-a*s,t[1]=n*l+o*s,t[2]=a*l+i*s,t[3]=o*l-n*s,t},Ie.rotateZ=function(t,e,r){r*=.5;var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l+n*s,t[1]=n*l-i*s,t[2]=a*l+o*s,t[3]=o*l-a*s,t},Ie.calculateW=function(t,e){var r=e[0],i=e[1],n=e[2];return t[0]=r,t[1]=i,t[2]=n,t[3]=Math.sqrt(Math.abs(1-r*r-i*i-n*n)),t},Ie.dot=Ce.dot,Ie.lerp=Ce.lerp,Ie.slerp=function(t,e,r,i){var n,a,o,s,l,h=e[0],u=e[1],c=e[2],d=e[3],f=r[0],p=r[1],m=r[2],g=r[3];return(a=h*f+u*p+c*m+d*g)<0&&(a=-a,f=-f,p=-p,m=-m,g=-g),1-a>1e-6?(n=Math.acos(a),o=Math.sin(n),s=Math.sin((1-i)*n)/o,l=Math.sin(i*n)/o):(s=1-i,l=i),t[0]=s*h+l*f,t[1]=s*u+l*p,t[2]=s*c+l*m,t[3]=s*d+l*g,t},Ie.invert=function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r*r+i*i+n*n+a*a,s=o?1/o:0;return t[0]=-r*s,t[1]=-i*s,t[2]=-n*s,t[3]=a*s,t},Ie.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},Ie.length=Ce.length,Ie.len=Ie.length,Ie.squaredLength=Ce.squaredLength,Ie.sqrLen=Ie.squaredLength,Ie.normalize=Ce.normalize,Ie.fromMat3=function(t,e){var r,i=e[0]+e[4]+e[8];if(i>0)r=Math.sqrt(i+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var n=0;e[4]>e[0]&&(n=1),e[8]>e[3*n+n]&&(n=2);var a=(n+1)%3,o=(n+2)%3;r=Math.sqrt(e[3*n+n]-e[3*a+a]-e[3*o+o]+1),t[n]=.5*r,r=.5/r,t[3]=(e[3*a+o]-e[3*o+a])*r,t[a]=(e[3*a+n]+e[3*n+a])*r,t[o]=(e[3*o+n]+e[3*n+o])*r}return t};const Re=Ie;var Be,Fe,ze,ke,Ge=function(){this._axisX=new ve,this._axisY=new ve,this._axisZ=new ve,this.array=Yt.create(),this._dirty=!0};Ge.prototype={constructor:Ge,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},adjoint:function(){return Yt.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new Ge).copy(this)},copy:function(t){return Yt.copy(this.array,t.array),this._dirty=!0,this},determinant:function(){return Yt.determinant(this.array)},fromQuat:function(t){return Yt.fromQuat(this.array,t.array),this._dirty=!0,this},fromRotationTranslation:function(t,e){return Yt.fromRotationTranslation(this.array,t.array,e.array),this._dirty=!0,this},fromMat2d:function(t){return Ge.fromMat2d(this,t),this},frustum:function(t,e,r,i,n,a){return Yt.frustum(this.array,t,e,r,i,n,a),this._dirty=!0,this},identity:function(){return Yt.identity(this.array),this._dirty=!0,this},invert:function(){return Yt.invert(this.array,this.array),this._dirty=!0,this},lookAt:function(t,e,r){return Yt.lookAt(this.array,t.array,e.array,r.array),this._dirty=!0,this},mul:function(t){return Yt.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return Yt.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return Yt.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return Yt.multiply(this.array,t.array,this.array),this._dirty=!0,this},ortho:function(t,e,r,i,n,a){return Yt.ortho(this.array,t,e,r,i,n,a),this._dirty=!0,this},perspective:function(t,e,r,i){return Yt.perspective(this.array,t,e,r,i),this._dirty=!0,this},rotate:function(t,e){return Yt.rotate(this.array,this.array,t,e.array),this._dirty=!0,this},rotateX:function(t){return Yt.rotateX(this.array,this.array,t),this._dirty=!0,this},rotateY:function(t){return Yt.rotateY(this.array,this.array,t),this._dirty=!0,this},rotateZ:function(t){return Yt.rotateZ(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return Yt.scale(this.array,this.array,t.array),this._dirty=!0,this},translate:function(t){return Yt.translate(this.array,this.array,t.array),this._dirty=!0,this},transpose:function(){return Yt.transpose(this.array,this.array),this._dirty=!0,this},decomposeMatrix:(Be=Qt.create(),Fe=Qt.create(),ze=Qt.create(),ke=De.create(),function(t,e,r){var i=this.array;Qt.set(Be,i[0],i[1],i[2]),Qt.set(Fe,i[4],i[5],i[6]),Qt.set(ze,i[8],i[9],i[10]);var n=Qt.length(Be),a=Qt.length(Fe),o=Qt.length(ze);this.determinant()<0&&(n=-n),t&&t.set(n,a,o),r.set(i[12],i[13],i[14]),De.fromMat4(ke,i),ke[0]/=n,ke[1]/=n,ke[2]/=n,ke[3]/=a,ke[4]/=a,ke[5]/=a,ke[6]/=o,ke[7]/=o,ke[8]/=o,Re.fromMat3(e.array,ke),Re.normalize(e.array,e.array),e._dirty=!0,r._dirty=!0}),toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var Ue=Object.defineProperty;if(Ue){var He=Ge.prototype;Ue(He,"z",{get:function(){var t=this.array;return this._axisZ.set(t[8],t[9],t[10]),this._axisZ},set:function(t){var e=this.array;t=t.array,e[8]=t[0],e[9]=t[1],e[10]=t[2],this._dirty=!0}}),Ue(He,"y",{get:function(){var t=this.array;return this._axisY.set(t[4],t[5],t[6]),this._axisY},set:function(t){var e=this.array;t=t.array,e[4]=t[0],e[5]=t[1],e[6]=t[2],this._dirty=!0}}),Ue(He,"x",{get:function(){var t=this.array;return this._axisX.set(t[0],t[1],t[2]),this._axisX},set:function(t){var e=this.array;t=t.array,e[0]=t[0],e[1]=t[1],e[2]=t[2],this._dirty=!0}})}Ge.adjoint=function(t,e){return Yt.adjoint(t.array,e.array),t._dirty=!0,t},Ge.copy=function(t,e){return Yt.copy(t.array,e.array),t._dirty=!0,t},Ge.determinant=function(t){return Yt.determinant(t.array)},Ge.identity=function(t){return Yt.identity(t.array),t._dirty=!0,t},Ge.ortho=function(t,e,r,i,n,a,o){return Yt.ortho(t.array,e,r,i,n,a,o),t._dirty=!0,t},Ge.perspective=function(t,e,r,i,n){return Yt.perspective(t.array,e,r,i,n),t._dirty=!0,t},Ge.lookAt=function(t,e,r,i){return Yt.lookAt(t.array,e.array,r.array,i.array),t._dirty=!0,t},Ge.invert=function(t,e){return Yt.invert(t.array,e.array),t._dirty=!0,t},Ge.multiply=Ge.mul=function(t,e,r){return Yt.mul(t.array,e.array,r.array),t._dirty=!0,t},Ge.fromQuat=function(t,e){return Yt.fromQuat(t.array,e.array),t._dirty=!0,t},Ge.fromRotationTranslation=function(t,e,r){return Yt.fromRotationTranslation(t.array,e.array,r.array),t._dirty=!0,t},Ge.fromMat2d=function(t,e){return t._dirty=!0,e=e.array,(t=t.array)[0]=e[0],t[4]=e[2],t[12]=e[4],t[1]=e[1],t[5]=e[3],t[13]=e[5],t},Ge.rotate=function(t,e,r,i){return Yt.rotate(t.array,e.array,r,i.array),t._dirty=!0,t},Ge.rotateX=function(t,e,r){return Yt.rotateX(t.array,e.array,r),t._dirty=!0,t},Ge.rotateY=function(t,e,r){return Yt.rotateY(t.array,e.array,r),t._dirty=!0,t},Ge.rotateZ=function(t,e,r){return Yt.rotateZ(t.array,e.array,r),t._dirty=!0,t},Ge.scale=function(t,e,r){return Yt.scale(t.array,e.array,r.array),t._dirty=!0,t},Ge.transpose=function(t,e){return Yt.transpose(t.array,e.array),t._dirty=!0,t},Ge.translate=function(t,e,r){return Yt.translate(t.array,e.array,r.array),t._dirty=!0,t};const Ve=Ge;var We=function(t,e,r,i){t=t||0,e=e||0,r=r||0,i=void 0===i?1:i,this.array=Re.fromValues(t,e,r,i),this._dirty=!0};We.prototype={constructor:We,add:function(t){return Re.add(this.array,this.array,t.array),this._dirty=!0,this},calculateW:function(){return Re.calculateW(this.array,this.array),this._dirty=!0,this},set:function(t,e,r,i){return this.array[0]=t,this.array[1]=e,this.array[2]=r,this.array[3]=i,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this.array[2]=t[2],this.array[3]=t[3],this._dirty=!0,this},clone:function(){return new We(this.x,this.y,this.z,this.w)},conjugate:function(){return Re.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(t){return Re.copy(this.array,t.array),this._dirty=!0,this},dot:function(t){return Re.dot(this.array,t.array)},fromMat3:function(t){return Re.fromMat3(this.array,t.array),this._dirty=!0,this},fromMat4:function(){var t=De.create();return function(e){return De.fromMat4(t,e.array),De.transpose(t,t),Re.fromMat3(this.array,t),this._dirty=!0,this}}(),identity:function(){return Re.identity(this.array),this._dirty=!0,this},invert:function(){return Re.invert(this.array,this.array),this._dirty=!0,this},len:function(){return Re.len(this.array)},length:function(){return Re.length(this.array)},lerp:function(t,e,r){return Re.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},mul:function(t){return Re.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return Re.multiply(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return Re.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return Re.multiply(this.array,t.array,this.array),this._dirty=!0,this},normalize:function(){return Re.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(t){return Re.rotateX(this.array,this.array,t),this._dirty=!0,this},rotateY:function(t){return Re.rotateY(this.array,this.array,t),this._dirty=!0,this},rotateZ:function(t){return Re.rotateZ(this.array,this.array,t),this._dirty=!0,this},rotationTo:function(t,e){return Re.rotationTo(this.array,t.array,e.array),this._dirty=!0,this},setAxes:function(t,e,r){return Re.setAxes(this.array,t.array,e.array,r.array),this._dirty=!0,this},setAxisAngle:function(t,e){return Re.setAxisAngle(this.array,t.array,e),this._dirty=!0,this},slerp:function(t,e,r){return Re.slerp(this.array,t.array,e.array,r),this._dirty=!0,this},sqrLen:function(){return Re.sqrLen(this.array)},squaredLength:function(){return Re.squaredLength(this.array)},fromEuler:function(t,e){return We.fromEuler(this,t,e)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var je=Object.defineProperty;if(je){var Xe=We.prototype;je(Xe,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),je(Xe,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}}),je(Xe,"z",{get:function(){return this.array[2]},set:function(t){this.array[2]=t,this._dirty=!0}}),je(Xe,"w",{get:function(){return this.array[3]},set:function(t){this.array[3]=t,this._dirty=!0}})}We.add=function(t,e,r){return Re.add(t.array,e.array,r.array),t._dirty=!0,t},We.set=function(t,e,r,i,n){Re.set(t.array,e,r,i,n),t._dirty=!0},We.copy=function(t,e){return Re.copy(t.array,e.array),t._dirty=!0,t},We.calculateW=function(t,e){return Re.calculateW(t.array,e.array),t._dirty=!0,t},We.conjugate=function(t,e){return Re.conjugate(t.array,e.array),t._dirty=!0,t},We.identity=function(t){return Re.identity(t.array),t._dirty=!0,t},We.invert=function(t,e){return Re.invert(t.array,e.array),t._dirty=!0,t},We.dot=function(t,e){return Re.dot(t.array,e.array)},We.len=function(t){return Re.length(t.array)},We.lerp=function(t,e,r,i){return Re.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},We.slerp=function(t,e,r,i){return Re.slerp(t.array,e.array,r.array,i),t._dirty=!0,t},We.multiply=We.mul=function(t,e,r){return Re.multiply(t.array,e.array,r.array),t._dirty=!0,t},We.rotateX=function(t,e,r){return Re.rotateX(t.array,e.array,r),t._dirty=!0,t},We.rotateY=function(t,e,r){return Re.rotateY(t.array,e.array,r),t._dirty=!0,t},We.rotateZ=function(t,e,r){return Re.rotateZ(t.array,e.array,r),t._dirty=!0,t},We.setAxisAngle=function(t,e,r){return Re.setAxisAngle(t.array,e.array,r),t._dirty=!0,t},We.normalize=function(t,e){return Re.normalize(t.array,e.array),t._dirty=!0,t},We.squaredLength=We.sqrLen=function(t){return Re.sqrLen(t.array)},We.fromMat3=function(t,e){return Re.fromMat3(t.array,e.array),t._dirty=!0,t},We.setAxes=function(t,e,r,i){return Re.setAxes(t.array,e.array,r.array,i.array),t._dirty=!0,t},We.rotationTo=function(t,e,r){return Re.rotationTo(t.array,e.array,r.array),t._dirty=!0,t},We.fromEuler=function(t,e,r){t._dirty=!0,e=e.array;var i=t.array,n=Math.cos(e[0]/2),a=Math.cos(e[1]/2),o=Math.cos(e[2]/2),s=Math.sin(e[0]/2),l=Math.sin(e[1]/2),h=Math.sin(e[2]/2);switch(r=(r||"XYZ").toUpperCase()){case"XYZ":i[0]=s*a*o+n*l*h,i[1]=n*l*o-s*a*h,i[2]=n*a*h+s*l*o,i[3]=n*a*o-s*l*h;break;case"YXZ":i[0]=s*a*o+n*l*h,i[1]=n*l*o-s*a*h,i[2]=n*a*h-s*l*o,i[3]=n*a*o+s*l*h;break;case"ZXY":i[0]=s*a*o-n*l*h,i[1]=n*l*o+s*a*h,i[2]=n*a*h+s*l*o,i[3]=n*a*o-s*l*h;break;case"ZYX":i[0]=s*a*o-n*l*h,i[1]=n*l*o+s*a*h,i[2]=n*a*h-s*l*o,i[3]=n*a*o+s*l*h;break;case"YZX":i[0]=s*a*o+n*l*h,i[1]=n*l*o+s*a*h,i[2]=n*a*h-s*l*o,i[3]=n*a*o-s*l*h;break;case"XZY":i[0]=s*a*o-n*l*h,i[1]=n*l*o-s*a*h,i[2]=n*a*h+s*l*o,i[3]=n*a*o+s*l*h}};const qe=We;var Ze,Ye,Ke,Qe,Je,$e,tr=Qt.set,er=Qt.copy,rr=function(t,e){this.min=t||new ve(1/0,1/0,1/0),this.max=e||new ve(-1/0,-1/0,-1/0),this.vertices=null};rr.prototype={constructor:rr,updateFromVertices:function(t){if(t.length>0){var e=this.min,r=this.max,i=e.array,n=r.array;er(i,t[0]),er(n,t[0]);for(var a=1;a<t.length;a++){var o=t[a];o[0]<i[0]&&(i[0]=o[0]),o[1]<i[1]&&(i[1]=o[1]),o[2]<i[2]&&(i[2]=o[2]),o[0]>n[0]&&(n[0]=o[0]),o[1]>n[1]&&(n[1]=o[1]),o[2]>n[2]&&(n[2]=o[2])}e._dirty=!0,r._dirty=!0}},union:function(t){var e=this.min,r=this.max;return Qt.min(e.array,e.array,t.min.array),Qt.max(r.array,r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},intersection:function(t){var e=this.min,r=this.max;return Qt.max(e.array,e.array,t.min.array),Qt.min(r.array,r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},intersectBoundingBox:function(t){var e=this.min.array,r=this.max.array,i=t.min.array,n=t.max.array;return!(e[0]>n[0]||e[1]>n[1]||e[2]>n[2]||r[0]<i[0]||r[1]<i[1]||r[2]<i[2])},containBoundingBox:function(t){var e=this.min.array,r=this.max.array,i=t.min.array,n=t.max.array;return e[0]<=i[0]&&e[1]<=i[1]&&e[2]<=i[2]&&r[0]>=n[0]&&r[1]>=n[1]&&r[2]>=n[2]},containPoint:function(t){var e=this.min.array,r=this.max.array,i=t.array;return e[0]<=i[0]&&e[1]<=i[1]&&e[2]<=i[2]&&r[0]>=i[0]&&r[1]>=i[1]&&r[2]>=i[2]},isFinite:function(){var t=this.min.array,e=this.max.array;return isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])&&isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])},applyTransform:function(t){this.transformFrom(this,t)},transformFrom:(Ze=Qt.create(),Ye=Qt.create(),Ke=Qt.create(),Qe=Qt.create(),Je=Qt.create(),$e=Qt.create(),function(t,e){var r=t.min.array,i=t.max.array,n=e.array;return Ze[0]=n[0]*r[0],Ze[1]=n[1]*r[0],Ze[2]=n[2]*r[0],Ye[0]=n[0]*i[0],Ye[1]=n[1]*i[0],Ye[2]=n[2]*i[0],Ke[0]=n[4]*r[1],Ke[1]=n[5]*r[1],Ke[2]=n[6]*r[1],Qe[0]=n[4]*i[1],Qe[1]=n[5]*i[1],Qe[2]=n[6]*i[1],Je[0]=n[8]*r[2],Je[1]=n[9]*r[2],Je[2]=n[10]*r[2],$e[0]=n[8]*i[2],$e[1]=n[9]*i[2],$e[2]=n[10]*i[2],r=this.min.array,i=this.max.array,r[0]=Math.min(Ze[0],Ye[0])+Math.min(Ke[0],Qe[0])+Math.min(Je[0],$e[0])+n[12],r[1]=Math.min(Ze[1],Ye[1])+Math.min(Ke[1],Qe[1])+Math.min(Je[1],$e[1])+n[13],r[2]=Math.min(Ze[2],Ye[2])+Math.min(Ke[2],Qe[2])+Math.min(Je[2],$e[2])+n[14],i[0]=Math.max(Ze[0],Ye[0])+Math.max(Ke[0],Qe[0])+Math.max(Je[0],$e[0])+n[12],i[1]=Math.max(Ze[1],Ye[1])+Math.max(Ke[1],Qe[1])+Math.max(Je[1],$e[1])+n[13],i[2]=Math.max(Ze[2],Ye[2])+Math.max(Ke[2],Qe[2])+Math.max(Je[2],$e[2])+n[14],this.min._dirty=!0,this.max._dirty=!0,this}),applyProjection:function(t){var e=this.min.array,r=this.max.array,i=t.array,n=e[0],a=e[1],o=e[2],s=r[0],l=r[1],h=e[2],u=r[0],c=r[1],d=r[2];if(1===i[15])e[0]=i[0]*n+i[12],e[1]=i[5]*a+i[13],r[2]=i[10]*o+i[14],r[0]=i[0]*u+i[12],r[1]=i[5]*c+i[13],e[2]=i[10]*d+i[14];else{var f=-1/o;e[0]=i[0]*n*f,e[1]=i[5]*a*f,r[2]=(i[10]*o+i[14])*f,f=-1/h,r[0]=i[0]*s*f,r[1]=i[5]*l*f,f=-1/d,e[2]=(i[10]*d+i[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var t=this.vertices;if(!t){t=[];for(var e=0;e<8;e++)t[e]=Qt.fromValues(0,0,0);this.vertices=t}var r=this.min.array,i=this.max.array;return tr(t[0],r[0],r[1],r[2]),tr(t[1],r[0],i[1],r[2]),tr(t[2],i[0],r[1],r[2]),tr(t[3],i[0],i[1],r[2]),tr(t[4],r[0],r[1],i[2]),tr(t[5],r[0],i[1],i[2]),tr(t[6],i[0],r[1],i[2]),tr(t[7],i[0],i[1],i[2]),this},copy:function(t){var e=this.min,r=this.max;return er(e.array,t.min.array),er(r.array,t.max.array),e._dirty=!0,r._dirty=!0,this},clone:function(){var t=new rr;return t.copy(this),t}};const ir=rr;var nr,ar=0;const or=m.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},(function(){this.name||(this.name=(this.type||"NODE")+"_"+ar++),this.position||(this.position=new ve),this.rotation||(this.rotation=new qe),this.scale||(this.scale=new ve(1,1,1)),this.worldTransform=new Ve,this.localTransform=new Ve,this._children=[]}),{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(t){var e=this._scene;if(e){var r=e._nodeRepository;delete r[this.name],r[t]=this}this.name=t},add:function(t){var e=t._parent;if(e!==this){e&&e.remove(t),t._parent=this,this._children.push(t);var r=this._scene;r&&r!==t.scene&&t.traverse(this._addSelfToScene,this),t._needsUpdateWorldTransform=!0}},remove:function(t){var e=this._children,r=e.indexOf(t);r<0||(e.splice(r,1),t._parent=null,this._scene&&t.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var t=this._children,e=0;e<t.length;e++)t[e]._parent=null,this._scene&&t[e].traverse(this._removeSelfFromScene,this);this._children=[]},getScene:function(){return this._scene},getParent:function(){return this._parent},_removeSelfFromScene:function(t){t._scene.removeFromScene(t),t._scene=null},_addSelfToScene:function(t){this._scene.addToScene(t),t._scene=this._scene},isAncestor:function(t){for(var e=t._parent;e;){if(e===this)return!0;e=e._parent}return!1},children:function(){return this._children.slice()},childAt:function(t){return this._children[t]},getChildByName:function(t){for(var e=this._children,r=0;r<e.length;r++)if(e[r].name===t)return e[r]},getDescendantByName:function(t){for(var e=this._children,r=0;r<e.length;r++){var i=e[r];if(i.name===t)return i;var n=i.getDescendantByName(t);if(n)return n}},queryNode:function(t){if(t){for(var e=t.split("/"),r=this,i=0;i<e.length;i++){var n=e[i];if(n){for(var a=!1,o=r._children,s=0;s<o.length;s++){var l=o[s];if(l.name===n){r=l,a=!0;break}}if(!a)return}}return r}},getPath:function(t){if(!this._parent)return"/";for(var e=this._parent,r=this.name;e._parent&&(r=e.name+"/"+r,e._parent!=t);)e=e._parent;return!e._parent&&t?null:r},traverse:function(t,e){t.call(e,this);for(var r=this._children,i=0,n=r.length;i<n;i++)r[i].traverse(t,e)},eachChild:function(t,e){for(var r=this._children,i=0,n=r.length;i<n;i++){var a=r[i];t.call(e,a,i)}},setLocalTransform:function(t){Yt.copy(this.localTransform.array,t.array),this.decomposeLocalTransform()},decomposeLocalTransform:function(t){var e=t?null:this.scale;this.localTransform.decomposeMatrix(e,this.rotation,this.position)},setWorldTransform:function(t){Yt.copy(this.worldTransform.array,t.array),this.decomposeWorldTransform()},decomposeWorldTransform:(nr=Yt.create(),function(t){var e=this.localTransform,r=this.worldTransform;this._parent?(Yt.invert(nr,this._parent.worldTransform.array),Yt.multiply(e.array,nr,r.array)):Yt.copy(e.array,r.array);var i=t?null:this.scale;e.decomposeMatrix(i,this.rotation,this.position)}),transformNeedsUpdate:function(){return this.position._dirty||this.rotation._dirty||this.scale._dirty},updateLocalTransform:function(){var t=this.position,e=this.rotation,r=this.scale;if(this.transformNeedsUpdate()){var i=this.localTransform.array;Yt.fromRotationTranslation(i,e.array,t.array),Yt.scale(i,i,r.array),e._dirty=!1,r._dirty=!1,t._dirty=!1,this._needsUpdateWorldTransform=!0}},_updateWorldTransformTopDown:function(){var t=this.localTransform.array,e=this.worldTransform.array;this._parent?Yt.multiplyAffine(e,this._parent.worldTransform.array,t):Yt.copy(e,t)},updateWorldTransform:function(){for(var t=this;t&&t.getParent()&&t.getParent().transformNeedsUpdate();)t=t.getParent();t.update()},update:function(t){this.autoUpdateLocalTransform?this.updateLocalTransform():t=!0,(t||this._needsUpdateWorldTransform)&&(this._updateWorldTransformTopDown(),t=!0,this._needsUpdateWorldTransform=!1);for(var e=this._children,r=0,i=e.length;r<i;r++)e[r].update(t)},getBoundingBox:function(){function t(t){return!t.invisible&&t.geometry}var e=new ir,r=new Ve,i=new Ve;return function(n,a){return a=a||new ir,n=n||t,this._parent?Ve.invert(i,this._parent.worldTransform):Ve.identity(i),this.traverse((function(t){t.geometry&&t.geometry.boundingBox&&(e.copy(t.geometry.boundingBox),Ve.multiply(r,i,t.worldTransform),e.applyTransform(r),a.union(e))}),this,t),a}}(),getWorldPosition:function(t){this.transformNeedsUpdate()&&this.updateWorldTransform();var e=this.worldTransform.array;if(t){var r=t.array;return r[0]=e[12],r[1]=e[13],r[2]=e[14],t}return new ve(e[12],e[13],e[14])},clone:function(){var t=new this.constructor,e=this._children;t.setName(this.name),t.position.copy(this.position),t.rotation.copy(this.rotation),t.scale.copy(this.scale);for(var r=0;r<e.length;r++)t.add(e[r].clone());return t},rotateAround:function(){var t=new ve,e=new Ve;return function(r,i,n){t.copy(this.position).subtract(r);var a=this.localTransform;a.identity(),a.translate(r),a.rotate(n,i),e.fromRotationTranslation(this.rotation,t),a.multiply(e),a.scale(this.scale),this.decomposeLocalTransform(),this._needsUpdateWorldTransform=!0}}(),lookAt:function(){var t=new Ve;return function(e,r){t.lookAt(this.position,e,r||this.localTransform.y).invert(),this.setLocalTransform(t),this.target=e}}()});var sr,lr=or.extend({material:null,geometry:null,mode:4,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:x,frontFace:w,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,ignorePreZ:!1,ignoreGBuffer:!1,isRenderable:function(){return this.geometry&&this.material&&this.material.shader&&!this.invisible&&this.geometry.vertexCount>0},beforeRender:function(t){},afterRender:function(t,e){},getBoundingBox:function(t,e){return e=or.prototype.getBoundingBox.call(this,t,e),this.geometry&&this.geometry.boundingBox&&e.union(this.geometry.boundingBox),e},clone:(sr=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"],function(){var t=or.prototype.clone.call(this);t.geometry=this.geometry,t.material=this.material;for(var e=0;e<sr.length;e++){var r=sr[e];t[r]!==this[r]&&(t[r]=this[r])}return t})});lr.POINTS=0,lr.LINES=1,lr.LINE_LOOP=2,lr.LINE_STRIP=3,lr.TRIANGLES=4,lr.TRIANGLE_STRIP=5,lr.TRIANGLE_FAN=6,lr.BACK=x,lr.FRONT=y,lr.FRONT_AND_BACK=1032,lr.CW=b,lr.CCW=w;const hr=lr;var ur,cr,dr,fr,pr,mr=m.extend({scene:null,camera:null,renderer:null},(function(){this._ray=new Me,this._ndc=new _t}),{pick:function(t,e,r){return this.pickAll(t,e,[],r)[0]||null},pickAll:function(t,e,r,i){return this.renderer.screenToNDC(t,e,this._ndc),this.camera.castRay(this._ndc,this._ray),r=r||[],this._intersectNode(this.scene,r,i||!1),r.sort(this._intersectionCompareFunc),r},_intersectNode:function(t,e,r){t instanceof hr&&t.isRenderable()&&(t.ignorePicking&&!r||!(4===t.mode&&t.geometry.isUseIndices()||t.geometry.pickByRay||t.geometry.pick)||this._intersectRenderable(t,e));for(var i=0;i<t._children.length;i++)this._intersectNode(t._children[i],e,r)},_intersectRenderable:(ur=new ve,cr=new ve,dr=new ve,fr=new Me,pr=new Ve,function(t,e){var r=t.isSkinnedMesh();fr.copy(this._ray),Ve.invert(pr,t.worldTransform),r||fr.applyTransform(pr);var i=t.geometry,n=r?t.skeleton.boundingBox:i.boundingBox;if(!n||fr.intersectBoundingBox(n))if(i.pick)i.pick(this._ndc.x,this._ndc.y,this.renderer,this.camera,t,e);else if(i.pickByRay)i.pickByRay(fr,t,e);else{var a,o,s=t.cullFace===x&&t.frontFace===w||t.cullFace===y&&t.frontFace===b,l=i.indices,h=i.attributes.position,u=i.attributes.weight,c=i.attributes.joint,d=[];if(h&&h.value&&l){if(r){o=t.skeleton.getSubSkinMatrices(t.__uid__,t.joints);for(var f=0;f<t.joints.length;f++){d[f]=d[f]||[];for(var p=0;p<16;p++)d[f][p]=o[16*f+p]}var m=[],g=[],_=[],v=[],T=[],S=i.attributes.skinnedPosition;for(S&&S.value||(i.createAttribute("skinnedPosition","f",3),(S=i.attributes.skinnedPosition).init(i.vertexCount)),f=0;f<i.vertexCount;f++){for(h.get(f,m),u.get(f,g),c.get(f,_),g[3]=1-g[0]-g[1]-g[2],Qt.set(v,0,0,0),p=0;p<4;p++)_[p]>=0&&g[p]>1e-4&&(Qt.transformMat4(T,m,d[_[p]]),Qt.scaleAndAdd(v,v,T,g[p]));S.set(f,v)}}for(f=0;f<l.length;f+=3){var M=l[f],A=l[f+1],C=l[f+2],E=r?i.attributes.skinnedPosition:h;if(E.get(M,ur.array),E.get(A,cr.array),E.get(C,dr.array),a=s?fr.intersectTriangle(ur,cr,dr,t.culling):fr.intersectTriangle(ur,dr,cr,t.culling)){var D=new ve;r?ve.copy(D,a):ve.transformMat4(D,a,t.worldTransform),e.push(new mr.Intersection(a,D,t,[M,A,C],f/3,ve.dist(D,this._ray.origin)))}}}}}),_intersectionCompareFunc:function(t,e){return t.distance-e.distance}});mr.Intersection=function(t,e,r,i,n,a){this.point=t,this.pointWorld=e,this.target=r,this.triangle=i,this.triangleIndex=n,this.distance=a};const gr=mr;var _r="__dt__",vr=function(){this._contextId=0,this._caches=[],this._context={}};(vr.prototype={use:function(t,e){var r=this._caches;r[t]||(r[t]={},e&&(r[t]=e())),this._contextId=t,this._context=r[t]},put:function(t,e){this._context[t]=e},get:function(t){return this._context[t]},dirty:function(t){var e=_r+(t=t||"");this.put(e,!0)},dirtyAll:function(t){for(var e=_r+(t=t||""),r=this._caches,i=0;i<r.length;i++)r[i]&&(r[i][e]=!0)},fresh:function(t){var e=_r+(t=t||"");this.put(e,!1)},freshAll:function(t){for(var e=_r+(t=t||""),r=this._caches,i=0;i<r.length;i++)r[i]&&(r[i][e]=!1)},isDirty:function(t){var e=_r+(t=t||""),r=this._context;return!r.hasOwnProperty(e)||!0===r[e]},deleteContext:function(t){delete this._caches[t],this._context={}},delete:function(t){delete this._context[t]},clearAll:function(){this._caches={}},getContext:function(){return this._context},eachContext:function(t,e){Object.keys(this._caches).forEach((function(r){t&&t.call(e,r)}))},miss:function(t){return!this._context.hasOwnProperty(t)}}).constructor=vr;const yr=vr;var xr=m.extend({width:512,height:512,type:T,format:A,wrapS:N,wrapT:N,minFilter:O,magFilter:E,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},(function(){this._cache=new yr}),{getWebGLTexture:function(t){var e=t.gl,r=this._cache;return r.use(t.__uid__),r.miss("webgl_texture")&&r.put("webgl_texture",e.createTexture()),this.dynamic?this.update(t):r.isDirty()&&(this.update(t),r.fresh()),r.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(t){},updateCommon:function(t){var e=t.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,this.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===M&&(this.useMipmap=!1);var r=t.getGLExtension("EXT_sRGB");this.format!==xr.SRGB||r||(this.format=xr.RGB),this.format!==xr.SRGB_ALPHA||r||(this.format=xr.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?I:this.wrapS},getAvailableWrapT:function(){return this.NPOT?I:this.wrapT},getAvailableMinFilter:function(){var t=this.minFilter;return this.NPOT||!this.useMipmap?t===D||t===P?C:t===O||t===L?E:t:t},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(t){--t;for(var e=1;e<32;e<<=1)t|=t>>e;return t+1},dispose:function(t){var e=this._cache;e.use(t.__uid__);var r=e.get("webgl_texture");r&&t.gl.deleteTexture(r),e.deleteContext(t.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(xr.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(xr.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),xr.BYTE=5120,xr.UNSIGNED_BYTE=T,xr.SHORT=5122,xr.UNSIGNED_SHORT=5123,xr.INT=5124,xr.UNSIGNED_INT=5125,xr.FLOAT=S,xr.HALF_FLOAT=36193,xr.UNSIGNED_INT_24_8_WEBGL=34042,xr.DEPTH_COMPONENT=M,xr.DEPTH_STENCIL=34041,xr.ALPHA=6406,xr.RGB=6407,xr.RGBA=A,xr.LUMINANCE=6409,xr.LUMINANCE_ALPHA=6410,xr.SRGB=35904,xr.SRGB_ALPHA=35906,xr.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,xr.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,xr.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,xr.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,xr.NEAREST=C,xr.LINEAR=E,xr.NEAREST_MIPMAP_NEAREST=D,xr.LINEAR_MIPMAP_NEAREST=L,xr.NEAREST_MIPMAP_LINEAR=P,xr.LINEAR_MIPMAP_LINEAR=O,xr.REPEAT=N,xr.CLAMP_TO_EDGE=I,xr.MIRRORED_REPEAT=33648;const br=xr;var wr=hr.extend({skeleton:null,joints:null},(function(){this.joints||(this.joints=[])}),{offsetMatrix:null,isInstancedMesh:function(){return!1},isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var t=hr.prototype.clone.call(this);return t.skeleton=this.skeleton,this.joints&&(t.joints=this.joints.slice()),t}});wr.POINTS=0,wr.LINES=1,wr.LINE_LOOP=2,wr.LINE_STRIP=3,wr.TRIANGLES=4,wr.TRIANGLE_STRIP=5,wr.TRIANGLE_FAN=6,wr.BACK=x,wr.FRONT=y,wr.FRONT_AND_BACK=1032,wr.CW=b,wr.CCW=w;const Tr=wr;const Sr={isPowerOfTwo:function(t){return 0==(t&t-1)},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}};var Mr=Sr.isPowerOfTwo;function Ar(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}var Cr=br.extend((function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}}),{textureType:"texture2D",update:function(t){var e=t.gl;e.bindTexture(e.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(t);var r=this.format,i=this.type,n=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==br.REPEAT&&this.wrapT!==br.REPEAT||!this.NPOT);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,n?this.wrapS:this.getAvailableWrapS()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,n?this.wrapT:this.getAvailableWrapT()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,n?this.magFilter:this.getAvailableMagFilter()),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n?this.minFilter:this.getAvailableMinFilter());var a=t.getGLExtension("EXT_texture_filter_anisotropic");if(a&&this.anisotropic>1&&e.texParameterf(e.TEXTURE_2D,a.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===i&&(t.getGLExtension("OES_texture_half_float")||(i=S)),this.mipmaps.length)for(var o=this.width,s=this.height,l=0;l<this.mipmaps.length;l++){var h=this.mipmaps[l];this._updateTextureData(e,h,l,o,s,r,i,!1),o/=2,s/=2}else this._updateTextureData(e,this,0,this.width,this.height,r,i,n),!this.useMipmap||this.NPOT&&!n||e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)},_updateTextureData:function(t,e,r,i,n,a,o,s){if(e.image){var l=e.image;s&&(this._potCanvas=function(t,e){var r=Ar(t.width),i=Ar(t.height);return(e=e||document.createElement("canvas")).width=r,e.height=i,e.getContext("2d").drawImage(t.image,0,0,r,i),e}(this,this._potCanvas),l=this._potCanvas),t.texImage2D(t.TEXTURE_2D,r,a,a,o,l)}else a<=br.COMPRESSED_RGBA_S3TC_DXT5_EXT&&a>=br.COMPRESSED_RGB_S3TC_DXT1_EXT?t.compressedTexImage2D(t.TEXTURE_2D,r,a,i,n,0,e.pixels):t.texImage2D(t.TEXTURE_2D,r,a,i,n,0,a,o,e.pixels)},generateMipmap:function(t){var e=t.gl;this.useMipmap&&!this.NPOT&&(e.bindTexture(e.TEXTURE_2D,this._cache.get("webgl_texture")),e.generateMipmap(e.TEXTURE_2D))},isPowerOfTwo:function(){return Mr(this.width)&&Mr(this.height)},isRenderable:function(){return this.image?this.image.width>0&&this.image.height>0:!(!this.width||!this.height)},bind:function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,this.getWebGLTexture(t))},unbind:function(t){t.gl.bindTexture(t.gl.TEXTURE_2D,null)},load:function(t,e){var r=G.createImage();e&&(r.crossOrigin=e);var i=this;return r.onload=function(){i.dirty(),i.trigger("success",i)},r.onerror=function(){i.trigger("error",i)},r.src=t,this.image=r,this}});Object.defineProperty(Cr.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(t){this.image?console.warn("Texture from image can't set width"):(this._width!==t&&this.dirty(),this._width=t)}}),Object.defineProperty(Cr.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(t){this.image?console.warn("Texture from image can't set height"):(this._height!==t&&this.dirty(),this._height=t)}});const Er=Cr;function Dr(t){return{byte:G.Int8Array,ubyte:G.Uint8Array,short:G.Int16Array,ushort:G.Uint16Array}[t]||G.Float32Array}function Lr(t){return"attr_"+t}function Pr(t,e,r,i){switch(this.name=t,this.type=e,this.size=r,this.semantic=i||"",this.value=null,r){case 1:this.get=function(t){return this.value[t]},this.set=function(t,e){this.value[t]=e},this.copy=function(t,e){this.value[t]=this.value[t]};break;case 2:this.get=function(t,e){var r=this.value;return e[0]=r[2*t],e[1]=r[2*t+1],e},this.set=function(t,e){var r=this.value;r[2*t]=e[0],r[2*t+1]=e[1]},this.copy=function(t,e){var r=this.value;e*=2,r[t*=2]=r[e],r[t+1]=r[e+1]};break;case 3:this.get=function(t,e){var r=3*t,i=this.value;return e[0]=i[r],e[1]=i[r+1],e[2]=i[r+2],e},this.set=function(t,e){var r=3*t,i=this.value;i[r]=e[0],i[r+1]=e[1],i[r+2]=e[2]},this.copy=function(t,e){var r=this.value;e*=3,r[t*=3]=r[e],r[t+1]=r[e+1],r[t+2]=r[e+2]};break;case 4:this.get=function(t,e){var r=this.value,i=4*t;return e[0]=r[i],e[1]=r[i+1],e[2]=r[i+2],e[3]=r[i+3],e},this.set=function(t,e){var r=this.value,i=4*t;r[i]=e[0],r[i+1]=e[1],r[i+2]=e[2],r[i+3]=e[3]},this.copy=function(t,e){var r=this.value;e*=4,r[t*=4]=r[e],r[t+1]=r[e+1],r[t+2]=r[e+2],r[t+3]=r[e+3]}}}function Or(t,e,r,i,n){this.name=t,this.type=e,this.buffer=r,this.size=i,this.semantic=n,this.symbol="",this.needsRemove=!1}function Nr(t){this.buffer=t,this.count=0}Pr.prototype.init=function(t){if(!this.value||this.value.length!==t*this.size){var e=Dr(this.type);this.value=new e(t*this.size)}},Pr.prototype.fromArray=function(t){var e,r=Dr(this.type);if(t[0]&&t[0].length){var i=0,n=this.size;e=new r(t.length*n);for(var a=0;a<t.length;a++)for(var o=0;o<n;o++)e[i++]=t[a][o]}else e=new r(t);this.value=e},Pr.prototype.clone=function(t){var e=new Pr(this.name,this.type,this.size,this.semantic);return t&&console.warn("todo"),e};var Ir=m.extend((function(){return{attributes:{},indices:null,dynamic:!0,_enabledAttributes:null,__used:0}}),(function(){this._cache=new yr,this._attributeList=Object.keys(this.attributes),this.__vaoCache={}}),{mainAttribute:"",pick:null,pickByRay:null,dirty:function(){for(var t=this.getEnabledAttributes(),e=0;e<t.length;e++)this.dirtyAttribute(t[e]);this.dirtyIndices(),this._enabledAttributes=null,this._cache.dirty("any")},dirtyIndices:function(){this._cache.dirtyAll("indices")},dirtyAttribute:function(t){this._cache.dirtyAll(Lr(t)),this._cache.dirtyAll("attributes")},getTriangleIndices:function(t,e){if(t<this.triangleCount&&t>=0){e||(e=[]);var r=this.indices;return e[0]=r[3*t],e[1]=r[3*t+1],e[2]=r[3*t+2],e}},setTriangleIndices:function(t,e){var r=this.indices;r[3*t]=e[0],r[3*t+1]=e[1],r[3*t+2]=e[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(t){var e,r=this.vertexCount>65535?G.Uint32Array:G.Uint16Array;if(t[0]&&t[0].length){var i=0;e=new r(3*t.length);for(var n=0;n<t.length;n++)for(var a=0;a<3;a++)e[i++]=t[n][a]}else e=new r(t);this.indices=e},createAttribute:function(t,e,r,i){var n=new Pr(t,e,r,i);return this.attributes[t]&&this.removeAttribute(t),this.attributes[t]=n,this._attributeList.push(t),n},removeAttribute:function(t){var e=this._attributeList,r=e.indexOf(t);return r>=0&&(e.splice(r,1),delete this.attributes[t],!0)},getAttribute:function(t){return this.attributes[t]},getEnabledAttributes:function(){var t=this._enabledAttributes,e=this._attributeList;if(t)return t;for(var r=[],i=this.vertexCount,n=0;n<e.length;n++){var a=e[n],o=this.attributes[a];o.value&&o.value.length===i*o.size&&r.push(a)}return this._enabledAttributes=r,r},getBufferChunks:function(t){var e=this._cache;e.use(t.__uid__);var r=e.isDirty("attributes"),i=e.isDirty("indices");if(r||i){this._updateBuffer(t.gl,r,i);for(var n=this.getEnabledAttributes(),a=0;a<n.length;a++)e.fresh(Lr(n[a]));e.fresh("attributes"),e.fresh("indices")}return e.fresh("any"),e.get("chunks")},_updateBuffer:function(t,e,r){var i=this._cache,n=i.get("chunks"),a=!1;n||((n=[])[0]={attributeBuffers:[],indicesBuffer:null},i.put("chunks",n),a=!0);var o=n[0],s=o.attributeBuffers,l=o.indicesBuffer;if(e||a){var h=this.getEnabledAttributes(),u={};if(!a)for(var c=0;c<s.length;c++)u[s[c].name]=s[c];for(var d=0;d<h.length;d++){var f,p,m=h[d],g=this.attributes[m];a||(f=u[m]),p=f?f.buffer:t.createBuffer(),i.isDirty(Lr(m))&&(t.bindBuffer(t.ARRAY_BUFFER,p),t.bufferData(t.ARRAY_BUFFER,g.value,this.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW)),s[d]=new Or(m,g.type,p,g.size,g.semantic)}for(c=d;c<s.length;c++)t.deleteBuffer(s[c].buffer);s.length=d}this.isUseIndices()&&(r||a)&&(l||(l=new Nr(t.createBuffer()),o.indicesBuffer=l),l.count=this.indices.length,t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,l.buffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,this.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW))},dispose:function(t){var e=this._cache;e.use(t.__uid__);var r=e.get("chunks");if(r)for(var i=0;i<r.length;i++){for(var n=r[i],a=0;a<n.attributeBuffers.length;a++){var o=n.attributeBuffers[a];t.gl.deleteBuffer(o.buffer)}n.indicesBuffer&&t.gl.deleteBuffer(n.indicesBuffer.buffer)}if(this.__vaoCache){var s=t.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var h=this.__vaoCache[l].vao;h&&s.deleteVertexArrayOES(h)}}this.__vaoCache={},e.deleteContext(t.__uid__)}});Object.defineProperty&&(Object.defineProperty(Ir.prototype,"vertexCount",{enumerable:!1,get:function(){var t=this.attributes[this.mainAttribute];return t||(t=this.attributes[this._attributeList[0]]),t&&t.value?t.value.length/t.size:0}}),Object.defineProperty(Ir.prototype,"triangleCount",{enumerable:!1,get:function(){var t=this.indices;return t?t.length/3:0}})),Ir.STATIC_DRAW=35044,Ir.DYNAMIC_DRAW=35048,Ir.STREAM_DRAW=35040,Ir.AttributeBuffer=Or,Ir.IndicesBuffer=Nr,Ir.Attribute=Pr;const Rr=Ir;var Br=Qt.create,Fr=Qt.add,zr=Qt.set,kr=Rr.Attribute,Gr=Rr.extend((function(){return{attributes:{position:new kr("position","float",3,"POSITION"),texcoord0:new kr("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new kr("texcoord1","float",2,"TEXCOORD_1"),normal:new kr("normal","float",3,"NORMAL"),tangent:new kr("tangent","float",4,"TANGENT"),color:new kr("color","float",4,"COLOR"),weight:new kr("weight","float",3,"WEIGHT"),joint:new kr("joint","float",4,"JOINT"),barycentric:new kr("barycentric","float",3,null)},boundingBox:null}}),{mainAttribute:"position",updateBoundingBox:function(){var t=this.boundingBox;t||(t=this.boundingBox=new ir);var e=this.attributes.position.value;if(e&&e.length){var r=t.min,i=t.max,n=r.array,a=i.array;Qt.set(n,e[0],e[1],e[2]),Qt.set(a,e[0],e[1],e[2]);for(var o=3;o<e.length;){var s=e[o++],l=e[o++],h=e[o++];s<n[0]&&(n[0]=s),l<n[1]&&(n[1]=l),h<n[2]&&(n[2]=h),s>a[0]&&(a[0]=s),l>a[1]&&(a[1]=l),h>a[2]&&(a[2]=h)}r._dirty=!0,i._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var t=this.indices,e=this.attributes,r=e.position.value,i=e.normal.value;if(i&&i.length===r.length)for(var n=0;n<i.length;n++)i[n]=0;else i=e.normal.value=new G.Float32Array(r.length);for(var a,o,s,l=Br(),h=Br(),u=Br(),c=Br(),d=Br(),f=Br(),p=t?t.length:this.vertexCount,m=0;m<p;)for(t?(a=t[m++],o=t[m++],s=t[m++]):(a=m++,o=m++,s=m++),zr(l,r[3*a],r[3*a+1],r[3*a+2]),zr(h,r[3*o],r[3*o+1],r[3*o+2]),zr(u,r[3*s],r[3*s+1],r[3*s+2]),Qt.sub(c,l,h),Qt.sub(d,h,u),Qt.cross(f,c,d),n=0;n<3;n++)i[3*a+n]=i[3*a+n]+f[n],i[3*o+n]=i[3*o+n]+f[n],i[3*s+n]=i[3*s+n]+f[n];for(n=0;n<i.length;)zr(f,i[n],i[n+1],i[n+2]),Qt.normalize(f,f),i[n++]=f[0],i[n++]=f[1],i[n++]=f[2];this.dirty()}},generateFaceNormals:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var t=this.indices,e=this.attributes,r=e.position.value,i=e.normal.value,n=Br(),a=Br(),o=Br(),s=Br(),l=Br(),h=Br();i||(i=e.normal.value=new Float32Array(r.length));for(var u,c,d,f=t?t.length:this.vertexCount,p=0;p<f;){t?(u=t[p++],c=t[p++],d=t[p++]):(u=p++,c=p++,d=p++),zr(n,r[3*u],r[3*u+1],r[3*u+2]),zr(a,r[3*c],r[3*c+1],r[3*c+2]),zr(o,r[3*d],r[3*d+1],r[3*d+2]),Qt.sub(s,n,a),Qt.sub(l,a,o),Qt.cross(h,s,l),Qt.normalize(h,h);for(var m=0;m<3;m++)i[3*u+m]=h[m],i[3*c+m]=h[m],i[3*d+m]=h[m]}this.dirty()}},generateTangents:function(){if(this.vertexCount){var t=this.vertexCount,e=this.attributes;e.tangent.value||(e.tangent.value=new Float32Array(4*t));var r=e.texcoord0.value,i=e.position.value,n=e.tangent.value,a=e.normal.value;if(r){for(var o=[],s=[],l=0;l<t;l++)o[l]=[0,0,0],s[l]=[0,0,0];var h,u,c,d=[0,0,0],f=[0,0,0],p=this.indices,m=p?p.length:this.vertexCount;for(l=0;l<m;){p?(h=p[l++],u=p[l++],c=p[l++]):(h=l++,u=l++,c=l++);var g=r[2*h],_=r[2*u],v=r[2*c],y=r[2*h+1],x=r[2*u+1],b=r[2*c+1],w=i[3*h],T=i[3*u],S=i[3*c],M=i[3*h+1],A=i[3*u+1],C=i[3*c+1],E=i[3*h+2],D=T-w,L=S-w,P=A-M,O=C-M,N=i[3*u+2]-E,I=i[3*c+2]-E,R=_-g,B=v-g,F=x-y,z=b-y,k=1/(R*z-F*B);d[0]=(z*D-F*L)*k,d[1]=(z*P-F*O)*k,d[2]=(z*N-F*I)*k,f[0]=(R*L-B*D)*k,f[1]=(R*O-B*P)*k,f[2]=(R*I-B*N)*k,Fr(o[h],o[h],d),Fr(o[u],o[u],d),Fr(o[c],o[c],d),Fr(s[h],s[h],f),Fr(s[u],s[u],f),Fr(s[c],s[c],f)}var G=Br(),U=Br(),H=Br();for(l=0;l<t;l++){H[0]=a[3*l],H[1]=a[3*l+1],H[2]=a[3*l+2];var V=o[l];Qt.scale(G,H,Qt.dot(H,V)),Qt.sub(G,V,G),Qt.normalize(G,G),Qt.cross(U,H,V),n[4*l]=G[0],n[4*l+1]=G[1],n[4*l+2]=G[2],n[4*l+3]=Qt.dot(U,s[l])<0?-1:1}this.dirty()}else console.warn("Geometry without texcoords can't generate tangents.")}},isUniqueVertex:function(){return!this.isUseIndices()||this.vertexCount===this.indices.length},generateUniqueVertex:function(){if(this.vertexCount&&this.indices){this.indices.length>65535&&(this.indices=new G.Uint32Array(this.indices));for(var t=this.attributes,e=this.indices,r=this.getEnabledAttributes(),i={},n=0;n<r.length;n++)i[l=r[n]]=t[l].value,t[l].init(this.indices.length);for(var a=0,o=0;o<e.length;o++){var s=e[o];for(n=0;n<r.length;n++)for(var l,h=t[l=r[n]].value,u=t[l].size,c=0;c<u;c++)h[a*u+c]=i[l][s*u+c];e[o]=a,a++}this.dirty()}},generateBarycentric:function(){if(this.vertexCount){this.isUniqueVertex()||this.generateUniqueVertex();var t=this.attributes,e=t.barycentric.value,r=this.indices;if(!e||e.length!==3*r.length){e=t.barycentric.value=new Float32Array(3*r.length);for(var i=0;i<(r?r.length:this.vertexCount/3);)for(var n=0;n<3;n++)e[3*(r?r[i++]:3*i+n)+n]=1;this.dirty()}}},applyTransform:function(t){var e=this.attributes,r=e.position.value,i=e.normal.value,n=e.tangent.value;t=t.array;var a=Yt.create();Yt.invert(a,t),Yt.transpose(a,a);var o=Qt.transformMat4,s=Qt.forEach;s(r,3,0,null,o,t),i&&s(i,3,0,null,o,a),n&&s(n,4,0,null,o,a),this.boundingBox&&this.updateBoundingBox()},dispose:function(t){var e=this._cache;e.use(t.__uid__);var r=e.get("chunks");if(r)for(var i=0;i<r.length;i++){for(var n=r[i],a=0;a<n.attributeBuffers.length;a++){var o=n.attributeBuffers[a];t.gl.deleteBuffer(o.buffer)}n.indicesBuffer&&t.gl.deleteBuffer(n.indicesBuffer.buffer)}if(this.__vaoCache){var s=t.getGLExtension("OES_vertex_array_object");for(var l in this.__vaoCache){var h=this.__vaoCache[l].vao;h&&s.deleteVertexArrayOES(h)}}this.__vaoCache={},e.deleteContext(t.__uid__)}});Gr.STATIC_DRAW=Rr.STATIC_DRAW,Gr.DYNAMIC_DRAW=Rr.DYNAMIC_DRAW,Gr.STREAM_DRAW=Rr.STREAM_DRAW,Gr.AttributeBuffer=Rr.AttributeBuffer,Gr.IndicesBuffer=Rr.IndicesBuffer,Gr.Attribute=kr;const Ur=Gr;var Hr="@export clay.header.",Vr="@end",Wr=":unconfigurable;";const jr=[Hr+"directional_light","uniform vec3 directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+Wr,"uniform vec3 directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+Wr,Vr,Hr+"ambient_light","uniform vec3 ambientLightColor[AMBIENT_LIGHT_COUNT]"+Wr,Vr,Hr+"ambient_sh_light","uniform vec3 ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+Wr,"uniform vec3 ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+Wr,"vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}",Vr,Hr+"ambient_cubemap_light","uniform vec3 ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+Wr,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+Wr,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+Wr,Vr,Hr+"point_light","uniform vec3 pointLightPosition[POINT_LIGHT_COUNT]"+Wr,"uniform float pointLightRange[POINT_LIGHT_COUNT]"+Wr,"uniform vec3 pointLightColor[POINT_LIGHT_COUNT]"+Wr,Vr,Hr+"spot_light","uniform vec3 spotLightPosition[SPOT_LIGHT_COUNT]"+Wr,"uniform vec3 spotLightDirection[SPOT_LIGHT_COUNT]"+Wr,"uniform float spotLightRange[SPOT_LIGHT_COUNT]"+Wr,"uniform float spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+Wr,"uniform float spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+Wr,"uniform float spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+Wr,"uniform vec3 spotLightColor[SPOT_LIGHT_COUNT]"+Wr,Vr].join("\n");Xt.import(jr);const Xr=or.extend((function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}}),{type:"",clone:function(){var t=or.prototype.clone.call(this);return t.color=Array.prototype.slice.call(this.color),t.intensity=this.intensity,t.castShadow=this.castShadow,t.shadowResolution=this.shadowResolution,t}});var qr,Zr,Yr,Kr,Qr=function(t,e){this.normal=t||new ve(0,1,0),this.distance=e||0};Qr.prototype={constructor:Qr,distanceToPoint:function(t){return Qt.dot(t.array,this.normal.array)-this.distance},projectPoint:function(t,e){e||(e=new ve);var r=this.distanceToPoint(t);return Qt.scaleAndAdd(e.array,t.array,this.normal.array,-r),e._dirty=!0,e},normalize:function(){var t=1/Qt.len(this.normal.array);Qt.scale(this.normal.array,t),this.distance*=t},intersectFrustum:function(t){for(var e=t.vertices,r=this.normal.array,i=Qt.dot(e[0].array,r)>this.distance,n=1;n<8;n++)if(Qt.dot(e[n].array,r)>this.distance!=i)return!0},intersectLine:(Kr=Qt.create(),function(t,e,r){var i=this.distanceToPoint(t),n=this.distanceToPoint(e);if(i>0&&n>0||i<0&&n<0)return null;var a=this.normal.array,o=this.distance,s=t.array;Qt.sub(Kr,e.array,t.array),Qt.normalize(Kr,Kr);var l=Qt.dot(a,Kr);if(0===l)return null;r||(r=new ve);var h=(Qt.dot(a,s)-o)/l;return Qt.scaleAndAdd(r.array,s,Kr,-h),r._dirty=!0,r}),applyTransform:(qr=Yt.create(),Zr=Ce.create(),Yr=Ce.create(),Yr[3]=1,function(t){t=t.array,Qt.scale(Yr,this.normal.array,this.distance),Ce.transformMat4(Yr,Yr,t),this.distance=Qt.dot(Yr,this.normal.array),Yt.invert(qr,t),Yt.transpose(qr,qr),Zr[3]=0,Qt.copy(Zr,this.normal.array),Ce.transformMat4(Zr,Zr,qr),Qt.copy(this.normal.array,Zr)}),copy:function(t){Qt.copy(this.normal.array,t.normal.array),this.normal._dirty=!0,this.distance=t.distance},clone:function(){var t=new Qr;return t.copy(this),t}};const Jr=Qr;var $r,ti=Qt.set,ei=Qt.copy,ri=Qt.transformMat4,ii=Math.min,ni=Math.max,ai=function(){this.planes=[];for(var t=0;t<6;t++)this.planes.push(new Jr);for(this.boundingBox=new ir,this.vertices=[],t=0;t<8;t++)this.vertices[t]=Qt.fromValues(0,0,0)};ai.prototype={setFromProjection:function(t){var e=this.planes,r=t.array,i=r[0],n=r[1],a=r[2],o=r[3],s=r[4],l=r[5],h=r[6],u=r[7],c=r[8],d=r[9],f=r[10],p=r[11],m=r[12],g=r[13],_=r[14],v=r[15];ti(e[0].normal.array,o-i,u-s,p-c),e[0].distance=-(v-m),e[0].normalize(),ti(e[1].normal.array,o+i,u+s,p+c),e[1].distance=-(v+m),e[1].normalize(),ti(e[2].normal.array,o+n,u+l,p+d),e[2].distance=-(v+g),e[2].normalize(),ti(e[3].normal.array,o-n,u-l,p-d),e[3].distance=-(v-g),e[3].normalize(),ti(e[4].normal.array,o-a,u-h,p-f),e[4].distance=-(v-_),e[4].normalize(),ti(e[5].normal.array,o+a,u+h,p+f),e[5].distance=-(v+_),e[5].normalize();var y=this.boundingBox,x=this.vertices;if(0===v){var b=l/i,w=-_/(f-1),T=-_/(f+1),S=-T/l,M=-w/l;y.min.set(-S*b,-S,T),y.max.set(S*b,S,w),ti(x[0],-S*b,-S,T),ti(x[1],-S*b,S,T),ti(x[2],S*b,-S,T),ti(x[3],S*b,S,T),ti(x[4],-M*b,-M,w),ti(x[5],-M*b,M,w),ti(x[6],M*b,-M,w),ti(x[7],M*b,M,w)}else{var A=(-1-m)/i,C=(1-m)/i,E=(1-g)/l,D=(-1-g)/l,L=(-1-_)/f,P=(1-_)/f;y.min.set(Math.min(A,C),Math.min(D,E),Math.min(P,L)),y.max.set(Math.max(C,A),Math.max(E,D),Math.max(L,P));var O=y.min.array,N=y.max.array;ti(x[0],O[0],O[1],O[2]),ti(x[1],O[0],N[1],O[2]),ti(x[2],N[0],O[1],O[2]),ti(x[3],N[0],N[1],O[2]),ti(x[4],O[0],O[1],N[2]),ti(x[5],O[0],N[1],N[2]),ti(x[6],N[0],O[1],N[2]),ti(x[7],N[0],N[1],N[2])}},getTransformedBoundingBox:($r=Qt.create(),function(t,e){var r=this.vertices,i=e.array,n=t.min,a=t.max,o=n.array,s=a.array,l=r[0];ri($r,l,i),ei(o,$r),ei(s,$r);for(var h=1;h<8;h++)l=r[h],ri($r,l,i),o[0]=ii($r[0],o[0]),o[1]=ii($r[1],o[1]),o[2]=ii($r[2],o[2]),s[0]=ni($r[0],s[0]),s[1]=ni($r[1],s[1]),s[2]=ni($r[2],s[2]);return n._dirty=!0,a._dirty=!0,t})};const oi=ai;var si;const li=or.extend((function(){return{projectionMatrix:new Ve,invProjectionMatrix:new Ve,viewMatrix:new Ve,frustum:new oi}}),(function(){this.update(!0)}),{update:function(t){or.prototype.update.call(this,t),Ve.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),Ve.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(t){Ve.copy(this.viewMatrix,t),Ve.invert(this.worldTransform,t),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(t){Ve.copy(this.projectionMatrix,t),Ve.invert(this.invProjectionMatrix,t),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:(si=Ce.create(),function(t,e){var r=void 0!==e?e:new Me,i=t.array[0],n=t.array[1];return Ce.set(si,i,n,-1,1),Ce.transformMat4(si,si,this.invProjectionMatrix.array),Ce.transformMat4(si,si,this.worldTransform.array),Qt.scale(r.origin.array,si,1/si[3]),Ce.set(si,i,n,1,1),Ce.transformMat4(si,si,this.invProjectionMatrix.array),Ce.transformMat4(si,si,this.worldTransform.array),Qt.scale(si,si,1/si[3]),Qt.sub(r.direction.array,si,r.origin.array),Qt.normalize(r.direction.array,r.direction.array),r.direction._dirty=!0,r.origin._dirty=!0,r})});var hi,ui,ci=Yt.create(),di=Yt.create(),fi={};function pi(t){var e=[],r=Object.keys(t);r.sort();for(var i=0;i<r.length;i++){var n=r[i];e.push(n+" "+t[n])}var a=e.join("\n");if(fi[a])return fi[a];var o=f.genGUID();return fi[a]=o,o}function mi(){this.opaque=[],this.transparent=[],this._opaqueCount=0,this._transparentCount=0}function gi(t,e){if(e.castShadow&&!t.castShadow)return!0}mi.prototype.startCount=function(){this._opaqueCount=0,this._transparentCount=0},mi.prototype.add=function(t,e){e?this.transparent[this._transparentCount++]=t:this.opaque[this._opaqueCount++]=t},mi.prototype.endCount=function(){this.transparent.length=this._transparentCount,this.opaque.length=this._opaqueCount};const _i=or.extend((function(){return{material:null,lights:[],viewBoundingBoxLastFrame:new ir,shadowUniforms:{},_cameraList:[],_lightUniforms:{},_previousLightNumber:{},_lightNumber:{},_lightProgramKeys:{},_nodeRepository:{},_renderLists:new W(20)}}),(function(){this._scene=this}),{addToScene:function(t){t instanceof li?(this._cameraList.length>0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(t)):t instanceof Xr&&this.lights.push(t),t.name&&(this._nodeRepository[t.name]=t)},removeFromScene:function(t){var e;t instanceof li?(e=this._cameraList.indexOf(t))>=0&&this._cameraList.splice(e,1):t instanceof Xr&&(e=this.lights.indexOf(t))>=0&&this.lights.splice(e,1),t.name&&delete this._nodeRepository[t.name]},getNode:function(t){return this._nodeRepository[t]},setMainCamera:function(t){var e=this._cameraList.indexOf(t);e>=0&&this._cameraList.splice(e,1),this._cameraList.unshift(t)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var t=this.lights;this._previousLightNumber=this._lightNumber;for(var e={},r=0;r<t.length;r++){var i=t[r];if(!i.invisible){var n=i.group;e[n]||(e[n]={}),e[n][i.type]=e[n][i.type]||0,e[n][i.type]++}}for(var a in this._lightNumber=e,e)this._lightProgramKeys[a]=pi(e[a]);this._updateLightUniforms()},cloneNode:function(t){var e=t.clone(),r={};return function t(e,i){r[e.__uid__]=i;for(var n=0;n<e._children.length;n++)t(e._children[n],i._children[n])}(t,e),e.traverse((function(t){t.skeleton&&(t.skeleton=t.skeleton.clone(r)),t.material&&(t.material=t.material.clone())})),e},updateRenderList:function(t,e){var r=t.__uid__,i=this._renderLists.get(r);i||(i=new mi,this._renderLists.put(r,i)),i.startCount(),e&&(this.viewBoundingBoxLastFrame.min.set(1/0,1/0,1/0),this.viewBoundingBoxLastFrame.max.set(-1/0,-1/0,-1/0));var n=this.material&&this.material.transparent||!1;return this._doUpdateRenderList(this,t,n,i,e),i.endCount(),i},getRenderList:function(t){return this._renderLists.get(t.__uid__)},_doUpdateRenderList:function(t,e,r,i,n){if(!t.invisible)for(var a=0;a<t._children.length;a++){var o=t._children[a];if(o.isRenderable()){var s=o.isSkinnedMesh()?ci:o.worldTransform.array,l=o.geometry;Yt.multiplyAffine(di,e.viewMatrix.array,s),(n&&!l.boundingBox||!this.isFrustumCulled(o,e,di))&&i.add(o,o.material.transparent||r)}o._children.length>0&&this._doUpdateRenderList(o,e,r,i,n)}},isFrustumCulled:(hi=new ir,ui=new Ve,function(t,e,r){var i=t.boundingBox;if(i||(i=t.skeleton&&t.skeleton.boundingBox?t.skeleton.boundingBox:t.geometry.boundingBox),!i)return!1;if(ui.array=r,hi.transformFrom(i,ui),t.castShadow&&this.viewBoundingBoxLastFrame.union(hi),t.frustumCulling){if(!hi.intersectBoundingBox(e.frustum.boundingBox))return!0;ui.array=e.projectionMatrix.array,hi.max.array[2]>0&&hi.min.array[2]<0&&(hi.max.array[2]=-1e-20),hi.applyProjection(ui);var n=hi.min.array,a=hi.max.array;if(a[0]<-1||n[0]>1||a[1]<-1||n[1]>1||a[2]<-1||n[2]>1)return!0}return!1}),_updateLightUniforms:function(){var t=this.lights;t.sort(gi);var e=this._lightUniforms;for(var r in e)for(var i in e[r])e[r][i].value.length=0;for(var n=0;n<t.length;n++){var a=t[n];if(!a.invisible)for(var i in r=a.group,a.uniformTemplates){var o=a.uniformTemplates[i],s=o.value(a);if(null!=s){e[r]||(e[r]={}),e[r][i]||(e[r][i]={type:"",value:[]});var l=e[r][i];switch(l.type=o.type+"v",o.type){case"1i":case"1f":case"t":l.value.push(s);break;case"2f":case"3f":case"4f":for(var h=0;h<s.length;h++)l.value.push(s[h]);break;default:console.error("Unkown light uniform type "+o.type)}}}}},getLightGroups:function(){var t=[];for(var e in this._lightNumber)t.push(e);return t},getNumberChangedLightGroups:function(){var t=[];for(var e in this._lightNumber)this.isLightNumberChanged(e)&&t.push(e);return t},isLightNumberChanged:function(t){var e=this._previousLightNumber,r=this._lightNumber;for(var i in r[t]){if(!e[t])return!0;if(r[t][i]!==e[t][i])return!0}for(var i in e[t]){if(!r[t])return!0;if(r[t][i]!==e[t][i])return!0}return!1},getLightsNumbers:function(t){return this._lightNumber[t]},getProgramKey:function(t){return this._lightProgramKeys[t]},setLightUniforms:function(){function t(t,e,r){for(var i in t){var n=t[i];if("tv"===n.type){if(!e.hasUniform(i))continue;for(var a=[],o=0;o<n.value.length;o++){var s=n.value[o],l=e.takeCurrentTextureSlot(r,s);a.push(l)}e.setUniform(r.gl,"1iv",i,a)}else e.setUniform(r.gl,n.type,i,n.value)}}return function(e,r,i){t(this._lightUniforms[r],e,i),t(this.shadowUniforms,e,i)}}(),dispose:function(){this.material=null,this._opaqueList=[],this._transparentList=[],this.lights=[],this._lightUniforms={},this._lightNumber={},this._nodeRepository={}}});var vi=function(t){this.value=t},yi=function(){function t(){this._len=0}return t.prototype.insert=function(t){var e=new vi(t);return this.insertEntry(e),e},t.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t):this.head=this.tail=t,this._len++},t.prototype.remove=function(t){var e=t.prev,r=t.next;e?e.next=r:this.head=r,r?r.prev=e:this.tail=e,t.next=t.prev=null,this._len--},t.prototype.len=function(){return this._len},t.prototype.clear=function(){this.head=this.tail=null,this._len=0},t}();const xi=function(){function t(t){this._list=new yi,this._maxSize=10,this._map={},this._maxSize=t}return t.prototype.put=function(t,e){var r=this._list,i=this._map,n=null;if(null==i[t]){var a=r.len(),o=this._lastRemovedEntry;if(a>=this._maxSize&&a>0){var s=r.head;r.remove(s),delete i[s.key],n=s.value,this._lastRemovedEntry=s}o?o.value=e:o=new vi(e),o.key=t,r.insertEntry(o),i[t]=o}return n},t.prototype.get=function(t){var e=this._map[t],r=this._list;if(null!=e)return e!==r.tail&&(r.remove(e),r.insertEntry(e)),e.value},t.prototype.clear=function(){this._list.clear(),this._map={}},t.prototype.len=function(){return this._list.len()},t}();var bi=Sr.isPowerOfTwo,wi=["px","nx","py","ny","pz","nz"],Ti=br.extend((function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}}),{textureType:"textureCube",update:function(t){var e=t.gl;e.bindTexture(e.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(t);var r=this.format,i=this.type;e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,this.getAvailableWrapS()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,this.getAvailableWrapT()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var n=t.getGLExtension("EXT_texture_filter_anisotropic");if(n&&this.anisotropic>1&&e.texParameterf(e.TEXTURE_CUBE_MAP,n.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===i&&(t.getGLExtension("OES_texture_half_float")||(i=S)),this.mipmaps.length)for(var a=this.width,o=this.height,s=0;s<this.mipmaps.length;s++){var l=this.mipmaps[s];this._updateTextureData(e,l,s,a,o,r,i),a/=2,o/=2}else this._updateTextureData(e,this,0,this.width,this.height,r,i),!this.NPOT&&this.useMipmap&&e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null)},_updateTextureData:function(t,e,r,i,n,a,o){for(var s=0;s<6;s++){var l=wi[s],h=e.image&&e.image[l];h?t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,r,a,a,o,h):t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,r,a,i,n,0,a,o,e.pixels&&e.pixels[l])}},generateMipmap:function(t){var e=t.gl;this.useMipmap&&!this.NPOT&&(e.bindTexture(e.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),e.generateMipmap(e.TEXTURE_CUBE_MAP))},bind:function(t){t.gl.bindTexture(t.gl.TEXTURE_CUBE_MAP,this.getWebGLTexture(t))},unbind:function(t){t.gl.bindTexture(t.gl.TEXTURE_CUBE_MAP,null)},isPowerOfTwo:function(){return this.image.px?bi(this.image.px.width)&&bi(this.image.px.height):bi(this.width)&&bi(this.height)},isRenderable:function(){return this.image.px?Si(this.image.px)&&Si(this.image.nx)&&Si(this.image.py)&&Si(this.image.ny)&&Si(this.image.pz)&&Si(this.image.nz):!(!this.width||!this.height)},load:function(t,e){var r=0,i=this;return f.each(t,(function(t,n){var a=G.createImage();e&&(a.crossOrigin=e),a.onload=function(){0==--r&&(i.dirty(),i.trigger("success",i))},a.onerror=function(){r--},r++,a.src=t,i.image[n]=a})),this}});function Si(t){return t.width>0&&t.height>0}Object.defineProperty(Ti.prototype,"width",{get:function(){return this.image&&this.image.px?this.image.px.width:this._width},set:function(t){this.image&&this.image.px?console.warn("Texture from image can't set width"):(this._width!==t&&this.dirty(),this._width=t)}}),Object.defineProperty(Ti.prototype,"height",{get:function(){return this.image&&this.image.px?this.image.px.height:this._height},set:function(t){this.image&&this.image.px?console.warn("Texture from image can't set height"):(this._height!==t&&this.dirty(),this._height=t)}});const Mi=Ti,Ai=li.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var t=this.fov/180*Math.PI;this.projectionMatrix.perspective(t,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var t=this.projectionMatrix.array,e=2*Math.atan(1/t[5]);this.fov=e/Math.PI*180,this.aspect=t[5]/t[0],this.near=t[14]/(t[10]-1),this.far=t[14]/(t[10]+1)},clone:function(){var t=li.prototype.clone.call(this);return t.fov=this.fov,t.aspect=this.aspect,t.near=this.near,t.far=this.far,t}});var Ci="framebuffer",Ei="renderbuffer",Di="renderbuffer_width",Li="renderbuffer_height",Pi="renderbuffer_attached",Oi="depthtexture_attached",Ni=36160,Ii=36161,Ri=36096,Bi=m.extend({depthBuffer:!0,viewport:null,_width:0,_height:0,_textures:null,_boundRenderer:null},(function(){this._cache=new yr,this._textures={}}),{getTextureWidth:function(){return this._width},getTextureHeight:function(){return this._height},bind:function(t){if(t.__currentFrameBuffer){if(t.__currentFrameBuffer===this)return;console.warn("Renderer already bound with another framebuffer. Unbind it first")}t.__currentFrameBuffer=this;var e=t.gl;e.bindFramebuffer(Ni,this._getFrameBufferGL(t)),this._boundRenderer=t;var r=this._cache;r.put("viewport",t.viewport);var i,n,a=!1;for(var o in this._textures){a=!0;var s=this._textures[o];s&&(i=s.texture.width,n=s.texture.height,this._doAttach(t,s.texture,o,s.target))}this._width=i,this._height=n,!a&&this.depthBuffer&&console.error("Must attach texture before bind, or renderbuffer may have incorrect width and height."),this.viewport?t.setViewport(this.viewport):t.setViewport(0,0,i,n,1);var l=r.get("attached_textures");if(l)for(var o in l)if(!this._textures[o]){var h=l[o];this._doDetach(e,o,h)}if(!r.get(Oi)&&this.depthBuffer){r.miss(Ei)&&r.put(Ei,e.createRenderbuffer());var u=r.get(Ei);i===r.get(Di)&&n===r.get(Li)||(e.bindRenderbuffer(Ii,u),e.renderbufferStorage(Ii,e.DEPTH_COMPONENT16,i,n),r.put(Di,i),r.put(Li,n),e.bindRenderbuffer(Ii,null)),r.get(Pi)||(e.framebufferRenderbuffer(Ni,Ri,Ii,u),r.put(Pi,!0))}},unbind:function(t){t.__currentFrameBuffer=null,t.gl.bindFramebuffer(Ni,null),this._boundRenderer=null,this._cache.use(t.__uid__);var e=this._cache.get("viewport");e&&t.setViewport(e),this.updateMipmap(t)},updateMipmap:function(t){var e=t.gl;for(var r in this._textures){var i=this._textures[r];if(i){var n=i.texture;if(!n.NPOT&&n.useMipmap&&n.minFilter===br.LINEAR_MIPMAP_LINEAR){var a="textureCube"===n.textureType?34067:3553;e.bindTexture(a,n.getWebGLTexture(t)),e.generateMipmap(a),e.bindTexture(a,null)}}}},checkStatus:function(t){return t.checkFramebufferStatus(Ni)},_getFrameBufferGL:function(t){var e=this._cache;return e.use(t.__uid__),e.miss(Ci)&&e.put(Ci,t.gl.createFramebuffer()),e.get(Ci)},attach:function(t,e,r){if(!t.width)throw new Error("The texture attached to color buffer is not a valid.");e=e||36064,r=r||3553;var i,n=this._boundRenderer;if(n&&n.gl){var a=this._cache;a.use(n.__uid__),i=a.get("attached_textures")}var o=this._textures[e];if(!o||o.target!==r||o.texture!==t||!i||null==i[e]){var s=!0;n&&(s=this._doAttach(n,t,e,r),this.viewport||n.setViewport(0,0,t.width,t.height,1)),s&&(this._textures[e]=this._textures[e]||{},this._textures[e].texture=t,this._textures[e].target=r)}},_doAttach:function(t,e,r,i){var n=t.gl,a=e.getWebGLTexture(t),o=this._cache.get("attached_textures");if(o&&o[r]){var s=o[r];if(s.texture===e&&s.target===i)return}var l=!0;if(((r=+r)===Ri||r===R)&&(t.getGLExtension("WEBGL_depth_texture")||(console.error("Depth texture is not supported by the browser"),l=!1),e.format!==M&&34041!==e.format&&(console.error("The texture attached to depth buffer is not a valid."),l=!1),l)){var h=this._cache.get(Ei);h&&(n.framebufferRenderbuffer(Ni,Ri,Ii,null),n.deleteRenderbuffer(h),this._cache.put(Ei,!1)),this._cache.put(Pi,!1),this._cache.put(Oi,!0)}return n.framebufferTexture2D(Ni,r,i,a,0),o||(o={},this._cache.put("attached_textures",o)),o[r]=o[r]||{},o[r].texture=e,o[r].target=i,l},_doDetach:function(t,e,r){t.framebufferTexture2D(Ni,e,r,null,0);var i=this._cache.get("attached_textures");i&&i[e]&&(i[e]=null),e!==Ri&&e!==R||this._cache.put(Oi,!1)},detach:function(t,e){this._textures[t]=null,this._boundRenderer&&(this._cache.use(this._boundRenderer.__uid__),this._doDetach(this._boundRenderer.gl,t,e))},dispose:function(t){var e=t.gl,r=this._cache;r.use(t.__uid__);var i=r.get(Ei);i&&e.deleteRenderbuffer(i);var n=r.get(Ci);n&&e.deleteFramebuffer(n),r.deleteContext(t.__uid__),this._textures={}}});Bi.DEPTH_ATTACHMENT=Ri,Bi.COLOR_ATTACHMENT0=36064,Bi.STENCIL_ATTACHMENT=36128,Bi.DEPTH_STENCIL_ATTACHMENT=R;const Fi=Bi;var zi=["px","nx","py","ny","pz","nz"];const ki=m.extend((function(){var t={position:new ve,far:1e3,near:.1,texture:null,shadowMapPass:null},e=t._cameras={px:new Ai({fov:90}),nx:new Ai({fov:90}),py:new Ai({fov:90}),ny:new Ai({fov:90}),pz:new Ai({fov:90}),nz:new Ai({fov:90})};return e.px.lookAt(ve.POSITIVE_X,ve.NEGATIVE_Y),e.nx.lookAt(ve.NEGATIVE_X,ve.NEGATIVE_Y),e.py.lookAt(ve.POSITIVE_Y,ve.POSITIVE_Z),e.ny.lookAt(ve.NEGATIVE_Y,ve.NEGATIVE_Z),e.pz.lookAt(ve.POSITIVE_Z,ve.NEGATIVE_Y),e.nz.lookAt(ve.NEGATIVE_Z,ve.NEGATIVE_Y),t._frameBuffer=new Fi,t}),{getCamera:function(t){return this._cameras[t]},render:function(t,e,r){var i=t.gl;r||e.update();for(var n=this.texture.width,a=2*Math.atan(n/(n-.5))/Math.PI*180,o=0;o<6;o++){var s=zi[o],l=this._cameras[s];if(ve.copy(l.position,this.position),l.far=this.far,l.near=this.near,l.fov=a,this.shadowMapPass){l.update();var h=e.getBoundingBox();h.applyTransform(l.viewMatrix),e.viewBoundingBoxLastFrame.copy(h),this.shadowMapPass.render(t,e,l,!0)}this._frameBuffer.attach(this.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._frameBuffer.bind(t),t.render(e,l,!0),this._frameBuffer.unbind(t)}},dispose:function(t){this._frameBuffer.dispose(t)}}),Gi=Ur.extend({dynamic:!1,widthSegments:1,heightSegments:1},(function(){this.build()}),{build:function(){for(var t=this.heightSegments,e=this.widthSegments,r=this.attributes,i=[],n=[],a=[],o=[],s=0;s<=t;s++)for(var l=s/t,h=0;h<=e;h++){var u=h/e;if(i.push([2*u-1,2*l-1,0]),n&&n.push([u,l]),a&&a.push([0,0,1]),h<e&&s<t){var c=h+s*(e+1);o.push([c,c+1,c+e+1]),o.push([c+e+1,c+1,c+e+2])}}r.position.fromArray(i),r.texcoord0.fromArray(n),r.normal.fromArray(a),this.initIndicesFromArray(o),this.boundingBox=new ir,this.boundingBox.min.set(-1,-1,0),this.boundingBox.max.set(1,1,0)}});var Ui=new Ve;function Hi(t,e,r){Ui.identity();var i=new Gi({widthSegments:e,heightSegments:r});switch(t){case"px":Ve.translate(Ui,Ui,ve.POSITIVE_X),Ve.rotateY(Ui,Ui,Math.PI/2);break;case"nx":Ve.translate(Ui,Ui,ve.NEGATIVE_X),Ve.rotateY(Ui,Ui,-Math.PI/2);break;case"py":Ve.translate(Ui,Ui,ve.POSITIVE_Y),Ve.rotateX(Ui,Ui,-Math.PI/2);break;case"ny":Ve.translate(Ui,Ui,ve.NEGATIVE_Y),Ve.rotateX(Ui,Ui,Math.PI/2);break;case"pz":Ve.translate(Ui,Ui,ve.POSITIVE_Z);break;case"nz":Ve.translate(Ui,Ui,ve.NEGATIVE_Z),Ve.rotateY(Ui,Ui,Math.PI)}return i.applyTransform(Ui),i}const Vi=Ur.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},(function(){this.build()}),{build:function(){var t={px:Hi("px",this.depthSegments,this.heightSegments),nx:Hi("nx",this.depthSegments,this.heightSegments),py:Hi("py",this.widthSegments,this.depthSegments),ny:Hi("ny",this.widthSegments,this.depthSegments),pz:Hi("pz",this.widthSegments,this.heightSegments),nz:Hi("nz",this.widthSegments,this.heightSegments)},e=["position","texcoord0","normal"],r=0,i=0;for(var n in t)r+=t[n].vertexCount,i+=t[n].indices.length;for(var a=0;a<e.length;a++)this.attributes[e[a]].init(r);this.indices=new G.Uint16Array(i);var o=0,s=0;for(var n in t){var l=t[n];for(a=0;a<e.length;a++)for(var h=e[a],u=l.attributes[h].value,c=l.attributes[h].size,d="normal"===h,f=0;f<u.length;f++){var p=u[f];this.inside&&d&&(p=-p),this.attributes[h].value[f+c*s]=p}var m=l.indices.length;for(f=0;f<l.indices.length;f++)this.indices[f+o]=s+l.indices[this.inside?m-f-1:f];o+=l.indices.length,s+=l.vertexCount}this.boundingBox=new ir,this.boundingBox.max.set(1,1,1),this.boundingBox.min.set(-1,-1,-1)}});Xt.import("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");const Wi=Tr.extend((function(){var t=new Xt({vertex:Xt.source("clay.skybox.vertex"),fragment:Xt.source("clay.skybox.fragment")}),e=new lt({shader:t,depthMask:!1});return{scene:null,geometry:new Vi,material:e,environmentMap:null,culling:!1,_dummyCamera:new Ai}}),(function(){var t=this.scene;t&&this.attachScene(t),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)}),{attachScene:function(t){this.scene&&this.detachScene(),t.skybox=this,this.scene=t,t.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(t){this.detachScene(),this.geometry.dispose(t)},setEnvironmentMap:function(t){"texture2D"===t.textureType?(this.material.define("EQUIRECTANGULAR"),t.minFilter=br.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",t)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(t,e,r){this.renderSkybox(t,r)},renderSkybox:function(t,e){var r=this._dummyCamera;r.aspect=t.getViewportAspect(),r.fov=e.fov||50,r.updateProjectionMatrix(),Ve.invert(r.invProjectionMatrix,r.projectionMatrix),r.worldTransform.copy(e.worldTransform),r.viewMatrix.copy(e.viewMatrix),this.position.copy(e.getWorldPosition()),this.update(),t.gl.disable(t.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),t.renderPass([this],r)}}),ji=Wi;function Xi(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var qi=Xi("DXT1"),Zi=Xi("DXT3"),Yi=Xi("DXT5");const Ki=function(t,e){var r=new Int32Array(t,0,31);if(542327876!==r[0])return null;if(4&!r(20))return null;var i,n,a=r(21),o=r[4],s=r[3],l=512&r[28],h=131072&r[2];switch(a){case qi:i=8,n=br.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case Zi:i=16,n=br.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case Yi:i=16,n=br.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var u=r[1]+4,c=l?6:1,d=1;h&&(d=Math.max(1,r[7]));for(var f=[],p=0;p<c;p++){var m=o,g=s;f[p]=new Er({width:m,height:g,format:n});for(var _=[],v=0;v<d;v++){var y=Math.max(4,m)/4*Math.max(4,g)/4*i,x=new Uint8Array(t,u,y);u+=y,m*=.5,g*=.5,_[v]=x}f[p].pixels=_[0],h&&(f[p].mipmaps=_)}if(!e)return f[0];e.width=f[0].width,e.height=f[0].height,e.format=f[0].format,e.pixels=f[0].pixels,e.mipmaps=f[0].mipmaps};var Qi=String.fromCharCode;function Ji(t,e,r,i){if(t[3]>0){var n=Math.pow(2,t[3]-128-8+i);e[r+0]=t[0]*n,e[r+1]=t[1]*n,e[r+2]=t[2]*n}else e[r+0]=0,e[r+1]=0,e[r+2]=0;return e[r+3]=1,e}function $i(t,e,r,i){for(var n,a,o=0,s=0,l=i;l>0;)if(t[s][0]=e[r++],t[s][1]=e[r++],t[s][2]=e[r++],t[s][3]=e[r++],1===t[s][0]&&1===t[s][1]&&1===t[s][2]){for(var h=t[s][3]<<o>>>0;h>0;h--)n=t[s-1],(a=t[s])[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],s++,l--;o+=8}else s++,l--,o=0;return r}function tn(t,e,r,i){if(i<8|i>32767)return $i(t,e,r,i);if(2!=(n=e[r++]))return $i(t,e,r-1,i);if(t[0][1]=e[r++],t[0][2]=e[r++],n=e[r++],(t[0][2]<<8>>>0|n)>>>0!==i)return null;for(var n=0;n<4;n++)for(var a=0;a<i;){var o=e[r++];if(o>128){o=(127&o)>>>0;for(var s=e[r++];o--;)t[a++][n]=s}else for(;o--;)t[a++][n]=e[r++]}return r}const en=function(t,e,r){null==r&&(r=0);var i=new Uint8Array(t),n=i.length;if("#?"===function(t,e,r){for(var i="",n=0;n<2;n++)i+=Qi(t[n]);return i}(i)){for(var a=2;a<n&&("\n"!==Qi(i[a])||"\n"!==Qi(i[a+1]));a++);if(!(a>=n)){a+=2;for(var o="";a<n;a++){var s=Qi(i[a]);if("\n"===s)break;o+=s}var l=o.split(" "),h=parseInt(l[1]),u=parseInt(l[3]);if(u&&h){for(var c=a+1,d=[],f=0;f<u;f++){d[f]=[];for(var p=0;p<4;p++)d[f][p]=0}for(var m=new Float32Array(u*h*4),g=0,_=0;_<h;_++){if(!(c=tn(d,i,c,u)))return null;for(f=0;f<u;f++)Ji(d[f],m,g,r),g+=4}return e||(e=new Er),e.width=u,e.height=h,e.pixels=m,e.type=br.FLOAT,e}}}};var rn={loadTexture:function(t,e,r,i){var n;if("function"==typeof e?(i=r=e,e={}):e=e||{},"string"==typeof t){if(t.match(/.hdr$/)||"hdr"===e.fileType)return n=new Er({width:0,height:0,sRGB:!1}),rn._fetchTexture(t,(function(t){en(t,n,e.exposure),n.dirty(),r&&r(n)}),i),n;t.match(/.dds$/)||"dds"===e.fileType?(n=new Er({width:0,height:0}),rn._fetchTexture(t,(function(t){Ki(t,n),n.dirty(),r&&r(n)}),i)):((n=new Er).load(t),n.success(r),n.error(i))}else"object"==typeof t&&void 0!==t.px&&((n=new Mi).load(t),n.success(r),n.error(i));return n},loadPanorama:function(t,e,r,i,n,a){var o=this;"function"==typeof i?(a=n=i,i={}):i=i||{},rn.loadTexture(e,i,(function(e){e.flipY=i.flipY||!1,o.panoramaToCubeMap(t,e,r,i),e.dispose(t),n&&n(r)}),a)},panoramaToCubeMap:function(t,e,r,i){var n=new ki,a=new ji({scene:new _i});return a.setEnvironmentMap(e),(i=i||{}).encodeRGBM&&a.material.define("fragment","RGBM_ENCODE"),r.sRGB=e.sRGB,n.texture=r,n.render(t,a.scene),n.texture=null,n.dispose(t),r},heightToNormal:function(t,e){var r=document.createElement("canvas"),i=r.width=t.width,n=r.height=t.height,a=r.getContext("2d");a.drawImage(t,0,0,i,n),e=e||!1;for(var o=a.getImageData(0,0,i,n),s=a.createImageData(i,n),l=0;l<o.data.length;l+=4){if(e){var h=o.data[l],u=o.data[l+1],c=o.data[l+2];if(Math.abs(h-u)+Math.abs(u-c)>20)return console.warn("Given image is not a height map"),t}var d,f,p,m;l%(4*i)==0?(d=o.data[l],p=o.data[l+4]):l%(4*i)==4*(i-1)?(d=o.data[l-4],p=o.data[l]):(d=o.data[l-4],p=o.data[l+4]),l<4*i?(f=o.data[l],m=o.data[l+4*i]):l>i*(n-1)*4?(f=o.data[l-4*i],m=o.data[l]):(f=o.data[l-4*i],m=o.data[l+4*i]),s.data[l]=d-p+127,s.data[l+1]=f-m+127,s.data[l+2]=255,s.data[l+3]=255}return a.putImageData(s,0,0),r},isHeightImage:function(t,e,r){if(!t||!t.width||!t.height)return!1;var i=document.createElement("canvas"),n=i.getContext("2d"),a=e||32;r=r||20,i.width=i.height=a,n.drawImage(t,0,0,a,a);for(var o=n.getImageData(0,0,a,a),s=0;s<o.data.length;s+=4){var l=o.data[s],h=o.data[s+1],u=o.data[s+2];if(Math.abs(l-h)+Math.abs(h-u)>r)return!1}return!0},_fetchTexture:function(t,e,r){G.request.get({url:t,responseType:"arraybuffer",onload:e,onerror:r})},createChessboard:function(t,e,r,i){t=t||512,e=e||64,r=r||"black",i=i||"white";var n=Math.ceil(t/e),a=document.createElement("canvas");a.width=t,a.height=t;var o=a.getContext("2d");o.fillStyle=i,o.fillRect(0,0,t,t),o.fillStyle=r;for(var s=0;s<n;s++)for(var l=0;l<n;l++)(l%2?s%2:s%2-1)&&o.fillRect(s*e,l*e,e,e);return new Er({image:a,anisotropic:8})},createBlank:function(t){var e=document.createElement("canvas");e.width=1,e.height=1;var r=e.getContext("2d");return r.fillStyle=t,r.fillRect(0,0,1,1),new Er({image:e})}};const nn=rn;var an=["mousedown","mouseup","mousemove","mouseover","mouseout","click","dblclick","contextmenu"];function on(t){return"_on"+t}var sn=function(t){var e=this;this._texture=new Er({anisotropic:32,flipY:!1,surface:this,dispose:function(t){e.dispose(),Er.prototype.dispose.call(this,t)}}),an.forEach((function(t){this[on(t)]=function(e){e.triangle&&this._meshes.forEach((function(r){this.dispatchEvent(t,r,e.triangle,e.point)}),this)}}),this),this._meshes=[],t&&this.setECharts(t),this.onupdate=null};sn.prototype={constructor:sn,getTexture:function(){return this._texture},setECharts:function(t){this._chart=t;var e=t.getDom();if(e instanceof HTMLCanvasElement){var r=this,i=t.getZr(),n=i.__oldRefreshImmediately||i.refreshImmediately;i.refreshImmediately=function(){n.call(this),r._texture.dirty(),r.onupdate&&r.onupdate()},i.__oldRefreshImmediately=n}else console.error("ECharts must init on canvas if it is used as texture."),e=document.createElement("canvas");this._texture.image=e,this._texture.dirty(),this.onupdate&&this.onupdate()},dispatchEvent:function(){var t=new ve,e=new ve,r=new ve,i=new _t,n=new _t,a=new _t,o=new _t,s=new ve;return function(l,h,u,c){var d=h.geometry,f=d.attributes.position,p=d.attributes.texcoord0,m=ve.dot,g=ve.cross;f.get(u[0],t.array),f.get(u[1],e.array),f.get(u[2],r.array),p.get(u[0],i.array),p.get(u[1],n.array),p.get(u[2],a.array),g(s,e,r);var _=m(t,s),v=m(c,s)/_;g(s,r,t);var y=m(c,s)/_;g(s,t,e);var x=m(c,s)/_;_t.scale(o,i,v),_t.scaleAndAdd(o,o,n,y),_t.scaleAndAdd(o,o,a,x);var b=o.x*this._chart.getWidth(),w=o.y*this._chart.getHeight();this._chart.getZr().handler.dispatch(l,{zrX:b,zrY:w})}}(),attachToMesh:function(t){this._meshes.indexOf(t)>=0||(an.forEach((function(e){t.on(e,this[on(e)],this)}),this),this._meshes.push(t))},detachFromMesh:function(t){var e=this._meshes.indexOf(t);e>=0&&this._meshes.splice(e,1),an.forEach((function(e){t.off(e,this[on(e)])}),this)},dispose:function(){this._meshes.forEach((function(t){this.detachFromMesh(t)}),this)}};const ln=sn,hn=li.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var t=this.projectionMatrix.array;this.left=(-1-t[12])/t[0],this.right=(1-t[12])/t[0],this.top=(1-t[13])/t[5],this.bottom=(-1-t[13])/t[5],this.near=-(-1-t[14])/t[10],this.far=-(1-t[14])/t[10]},clone:function(){var t=li.prototype.clone.call(this);return t.left=this.left,t.right=this.right,t.near=this.near,t.far=this.far,t.top=this.top,t.bottom=this.bottom,t}});Xt.import("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");var un=new Gi,cn=new Tr({geometry:un,frustumCulling:!1}),dn=new hn;const fn=m.extend((function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}}),(function(){var t=new Xt(Xt.source("clay.compositor.vertex"),this.fragment),e=new lt({shader:t});e.enableTexturesAll(),this.material=e}),{setUniform:function(t,e){this.material.setUniform(t,e)},getUniform:function(t){var e=this.material.uniforms[t];if(e)return e.value},attachOutput:function(t,e){this.outputs||(this.outputs={}),e=e||36064,this.outputs[e]=t},detachOutput:function(t){for(var e in this.outputs)this.outputs[e]===t&&(this.outputs[e]=null)},bind:function(t,e){if(this.outputs)for(var r in this.outputs){var i=this.outputs[r];i&&e.attach(i,r)}e&&e.bind(t)},unbind:function(t,e){e.unbind(t)},render:function(t,e){var r=t.gl;if(e){this.bind(t,e);var i=t.getGLExtension("EXT_draw_buffers");if(i&&this.outputs){var n=[];for(var a in this.outputs)(a=+a)>=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&n.push(a);i.drawBuffersEXT(n)}}this.trigger("beforerender",this,t);var o=this.clearDepth?r.DEPTH_BUFFER_BIT:0;if(r.depthMask(!0),this.clearColor){o|=r.COLOR_BUFFER_BIT,r.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&r.clearColor(s[0],s[1],s[2],s[3])}r.clear(o),this.blendWithPrevious?(r.enable(r.BLEND),this.material.transparent=!0):(r.disable(r.BLEND),this.material.transparent=!1),this.renderQuad(t),this.trigger("afterrender",this,t),e&&this.unbind(t,e)},renderQuad:function(t){cn.material=this.material,t.renderPass([cn],dn)},dispose:function(t){}});var pn={},mn=["px","nx","py","ny","pz","nz"];pn.prefilterEnvironmentMap=function(t,e,r,i,n){n&&i||(i=pn.generateNormalDistribution(),n=pn.integrateBRDF(t,i));var a=(r=r||{}).width||64,o=r.height||64,s=r.type||e.type,l=new Mi({width:a,height:o,type:s,flipY:!1,mipmaps:[]});l.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var h=Math.min(a,o),u=Math.log(h)/Math.log(2)+1,c=new lt({shader:new Xt({vertex:Xt.source("clay.skybox.vertex"),fragment:"#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"})});c.set("normalDistribution",i),r.encodeRGBM&&c.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&c.define("fragment","RGBM_DECODE");var d,f=new _i;if("texture2D"===e.textureType){var p=new Mi({width:a,height:o,type:s===br.FLOAT?br.HALF_FLOAT:s});nn.panoramaToCubeMap(t,e,p,{encodeRGBM:r.decodeRGBM}),e=p}(d=new Wi({scene:f,material:c})).material.set("environmentMap",e);var m=new ki({texture:l});r.encodeRGBM&&(s=l.type=br.UNSIGNED_BYTE);for(var g=new Er({width:a,height:o,type:s}),_=new Fi({depthBuffer:!1}),v=G[s===br.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],y=0;y<u;y++){l.mipmaps[y]={pixels:{}},d.material.set("roughness",y/(u-1));for(var x=g.width,b=2*Math.atan(x/(x-.5))/Math.PI*180,w=0;w<mn.length;w++){var T=new v(g.width*g.height*4);_.attach(g),_.bind(t);var S=m.getCamera(mn[w]);S.fov=b,t.render(f,S),t.gl.readPixels(0,0,g.width,g.height,br.RGBA,s,T),_.unbind(t),l.mipmaps[y].pixels[mn[w]]=T}g.width/=2,g.height/=2,g.dirty()}return _.dispose(t),g.dispose(t),d.dispose(t),i.dispose(t),{environmentMap:l,brdfLookup:n,normalDistribution:i,maxMipmapLevel:u}},pn.integrateBRDF=function(t,e){e=e||pn.generateNormalDistribution();var r=new Fi({depthBuffer:!1}),i=new fn({fragment:"#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"}),n=new Er({width:512,height:256,type:br.HALF_FLOAT,wrapS:br.CLAMP_TO_EDGE,wrapT:br.CLAMP_TO_EDGE,minFilter:br.NEAREST,magFilter:br.NEAREST,useMipmap:!1});return i.setUniform("normalDistribution",e),i.setUniform("viewportSize",[512,256]),i.attachOutput(n),i.render(t,r),r.dispose(t),n},pn.generateNormalDistribution=function(t,e){for(var r=new Er({width:t=t||256,height:e=e||1024,type:br.FLOAT,minFilter:br.NEAREST,magFilter:br.NEAREST,wrapS:br.CLAMP_TO_EDGE,wrapT:br.CLAMP_TO_EDGE,useMipmap:!1}),i=new Float32Array(e*t*4),n=[],a=0;a<t;a++){for(var o=a/t,s=o*o,l=0;l<e;l++){var h=(l<<16|l>>>16)>>>0;h=(((16711935&(h=((252645135&(h=((858993459&(h=((1431655765&h)<<1|(2863311530&h)>>>1)>>>0))<<2|(3435973836&h)>>>2)>>>0))<<4|(4042322160&h)>>>4)>>>0))<<8|(4278255360&h)>>>8)>>>0)/4294967296;var u=Math.sqrt((1-h)/(1+(s*s-1)*h));n[l]=u}for(l=0;l<e;l++){var c=4*(l*t+a),d=(u=n[l],Math.sqrt(1-u*u)),f=l/e,p=2*Math.PI*f;i[c]=d*Math.cos(p),i[c+1]=u,i[c+2]=d*Math.sin(p),i[c+3]=1}}return r.pixels=i,r};const gn=pn,_n=Xr.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(t,e){if(t.getGLExtension("EXT_shader_texture_lod")){this._brdfLookup||(this._normalDistribution=gn.generateNormalDistribution(),this._brdfLookup=gn.integrateBRDF(t,this._normalDistribution));var r=this.cubemap;if(!r.__prefiltered){var i=gn.prefilterEnvironmentMap(t,r,{encodeRGBM:!0,width:e,height:e},this._normalDistribution,this._brdfLookup);this.cubemap=i.environmentMap,this.cubemap.__prefiltered=!0,r.dispose(t)}}else console.warn("Device not support textureCubeLodEXT")},getBRDFLookup:function(){return this._brdfLookup},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}},ambientCubemapLightCubemap:{type:"t",value:function(t){return t.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(t){return t._brdfLookup}}}}),vn=Xr.extend({castShadow:!1,coefficients:[]},(function(){this._coefficientsTmpArr=new G.Float32Array(27)}),{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}},ambientSHLightCoefficients:{type:"3f",value:function(t){for(var e=t._coefficientsTmpArr,r=0;r<t.coefficients.length;r++)e[r]=t.coefficients[r];return e}}}});var yn={},xn=["px","nx","py","ny","pz","nz"];function bn(t,e){var r=t[0],i=t[1],n=t[2];return 0===e?1:1===e?r:2===e?i:3===e?n:4===e?r*n:5===e?i*n:6===e?r*i:7===e?3*n*n-1:r*r-i*i}var wn={px:[2,1,0,-1,-1,1],nx:[2,1,0,1,-1,-1],py:[0,2,1,1,-1,-1],ny:[0,2,1,1,1,1],pz:[0,1,2,-1,-1,-1],nz:[0,1,2,1,-1,1]};yn.projectEnvironmentMap=function(t,e,r){var i;(r=r||{}).lod=r.lod||0;var n=new _i,a=64;"texture2D"===e.textureType?i=new ji({scene:n,environmentMap:e}):(a=e.image&&e.image.px?e.image.px.width:e.width,i=new Wi({scene:n,environmentMap:e}));var o=Math.ceil(a/Math.pow(2,r.lod)),s=Math.ceil(a/Math.pow(2,r.lod)),l=new Er({width:o,height:s}),h=new Fi;i.material.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&i.material.define("fragment","RGBM_DECODE"),i.material.set("lod",r.lod);for(var u=new ki({texture:l}),c={},d=0;d<xn.length;d++){c[xn[d]]=new Uint8Array(o*s*4);var f=u.getCamera(xn[d]);f.fov=90,h.attach(l),h.bind(t),t.render(n,f),t.gl.readPixels(0,0,o,s,br.RGBA,br.UNSIGNED_BYTE,c[xn[d]]),h.unbind(t)}return i.dispose(t),h.dispose(t),l.dispose(t),function(t,e,r,i){for(var n=new G.Float32Array(27),a=Qt.create(),o=Qt.create(),s=Qt.create(),l=0;l<9;l++){for(var h=Qt.create(),u=0;u<xn.length;u++){for(var c=e[xn[u]],d=Qt.create(),f=0,p=0,m=wn[xn[u]],g=0;g<i;g++)for(var _=0;_<r;_++){a[0]=_/(r-1)*2-1,a[1]=g/(i-1)*2-1,a[2]=-1,Qt.normalize(a,a),s[0]=a[m[0]]*m[3],s[1]=a[m[1]]*m[4],s[2]=a[m[2]]*m[5],o[0]=c[p++]/255,o[1]=c[p++]/255,o[2]=c[p++]/255;var v=c[p++]/255*8.12;o[0]*=v,o[1]*=v,o[2]*=v,Qt.scaleAndAdd(d,d,o,bn(s,l)*-a[2]),f+=-a[2]}Qt.scaleAndAdd(h,h,d,1/f)}n[3*l]=h[0]/6,n[3*l+1]=h[1]/6,n[3*l+2]=h[2]/6}return n}(0,c,o,s)};const Tn=yn,Sn=function(){for(var t=0,e=arguments.length;t<e;t++)if(null!=arguments[t])return arguments[t]},Mn=function(t,e){return null!=e.dataIndexInside?e.dataIndexInside:null!=e.dataIndex?i.util.isArray(e.dataIndex)?i.util.map(e.dataIndex,(function(e){return t.indexOfRawIndex(e)})):t.indexOfRawIndex(e.dataIndex):null!=e.name?i.util.isArray(e.name)?i.util.map(e.name,(function(e){return t.indexOfName(e)})):t.indexOfName(e.name):void 0},An=Ur.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},(function(){this.build()}),{build:function(){var t=this.heightSegments,e=this.widthSegments,r=this.attributes.position,i=this.attributes.texcoord0,n=this.attributes.normal,a=(e+1)*(t+1);r.init(a),i.init(a),n.init(a);var o,s,l,h,u,c,d,f,p,m,g,_=a>65535?Uint32Array:Uint16Array,v=this.indices=new _(e*t*6),y=this.radius,x=this.phiStart,b=this.phiLength,w=this.thetaStart,T=this.thetaLength,S=[],M=[],A=0,C=1/(y=this.radius);for(d=0;d<=t;d++)for(c=0;c<=e;c++)h=c/e,u=d/t,o=-y*Math.cos(x+h*b)*Math.sin(w+u*T),s=y*Math.cos(w+u*T),l=y*Math.sin(x+h*b)*Math.sin(w+u*T),S[0]=o,S[1]=s,S[2]=l,M[0]=h,M[1]=u,r.set(A,S),i.set(A,M),S[0]*=C,S[1]*=C,S[2]*=C,n.set(A,S),A++;var E=e+1,D=0;for(d=0;d<t;d++)for(c=0;c<e;c++)p=d*E+c,f=d*E+c+1,g=(d+1)*E+c+1,m=(d+1)*E+c,v[D++]=f,v[D++]=p,v[D++]=g,v[D++]=p,v[D++]=m,v[D++]=g;this.boundingBox=new ir,this.boundingBox.max.set(y,y,y),this.boundingBox.min.set(-y,-y,-y)}}),Cn=Xr.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}}}}),En=Xr.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(t){return t.__dir=t.__dir||new ve,t.__dir.copy(t.worldTransform.z).normalize().negate().array}},directionalLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}}},clone:function(){var t=Xr.prototype.clone.call(this);return t.shadowBias=this.shadowBias,t.shadowSlopeScale=this.shadowSlopeScale,t}}),Dn=Xr.extend({range:100,castShadow:!1},{type:"POINT_LIGHT",uniformTemplates:{pointLightPosition:{type:"3f",value:function(t){return t.getWorldPosition().array}},pointLightRange:{type:"1f",value:function(t){return t.range}},pointLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}}},clone:function(){var t=Xr.prototype.clone.call(this);return t.range=this.range,t}}),Ln=Xr.extend({range:20,umbraAngle:30,penumbraAngle:45,falloffFactor:2,shadowBias:.001,shadowSlopeScale:2},{type:"SPOT_LIGHT",uniformTemplates:{spotLightPosition:{type:"3f",value:function(t){return t.getWorldPosition().array}},spotLightRange:{type:"1f",value:function(t){return t.range}},spotLightUmbraAngleCosine:{type:"1f",value:function(t){return Math.cos(t.umbraAngle*Math.PI/180)}},spotLightPenumbraAngleCosine:{type:"1f",value:function(t){return Math.cos(t.penumbraAngle*Math.PI/180)}},spotLightFalloffFactor:{type:"1f",value:function(t){return t.falloffFactor}},spotLightDirection:{type:"3f",value:function(t){return t.__dir=t.__dir||new ve,t.__dir.copy(t.worldTransform.z).negate().array}},spotLightColor:{type:"3f",value:function(t){var e=t.color,r=t.intensity;return[e[0]*r,e[1]*r,e[2]*r]}}},clone:function(){var t=Xr.prototype.clone.call(this);return t.range=this.range,t.umbraAngle=this.umbraAngle,t.penumbraAngle=this.penumbraAngle,t.falloffFactor=this.falloffFactor,t.shadowBias=this.shadowBias,t.shadowSlopeScale=this.shadowSlopeScale,t}});var Pn=function(t,e,r,i){t=t||0,e=e||0,r=r||0,i=i||0,this.array=Ce.fromValues(t,e,r,i),this._dirty=!0};Pn.prototype={constructor:Pn,add:function(t){return Ce.add(this.array,this.array,t.array),this._dirty=!0,this},set:function(t,e,r,i){return this.array[0]=t,this.array[1]=e,this.array[2]=r,this.array[3]=i,this._dirty=!0,this},setArray:function(t){return this.array[0]=t[0],this.array[1]=t[1],this.array[2]=t[2],this.array[3]=t[3],this._dirty=!0,this},clone:function(){return new Pn(this.x,this.y,this.z,this.w)},copy:function(t){return Ce.copy(this.array,t.array),this._dirty=!0,this},dist:function(t){return Ce.dist(this.array,t.array)},distance:function(t){return Ce.distance(this.array,t.array)},div:function(t){return Ce.div(this.array,this.array,t.array),this._dirty=!0,this},divide:function(t){return Ce.divide(this.array,this.array,t.array),this._dirty=!0,this},dot:function(t){return Ce.dot(this.array,t.array)},len:function(){return Ce.len(this.array)},length:function(){return Ce.length(this.array)},lerp:function(t,e,r){return Ce.lerp(this.array,t.array,e.array,r),this._dirty=!0,this},min:function(t){return Ce.min(this.array,this.array,t.array),this._dirty=!0,this},max:function(t){return Ce.max(this.array,this.array,t.array),this._dirty=!0,this},mul:function(t){return Ce.mul(this.array,this.array,t.array),this._dirty=!0,this},multiply:function(t){return Ce.multiply(this.array,this.array,t.array),this._dirty=!0,this},negate:function(){return Ce.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return Ce.normalize(this.array,this.array),this._dirty=!0,this},random:function(t){return Ce.random(this.array,t),this._dirty=!0,this},scale:function(t){return Ce.scale(this.array,this.array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return Ce.scaleAndAdd(this.array,this.array,t.array,e),this._dirty=!0,this},sqrDist:function(t){return Ce.sqrDist(this.array,t.array)},squaredDistance:function(t){return Ce.squaredDistance(this.array,t.array)},sqrLen:function(){return Ce.sqrLen(this.array)},squaredLength:function(){return Ce.squaredLength(this.array)},sub:function(t){return Ce.sub(this.array,this.array,t.array),this._dirty=!0,this},subtract:function(t){return Ce.subtract(this.array,this.array,t.array),this._dirty=!0,this},transformMat4:function(t){return Ce.transformMat4(this.array,this.array,t.array),this._dirty=!0,this},transformQuat:function(t){return Ce.transformQuat(this.array,this.array,t.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var On=Object.defineProperty;if(On){var Nn=Pn.prototype;On(Nn,"x",{get:function(){return this.array[0]},set:function(t){this.array[0]=t,this._dirty=!0}}),On(Nn,"y",{get:function(){return this.array[1]},set:function(t){this.array[1]=t,this._dirty=!0}}),On(Nn,"z",{get:function(){return this.array[2]},set:function(t){this.array[2]=t,this._dirty=!0}}),On(Nn,"w",{get:function(){return this.array[3]},set:function(t){this.array[3]=t,this._dirty=!0}})}Pn.add=function(t,e,r){return Ce.add(t.array,e.array,r.array),t._dirty=!0,t},Pn.set=function(t,e,r,i,n){Ce.set(t.array,e,r,i,n),t._dirty=!0},Pn.copy=function(t,e){return Ce.copy(t.array,e.array),t._dirty=!0,t},Pn.distance=Pn.dist=function(t,e){return Ce.distance(t.array,e.array)},Pn.divide=Pn.div=function(t,e,r){return Ce.divide(t.array,e.array,r.array),t._dirty=!0,t},Pn.dot=function(t,e){return Ce.dot(t.array,e.array)},Pn.len=function(t){return Ce.length(t.array)},Pn.lerp=function(t,e,r,i){return Ce.lerp(t.array,e.array,r.array,i),t._dirty=!0,t},Pn.min=function(t,e,r){return Ce.min(t.array,e.array,r.array),t._dirty=!0,t},Pn.max=function(t,e,r){return Ce.max(t.array,e.array,r.array),t._dirty=!0,t},Pn.multiply=Pn.mul=function(t,e,r){return Ce.multiply(t.array,e.array,r.array),t._dirty=!0,t},Pn.negate=function(t,e){return Ce.negate(t.array,e.array),t._dirty=!0,t},Pn.normalize=function(t,e){return Ce.normalize(t.array,e.array),t._dirty=!0,t},Pn.random=function(t,e){return Ce.random(t.array,e),t._dirty=!0,t},Pn.scale=function(t,e,r){return Ce.scale(t.array,e.array,r),t._dirty=!0,t},Pn.scaleAndAdd=function(t,e,r,i){return Ce.scaleAndAdd(t.array,e.array,r.array,i),t._dirty=!0,t},Pn.squaredDistance=Pn.sqrDist=function(t,e){return Ce.sqrDist(t.array,e.array)},Pn.squaredLength=Pn.sqrLen=function(t){return Ce.sqrLen(t.array)},Pn.subtract=Pn.sub=function(t,e,r){return Ce.subtract(t.array,e.array,r.array),t._dirty=!0,t},Pn.transformMat4=function(t,e,r){return Ce.transformMat4(t.array,e.array,r.array),t._dirty=!0,t},Pn.transformQuat=function(t,e,r){return Ce.transformQuat(t.array,e.array,r.array),t._dirty=!0,t};const In=Pn;var Rn={create:function(){var t=new ct(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},clone:function(t){var e=new ct(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},transpose:function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=r*a-n*i;return o?(o=1/o,t[0]=a*o,t[1]=-i*o,t[2]=-n*o,t[3]=r*o,t):null},adjoint:function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},determinant:function(t){return t[0]*t[3]-t[2]*t[1]},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],h=r[2],u=r[3];return t[0]=i*s+a*l,t[1]=n*s+o*l,t[2]=i*h+a*u,t[3]=n*h+o*u,t}};Rn.mul=Rn.multiply,Rn.rotate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(r),l=Math.cos(r);return t[0]=i*l+a*s,t[1]=n*l+o*s,t[2]=i*-s+a*l,t[3]=n*-s+o*l,t},Rn.scale=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1];return t[0]=i*s,t[1]=n*s,t[2]=a*l,t[3]=o*l,t},Rn.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2))},Rn.LDU=function(t,e,r,i){return t[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-t[2]*r[1],[t,e,r]};const Bn=Rn;var Fn=function(){this.array=Bn.create(),this._dirty=!0};Fn.prototype={constructor:Fn,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},clone:function(){return(new Fn).copy(this)},copy:function(t){return Bn.copy(this.array,t.array),this._dirty=!0,this},adjoint:function(){return Bn.adjoint(this.array,this.array),this._dirty=!0,this},determinant:function(){return Bn.determinant(this.array)},identity:function(){return Bn.identity(this.array),this._dirty=!0,this},invert:function(){return Bn.invert(this.array,this.array),this._dirty=!0,this},mul:function(t){return Bn.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return Bn.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return Bn.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return Bn.multiply(this.array,t.array,this.array),this._dirty=!0,this},rotate:function(t){return Bn.rotate(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return Bn.scale(this.array,this.array,t.array),this._dirty=!0,this},transpose:function(){return Bn.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Fn.adjoint=function(t,e){return Bn.adjoint(t.array,e.array),t._dirty=!0,t},Fn.copy=function(t,e){return Bn.copy(t.array,e.array),t._dirty=!0,t},Fn.determinant=function(t){return Bn.determinant(t.array)},Fn.identity=function(t){return Bn.identity(t.array),t._dirty=!0,t},Fn.invert=function(t,e){return Bn.invert(t.array,e.array),t._dirty=!0,t},Fn.multiply=Fn.mul=function(t,e,r){return Bn.mul(t.array,e.array,r.array),t._dirty=!0,t},Fn.rotate=function(t,e,r){return Bn.rotate(t.array,e.array,r),t._dirty=!0,t},Fn.scale=function(t,e,r){return Bn.scale(t.array,e.array,r.array),t._dirty=!0,t},Fn.transpose=function(t,e){return Bn.transpose(t.array,e.array),t._dirty=!0,t};const zn=Fn;var kn={create:function(){var t=new ct(6);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},clone:function(t){var e=new ct(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},copy:function(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},identity:function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},invert:function(t,e){var r=e[0],i=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=r*a-i*n;return l?(l=1/l,t[0]=a*l,t[1]=-i*l,t[2]=-n*l,t[3]=r*l,t[4]=(n*s-a*o)*l,t[5]=(i*o-r*s)*l,t):null},determinant:function(t){return t[0]*t[3]-t[1]*t[2]},multiply:function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=r[0],u=r[1],c=r[2],d=r[3],f=r[4],p=r[5];return t[0]=i*h+a*u,t[1]=n*h+o*u,t[2]=i*c+a*d,t[3]=n*c+o*d,t[4]=i*f+a*p+s,t[5]=n*f+o*p+l,t}};kn.mul=kn.multiply,kn.rotate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=Math.sin(r),u=Math.cos(r);return t[0]=i*u+a*h,t[1]=n*u+o*h,t[2]=i*-h+a*u,t[3]=n*-h+o*u,t[4]=s,t[5]=l,t},kn.scale=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=r[0],u=r[1];return t[0]=i*h,t[1]=n*h,t[2]=a*u,t[3]=o*u,t[4]=s,t[5]=l,t},kn.translate=function(t,e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],h=r[0],u=r[1];return t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=i*h+a*u+s,t[5]=n*h+o*u+l,t},kn.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+1)};const Gn=kn;var Un=function(){this.array=Gn.create(),this._dirty=!0};Un.prototype={constructor:Un,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},clone:function(){return(new Un).copy(this)},copy:function(t){return Gn.copy(this.array,t.array),this._dirty=!0,this},determinant:function(){return Gn.determinant(this.array)},identity:function(){return Gn.identity(this.array),this._dirty=!0,this},invert:function(){return Gn.invert(this.array,this.array),this._dirty=!0,this},mul:function(t){return Gn.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return Gn.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return Gn.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return Gn.multiply(this.array,t.array,this.array),this._dirty=!0,this},rotate:function(t){return Gn.rotate(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return Gn.scale(this.array,this.array,t.array),this._dirty=!0,this},translate:function(t){return Gn.translate(this.array,this.array,t.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Un.copy=function(t,e){return Gn.copy(t.array,e.array),t._dirty=!0,t},Un.determinant=function(t){return Gn.determinant(t.array)},Un.identity=function(t){return Gn.identity(t.array),t._dirty=!0,t},Un.invert=function(t,e){return Gn.invert(t.array,e.array),t._dirty=!0,t},Un.multiply=Un.mul=function(t,e,r){return Gn.mul(t.array,e.array,r.array),t._dirty=!0,t},Un.rotate=function(t,e,r){return Gn.rotate(t.array,e.array,r),t._dirty=!0,t},Un.scale=function(t,e,r){return Gn.scale(t.array,e.array,r.array),t._dirty=!0,t},Un.translate=function(t,e,r){return Gn.translate(t.array,e.array,r.array),t._dirty=!0,t};const Hn=Un;var Vn=function(){this.array=De.create(),this._dirty=!0};Vn.prototype={constructor:Vn,setArray:function(t){for(var e=0;e<this.array.length;e++)this.array[e]=t[e];return this._dirty=!0,this},adjoint:function(){return De.adjoint(this.array,this.array),this._dirty=!0,this},clone:function(){return(new Vn).copy(this)},copy:function(t){return De.copy(this.array,t.array),this._dirty=!0,this},determinant:function(){return De.determinant(this.array)},fromMat2d:function(t){return De.fromMat2d(this.array,t.array),this._dirty=!0,this},fromMat4:function(t){return De.fromMat4(this.array,t.array),this._dirty=!0,this},fromQuat:function(t){return De.fromQuat(this.array,t.array),this._dirty=!0,this},identity:function(){return De.identity(this.array),this._dirty=!0,this},invert:function(){return De.invert(this.array,this.array),this._dirty=!0,this},mul:function(t){return De.mul(this.array,this.array,t.array),this._dirty=!0,this},mulLeft:function(t){return De.mul(this.array,t.array,this.array),this._dirty=!0,this},multiply:function(t){return De.multiply(this.array,this.array,t.array),this._dirty=!0,this},multiplyLeft:function(t){return De.multiply(this.array,t.array,this.array),this._dirty=!0,this},rotate:function(t){return De.rotate(this.array,this.array,t),this._dirty=!0,this},scale:function(t){return De.scale(this.array,this.array,t.array),this._dirty=!0,this},translate:function(t){return De.translate(this.array,this.array,t.array),this._dirty=!0,this},normalFromMat4:function(t){return De.normalFromMat4(this.array,t.array),this._dirty=!0,this},transpose:function(){return De.transpose(this.array,this.array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}},Vn.adjoint=function(t,e){return De.adjoint(t.array,e.array),t._dirty=!0,t},Vn.copy=function(t,e){return De.copy(t.array,e.array),t._dirty=!0,t},Vn.determinant=function(t){return De.determinant(t.array)},Vn.identity=function(t){return De.identity(t.array),t._dirty=!0,t},Vn.invert=function(t,e){return De.invert(t.array,e.array),t},Vn.multiply=Vn.mul=function(t,e,r){return De.mul(t.array,e.array,r.array),t._dirty=!0,t},Vn.fromMat2d=function(t,e){return De.fromMat2d(t.array,e.array),t._dirty=!0,t},Vn.fromMat4=function(t,e){return De.fromMat4(t.array,e.array),t._dirty=!0,t},Vn.fromQuat=function(t,e){return De.fromQuat(t.array,e.array),t._dirty=!0,t},Vn.normalFromMat4=function(t,e){return De.normalFromMat4(t.array,e.array),t._dirty=!0,t},Vn.rotate=function(t,e,r){return De.rotate(t.array,e.array,r),t._dirty=!0,t},Vn.scale=function(t,e,r){return De.scale(t.array,e.array,r.array),t._dirty=!0,t},Vn.transpose=function(t,e){return De.transpose(t.array,e.array),t._dirty=!0,t},Vn.translate=function(t,e,r){return De.translate(t.array,e.array,r.array),t._dirty=!0,t};const Wn=Vn;var jn={linear:function(t){return t},quadraticIn:function(t){return t*t},quadraticOut:function(t){return t*(2-t)},quadraticInOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},cubicIn:function(t){return t*t*t},cubicOut:function(t){return--t*t*t+1},cubicInOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},quarticIn:function(t){return t*t*t*t},quarticOut:function(t){return 1- --t*t*t*t},quarticInOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},quinticIn:function(t){return t*t*t*t*t},quinticOut:function(t){return--t*t*t*t*t+1},quinticInOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},sinusoidalIn:function(t){return 1-Math.cos(t*Math.PI/2)},sinusoidalOut:function(t){return Math.sin(t*Math.PI/2)},sinusoidalInOut:function(t){return.5*(1-Math.cos(Math.PI*t))},exponentialIn:function(t){return 0===t?0:Math.pow(1024,t-1)},exponentialOut:function(t){return 1===t?1:1-Math.pow(2,-10*t)},exponentialInOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))},circularIn:function(t){return 1-Math.sqrt(1-t*t)},circularOut:function(t){return Math.sqrt(1- --t*t)},circularInOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},elasticIn:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),-r*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4))},elasticOut:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),r*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/.4)+1)},elasticInOut:function(t){var e,r=.1;return 0===t?0:1===t?1:(!r||r<1?(r=1,e=.1):e=.4*Math.asin(1/r)/(2*Math.PI),(t*=2)<1?r*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*-.5:r*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/.4)*.5+1)},backIn:function(t){var e=1.70158;return t*t*((e+1)*t-e)},backOut:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},backInOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)},bounceIn:function(t){return 1-jn.bounceOut(1-t)},bounceOut:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bounceInOut:function(t){return t<.5?.5*jn.bounceIn(2*t):.5*jn.bounceOut(2*t-1)+.5}};const Xn=jn,qn=function(){function t(t){this._initialized=!1,this._startTime=0,this._pausedTime=0,this._paused=!1,this._life=t.life||1e3,this._delay=t.delay||0,this.loop=null!=t.loop&&t.loop,this.gap=t.gap||0,this.easing=t.easing||"linear",this.onframe=t.onframe,this.ondestroy=t.ondestroy,this.onrestart=t.onrestart}return t.prototype.step=function(t,e){if(this._initialized||(this._startTime=t+this._delay,this._initialized=!0),!this._paused){var r=(t-this._startTime-this._pausedTime)/this._life;r<0&&(r=0),r=Math.min(r,1);var i=this.easing,n="string"==typeof i?Xn[i]:i,a="function"==typeof n?n(r):r;if(this.onframe&&this.onframe(a),1===r){if(!this.loop)return!0;this._restart(t),this.onrestart&&this.onrestart()}return!1}this._pausedTime+=e},t.prototype._restart=function(t){var e=(t-this._startTime-this._pausedTime)%this._life;this._startTime=t-e+this.gap,this._pausedTime=0},t.prototype.pause=function(){this._paused=!0},t.prototype.resume=function(){this._paused=!1},t}();var Zn={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Yn(t){return(t=Math.round(t))<0?0:t>255?255:t}function Kn(t){return t<0?0:t>1?1:t}function Qn(t){var e=t;return e.length&&"%"===e.charAt(e.length-1)?Yn(parseFloat(e)/100*255):Yn(parseInt(e,10))}function Jn(t){var e=t;return e.length&&"%"===e.charAt(e.length-1)?Kn(parseFloat(e)/100):Kn(parseFloat(e))}function $n(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}function ta(t,e,r,i,n){return t[0]=e,t[1]=r,t[2]=i,t[3]=n,t}function ea(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}var ra=new xi(20),ia=null;function na(t,e){ia&&ea(ia,e),ia=ra.put(t,ia||e.slice())}function aa(t,e){if(t){e=e||[];var r=ra.get(t);if(r)return ea(e,r);var i=(t+="").replace(/ /g,"").toLowerCase();if(i in Zn)return ea(e,Zn[i]),na(t,e),e;var n,a=i.length;if("#"===i.charAt(0))return 4===a||5===a?(n=parseInt(i.slice(1,4),16))>=0&&n<=4095?(ta(e,(3840&n)>>4|(3840&n)>>8,240&n|(240&n)>>4,15&n|(15&n)<<4,5===a?parseInt(i.slice(4),16)/15:1),na(t,e),e):void ta(e,0,0,0,1):7===a||9===a?(n=parseInt(i.slice(1,7),16))>=0&&n<=16777215?(ta(e,(16711680&n)>>16,(65280&n)>>8,255&n,9===a?parseInt(i.slice(7),16)/255:1),na(t,e),e):void ta(e,0,0,0,1):void 0;var o=i.indexOf("("),s=i.indexOf(")");if(-1!==o&&s+1===a){var l=i.substr(0,o),h=i.substr(o+1,s-(o+1)).split(","),u=1;switch(l){case"rgba":if(4!==h.length)return 3===h.length?ta(e,+h[0],+h[1],+h[2],1):ta(e,0,0,0,1);u=Jn(h.pop());case"rgb":return 3!==h.length?void ta(e,0,0,0,1):(ta(e,Qn(h[0]),Qn(h[1]),Qn(h[2]),u),na(t,e),e);case"hsla":return 4!==h.length?void ta(e,0,0,0,1):(h[3]=Jn(h[3]),oa(h,e),na(t,e),e);case"hsl":return 3!==h.length?void ta(e,0,0,0,1):(oa(h,e),na(t,e),e);default:return}}ta(e,0,0,0,1)}}function oa(t,e){var r=(parseFloat(t[0])%360+360)%360/360,i=Jn(t[1]),n=Jn(t[2]),a=n<=.5?n*(i+1):n+i-n*i,o=2*n-a;return ta(e=e||[],Yn(255*$n(o,a,r+1/3)),Yn(255*$n(o,a,r)),Yn(255*$n(o,a,r-1/3)),1),4===t.length&&(e[3]=t[3]),e}function sa(t,e){var r=aa(t);return r?(.299*r[0]+.587*r[1]+.114*r[2])*r[3]/255+(1-r[3])*e:0}var la={"[object Function]":!0,"[object RegExp]":!0,"[object Date]":!0,"[object Error]":!0,"[object CanvasGradient]":!0,"[object CanvasPattern]":!0,"[object Image]":!0,"[object Canvas]":!0},ha={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0},ua=Object.prototype.toString,ca=Array.prototype,da=ca.forEach,fa=ca.filter,pa=ca.slice,ma=ca.map,ga=function(){}.constructor,_a=ga?ga.prototype:null,va={},ya=2311;function xa(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];"undefined"!=typeof console&&console.error.apply(console,t)}function ba(t){if(null==t||"object"!=typeof t)return t;var e=t,r=ua.call(t);if("[object Array]"===r){if(!Ha(t)){e=[];for(var i=0,n=t.length;i<n;i++)e[i]=ba(t[i])}}else if(ha[r]){if(!Ha(t)){var a=t.constructor;if(a.from)e=a.from(t);else for(e=new a(t.length),i=0,n=t.length;i<n;i++)e[i]=ba(t[i])}}else if(!la[r]&&!Ha(t)&&!Ba(t))for(var o in e={},t)t.hasOwnProperty(o)&&(e[o]=ba(t[o]));return e}function wa(t,e,r){if(!Ia(e)||!Ia(t))return r?ba(e):t;for(var i in e)if(e.hasOwnProperty(i)){var n=t[i],a=e[i];!Ia(a)||!Ia(n)||Oa(a)||Oa(n)||Ba(a)||Ba(n)||Ra(a)||Ra(n)||Ha(a)||Ha(n)?!r&&i in t||(t[i]=ba(e[i])):wa(n,a,r)}return t}function Ta(t,e){if(Object.assign)Object.assign(t,e);else for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function Sa(t,e,r){for(var i=La(e),n=0;n<i.length;n++){var a=i[n];(r?null!=e[a]:null==t[a])&&(t[a]=e[a])}return t}function Ma(t,e){if(t){if(t.indexOf)return t.indexOf(e);for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r}return-1}function Aa(t,e,r){if(t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,Object.getOwnPropertyNames)for(var i=Object.getOwnPropertyNames(e),n=0;n<i.length;n++){var a=i[n];"constructor"!==a&&(r?null!=e[a]:null==t[a])&&(t[a]=e[a])}else Sa(t,e,r)}function Ca(t){return!!t&&"string"!=typeof t&&"number"==typeof t.length}function Ea(t,e,r){if(t&&e)if(t.forEach&&t.forEach===da)t.forEach(e,r);else if(t.length===+t.length)for(var i=0,n=t.length;i<n;i++)e.call(r,t[i],i,t);else for(var a in t)t.hasOwnProperty(a)&&e.call(r,t[a],a,t)}function Da(t,e,r){if(!t)return[];if(!e)return ka(t);if(t.map&&t.map===ma)return t.map(e,r);for(var i=[],n=0,a=t.length;n<a;n++)i.push(e.call(r,t[n],n,t));return i}function La(t){if(!t)return[];if(Object.keys)return Object.keys(t);var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e}function Pa(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return function(){return t.apply(this,e.concat(pa.call(arguments)))}}function Oa(t){return Array.isArray?Array.isArray(t):"[object Array]"===ua.call(t)}function Na(t){return"string"==typeof t}function Ia(t){var e=typeof t;return"function"===e||!!t&&"object"===e}function Ra(t){return!!la[ua.call(t)]}function Ba(t){return"object"==typeof t&&"number"==typeof t.nodeType&&"object"==typeof t.ownerDocument}function Fa(t,e){return null!=t?t:e}function za(t,e,r){return null!=t?t:null!=e?e:r}function ka(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return pa.apply(t,e)}function Ga(t){if("number"==typeof t)return[t,t,t,t];var e=t.length;return 2===e?[t[0],t[1],t[0],t[1]]:3===e?[t[0],t[1],t[2],t[1]]:t}function Ua(t){return null==t?null:"function"==typeof t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}va.createCanvas=function(){return document.createElement("canvas")},_a&&"function"==typeof _a.bind&&_a.call.bind(_a.bind);function Ha(t){return t.__ec_primitive__}var Va=function(){function t(e){this.data={};var r=Oa(e);this.data={};var i=this;function n(t,e){r?i.set(t,e):i.set(e,t)}e instanceof t?e.each(n):e&&Ea(e,n)}return t.prototype.get=function(t){return this.data.hasOwnProperty(t)?this.data[t]:null},t.prototype.set=function(t,e){return this.data[t]=e},t.prototype.each=function(t,e){for(var r in this.data)this.data.hasOwnProperty(r)&&t.call(e,this.data[r],r)},t.prototype.keys=function(){return La(this.data)},t.prototype.removeKey=function(t){delete this.data[t]},t}();function Wa(t,e){for(var r=new t.constructor(t.length+e.length),i=0;i<t.length;i++)r[i]=t[i];var n=t.length;for(i=0;i<e.length;i++)r[i+n]=e[i];return r}function ja(t,e){var r;if(Object.create)r=Object.create(t);else{var i=function(){};i.prototype=t,r=new i}return e&&Ta(r,e),r}var Xa=Array.prototype.slice;function qa(t,e,r){return(e-t)*r+t}function Za(t,e,r,i){for(var n=e.length,a=0;a<n;a++)t[a]=qa(e[a],r[a],i)}function Ya(t,e,r,i){for(var n=e.length,a=0;a<n;a++)t[a]=e[a]+r[a]*i;return t}function Ka(t,e,r,i){for(var n=e.length,a=n&&e[0].length,o=0;o<n;o++){t[o]||(t[o]=[]);for(var s=0;s<a;s++)t[o][s]=e[o][s]+r[o][s]*i}return t}function Qa(t,e,r){var i=t,n=e;if(i.push&&n.push){var a=i.length,o=n.length;if(a!==o)if(a>o)i.length=o;else for(var s=a;s<o;s++)i.push(1===r?n[s]:Xa.call(n[s]));var l=i[0]&&i[0].length;for(s=0;s<i.length;s++)if(1===r)isNaN(i[s])&&(i[s]=n[s]);else for(var h=0;h<l;h++)isNaN(i[s][h])&&(i[s][h]=n[s][h])}}function Ja(t,e){var r=t.length;if(r!==e.length)return!1;for(var i=0;i<r;i++)if(t[i]!==e[i])return!1;return!0}function $a(t,e,r,i,n,a,o){var s=.5*(r-t),l=.5*(i-e);return(2*(e-r)+s+l)*o+(-3*(e-r)-2*s-l)*a+s*n+e}function to(t,e,r,i,n,a,o,s){for(var l=e.length,h=0;h<l;h++)t[h]=$a(e[h],r[h],i[h],n[h],a,o,s)}function eo(t){if(Ca(t)){var e=t.length;if(Ca(t[0])){for(var r=[],i=0;i<e;i++)r.push(Xa.call(t[i]));return r}return Xa.call(t)}return t}function ro(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.floor(t[2]),"rgba("+t.join(",")+")"}var io=[0,0,0,0],no=function(){function t(t){this.keyframes=[],this.maxTime=0,this.arrDim=0,this.interpolable=!0,this._needsSort=!1,this._isAllValueEqual=!0,this._lastFrame=0,this._lastFramePercent=0,this.propName=t}return t.prototype.isFinished=function(){return this._finished},t.prototype.setFinished=function(){this._finished=!0,this._additiveTrack&&this._additiveTrack.setFinished()},t.prototype.needsAnimate=function(){return!this._isAllValueEqual&&this.keyframes.length>=2&&this.interpolable},t.prototype.getAdditiveTrack=function(){return this._additiveTrack},t.prototype.addKeyframe=function(t,e){t>=this.maxTime?this.maxTime=t:this._needsSort=!0;var r=this.keyframes,i=r.length;if(this.interpolable)if(Ca(e)){var n=function(t){return Ca(t&&t[0])?2:1}(e);if(i>0&&this.arrDim!==n)return void(this.interpolable=!1);if(1===n&&"number"!=typeof e[0]||2===n&&"number"!=typeof e[0][0])return void(this.interpolable=!1);if(i>0){var a=r[i-1];this._isAllValueEqual&&(1===n&&Ja(e,a.value)||(this._isAllValueEqual=!1))}this.arrDim=n}else{if(this.arrDim>0)return void(this.interpolable=!1);if("string"==typeof e){var o=aa(e);o?(e=o,this.isValueColor=!0):this.interpolable=!1}else if("number"!=typeof e)return void(this.interpolable=!1);this._isAllValueEqual&&i>0&&(a=r[i-1],(this.isValueColor&&!Ja(a.value,e)||a.value!==e)&&(this._isAllValueEqual=!1))}var s={time:t,value:e,percent:0};return this.keyframes.push(s),s},t.prototype.prepare=function(t){var e=this.keyframes;this._needsSort&&e.sort((function(t,e){return t.time-e.time}));for(var r=this.arrDim,i=e.length,n=e[i-1],a=0;a<i;a++)e[a].percent=e[a].time/this.maxTime,r>0&&a!==i-1&&Qa(e[a].value,n.value,r);if(t&&this.needsAnimate()&&t.needsAnimate()&&r===t.arrDim&&this.isValueColor===t.isValueColor&&!t._finished){this._additiveTrack=t;var o=e[0].value;for(a=0;a<i;a++)0===r?this.isValueColor?e[a].additiveValue=Ya([],e[a].value,o,-1):e[a].additiveValue=e[a].value-o:1===r?e[a].additiveValue=Ya([],e[a].value,o,-1):2===r&&(e[a].additiveValue=Ka([],e[a].value,o,-1))}},t.prototype.step=function(t,e){if(!this._finished){this._additiveTrack&&this._additiveTrack._finished&&(this._additiveTrack=null);var r,i=null!=this._additiveTrack,n=i?"additiveValue":"value",a=this.keyframes,o=this.keyframes.length,s=this.propName,l=this.arrDim,h=this.isValueColor;if(e<0)r=0;else if(e<this._lastFramePercent){for(r=Math.min(this._lastFrame+1,o-1);r>=0&&!(a[r].percent<=e);r--);r=Math.min(r,o-2)}else{for(r=this._lastFrame;r<o&&!(a[r].percent>e);r++);r=Math.min(r-1,o-2)}var u=a[r+1],c=a[r];if(c&&u){this._lastFrame=r,this._lastFramePercent=e;var d=u.percent-c.percent;if(0!==d){var f=(e-c.percent)/d,p=i?this._additiveValue:h?io:t[s];if((l>0||h)&&!p&&(p=this._additiveValue=[]),this.useSpline){var m=a[r][n],g=a[0===r?r:r-1][n],_=a[r>o-2?o-1:r+1][n],v=a[r>o-3?o-1:r+2][n];if(l>0)1===l?to(p,g,m,_,v,f,f*f,f*f*f):function(t,e,r,i,n,a,o,s){for(var l=e.length,h=e[0].length,u=0;u<l;u++){t[u]||(t[1]=[]);for(var c=0;c<h;c++)t[u][c]=$a(e[u][c],r[u][c],i[u][c],n[u][c],a,o,s)}}(p,g,m,_,v,f,f*f,f*f*f);else if(h)to(p,g,m,_,v,f,f*f,f*f*f),i||(t[s]=ro(p));else{var y=void 0;y=this.interpolable?$a(g,m,_,v,f,f*f,f*f*f):_,i?this._additiveValue=y:t[s]=y}}else l>0?1===l?Za(p,c[n],u[n],f):function(t,e,r,i){for(var n=e.length,a=n&&e[0].length,o=0;o<n;o++){t[o]||(t[o]=[]);for(var s=0;s<a;s++)t[o][s]=qa(e[o][s],r[o][s],i)}}(p,c[n],u[n],f):h?(Za(p,c[n],u[n],f),i||(t[s]=ro(p))):(y=void 0,y=this.interpolable?qa(c[n],u[n],f):function(t,e,r){return r>.5?e:t}(c[n],u[n],f),i?this._additiveValue=y:t[s]=y);i&&this._addToTarget(t)}}}},t.prototype._addToTarget=function(t){var e=this.arrDim,r=this.propName,i=this._additiveValue;0===e?this.isValueColor?(aa(t[r],io),Ya(io,io,i,1),t[r]=ro(io)):t[r]=t[r]+i:1===e?Ya(t[r],t[r],i,1):2===e&&Ka(t[r],t[r],i,1)},t}();const ao=function(){function t(t,e,r){this._tracks={},this._trackKeys=[],this._delay=0,this._maxTime=0,this._paused=!1,this._started=0,this._clip=null,this._target=t,this._loop=e,e&&r?xa("Can' use additive animation on looped animation."):this._additiveAnimators=r}return t.prototype.getTarget=function(){return this._target},t.prototype.changeTarget=function(t){this._target=t},t.prototype.when=function(t,e){return this.whenWithKeys(t,e,La(e))},t.prototype.whenWithKeys=function(t,e,r){for(var i=this._tracks,n=0;n<r.length;n++){var a=r[n],o=i[a];if(!o){o=i[a]=new no(a);var s=void 0,l=this._getAdditiveTrack(a);if(l){var h=l.keyframes[l.keyframes.length-1];s=h&&h.value,l.isValueColor&&s&&(s=ro(s))}else s=this._target[a];if(null==s)continue;0!==t&&o.addKeyframe(0,eo(s)),this._trackKeys.push(a)}o.addKeyframe(t,eo(e[a]))}return this._maxTime=Math.max(this._maxTime,t),this},t.prototype.pause=function(){this._clip.pause(),this._paused=!0},t.prototype.resume=function(){this._clip.resume(),this._paused=!1},t.prototype.isPaused=function(){return!!this._paused},t.prototype._doneCallback=function(){this._setTracksFinished(),this._clip=null;var t=this._doneList;if(t)for(var e=t.length,r=0;r<e;r++)t[r].call(this)},t.prototype._abortedCallback=function(){this._setTracksFinished();var t=this.animation,e=this._abortedList;if(t&&t.removeClip(this._clip),this._clip=null,e)for(var r=0;r<e.length;r++)e[r].call(this)},t.prototype._setTracksFinished=function(){for(var t=this._tracks,e=this._trackKeys,r=0;r<e.length;r++)t[e[r]].setFinished()},t.prototype._getAdditiveTrack=function(t){var e,r=this._additiveAnimators;if(r)for(var i=0;i<r.length;i++){var n=r[i].getTrack(t);n&&(e=n)}return e},t.prototype.start=function(t,e){if(!(this._started>0)){this._started=1;for(var r=this,i=[],n=0;n<this._trackKeys.length;n++){var a=this._trackKeys[n],o=this._tracks[a],s=this._getAdditiveTrack(a),l=o.keyframes;if(o.prepare(s),o.needsAnimate())i.push(o);else if(!o.interpolable){var h=l[l.length-1];h&&(r._target[o.propName]=h.value)}}if(i.length||e){var u=new qn({life:this._maxTime,loop:this._loop,delay:this._delay,onframe:function(t){r._started=2;var e=r._additiveAnimators;if(e){for(var n=!1,a=0;a<e.length;a++)if(e[a]._clip){n=!0;break}n||(r._additiveAnimators=null)}for(a=0;a<i.length;a++)i[a].step(r._target,t);var o=r._onframeList;if(o)for(a=0;a<o.length;a++)o[a](r._target,t)},ondestroy:function(){r._doneCallback()}});this._clip=u,this.animation&&this.animation.addClip(u),t&&"spline"!==t&&(u.easing=t)}else this._doneCallback();return this}},t.prototype.stop=function(t){if(this._clip){var e=this._clip;t&&e.onframe(1),this._abortedCallback()}},t.prototype.delay=function(t){return this._delay=t,this},t.prototype.during=function(t){return t&&(this._onframeList||(this._onframeList=[]),this._onframeList.push(t)),this},t.prototype.done=function(t){return t&&(this._doneList||(this._doneList=[]),this._doneList.push(t)),this},t.prototype.aborted=function(t){return t&&(this._abortedList||(this._abortedList=[]),this._abortedList.push(t)),this},t.prototype.getClip=function(){return this._clip},t.prototype.getTrack=function(t){return this._tracks[t]},t.prototype.stopTracks=function(t,e){if(!t.length||!this._clip)return!0;for(var r=this._tracks,i=this._trackKeys,n=0;n<t.length;n++){var a=r[t[n]];a&&(e?a.step(this._target,1):1===this._started&&a.step(this._target,0),a.setFinished())}var o=!0;for(n=0;n<i.length;n++)if(!r[i[n]].isFinished()){o=!1;break}return o&&this._abortedCallback(),o},t.prototype.saveFinalToTarget=function(t,e){if(t){e=e||this._trackKeys;for(var r=0;r<e.length;r++){var i=e[r],n=this._tracks[i];if(n&&!n.isFinished()){var a=n.keyframes,o=a[a.length-1];if(o){var s=eo(o.value);n.isValueColor&&(s=ro(s)),t[i]=s}}}}},t.prototype.__changeFinalValue=function(t,e){e=e||La(t);for(var r=0;r<e.length;r++){var i=e[r],n=this._tracks[i];if(n){var a=n.keyframes;if(a.length>1){var o=a.pop();n.addKeyframe(o.time,t[i]),n.prepare(n.getAdditiveTrack())}}}},t}(),oo={_animators:null,getAnimators:function(){return this._animators=this._animators||[],this._animators},animate:function(t,e){var r;if(this._animators=this._animators||[],t){for(var i=t.split("."),n=this,a=0,o=i.length;a<o;a++)n&&(n=n[i[a]]);n&&(r=n)}else r=this;if(null==r)throw new Error("Target "+t+" not exists");var s=this._animators,l=new ao(r,e),h=this;return l.during((function(){h.__zr&&h.__zr.refresh()})).done((function(){var t=s.indexOf(l);t>=0&&s.splice(t,1)})),s.push(l),this.__zr&&this.__zr.animation.addAnimator(l),l},stopAnimation:function(t){this._animators=this._animators||[];for(var e=this._animators,r=e.length,i=0;i<r;i++)e[i].stop(t);return e.length=0,this},addAnimatorsToZr:function(t){if(this._animators)for(var e=0;e<this._animators.length;e++)t.animation.addAnimator(this._animators[e])},removeAnimatorsFromZr:function(t){if(this._animators)for(var e=0;e<this._animators.length;e++)t.animation.removeAnimator(this._animators[e])}};function so(t){return t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof Image}Object.assign(or.prototype,oo),Xt.import("\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return 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.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return 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.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.chunk.instancing_header\n#ifdef INSTANCING\nattribute vec4 instanceMat1;\nattribute vec4 instanceMat2;\nattribute vec4 instanceMat3;\n#endif\n@end\n@export clay.chunk.instancing_matrix\nmat4 instanceMat = mat4(\n vec4(instanceMat1.xyz, 0.0),\n vec4(instanceMat2.xyz, 0.0),\n vec4(instanceMat3.xyz, 0.0),\n vec4(instanceMat1.w, instanceMat2.w, instanceMat3.w, 1.0)\n);\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end"),Xt.import(qt),Xt.import("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"),Xt.import("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\nattribute vec3 normal: NORMAL;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nvarying vec3 v_Normal;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef ATMOSPHERE_ENABLED\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\nvarying vec3 v_Normal;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"),Xt.import("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),Xt.import("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef ATMOSPHERE_ENABLED\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform vec3 glowColor;\nuniform float glowPower;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef ATMOSPHERE_ENABLED\n float atmoIntensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor.rgb += glowColor * atmoIntensity;\n#endif\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"),Xt.import("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"),Xt.import("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");var lo=_i.prototype.addToScene,ho=_i.prototype.removeFromScene;_i.prototype.addToScene=function(t){if(lo.call(this,t),this.__zr){var e=this.__zr;t.traverse((function(t){t.__zr=e,t.addAnimatorsToZr&&t.addAnimatorsToZr(e)}))}},_i.prototype.removeFromScene=function(t){ho.call(this,t),t.traverse((function(t){var e=t.__zr;t.__zr=null,e&&t.removeAnimatorsFromZr&&t.removeAnimatorsFromZr(e)}))},lt.prototype.setTextureImage=function(t,e,r,i){if(this.shader){var n,a=r.getZr(),o=this;return o.autoUpdateTextureStatus=!1,o.disableTexture(t),!(s=e)||"none"===s||(n=uo.loadTexture(e,r,i,(function(e){o.enableTexture(t),a&&a.refresh()})),o.set(t,n)),n}var s};var uo={};uo.Renderer=ue,uo.Node=or,uo.Mesh=Tr,uo.Shader=Xt,uo.Material=lt,uo.Texture=br,uo.Texture2D=Er,uo.Geometry=Ur,uo.SphereGeometry=An,uo.PlaneGeometry=Gi,uo.CubeGeometry=Vi,uo.AmbientLight=Cn,uo.DirectionalLight=En,uo.PointLight=Dn,uo.SpotLight=Ln,uo.PerspectiveCamera=Ai,uo.OrthographicCamera=hn,uo.Vector2=_t,uo.Vector3=ve,uo.Vector4=In,uo.Quaternion=qe,uo.Matrix2=zn,uo.Matrix2d=Hn,uo.Matrix3=Wn,uo.Matrix4=Ve,uo.Plane=Jr,uo.Ray=Me,uo.BoundingBox=ir,uo.Frustum=oi;var co=nn.createBlank("rgba(255,255,255,0)").image;function fo(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function po(t){if((t.wrapS===br.REPEAT||t.wrapT===br.REPEAT)&&t.image){var e=fo(t.width),r=fo(t.height);if(e!==t.width||r!==t.height){var i=document.createElement("canvas");i.width=e,i.height=r,i.getContext("2d").drawImage(t.image,0,0,e,r),t.image=i}}}uo.loadTexture=function(t,e,r,i){"function"==typeof r&&(i=r,r={}),r=r||{};for(var n=Object.keys(r).sort(),a="",o=0;o<n.length;o++)a+=n[o]+"_"+r[n[o]]+"_";var s,l=e.__textureCache=e.__textureCache||new xi(20);if((s=t).getZr&&s.setOption){var h=t.__textureid__;if(c=l.get(a+h))c.texture.surface.setECharts(t),i&&i(c.texture);else{var u=new ln(t);for(u.onupdate=function(){e.getZr().refresh()},c={texture:u.getTexture()},o=0;o<n.length;o++)c.texture[n[o]]=r[n[o]];h=t.__textureid__||"__ecgl_ec__"+c.texture.__uid__,t.__textureid__=h,l.put(a+h,c),i&&i(c.texture)}return c.texture}if(so(t)){var c;if(h=t.__textureid__,!(c=l.get(a+h))){for(c={texture:new uo.Texture2D({image:t})},o=0;o<n.length;o++)c.texture[n[o]]=r[n[o]];h=t.__textureid__||"__ecgl_image__"+c.texture.__uid__,t.__textureid__=h,l.put(a+h,c),po(c.texture),i&&i(c.texture)}return c.texture}if(c=l.get(a+t))c.callbacks?c.callbacks.push(i):i&&i(c.texture);else if(t.match(/.hdr$|^data:application\/octet-stream/)){c={callbacks:[i]};var d=nn.loadTexture(t,{exposure:r.exposure,fileType:"hdr"},(function(){d.dirty(),c.callbacks.forEach((function(t){t&&t(d)})),c.callbacks=null}));c.texture=d,l.put(a+t,c)}else{for(d=new uo.Texture2D({image:new Image}),o=0;o<n.length;o++)d[n[o]]=r[n[o]];c={texture:d,callbacks:[i]};var f=d.image;f.onload=function(){d.image=f,po(d),d.dirty(),c.callbacks.forEach((function(t){t&&t(d)})),c.callbacks=null},f.src=t,d.image=co,l.put(a+t,c)}return c.texture},uo.createAmbientCubemap=function(t,e,r,i){var n=(t=t||{}).texture,a=Sn(t.exposure,1),o=new _n({intensity:Sn(t.specularIntensity,1)}),s=new vn({intensity:Sn(t.diffuseIntensity,1),coefficients:[.844,.712,.691,-.037,.083,.167,.343,.288,.299,-.041,-.021,-.009,-.003,-.041,-.064,-.011,-.007,-.004,-.031,.034,.081,-.06,-.049,-.06,.046,.056,.05]});return o.cubemap=uo.loadTexture(n,r,{exposure:a},(function(){o.cubemap.flipY=!1,o.prefilter(e,32),s.coefficients=Tn.projectEnvironmentMap(e,o.cubemap,{lod:1}),i&&i()})),{specular:o,diffuse:s}},uo.createBlankTexture=nn.createBlank,uo.isImage=so,uo.additiveBlend=function(t){t.blendEquation(t.FUNC_ADD),t.blendFunc(t.SRC_ALPHA,t.ONE)},uo.parseColor=function(t,e){return t instanceof Array?(e||(e=[]),e[0]=t[0],e[1]=t[1],e[2]=t[2],t.length>3?e[3]=t[3]:e[3]=1,e):((e=i.color.parse(t||"#000",e)||[0,0,0,0])[0]/=255,e[1]/=255,e[2]/=255,e)},uo.directionFromAlphaBeta=function(t,e){var r=t/180*Math.PI+Math.PI/2,i=-e/180*Math.PI+Math.PI/2,n=[],a=Math.sin(r);return n[0]=a*Math.cos(i),n[1]=-Math.cos(r),n[2]=a*Math.sin(i),n},uo.getShadowResolution=function(t){var e=1024;switch(t){case"low":e=512;break;case"medium":break;case"high":e=2048;break;case"ultra":e=4096}return e},uo.COMMON_SHADERS=["lambert","color","realistic","hatching","shadow"],uo.createShader=function(t){"ecgl.shadow"===t&&(t="ecgl.displayShadow");var e=Xt.source(t+".vertex"),r=Xt.source(t+".fragment");e||console.error("Vertex shader of '%s' not exits",t),r||console.error("Fragment shader of '%s' not exits",t);var i=new Xt(e,r);return i.name=t,i},uo.createMaterial=function(t,e){e instanceof Array||(e=[e]);var r=uo.createShader(t),i=new lt({shader:r});return e.forEach((function(t){"string"==typeof t&&i.define(t)})),i},uo.setMaterialFromModel=function(t,e,r,i){e.autoUpdateTextureStatus=!1;var n=r.getModel(t+"Material"),a=n.get("detailTexture"),o=Sn(n.get("textureTiling"),1),s=Sn(n.get("textureOffset"),0);"number"==typeof o&&(o=[o,o]),"number"==typeof s&&(s=[s,s]);var l=o[0]>1||o[1]>1?uo.Texture.REPEAT:uo.Texture.CLAMP_TO_EDGE,h={anisotropic:8,wrapS:l,wrapT:l};if("realistic"===t){var u=n.get("roughness"),c=n.get("metalness");null!=c?isNaN(c)&&(e.setTextureImage("metalnessMap",c,i,h),c=Sn(n.get("metalnessAdjust"),.5)):c=0,null!=u?isNaN(u)&&(e.setTextureImage("roughnessMap",u,i,h),u=Sn(n.get("roughnessAdjust"),.5)):u=.5;var d=n.get("normalTexture");e.setTextureImage("detailMap",a,i,h),e.setTextureImage("normalMap",d,i,h),e.set({roughness:u,metalness:c,detailUvRepeat:o,detailUvOffset:s})}else if("lambert"===t)e.setTextureImage("detailMap",a,i,h),e.set({detailUvRepeat:o,detailUvOffset:s});else if("color"===t)e.setTextureImage("detailMap",a,i,h),e.set({detailUvRepeat:o,detailUvOffset:s});else if("hatching"===t){var f=n.get("hatchingTextures")||[];f.length;for(var p=0;p<6;p++)e.setTextureImage("hatch"+(p+1),f[p],i,{anisotropic:8,wrapS:uo.Texture.REPEAT,wrapT:uo.Texture.REPEAT});e.set({detailUvRepeat:o,detailUvOffset:s})}},uo.updateVertexAnimation=function(t,e,r,i){var n=i.get("animation"),a=i.get("animationDurationUpdate"),o=i.get("animationEasingUpdate"),s=r.shadowDepthMaterial;if(n&&e&&a>0&&e.geometry.vertexCount===r.geometry.vertexCount){r.material.define("vertex","VERTEX_ANIMATION"),r.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var l=0;l<t.length;l++)r.geometry.attributes[t[l][0]].value=e.geometry.attributes[t[l][1]].value;r.geometry.dirty(),r.__percent=0,r.material.set("percent",0),r.stopAnimation(),r.animate().when(a,{__percent:1}).during((function(){r.material.set("percent",r.__percent),s&&s.set("percent",r.__percent)})).done((function(){r.ignorePreZ=!1,r.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")})).start(o)}else r.material.undefine("vertex","VERTEX_ANIMATION"),s&&s.undefine("vertex","VERTEX_ANIMATION")};const mo=uo,go="undefined"!=typeof window&&(window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.msRequestAnimationFrame&&window.msRequestAnimationFrame.bind(window)||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(t){return setTimeout(t,16)};var _o=function(t,e){this.id=t,this.zr=e;try{this.renderer=new ue({clearBit:0,devicePixelRatio:e.painter.dpr,preserveDrawingBuffer:!0,premultipliedAlpha:!0}),this.renderer.resize(e.painter.getWidth(),e.painter.getHeight())}catch(t){return this.renderer=null,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute; left: 0; top: 0; right: 0; bottom: 0;",this.dom.className="ecgl-nowebgl",this.dom.innerHTML="Sorry, your browser does not support WebGL",void console.error(t)}this.onglobalout=this.onglobalout.bind(this),e.on("globalout",this.onglobalout),this.dom=this.renderer.canvas;var r=this.dom.style;r.position="absolute",r.left="0",r.top="0",this.views=[],this._picking=new gr({renderer:this.renderer}),this._viewsToDispose=[],this._accumulatingId=0,this._zrEventProxy=new i.graphic.Rect({shape:{x:-1,y:-1,width:2,height:2},__isGLToZRProxy:!0}),this._backgroundColor=null};function vo(t){var e=t.__zr;t.__zr=null,e&&t.removeAnimatorsFromZr&&t.removeAnimatorsFromZr(e)}_o.prototype.setUnpainted=function(){},_o.prototype.addView=function(t){if(t.layer!==this){var e=this._viewsToDispose.indexOf(t);e>=0&&this._viewsToDispose.splice(e,1),this.views.push(t),t.layer=this;var r=this.zr;t.scene.traverse((function(t){t.__zr=r,t.addAnimatorsToZr&&t.addAnimatorsToZr(r)}))}},_o.prototype.removeView=function(t){if(t.layer===this){var e=this.views.indexOf(t);e>=0&&(this.views.splice(e,1),t.scene.traverse(vo,this),t.layer=null,this._viewsToDispose.push(t))}},_o.prototype.removeViewsAll=function(){this.views.forEach((function(t){t.scene.traverse(vo,this),t.layer=null,this._viewsToDispose.push(t)}),this),this.views.length=0},_o.prototype.resize=function(t,e){this.renderer.resize(t,e)},_o.prototype.clear=function(){var t=this.renderer.gl,e=this._backgroundColor||[0,0,0,0];t.clearColor(e[0],e[1],e[2],e[3]),t.depthMask(!0),t.colorMask(!0,!0,!0,!0),t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT)},_o.prototype.clearDepth=function(){var t=this.renderer.gl;t.clear(t.DEPTH_BUFFER_BIT)},_o.prototype.clearColor=function(){var t=this.renderer.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)},_o.prototype.needsRefresh=function(){this.zr.refresh()},_o.prototype.refresh=function(t){this._backgroundColor=t?mo.parseColor(t):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var e=0;e<this.views.length;e++)this.views[e].prepareRender(this.renderer);for(this._doRender(!1),this._trackAndClean(),e=0;e<this._viewsToDispose.length;e++)this._viewsToDispose[e].dispose(this.renderer);this._viewsToDispose.length=0,this._startAccumulating()},_o.prototype.renderToCanvas=function(t){this._startAccumulating(!0),t.drawImage(this.dom,0,0,t.canvas.width,t.canvas.height)},_o.prototype._doRender=function(t){this.clear(),this.renderer.saveViewport();for(var e=0;e<this.views.length;e++)this.views[e].render(this.renderer,t);this.renderer.restoreViewport()},_o.prototype._stopAccumulating=function(){this._accumulatingId=0,clearTimeout(this._accumulatingTimeout)};var yo=1;function xo(t){for(var e=0;e<t.length;e++)t[e].__used__=0}function bo(t,e){for(var r=0;r<e.length;r++)e[r].__used__||e[r].dispose(t)}function wo(t,e){t.__used__=t.__used__||0,t.__used__++,1===t.__used__&&e.push(t)}function To(t,e,r){var i,n;t.traverse((function(t){if(t.isRenderable()){var a=t.geometry,o=t.material;if(o!==i)for(var s=o.getTextureUniforms(),l=0;l<s.length;l++){var h=s[l],u=o.uniforms[h].value;if(u)if(u instanceof br)wo(u,e);else if(u instanceof Array)for(var c=0;c<u.length;c++)u[c]instanceof br&&wo(u[c],e)}a!==n&&wo(a,r),i=o,n=a}}));for(var a=0;a<t.lights.length;a++)t.lights[a].cubemap&&wo(t.lights[a].cubemap,e)}_o.prototype._startAccumulating=function(t){var e=this;this._stopAccumulating();for(var r=!1,i=0;i<this.views.length;i++)r=this.views[i].needsAccumulate()||r;function n(i){if(e._accumulatingId&&i===e._accumulatingId){for(var a=!0,o=0;o<e.views.length;o++)a=e.views[o].isAccumulateFinished()&&r;a||(e._doRender(!0),t?n(i):go((function(){n(i)})))}}r&&(this._accumulatingId=yo++,t?n(e._accumulatingId):this._accumulatingTimeout=setTimeout((function(){n(e._accumulatingId)}),50))},_o.prototype._trackAndClean=function(){var t=[],e=[];this._textureList&&(xo(this._textureList),xo(this._geometriesList));for(var r=0;r<this.views.length;r++)To(this.views[r].scene,t,e);this._textureList&&(bo(this.renderer,this._textureList),bo(this.renderer,this._geometriesList)),this._textureList=t,this._geometriesList=e},_o.prototype.dispose=function(){this._stopAccumulating(),this.renderer.disposeScene(this.scene),this.zr.off("globalout",this.onglobalout)},_o.prototype.onmousedown=function(t){if(!t.target||!t.target.__isGLToZRProxy){t=t.event;var e=this.pickObject(t.offsetX,t.offsetY);e&&(this._dispatchEvent("mousedown",t,e),this._dispatchDataEvent("mousedown",t,e)),this._downX=t.offsetX,this._downY=t.offsetY}},_o.prototype.onmousemove=function(t){if(!t.target||!t.target.__isGLToZRProxy){t=t.event;var e=this.pickObject(t.offsetX,t.offsetY),r=e&&e.target,i=this._hovered;this._hovered=e,i&&r!==i.target&&(i.relatedTarget=r,this._dispatchEvent("mouseout",t,i),this.zr.setCursorStyle("default")),this._dispatchEvent("mousemove",t,e),e&&(this.zr.setCursorStyle("pointer"),i&&r===i.target||this._dispatchEvent("mouseover",t,e)),this._dispatchDataEvent("mousemove",t,e)}},_o.prototype.onmouseup=function(t){if(!t.target||!t.target.__isGLToZRProxy){t=t.event;var e=this.pickObject(t.offsetX,t.offsetY);e&&(this._dispatchEvent("mouseup",t,e),this._dispatchDataEvent("mouseup",t,e)),this._upX=t.offsetX,this._upY=t.offsetY}},_o.prototype.onclick=_o.prototype.dblclick=function(t){if(!t.target||!t.target.__isGLToZRProxy){var e=this._upX-this._downX,r=this._upY-this._downY;if(!(Math.sqrt(e*e+r*r)>20)){t=t.event;var i=this.pickObject(t.offsetX,t.offsetY);i&&(this._dispatchEvent(t.type,t,i),this._dispatchDataEvent(t.type,t,i));var n=this._clickToSetFocusPoint(t);n&&n.view.setDOFFocusOnPoint(n.distance)&&this.zr.refresh()}}},_o.prototype._clickToSetFocusPoint=function(t){for(var e=this.renderer,r=e.viewport,i=this.views.length-1;i>=0;i--){var n=this.views[i];if(n.hasDOF()&&n.containPoint(t.offsetX,t.offsetY)){this._picking.scene=n.scene,this._picking.camera=n.camera,e.viewport=n.viewport;var a=this._picking.pick(t.offsetX,t.offsetY,!0);if(a)return a.view=n,a}}e.viewport=r},_o.prototype.onglobalout=function(t){var e=this._hovered;e&&this._dispatchEvent("mouseout",t,{target:e.target})},_o.prototype.pickObject=function(t,e){for(var r=[],i=this.renderer,n=i.viewport,a=0;a<this.views.length;a++){var o=this.views[a];o.containPoint(t,e)&&(this._picking.scene=o.scene,this._picking.camera=o.camera,i.viewport=o.viewport,this._picking.pickAll(t,e,r))}return i.viewport=n,r.sort((function(t,e){return t.distance-e.distance})),r[0]},_o.prototype._dispatchEvent=function(t,e,r){r||(r={});var i=r.target;for(r.cancelBubble=!1,r.event=e,r.type=t,r.offsetX=e.offsetX,r.offsetY=e.offsetY;i&&(i.trigger(t,r),i=i.getParent(),!r.cancelBubble););this._dispatchToView(t,r)},_o.prototype._dispatchDataEvent=function(t,e,r){var n=r&&r.target,a=n&&n.dataIndex,o=n&&n.seriesIndex,s=n&&n.eventData,l=!1,h=this._zrEventProxy;h.x=e.offsetX,h.y=e.offsetY,h.update();var u={target:h};const c=i.helper.getECData(h);"mousemove"===t&&(null!=a?a!==this._lastDataIndex&&(parseInt(this._lastDataIndex,10)>=0&&(c.dataIndex=this._lastDataIndex,c.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(u,"mouseout",e)),l=!0):null!=s&&s!==this._lastEventData&&(null!=this._lastEventData&&(c.eventData=this._lastEventData,this.zr.handler.dispatchToElement(u,"mouseout",e)),l=!0),this._lastEventData=s,this._lastDataIndex=a,this._lastSeriesIndex=o),c.eventData=s,c.dataIndex=a,c.seriesIndex=o,(null!=s||parseInt(a,10)>=0&&parseInt(o,10)>=0)&&(this.zr.handler.dispatchToElement(u,t,e),l&&this.zr.handler.dispatchToElement(u,"mouseover",e))},_o.prototype._dispatchToView=function(t,e){for(var r=0;r<this.views.length;r++)this.views[r].containPoint(e.offsetX,e.offsetY)&&this.views[r].trigger(t,e)},Object.assign(_o.prototype,h);const So=_o;var Mo=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];function Ao(t,e){if(t&&t[e]&&(t[e].normal||t[e].emphasis)){var r=t[e].normal,i=t[e].emphasis;r&&(t[e]=r),i&&(t.emphasis=t.emphasis||{},t.emphasis[e]=i)}}function Co(t){t&&(t instanceof Array||(t=[t]),i.util.each(t,(function(t){if(t.axisLabel){var e=t.axisLabel;Object.assign(e,e.textStyle),e.textStyle=null}})))}function Eo(t){this._layers={},this._zr=t}Eo.prototype.update=function(t,e){var r=this,n=e.getZr();if(n.getWidth()&&n.getHeight()){for(var a in this._layers)this._layers[a].removeViewsAll();t.eachComponent((function(r,i){if("series"!==r){var n=e.getViewOfComponentModel(i),a=i.coordinateSystem;if(n.__ecgl__){if(a){if(!a.viewGL)return void console.error("Can't find viewGL in coordinateSystem of component "+i.id);l=a.viewGL}else{if(!i.viewGL)return void console.error("Can't find viewGL of component "+i.id);l=a.viewGL}var l=a.viewGL,h=o(i);h.addView(l),n.afterRender&&n.afterRender(i,t,e,h),s(n.groupGL,i.get("silent"))}}})),t.eachSeries((function(r){var i=e.getViewOfSeriesModel(r),n=r.coordinateSystem;if(i.__ecgl__){if(n&&!n.viewGL&&!i.viewGL)return void console.error("Can't find viewGL of series "+i.id);var a=n&&n.viewGL||i.viewGL,l=o(r);l.addView(a),i.afterRender&&i.afterRender(r,t,e,l),s(i.groupGL,r.get("silent"))}}))}else console.warn("Dom has no width or height");function o(t){var e;n.setSleepAfterStill(0),t.coordinateSystem&&t.coordinateSystem.model,e=t.get("zlevel");var a=r._layers,o=a[e];if(!o){if(o=a[e]=new So("gl-"+e,n),n.painter.isSingleCanvas()){o.virtual=!0;var s=new i.graphic.Image({z:1e4,style:{image:o.renderer.canvas},silent:!0});o.__hostImage=s,n.add(s)}n.painter.insertLayer(e,o)}return o.__hostImage&&o.__hostImage.setStyle({width:o.renderer.getWidth(),height:o.renderer.getHeight()}),o}function s(t,e){t&&t.traverse((function(t){t.isRenderable&&t.isRenderable()&&(t.ignorePicking=null!=t.$ignorePicking?t.$ignorePicking:e)}))}},i.registerPostInit((function(t){t.getZr().painter.getRenderedCanvas=function(t){if(t=t||{},this._singleCanvas)return this._layers[0].dom;var e=document.createElement("canvas"),r=t.pixelRatio||this.dpr;e.width=this.getWidth()*r,e.height=this.getHeight()*r;var i=e.getContext("2d");i.dpr=r,i.clearRect(0,0,e.width,e.height),t.backgroundColor&&(i.fillStyle=t.backgroundColor,i.fillRect(0,0,e.width,e.height));var n,a=this.storage.getDisplayList(!0),o={},s=this;function l(t,e){var r,n=s._zlevelList;null==t&&(t=-1/0);for(var a=0;a<n.length;a++){var o=n[a],l=s._layers[o];if(!l.__builtin__&&o>t&&o<e){r=l;break}}r&&r.renderToCanvas&&(i.save(),r.renderToCanvas(i),i.restore())}for(var h={ctx:i},u=0;u<a.length;u++){var c=a[u];c.zlevel!==n&&(l(n,c.zlevel),n=c.zlevel),this._doPaintEl(c,h,!0,o)}return l(n,1/0),e}})),i.registerPostUpdate((function(t,e){var r=e.getZr();(r.__egl=r.__egl||new Eo(r)).update(t,e)})),i.registerPreprocessor((function(t){i.util.each(t.series,(function(e){i.util.indexOf(Mo,e.type)>=0&&(function(t){Ao(t,"itemStyle"),Ao(t,"lineStyle"),Ao(t,"areaStyle"),Ao(t,"label")}(e),"mapbox"===e.coordinateSystem&&(e.coordinateSystem="mapbox3D",t.mapbox3D=t.mapbox))})),Co(t.xAxis3D),Co(t.yAxis3D),Co(t.zAxis3D),Co(t.grid3D),Ao(t.geo3D)}));var Do={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},Lo=i.util.merge({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},Do),Po=i.util.merge({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},Do),Oo=i.util.defaults({scale:!0,min:"dataMin",max:"dataMax"},Po),No=i.util.defaults({logBase:10},Po);No.scale=!0;const Io={categoryAxis3D:Lo,valueAxis3D:Po,timeAxis3D:Oo,logAxis3D:No};function Ro(t){return Ia(t)&&null!=t.value?t.value:t+""}const Bo=function(){function t(t){this.categories=t.categories||[],this._needCollect=t.needCollect,this._deduplication=t.deduplication}return t.createByAxisModel=function(e){var r=e.option,i=r.data,n=i&&Da(i,Ro);return new t({categories:n,needCollect:!n,deduplication:!1!==r.dedplication})},t.prototype.getOrdinal=function(t){return this._getOrCreateMap().get(t)},t.prototype.parseAndCollect=function(t){var e,r=this._needCollect;if("string"!=typeof t&&!r)return t;if(r&&!this._deduplication)return e=this.categories.length,this.categories[e]=t,e;var i=this._getOrCreateMap();return null==(e=i.get(t))&&(r?(e=this.categories.length,this.categories[e]=t,i.set(t,e)):e=NaN),e},t.prototype._getOrCreateMap=function(){return this._map||(this._map=(t=this.categories,new Va(t)));var t},t}();var Fo=["value","category","time","log"];function zo(t,e,r,n){i.util.each(Fo,(function(a){e.extend({type:t+"Axis3D."+a,__ordinalMeta:null,mergeDefaultAndTheme:function(e,n){var o=n.getTheme();i.util.merge(e,o.get(a+"Axis3D")),i.util.merge(e,this.getDefaultOption()),e.type=r(t,e)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=Bo.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:i.util.merge(i.util.clone(Io[a+"Axis3D"]),n||{},!0)})})),e.superClass.registerSubTypeDefaulter(t+"Axis3D",i.util.curry(r,t))}var ko=i.extendComponentModel({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});function Go(t,e){return e.type||(e.data?"category":"value")}i.helper.mixinAxisModelCommonMethods(ko),zo("x",ko,Go,{name:"X"}),zo("y",ko,Go,{name:"Y"}),zo("z",ko,Go,{name:"Z"});const Uo={defaultOption:{viewControl:{projection:"perspective",autoRotate:!1,autoRotateDirection:"cw",autoRotateSpeed:10,autoRotateAfterStill:3,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",distance:150,minDistance:40,maxDistance:400,orthographicSize:150,maxOrthographicSize:400,minOrthographicSize:20,center:[0,0,0],alpha:0,beta:0,minAlpha:-90,maxAlpha:90}},setView:function(t){t=t||{},this.option.viewControl=this.option.viewControl||{},null!=t.alpha&&(this.option.viewControl.alpha=t.alpha),null!=t.beta&&(this.option.viewControl.beta=t.beta),null!=t.distance&&(this.option.viewControl.distance=t.distance),null!=t.center&&(this.option.viewControl.center=t.center)}},Ho={defaultOption:{postEffect:{enable:!1,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalRange:20,focalDistance:50,blurRadius:10,fstop:2.8,quality:"medium"},screenSpaceAmbientOcclusion:{enable:!1,radius:2,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},edge:{enable:!1},FXAA:{enable:!1}},temporalSuperSampling:{enable:"auto"}}},Vo={defaultOption:{light:{main:{shadow:!1,shadowQuality:"high",color:"#fff",intensity:1,alpha:0,beta:0},ambient:{color:"#fff",intensity:.2},ambientCubemap:{texture:null,exposure:1,diffuseIntensity:.5,specularIntensity:.5}}}};var Wo=i.extendComponentModel({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});i.util.merge(Wo.prototype,Uo),i.util.merge(Wo.prototype,Ho),i.util.merge(Wo.prototype,Vo);var jo=function(t,e){return(jo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function Xo(t,e){function r(){this.constructor=t}jo(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function qo(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var i=Array(t),n=0;for(e=0;e<r;e++)for(var a=arguments[e],o=0,s=a.length;o<s;o++,n++)i[n]=a[o];return i}var Zo=new xi(50);function Yo(t){if("string"==typeof t){var e=Zo.get(t);return e&&e.image}return t}function Ko(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}function Qo(t,e,r){var i=e[0]*r[0]+e[2]*r[1],n=e[1]*r[0]+e[3]*r[1],a=e[0]*r[2]+e[2]*r[3],o=e[1]*r[2]+e[3]*r[3],s=e[0]*r[4]+e[2]*r[5]+e[4],l=e[1]*r[4]+e[3]*r[5]+e[5];return t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t}function Jo(t,e,r){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4]+r[0],t[5]=e[5]+r[1],t}function $o(t,e){var r=e[0],i=e[2],n=e[4],a=e[1],o=e[3],s=e[5],l=r*o-a*i;return l?(l=1/l,t[0]=o*l,t[1]=-a*l,t[2]=-i*l,t[3]=r*l,t[4]=(i*s-o*n)*l,t[5]=(a*n-r*s)*l,t):null}const ts=function(){function t(t,e){this.x=t||0,this.y=e||0}return t.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.set=function(t,e){return this.x=t,this.y=e,this},t.prototype.equal=function(t){return t.x===this.x&&t.y===this.y},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},t.prototype.scale=function(t){this.x*=t,this.y*=t},t.prototype.scaleAndAdd=function(t,e){this.x+=t.x*e,this.y+=t.y*e},t.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y},t.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},t.prototype.lenSquare=function(){return this.x*this.x+this.y*this.y},t.prototype.normalize=function(){var t=this.len();return this.x/=t,this.y/=t,this},t.prototype.distance=function(t){var e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)},t.prototype.distanceSquare=function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},t.prototype.transform=function(t){if(t){var e=this.x,r=this.y;return this.x=t[0]*e+t[2]*r+t[4],this.y=t[1]*e+t[3]*r+t[5],this}},t.prototype.toArray=function(t){return t[0]=this.x,t[1]=this.y,t},t.prototype.fromArray=function(t){this.x=t[0],this.y=t[1]},t.set=function(t,e,r){t.x=e,t.y=r},t.copy=function(t,e){t.x=e.x,t.y=e.y},t.len=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},t.lenSquare=function(t){return t.x*t.x+t.y*t.y},t.dot=function(t,e){return t.x*e.x+t.y*e.y},t.add=function(t,e,r){t.x=e.x+r.x,t.y=e.y+r.y},t.sub=function(t,e,r){t.x=e.x-r.x,t.y=e.y-r.y},t.scale=function(t,e,r){t.x=e.x*r,t.y=e.y*r},t.scaleAndAdd=function(t,e,r,i){t.x=e.x+r.x*i,t.y=e.y+r.y*i},t.lerp=function(t,e,r,i){var n=1-i;t.x=n*e.x+i*r.x,t.y=n*e.y+i*r.y},t}();var es=Math.min,rs=Math.max,is=new ts,ns=new ts,as=new ts,os=new ts,ss=new ts,ls=new ts;const hs=function(){function t(t,e,r,i){r<0&&isFinite(r)&&(t+=r,r=-r),i<0&&isFinite(i)&&(e+=i,i=-i),this.x=t,this.y=e,this.width=r,this.height=i}return t.prototype.union=function(t){var e=es(t.x,this.x),r=es(t.y,this.y);isFinite(this.x)&&isFinite(this.width)?this.width=rs(t.x+t.width,this.x+this.width)-e:this.width=t.width,isFinite(this.y)&&isFinite(this.height)?this.height=rs(t.y+t.height,this.y+this.height)-r:this.height=t.height,this.x=e,this.y=r},t.prototype.applyTransform=function(e){t.applyTransform(this,this,e)},t.prototype.calculateTransform=function(t){var e=this,r=t.width/e.width,i=t.height/e.height,n=[1,0,0,1,0,0];return Jo(n,n,[-e.x,-e.y]),function(t,e,r){var i=r[0],n=r[1];t[0]=e[0]*i,t[1]=e[1]*n,t[2]=e[2]*i,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*n}(n,n,[r,i]),Jo(n,n,[t.x,t.y]),n},t.prototype.intersect=function(e,r){if(!e)return!1;e instanceof t||(e=t.create(e));var i=this,n=i.x,a=i.x+i.width,o=i.y,s=i.y+i.height,l=e.x,h=e.x+e.width,u=e.y,c=e.y+e.height,d=!(a<l||h<n||s<u||c<o);if(r){var f=1/0,p=0,m=Math.abs(a-l),g=Math.abs(h-n),_=Math.abs(s-u),v=Math.abs(c-o),y=Math.min(m,g),x=Math.min(_,v);a<l||h<n?y>p&&(p=y,m<g?ts.set(ls,-m,0):ts.set(ls,g,0)):y<f&&(f=y,m<g?ts.set(ss,m,0):ts.set(ss,-g,0)),s<u||c<o?x>p&&(p=x,_<v?ts.set(ls,0,-_):ts.set(ls,0,v)):y<f&&(f=y,_<v?ts.set(ss,0,_):ts.set(ss,0,-v))}return r&&ts.copy(r,d?ss:ls),d},t.prototype.contain=function(t,e){var r=this;return t>=r.x&&t<=r.x+r.width&&e>=r.y&&e<=r.y+r.height},t.prototype.clone=function(){return new t(this.x,this.y,this.width,this.height)},t.prototype.copy=function(e){t.copy(this,e)},t.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},t.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},t.prototype.isZero=function(){return 0===this.width||0===this.height},t.create=function(e){return new t(e.x,e.y,e.width,e.height)},t.copy=function(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},t.applyTransform=function(e,r,i){if(i){if(i[1]<1e-5&&i[1]>-1e-5&&i[2]<1e-5&&i[2]>-1e-5){var n=i[0],a=i[3],o=i[4],s=i[5];return e.x=r.x*n+o,e.y=r.y*a+s,e.width=r.width*n,e.height=r.height*a,e.width<0&&(e.x+=e.width,e.width=-e.width),void(e.height<0&&(e.y+=e.height,e.height=-e.height))}is.x=as.x=r.x,is.y=os.y=r.y,ns.x=os.x=r.x+r.width,ns.y=as.y=r.y+r.height,is.transform(i),os.transform(i),ns.transform(i),as.transform(i),e.x=es(is.x,ns.x,as.x,os.x),e.y=es(is.y,ns.y,as.y,os.y);var l=rs(is.x,ns.x,as.x,os.x),h=rs(is.y,ns.y,as.y,os.y);e.width=l-e.x,e.height=h-e.y}else e!==r&&t.copy(e,r)},t}();var us,cs,ds={},fs="12px sans-serif",ps=function(t,e){return us||(us=va.createCanvas().getContext("2d")),cs!==e&&(cs=us.font=e||fs),us.measureText(t)};function ms(t,e){var r=ds[e=e||fs];r||(r=ds[e]=new xi(500));var i=r.get(t);return null==i&&(i=ps(t,e).width,r.put(t,i)),i}function gs(t,e,r,i){var n=ms(t,e),a=ys(e),o=_s(0,n,r),s=vs(0,a,i);return new hs(o,s,n,a)}function _s(t,e,r){return"right"===r?t-=e:"center"===r&&(t-=e/2),t}function vs(t,e,r){return"middle"===r?t-=e/2:"bottom"===r&&(t-=e),t}function ys(t){return ms("国",t)}function xs(t,e){return"string"==typeof t?t.lastIndexOf("%")>=0?parseFloat(t)/100*e:parseFloat(t):t}var bs=/\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;function ws(t,e,r,i,n){if(!e)return"";var a=(t+"").split("\n");n=Ts(e,r,i,n);for(var o=0,s=a.length;o<s;o++)a[o]=Ss(a[o],n);return a.join("\n")}function Ts(t,e,r,i){var n=Ta({},i=i||{});n.font=e,r=Fa(r,"..."),n.maxIterations=Fa(i.maxIterations,2);var a=n.minChar=Fa(i.minChar,0);n.cnCharWidth=ms("国",e);var o=n.ascCharWidth=ms("a",e);n.placeholder=Fa(i.placeholder,"");for(var s=t=Math.max(0,t-1),l=0;l<a&&s>=o;l++)s-=o;var h=ms(r,e);return h>s&&(r="",h=0),s=t-h,n.ellipsis=r,n.ellipsisWidth=h,n.contentWidth=s,n.containerWidth=t,n}function Ss(t,e){var r=e.containerWidth,i=e.font,n=e.contentWidth;if(!r)return"";var a=ms(t,i);if(a<=r)return t;for(var o=0;;o++){if(a<=n||o>=e.maxIterations){t+=e.ellipsis;break}var s=0===o?Ms(t,n,e.ascCharWidth,e.cnCharWidth):a>0?Math.floor(t.length*n/a):0;a=ms(t=t.substr(0,s),i)}return""===t&&(t=e.placeholder),t}function Ms(t,e,r,i){for(var n=0,a=0,o=t.length;a<o&&n<e;a++){var s=t.charCodeAt(a);n+=0<=s&&s<=127?r:i}return a}var As=function(){},Cs=function(t){this.tokens=[],t&&(this.tokens=t)},Es=function(){this.width=0,this.height=0,this.contentWidth=0,this.contentHeight=0,this.outerWidth=0,this.outerHeight=0,this.lines=[]};function Ds(t,e,r,i,n){var a,o,s,l,h=""===e,u=n&&r.rich[n]||{},c=t.lines,d=u.font||r.font,f=!1;if(i){var p=u.padding,m=p?p[1]+p[3]:0;if(null!=u.width&&"auto"!==u.width){var g=(s=u.width,l=i.width,("string"==typeof s?s.lastIndexOf("%")>=0?parseFloat(s)/100*l:parseFloat(s):s)+m);c.length>0&&g+i.accumWidth>i.width&&(a=e.split("\n"),f=!0),i.accumWidth=g}else{var _=Os(e,d,i.width,i.breakAll,i.accumWidth);i.accumWidth=_.accumWidth+m,o=_.linesWidths,a=_.lines}}else a=e.split("\n");for(var v=0;v<a.length;v++){var y=a[v],x=new As;if(x.styleName=n,x.text=y,x.isLineHolder=!y&&!h,"number"==typeof u.width?x.width=u.width:x.width=o?o[v]:ms(y,d),v||f)c.push(new Cs([x]));else{var b=(c[c.length-1]||(c[0]=new Cs)).tokens,w=b.length;1===w&&b[0].isLineHolder?b[0]=x:(y||!w||h)&&b.push(x)}}}var Ls=function(t,e,r,i){if(t&&e){for(var n=0,a=t.length;n<a;n++)r=e.call(undefined,r,t[n],n,t);return r}}(",&?/;] ".split(""),(function(t,e){return t[e]=!0,t}),{});function Ps(t){return!function(t){var e=t.charCodeAt(0);return e>=33&&e<=255}(t)||!!Ls[t]}function Os(t,e,r,i,n){for(var a=[],o=[],s="",l="",h=0,u=0,c=0;c<t.length;c++){var d=t.charAt(c);if("\n"!==d){var f=ms(d,e),p=!i&&!Ps(d);(a.length?u+f>r:n+u+f>r)?u?(s||l)&&(p?(s||(s=l,l="",u=h=0),a.push(s),o.push(u-h),l+=d,s="",u=h+=f):(l&&(s+=l,u+=h,l="",h=0),a.push(s),o.push(u),s=d,u=f)):p?(a.push(l),o.push(h),l=d,h=f):(a.push(d),o.push(f)):(u+=f,p?(l+=d,h+=f):(l&&(s+=l,l="",h=0),s+=d))}else l&&(s+=l,u+=h),a.push(s),o.push(u),s="",l="",h=0,u=0}return a.length||s||(s=t,l="",h=0),l&&(s+=l),s&&(a.push(s),o.push(u)),1===a.length&&(u+=n),{accumWidth:u,lines:a,linesWidths:o}}function Ns(t,e){return null==t&&(t=0),null==e&&(e=0),[t,e]}function Is(t){return[t[0],t[1]]}function Rs(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function Bs(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function Fs(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function zs(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}var ks=function(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])};function Gs(t,e,r){var i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n+r[4],t[1]=r[1]*i+r[3]*n+r[5],t}function Us(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function Hs(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}var Vs=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t};function Ws(t){return t>5e-5||t<-5e-5}var js=[],Xs=[],qs=[1,0,0,1,0,0],Zs=Math.abs;const Ys=function(){function t(){}return t.prototype.setPosition=function(t){this.x=t[0],this.y=t[1]},t.prototype.setScale=function(t){this.scaleX=t[0],this.scaleY=t[1]},t.prototype.setOrigin=function(t){this.originX=t[0],this.originY=t[1]},t.prototype.needLocalTransform=function(){return Ws(this.rotation)||Ws(this.x)||Ws(this.y)||Ws(this.scaleX-1)||Ws(this.scaleY-1)},t.prototype.updateTransform=function(){var t=this.parent,e=t&&t.transform,r=this.needLocalTransform(),i=this.transform;r||e?(i=i||[1,0,0,1,0,0],r?this.getLocalTransform(i):Vs(i),e&&(r?Qo(i,t.transform,i):Ko(i,t.transform)),this.transform=i,this._resolveGlobalScaleRatio(i)):i&&Vs(i)},t.prototype._resolveGlobalScaleRatio=function(t){var e=this.globalScaleRatio;if(null!=e&&1!==e){this.getGlobalScale(js);var r=js[0]<0?-1:1,i=js[1]<0?-1:1,n=((js[0]-r)*e+r)/js[0]||0,a=((js[1]-i)*e+i)/js[1]||0;t[0]*=n,t[1]*=n,t[2]*=a,t[3]*=a}this.invTransform=this.invTransform||[1,0,0,1,0,0],$o(this.invTransform,t)},t.prototype.getLocalTransform=function(e){return t.getLocalTransform(this,e)},t.prototype.getComputedTransform=function(){for(var t=this,e=[];t;)e.push(t),t=t.parent;for(;t=e.pop();)t.updateTransform();return this.transform},t.prototype.setLocalTransform=function(t){if(t){var e=t[0]*t[0]+t[1]*t[1],r=t[2]*t[2]+t[3]*t[3];Ws(e-1)&&(e=Math.sqrt(e)),Ws(r-1)&&(r=Math.sqrt(r)),t[0]<0&&(e=-e),t[3]<0&&(r=-r),this.rotation=Math.atan2(-t[1]/r,t[0]/e),e<0&&r<0&&(this.rotation+=Math.PI,e=-e,r=-r),this.x=t[4],this.y=t[5],this.scaleX=e,this.scaleY=r}},t.prototype.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(Qo(Xs,t.invTransform,e),e=Xs);var r=this.originX,i=this.originY;(r||i)&&(qs[4]=r,qs[5]=i,Qo(Xs,e,qs),Xs[4]-=r,Xs[5]-=i,e=Xs),this.setLocalTransform(e)}},t.prototype.getGlobalScale=function(t){var e=this.transform;return t=t||[],e?(t[0]=Math.sqrt(e[0]*e[0]+e[1]*e[1]),t[1]=Math.sqrt(e[2]*e[2]+e[3]*e[3]),e[0]<0&&(t[0]=-t[0]),e[3]<0&&(t[1]=-t[1]),t):(t[0]=1,t[1]=1,t)},t.prototype.transformCoordToLocal=function(t,e){var r=[t,e],i=this.invTransform;return i&&Gs(r,r,i),r},t.prototype.transformCoordToGlobal=function(t,e){var r=[t,e],i=this.transform;return i&&Gs(r,r,i),r},t.prototype.getLineScale=function(){var t=this.transform;return t&&Zs(t[0]-1)>1e-10&&Zs(t[3]-1)>1e-10?Math.sqrt(Zs(t[0]*t[3]-t[2]*t[1])):1},t.getLocalTransform=function(t,e){Vs(e=e||[]);var r=t.originX||0,i=t.originY||0,n=t.scaleX,a=t.scaleY,o=t.rotation||0,s=t.x,l=t.y;return e[4]-=r,e[5]-=i,e[0]*=n,e[1]*=a,e[2]*=n,e[3]*=a,e[4]*=n,e[5]*=a,o&&function(t,e,r){var i=e[0],n=e[2],a=e[4],o=e[1],s=e[3],l=e[5],h=Math.sin(r),u=Math.cos(r);t[0]=i*u+o*h,t[1]=-i*h+o*u,t[2]=n*u+s*h,t[3]=-n*h+u*s,t[4]=u*a+h*l,t[5]=u*l-h*a}(e,e,o),e[4]+=r,e[5]+=i,e[4]+=s,e[5]+=l,e},t.initDefaultProps=function(){var e=t.prototype;e.x=0,e.y=0,e.scaleX=1,e.scaleY=1,e.originX=0,e.originY=0,e.rotation=0,e.globalScaleRatio=1}(),t}(),Ks=function(){function t(t){t&&(this._$eventProcessor=t)}return t.prototype.on=function(t,e,r,i){this._$handlers||(this._$handlers={});var n=this._$handlers;if("function"==typeof e&&(i=r,r=e,e=null),!r||!t)return this;var a=this._$eventProcessor;null!=e&&a&&a.normalizeQuery&&(e=a.normalizeQuery(e)),n[t]||(n[t]=[]);for(var o=0;o<n[t].length;o++)if(n[t][o].h===r)return this;var s={h:r,query:e,ctx:i||this,callAtLast:r.zrEventfulCallAtLast},l=n[t].length-1,h=n[t][l];return h&&h.callAtLast?n[t].splice(l,0,s):n[t].push(s),this},t.prototype.isSilent=function(t){var e=this._$handlers;return!e||!e[t]||!e[t].length},t.prototype.off=function(t,e){var r=this._$handlers;if(!r)return this;if(!t)return this._$handlers={},this;if(e){if(r[t]){for(var i=[],n=0,a=r[t].length;n<a;n++)r[t][n].h!==e&&i.push(r[t][n]);r[t]=i}r[t]&&0===r[t].length&&delete r[t]}else delete r[t];return this},t.prototype.trigger=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(!this._$handlers)return this;var i=this._$handlers[t],n=this._$eventProcessor;if(i)for(var a=e.length,o=i.length,s=0;s<o;s++){var l=i[s];if(!n||!n.filter||null==l.query||n.filter(t,l.query))switch(a){case 0:l.h.call(l.ctx);break;case 1:l.h.call(l.ctx,e[0]);break;case 2:l.h.call(l.ctx,e[0],e[1]);break;default:l.h.apply(l.ctx,e)}}return n&&n.afterTrigger&&n.afterTrigger(t),this},t.prototype.triggerWithContext=function(t){if(!this._$handlers)return this;var e=this._$handlers[t],r=this._$eventProcessor;if(e)for(var i=arguments,n=i.length,a=i[n-1],o=e.length,s=0;s<o;s++){var l=e[s];if(!r||!r.filter||null==l.query||r.filter(t,l.query))switch(n){case 0:l.h.call(a);break;case 1:l.h.call(a,i[0]);break;case 2:l.h.call(a,i[0],i[1]);break;default:l.h.apply(a,i.slice(1,n-1))}}return r&&r.afterTrigger&&r.afterTrigger(t),this},t}();var Qs=1;"undefined"!=typeof window&&(Qs=Math.max(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI||1,1));var Js,$s,tl,el,rl,il,nl,al=Qs,ol="#333",sl="#ccc",ll=function(){this.firefox=!1,this.ie=!1,this.edge=!1,this.weChat=!1},hl=new function(){this.browser=new ll,this.node=!1,this.wxa=!1,this.worker=!1,this.canvasSupported=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1};"object"==typeof wx&&"function"==typeof wx.getSystemInfoSync?(hl.wxa=!0,hl.canvasSupported=!0,hl.touchEventsSupported=!0):"undefined"==typeof document&&"undefined"!=typeof self?(hl.worker=!0,hl.canvasSupported=!0):"undefined"==typeof navigator?(hl.node=!0,hl.canvasSupported=!0,hl.svgSupported=!0):(Js=navigator.userAgent,tl=($s=hl).browser,el=Js.match(/Firefox\/([\d.]+)/),rl=Js.match(/MSIE\s([\d.]+)/)||Js.match(/Trident\/.+?rv:(([\d.]+))/),il=Js.match(/Edge\/([\d.]+)/),nl=/micromessenger/i.test(Js),el&&(tl.firefox=!0,tl.version=el[1]),rl&&(tl.ie=!0,tl.version=rl[1]),il&&(tl.edge=!0,tl.version=il[1]),nl&&(tl.weChat=!0),$s.canvasSupported=!!document.createElement("canvas").getContext,$s.svgSupported="undefined"!=typeof SVGRect,$s.touchEventsSupported="ontouchstart"in window&&!tl.ie&&!tl.edge,$s.pointerEventsSupported="onpointerdown"in window&&(tl.edge||tl.ie&&+tl.version>=11),$s.domSupported="undefined"!=typeof document);const ul=hl;var cl="__zr_normal__",dl=["x","y","scaleX","scaleY","originX","originY","rotation","ignore"],fl={x:!0,y:!0,scaleX:!0,scaleY:!0,originX:!0,originY:!0,rotation:!0,ignore:!1},pl={},ml=new hs(0,0,0,0),gl=function(){function t(t){this.id=ya++,this.animators=[],this.currentStates=[],this.states={},this._init(t)}return t.prototype._init=function(t){this.attr(t)},t.prototype.drift=function(t,e,r){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0}var i=this.transform;i||(i=this.transform=[1,0,0,1,0,0]),i[4]+=t,i[5]+=e,this.decomposeTransform(),this.markRedraw()},t.prototype.beforeUpdate=function(){},t.prototype.afterUpdate=function(){},t.prototype.update=function(){this.updateTransform(),this.__dirty&&this.updateInnerText()},t.prototype.updateInnerText=function(t){var e=this._textContent;if(e&&(!e.ignore||t)){this.textConfig||(this.textConfig={});var r=this.textConfig,i=r.local,n=e.attachedTransform,a=void 0,o=void 0,s=!1;n.parent=i?this:null;var l=!1;if(n.x=e.x,n.y=e.y,n.originX=e.originX,n.originY=e.originY,n.rotation=e.rotation,n.scaleX=e.scaleX,n.scaleY=e.scaleY,null!=r.position){var h=ml;r.layoutRect?h.copy(r.layoutRect):h.copy(this.getBoundingRect()),i||h.applyTransform(this.transform),this.calculateTextPosition?this.calculateTextPosition(pl,r,h):function(t,e,r){var i=e.position||"inside",n=null!=e.distance?e.distance:5,a=r.height,o=r.width,s=a/2,l=r.x,h=r.y,u="left",c="top";if(i instanceof Array)l+=xs(i[0],r.width),h+=xs(i[1],r.height),u=null,c=null;else switch(i){case"left":l-=n,h+=s,u="right",c="middle";break;case"right":l+=n+o,h+=s,c="middle";break;case"top":l+=o/2,h-=n,u="center",c="bottom";break;case"bottom":l+=o/2,h+=a+n,u="center";break;case"inside":l+=o/2,h+=s,u="center",c="middle";break;case"insideLeft":l+=n,h+=s,c="middle";break;case"insideRight":l+=o-n,h+=s,u="right",c="middle";break;case"insideTop":l+=o/2,h+=n,u="center";break;case"insideBottom":l+=o/2,h+=a-n,u="center",c="bottom";break;case"insideTopLeft":l+=n,h+=n;break;case"insideTopRight":l+=o-n,h+=n,u="right";break;case"insideBottomLeft":l+=n,h+=a-n,c="bottom";break;case"insideBottomRight":l+=o-n,h+=a-n,u="right",c="bottom"}(t=t||{}).x=l,t.y=h,t.align=u,t.verticalAlign=c}(pl,r,h),n.x=pl.x,n.y=pl.y,a=pl.align,o=pl.verticalAlign;var u=r.origin;if(u&&null!=r.rotation){var c=void 0,d=void 0;"center"===u?(c=.5*h.width,d=.5*h.height):(c=xs(u[0],h.width),d=xs(u[1],h.height)),l=!0,n.originX=-n.x+c+(i?0:h.x),n.originY=-n.y+d+(i?0:h.y)}}null!=r.rotation&&(n.rotation=r.rotation);var f=r.offset;f&&(n.x+=f[0],n.y+=f[1],l||(n.originX=-f[0],n.originY=-f[1]));var p=null==r.inside?"string"==typeof r.position&&r.position.indexOf("inside")>=0:r.inside,m=this._innerTextDefaultStyle||(this._innerTextDefaultStyle={}),g=void 0,_=void 0,v=void 0;p&&this.canBeInsideText()?(g=r.insideFill,_=r.insideStroke,null!=g&&"auto"!==g||(g=this.getInsideTextFill()),null!=_&&"auto"!==_||(_=this.getInsideTextStroke(g),v=!0)):(g=r.outsideFill,_=r.outsideStroke,null!=g&&"auto"!==g||(g=this.getOutsideFill()),null!=_&&"auto"!==_||(_=this.getOutsideStroke(g),v=!0)),(g=g||"#000")===m.fill&&_===m.stroke&&v===m.autoStroke&&a===m.align&&o===m.verticalAlign||(s=!0,m.fill=g,m.stroke=_,m.autoStroke=v,m.align=a,m.verticalAlign=o,e.setDefaultTextStyle(m)),s&&e.dirtyStyle(),e.markRedraw()}},t.prototype.canBeInsideText=function(){return!0},t.prototype.getInsideTextFill=function(){return"#fff"},t.prototype.getInsideTextStroke=function(t){return"#000"},t.prototype.getOutsideFill=function(){return this.__zr&&this.__zr.isDarkMode()?sl:ol},t.prototype.getOutsideStroke=function(t){var e=this.__zr&&this.__zr.getBackgroundColor(),r="string"==typeof e&&aa(e);r||(r=[255,255,255,1]);for(var i=r[3],n=this.__zr.isDarkMode(),a=0;a<3;a++)r[a]=r[a]*i+(n?0:255)*(1-i);return r[3]=1,function(t,e){if(t&&t.length){var r=t[0]+","+t[1]+","+t[2];return"rgba"!==e&&"hsva"!==e&&"hsla"!==e||(r+=","+t[3]),e+"("+r+")"}}(r,"rgba")},t.prototype.traverse=function(t,e){},t.prototype.attrKV=function(t,e){"textConfig"===t?this.setTextConfig(e):"textContent"===t?this.setTextContent(e):"clipPath"===t?this.setClipPath(e):"extra"===t?(this.extra=this.extra||{},Ta(this.extra,e)):this[t]=e},t.prototype.hide=function(){this.ignore=!0,this.markRedraw()},t.prototype.show=function(){this.ignore=!1,this.markRedraw()},t.prototype.attr=function(t,e){if("string"==typeof t)this.attrKV(t,e);else if(Ia(t))for(var r=La(t),i=0;i<r.length;i++){var n=r[i];this.attrKV(n,t[n])}return this.markRedraw(),this},t.prototype.saveCurrentToNormalState=function(t){this._innerSaveToNormal(t);for(var e=this._normalState,r=0;r<this.animators.length;r++){var i=this.animators[r],n=i.__fromStateTransition;if(!n||n===cl){var a=i.targetName,o=a?e[a]:e;i.saveFinalToTarget(o)}}},t.prototype._innerSaveToNormal=function(t){var e=this._normalState;e||(e=this._normalState={}),t.textConfig&&!e.textConfig&&(e.textConfig=this.textConfig),this._savePrimaryToNormal(t,e,dl)},t.prototype._savePrimaryToNormal=function(t,e,r){for(var i=0;i<r.length;i++){var n=r[i];null==t[n]||n in e||(e[n]=this[n])}},t.prototype.hasState=function(){return this.currentStates.length>0},t.prototype.getState=function(t){return this.states[t]},t.prototype.ensureState=function(t){var e=this.states;return e[t]||(e[t]={}),e[t]},t.prototype.clearStates=function(t){this.useState(cl,!1,t)},t.prototype.useState=function(e,r,i){var n=e===cl;if(this.hasState()||!n){var a=this.currentStates,o=this.stateTransition;if(!(Ma(a,e)>=0)||!r&&1!==a.length){var s;if(this.stateProxy&&!n&&(s=this.stateProxy(e)),s||(s=this.states&&this.states[e]),s||n){n||this.saveCurrentToNormalState(s);var l=!(!s||!s.hoverLayer);return l&&this._toggleHoverLayerFlag(!0),this._applyStateObj(e,s,this._normalState,r,!i&&!this.__inHover&&o&&o.duration>0,o),this._textContent&&this._textContent.useState(e,r),this._textGuide&&this._textGuide.useState(e,r),n?(this.currentStates=[],this._normalState={}):r?this.currentStates.push(e):this.currentStates=[e],this._updateAnimationTargets(),this.markRedraw(),!l&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=~t.REDARAW_BIT),s}xa("State "+e+" not exists.")}}},t.prototype.useStates=function(e,r){if(e.length){var i=[],n=this.currentStates,a=e.length,o=a===n.length;if(o)for(var s=0;s<a;s++)if(e[s]!==n[s]){o=!1;break}if(o)return;for(s=0;s<a;s++){var l=e[s],h=void 0;this.stateProxy&&(h=this.stateProxy(l,e)),h||(h=this.states[l]),h&&i.push(h)}var u=!(!i[a-1]||!i[a-1].hoverLayer);u&&this._toggleHoverLayerFlag(!0);var c=this._mergeStates(i),d=this.stateTransition;this.saveCurrentToNormalState(c),this._applyStateObj(e.join(","),c,this._normalState,!1,!r&&!this.__inHover&&d&&d.duration>0,d),this._textContent&&this._textContent.useStates(e),this._textGuide&&this._textGuide.useStates(e),this._updateAnimationTargets(),this.currentStates=e.slice(),this.markRedraw(),!u&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=~t.REDARAW_BIT)}else this.clearStates()},t.prototype._updateAnimationTargets=function(){for(var t=0;t<this.animators.length;t++){var e=this.animators[t];e.targetName&&e.changeTarget(this[e.targetName])}},t.prototype.removeState=function(t){var e=Ma(this.currentStates,t);if(e>=0){var r=this.currentStates.slice();r.splice(e,1),this.useStates(r)}},t.prototype.replaceState=function(t,e,r){var i=this.currentStates.slice(),n=Ma(i,t),a=Ma(i,e)>=0;n>=0?a?i.splice(n,1):i[n]=e:r&&!a&&i.push(e),this.useStates(i)},t.prototype.toggleState=function(t,e){e?this.useState(t,!0):this.removeState(t)},t.prototype._mergeStates=function(t){for(var e,r={},i=0;i<t.length;i++){var n=t[i];Ta(r,n),n.textConfig&&Ta(e=e||{},n.textConfig)}return e&&(r.textConfig=e),r},t.prototype._applyStateObj=function(t,e,r,i,n,a){var o=!(e&&i);e&&e.textConfig?(this.textConfig=Ta({},i?this.textConfig:r.textConfig),Ta(this.textConfig,e.textConfig)):o&&r.textConfig&&(this.textConfig=r.textConfig);for(var s={},l=!1,h=0;h<dl.length;h++){var u=dl[h],c=n&&fl[u];e&&null!=e[u]?c?(l=!0,s[u]=e[u]):this[u]=e[u]:o&&null!=r[u]&&(c?(l=!0,s[u]=r[u]):this[u]=r[u])}if(!n)for(h=0;h<this.animators.length;h++){var d=this.animators[h],f=d.targetName;d.__changeFinalValue(f?(e||r)[f]:e||r)}l&&this._transitionState(t,s,a)},t.prototype._attachComponent=function(t){if(t.__zr&&!t.__hostTarget)throw new Error("Text element has been added to zrender.");if(t===this)throw new Error("Recursive component attachment.");var e=this.__zr;e&&t.addSelfToZr(e),t.__zr=e,t.__hostTarget=this},t.prototype._detachComponent=function(t){t.__zr&&t.removeSelfFromZr(t.__zr),t.__zr=null,t.__hostTarget=null},t.prototype.getClipPath=function(){return this._clipPath},t.prototype.setClipPath=function(t){this._clipPath&&this._clipPath!==t&&this.removeClipPath(),this._attachComponent(t),this._clipPath=t,this.markRedraw()},t.prototype.removeClipPath=function(){var t=this._clipPath;t&&(this._detachComponent(t),this._clipPath=null,this.markRedraw())},t.prototype.getTextContent=function(){return this._textContent},t.prototype.setTextContent=function(t){var e=this._textContent;if(e!==t){if(e&&e!==t&&this.removeTextContent(),t.__zr&&!t.__hostTarget)throw new Error("Text element has been added to zrender.");t.attachedTransform=new Ys,this._attachComponent(t),this._textContent=t,this.markRedraw()}},t.prototype.setTextConfig=function(t){this.textConfig||(this.textConfig={}),Ta(this.textConfig,t),this.markRedraw()},t.prototype.removeTextContent=function(){var t=this._textContent;t&&(t.attachedTransform=null,this._detachComponent(t),this._textContent=null,this._innerTextDefaultStyle=null,this.markRedraw())},t.prototype.getTextGuideLine=function(){return this._textGuide},t.prototype.setTextGuideLine=function(t){this._textGuide&&this._textGuide!==t&&this.removeTextGuideLine(),this._attachComponent(t),this._textGuide=t,this.markRedraw()},t.prototype.removeTextGuideLine=function(){var t=this._textGuide;t&&(this._detachComponent(t),this._textGuide=null,this.markRedraw())},t.prototype.markRedraw=function(){this.__dirty|=t.REDARAW_BIT;var e=this.__zr;e&&(this.__inHover?e.refreshHover():e.refresh()),this.__hostTarget&&this.__hostTarget.markRedraw()},t.prototype.dirty=function(){this.markRedraw()},t.prototype._toggleHoverLayerFlag=function(t){this.__inHover=t;var e=this._textContent,r=this._textGuide;e&&(e.__inHover=t),r&&(r.__inHover=t)},t.prototype.addSelfToZr=function(t){this.__zr=t;var e=this.animators;if(e)for(var r=0;r<e.length;r++)t.animation.addAnimator(e[r]);this._clipPath&&this._clipPath.addSelfToZr(t),this._textContent&&this._textContent.addSelfToZr(t),this._textGuide&&this._textGuide.addSelfToZr(t)},t.prototype.removeSelfFromZr=function(t){this.__zr=null;var e=this.animators;if(e)for(var r=0;r<e.length;r++)t.animation.removeAnimator(e[r]);this._clipPath&&this._clipPath.removeSelfFromZr(t),this._textContent&&this._textContent.removeSelfFromZr(t),this._textGuide&&this._textGuide.removeSelfFromZr(t)},t.prototype.animate=function(t,e){var r=t?this[t]:this;if(r){var i=new ao(r,e);return this.addAnimator(i,t),i}xa('Property "'+t+'" is not existed in element '+this.id)},t.prototype.addAnimator=function(t,e){var r=this.__zr,i=this;t.during((function(){i.updateDuringAnimation(e)})).done((function(){var e=i.animators,r=Ma(e,t);r>=0&&e.splice(r,1)})),this.animators.push(t),r&&r.animation.addAnimator(t),r&&r.wakeUp()},t.prototype.updateDuringAnimation=function(t){this.markRedraw()},t.prototype.stopAnimation=function(t,e){for(var r=this.animators,i=r.length,n=[],a=0;a<i;a++){var o=r[a];t&&t!==o.scope?n.push(o):o.stop(e)}return this.animators=n,this},t.prototype.animateTo=function(t,e,r){_l(this,t,e,r)},t.prototype.animateFrom=function(t,e,r){_l(this,t,e,r,!0)},t.prototype._transitionState=function(t,e,r,i){for(var n=_l(this,e,r,i),a=0;a<n.length;a++)n[a].__fromStateTransition=t},t.prototype.getBoundingRect=function(){return null},t.prototype.getPaintRect=function(){return null},t.REDARAW_BIT=1,t.initDefaultProps=function(){var e=t.prototype;e.type="element",e.name="",e.ignore=!1,e.silent=!1,e.isGroup=!1,e.draggable=!1,e.dragging=!1,e.ignoreClip=!1,e.__inHover=!1,e.__dirty=t.REDARAW_BIT;var r={};function i(t,e,i){r[t+e+i]||(console.warn("DEPRECATED: '"+t+"' has been deprecated. use '"+e+"', '"+i+"' instead"),r[t+e+i]=!0)}function n(t,r,n,a){function o(t,e){Object.defineProperty(e,0,{get:function(){return t[n]},set:function(e){t[n]=e}}),Object.defineProperty(e,1,{get:function(){return t[a]},set:function(e){t[a]=e}})}Object.defineProperty(e,t,{get:function(){return i(t,n,a),this[r]||o(this,this[r]=[]),this[r]},set:function(e){i(t,n,a),this[n]=e[0],this[a]=e[1],this[r]=e,o(this,e)}})}Object.defineProperty&&(!ul.browser.ie||ul.browser.version>8)&&(n("position","_legacyPos","x","y"),n("scale","_legacyScale","scaleX","scaleY"),n("origin","_legacyOrigin","originX","originY"))}(),t}();function _l(t,e,r,i,n){var a=[];xl(t,"",t,e,r=r||{},i,a,n);var o=a.length,s=!1,l=r.done,h=r.aborted,u=function(){s=!0,--o<=0&&(s?l&&l():h&&h())},c=function(){--o<=0&&(s?l&&l():h&&h())};o||l&&l(),a.length>0&&r.during&&a[0].during((function(t,e){r.during(e)}));for(var d=0;d<a.length;d++){var f=a[d];u&&f.done(u),c&&f.aborted(c),f.start(r.easing,r.force)}return a}function vl(t,e,r){for(var i=0;i<r;i++)t[i]=e[i]}function yl(t,e,r){if(Ca(e[r]))if(Ca(t[r])||(t[r]=[]),h=e[r],ha[ua.call(h)]){var i=e[r].length;t[r].length!==i&&(t[r]=new e[r].constructor(i),vl(t[r],e[r],i))}else{var n=e[r],a=t[r],o=n.length;if(function(t){return Ca(t[0])}(n))for(var s=n[0].length,l=0;l<o;l++)a[l]?vl(a[l],n[l],s):a[l]=Array.prototype.slice.call(n[l]);else vl(a,n,o);a.length=n.length}else t[r]=e[r];var h}function xl(t,e,r,i,n,a,o,s){for(var l=[],h=[],u=La(i),c=n.duration,d=n.delay,f=n.additive,p=n.setToFinal,m=!Ia(a),g=0;g<u.length;g++)if(null!=r[M=u[g]]&&null!=i[M]&&(m||a[M]))if(Ia(i[M])&&!Ca(i[M])){if(e){s||(r[M]=i[M],t.updateDuringAnimation(e));continue}xl(t,M,r[M],i[M],n,a&&a[M],o,s)}else l.push(M),h.push(M);else s||(r[M]=i[M],t.updateDuringAnimation(e),h.push(M));var _=l.length;if(_>0||n.force&&!o.length){for(var v=t.animators,y=[],x=0;x<v.length;x++)v[x].targetName===e&&y.push(v[x]);if(!f&&y.length)for(x=0;x<y.length;x++)if(y[x].stopTracks(h)){var b=Ma(v,y[x]);v.splice(b,1)}var w=void 0,T=void 0,S=void 0;if(s)for(T={},p&&(w={}),x=0;x<_;x++)T[M=l[x]]=r[M],p?w[M]=i[M]:r[M]=i[M];else if(p)for(S={},x=0;x<_;x++){var M;S[M=l[x]]=eo(r[M]),yl(r,i,M)}var A=new ao(r,!1,f?y:null);A.targetName=e,n.scope&&(A.scope=n.scope),p&&w&&A.whenWithKeys(0,w,l),S&&A.whenWithKeys(0,S,l),A.whenWithKeys(null==c?500:c,s?T:i,l).delay(d||0),t.addAnimator(A,e),o.push(A)}}Aa(gl,Ks),Aa(gl,Ys);const bl=gl;var wl="__zr_style_"+Math.round(10*Math.random()),Tl={shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",opacity:1,blend:"source-over"},Sl={style:{shadowBlur:!0,shadowOffsetX:!0,shadowOffsetY:!0,shadowColor:!0,opacity:!0}};Tl[wl]=!0;var Ml=["z","z2","invisible"],Al=function(t){function e(e){return t.call(this,e)||this}var r;return Xo(e,t),e.prototype._init=function(e){for(var r=La(e),i=0;i<r.length;i++){var n=r[i];"style"===n?this.useStyle(e[n]):t.prototype.attrKV.call(this,n,e[n])}this.style||this.useStyle({})},e.prototype.beforeBrush=function(){},e.prototype.afterBrush=function(){},e.prototype.innerBeforeBrush=function(){},e.prototype.innerAfterBrush=function(){},e.prototype.shouldBePainted=function(t,e,r,i){var n,a,o,s=this.transform;if(this.ignore||this.invisible||0===this.style.opacity||this.culling&&(n=this,a=t,o=e,Cl.copy(n.getBoundingRect()),n.transform&&Cl.applyTransform(n.transform),El.width=a,El.height=o,!Cl.intersect(El))||s&&!s[0]&&!s[3])return!1;if(r&&this.__clipPaths)for(var l=0;l<this.__clipPaths.length;++l)if(this.__clipPaths[l].isZeroArea())return!1;if(i&&this.parent)for(var h=this.parent;h;){if(h.ignore)return!1;h=h.parent}return!0},e.prototype.contain=function(t,e){return this.rectContain(t,e)},e.prototype.traverse=function(t,e){t.call(e,this)},e.prototype.rectContain=function(t,e){var r=this.transformCoordToLocal(t,e);return this.getBoundingRect().contain(r[0],r[1])},e.prototype.getPaintRect=function(){var t=this._paintRect;if(!this._paintRect||this.__dirty){var e=this.transform,r=this.getBoundingRect(),i=this.style,n=i.shadowBlur||0,a=i.shadowOffsetX||0,o=i.shadowOffsetY||0;t=this._paintRect||(this._paintRect=new hs(0,0,0,0)),e?hs.applyTransform(t,r,e):t.copy(r),(n||a||o)&&(t.width+=2*n+Math.abs(a),t.height+=2*n+Math.abs(o),t.x=Math.min(t.x,t.x+a-n),t.y=Math.min(t.y,t.y+o-n));var s=this.dirtyRectTolerance;t.isZero()||(t.x=Math.floor(t.x-s),t.y=Math.floor(t.y-s),t.width=Math.ceil(t.width+1+2*s),t.height=Math.ceil(t.height+1+2*s))}return t},e.prototype.setPrevPaintRect=function(t){t?(this._prevPaintRect=this._prevPaintRect||new hs(0,0,0,0),this._prevPaintRect.copy(t)):this._prevPaintRect=null},e.prototype.getPrevPaintRect=function(){return this._prevPaintRect},e.prototype.animateStyle=function(t){return this.animate("style",t)},e.prototype.updateDuringAnimation=function(t){"style"===t?this.dirtyStyle():this.markRedraw()},e.prototype.attrKV=function(e,r){"style"!==e?t.prototype.attrKV.call(this,e,r):this.style?this.setStyle(r):this.useStyle(r)},e.prototype.setStyle=function(t,e){return"string"==typeof t?this.style[t]=e:Ta(this.style,t),this.dirtyStyle(),this},e.prototype.dirtyStyle=function(){this.markRedraw(),this.__dirty|=e.STYLE_CHANGED_BIT,this._rect&&(this._rect=null)},e.prototype.dirty=function(){this.dirtyStyle()},e.prototype.styleChanged=function(){return!!(this.__dirty&e.STYLE_CHANGED_BIT)},e.prototype.styleUpdated=function(){this.__dirty&=~e.STYLE_CHANGED_BIT},e.prototype.createStyle=function(t){return ja(Tl,t)},e.prototype.useStyle=function(t){t[wl]||(t=this.createStyle(t)),this.__inHover?this.__hoverStyle=t:this.style=t,this.dirtyStyle()},e.prototype.isStyleObject=function(t){return t[wl]},e.prototype._innerSaveToNormal=function(e){t.prototype._innerSaveToNormal.call(this,e);var r=this._normalState;e.style&&!r.style&&(r.style=this._mergeStyle(this.createStyle(),this.style)),this._savePrimaryToNormal(e,r,Ml)},e.prototype._applyStateObj=function(e,r,i,n,a,o){t.prototype._applyStateObj.call(this,e,r,i,n,a,o);var s,l=!(r&&n);if(r&&r.style?a?n?s=r.style:(s=this._mergeStyle(this.createStyle(),i.style),this._mergeStyle(s,r.style)):(s=this._mergeStyle(this.createStyle(),n?this.style:i.style),this._mergeStyle(s,r.style)):l&&(s=i.style),s)if(a){var h=this.style;if(this.style=this.createStyle(l?{}:h),l)for(var u=La(h),c=0;c<u.length;c++)(f=u[c])in s&&(s[f]=s[f],this.style[f]=h[f]);var d=La(s);for(c=0;c<d.length;c++){var f=d[c];this.style[f]=this.style[f]}this._transitionState(e,{style:s},o,this.getAnimationStyleProps())}else this.useStyle(s);for(c=0;c<Ml.length;c++)f=Ml[c],r&&null!=r[f]?this[f]=r[f]:l&&null!=i[f]&&(this[f]=i[f])},e.prototype._mergeStates=function(e){for(var r,i=t.prototype._mergeStates.call(this,e),n=0;n<e.length;n++){var a=e[n];a.style&&(r=r||{},this._mergeStyle(r,a.style))}return r&&(i.style=r),i},e.prototype._mergeStyle=function(t,e){return Ta(t,e),t},e.prototype.getAnimationStyleProps=function(){return Sl},e.STYLE_CHANGED_BIT=2,e.initDefaultProps=((r=e.prototype).type="displayable",r.invisible=!1,r.z=0,r.z2=0,r.zlevel=0,r.culling=!1,r.cursor="pointer",r.rectHover=!1,r.incremental=!1,r._rect=null,r.dirtyRectTolerance=0,void(r.__dirty=bl.REDARAW_BIT|e.STYLE_CHANGED_BIT)),e}(bl),Cl=new hs(0,0,0,0),El=new hs(0,0,0,0);const Dl=Al;var Ll=Math.pow,Pl=Math.sqrt,Ol=1e-4,Nl=Pl(3),Il=1/3,Rl=Ns(),Bl=Ns(),Fl=Ns();function zl(t){return t>-1e-8&&t<1e-8}function kl(t){return t>1e-8||t<-1e-8}function Gl(t,e,r,i,n){var a=1-n;return a*a*(a*t+3*n*e)+n*n*(n*i+3*a*r)}function Ul(t,e,r,i,n){var a=1-n;return 3*(((e-t)*a+2*(r-e)*n)*a+(i-r)*n*n)}function Hl(t,e,r,i,n){var a=6*r-12*e+6*t,o=9*e+3*i-3*t-9*r,s=3*e-3*t,l=0;if(zl(o))kl(a)&&(u=-s/a)>=0&&u<=1&&(n[l++]=u);else{var h=a*a-4*o*s;if(zl(h))n[0]=-a/(2*o);else if(h>0){var u,c=Pl(h),d=(-a-c)/(2*o);(u=(-a+c)/(2*o))>=0&&u<=1&&(n[l++]=u),d>=0&&d<=1&&(n[l++]=d)}}return l}function Vl(t,e,r,i,n,a){var o=(e-t)*n+t,s=(r-e)*n+e,l=(i-r)*n+r,h=(s-o)*n+o,u=(l-s)*n+s,c=(u-h)*n+h;a[0]=t,a[1]=o,a[2]=h,a[3]=c,a[4]=c,a[5]=u,a[6]=l,a[7]=i}function Wl(t,e,r,i,n,a,o,s,l){for(var h=t,u=e,c=0,d=1/l,f=1;f<=l;f++){var p=f*d,m=Gl(t,r,n,o,p),g=Gl(e,i,a,s,p),_=m-h,v=g-u;c+=Math.sqrt(_*_+v*v),h=m,u=g}return c}function jl(t,e,r,i){var n=1-i;return n*(n*t+2*i*e)+i*i*r}function Xl(t,e,r,i){return 2*((1-i)*(e-t)+i*(r-e))}function ql(t,e,r){var i=t+r-2*e;return 0===i?.5:(t-e)/i}function Zl(t,e,r,i,n){var a=(e-t)*i+t,o=(r-e)*i+e,s=(o-a)*i+a;n[0]=t,n[1]=a,n[2]=s,n[3]=s,n[4]=o,n[5]=r}function Yl(t,e,r,i,n,a,o){for(var s=t,l=e,h=0,u=1/o,c=1;c<=o;c++){var d=c*u,f=jl(t,r,n,d),p=jl(e,i,a,d),m=f-s,g=p-l;h+=Math.sqrt(m*m+g*g),s=f,l=p}return h}var Kl=Math.min,Ql=Math.max,Jl=Math.sin,$l=Math.cos,th=2*Math.PI,eh=Ns(),rh=Ns(),ih=Ns();function nh(t,e,r,i,n,a){n[0]=Kl(t,r),n[1]=Kl(e,i),a[0]=Ql(t,r),a[1]=Ql(e,i)}var ah=[],oh=[];function sh(t,e,r,i,n,a,o,s,l,h){var u=Hl,c=Gl,d=u(t,r,n,o,ah);l[0]=1/0,l[1]=1/0,h[0]=-1/0,h[1]=-1/0;for(var f=0;f<d;f++){var p=c(t,r,n,o,ah[f]);l[0]=Kl(p,l[0]),h[0]=Ql(p,h[0])}for(d=u(e,i,a,s,oh),f=0;f<d;f++){var m=c(e,i,a,s,oh[f]);l[1]=Kl(m,l[1]),h[1]=Ql(m,h[1])}l[0]=Kl(t,l[0]),h[0]=Ql(t,h[0]),l[0]=Kl(o,l[0]),h[0]=Ql(o,h[0]),l[1]=Kl(e,l[1]),h[1]=Ql(e,h[1]),l[1]=Kl(s,l[1]),h[1]=Ql(s,h[1])}function lh(t,e,r,i,n,a,o,s){var l=ql,h=jl,u=Ql(Kl(l(t,r,n),1),0),c=Ql(Kl(l(e,i,a),1),0),d=h(t,r,n,u),f=h(e,i,a,c);o[0]=Kl(t,n,d),o[1]=Kl(e,a,f),s[0]=Ql(t,n,d),s[1]=Ql(e,a,f)}function hh(t,e,r,i,n,a,o,s,l){var h=Us,u=Hs,c=Math.abs(n-a);if(c%th<1e-4&&c>1e-4)return s[0]=t-r,s[1]=e-i,l[0]=t+r,void(l[1]=e+i);if(eh[0]=$l(n)*r+t,eh[1]=Jl(n)*i+e,rh[0]=$l(a)*r+t,rh[1]=Jl(a)*i+e,h(s,eh,rh),u(l,eh,rh),(n%=th)<0&&(n+=th),(a%=th)<0&&(a+=th),n>a&&!o?a+=th:n<a&&o&&(n+=th),o){var d=a;a=n,n=d}for(var f=0;f<a;f+=Math.PI/2)f>n&&(ih[0]=$l(f)*r+t,ih[1]=Jl(f)*i+e,h(s,ih,s),u(l,ih,l))}var uh={M:1,L:2,C:3,Q:4,A:5,Z:6,R:7},ch=[],dh=[],fh=[],ph=[],mh=[],gh=[],_h=Math.min,vh=Math.max,yh=Math.cos,xh=Math.sin,bh=Math.sqrt,wh=Math.abs,Th=Math.PI,Sh=2*Th,Mh="undefined"!=typeof Float32Array,Ah=[];function Ch(t){return Math.round(t/Th*1e8)/1e8%2*Th}function Eh(t,e){var r=Ch(t[0]);r<0&&(r+=Sh);var i=r-t[0],n=t[1];n+=i,!e&&n-r>=Sh?n=r+Sh:e&&r-n>=Sh?n=r-Sh:!e&&r>n?n=r+(Sh-Ch(r-n)):e&&r<n&&(n=r-(Sh-Ch(n-r))),t[0]=r,t[1]=n}const Dh=function(){function t(t){this.dpr=1,this._version=0,this._xi=0,this._yi=0,this._x0=0,this._y0=0,this._len=0,t&&(this._saveData=!1),this._saveData&&(this.data=[])}return t.prototype.increaseVersion=function(){this._version++},t.prototype.getVersion=function(){return this._version},t.prototype.setScale=function(t,e,r){(r=r||0)>0&&(this._ux=wh(r/al/t)||0,this._uy=wh(r/al/e)||0)},t.prototype.setDPR=function(t){this.dpr=t},t.prototype.setContext=function(t){this._ctx=t},t.prototype.getContext=function(){return this._ctx},t.prototype.beginPath=function(){return this._ctx&&this._ctx.beginPath(),this.reset(),this},t.prototype.reset=function(){this._saveData&&(this._len=0),this._lineDash&&(this._lineDash=null,this._dashOffset=0),this._pathSegLen&&(this._pathSegLen=null,this._pathLen=0),this._version++},t.prototype.moveTo=function(t,e){return this.addData(uh.M,t,e),this._ctx&&this._ctx.moveTo(t,e),this._x0=t,this._y0=e,this._xi=t,this._yi=e,this},t.prototype.lineTo=function(t,e){var r=wh(t-this._xi)>this._ux||wh(e-this._yi)>this._uy||this._len<5;return this.addData(uh.L,t,e),this._ctx&&r&&(this._needsDash?this._dashedLineTo(t,e):this._ctx.lineTo(t,e)),r&&(this._xi=t,this._yi=e),this},t.prototype.bezierCurveTo=function(t,e,r,i,n,a){return this.addData(uh.C,t,e,r,i,n,a),this._ctx&&(this._needsDash?this._dashedBezierTo(t,e,r,i,n,a):this._ctx.bezierCurveTo(t,e,r,i,n,a)),this._xi=n,this._yi=a,this},t.prototype.quadraticCurveTo=function(t,e,r,i){return this.addData(uh.Q,t,e,r,i),this._ctx&&(this._needsDash?this._dashedQuadraticTo(t,e,r,i):this._ctx.quadraticCurveTo(t,e,r,i)),this._xi=r,this._yi=i,this},t.prototype.arc=function(t,e,r,i,n,a){Ah[0]=i,Ah[1]=n,Eh(Ah,a),i=Ah[0];var o=(n=Ah[1])-i;return this.addData(uh.A,t,e,r,r,i,o,0,a?0:1),this._ctx&&this._ctx.arc(t,e,r,i,n,a),this._xi=yh(n)*r+t,this._yi=xh(n)*r+e,this},t.prototype.arcTo=function(t,e,r,i,n){return this._ctx&&this._ctx.arcTo(t,e,r,i,n),this},t.prototype.rect=function(t,e,r,i){return this._ctx&&this._ctx.rect(t,e,r,i),this.addData(uh.R,t,e,r,i),this},t.prototype.closePath=function(){this.addData(uh.Z);var t=this._ctx,e=this._x0,r=this._y0;return t&&(this._needsDash&&this._dashedLineTo(e,r),t.closePath()),this._xi=e,this._yi=r,this},t.prototype.fill=function(t){t&&t.fill(),this.toStatic()},t.prototype.stroke=function(t){t&&t.stroke(),this.toStatic()},t.prototype.setLineDash=function(t){if(t instanceof Array){this._lineDash=t,this._dashIdx=0;for(var e=0,r=0;r<t.length;r++)e+=t[r];this._dashSum=e,this._needsDash=!0}else this._lineDash=null,this._needsDash=!1;return this},t.prototype.setLineDashOffset=function(t){return this._dashOffset=t,this},t.prototype.len=function(){return this._len},t.prototype.setData=function(t){var e=t.length;this.data&&this.data.length===e||!Mh||(this.data=new Float32Array(e));for(var r=0;r<e;r++)this.data[r]=t[r];this._len=e},t.prototype.appendPath=function(t){t instanceof Array||(t=[t]);for(var e=t.length,r=0,i=this._len,n=0;n<e;n++)r+=t[n].len();for(Mh&&this.data instanceof Float32Array&&(this.data=new Float32Array(i+r)),n=0;n<e;n++)for(var a=t[n].data,o=0;o<a.length;o++)this.data[i++]=a[o];this._len=i},t.prototype.addData=function(t,e,r,i,n,a,o,s,l){if(this._saveData){var h=this.data;this._len+arguments.length>h.length&&(this._expandData(),h=this.data);for(var u=0;u<arguments.length;u++)h[this._len++]=arguments[u]}},t.prototype._expandData=function(){if(!(this.data instanceof Array)){for(var t=[],e=0;e<this._len;e++)t[e]=this.data[e];this.data=t}},t.prototype._dashedLineTo=function(t,e){var r,i,n=this._dashSum,a=this._lineDash,o=this._ctx,s=this._dashOffset,l=this._xi,h=this._yi,u=t-l,c=e-h,d=bh(u*u+c*c),f=l,p=h,m=a.length;for(s<0&&(s=n+s),f-=(s%=n)*(u/=d),p-=s*(c/=d);u>0&&f<=t||u<0&&f>=t||0===u&&(c>0&&p<=e||c<0&&p>=e);)f+=u*(r=a[i=this._dashIdx]),p+=c*r,this._dashIdx=(i+1)%m,u>0&&f<l||u<0&&f>l||c>0&&p<h||c<0&&p>h||o[i%2?"moveTo":"lineTo"](u>=0?_h(f,t):vh(f,t),c>=0?_h(p,e):vh(p,e));u=f-t,c=p-e,this._dashOffset=-bh(u*u+c*c)},t.prototype._dashedBezierTo=function(t,e,r,i,n,a){var o,s,l,h,u,c=this._ctx,d=this._dashSum,f=this._dashOffset,p=this._lineDash,m=this._xi,g=this._yi,_=0,v=this._dashIdx,y=p.length,x=0;for(f<0&&(f=d+f),f%=d,o=0;o<1;o+=.1)s=Gl(m,t,r,n,o+.1)-Gl(m,t,r,n,o),l=Gl(g,e,i,a,o+.1)-Gl(g,e,i,a,o),_+=bh(s*s+l*l);for(;v<y&&!((x+=p[v])>f);v++);for(o=(x-f)/_;o<=1;)h=Gl(m,t,r,n,o),u=Gl(g,e,i,a,o),v%2?c.moveTo(h,u):c.lineTo(h,u),o+=p[v]/_,v=(v+1)%y;v%2!=0&&c.lineTo(n,a),s=n-h,l=a-u,this._dashOffset=-bh(s*s+l*l)},t.prototype._dashedQuadraticTo=function(t,e,r,i){var n=r,a=i;r=(r+2*t)/3,i=(i+2*e)/3,t=(this._xi+2*t)/3,e=(this._yi+2*e)/3,this._dashedBezierTo(t,e,r,i,n,a)},t.prototype.toStatic=function(){if(this._saveData){var t=this.data;t instanceof Array&&(t.length=this._len,Mh&&this._len>11&&(this.data=new Float32Array(t)))}},t.prototype.getBoundingRect=function(){fh[0]=fh[1]=mh[0]=mh[1]=Number.MAX_VALUE,ph[0]=ph[1]=gh[0]=gh[1]=-Number.MAX_VALUE;var t,e=this.data,r=0,i=0,n=0,a=0;for(t=0;t<this._len;){var o=e[t++],s=1===t;switch(s&&(n=r=e[t],a=i=e[t+1]),o){case uh.M:r=n=e[t++],i=a=e[t++],mh[0]=n,mh[1]=a,gh[0]=n,gh[1]=a;break;case uh.L:nh(r,i,e[t],e[t+1],mh,gh),r=e[t++],i=e[t++];break;case uh.C:sh(r,i,e[t++],e[t++],e[t++],e[t++],e[t],e[t+1],mh,gh),r=e[t++],i=e[t++];break;case uh.Q:lh(r,i,e[t++],e[t++],e[t],e[t+1],mh,gh),r=e[t++],i=e[t++];break;case uh.A:var l=e[t++],h=e[t++],u=e[t++],c=e[t++],d=e[t++],f=e[t++]+d;t+=1;var p=!e[t++];s&&(n=yh(d)*u+l,a=xh(d)*c+h),hh(l,h,u,c,d,f,p,mh,gh),r=yh(f)*u+l,i=xh(f)*c+h;break;case uh.R:nh(n=r=e[t++],a=i=e[t++],n+e[t++],a+e[t++],mh,gh);break;case uh.Z:r=n,i=a}Us(fh,fh,mh),Hs(ph,ph,gh)}return 0===t&&(fh[0]=fh[1]=ph[0]=ph[1]=0),new hs(fh[0],fh[1],ph[0]-fh[0],ph[1]-fh[1])},t.prototype._calculateLength=function(){var t=this.data,e=this._len,r=this._ux,i=this._uy,n=0,a=0,o=0,s=0;this._pathSegLen||(this._pathSegLen=[]);for(var l=this._pathSegLen,h=0,u=0,c=0;c<e;){var d=t[c++],f=1===c;f&&(o=n=t[c],s=a=t[c+1]);var p=-1;switch(d){case uh.M:n=o=t[c++],a=s=t[c++];break;case uh.L:var m=t[c++],g=(y=t[c++])-a;(wh(D=m-n)>r||wh(g)>i||c===e-1)&&(p=Math.sqrt(D*D+g*g),n=m,a=y);break;case uh.C:var _=t[c++],v=t[c++],y=(m=t[c++],t[c++]),x=t[c++],b=t[c++];p=Wl(n,a,_,v,m,y,x,b,10),n=x,a=b;break;case uh.Q:p=Yl(n,a,_=t[c++],v=t[c++],m=t[c++],y=t[c++],10),n=m,a=y;break;case uh.A:var w=t[c++],T=t[c++],S=t[c++],M=t[c++],A=t[c++],C=t[c++],E=C+A;c+=1,t[c++],f&&(o=yh(A)*S+w,s=xh(A)*M+T),p=vh(S,M)*_h(Sh,Math.abs(C)),n=yh(E)*S+w,a=xh(E)*M+T;break;case uh.R:o=n=t[c++],s=a=t[c++],p=2*t[c++]+2*t[c++];break;case uh.Z:var D=o-n;g=s-a,p=Math.sqrt(D*D+g*g),n=o,a=s}p>=0&&(l[u++]=p,h+=p)}return this._pathLen=h,h},t.prototype.rebuildPath=function(t,e){var r,i,n,a,o,s,l,h,u=this.data,c=this._ux,d=this._uy,f=this._len,p=e<1,m=0,g=0;if(!p||(this._pathSegLen||this._calculateLength(),l=this._pathSegLen,h=e*this._pathLen))t:for(var _=0;_<f;){var v=u[_++],y=1===_;switch(y&&(r=n=u[_],i=a=u[_+1]),v){case uh.M:r=n=u[_++],i=a=u[_++],t.moveTo(n,a);break;case uh.L:if(o=u[_++],s=u[_++],wh(o-n)>c||wh(s-a)>d||_===f-1){if(p){if(m+(H=l[g++])>h){var x=(h-m)/H;t.lineTo(n*(1-x)+o*x,a*(1-x)+s*x);break t}m+=H}t.lineTo(o,s),n=o,a=s}break;case uh.C:var b=u[_++],w=u[_++],T=u[_++],S=u[_++],M=u[_++],A=u[_++];if(p){if(m+(H=l[g++])>h){Vl(n,b,T,M,x=(h-m)/H,ch),Vl(a,w,S,A,x,dh),t.bezierCurveTo(ch[1],dh[1],ch[2],dh[2],ch[3],dh[3]);break t}m+=H}t.bezierCurveTo(b,w,T,S,M,A),n=M,a=A;break;case uh.Q:if(b=u[_++],w=u[_++],T=u[_++],S=u[_++],p){if(m+(H=l[g++])>h){Zl(n,b,T,x=(h-m)/H,ch),Zl(a,w,S,x,dh),t.quadraticCurveTo(ch[1],dh[1],ch[2],dh[2]);break t}m+=H}t.quadraticCurveTo(b,w,T,S),n=T,a=S;break;case uh.A:var C=u[_++],E=u[_++],D=u[_++],L=u[_++],P=u[_++],O=u[_++],N=u[_++],I=!u[_++],R=D>L?D:L,B=wh(D-L)>.001,F=P+O,z=!1;if(p&&(m+(H=l[g++])>h&&(F=P+O*(h-m)/H,z=!0),m+=H),B&&t.ellipse?t.ellipse(C,E,D,L,N,P,F,I):t.arc(C,E,R,P,F,I),z)break t;y&&(r=yh(P)*D+C,i=xh(P)*L+E),n=yh(F)*D+C,a=xh(F)*L+E;break;case uh.R:r=n=u[_],i=a=u[_+1],o=u[_++],s=u[_++];var k=u[_++],G=u[_++];if(p){if(m+(H=l[g++])>h){var U=h-m;t.moveTo(o,s),t.lineTo(o+_h(U,k),s),(U-=k)>0&&t.lineTo(o+k,s+_h(U,G)),(U-=G)>0&&t.lineTo(o+vh(k-U,0),s+G),(U-=k)>0&&t.lineTo(o,s+vh(G-U,0));break t}m+=H}t.rect(o,s,k,G);break;case uh.Z:if(p){var H;if(m+(H=l[g++])>h){x=(h-m)/H,t.lineTo(n*(1-x)+r*x,a*(1-x)+i*x);break t}m+=H}t.closePath(),n=r,a=i}}},t.CMD=uh,t.initDefaultProps=function(){var e=t.prototype;e._saveData=!0,e._needsDash=!1,e._dashOffset=0,e._dashIdx=0,e._dashSum=0,e._ux=0,e._uy=0}(),t}();function Lh(t,e,r,i,n,a,o){if(0===n)return!1;var s,l=n;if(o>e+l&&o>i+l||o<e-l&&o<i-l||a>t+l&&a>r+l||a<t-l&&a<r-l)return!1;if(t===r)return Math.abs(a-t)<=l/2;var h=(s=(e-i)/(t-r))*a-o+(t*i-r*e)/(t-r);return h*h/(s*s+1)<=l/2*l/2}function Ph(t,e,r,i,n,a,o,s,l,h,u){if(0===l)return!1;var c=l;return!(u>e+c&&u>i+c&&u>a+c&&u>s+c||u<e-c&&u<i-c&&u<a-c&&u<s-c||h>t+c&&h>r+c&&h>n+c&&h>o+c||h<t-c&&h<r-c&&h<n-c&&h<o-c)&&function(t,e,r,i,n,a,o,s,l,h,u){var c,d,f,p,m,g=.005,_=1/0;Rl[0]=l,Rl[1]=h;for(var v=0;v<1;v+=.05)Bl[0]=Gl(t,r,n,o,v),Bl[1]=Gl(e,i,a,s,v),(p=ks(Rl,Bl))<_&&(c=v,_=p);_=1/0;for(var y=0;y<32&&!(g<Ol);y++)d=c-g,f=c+g,Bl[0]=Gl(t,r,n,o,d),Bl[1]=Gl(e,i,a,s,d),p=ks(Bl,Rl),d>=0&&p<_?(c=d,_=p):(Fl[0]=Gl(t,r,n,o,f),Fl[1]=Gl(e,i,a,s,f),m=ks(Fl,Rl),f<=1&&m<_?(c=f,_=m):g*=.5);return Pl(_)}(t,e,r,i,n,a,o,s,h,u)<=c/2}function Oh(t,e,r,i,n,a,o,s,l){if(0===o)return!1;var h=o;return!(l>e+h&&l>i+h&&l>a+h||l<e-h&&l<i-h&&l<a-h||s>t+h&&s>r+h&&s>n+h||s<t-h&&s<r-h&&s<n-h)&&function(t,e,r,i,n,a,o,s,l){var h,u=.005,c=1/0;Rl[0]=o,Rl[1]=s;for(var d=0;d<1;d+=.05)Bl[0]=jl(t,r,n,d),Bl[1]=jl(e,i,a,d),(g=ks(Rl,Bl))<c&&(h=d,c=g);c=1/0;for(var f=0;f<32&&!(u<Ol);f++){var p=h-u,m=h+u;Bl[0]=jl(t,r,n,p),Bl[1]=jl(e,i,a,p);var g=ks(Bl,Rl);if(p>=0&&g<c)h=p,c=g;else{Fl[0]=jl(t,r,n,m),Fl[1]=jl(e,i,a,m);var _=ks(Fl,Rl);m<=1&&_<c?(h=m,c=_):u*=.5}}return Pl(c)}(t,e,r,i,n,a,s,l)<=h/2}var Nh=2*Math.PI;function Ih(t){return(t%=Nh)<0&&(t+=Nh),t}var Rh=2*Math.PI;function Bh(t,e,r,i,n,a,o,s,l){if(0===o)return!1;var h=o;s-=t,l-=e;var u=Math.sqrt(s*s+l*l);if(u-h>r||u+h<r)return!1;if(Math.abs(i-n)%Rh<1e-4)return!0;if(a){var c=i;i=Ih(n),n=Ih(c)}else i=Ih(i),n=Ih(n);i>n&&(n+=Rh);var d=Math.atan2(l,s);return d<0&&(d+=Rh),d>=i&&d<=n||d+Rh>=i&&d+Rh<=n}function Fh(t,e,r,i,n,a){if(a>e&&a>i||a<e&&a<i)return 0;if(i===e)return 0;var o=(a-e)/(i-e),s=i<e?1:-1;1!==o&&0!==o||(s=i<e?.5:-.5);var l=o*(r-t)+t;return l===n?1/0:l>n?s:0}var zh=Dh.CMD,kh=2*Math.PI,Gh=[-1,-1,-1],Uh=[-1,-1];function Hh(){var t=Uh[0];Uh[0]=Uh[1],Uh[1]=t}function Vh(t,e,r,i,n,a,o,s,l,h){if(h>e&&h>i&&h>a&&h>s||h<e&&h<i&&h<a&&h<s)return 0;var u=function(t,e,r,i,n,a){var o=i+3*(e-r)-t,s=3*(r-2*e+t),l=3*(e-t),h=t-n,u=s*s-3*o*l,c=s*l-9*o*h,d=l*l-3*s*h,f=0;if(zl(u)&&zl(c))zl(s)?a[0]=0:(S=-l/s)>=0&&S<=1&&(a[f++]=S);else{var p=c*c-4*u*d;if(zl(p)){var m=c/u,g=-m/2;(S=-s/o+m)>=0&&S<=1&&(a[f++]=S),g>=0&&g<=1&&(a[f++]=g)}else if(p>0){var _=Pl(p),v=u*s+1.5*o*(-c+_),y=u*s+1.5*o*(-c-_);(S=(-s-((v=v<0?-Ll(-v,Il):Ll(v,Il))+(y=y<0?-Ll(-y,Il):Ll(y,Il))))/(3*o))>=0&&S<=1&&(a[f++]=S)}else{var x=(2*u*s-3*o*c)/(2*Pl(u*u*u)),b=Math.acos(x)/3,w=Pl(u),T=Math.cos(b),S=(-s-2*w*T)/(3*o),M=(g=(-s+w*(T+Nl*Math.sin(b)))/(3*o),(-s+w*(T-Nl*Math.sin(b)))/(3*o));S>=0&&S<=1&&(a[f++]=S),g>=0&&g<=1&&(a[f++]=g),M>=0&&M<=1&&(a[f++]=M)}}return f}(e,i,a,s,h,Gh);if(0===u)return 0;for(var c=0,d=-1,f=void 0,p=void 0,m=0;m<u;m++){var g=Gh[m],_=0===g||1===g?.5:1;Gl(t,r,n,o,g)<l||(d<0&&(d=Hl(e,i,a,s,Uh),Uh[1]<Uh[0]&&d>1&&Hh(),f=Gl(e,i,a,s,Uh[0]),d>1&&(p=Gl(e,i,a,s,Uh[1]))),2===d?g<Uh[0]?c+=f<e?_:-_:g<Uh[1]?c+=p<f?_:-_:c+=s<p?_:-_:g<Uh[0]?c+=f<e?_:-_:c+=s<f?_:-_)}return c}function Wh(t,e,r,i,n,a,o,s){if(s>e&&s>i&&s>a||s<e&&s<i&&s<a)return 0;var l=function(t,e,r,i,n){var a=t-2*e+r,o=2*(e-t),s=t-i,l=0;if(zl(a))kl(o)&&(u=-s/o)>=0&&u<=1&&(n[l++]=u);else{var h=o*o-4*a*s;if(zl(h))(u=-o/(2*a))>=0&&u<=1&&(n[l++]=u);else if(h>0){var u,c=Pl(h),d=(-o-c)/(2*a);(u=(-o+c)/(2*a))>=0&&u<=1&&(n[l++]=u),d>=0&&d<=1&&(n[l++]=d)}}return l}(e,i,a,s,Gh);if(0===l)return 0;var h=ql(e,i,a);if(h>=0&&h<=1){for(var u=0,c=jl(e,i,a,h),d=0;d<l;d++){var f=0===Gh[d]||1===Gh[d]?.5:1;jl(t,r,n,Gh[d])<o||(Gh[d]<h?u+=c<e?f:-f:u+=a<c?f:-f)}return u}return f=0===Gh[0]||1===Gh[0]?.5:1,jl(t,r,n,Gh[0])<o?0:a<e?f:-f}function jh(t,e,r,i,n,a,o,s){if((s-=e)>r||s<-r)return 0;var l=Math.sqrt(r*r-s*s);Gh[0]=-l,Gh[1]=l;var h=Math.abs(i-n);if(h<1e-4)return 0;if(h>=kh-1e-4){i=0,n=kh;var u=a?1:-1;return o>=Gh[0]+t&&o<=Gh[1]+t?u:0}if(i>n){var c=i;i=n,n=c}i<0&&(i+=kh,n+=kh);for(var d=0,f=0;f<2;f++){var p=Gh[f];if(p+t>o){var m=Math.atan2(s,p);u=a?1:-1,m<0&&(m=kh+m),(m>=i&&m<=n||m+kh>=i&&m+kh<=n)&&(m>Math.PI/2&&m<1.5*Math.PI&&(u=-u),d+=u)}}return d}function Xh(t,e,r,i,n){for(var a,o,s,l,h=t.data,u=t.len(),c=0,d=0,f=0,p=0,m=0,g=0;g<u;){var _=h[g++],v=1===g;switch(_===zh.M&&g>1&&(r||(c+=Fh(d,f,p,m,i,n))),v&&(p=d=h[g],m=f=h[g+1]),_){case zh.M:d=p=h[g++],f=m=h[g++];break;case zh.L:if(r){if(Lh(d,f,h[g],h[g+1],e,i,n))return!0}else c+=Fh(d,f,h[g],h[g+1],i,n)||0;d=h[g++],f=h[g++];break;case zh.C:if(r){if(Ph(d,f,h[g++],h[g++],h[g++],h[g++],h[g],h[g+1],e,i,n))return!0}else c+=Vh(d,f,h[g++],h[g++],h[g++],h[g++],h[g],h[g+1],i,n)||0;d=h[g++],f=h[g++];break;case zh.Q:if(r){if(Oh(d,f,h[g++],h[g++],h[g],h[g+1],e,i,n))return!0}else c+=Wh(d,f,h[g++],h[g++],h[g],h[g+1],i,n)||0;d=h[g++],f=h[g++];break;case zh.A:var y=h[g++],x=h[g++],b=h[g++],w=h[g++],T=h[g++],S=h[g++];g+=1;var M=!!(1-h[g++]);a=Math.cos(T)*b+y,o=Math.sin(T)*w+x,v?(p=a,m=o):c+=Fh(d,f,a,o,i,n);var A=(i-y)*w/b+y;if(r){if(Bh(y,x,w,T,T+S,M,e,A,n))return!0}else c+=jh(y,x,w,T,T+S,M,A,n);d=Math.cos(T+S)*b+y,f=Math.sin(T+S)*w+x;break;case zh.R:if(p=d=h[g++],m=f=h[g++],a=p+h[g++],o=m+h[g++],r){if(Lh(p,m,a,m,e,i,n)||Lh(a,m,a,o,e,i,n)||Lh(a,o,p,o,e,i,n)||Lh(p,o,p,m,e,i,n))return!0}else c+=Fh(a,m,a,o,i,n),c+=Fh(p,o,p,m,i,n);break;case zh.Z:if(r){if(Lh(d,f,p,m,e,i,n))return!0}else c+=Fh(d,f,p,m,i,n);d=p,f=m}}return r||(s=f,l=m,Math.abs(s-l)<1e-4)||(c+=Fh(d,f,p,m,i,n)||0),0!==c}var qh=Sa({fill:"#000",stroke:null,strokePercent:1,fillOpacity:1,strokeOpacity:1,lineDashOffset:0,lineWidth:1,lineCap:"butt",miterLimit:10,strokeNoScale:!1,strokeFirst:!1},Tl),Zh={style:Sa({fill:!0,stroke:!0,strokePercent:!0,fillOpacity:!0,strokeOpacity:!0,lineDashOffset:!0,lineWidth:!0,miterLimit:!0},Sl.style)},Yh=["x","y","rotation","scaleX","scaleY","originX","originY","invisible","culling","z","z2","zlevel","parent"];const Kh=function(t){function e(e){return t.call(this,e)||this}var r;return Xo(e,t),e.prototype.update=function(){var r=this;t.prototype.update.call(this);var i=this.style;if(i.decal){var n=this._decalEl=this._decalEl||new e;n.buildPath===e.prototype.buildPath&&(n.buildPath=function(t){r.buildPath(t,r.shape)}),n.silent=!0;var a=n.style;for(var o in i)a[o]!==i[o]&&(a[o]=i[o]);a.fill=i.fill?i.decal:null,a.decal=null,a.shadowColor=null,i.strokeFirst&&(a.stroke=null);for(var s=0;s<Yh.length;++s)n[Yh[s]]=this[Yh[s]];n.__dirty|=bl.REDARAW_BIT}else this._decalEl&&(this._decalEl=null)},e.prototype.getDecalElement=function(){return this._decalEl},e.prototype._init=function(e){var r=La(e);this.shape=this.getDefaultShape();var i=this.getDefaultStyle();i&&this.useStyle(i);for(var n=0;n<r.length;n++){var a=r[n],o=e[a];"style"===a?this.style?Ta(this.style,o):this.useStyle(o):"shape"===a?Ta(this.shape,o):t.prototype.attrKV.call(this,a,o)}this.style||this.useStyle({})},e.prototype.getDefaultStyle=function(){return null},e.prototype.getDefaultShape=function(){return{}},e.prototype.canBeInsideText=function(){return this.hasFill()},e.prototype.getInsideTextFill=function(){var t=this.style.fill;if("none"!==t){if(Na(t)){var e=sa(t,0);return e>.5?ol:e>.2?"#eee":sl}if(t)return sl}return ol},e.prototype.getInsideTextStroke=function(t){var e=this.style.fill;if(Na(e)){var r=this.__zr;if(!(!r||!r.isDarkMode())==sa(t,0)<.4)return e}},e.prototype.buildPath=function(t,e,r){},e.prototype.pathUpdated=function(){this.__dirty&=~e.SHAPE_CHANGED_BIT},e.prototype.createPathProxy=function(){this.path=new Dh(!1)},e.prototype.hasStroke=function(){var t=this.style,e=t.stroke;return!(null==e||"none"===e||!(t.lineWidth>0))},e.prototype.hasFill=function(){var t=this.style.fill;return null!=t&&"none"!==t},e.prototype.getBoundingRect=function(){var t=this._rect,r=this.style,i=!t;if(i){var n=!1;this.path||(n=!0,this.createPathProxy());var a=this.path;(n||this.__dirty&e.SHAPE_CHANGED_BIT)&&(a.beginPath(),this.buildPath(a,this.shape,!1),this.pathUpdated()),t=a.getBoundingRect()}if(this._rect=t,this.hasStroke()&&this.path&&this.path.len()>0){var o=this._rectWithStroke||(this._rectWithStroke=t.clone());if(this.__dirty||i){o.copy(t);var s=r.strokeNoScale?this.getLineScale():1,l=r.lineWidth;if(!this.hasFill()){var h=this.strokeContainThreshold;l=Math.max(l,null==h?4:h)}s>1e-10&&(o.width+=l/s,o.height+=l/s,o.x-=l/s/2,o.y-=l/s/2)}return o}return t},e.prototype.contain=function(t,e){var r=this.transformCoordToLocal(t,e),i=this.getBoundingRect(),n=this.style;if(t=r[0],e=r[1],i.contain(t,e)){var a=this.path;if(this.hasStroke()){var o=n.lineWidth,s=n.strokeNoScale?this.getLineScale():1;if(s>1e-10&&(this.hasFill()||(o=Math.max(o,this.strokeContainThreshold)),function(t,e,r,i){return Xh(t,e,!0,r,i)}(a,o/s,t,e)))return!0}if(this.hasFill())return function(t,e,r){return Xh(t,0,!1,e,r)}(a,t,e)}return!1},e.prototype.dirtyShape=function(){this.__dirty|=e.SHAPE_CHANGED_BIT,this._rect&&(this._rect=null),this._decalEl&&this._decalEl.dirtyShape(),this.markRedraw()},e.prototype.dirty=function(){this.dirtyStyle(),this.dirtyShape()},e.prototype.animateShape=function(t){return this.animate("shape",t)},e.prototype.updateDuringAnimation=function(t){"style"===t?this.dirtyStyle():"shape"===t?this.dirtyShape():this.markRedraw()},e.prototype.attrKV=function(e,r){"shape"===e?this.setShape(r):t.prototype.attrKV.call(this,e,r)},e.prototype.setShape=function(t,e){var r=this.shape;return r||(r=this.shape={}),"string"==typeof t?r[t]=e:Ta(r,t),this.dirtyShape(),this},e.prototype.shapeChanged=function(){return!!(this.__dirty&e.SHAPE_CHANGED_BIT)},e.prototype.createStyle=function(t){return ja(qh,t)},e.prototype._innerSaveToNormal=function(e){t.prototype._innerSaveToNormal.call(this,e);var r=this._normalState;e.shape&&!r.shape&&(r.shape=Ta({},this.shape))},e.prototype._applyStateObj=function(e,r,i,n,a,o){t.prototype._applyStateObj.call(this,e,r,i,n,a,o);var s,l=!(r&&n);if(r&&r.shape?a?n?s=r.shape:(s=Ta({},i.shape),Ta(s,r.shape)):(s=Ta({},n?this.shape:i.shape),Ta(s,r.shape)):l&&(s=i.shape),s)if(a){this.shape=Ta({},this.shape);for(var h={},u=La(s),c=0;c<u.length;c++){var d=u[c];"object"==typeof s[d]?this.shape[d]=s[d]:h[d]=s[d]}this._transitionState(e,{shape:h},o)}else this.shape=s,this.dirtyShape()},e.prototype._mergeStates=function(e){for(var r,i=t.prototype._mergeStates.call(this,e),n=0;n<e.length;n++){var a=e[n];a.shape&&(r=r||{},this._mergeStyle(r,a.shape))}return r&&(i.shape=r),i},e.prototype.getAnimationStyleProps=function(){return Zh},e.prototype.isZeroArea=function(){return!1},e.extend=function(t){var r=function(e){function r(r){var i=e.call(this,r)||this;return t.init&&t.init.call(i,r),i}return Xo(r,e),r.prototype.getDefaultStyle=function(){return ba(t.style)},r.prototype.getDefaultShape=function(){return ba(t.shape)},r}(e);for(var i in t)"function"==typeof t[i]&&(r.prototype[i]=t[i]);return r},e.SHAPE_CHANGED_BIT=4,e.initDefaultProps=((r=e.prototype).type="path",r.strokeContainThreshold=5,r.segmentIgnoreThreshold=0,r.subPixelOptimize=!1,r.autoBatch=!1,void(r.__dirty=bl.REDARAW_BIT|Dl.STYLE_CHANGED_BIT|e.SHAPE_CHANGED_BIT)),e}(Dl);var Qh=Sa({strokeFirst:!0,font:fs,x:0,y:0,textAlign:"left",textBaseline:"top",miterLimit:2},qh),Jh=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Xo(e,t),e.prototype.hasStroke=function(){var t=this.style,e=t.stroke;return null!=e&&"none"!==e&&t.lineWidth>0},e.prototype.hasFill=function(){var t=this.style.fill;return null!=t&&"none"!==t},e.prototype.createStyle=function(t){return ja(Qh,t)},e.prototype.setBoundingRect=function(t){this._rect=t},e.prototype.getBoundingRect=function(){var t=this.style;if(!this._rect){var e=t.text;null!=e?e+="":e="";var r=function(t,e,r,i){var n=((t||"")+"").split("\n");if(1===n.length)return gs(n[0],e,r,i);for(var a=new hs(0,0,0,0),o=0;o<n.length;o++){var s=gs(n[o],e,r,i);0===o?a.copy(s):a.union(s)}return a}(e,t.font,t.textAlign,t.textBaseline);if(r.x+=t.x||0,r.y+=t.y||0,this.hasStroke()){var i=t.lineWidth;r.x-=i/2,r.y-=i/2,r.width+=i,r.height+=i}this._rect=r}return this._rect},e.initDefaultProps=void(e.prototype.dirtyRectTolerance=10),e}(Dl);Jh.prototype.type="tspan";const $h=Jh;var tu=Sa({x:0,y:0},Tl),eu={style:Sa({x:!0,y:!0,width:!0,height:!0,sx:!0,sy:!0,sWidth:!0,sHeight:!0},Sl.style)},ru=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Xo(e,t),e.prototype.createStyle=function(t){return ja(tu,t)},e.prototype._getSize=function(t){var e=this.style,r=e[t];if(null!=r)return r;var i,n=(i=e.image)&&"string"!=typeof i&&i.width&&i.height?e.image:this.__image;if(!n)return 0;var a="width"===t?"height":"width",o=e[a];return null==o?n[t]:n[t]/n[a]*o},e.prototype.getWidth=function(){return this._getSize("width")},e.prototype.getHeight=function(){return this._getSize("height")},e.prototype.getAnimationStyleProps=function(){return eu},e.prototype.getBoundingRect=function(){var t=this.style;return this._rect||(this._rect=new hs(t.x||0,t.y||0,this.getWidth(),this.getHeight())),this._rect},e}(Dl);ru.prototype.type="image";const iu=ru;var nu=Math.round;function au(t,e,r){if(!e)return t;var i=nu(2*t);return(i+nu(e))%2==0?i/2:(i+(r?1:-1))/2}var ou=function(){this.x=0,this.y=0,this.width=0,this.height=0},su={},lu=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultShape=function(){return new ou},e.prototype.buildPath=function(t,e){var r,i,n,a;if(this.subPixelOptimize){var o=function(t,e,r){if(e){var i=e.x,n=e.y,a=e.width,o=e.height;t.x=i,t.y=n,t.width=a,t.height=o;var s=r&&r.lineWidth;return s?(t.x=au(i,s,!0),t.y=au(n,s,!0),t.width=Math.max(au(i+a,s,!1)-t.x,0===a?0:1),t.height=Math.max(au(n+o,s,!1)-t.y,0===o?0:1),t):t}}(su,e,this.style);r=o.x,i=o.y,n=o.width,a=o.height,o.r=e.r,e=o}else r=e.x,i=e.y,n=e.width,a=e.height;e.r?function(t,e){var r,i,n,a,o,s=e.x,l=e.y,h=e.width,u=e.height,c=e.r;h<0&&(s+=h,h=-h),u<0&&(l+=u,u=-u),"number"==typeof c?r=i=n=a=c:c instanceof Array?1===c.length?r=i=n=a=c[0]:2===c.length?(r=n=c[0],i=a=c[1]):3===c.length?(r=c[0],i=a=c[1],n=c[2]):(r=c[0],i=c[1],n=c[2],a=c[3]):r=i=n=a=0,r+i>h&&(r*=h/(o=r+i),i*=h/o),n+a>h&&(n*=h/(o=n+a),a*=h/o),i+n>u&&(i*=u/(o=i+n),n*=u/o),r+a>u&&(r*=u/(o=r+a),a*=u/o),t.moveTo(s+r,l),t.lineTo(s+h-i,l),0!==i&&t.arc(s+h-i,l+i,i,-Math.PI/2,0),t.lineTo(s+h,l+u-n),0!==n&&t.arc(s+h-n,l+u-n,n,0,Math.PI/2),t.lineTo(s+a,l+u),0!==a&&t.arc(s+a,l+u-a,a,Math.PI/2,Math.PI),t.lineTo(s,l+r),0!==r&&t.arc(s+r,l+r,r,Math.PI,1.5*Math.PI)}(t,e):t.rect(r,i,n,a)},e.prototype.isZeroArea=function(){return!this.shape.width||!this.shape.height},e}(Kh);lu.prototype.type="rect";const hu=lu;var uu={fill:"#000"},cu={style:Sa({fill:!0,stroke:!0,fillOpacity:!0,strokeOpacity:!0,lineWidth:!0,fontSize:!0,lineHeight:!0,width:!0,height:!0,textShadowColor:!0,textShadowBlur:!0,textShadowOffsetX:!0,textShadowOffsetY:!0,backgroundColor:!0,padding:!0,borderColor:!0,borderWidth:!0,borderRadius:!0},Sl.style)},du=function(t){function e(e){var r=t.call(this)||this;return r.type="text",r._children=[],r._defaultStyle=uu,r.attr(e),r}return Xo(e,t),e.prototype.childrenRef=function(){return this._children},e.prototype.update=function(){this.styleChanged()&&this._updateSubTexts();for(var e=0;e<this._children.length;e++){var r=this._children[e];r.zlevel=this.zlevel,r.z=this.z,r.z2=this.z2,r.culling=this.culling,r.cursor=this.cursor,r.invisible=this.invisible}var i=this.attachedTransform;if(i){i.updateTransform();var n=i.transform;n?(this.transform=this.transform||[],Ko(this.transform,n)):this.transform=null}else t.prototype.update.call(this)},e.prototype.getComputedTransform=function(){return this.__hostTarget&&(this.__hostTarget.getComputedTransform(),this.__hostTarget.updateInnerText(!0)),this.attachedTransform?this.attachedTransform.getComputedTransform():t.prototype.getComputedTransform.call(this)},e.prototype._updateSubTexts=function(){var t;this._childCursor=0,mu(t=this.style),Ea(t.rich,mu),this.style.rich?this._updateRichTexts():this._updatePlainTexts(),this._children.length=this._childCursor,this.styleUpdated()},e.prototype.addSelfToZr=function(e){t.prototype.addSelfToZr.call(this,e);for(var r=0;r<this._children.length;r++)this._children[r].__zr=e},e.prototype.removeSelfFromZr=function(e){t.prototype.removeSelfFromZr.call(this,e);for(var r=0;r<this._children.length;r++)this._children[r].__zr=null},e.prototype.getBoundingRect=function(){if(this.styleChanged()&&this._updateSubTexts(),!this._rect){for(var t=new hs(0,0,0,0),e=this._children,r=[],i=null,n=0;n<e.length;n++){var a=e[n],o=a.getBoundingRect(),s=a.getLocalTransform(r);s?(t.copy(o),t.applyTransform(s),(i=i||t.clone()).union(t)):(i=i||o.clone()).union(o)}this._rect=i||t}return this._rect},e.prototype.setDefaultTextStyle=function(t){this._defaultStyle=t||uu},e.prototype.setTextContent=function(t){throw new Error("Can't attach text on another text")},e.prototype._mergeStyle=function(t,e){if(!e)return t;var r=e.rich,i=t.rich||r&&{};return Ta(t,e),r&&i?(this._mergeRich(i,r),t.rich=i):i&&(t.rich=i),t},e.prototype._mergeRich=function(t,e){for(var r=La(e),i=0;i<r.length;i++){var n=r[i];t[n]=t[n]||{},Ta(t[n],e[n])}},e.prototype.getAnimationStyleProps=function(){return cu},e.prototype._getOrCreateChild=function(t){var e=this._children[this._childCursor];return e&&e instanceof t||(e=new t),this._children[this._childCursor++]=e,e.__zr=this.__zr,e.parent=this,e},e.prototype._updatePlainTexts=function(){var t=this.style,e=t.font||fs,r=t.padding,i=function(t,e){null!=t&&(t+="");var r,i=e.overflow,n=e.padding,a=e.font,o="truncate"===i,s=ys(a),l=Fa(e.lineHeight,s),h="truncate"===e.lineOverflow,u=e.width,c=(r=null!=u&&"break"===i||"breakAll"===i?t?Os(t,e.font,u,"breakAll"===i,0).lines:[]:t?t.split("\n"):[]).length*l,d=Fa(e.height,c);if(c>d&&h){var f=Math.floor(d/l);r=r.slice(0,f)}var p=d,m=u;if(n&&(p+=n[0]+n[2],null!=m&&(m+=n[1]+n[3])),t&&o&&null!=m)for(var g=Ts(u,a,e.ellipsis,{minChar:e.truncateMinChar,placeholder:e.placeholder}),_=0;_<r.length;_++)r[_]=Ss(r[_],g);if(null==u){var v=0;for(_=0;_<r.length;_++)v=Math.max(ms(r[_],a),v);u=v}return{lines:r,height:d,outerHeight:p,lineHeight:l,calculatedLineHeight:s,contentHeight:c,width:u}}(vu(t),t),n=yu(t),a=!!t.backgroundColor,o=i.outerHeight,s=i.lines,l=i.lineHeight,h=this._defaultStyle,u=t.x||0,c=t.y||0,d=t.align||h.align||"left",f=t.verticalAlign||h.verticalAlign||"top",p=u,m=vs(c,i.contentHeight,f);if(n||r){var g=i.width;r&&(g+=r[1]+r[3]);var _=_s(u,g,d),v=vs(c,o,f);n&&this._renderBackground(t,t,_,v,g,o)}m+=l/2,r&&(p=_u(u,d,r),"top"===f?m+=r[0]:"bottom"===f&&(m-=r[2]));for(var y,x=0,b=!1,w=(null==(y="fill"in t?t.fill:(b=!0,h.fill))||"none"===y?null:y.image||y.colorStops?"#000":y),T=(gu("stroke"in t?t.stroke:a||h.autoStroke&&!b?null:(x=2,h.stroke))),S=t.textShadowBlur>0,M=null!=t.width&&("truncate"===t.overflow||"break"===t.overflow||"breakAll"===t.overflow),A=i.calculatedLineHeight,C=0;C<s.length;C++){var E=this._getOrCreateChild($h),D=E.createStyle();E.useStyle(D),D.text=s[C],D.x=p,D.y=m,d&&(D.textAlign=d),D.textBaseline="middle",D.opacity=t.opacity,D.strokeFirst=!0,S&&(D.shadowBlur=t.textShadowBlur||0,D.shadowColor=t.textShadowColor||"transparent",D.shadowOffsetX=t.textShadowOffsetX||0,D.shadowOffsetY=t.textShadowOffsetY||0),T&&(D.stroke=T,D.lineWidth=t.lineWidth||x,D.lineDash=t.lineDash,D.lineDashOffset=t.lineDashOffset||0),w&&(D.fill=w),D.font=e,m+=l,M&&E.setBoundingRect(new hs(_s(D.x,t.width,D.textAlign),vs(D.y,A,D.textBaseline),t.width,A))}},e.prototype._updateRichTexts=function(){var t=this.style,e=function(t,e){var r=new Es;if(null!=t&&(t+=""),!t)return r;for(var i,n=e.width,a=e.height,o=e.overflow,s="break"!==o&&"breakAll"!==o||null==n?null:{width:n,accumWidth:0,breakAll:"breakAll"===o},l=bs.lastIndex=0;null!=(i=bs.exec(t));){var h=i.index;h>l&&Ds(r,t.substring(l,h),e,s),Ds(r,i[2],e,s,i[1]),l=bs.lastIndex}l<t.length&&Ds(r,t.substring(l,t.length),e,s);var u,c=[],d=0,f=0,p=e.padding,m="truncate"===o,g="truncate"===e.lineOverflow;function _(t,e,r){t.width=e,t.lineHeight=r,d+=r,f=Math.max(f,e)}t:for(var v=0;v<r.lines.length;v++){for(var y=r.lines[v],x=0,b=0,w=0;w<y.tokens.length;w++){var T=(N=y.tokens[w]).styleName&&e.rich[N.styleName]||{},S=N.textPadding=T.padding,M=S?S[1]+S[3]:0,A=N.font=T.font||e.font;N.contentHeight=ys(A);var C=Fa(T.height,N.contentHeight);if(N.innerHeight=C,S&&(C+=S[0]+S[2]),N.height=C,N.lineHeight=za(T.lineHeight,e.lineHeight,C),N.align=T&&T.align||e.align,N.verticalAlign=T&&T.verticalAlign||"middle",g&&null!=a&&d+N.lineHeight>a){w>0?(y.tokens=y.tokens.slice(0,w),_(y,b,x),r.lines=r.lines.slice(0,v+1)):r.lines=r.lines.slice(0,v);break t}var E=T.width,D=null==E||"auto"===E;if("string"==typeof E&&"%"===E.charAt(E.length-1))N.percentWidth=E,c.push(N),N.contentWidth=ms(N.text,A);else{if(D){var L=T.backgroundColor,P=L&&L.image;P&&((u=P=Yo(P))&&u.width&&u.height)&&(N.width=Math.max(N.width,P.width*C/P.height))}var O=m&&null!=n?n-b:null;null!=O&&O<N.width?!D||O<M?(N.text="",N.width=N.contentWidth=0):(N.text=ws(N.text,O-M,A,e.ellipsis,{minChar:e.truncateMinChar}),N.width=N.contentWidth=ms(N.text,A)):N.contentWidth=ms(N.text,A)}N.width+=M,b+=N.width,T&&(x=Math.max(x,N.lineHeight))}_(y,b,x)}for(r.outerWidth=r.width=Fa(n,f),r.outerHeight=r.height=Fa(a,d),r.contentHeight=d,r.contentWidth=f,p&&(r.outerWidth+=p[1]+p[3],r.outerHeight+=p[0]+p[2]),v=0;v<c.length;v++){var N,I=(N=c[v]).percentWidth;N.width=parseInt(I,10)/100*r.width}return r}(vu(t),t),r=e.width,i=e.outerWidth,n=e.outerHeight,a=t.padding,o=t.x||0,s=t.y||0,l=this._defaultStyle,h=t.align||l.align,u=t.verticalAlign||l.verticalAlign,c=_s(o,i,h),d=vs(s,n,u),f=c,p=d;a&&(f+=a[3],p+=a[0]);var m=f+r;yu(t)&&this._renderBackground(t,t,c,d,i,n);for(var g=!!t.backgroundColor,_=0;_<e.lines.length;_++){for(var v=e.lines[_],y=v.tokens,x=y.length,b=v.lineHeight,w=v.width,T=0,S=f,M=m,A=x-1,C=void 0;T<x&&(!(C=y[T]).align||"left"===C.align);)this._placeToken(C,t,b,p,S,"left",g),w-=C.width,S+=C.width,T++;for(;A>=0&&"right"===(C=y[A]).align;)this._placeToken(C,t,b,p,M,"right",g),w-=C.width,M-=C.width,A--;for(S+=(r-(S-f)-(m-M)-w)/2;T<=A;)C=y[T],this._placeToken(C,t,b,p,S+C.width/2,"center",g),S+=C.width,T++;p+=b}},e.prototype._placeToken=function(t,e,r,i,n,a,o){var s=e.rich[t.styleName]||{};s.text=t.text;var l=t.verticalAlign,h=i+r/2;"top"===l?h=i+t.height/2:"bottom"===l&&(h=i+r-t.height/2),!t.isLineHolder&&yu(s)&&this._renderBackground(s,e,"right"===a?n-t.width:"center"===a?n-t.width/2:n,h-t.height/2,t.width,t.height);var u=!!s.backgroundColor,c=t.textPadding;c&&(n=_u(n,a,c),h-=t.height/2-c[0]-t.innerHeight/2);var d=this._getOrCreateChild($h),f=d.createStyle();d.useStyle(f);var p=this._defaultStyle,m=!1,g=0,_=gu("fill"in s?s.fill:"fill"in e?e.fill:(m=!0,p.fill)),v=gu("stroke"in s?s.stroke:"stroke"in e?e.stroke:u||o||p.autoStroke&&!m?null:(g=2,p.stroke)),y=s.textShadowBlur>0||e.textShadowBlur>0;f.text=t.text,f.x=n,f.y=h,y&&(f.shadowBlur=s.textShadowBlur||e.textShadowBlur||0,f.shadowColor=s.textShadowColor||e.textShadowColor||"transparent",f.shadowOffsetX=s.textShadowOffsetX||e.textShadowOffsetX||0,f.shadowOffsetY=s.textShadowOffsetY||e.textShadowOffsetY||0),f.textAlign=a,f.textBaseline="middle",f.font=t.font||fs,f.opacity=za(s.opacity,e.opacity,1),v&&(f.lineWidth=za(s.lineWidth,e.lineWidth,g),f.lineDash=Fa(s.lineDash,e.lineDash),f.lineDashOffset=e.lineDashOffset||0,f.stroke=v),_&&(f.fill=_);var x=t.contentWidth,b=t.contentHeight;d.setBoundingRect(new hs(_s(f.x,x,f.textAlign),vs(f.y,b,f.textBaseline),x,b))},e.prototype._renderBackground=function(t,e,r,i,n,a){var o,s,l,h=t.backgroundColor,u=t.borderWidth,c=t.borderColor,d=Na(h),f=t.borderRadius,p=this;if(d||u&&c){(o=this._getOrCreateChild(hu)).useStyle(o.createStyle()),o.style.fill=null;var m=o.shape;m.x=r,m.y=i,m.width=n,m.height=a,m.r=f,o.dirtyShape()}if(d)(l=o.style).fill=h||null,l.fillOpacity=Fa(t.fillOpacity,1);else if(h&&h.image){(s=this._getOrCreateChild(iu)).onload=function(){p.dirtyStyle()};var g=s.style;g.image=h.image,g.x=r,g.y=i,g.width=n,g.height=a}u&&c&&((l=o.style).lineWidth=u,l.stroke=c,l.strokeOpacity=Fa(t.strokeOpacity,1),l.lineDash=t.borderDash,l.lineDashOffset=t.borderDashOffset||0,o.strokeContainThreshold=0,o.hasFill()&&o.hasStroke()&&(l.strokeFirst=!0,l.lineWidth*=2));var _=(o||s).style;_.shadowBlur=t.shadowBlur||0,_.shadowColor=t.shadowColor||"transparent",_.shadowOffsetX=t.shadowOffsetX||0,_.shadowOffsetY=t.shadowOffsetY||0,_.opacity=za(t.opacity,e.opacity,1)},e.makeFont=function(t){var e="";if(t.fontSize||t.fontFamily||t.fontWeight){var r="";r="string"!=typeof t.fontSize||-1===t.fontSize.indexOf("px")&&-1===t.fontSize.indexOf("rem")&&-1===t.fontSize.indexOf("em")?isNaN(+t.fontSize)?"12px":t.fontSize+"px":t.fontSize,e=[t.fontStyle,t.fontWeight,r,t.fontFamily||"sans-serif"].join(" ")}return e&&Ua(e)||t.textFont||t.font},e}(Dl),fu={left:!0,right:1,center:1},pu={top:1,bottom:1,middle:1};function mu(t){if(t){t.font=du.makeFont(t);var e=t.align;"middle"===e&&(e="center"),t.align=null==e||fu[e]?e:"left";var r=t.verticalAlign;"center"===r&&(r="middle"),t.verticalAlign=null==r||pu[r]?r:"top",t.padding&&(t.padding=Ga(t.padding))}}function gu(t,e){return null==t||e<=0||"transparent"===t||"none"===t?null:t.image||t.colorStops?"#000":t}function _u(t,e,r){return"right"===e?t-r[1]:"center"===e?t+r[3]/2-r[1]/2:t+r[3]}function vu(t){var e=t.text;return null!=e&&(e+=""),e}function yu(t){return!!(t.backgroundColor||t.borderWidth&&t.borderColor)}const xu=du;function bu(t,e){switch(t){case"center":case"middle":t="50%";break;case"left":case"top":t="0%";break;case"right":case"bottom":t="100%"}return"string"==typeof t?(r=t,r.replace(/^\s+|\s+$/g,"")).match(/%$/)?parseFloat(t)/100*e:parseFloat(t):null==t?NaN:+t;var r}function wu(){var t="__ec_inner_"+Tu++;return function(e){return e[t]||(e[t]={})}}"undefined"!=typeof console&&console.warn&&console.log;var Tu=Math.round(9*Math.random());wu(),wu(),new xi(100),Dh.CMD,Math.sqrt,Math.atan2,Math.sqrt,Math.sin,Math.cos,Math.PI,function(t){function e(){return null!==t&&t.apply(this,arguments)||this}Xo(e,t),e.prototype.applyTransform=function(t){}}(Kh),function(t){function e(e){var r=t.call(this)||this;return r.isGroup=!0,r._children=[],r.attr(e),r}return Xo(e,t),e.prototype.childrenRef=function(){return this._children},e.prototype.children=function(){return this._children.slice()},e.prototype.childAt=function(t){return this._children[t]},e.prototype.childOfName=function(t){for(var e=this._children,r=0;r<e.length;r++)if(e[r].name===t)return e[r]},e.prototype.childCount=function(){return this._children.length},e.prototype.add=function(t){if(t&&(t!==this&&t.parent!==this&&(this._children.push(t),this._doAdd(t)),t.__hostTarget))throw"This elemenet has been used as an attachment";return this},e.prototype.addBefore=function(t,e){if(t&&t!==this&&t.parent!==this&&e&&e.parent===this){var r=this._children,i=r.indexOf(e);i>=0&&(r.splice(i,0,t),this._doAdd(t))}return this},e.prototype.replaceAt=function(t,e){var r=this._children,i=r[e];if(t&&t!==this&&t.parent!==this&&t!==i){r[e]=t,i.parent=null;var n=this.__zr;n&&i.removeSelfFromZr(n),this._doAdd(t)}return this},e.prototype._doAdd=function(t){t.parent&&t.parent.remove(t),t.parent=this;var e=this.__zr;e&&e!==t.__zr&&t.addSelfToZr(e),e&&e.refresh()},e.prototype.remove=function(t){var e=this.__zr,r=this._children,i=Ma(r,t);return i<0||(r.splice(i,1),t.parent=null,e&&t.removeSelfFromZr(e),e&&e.refresh()),this},e.prototype.removeAll=function(){for(var t=this._children,e=this.__zr,r=0;r<t.length;r++){var i=t[r];e&&i.removeSelfFromZr(e),i.parent=null}return t.length=0,this},e.prototype.eachChild=function(t,e){for(var r=this._children,i=0;i<r.length;i++){var n=r[i];t.call(e,n,i)}return this},e.prototype.traverse=function(t,e){for(var r=0;r<this._children.length;r++){var i=this._children[r],n=t.call(e,i);i.isGroup&&!n&&i.traverse(t,e)}return this},e.prototype.addSelfToZr=function(e){t.prototype.addSelfToZr.call(this,e);for(var r=0;r<this._children.length;r++)this._children[r].addSelfToZr(e)},e.prototype.removeSelfFromZr=function(e){t.prototype.removeSelfFromZr.call(this,e);for(var r=0;r<this._children.length;r++)this._children[r].removeSelfFromZr(e)},e.prototype.getBoundingRect=function(t){for(var e=new hs(0,0,0,0),r=t||this._children,i=[],n=null,a=0;a<r.length;a++){var o=r[a];if(!o.ignore&&!o.invisible){var s=o.getBoundingRect(),l=o.getLocalTransform(i);l?(hs.applyTransform(e,s,l),(n=n||e.clone()).union(e)):(n=n||s.clone()).union(s)}}return n||e},e}(bl).prototype.type="group";var Su=function(){this.cx=0,this.cy=0,this.r=0},Mu=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultShape=function(){return new Su},e.prototype.buildPath=function(t,e,r){r&&t.moveTo(e.cx+e.r,e.cy),t.arc(e.cx,e.cy,e.r,0,2*Math.PI)},e}(Kh);Mu.prototype.type="circle";const Au=Mu;var Cu=function(){this.cx=0,this.cy=0,this.rx=0,this.ry=0},Eu=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultShape=function(){return new Cu},e.prototype.buildPath=function(t,e){var r=.5522848,i=e.cx,n=e.cy,a=e.rx,o=e.ry,s=a*r,l=o*r;t.moveTo(i-a,n),t.bezierCurveTo(i-a,n-l,i-s,n-o,i,n-o),t.bezierCurveTo(i+s,n-o,i+a,n-l,i+a,n),t.bezierCurveTo(i+a,n+l,i+s,n+o,i,n+o),t.bezierCurveTo(i-s,n+o,i-a,n+l,i-a,n),t.closePath()},e}(Kh);Eu.prototype.type="ellipse";const Du=Eu;var Lu=Math.PI,Pu=2*Lu,Ou=Math.sin,Nu=Math.cos,Iu=Math.acos,Ru=Math.atan2,Bu=Math.abs,Fu=Math.sqrt,zu=Math.max,ku=Math.min,Gu=1e-4;function Uu(t,e,r,i,n,a,o){var s=t-r,l=e-i,h=(o?a:-a)/Fu(s*s+l*l),u=h*l,c=-h*s,d=t+u,f=e+c,p=r+u,m=i+c,g=(d+p)/2,_=(f+m)/2,v=p-d,y=m-f,x=v*v+y*y,b=n-a,w=d*m-p*f,T=(y<0?-1:1)*Fu(zu(0,b*b*x-w*w)),S=(w*y-v*T)/x,M=(-w*v-y*T)/x,A=(w*y+v*T)/x,C=(-w*v+y*T)/x,E=S-g,D=M-_,L=A-g,P=C-_;return E*E+D*D>L*L+P*P&&(S=A,M=C),{cx:S,cy:M,x01:-u,y01:-c,x11:S*(n/b-1),y11:M*(n/b-1)}}var Hu=function(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=2*Math.PI,this.clockwise=!0,this.cornerRadius=0,this.innerCornerRadius=0},Vu=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultShape=function(){return new Hu},e.prototype.buildPath=function(t,e){!function(t,e){var r=zu(e.r,0),i=zu(e.r0||0,0),n=r>0;if(n||i>0){if(n||(r=i,i=0),i>r){var a=r;r=i,i=a}var o=!!e.clockwise,s=e.startAngle,l=e.endAngle,h=[s,l];Eh(h,!o);var u=Bu(h[0]-h[1]),c=e.cx,d=e.cy,f=e.cornerRadius||0,p=e.innerCornerRadius||0;if(r>Gu)if(u>Pu-Gu)t.moveTo(c+r*Nu(s),d+r*Ou(s)),t.arc(c,d,r,s,l,!o),i>Gu&&(t.moveTo(c+i*Nu(l),d+i*Ou(l)),t.arc(c,d,i,l,s,o));else{var m=Bu(r-i)/2,g=ku(m,f),_=ku(m,p),v=_,y=g,x=r*Nu(s),b=r*Ou(s),w=i*Nu(l),T=i*Ou(l),S=void 0,M=void 0,A=void 0,C=void 0;if((g>Gu||_>Gu)&&(S=r*Nu(l),M=r*Ou(l),A=i*Nu(s),C=i*Ou(s),u<Lu)){var E=function(t,e,r,i,n,a,o,s){var l=r-t,h=i-e,u=o-n,c=s-a,d=c*l-u*h;if(!(d*d<Gu))return[t+(d=(u*(e-a)-c*(t-n))/d)*l,e+d*h]}(x,b,A,C,S,M,w,T);if(E){var D=x-E[0],L=b-E[1],P=S-E[0],O=M-E[1],N=1/Ou(Iu((D*P+L*O)/(Fu(D*D+L*L)*Fu(P*P+O*O)))/2),I=Fu(E[0]*E[0]+E[1]*E[1]);v=ku(_,(i-I)/(N-1)),y=ku(g,(r-I)/(N+1))}}if(u>Gu)if(y>Gu){var R=Uu(A,C,x,b,r,y,o),B=Uu(S,M,w,T,r,y,o);t.moveTo(c+R.cx+R.x01,d+R.cy+R.y01),y<g?t.arc(c+R.cx,d+R.cy,y,Ru(R.y01,R.x01),Ru(B.y01,B.x01),!o):(t.arc(c+R.cx,d+R.cy,y,Ru(R.y01,R.x01),Ru(R.y11,R.x11),!o),t.arc(c,d,r,Ru(R.cy+R.y11,R.cx+R.x11),Ru(B.cy+B.y11,B.cx+B.x11),!o),t.arc(c+B.cx,d+B.cy,y,Ru(B.y11,B.x11),Ru(B.y01,B.x01),!o))}else t.moveTo(c+x,d+b),t.arc(c,d,r,s,l,!o);else t.moveTo(c+x,d+b);i>Gu&&u>Gu?v>Gu?(R=Uu(w,T,S,M,i,-v,o),B=Uu(x,b,A,C,i,-v,o),t.lineTo(c+R.cx+R.x01,d+R.cy+R.y01),v<_?t.arc(c+R.cx,d+R.cy,v,Ru(R.y01,R.x01),Ru(B.y01,B.x01),!o):(t.arc(c+R.cx,d+R.cy,v,Ru(R.y01,R.x01),Ru(R.y11,R.x11),!o),t.arc(c,d,i,Ru(R.cy+R.y11,R.cx+R.x11),Ru(B.cy+B.y11,B.cx+B.x11),o),t.arc(c+B.cx,d+B.cy,v,Ru(B.y11,B.x11),Ru(B.y01,B.x01),!o))):(t.lineTo(c+w,d+T),t.arc(c,d,i,l,s,o)):t.lineTo(c+w,d+T)}else t.moveTo(c,d);t.closePath()}}(t,e)},e.prototype.isZeroArea=function(){return this.shape.startAngle===this.shape.endAngle||this.shape.r===this.shape.r0},e}(Kh);Vu.prototype.type="sector";const Wu=Vu;var ju=function(){this.cx=0,this.cy=0,this.r=0,this.r0=0},Xu=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultShape=function(){return new ju},e.prototype.buildPath=function(t,e){var r=e.cx,i=e.cy,n=2*Math.PI;t.moveTo(r+e.r,i),t.arc(r,i,e.r,0,n,!1),t.moveTo(r+e.r0,i),t.arc(r,i,e.r0,0,n,!0)},e}(Kh);Xu.prototype.type="ring";const qu=Xu;function Zu(t,e,r,i,n,a,o){var s=.5*(r-t),l=.5*(i-e);return(2*(e-r)+s+l)*o+(-3*(e-r)-2*s-l)*a+s*n+e}function Yu(t,e,r){var i=e.smooth,n=e.points;if(n&&n.length>=2){if(i&&"spline"!==i){var a=function(t,e,r,i){var n,a,o,s,l=[],h=[],u=[],c=[];if(i){o=[1/0,1/0],s=[-1/0,-1/0];for(var d=0,f=t.length;d<f;d++)Us(o,o,t[d]),Hs(s,s,t[d]);Us(o,o,i[0]),Hs(s,s,i[1])}for(d=0,f=t.length;d<f;d++){var p=t[d];if(r)n=t[d?d-1:f-1],a=t[(d+1)%f];else{if(0===d||d===f-1){l.push(Is(t[d]));continue}n=t[d-1],a=t[d+1]}Bs(h,a,n),Fs(h,h,e);var m=zs(p,n),g=zs(p,a),_=m+g;0!==_&&(m/=_,g/=_),Fs(u,h,-m),Fs(c,h,g);var v=Rs([],p,u),y=Rs([],p,c);i&&(Hs(v,v,o),Us(v,v,s),Hs(y,y,o),Us(y,y,s)),l.push(v),l.push(y)}return r&&l.push(l.shift()),l}(n,i,r,e.smoothConstraint);t.moveTo(n[0][0],n[0][1]);for(var o=n.length,s=0;s<(r?o:o-1);s++){var l=a[2*s],h=a[2*s+1],u=n[(s+1)%o];t.bezierCurveTo(l[0],l[1],h[0],h[1],u[0],u[1])}}else{"spline"===i&&(n=function(t,e){for(var r=t.length,i=[],n=0,a=1;a<r;a++)n+=zs(t[a-1],t[a]);var o=n/2;for(o=o<r?r:o,a=0;a<o;a++){var s=a/(o-1)*(e?r:r-1),l=Math.floor(s),h=s-l,u=void 0,c=t[l%r],d=void 0,f=void 0;e?(u=t[(l-1+r)%r],d=t[(l+1)%r],f=t[(l+2)%r]):(u=t[0===l?l:l-1],d=t[l>r-2?r-1:l+1],f=t[l>r-3?r-1:l+2]);var p=h*h,m=h*p;i.push([Zu(u[0],c[0],d[0],f[0],h,p,m),Zu(u[1],c[1],d[1],f[1],h,p,m)])}return i}(n,r)),t.moveTo(n[0][0],n[0][1]),s=1;for(var c=n.length;s<c;s++)t.lineTo(n[s][0],n[s][1])}r&&t.closePath()}}var Ku=function(){this.points=null,this.smooth=0,this.smoothConstraint=null},Qu=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultShape=function(){return new Ku},e.prototype.buildPath=function(t,e){Yu(t,e,!0)},e}(Kh);Qu.prototype.type="polygon";const Ju=Qu;var $u=function(){this.points=null,this.percent=1,this.smooth=0,this.smoothConstraint=null},tc=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultStyle=function(){return{stroke:"#000",fill:null}},e.prototype.getDefaultShape=function(){return new $u},e.prototype.buildPath=function(t,e){Yu(t,e,!1)},e}(Kh);tc.prototype.type="polyline";const ec=tc;var rc={},ic=function(){this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.percent=1},nc=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultStyle=function(){return{stroke:"#000",fill:null}},e.prototype.getDefaultShape=function(){return new ic},e.prototype.buildPath=function(t,e){var r,i,n,a;if(this.subPixelOptimize){var o=function(t,e,r){if(e){var i=e.x1,n=e.x2,a=e.y1,o=e.y2;t.x1=i,t.x2=n,t.y1=a,t.y2=o;var s=r&&r.lineWidth;return s?(nu(2*i)===nu(2*n)&&(t.x1=t.x2=au(i,s,!0)),nu(2*a)===nu(2*o)&&(t.y1=t.y2=au(a,s,!0)),t):t}}(rc,e,this.style);r=o.x1,i=o.y1,n=o.x2,a=o.y2}else r=e.x1,i=e.y1,n=e.x2,a=e.y2;var s=e.percent;0!==s&&(t.moveTo(r,i),s<1&&(n=r*(1-s)+n*s,a=i*(1-s)+a*s),t.lineTo(n,a))},e.prototype.pointAt=function(t){var e=this.shape;return[e.x1*(1-t)+e.x2*t,e.y1*(1-t)+e.y2*t]},e}(Kh);nc.prototype.type="line";const ac=nc;var oc=[],sc=function(){this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.cpx1=0,this.cpy1=0,this.percent=1};function lc(t,e,r){var i=t.cpx2,n=t.cpy2;return null===i||null===n?[(r?Ul:Gl)(t.x1,t.cpx1,t.cpx2,t.x2,e),(r?Ul:Gl)(t.y1,t.cpy1,t.cpy2,t.y2,e)]:[(r?Xl:jl)(t.x1,t.cpx1,t.x2,e),(r?Xl:jl)(t.y1,t.cpy1,t.y2,e)]}var hc=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultStyle=function(){return{stroke:"#000",fill:null}},e.prototype.getDefaultShape=function(){return new sc},e.prototype.buildPath=function(t,e){var r=e.x1,i=e.y1,n=e.x2,a=e.y2,o=e.cpx1,s=e.cpy1,l=e.cpx2,h=e.cpy2,u=e.percent;0!==u&&(t.moveTo(r,i),null==l||null==h?(u<1&&(Zl(r,o,n,u,oc),o=oc[1],n=oc[2],Zl(i,s,a,u,oc),s=oc[1],a=oc[2]),t.quadraticCurveTo(o,s,n,a)):(u<1&&(Vl(r,o,l,n,u,oc),o=oc[1],l=oc[2],n=oc[3],Vl(i,s,h,a,u,oc),s=oc[1],h=oc[2],a=oc[3]),t.bezierCurveTo(o,s,l,h,n,a)))},e.prototype.pointAt=function(t){return lc(this.shape,t,!1)},e.prototype.tangentAt=function(t){var e=lc(this.shape,t,!0);return function(t,e){var r=function(t){return Math.sqrt(function(t){return t[0]*t[0]+t[1]*t[1]}(t))}(e);return 0===r?(t[0]=0,t[1]=0):(t[0]=e[0]/r,t[1]=e[1]/r),t}(e,e)},e}(Kh);hc.prototype.type="bezier-curve";const uc=hc;var cc=function(){this.cx=0,this.cy=0,this.r=0,this.startAngle=0,this.endAngle=2*Math.PI,this.clockwise=!0},dc=function(t){function e(e){return t.call(this,e)||this}return Xo(e,t),e.prototype.getDefaultStyle=function(){return{stroke:"#000",fill:null}},e.prototype.getDefaultShape=function(){return new cc},e.prototype.buildPath=function(t,e){var r=e.cx,i=e.cy,n=Math.max(e.r,0),a=e.startAngle,o=e.endAngle,s=e.clockwise,l=Math.cos(a),h=Math.sin(a);t.moveTo(l*n+r,h*n+i),t.arc(r,i,n,a,o,!s)},e}(Kh);dc.prototype.type="arc";const fc=dc;!function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="compound",e}Xo(e,t),e.prototype._updatePathDirty=function(){for(var t=this.shape.paths,e=this.shapeChanged(),r=0;r<t.length;r++)e=e||t[r].shapeChanged();e&&this.dirtyShape()},e.prototype.beforeBrush=function(){this._updatePathDirty();for(var t=this.shape.paths||[],e=this.getGlobalScale(),r=0;r<t.length;r++)t[r].path||t[r].createPathProxy(),t[r].path.setScale(e[0],e[1],t[r].segmentIgnoreThreshold)},e.prototype.buildPath=function(t,e){for(var r=e.paths||[],i=0;i<r.length;i++)r[i].buildPath(t,r[i].shape,!0)},e.prototype.afterBrush=function(){for(var t=this.shape.paths||[],e=0;e<t.length;e++)t[e].pathUpdated()},e.prototype.getBoundingRect=function(){return this._updatePathDirty.call(this),Kh.prototype.getBoundingRect.call(this)}}(Kh);const pc=function(){function t(t){this.colorStops=t||[]}return t.prototype.addColorStop=function(t,e){this.colorStops.push({offset:t,color:e})},t}();var mc;Xo((function(t,e,r,i,n,a){var o=mc.call(this,n)||this;return o.x=null==t?0:t,o.y=null==e?0:e,o.x2=null==r?1:r,o.y2=null==i?0:i,o.type="linear",o.global=a||!1,o}),mc=pc),function(t){Xo((function(e,r,i,n,a){var o=t.call(this,n)||this;return o.x=null==e?.5:e,o.y=null==r?.5:r,o.r=null==i?.5:i,o.type="radial",o.global=a||!1,o}),t)}(pc);var gc=[0,0],_c=[0,0],vc=new ts,yc=new ts;!function(){function t(t,e){this._corners=[],this._axes=[],this._origin=[0,0];for(var r=0;r<4;r++)this._corners[r]=new ts;for(r=0;r<2;r++)this._axes[r]=new ts;t&&this.fromBoundingRect(t,e)}t.prototype.fromBoundingRect=function(t,e){var r=this._corners,i=this._axes,n=t.x,a=t.y,o=n+t.width,s=a+t.height;if(r[0].set(n,a),r[1].set(o,a),r[2].set(o,s),r[3].set(n,s),e)for(var l=0;l<4;l++)r[l].transform(e);for(ts.sub(i[0],r[1],r[0]),ts.sub(i[1],r[3],r[0]),i[0].normalize(),i[1].normalize(),l=0;l<2;l++)this._origin[l]=i[l].dot(r[0])},t.prototype.intersect=function(t,e){var r=!0,i=!e;return vc.set(1/0,1/0),yc.set(0,0),!this._intersectCheckOneSide(this,t,vc,yc,i,1)&&(r=!1,i)||!this._intersectCheckOneSide(t,this,vc,yc,i,-1)&&(r=!1,i)||i||ts.copy(e,r?vc:yc),r},t.prototype._intersectCheckOneSide=function(t,e,r,i,n,a){for(var o=!0,s=0;s<2;s++){var l=this._axes[s];if(this._getProjMinMaxOnAxis(s,t._corners,gc),this._getProjMinMaxOnAxis(s,e._corners,_c),gc[1]<_c[0]||gc[0]>_c[1]){if(o=!1,n)return o;var h=Math.abs(_c[0]-gc[1]),u=Math.abs(gc[0]-_c[1]);Math.min(h,u)>i.len()&&(h<u?ts.scale(i,l,-h*a):ts.scale(i,l,u*a))}else r&&(h=Math.abs(_c[0]-gc[1]),u=Math.abs(gc[0]-_c[1]),Math.min(h,u)<r.len()&&(h<u?ts.scale(r,l,h*a):ts.scale(r,l,-u*a)))}return o},t.prototype._getProjMinMaxOnAxis=function(t,e,r){for(var i=this._axes[t],n=this._origin,a=e[0].dot(i)+n[t],o=a,s=a,l=1;l<e.length;l++){var h=e[l].dot(i)+n[t];o=Math.min(h,o),s=Math.max(h,s)}r[0]=o,r[1]=s}}();var xc=[];!function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.notClear=!0,e.incremental=!0,e._displayables=[],e._temporaryDisplayables=[],e._cursor=0,e}Xo(e,t),e.prototype.traverse=function(t,e){t.call(e,this)},e.prototype.useStyle=function(){this.style={}},e.prototype.getCursor=function(){return this._cursor},e.prototype.innerAfterBrush=function(){this._cursor=this._displayables.length},e.prototype.clearDisplaybles=function(){this._displayables=[],this._temporaryDisplayables=[],this._cursor=0,this.markRedraw(),this.notClear=!1},e.prototype.clearTemporalDisplayables=function(){this._temporaryDisplayables=[]},e.prototype.addDisplayable=function(t,e){e?this._temporaryDisplayables.push(t):this._displayables.push(t),this.markRedraw()},e.prototype.addDisplayables=function(t,e){e=e||!1;for(var r=0;r<t.length;r++)this.addDisplayable(t[r],e)},e.prototype.getDisplayables=function(){return this._displayables},e.prototype.getTemporalDisplayables=function(){return this._temporaryDisplayables},e.prototype.eachPendingDisplayable=function(t){for(var e=this._cursor;e<this._displayables.length;e++)t&&t(this._displayables[e]);for(e=0;e<this._temporaryDisplayables.length;e++)t&&t(this._temporaryDisplayables[e])},e.prototype.update=function(){this.updateTransform();for(var t=this._cursor;t<this._displayables.length;t++)(e=this._displayables[t]).parent=this,e.update(),e.parent=null;for(t=0;t<this._temporaryDisplayables.length;t++){var e;(e=this._temporaryDisplayables[t]).parent=this,e.update(),e.parent=null}},e.prototype.getBoundingRect=function(){if(!this._rect){for(var t=new hs(1/0,1/0,-1/0,-1/0),e=0;e<this._displayables.length;e++){var r=this._displayables[e],i=r.getBoundingRect().clone();r.needLocalTransform()&&i.applyTransform(r.getLocalTransform(xc)),t.union(i)}this._rect=t}return this._rect},e.prototype.contain=function(t,e){var r=this.transformCoordToLocal(t,e);if(this.getBoundingRect().contain(r[0],r[1]))for(var i=0;i<this._displayables.length;i++)if(this._displayables[i].contain(t,e))return!0;return!1}}(Dl),Math.max,Math.min;var bc={};function wc(t,e){bc[t]=e}wc("circle",Au),wc("ellipse",Du),wc("sector",Wu),wc("ring",qu),wc("polygon",Ju),wc("polyline",ec),wc("rect",hu),wc("line",ac),wc("bezierCurve",uc),wc("arc",fc);var Tc={};function Sc(t,e,r,i,n){var a={};return function(t,e,r,i,n){r=r||Tc;var a,o=e.ecModel,s=o&&o.option.textStyle,l=function(t){for(var e;t&&t!==t.ecModel;){var r=(t.option||Tc).rich;if(r){e=e||{};for(var i=La(r),n=0;n<i.length;n++)e[i[n]]=1}t=t.parentModel}return e}(e);if(l)for(var h in a={},l)if(l.hasOwnProperty(h)){var u=e.getModel(["rich",h]);Ec(a[h]={},u,s,r,i,n,!1,!0)}a&&(t.rich=a);var c=e.get("overflow");c&&(t.overflow=c);var d=e.get("minMargin");null!=d&&(t.margin=d),Ec(t,e,s,r,i,n,!0,!1)}(a,t,r,i,n),e&&Ta(a,e),a}var Mc=["fontStyle","fontWeight","fontSize","fontFamily","textShadowColor","textShadowBlur","textShadowOffsetX","textShadowOffsetY"],Ac=["align","lineHeight","width","height","tag","verticalAlign"],Cc=["padding","borderWidth","borderRadius","borderDashOffset","backgroundColor","borderColor","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY"];function Ec(t,e,r,i,n,a,o,s){r=!n&&r||Tc;var l=i&&i.inheritColor,h=e.getShallow("color"),u=e.getShallow("textBorderColor"),c=Fa(e.getShallow("opacity"),r.opacity);"inherit"!==h&&"auto"!==h||(h=l||null),"inherit"!==u&&"auto"!==u||(u=l||null),a||(h=h||r.color,u=u||r.textBorderColor),null!=h&&(t.fill=h),null!=u&&(t.stroke=u);var d=Fa(e.getShallow("textBorderWidth"),r.textBorderWidth);null!=d&&(t.lineWidth=d);var f=Fa(e.getShallow("textBorderType"),r.textBorderType);null!=f&&(t.lineDash=f);var p=Fa(e.getShallow("textBorderDashOffset"),r.textBorderDashOffset);null!=p&&(t.lineDashOffset=p),n||null!=c||s||(c=i&&i.defaultOpacity),null!=c&&(t.opacity=c),n||a||null==t.fill&&i.inheritColor&&(t.fill=i.inheritColor);for(var m=0;m<Mc.length;m++){var g=Mc[m];null!=(v=Fa(e.getShallow(g),r[g]))&&(t[g]=v)}for(m=0;m<Ac.length;m++)g=Ac[m],null!=(v=e.getShallow(g))&&(t[g]=v);if(null==t.verticalAlign){var _=e.getShallow("baseline");null!=_&&(t.verticalAlign=_)}if(!o||!i.disableBox){for(m=0;m<Cc.length;m++){var v;g=Cc[m],null!=(v=e.getShallow(g))&&(t[g]=v)}var y=e.getShallow("borderType");null!=y&&(t.borderDash=y),"auto"!==t.backgroundColor&&"inherit"!==t.backgroundColor||!l||(t.backgroundColor=l),"auto"!==t.borderColor&&"inherit"!==t.borderColor||!l||(t.borderColor=l)}}wu();var Dc=Sn,Lc={left:0,middle:1,right:2};function Pc(t){return t instanceof Array||(t=[t,t]),t}var Oc=m.extend((function(){return{zr:null,viewGL:null,_center:new ve,minDistance:.5,maxDistance:1.5,maxOrthographicSize:300,minOrthographicSize:30,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,panMouseButton:"middle",rotateMouseButton:"left",_mode:"rotate",_camera:null,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new _t,_panVelocity:new _t,_distance:500,_zoomSpeed:0,_stillTimeout:0,_animators:[]}}),(function(){["_mouseDownHandler","_mouseWheelHandler","_mouseMoveHandler","_mouseUpHandler","_pinchHandler","_contextMenuHandler","_update"].forEach((function(t){this[t]=this[t].bind(this)}),this)}),{init:function(){var t=this.zr;t&&(t.on("mousedown",this._mouseDownHandler),t.on("globalout",this._mouseUpHandler),t.on("mousewheel",this._mouseWheelHandler),t.on("pinch",this._pinchHandler),t.animation.on("frame",this._update),t.dom.addEventListener("contextmenu",this._contextMenuHandler))},dispose:function(){var t=this.zr;t&&(t.off("mousedown",this._mouseDownHandler),t.off("mousemove",this._mouseMoveHandler),t.off("mouseup",this._mouseUpHandler),t.off("mousewheel",this._mouseWheelHandler),t.off("pinch",this._pinchHandler),t.off("globalout",this._mouseUpHandler),t.dom.removeEventListener("contextmenu",this._contextMenuHandler),t.animation.off("frame",this._update)),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(t){this._distance=t,this._needsUpdate=!0},getOrthographicSize:function(){return this._orthoSize},setOrthographicSize:function(t){this._orthoSize=t,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(t){t=Math.max(Math.min(this.maxAlpha,t),this.minAlpha),this._theta=t/180*Math.PI,this._needsUpdate=!0},setBeta:function(t){t=Math.max(Math.min(this.maxBeta,t),this.minBeta),this._phi=-t/180*Math.PI,this._needsUpdate=!0},setCenter:function(t){this._center.setArray(t)},setViewGL:function(t){this.viewGL=t},getCamera:function(){return this.viewGL.camera},setFromViewControlModel:function(t,e){var r=(e=e||{}).baseDistance||0,i=e.baseOrthoSize||1,n=t.get("projection");"perspective"!==n&&"orthographic"!==n&&"isometric"!==n&&(n="perspective"),this._projection=n,this.viewGL.setProjection(n);var a=t.get("distance")+r,o=t.get("orthographicSize")+i;[["damping",.8],["autoRotate",!1],["autoRotateAfterStill",3],["autoRotateDirection","cw"],["autoRotateSpeed",10],["minDistance",30],["maxDistance",400],["minOrthographicSize",30],["maxOrthographicSize",300],["minAlpha",-90],["maxAlpha",90],["minBeta",-1/0],["maxBeta",1/0],["rotateSensitivity",1],["zoomSensitivity",1],["panSensitivity",1],["panMouseButton","left"],["rotateMouseButton","middle"]].forEach((function(e){this[e[0]]=Dc(t.get(e[0]),e[1])}),this),this.minDistance+=r,this.maxDistance+=r,this.minOrthographicSize+=i,this.maxOrthographicSize+=i;var s=t.ecModel,l={};["animation","animationDurationUpdate","animationEasingUpdate"].forEach((function(e){l[e]=Dc(t.get(e),s&&s.get(e))}));var h=Dc(e.alpha,t.get("alpha"))||0,u=Dc(e.beta,t.get("beta"))||0,c=Dc(e.center,t.get("center"))||[0,0,0];l.animation&&l.animationDurationUpdate>0&&this._notFirst?this.animateTo({alpha:h,beta:u,center:c,distance:a,orthographicSize:o,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(a),this.setAlpha(h),this.setBeta(u),this.setCenter(c),this.setOrthographicSize(o)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){},animateTo:function(t){var e=this.zr,r=this,i={},n={};return null!=t.distance&&(i.distance=this.getDistance(),n.distance=t.distance),null!=t.orthographicSize&&(i.orthographicSize=this.getOrthographicSize(),n.orthographicSize=t.orthographicSize),null!=t.alpha&&(i.alpha=this.getAlpha(),n.alpha=t.alpha),null!=t.beta&&(i.beta=this.getBeta(),n.beta=t.beta),null!=t.center&&(i.center=this.getCenter(),n.center=t.center),this._addAnimator(e.animation.animate(i).when(t.duration||1e3,n).during((function(){null!=i.alpha&&r.setAlpha(i.alpha),null!=i.beta&&r.setBeta(i.beta),null!=i.distance&&r.setDistance(i.distance),null!=i.center&&r.setCenter(i.center),null!=i.orthographicSize&&r.setOrthographicSize(i.orthographicSize),r._needsUpdate=!0}))).start(t.easing||"linear")},stopAllAnimation:function(){for(var t=0;t<this._animators.length;t++)this._animators[t].stop();this._animators.length=0},update:function(){this._needsUpdate=!0,this._update(20)},_isAnimating:function(){return this._animators.length>0},_update:function(t){if(this._rotating){var e=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=e*t/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(t=Math.min(t,50),this._updateDistanceOrSize(t),this._updatePan(t),this._updateRotate(t),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(t){var e=this._rotateVelocity;this._phi=e.y*t/20+this._phi,this._theta=e.x*t/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(e,Math.pow(this.damping,t/16))},_updateDistanceOrSize:function(t){"perspective"===this._projection?this._setDistance(this._distance+this._zoomSpeed*t/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*t/20),this._zoomSpeed*=Math.pow(this.damping,t/16)},_setDistance:function(t){this._distance=Math.max(Math.min(t,this.maxDistance),this.minDistance)},_setOrthoSize:function(t){this._orthoSize=Math.max(Math.min(t,this.maxOrthographicSize),this.minOrthographicSize);var e=this.getCamera(),r=this._orthoSize,i=r/this.viewGL.viewport.height*this.viewGL.viewport.width;e.left=-i/2,e.right=i/2,e.top=r/2,e.bottom=-r/2},_updatePan:function(t){var e=this._panVelocity,r=this._distance,i=this.getCamera(),n=i.worldTransform.y,a=i.worldTransform.x;this._center.scaleAndAdd(a,-e.x*r/200).scaleAndAdd(n,-e.y*r/200),this._vectorDamping(e,0)},_updateTransform:function(){var t=this.getCamera(),e=new ve,r=this._theta+Math.PI/2,i=this._phi+Math.PI/2,n=Math.sin(r);e.x=n*Math.cos(i),e.y=-Math.cos(r),e.z=n*Math.sin(i),t.position.copy(this._center).scaleAndAdd(e,this._distance),t.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var t=this.autoRotateAfterStill,e=this;!isNaN(t)&&t>0&&(this._stillTimeout=setTimeout((function(){e._rotating=!0}),1e3*t))},_vectorDamping:function(t,e){var r=t.len();(r*=e)<1e-4&&(r=0),t.normalize().scale(r)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var t=this.getCamera().worldTransform.z,e=Math.asin(t.y),r=Math.atan2(t.x,t.z);this._theta=e,this._phi=-r,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(t){if(!t.target&&!this._isAnimating()){var e=t.offsetX,r=t.offsetY;this.viewGL&&!this.viewGL.containPoint(e,r)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),t.event.targetTouches?1===t.event.targetTouches.length&&(this._mode="rotate"):t.event.button===Lc[this.rotateMouseButton]?this._mode="rotate":t.event.button===Lc[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=t.offsetX,this._mouseY=t.offsetY)}},_mouseMoveHandler:function(t){if(!(t.target&&t.target.__isGLToZRProxy||this._isAnimating())){var e=Pc(this.panSensitivity),r=Pc(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(t.offsetX-this._mouseX)/this.zr.getHeight()*2*r[0],this._rotateVelocity.x=(t.offsetY-this._mouseY)/this.zr.getWidth()*2*r[1]):"pan"===this._mode&&(this._panVelocity.x=(t.offsetX-this._mouseX)/this.zr.getWidth()*e[0]*400,this._panVelocity.y=(-t.offsetY+this._mouseY)/this.zr.getHeight()*e[1]*400),this._mouseX=t.offsetX,this._mouseY=t.offsetY,t.event.preventDefault()}},_mouseWheelHandler:function(t){if(!this._isAnimating()){var e=t.event.wheelDelta||-t.event.detail;this._zoomHandler(t,e)}},_pinchHandler:function(t){this._isAnimating()||(this._zoomHandler(t,t.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(t,e){if(0!==e){var r,i=t.offsetX,n=t.offsetY;this.viewGL&&!this.viewGL.containPoint(i,n)||(r="perspective"===this._projection?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(e>0?-1:1)*r*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),t.event.preventDefault())}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return"right"===this.rotateMouseButton||"right"===this.panMouseButton},_contextMenuHandler:function(t){this._isRightMouseButtonUsed()&&t.preventDefault()},_addAnimator:function(t){var e=this._animators;return e.push(t),t.done((function(){var r=e.indexOf(t);r>=0&&e.splice(r,1)})),t}});Object.defineProperty(Oc.prototype,"autoRotate",{get:function(t){return this._autoRotate},set:function(t){this._autoRotate=t,this._rotating=t}});const Nc=Oc,Ic={convertToDynamicArray:function(t){t&&this.resetOffset();var e=this.attributes;for(var r in e)t||!e[r].value?e[r].value=[]:e[r].value=Array.prototype.slice.call(e[r].value);t||!this.indices?this.indices=[]:this.indices=Array.prototype.slice.call(this.indices)},convertToTypedArray:function(){var t=this.attributes;for(var e in t)t[e].value&&t[e].value.length>0?t[e].value=new Float32Array(t[e].value):t[e].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}},Rc={vec2:pt,vec3:Qt,vec4:Ce,mat2:Bn,mat2d:Gn,mat3:De,mat4:Yt,quat:Re};var Bc=Rc.vec3,Fc=[[0,0],[1,1]],zc=Ur.extend((function(){return{segmentScale:1,dynamic:!0,useNativeLine:!0,attributes:{position:new Ur.Attribute("position","float",3,"POSITION"),positionPrev:new Ur.Attribute("positionPrev","float",3),positionNext:new Ur.Attribute("positionNext","float",3),prevPositionPrev:new Ur.Attribute("prevPositionPrev","float",3),prevPosition:new Ur.Attribute("prevPosition","float",3),prevPositionNext:new Ur.Attribute("prevPositionNext","float",3),offset:new Ur.Attribute("offset","float",1),color:new Ur.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(t){var e=this.attributes;this.vertexCount!==t&&(e.position.init(t),e.color.init(t),this.useNativeLine||(e.positionPrev.init(t),e.positionNext.init(t),e.offset.init(t)),t>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(t){this.triangleCount!==t&&(this.indices=0===t?null:this.vertexCount>65535?new Uint32Array(3*t):new Uint16Array(3*t))},_getCubicCurveApproxStep:function(t,e,r,i){return 1/(Bc.dist(t,e)+Bc.dist(r,e)+Bc.dist(i,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(t,e,r,i){var n=this._getCubicCurveApproxStep(t,e,r,i),a=Math.ceil(1/n);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(t,e,r,i){var n=this._getCubicCurveApproxStep(t,e,r,i),a=Math.ceil(1/n);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(Fc)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(Fc)},getPolylineVertexCount:function(t){var e;return e="number"==typeof t?t:"number"!=typeof t[0]?t.length:t.length/3,this.useNativeLine?2*(e-1):2*(e-1)+2},getPolylineTriangleCount:function(t){var e;return e="number"==typeof t?t:"number"!=typeof t[0]?t.length:t.length/3,this.useNativeLine?0:2*Math.max(e-1,0)},addCubicCurve:function(t,e,r,i,n,a){null==a&&(a=1);var o=t[0],s=t[1],l=t[2],h=e[0],u=e[1],c=e[2],d=r[0],f=r[1],p=r[2],m=i[0],g=i[1],_=i[2],v=this._getCubicCurveApproxStep(t,e,r,i),y=v*v,x=y*v,b=3*v,w=3*y,T=6*y,S=6*x,M=o-2*h+d,A=s-2*u+f,C=l-2*c+p,E=3*(h-d)-o+m,D=3*(u-f)-s+g,L=3*(c-p)-l+_,P=o,O=s,N=l,I=(h-o)*b+M*w+E*x,R=(u-s)*b+A*w+D*x,B=(c-l)*b+C*w+L*x,F=M*T+E*S,z=A*T+D*S,k=C*T+L*S,G=E*S,U=D*S,H=L*S,V=0,W=0,j=Math.ceil(1/v),X=new Float32Array(3*(j+1)),q=(X=[],0);for(W=0;W<j+1;W++)X[q++]=P,X[q++]=O,X[q++]=N,P+=I,O+=R,N+=B,I+=F,R+=z,B+=k,F+=G,z+=U,k+=H,(V+=v)>1&&(P=I>0?Math.min(P,m):Math.max(P,m),O=R>0?Math.min(O,g):Math.max(O,g),N=B>0?Math.min(N,_):Math.max(N,_));return this.addPolyline(X,n,a)},addLine:function(t,e,r,i){return this.addPolyline([t,e],r,i)},addPolyline:function(t,e,r,i,n){if(t.length){var a="number"!=typeof t[0];if(null==n&&(n=a?t.length:t.length/3),!(n<2)){null==i&&(i=0),null==r&&(r=1),this._itemVertexOffsets.push(this._vertexOffset);var o,s,l=(a="number"!=typeof t[0])?"number"!=typeof e[0]:e.length/4===n,h=this.attributes.position,u=this.attributes.positionPrev,c=this.attributes.positionNext,d=this.attributes.color,f=this.attributes.offset,p=this.indices,m=this._vertexOffset;r=Math.max(r,.01);for(var g=i;g<n;g++){if(a)o=t[g],s=l?e[g]:e;else{var _=3*g;if((o=o||[])[0]=t[_],o[1]=t[_+1],o[2]=t[_+2],l){var v=4*g;(s=s||[])[0]=e[v],s[1]=e[v+1],s[2]=e[v+2],s[3]=e[v+3]}else s=e}if(this.useNativeLine?g>1&&(h.copy(m,m-1),d.copy(m,m-1),m++):(g<n-1&&(u.set(m+2,o),u.set(m+3,o)),g>0&&(c.set(m-2,o),c.set(m-1,o)),h.set(m,o),h.set(m+1,o),d.set(m,s),d.set(m+1,s),f.set(m,r/2),f.set(m+1,-r/2),m+=2),this.useNativeLine)d.set(m,s),h.set(m,o),m++;else if(g>0){var y=3*this._triangleOffset;(p=this.indices)[y]=m-4,p[y+1]=m-3,p[y+2]=m-2,p[y+3]=m-3,p[y+4]=m-1,p[y+5]=m-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,b=this._vertexOffset+2*n;u.copy(x,x+2),u.copy(x+1,x+3),c.copy(b-1,b-3),c.copy(b-2,b-4)}return this._vertexOffset=m,this._vertexOffset}}},setItemColor:function(t,e){for(var r=this._itemVertexOffsets[t],i=t<this._itemVertexOffsets.length-1?this._itemVertexOffsets[t+1]:this._vertexOffset,n=r;n<i;n++)this.attributes.color.set(n,e);this.dirty("color")},currentTriangleOffset:function(){return this._triangleOffset},currentVertexOffset:function(){return this._vertexOffset}});i.util.defaults(zc.prototype,Ic);const kc=zc;function Gc(t,e,r,i,n,a,o){this._zr=t,this._x=0,this._y=0,this._rowHeight=0,this.width=i,this.height=n,this.offsetX=e,this.offsetY=r,this.dpr=o,this.gap=a}function Uc(t){(t=t||{}).width=t.width||512,t.height=t.height||512,t.devicePixelRatio=t.devicePixelRatio||1,t.gap=null==t.gap?2:t.gap;var e=document.createElement("canvas");e.width=t.width*t.devicePixelRatio,e.height=t.height*t.devicePixelRatio,this._canvas=e,this._texture=new Er({image:e,flipY:!1});var r=this;this._zr=i.zrender.init(e);var n=this._zr.refreshImmediately;this._zr.refreshImmediately=function(){n.call(this),r._texture.dirty(),r.onupdate&&r.onupdate()},this._dpr=t.devicePixelRatio,this._coords={},this.onupdate=t.onupdate,this._gap=t.gap,this._textureAtlasNodes=[new Gc(this._zr,0,0,t.width,t.height,this._gap,this._dpr)],this._nodeWidth=t.width,this._nodeHeight=t.height,this._currentNodeIdx=0}Gc.prototype={constructor:Gc,clear:function(){this._x=0,this._y=0,this._rowHeight=0},add:function(t,e,r){var i=t.getBoundingRect();null==e&&(e=i.width),null==r&&(r=i.height),e*=this.dpr,r*=this.dpr,this._fitElement(t,e,r);var n=this._x,a=this._y,o=this.width*this.dpr,s=this.height*this.dpr,l=this.gap;if(n+e+l>o&&(n=this._x=0,a+=this._rowHeight+l,this._y=a,this._rowHeight=0),this._x+=e+l,this._rowHeight=Math.max(this._rowHeight,r),a+r+l>s)return null;t.x+=this.offsetX*this.dpr+n,t.y+=this.offsetY*this.dpr+a,this._zr.add(t);var h=[this.offsetX/this.width,this.offsetY/this.height];return[[n/o+h[0],a/s+h[1]],[(n+e)/o+h[0],(a+r)/s+h[1]]]},_fitElement:function(t,e,r){var i=t.getBoundingRect(),n=e/i.width,a=r/i.height;t.x=-i.x*n,t.y=-i.y*a,t.scaleX=n,t.scaleY=a,t.update()}},Uc.prototype={clear:function(){for(var t=0;t<this._textureAtlasNodes.length;t++)this._textureAtlasNodes[t].clear();this._currentNodeIdx=0,this._zr.clear(),this._coords={}},getWidth:function(){return this._width},getHeight:function(){return this._height},getTexture:function(){return this._texture},getDevicePixelRatio:function(){return this._dpr},getZr:function(){return this._zr},_getCurrentNode:function(){return this._textureAtlasNodes[this._currentNodeIdx]},_expand:function(){if(this._currentNodeIdx++,this._textureAtlasNodes[this._currentNodeIdx])return this._textureAtlasNodes[this._currentNodeIdx];var t=4096/this._dpr,e=this._textureAtlasNodes.length,r=e*this._nodeWidth%t,i=Math.floor(e*this._nodeWidth/t)*this._nodeHeight;if(!(i>=t)){var n=(r+this._nodeWidth)*this._dpr,a=(i+this._nodeHeight)*this._dpr;try{this._zr.resize({width:n,height:a})}catch(t){this._canvas.width=n,this._canvas.height=a}var o=new Gc(this._zr,r,i,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(o),o}},add:function(t,e,r){if(this._coords[t.id])return this._coords[t.id];var i=this._getCurrentNode().add(t,e,r);if(!i){var n=this._expand();if(!n)return;i=n.add(t,e,r)}return this._coords[t.id]=i,i},getCoordsScale:function(){var t=this._dpr;return[this._nodeWidth/this._canvas.width*t,this._nodeHeight/this._canvas.height*t]},getCoords:function(t){return this._coords[t]}};const Hc=Uc;function Vc(){}Vc.prototype={constructor:Vc,setScene:function(t){this._scene=t,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(t){this._lightRoot=t,this.mainLight=new mo.DirectionalLight({shadowBias:.005}),this.ambientLight=new mo.AmbientLight,t.add(this.mainLight),t.add(this.ambientLight)},dispose:function(){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight))},updateLight:function(t){var e=this.mainLight,r=this.ambientLight,i=t.getModel("light"),n=i.getModel("main"),a=i.getModel("ambient");e.intensity=n.get("intensity"),r.intensity=a.get("intensity"),e.color=mo.parseColor(n.get("color")).slice(0,3),r.color=mo.parseColor(a.get("color")).slice(0,3);var o=n.get("alpha")||0,s=n.get("beta")||0;e.position.setArray(mo.directionFromAlphaBeta(o,s)),e.lookAt(mo.Vector3.ZERO),e.castShadow=n.get("shadow"),e.shadowResolution=mo.getShadowResolution(n.get("shadowQuality"))},updateAmbientCubemap:function(t,e,r){var i=e.getModel("light.ambientCubemap"),n=i.get("texture");if(n){this._cubemapLightsCache=this._cubemapLightsCache||{};var a=this._cubemapLightsCache[n];if(!a){var o=this;a=this._cubemapLightsCache[n]=mo.createAmbientCubemap(i.option,t,r,(function(){o._isSkyboxFromAmbientCubemap&&o._skybox.setEnvironmentMap(a.specular.cubemap),r.getZr().refresh()}))}this._lightRoot.add(a.diffuse),this._lightRoot.add(a.specular),this._currentCubemapLights=a}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null)},updateSkybox:function(t,e,r){var n=e.get("environment"),a=this,o=(a._skybox=a._skybox||new Wi,a._skybox);if(n&&"none"!==n)if("auto"===n)if(this._isSkyboxFromAmbientCubemap=!0,this._currentCubemapLights){var s=this._currentCubemapLights.specular.cubemap;o.setEnvironmentMap(s),this._scene&&o.attachScene(this._scene),o.material.set("lod",3)}else this._skybox&&this._skybox.detachScene();else if("object"==typeof n&&n.colorStops||"string"==typeof n&&i.color.parse(n)){this._isSkyboxFromAmbientCubemap=!1;var l=new mo.Texture2D({anisotropic:8,flipY:!1});o.setEnvironmentMap(l);var h=l.image=document.createElement("canvas");h.width=h.height=16;var u=h.getContext("2d"),c=new i.graphic.Rect({shape:{x:0,y:0,width:16,height:16},style:{fill:n}});i.innerDrawElementOnCanvas(u,c),o.attachScene(this._scene)}else this._isSkyboxFromAmbientCubemap=!1,l=mo.loadTexture(n,r,{anisotropic:8,flipY:!1}),o.setEnvironmentMap(l),o.attachScene(this._scene);else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;var d=e.coordinateSystem;if(this._skybox)if(!d||!d.viewGL||"auto"===n||n.match&&n.match(/.hdr$/))this._skybox.material.undefine("fragment","SRGB_DECODE");else{var f=d.viewGL.isLinearSpace()?"define":"undefine";this._skybox.material[f]("fragment","SRGB_DECODE")}}};const Wc=Vc;var jc=Rc.vec3,Xc=Ur.extend((function(){return{segmentScale:1,useNativeLine:!0,attributes:{position:new Ur.Attribute("position","float",3,"POSITION"),normal:new Ur.Attribute("normal","float",3,"NORMAL"),color:new Ur.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setQuadCount:function(t){var e=this.attributes,r=this.getQuadVertexCount()*t,i=this.getQuadTriangleCount()*t;this.vertexCount!==r&&(e.position.init(r),e.normal.init(r),e.color.init(r)),this.triangleCount!==i&&(this.indices=r>65535?new Uint32Array(3*i):new Uint16Array(3*i))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var t=jc.create(),e=jc.create(),r=jc.create(),i=[0,3,1,3,2,1];return function(n,a){var o=this.attributes.position,s=this.attributes.normal,l=this.attributes.color;jc.sub(t,n[1],n[0]),jc.sub(e,n[2],n[1]),jc.cross(r,t,e),jc.normalize(r,r);for(var h=0;h<4;h++)o.set(this._vertexOffset+h,n[h]),l.set(this._vertexOffset+h,a),s.set(this._vertexOffset+h,r);var u=3*this._faceOffset;for(h=0;h<6;h++)this.indices[u+h]=i[h]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});i.util.defaults(Xc.prototype,Ic);const qc=Xc;var Zc=Sn,Yc={x:0,y:2,z:1};function Kc(t,e,r){this.rootNode=new mo.Node;var i=new mo.Mesh({geometry:new kc({useNativeLine:!1}),material:e,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),n=new mo.Mesh({geometry:new qc,material:r,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(n),this.rootNode.add(i),this.faceInfo=t,this.plane=new mo.Plane,this.linesMesh=i,this.quadsMesh=n}Kc.prototype.update=function(t,e,r){var i=t.coordinateSystem,n=[i.getAxis(this.faceInfo[0]),i.getAxis(this.faceInfo[1])],a=this.linesMesh.geometry,o=this.quadsMesh.geometry;a.convertToDynamicArray(!0),o.convertToDynamicArray(!0),this._updateSplitLines(a,n,t,r),this._udpateSplitAreas(o,n,t,r),a.convertToTypedArray(),o.convertToTypedArray();var s=i.getAxis(this.faceInfo[2]);!function(t,e,r,i){var n=[0,0,0],a=i<0?r.getExtentMin():r.getExtentMax();n[Yc[r.dim]]=a,t.position.setArray(n),t.rotation.identity(),e.distance=-Math.abs(a),e.normal.set(0,0,0),"x"===r.dim?(t.rotation.rotateY(i*Math.PI/2),e.normal.x=-i):"z"===r.dim?(t.rotation.rotateX(-i*Math.PI/2),e.normal.y=-i):(i>0&&t.rotation.rotateY(Math.PI),e.normal.z=-i)}(this.rootNode,this.plane,s,this.faceInfo[3])},Kc.prototype._updateSplitLines=function(t,e,r,n){var a=n.getDevicePixelRatio();e.forEach((function(n,o){var s=n.model,l=e[1-o].getExtent();if(!n.scale.isBlank()){var h=s.getModel("splitLine",r.getModel("splitLine"));if(h.get("show")){var u=h.getModel("lineStyle"),c=u.get("color"),d=Zc(u.get("opacity"),1),f=Zc(u.get("width"),1);c=i.util.isArray(c)?c:[c];for(var p=n.getTicksCoords({tickModel:h}),m=0,g=0;g<p.length;g++){var _=p[g].coord,v=mo.parseColor(c[m%c.length]);v[3]*=d;var y=[0,0,0],x=[0,0,0];y[o]=x[o]=_,y[1-o]=l[0],x[1-o]=l[1],t.addLine(y,x,v,f*a),m++}}}}))},Kc.prototype._udpateSplitAreas=function(t,e,r,n){e.forEach((function(n,a){var o=n.model,s=e[1-a].getExtent();if(!n.scale.isBlank()){var l=o.getModel("splitArea",r.getModel("splitArea"));if(l.get("show")){var h=l.getModel("areaStyle"),u=h.get("color"),c=Zc(h.get("opacity"),1);u=i.util.isArray(u)?u:[u];for(var d=n.getTicksCoords({tickModel:l,clamp:!0}),f=0,p=[0,0,0],m=[0,0,0],g=0;g<d.length;g++){var _=d[g].coord,v=[0,0,0],y=[0,0,0];if(v[a]=y[a]=_,v[1-a]=s[0],y[1-a]=s[1],0!==g){var x=mo.parseColor(u[f%u.length]);x[3]*=c,t.addQuad([p,v,y,m],x),p=v,m=y,f++}else p=v,m=y}}}}))};const Qc=Kc;var Jc=[0,1,2,0,2,3],$c=Ur.extend((function(){return{attributes:{position:new Ur.Attribute("position","float",3,"POSITION"),texcoord:new Ur.Attribute("texcoord","float",2,"TEXCOORD_0"),offset:new Ur.Attribute("offset","float",2),color:new Ur.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setSpriteCount:function(t){this._spriteCount=t;var e=4*t,r=2*t;this.vertexCount!==e&&(this.attributes.position.init(e),this.attributes.offset.init(e),this.attributes.color.init(e)),this.triangleCount!==r&&(this.indices=e>65535?new Uint32Array(3*r):new Uint16Array(3*r))},setSpriteAlign:function(t,e,r,i,n){var a,o,s,l;switch(null==r&&(r="left"),null==i&&(i="top"),n=n||0,r){case"left":a=n,s=e[0]+n;break;case"center":case"middle":a=-e[0]/2,s=e[0]/2;break;case"right":a=-e[0]-n,s=-n}switch(i){case"bottom":o=n,l=e[1]+n;break;case"middle":o=-e[1]/2,l=e[1]/2;break;case"top":o=-e[1]-n,l=-n}var h=4*t,u=this.attributes.offset;u.set(h,[a,l]),u.set(h+1,[s,l]),u.set(h+2,[s,o]),u.set(h+3,[a,o])},addSprite:function(t,e,r,i,n,a){var o=this._vertexOffset;this.setSprite(this._vertexOffset/4,t,e,r,i,n,a);for(var s=0;s<Jc.length;s++)this.indices[3*this._faceOffset+s]=Jc[s]+o;return this._faceOffset+=2,this._vertexOffset+=4,o/4},setSprite:function(t,e,r,i,n,a,o){for(var s=4*t,l=this.attributes,h=0;h<4;h++)l.position.set(s+h,e);var u=l.texcoord;u.set(s,[i[0][0],i[0][1]]),u.set(s+1,[i[1][0],i[0][1]]),u.set(s+2,[i[1][0],i[1][1]]),u.set(s+3,[i[0][0],i[1][1]]),this.setSpriteAlign(t,r,n,a,o)}});i.util.defaults($c.prototype,Ic);const td=$c;mo.Shader.import("@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end");const ed=mo.Mesh.extend((function(){return{geometry:new td({dynamic:!0}),material:new mo.Material({shader:mo.createShader("ecgl.labels"),transparent:!0,depthMask:!1}),culling:!1,castShadow:!1,ignorePicking:!0}}));var rd=Sn,id={x:0,y:2,z:1};function nd(t,e){var r=new mo.Mesh({geometry:new kc({useNativeLine:!1}),material:e,castShadow:!1,ignorePicking:!0,renderOrder:2}),i=new ed;i.material.depthMask=!1;var n=new mo.Node;n.add(r),n.add(i),this.rootNode=n,this.dim=t,this.linesMesh=r,this.labelsMesh=i,this.axisLineCoords=null,this.labelElements=[]}var ad={x:"y",y:"x",z:"y"};nd.prototype.update=function(t,e,r){var n=t.coordinateSystem.getAxis(this.dim),a=this.linesMesh.geometry,o=this.labelsMesh.geometry;a.convertToDynamicArray(!0),o.convertToDynamicArray(!0);var s=n.model,l=n.getExtent(),h=r.getDevicePixelRatio(),u=s.getModel("axisLine",t.getModel("axisLine")),c=s.getModel("axisTick",t.getModel("axisTick")),d=s.getModel("axisLabel",t.getModel("axisLabel")),f=u.get("lineStyle.color");if(u.get("show")){var p=u.getModel("lineStyle"),m=[0,0,0];(M=[0,0,0])[A=id[n.dim]]=l[0],m[A]=l[1],this.axisLineCoords=[M,m];var g=mo.parseColor(f),_=rd(p.get("width"),1),v=rd(p.get("opacity"),1);g[3]*=v,a.addLine(M,m,g,_*h)}if(c.get("show")){var y=c.getModel("lineStyle"),x=mo.parseColor(rd(y.get("color"),f));_=rd(y.get("width"),1),x[3]*=rd(y.get("opacity"),1);for(var b=n.getTicksCoords(),w=c.get("length"),T=0;T<b.length;T++){var S=b[T].coord,M=[0,0,0],A=(m=[0,0,0],id[n.dim]),C=id[ad[n.dim]];M[A]=m[A]=S,m[C]=w,a.addLine(M,m,x,_*h)}}if(this.labelElements=[],h=r.getDevicePixelRatio(),d.get("show")){b=n.getTicksCoords();var E=s.get("data"),D=d.get("margin"),L=n.getViewLabels();for(T=0;T<L.length;T++){var P=L[T].tickValue,O=L[T].formattedLabel,N=L[T].rawLabel,I=(S=n.dataToCoord(P),[0,0,0]);A=id[n.dim],C=id[ad[n.dim]],I[A]=I[A]=S,I[C]=D;var R=d;E&&E[P]&&E[P].textStyle&&(R=new i.Model(E[P].textStyle,d,s.ecModel));var B=rd(R.get("color"),f),F=new i.graphic.Text({style:Sc(R,{text:O,fill:"function"==typeof B?B("category"===n.type?N:"value"===n.type?P+"":P,T):B,verticalAlign:"top",align:"left"})}),z=e.add(F),k=F.getBoundingRect();o.addSprite(I,[k.width*h,k.height*h],z),this.labelElements.push(F)}}if(s.get("name")){var G=s.getModel("nameTextStyle"),U=(I=[0,0,0],A=id[n.dim],C=id[ad[n.dim]],rd(G.get("color"),f)),H=G.get("borderColor");_=G.get("borderWidth"),I[A]=I[A]=(l[0]+l[1])/2,I[C]=s.get("nameGap"),F=new i.graphic.Text({style:Sc(G,{text:s.get("name"),fill:U,stroke:H,lineWidth:_})}),z=e.add(F),k=F.getBoundingRect(),o.addSprite(I,[k.width*h,k.height*h],z),F.__idx=this.labelElements.length,this.nameLabelElement=F}this.labelsMesh.material.set("textureAtlas",e.getTexture()),this.labelsMesh.material.set("uvScale",e.getCoordsScale()),a.convertToTypedArray(),o.convertToTypedArray()},nd.prototype.setSpriteAlign=function(t,e,r){for(var i=r.getDevicePixelRatio(),n=this.labelsMesh.geometry,a=0;a<this.labelElements.length;a++){var o=this.labelElements[a].getBoundingRect();n.setSpriteAlign(a,[o.width*i,o.height*i],t,e)}var s=this.nameLabelElement;s&&(o=s.getBoundingRect(),n.setSpriteAlign(s.__idx,[o.width*i,o.height*i],t,e),n.dirty()),this.textAlign=t,this.textVerticalAlign=e};const od=nd,sd="@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end";var ld=Sn;mo.Shader.import(sd),["x","y","z"].forEach((function(t){i.extendComponentView({type:t+"Axis3D"})}));var hd={x:0,y:2,z:1};i.extendComponentView({type:"grid3D",__ecgl__:!0,init:function(t,e){var r=new mo.Material({shader:mo.createShader("ecgl.color"),depthMask:!1,transparent:!0}),i=new mo.Material({shader:mo.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});r.define("fragment","DOUBLE_SIDED"),r.define("both","VERTEX_COLOR"),this.groupGL=new mo.Node,this._control=new Nc({zr:e.getZr()}),this._control.init(),this._faces=[["y","z","x",-1,"left"],["y","z","x",1,"right"],["x","y","z",-1,"bottom"],["x","y","z",1,"top"],["x","z","y",-1,"far"],["x","z","y",1,"near"]].map((function(t){var e=new Qc(t,i,r);return this.groupGL.add(e.rootNode),e}),this),this._axes=["x","y","z"].map((function(t){var e=new od(t,i);return this.groupGL.add(e.rootNode),e}),this);var n=e.getDevicePixelRatio();this._axisLabelSurface=new Hc({width:256,height:256,devicePixelRatio:n}),this._axisLabelSurface.onupdate=function(){e.getZr().refresh()},this._axisPointerLineMesh=new mo.Mesh({geometry:new kc({useNativeLine:!1}),material:i,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new Hc({width:128,height:128,devicePixelRatio:n}),this._axisPointerLabelsMesh=new ed({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new mo.Node,this._sceneHelper=new Wc,this._sceneHelper.initLight(this._lightRoot)},render:function(t,e,r){this._model=t,this._api=r;var i=t.coordinateSystem;i.viewGL.add(this._lightRoot),t.get("show")?i.viewGL.add(this.groupGL):i.viewGL.remove(this.groupGL);var n=this._control;n.setViewGL(i.viewGL);var a=t.getModel("viewControl");n.setFromViewControlModel(a,0),this._axisLabelSurface.clear(),n.off("update"),t.get("show")&&(this._faces.forEach((function(i){i.update(t,e,r)}),this),this._axes.forEach((function(e){e.update(t,this._axisLabelSurface,r)}),this)),n.on("update",this._onCameraChange.bind(this,t,r),this),this._sceneHelper.setScene(i.viewGL.scene),this._sceneHelper.updateLight(t),i.viewGL.setPostEffect(t.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling")),this._initMouseHandler(t)},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r)},showAxisPointer:function(t,e,r,i){this._doShowAxisPointer(),this._updateAxisPointer(i.value)},hideAxisPointer:function(t,e,r,i){this._doHideAxisPointer()},_initMouseHandler:function(t){var e=t.coordinateSystem.viewGL;t.get("show")&&t.get("axisPointer.show")?e.on("mousemove",this._updateAxisPointerOnMousePosition,this):e.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(t){if(!t.target){for(var e,r=this._model.coordinateSystem,i=r.viewGL,n=i.castRay(t.offsetX,t.offsetY,new mo.Ray),a=0;a<this._faces.length;a++){var o=this._faces[a];if(!o.rootNode.invisible){o.plane.normal.dot(i.camera.worldTransform.z)<0&&o.plane.normal.negate();var s=n.intersectPlane(o.plane);if(s){var l=r.getAxis(o.faceInfo[0]),h=r.getAxis(o.faceInfo[1]),u=hd[o.faceInfo[0]],c=hd[o.faceInfo[1]];l.contain(s.array[u])&&h.contain(s.array[c])&&(e=s)}}}if(e){var d=r.pointToData(e.array,[],!0);this._updateAxisPointer(d),this._doShowAxisPointer()}else this._doHideAxisPointer()}},_onCameraChange:function(t,e){t.get("show")&&(this._updateFaceVisibility(),this._updateAxisLinePosition());var r=this._control;e.dispatchAction({type:"grid3DChangeCamera",alpha:r.getAlpha(),beta:r.getBeta(),distance:r.getDistance(),center:r.getCenter(),from:this.uid,grid3DId:t.id})},_updateFaceVisibility:function(){var t=this._control.getCamera(),e=new mo.Vector3;t.update();for(var r=0;r<this._faces.length/2;r++){for(var i=[],n=0;n<2;n++)this._faces[2*r+n].rootNode.getWorldPosition(e),e.transformMat4(t.viewMatrix),i[n]=e.z;var a=i[0]>i[1]?0:1,o=this._faces[2*r+a],s=this._faces[2*r+1-a];o.rootNode.invisible=!0,s.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var t=this._model.coordinateSystem,e=t.getAxis("x"),r=t.getAxis("y"),i=t.getAxis("z"),n=i.getExtentMax(),a=i.getExtentMin(),o=e.getExtentMin(),s=e.getExtentMax(),l=r.getExtentMax(),h=r.getExtentMin(),u=this._axes[0].rootNode,c=this._axes[1].rootNode,d=this._axes[2].rootNode,f=this._faces,p=f[4].rootNode.invisible?h:l,m=f[2].rootNode.invisible?n:a,g=f[0].rootNode.invisible?o:s,_=f[2].rootNode.invisible?n:a,v=f[0].rootNode.invisible?s:o,y=f[4].rootNode.invisible?h:l;u.rotation.identity(),c.rotation.identity(),d.rotation.identity(),f[4].rootNode.invisible&&(this._axes[0].flipped=!0,u.rotation.rotateX(Math.PI)),f[0].rootNode.invisible&&(this._axes[1].flipped=!0,c.rotation.rotateZ(Math.PI)),f[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),u.position.set(0,m,p),c.position.set(g,_,0),d.position.set(v,0,y),u.update(),c.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var t=this._control.getCamera(),e=[new mo.Vector4,new mo.Vector4],r=new mo.Vector4;this.groupGL.getWorldPosition(r),r.w=1,r.transformMat4(t.viewMatrix).transformMat4(t.projectionMatrix),r.x/=r.w,r.y/=r.w,this._axes.forEach((function(i){for(var n=i.axisLineCoords,a=(i.labelsMesh.geometry,0);a<e.length;a++)e[a].setArray(n[a]),e[a].w=1,e[a].transformMat4(i.rootNode.worldTransform).transformMat4(t.viewMatrix).transformMat4(t.projectionMatrix),e[a].x/=e[a].w,e[a].y/=e[a].w;var o,s,l=e[1].x-e[0].x,h=e[1].y-e[0].y,u=(e[1].x+e[0].x)/2,c=(e[1].y+e[0].y)/2;Math.abs(h/l)<.5?(o="center",s=c>r.y?"bottom":"top"):(s="middle",o=u>r.x?"left":"right"),i.setSpriteAlign(o,s,this._api)}),this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(t){var e=this._model.coordinateSystem,r=e.dataToPoint(t),i=this._axisPointerLineMesh.geometry,n=this._model.getModel("axisPointer"),a=this._api.getDevicePixelRatio();function o(t){return Sn(t.model.get("axisPointer.show"),n.get("show"))}function s(t){var e=t.model.getModel("axisPointer",n).getModel("lineStyle"),r=mo.parseColor(e.get("color")),i=ld(e.get("width"),1),a=ld(e.get("opacity"),1);return r[3]*=a,{color:r,lineWidth:i}}i.convertToDynamicArray(!0);for(var l=0;l<this._faces.length;l++){var h=this._faces[l];if(!h.rootNode.invisible){for(var u=h.faceInfo,c=u[3]<0?e.getAxis(u[2]).getExtentMin():e.getAxis(u[2]).getExtentMax(),d=hd[u[2]],f=0;f<2;f++){var p=u[f],m=u[1-f],g=e.getAxis(p),_=e.getAxis(m);if(o(g)){var v=hd[p],y=hd[m];(w=[0,0,0])[v]=(b=[0,0,0])[v]=r[v],w[d]=b[d]=c,w[y]=_.getExtentMin(),b[y]=_.getExtentMax();var x=s(g);i.addLine(w,b,x.color,x.lineWidth*a)}}if(o(e.getAxis(u[2]))){var b,w=r.slice();(b=r.slice())[d]=c,x=s(e.getAxis(u[2])),i.addLine(w,b,x.color,x.lineWidth*a)}}}i.convertToTypedArray(),this._updateAxisPointerLabelsMesh(t),this._api.getZr().refresh()},_updateAxisPointerLabelsMesh:function(t){var e=this._model,r=this._axisPointerLabelsMesh,n=this._axisPointerLabelsSurface,a=e.coordinateSystem,o=e.getModel("axisPointer");r.geometry.convertToDynamicArray(!0),n.clear();var s={x:"y",y:"x",z:"y"};this._axes.forEach((function(e,l){var h=a.getAxis(e.dim),u=h.model.getModel("axisPointer",o),c=u.getModel("label"),d=u.get("lineStyle.color");if(c.get("show")&&u.get("show")){var f=t[l],p=c.get("formatter"),m=h.scale.getLabel({value:f});if(null!=p)m=p(m,t);else if("interval"===h.scale.type||"log"===h.scale.type){var g=i.number.getPrecisionSafe(h.scale.getTicks()[0]);m=f.toFixed(g+2)}var _=c.getModel("textStyle"),v=_.get("color"),y=new i.graphic.Text({style:Sc(_,{text:m,fill:v||d,align:"left",verticalAlign:"top"})}),x=n.add(y),b=y.getBoundingRect(),w=this._api.getDevicePixelRatio(),T=e.rootNode.position.toArray();T[hd[s[e.dim]]]+=(e.flipped?-1:1)*c.get("margin"),T[hd[e.dim]]=h.dataToCoord(t[l]),r.geometry.addSprite(T,[b.width*w,b.height*w],x,e.textAlign,e.textVerticalAlign)}}),this),n.getZr().refreshImmediately(),r.material.set("uvScale",n.getCoordsScale()),r.geometry.convertToTypedArray()},dispose:function(){this.groupGL.removeAll(),this._control.dispose()}});const ud=function(){function t(t){this.type="cartesian",this._dimList=[],this._axes={},this.name=t||""}return t.prototype.getAxis=function(t){return this._axes[t]},t.prototype.getAxes=function(){return Da(this._dimList,(function(t){return this._axes[t]}),this)},t.prototype.getAxesByScale=function(t){return t=t.toLowerCase(),function(t,e,r){if(!t)return[];if(!e)return ka(t);if(t.filter&&t.filter===fa)return t.filter(e,r);for(var i=[],n=0,a=t.length;n<a;n++)e.call(r,t[n],n,t)&&i.push(t[n]);return i}(this.getAxes(),(function(e){return e.scale.type===t}))},t.prototype.addAxis=function(t){var e=t.dim;this._axes[e]=t,this._dimList.push(e)},t}();function cd(t){ud.call(this,t),this.type="cartesian3D",this.dimensions=["x","y","z"],this.size=[0,0,0]}cd.prototype={constructor:cd,model:null,containPoint:function(t){return this.getAxis("x").contain(t[0])&&this.getAxis("y").contain(t[2])&&this.getAxis("z").contain(t[1])},containData:function(t){return this.getAxis("x").containData(t[0])&&this.getAxis("y").containData(t[1])&&this.getAxis("z").containData(t[2])},dataToPoint:function(t,e,r){return(e=e||[])[0]=this.getAxis("x").dataToCoord(t[0],r),e[2]=this.getAxis("y").dataToCoord(t[1],r),e[1]=this.getAxis("z").dataToCoord(t[2],r),e},pointToData:function(t,e,r){return(e=e||[])[0]=this.getAxis("x").coordToData(t[0],r),e[1]=this.getAxis("y").coordToData(t[2],r),e[2]=this.getAxis("z").coordToData(t[1],r),e}},i.util.inherits(cd,ud);const dd=cd;function fd(t,e,r){i.Axis.call(this,t,e,r)}fd.prototype={constructor:fd,getExtentMin:function(){var t=this._extent;return Math.min(t[0],t[1])},getExtentMax:function(){var t=this._extent;return Math.max(t[0],t[1])},calculateCategoryInterval:function(){return Math.floor(this.scale.count()/8)}},i.util.inherits(fd,i.Axis);const pd=fd;function md(t){return"function"==typeof t&&/^class\s/.test(Function.prototype.toString.call(t))}var gd=Math.round(10*Math.random());function _d(t,e){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return this.superClass.prototype[e].apply(t,r)}function vd(t,e,r){return this.superClass.prototype[e].apply(t,r)}function yd(t,e){for(var r=0;r<t.length;r++)t[r][1]||(t[r][1]=t[r][0]);return e=e||!1,function(r,i,n){for(var a={},o=0;o<t.length;o++){var s=t[o][1];if(!(i&&Ma(i,s)>=0||n&&Ma(n,s)<0)){var l=r.getShallow(s,e);null!=l&&(a[t[o][0]]=l)}}return a}}var xd=yd([["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["opacity"],["shadowColor"]]),bd=function(){function t(){}return t.prototype.getAreaStyle=function(t,e){return xd(this,t,e)},t}(),wd=["textStyle","color"],Td=new xu;const Sd=function(){function t(){}return t.prototype.getTextColor=function(t){var e=this.ecModel;return this.getShallow("color")||(!t&&e?e.get(wd):null)},t.prototype.getFont=function(){return t={fontStyle:this.getShallow("fontStyle"),fontWeight:this.getShallow("fontWeight"),fontSize:this.getShallow("fontSize"),fontFamily:this.getShallow("fontFamily")},r=(e=this.ecModel)&&e.getModel("textStyle"),Ua([t.fontStyle||r&&r.getShallow("fontStyle")||"",t.fontWeight||r&&r.getShallow("fontWeight")||"",(t.fontSize||r&&r.getShallow("fontSize")||12)+"px",t.fontFamily||r&&r.getShallow("fontFamily")||"sans-serif"].join(" "));var t,e,r},t.prototype.getTextRect=function(t){return Td.useStyle({text:t,fontStyle:this.getShallow("fontStyle"),fontWeight:this.getShallow("fontWeight"),fontSize:this.getShallow("fontSize"),fontFamily:this.getShallow("fontFamily"),verticalAlign:this.getShallow("verticalAlign")||this.getShallow("baseline"),padding:this.getShallow("padding"),lineHeight:this.getShallow("lineHeight"),rich:this.getShallow("rich")}),Td.update(),Td.getBoundingRect()},t}();var Md,Ad,Cd,Ed=yd([["lineWidth","width"],["stroke","color"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"],["lineDash","type"],["lineDashOffset","dashOffset"],["lineCap","cap"],["lineJoin","join"],["miterLimit"]]),Dd=function(){function t(){}return t.prototype.getLineStyle=function(t){return Ed(this,t)},t}(),Ld=yd([["fill","color"],["stroke","borderColor"],["lineWidth","borderWidth"],["opacity"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["shadowColor"],["lineDash","borderType"],["lineDashOffset","borderDashOffset"],["lineCap","borderCap"],["lineJoin","borderJoin"],["miterLimit","borderMiterLimit"]]),Pd=function(){function t(){}return t.prototype.getItemStyle=function(t,e){return Ld(this,t,e)},t}(),Od=function(){function t(t,e,r){this.parentModel=e,this.ecModel=r,this.option=t}return t.prototype.init=function(t,e,r){for(var i=[],n=3;n<arguments.length;n++)i[n-3]=arguments[n]},t.prototype.mergeOption=function(t,e){wa(this.option,t,!0)},t.prototype.get=function(t,e){return null==t?this.option:this._doGet(this.parsePath(t),!e&&this.parentModel)},t.prototype.getShallow=function(t,e){var r=this.option,i=null==r?r:r[t];if(null==i&&!e){var n=this.parentModel;n&&(i=n.getShallow(t))}return i},t.prototype.getModel=function(e,r){var i=null!=e,n=i?this.parsePath(e):null;return new t(i?this._doGet(n):this.option,r=r||this.parentModel&&this.parentModel.getModel(this.resolveParentPath(n)),this.ecModel)},t.prototype.isEmpty=function(){return null==this.option},t.prototype.restoreData=function(){},t.prototype.clone=function(){return new(0,this.constructor)(ba(this.option))},t.prototype.parsePath=function(t){return"string"==typeof t?t.split("."):t},t.prototype.resolveParentPath=function(t){return t},t.prototype.isAnimationEnabled=function(){if(!ul.node&&this.option){if(null!=this.option.animation)return!!this.option.animation;if(this.parentModel)return this.parentModel.isAnimationEnabled()}},t.prototype._doGet=function(t,e){var r=this.option;if(!t)return r;for(var i=0;i<t.length&&(!t[i]||null!=(r=r&&"object"==typeof r?r[t[i]]:null));i++);return null==r&&e&&(r=e._doGet(this.resolveParentPath(t),e.parentModel)),r},t}();(Md=Od).$constructor=Md,Md.extend=function(t){var e=this;function r(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(t.$constructor)t.$constructor.apply(this,arguments);else{if(md(e)){var a=ja(r.prototype,new(e.bind.apply(e,qo([void 0],i))));return a}e.apply(this,arguments)}}return r.___EC__EXTENDED_CLASS___=!0,Ta(r.prototype,t),r.extend=this.extend,r.superCall=_d,r.superApply=vd,function(t,e){var r=t.prototype;function i(){}for(var n in i.prototype=e.prototype,t.prototype=new i,r)r.hasOwnProperty(n)&&(t.prototype[n]=r[n]);t.prototype.constructor=t,t.superClass=e}(r,this),r.superClass=e,r},Ad=Od,Cd=["__\0is_clz",gd++].join("_"),Ad.prototype[Cd]=!0,Ad.isInstance=function(t){return!(!t||!t[Cd])},Aa(Od,Dd),Aa(Od,Pd),Aa(Od,bd),Aa(Od,Sd);const Nd=Od;var Id={},Rd={};function Bd(t,e){t=t.toUpperCase(),Rd[t]=new Nd(e),Id[t]=e}ul.domSupported&&(document.documentElement.lang||navigator.language||navigator.browserLanguage).toUpperCase().indexOf("ZH"),Bd("EN",{time:{month:["January","February","March","April","May","June","July","August","September","October","November","December"],monthAbbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayOfWeek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayOfWeekAbbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},legend:{selector:{all:"All",inverse:"Inv"}},toolbox:{brush:{title:{rect:"Box Select",polygon:"Lasso Select",lineX:"Horizontally Select",lineY:"Vertically Select",keep:"Keep Selections",clear:"Clear Selections"}},dataView:{title:"Data View",lang:["Data View","Close","Refresh"]},dataZoom:{title:{zoom:"Zoom",back:"Zoom Reset"}},magicType:{title:{line:"Switch to Line Chart",bar:"Switch to Bar Chart",stack:"Stack",tiled:"Tile"}},restore:{title:"Restore"},saveAsImage:{title:"Save as Image",lang:["Right Click to Save Image"]}},series:{typeNames:{pie:"Pie chart",bar:"Bar chart",line:"Line chart",scatter:"Scatter plot",effectScatter:"Ripple scatter plot",radar:"Radar chart",tree:"Tree",treemap:"Treemap",boxplot:"Boxplot",candlestick:"Candlestick",k:"K line chart",heatmap:"Heat map",map:"Map",parallel:"Parallel coordinate map",lines:"Line graph",graph:"Relationship graph",sankey:"Sankey diagram",funnel:"Funnel chart",gauge:"Guage",pictorialBar:"Pictorial bar",themeRiver:"Theme River Map",sunburst:"Sunburst"}},aria:{general:{withTitle:'This is a chart about "{title}"',withoutTitle:"This is a chart"},series:{single:{prefix:"",withName:" with type {seriesType} named {seriesName}.",withoutName:" with type {seriesType}."},multiple:{prefix:". It consists of {seriesCount} series count.",withName:" The {seriesId} series is a {seriesType} representing {seriesName}.",withoutName:" The {seriesId} series is a {seriesType}.",separator:{middle:"",end:""}}},data:{allData:"The data is as follows: ",partialData:"The first {displayCnt} items are: ",withName:"the data for {name} is {value}",withoutName:"{value}",separator:{middle:", ",end:". "}}}}),Bd("ZH",{time:{month:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthAbbr:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dayOfWeek:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],dayOfWeekAbbr:["日","一","二","三","四","五","六"]},legend:{selector:{all:"全选",inverse:"反选"}},toolbox:{brush:{title:{rect:"矩形选择",polygon:"圈选",lineX:"横向选择",lineY:"纵向选择",keep:"保持选择",clear:"清除选择"}},dataView:{title:"数据视图",lang:["数据视图","关闭","刷新"]},dataZoom:{title:{zoom:"区域缩放",back:"区域缩放还原"}},magicType:{title:{line:"切换为折线图",bar:"切换为柱状图",stack:"切换为堆叠",tiled:"切换为平铺"}},restore:{title:"还原"},saveAsImage:{title:"保存为图片",lang:["右键另存为图片"]}},series:{typeNames:{pie:"饼图",bar:"柱状图",line:"折线图",scatter:"散点图",effectScatter:"涟漪散点图",radar:"雷达图",tree:"树图",treemap:"矩形树图",boxplot:"箱型图",candlestick:"K线图",k:"K线图",heatmap:"热力图",map:"地图",parallel:"平行坐标图",lines:"线图",graph:"关系图",sankey:"桑基图",funnel:"漏斗图",gauge:"仪表盘图",pictorialBar:"象形柱图",themeRiver:"主题河流图",sunburst:"旭日图"}},aria:{general:{withTitle:"这是一个关于“{title}”的图表。",withoutTitle:"这是一个图表,"},series:{single:{prefix:"",withName:"图表类型是{seriesType},表示{seriesName}。",withoutName:"图表类型是{seriesType}。"},multiple:{prefix:"它由{seriesCount}个图表系列组成。",withName:"第{seriesId}个系列是一个表示{seriesName}的{seriesType},",withoutName:"第{seriesId}个系列是一个{seriesType},",separator:{middle:";",end:"。"}}},data:{allData:"其数据是——",partialData:"其中,前{displayCnt}项是——",withName:"{name}的数据是{value}",withoutName:"{value}",separator:{middle:",",end:""}}}});var Fd=Ga;function zd(t,e,r,i,n){var a=0,o=0;null==i&&(i=1/0),null==n&&(n=1/0);var s=0;e.eachChild((function(l,h){var u,c,d=l.getBoundingRect(),f=e.childAt(h+1),p=f&&f.getBoundingRect();if("horizontal"===t){var m=d.width+(p?-p.x+d.x:0);(u=a+m)>i||l.newline?(a=0,u=m,o+=s+r,s=d.height):s=Math.max(s,d.height)}else{var g=d.height+(p?-p.y+d.y:0);(c=o+g)>n||l.newline?(a+=s+r,o=0,c=g,s=d.width):s=Math.max(s,d.width)}l.newline||(l.x=a,l.y=o,l.markRedraw(),"horizontal"===t?a=u+r:o=c+r)}))}function kd(t,e,r){r=Fd(r||0);var i=e.width,n=e.height,a=bu(t.left,i),o=bu(t.top,n),s=bu(t.right,i),l=bu(t.bottom,n),h=bu(t.width,i),u=bu(t.height,n),c=r[2]+r[0],d=r[1]+r[3],f=t.aspect;switch(isNaN(h)&&(h=i-s-d-a),isNaN(u)&&(u=n-l-c-o),null!=f&&(isNaN(h)&&isNaN(u)&&(f>i/n?h=.8*i:u=.8*n),isNaN(h)&&(h=f*u),isNaN(u)&&(u=h/f)),isNaN(a)&&(a=i-s-h-d),isNaN(o)&&(o=n-l-u-c),t.left||t.right){case"center":a=i/2-h/2-r[3];break;case"right":a=i-h-d}switch(t.top||t.bottom){case"middle":case"center":o=n/2-u/2-r[0];break;case"bottom":o=n-u-c}a=a||0,o=o||0,isNaN(h)&&(h=i-d-a-(s||0)),isNaN(u)&&(u=n-c-o-(l||0));var p=new hs(a+r[3],o+r[0],h,u);return p.margin=r,p}Pa(zd,"vertical"),Pa(zd,"horizontal");var Gd=function(){this._pool={},this._allocatedTextures=[]};Gd.prototype={constructor:Gd,get:function(t){var e=Vd(t);this._pool.hasOwnProperty(e)||(this._pool[e]=[]);var r=this._pool[e];if(!r.length){var i=new Er(t);return this._allocatedTextures.push(i),i}return r.pop()},put:function(t){var e=Vd(t);this._pool.hasOwnProperty(e)||(this._pool[e]=[]),this._pool[e].push(t)},clear:function(t){for(var e=0;e<this._allocatedTextures.length;e++)this._allocatedTextures[e].dispose(t);this._pool={},this._allocatedTextures=[]}};var Ud={width:512,height:512,type:T,format:A,wrapS:I,wrapT:I,minFilter:O,magFilter:E,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1},Hd=Object.keys(Ud);function Vd(t){f.defaultsWithPropList(t,Ud,Hd),function(t){var e,r,i=(e=t.width,r=t.height,0==(e&e-1)&&0==(r&r-1));t.format===M&&(t.useMipmap=!1),i&&t.useMipmap||(t.minFilter==D||t.minFilter==P?t.minFilter=C:t.minFilter!=O&&t.minFilter!=L||(t.minFilter=E)),i||(t.wrapS=I,t.wrapT=I)}(t);for(var e="",r=0;r<Hd.length;r++)e+=t[Hd[r]].toString();return e}const Wd=Gd;var jd=["px","nx","py","ny","pz","nz"];function Xd(t,e,r){return"alphaMap"===r?t.material.get("diffuseMap"):"alphaCutoff"===r?t.material.isDefined("fragment","ALPHA_TEST")&&t.material.get("diffuseMap")&&t.material.get("alphaCutoff")||0:"uvRepeat"===r?t.material.get("uvRepeat"):"uvOffset"===r?t.material.get("uvOffset"):e.get(r)}function qd(t,e){var r=t.material,i=e.material;return r.get("diffuseMap")!==i.get("diffuseMap")||(r.get("alphaCutoff")||0)!==(i.get("alphaCutoff")||0)}Xt.import("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nuniform vec2 uvRepeat = vec2(1.0, 1.0);\nuniform vec2 uvOffset = vec2(0.0, 0.0);\n@import clay.chunk.skinning_header\n@import clay.chunk.instancing_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n v_ViewPosition = worldViewProjection * P;\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n #endif\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n #ifdef SUPPORT_STANDARD_DERIVATIVES\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n #else\n depth += bias;\n #endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec4 P = vec4(position, 1.0);\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = skinMatrixWS * P;\n#endif\n#ifdef INSTANCING\n @import clay.chunk.instancing_matrix\n P = instanceMat * P;\n#endif\n gl_Position = worldViewProjection * P;\n v_WorldPosition = (world * P).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end");var Zd,Yd,Kd,Qd,Jd,$d,tf,ef=m.extend((function(){return{softShadow:ef.PCF,shadowBlur:1,lightFrustumBias:"auto",kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"highp",_lastRenderNotCastShadow:!1,_frameBuffer:new Fi,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_depthMaterials:{},_distanceMaterials:{},_receivers:[],_lightsCastShadow:[],_lightCameras:{},_lightMaterials:{},_texturePool:new Wd}}),(function(){this._gaussianPassH=new fn({fragment:Xt.source("clay.compositor.gaussian_blur")}),this._gaussianPassV=new fn({fragment:Xt.source("clay.compositor.gaussian_blur")}),this._gaussianPassH.setUniform("blurSize",this.shadowBlur),this._gaussianPassH.setUniform("blurDir",0),this._gaussianPassV.setUniform("blurSize",this.shadowBlur),this._gaussianPassV.setUniform("blurDir",1),this._outputDepthPass=new fn({fragment:Xt.source("clay.sm.debug_depth")})}),{render:function(t,e,r,i){r||(r=e.getMainCamera()),this.trigger("beforerender",this,t,e,r),this._renderShadowPass(t,e,r,i),this.trigger("afterrender",this,t,e,r)},renderDebug:function(t,e){t.saveClear();var r=t.viewport,i=0,n=e||r.width/4,a=n;for(var o in this.softShadow===ef.VSM?this._outputDepthPass.material.define("fragment","USE_VSM"):this._outputDepthPass.material.undefine("fragment","USE_VSM"),this._textures){var s=this._textures[o];t.setViewport(i,0,n*s.width/s.height,a),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(t),i+=n*s.width/s.height}t.setViewport(r),t.restoreClear()},_updateReceivers:function(t,e){if(e.receiveShadow?(this._receivers.push(e),e.material.set("shadowEnabled",1),e.material.set("pcfKernel",this.kernelPCF)):e.material.set("shadowEnabled",0),this.softShadow===ef.VSM)e.material.define("fragment","USE_VSM"),e.material.undefine("fragment","PCF_KERNEL_SIZE");else{e.material.undefine("fragment","USE_VSM");var r=this.kernelPCF;r&&r.length?e.material.define("fragment","PCF_KERNEL_SIZE",r.length/2):e.material.undefine("fragment","PCF_KERNEL_SIZE")}},_update:function(t,e){var r=this;e.traverse((function(e){e.isRenderable()&&r._updateReceivers(t,e)}));for(var i=0;i<e.lights.length;i++){var n=e.lights[i];n.castShadow&&!n.invisible&&this._lightsCastShadow.push(n)}},_renderShadowPass:function(t,e,r,i){for(var n in this._shadowMapNumber)this._shadowMapNumber[n]=0;this._lightsCastShadow.length=0,this._receivers.length=0;var a=t.gl;if(i||e.update(),r&&r.update(),e.updateLights(),this._update(t,e),this._lightsCastShadow.length||!this._lastRenderNotCastShadow){this._lastRenderNotCastShadow=0===this._lightsCastShadow,a.enable(a.DEPTH_TEST),a.depthMask(!0),a.disable(a.BLEND),a.clearColor(1,1,1,1);for(var o,s=[],l=[],h=[],u=[],c=[],d=[],f=0;f<this._lightsCastShadow.length;f++){var p=this._lightsCastShadow[f];if("DIRECTIONAL_LIGHT"===p.type){if(o){console.warn("Only one direectional light supported with shadow cascade");continue}if(p.shadowCascade>4){console.warn("Support at most 4 cascade");continue}p.shadowCascade>1&&(o=p),this.renderDirectionalLightShadow(t,e,r,p,c,u,h)}else"SPOT_LIGHT"===p.type?this.renderSpotLightShadow(t,e,p,l,s):"POINT_LIGHT"===p.type&&this.renderPointLightShadow(t,e,p,d);this._shadowMapNumber[p.type]++}for(var m in this._shadowMapNumber){var g=this._shadowMapNumber[m],_=m+"_SHADOWMAP_COUNT";for(f=0;f<this._receivers.length;f++)(v=this._receivers[f].material).fragmentDefines[_]!==g&&(g>0?v.define("fragment",_,g):v.isDefined("fragment",_)&&v.undefine("fragment",_))}for(f=0;f<this._receivers.length;f++){var v=this._receivers[f].material;o?v.define("fragment","SHADOW_CASCADE",o.shadowCascade):v.undefine("fragment","SHADOW_CASCADE")}var y=e.shadowUniforms;if(h.length>0){var x=h.map(S);if(y.directionalLightShadowMaps={value:h,type:"tv"},y.directionalLightMatrices={value:u,type:"m4v"},y.directionalLightShadowMapSizes={value:x,type:"1fv"},o){var b=c.slice(),w=c.slice();b.pop(),w.shift(),b.reverse(),w.reverse(),u.reverse(),y.shadowCascadeClipsNear={value:b,type:"1fv"},y.shadowCascadeClipsFar={value:w,type:"1fv"}}}if(s.length>0){var T=s.map(S);(y=e.shadowUniforms).spotLightShadowMaps={value:s,type:"tv"},y.spotLightMatrices={value:l,type:"m4v"},y.spotLightShadowMapSizes={value:T,type:"1fv"}}d.length>0&&(y.pointLightShadowMaps={value:d,type:"tv"})}function S(t){return t.height}},renderDirectionalLightShadow:(Zd=new oi,Yd=new Ve,Kd=new ir,Qd=new Ve,Jd=new Ve,$d=new Ve,tf=new Ve,function(t,e,r,i,n,a,o){var s=this._getDepthMaterial(i),l={getMaterial:function(t){return t.shadowDepthMaterial||s},isMaterialChanged:qd,getUniform:Xd,ifRender:function(t){return t.castShadow},sortCompare:ue.opaqueSortCompare};if(!e.viewBoundingBoxLastFrame.isFinite()){var h=e.getBoundingBox();e.viewBoundingBoxLastFrame.copy(h).applyTransform(r.viewMatrix)}var u=Math.min(-e.viewBoundingBoxLastFrame.min.z,r.far),c=Math.max(-e.viewBoundingBoxLastFrame.max.z,r.near),d=this._getDirectionalLightCamera(i,e,r),f=$d.array;tf.copy(d.projectionMatrix),Yt.invert(Jd.array,d.worldTransform.array),Yt.multiply(Jd.array,Jd.array,r.worldTransform.array),Yt.multiply(f,tf.array,Jd.array);for(var p=[],m=r instanceof Ai,g=(r.near+r.far)/(r.near-r.far),_=2*r.near*r.far/(r.near-r.far),v=0;v<=i.shadowCascade;v++){var y=c*Math.pow(u/c,v/i.shadowCascade),x=c+(u-c)*v/i.shadowCascade,b=y*i.cascadeSplitLogFactor+x*(1-i.cascadeSplitLogFactor);p.push(b),n.push(-(-b*g+_)/-b)}var w=this._getTexture(i,i.shadowCascade);o.push(w);var T=t.viewport,S=t.gl;for(this._frameBuffer.attach(w),this._frameBuffer.bind(t),S.clear(S.COLOR_BUFFER_BIT|S.DEPTH_BUFFER_BIT),v=0;v<i.shadowCascade;v++){var M=p[v],A=p[v+1];m?Yt.perspective(Yd.array,r.fov/180*Math.PI,r.aspect,M,A):Yt.ortho(Yd.array,r.left,r.right,r.bottom,r.top,M,A),Zd.setFromProjection(Yd),Zd.getTransformedBoundingBox(Kd,Jd),Kd.applyProjection(tf);var C=Kd.min.array,E=Kd.max.array;C[0]=Math.max(C[0],-1),C[1]=Math.max(C[1],-1),E[0]=Math.min(E[0],1),E[1]=Math.min(E[1],1),Qd.ortho(C[0],E[0],C[1],E[1],1,-1),d.projectionMatrix.multiplyLeft(Qd);var D=i.shadowResolution||512;t.setViewport((i.shadowCascade-v-1)*D,0,D,D,1);var L=e.updateRenderList(d);t.renderPass(L.opaque,d,l),this.softShadow===ef.VSM&&this._gaussianFilter(t,w,w.width);var P=new Ve;P.copy(d.viewMatrix).multiplyLeft(d.projectionMatrix),a.push(P.array),d.projectionMatrix.copy(tf)}this._frameBuffer.unbind(t),t.setViewport(T)}),renderSpotLightShadow:function(t,e,r,i,n){var a=this._getTexture(r),o=this._getSpotLightCamera(r),s=t.gl;this._frameBuffer.attach(a),this._frameBuffer.bind(t),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT);var l=this._getDepthMaterial(r),h={getMaterial:function(t){return t.shadowDepthMaterial||l},isMaterialChanged:qd,getUniform:Xd,ifRender:function(t){return t.castShadow},sortCompare:ue.opaqueSortCompare},u=e.updateRenderList(o);t.renderPass(u.opaque,o,h),this._frameBuffer.unbind(t),this.softShadow===ef.VSM&&this._gaussianFilter(t,a,a.width);var c=new Ve;c.copy(o.worldTransform).invert().multiplyLeft(o.projectionMatrix),n.push(a),i.push(c.array)},renderPointLightShadow:function(t,e,r,i){var n=this._getTexture(r),a=t.gl;i.push(n);var o=this._getDepthMaterial(r),s={getMaterial:function(t){return t.shadowDepthMaterial||o},getUniform:Xd,sortCompare:ue.opaqueSortCompare},l={px:[],py:[],pz:[],nx:[],ny:[],nz:[]},h=new ir,u=r.getWorldPosition().array,c=new ir,d=r.range;c.min.setArray(u),c.max.setArray(u);var f=new ve(d,d,d);c.max.add(f),c.min.sub(f);var p={px:!1,py:!1,pz:!1,nx:!1,ny:!1,nz:!1};e.traverse((function(t){if(t.isRenderable()&&t.castShadow){var e=t.geometry;if(!e.boundingBox){for(var r=0;r<jd.length;r++)l[jd[r]].push(t);return}if(h.transformFrom(e.boundingBox,t.worldTransform),!h.intersectBoundingBox(c))return;for(h.updateVertices(),r=0;r<jd.length;r++)p[jd[r]]=!1;for(r=0;r<8;r++){var i=h.vertices[r],n=i[0]-u[0],a=i[1]-u[1],o=i[2]-u[2],s=Math.abs(n),d=Math.abs(a),f=Math.abs(o);s>d?s>f?p[n>0?"px":"nx"]=!0:p[o>0?"pz":"nz"]=!0:d>f?p[a>0?"py":"ny"]=!0:p[o>0?"pz":"nz"]=!0}for(r=0;r<jd.length;r++)p[jd[r]]&&l[jd[r]].push(t)}}));for(var m=0;m<6;m++){var g=jd[m],_=this._getPointLightCamera(r,g);this._frameBuffer.attach(n,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+m),this._frameBuffer.bind(t),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT),t.renderPass(l[g],_,s)}this._frameBuffer.unbind(t)},_getDepthMaterial:function(t){var e=this._lightMaterials[t.__uid__],r="POINT_LIGHT"===t.type;if(!e){var i=r?"clay.sm.distance.":"clay.sm.depth.";e=new lt({precision:this.precision,shader:new Xt(Xt.source(i+"vertex"),Xt.source(i+"fragment"))}),this._lightMaterials[t.__uid__]=e}return null!=t.shadowSlopeScale&&e.setUniform("slopeScale",t.shadowSlopeScale),null!=t.shadowBias&&e.setUniform("bias",t.shadowBias),this.softShadow===ef.VSM?e.define("fragment","USE_VSM"):e.undefine("fragment","USE_VSM"),r&&(e.set("lightPosition",t.getWorldPosition().array),e.set("range",t.range)),e},_gaussianFilter:function(t,e,r){var i={width:r,height:r,type:br.FLOAT},n=this._texturePool.get(i);this._frameBuffer.attach(n),this._frameBuffer.bind(t),this._gaussianPassH.setUniform("texture",e),this._gaussianPassH.setUniform("textureWidth",r),this._gaussianPassH.render(t),this._frameBuffer.attach(e),this._gaussianPassV.setUniform("texture",n),this._gaussianPassV.setUniform("textureHeight",r),this._gaussianPassV.render(t),this._frameBuffer.unbind(t),this._texturePool.put(n)},_getTexture:function(t,e){var r=t.__uid__,i=this._textures[r],n=t.shadowResolution||512;return e=e||1,i||((i="POINT_LIGHT"===t.type?new Mi:new Er).width=n*e,i.height=n,this.softShadow===ef.VSM?(i.type=br.FLOAT,i.anisotropic=4):(i.minFilter=C,i.magFilter=C,i.useMipmap=!1),this._textures[r]=i),i},_getPointLightCamera:function(t,e){this._lightCameras.point||(this._lightCameras.point={px:new Ai,nx:new Ai,py:new Ai,ny:new Ai,pz:new Ai,nz:new Ai});var r=this._lightCameras.point[e];switch(r.far=t.range,r.fov=90,r.position.set(0,0,0),e){case"px":r.lookAt(ve.POSITIVE_X,ve.NEGATIVE_Y);break;case"nx":r.lookAt(ve.NEGATIVE_X,ve.NEGATIVE_Y);break;case"py":r.lookAt(ve.POSITIVE_Y,ve.POSITIVE_Z);break;case"ny":r.lookAt(ve.NEGATIVE_Y,ve.NEGATIVE_Z);break;case"pz":r.lookAt(ve.POSITIVE_Z,ve.NEGATIVE_Y);break;case"nz":r.lookAt(ve.NEGATIVE_Z,ve.NEGATIVE_Y)}return t.getWorldPosition(r.position),r.update(),r},_getDirectionalLightCamera:function(){var t=new Ve,e=new ir,r=new ir;return function(i,n,a){this._lightCameras.directional||(this._lightCameras.directional=new hn);var o=this._lightCameras.directional;e.copy(n.viewBoundingBoxLastFrame),e.intersection(a.frustum.boundingBox),o.position.copy(e.min).add(e.max).scale(.5).transformMat4(a.worldTransform),o.rotation.copy(i.rotation),o.scale.copy(i.scale),o.updateWorldTransform(),Ve.invert(t,o.worldTransform),Ve.multiply(t,t,a.worldTransform),r.copy(e).applyTransform(t);var s=r.min.array,l=r.max.array;return o.position.set((s[0]+l[0])/2,(s[1]+l[1])/2,l[2]).transformMat4(o.worldTransform),o.near=0,o.far=-s[2]+l[2],isNaN(this.lightFrustumBias)?o.far*=4:o.far+=this.lightFrustumBias,o.left=s[0],o.right=l[0],o.top=l[1],o.bottom=s[1],o.update(!0),o}}(),_getSpotLightCamera:function(t){this._lightCameras.spot||(this._lightCameras.spot=new Ai);var e=this._lightCameras.spot;return e.fov=2*t.penumbraAngle,e.far=t.range,e.worldTransform.copy(t.worldTransform),e.updateProjectionMatrix(),Yt.invert(e.viewMatrix.array,e.worldTransform.array),e},dispose:function(t){var e=t.gl||t;for(var r in this._frameBuffer&&this._frameBuffer.dispose(e),this._textures)this._textures[r].dispose(e);this._texturePool.clear(t.gl),this._depthMaterials={},this._distanceMaterials={},this._textures={},this._lightCameras={},this._shadowMapNumber={POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},this._meshMaterials={};for(var i=0;i<this._receivers.length;i++){var n=this._receivers[i];if(n.material){var a=n.material;a.undefine("fragment","POINT_LIGHT_SHADOW_COUNT"),a.undefine("fragment","DIRECTIONAL_LIGHT_SHADOW_COUNT"),a.undefine("fragment","AMBIENT_LIGHT_SHADOW_COUNT"),a.set("shadowEnabled",0)}}this._receivers=[],this._lightsCastShadow=[]}});ef.VSM=1,ef.PCF=2;const rf=ef,nf=m.extend((function(){return{name:"",inputLinks:{},outputLinks:{},_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),{updateParameter:function(t,e){var r,i,n=this.outputs[t],a=n.parameters,o=n._parametersCopy;if(o||(o=n._parametersCopy={}),a)for(var s in a)"width"!==s&&"height"!==s&&(o[s]=a[s]);return r=a.width instanceof Function?a.width.call(this,e):a.width,i=a.height instanceof Function?a.height.call(this,e):a.height,o.width===r&&o.height===i||this._outputTextures[t]&&this._outputTextures[t].dispose(e.gl),o.width=r,o.height=i,o},setParameter:function(t,e){},getParameter:function(t){},setParameters:function(t){for(var e in t)this.setParameter(e,t[e])},render:function(){},getOutput:function(t,e){if(null==e)return e=t,this._outputTextures[e];var r=this.outputs[e];return r?this._rendered?r.outputLastFrame?this._prevOutputTextures[e]:this._outputTextures[e]:this._rendering?(this._prevOutputTextures[e]||(this._prevOutputTextures[e]=this._compositor.allocateTexture(r.parameters||{})),this._prevOutputTextures[e]):(this.render(t),this._outputTextures[e]):void 0},removeReference:function(t){this._outputReferences[t]--,0===this._outputReferences[t]&&(this.outputs[t].keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t]))},link:function(t,e,r){this.inputLinks[t]={node:e,pin:r},e.outputLinks[r]||(e.outputLinks[r]=[]),e.outputLinks[r].push({node:this,pin:t}),this.pass.material.enableTexture(t)},clear:function(){this.inputLinks={},this.outputLinks={}},updateReference:function(t){if(!this._rendering){for(var e in this._rendering=!0,this.inputLinks){var r=this.inputLinks[e];r.node.updateReference(r.pin)}this._rendering=!1}t&&this._outputReferences[t]++},beforeFrame:function(){for(var t in this._rendered=!1,this.outputLinks)this._outputReferences[t]=0},afterFrame:function(){for(var t in this.outputLinks)this._outputReferences[t]>0&&(this.outputs[t].keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t]))}}),af=m.extend((function(){return{nodes:[]}}),{dirty:function(){this._dirty=!0},addNode:function(t){this.nodes.indexOf(t)>=0||(this.nodes.push(t),this._dirty=!0)},removeNode:function(t){"string"==typeof t&&(t=this.getNodeByName(t));var e=this.nodes.indexOf(t);e>=0&&(this.nodes.splice(e,1),this._dirty=!0)},getNodeByName:function(t){for(var e=0;e<this.nodes.length;e++)if(this.nodes[e].name===t)return this.nodes[e]},update:function(){for(var t=0;t<this.nodes.length;t++)this.nodes[t].clear();for(t=0;t<this.nodes.length;t++){var e=this.nodes[t];if(e.inputs)for(var r in e.inputs)if(e.inputs[r])if(!e.pass||e.pass.material.isUniformEnabled(r)){var i=e.inputs[r],n=this.findPin(i);n?e.link(r,n.node,n.pin):"string"==typeof i?console.warn("Node "+i+" not exist"):console.warn("Pin of "+i.node+"."+i.pin+" not exist")}else console.warn("Pin "+e.name+"."+r+" not used.")}},findPin:function(t){var e;if(("string"==typeof t||t instanceof nf)&&(t={node:t}),"string"==typeof t.node)for(var r=0;r<this.nodes.length;r++){var i=this.nodes[r];i.name===t.node&&(e=i)}else e=t.node;if(e){var n=t.pin;if(n||e.outputs&&(n=Object.keys(e.outputs)[0]),e.outputs[n])return{node:e,pin:n}}}}),of=af.extend((function(){return{_outputs:[],_texturePool:new Wd,_frameBuffer:new Fi({depthBuffer:!1})}}),{addNode:function(t){af.prototype.addNode.call(this,t),t._compositor=this},render:function(t,e){if(this._dirty){this.update(),this._dirty=!1,this._outputs.length=0;for(var r=0;r<this.nodes.length;r++)this.nodes[r].outputs||this._outputs.push(this.nodes[r])}for(r=0;r<this.nodes.length;r++)this.nodes[r].beforeFrame();for(r=0;r<this._outputs.length;r++)this._outputs[r].updateReference();for(r=0;r<this._outputs.length;r++)this._outputs[r].render(t,e);for(r=0;r<this.nodes.length;r++)this.nodes[r].afterFrame()},allocateTexture:function(t){return this._texturePool.get(t)},releaseTexture:function(t){this._texturePool.put(t)},getFrameBuffer:function(){return this._frameBuffer},dispose:function(t){this._texturePool.clear(t)}}),sf=nf.extend({name:"scene",scene:null,camera:null,autoUpdateScene:!0,preZ:!1},(function(){this.frameBuffer=new Fi}),{render:function(t){this._rendering=!0;var e,r=t.gl;if(this.trigger("beforerender"),this.outputs){var i=this.frameBuffer;for(var n in this.outputs){var a=this.updateParameter(n,t),o=this.outputs[n],s=this._compositor.allocateTexture(a);this._outputTextures[n]=s,"string"==typeof(u=o.attachment||r.COLOR_ATTACHMENT0)&&(u=r[u]),i.attach(s,u)}i.bind(t);var l=t.getGLExtension("EXT_draw_buffers");if(l){var h=[];for(var u in this.outputs)(u=parseInt(u))>=r.COLOR_ATTACHMENT0&&u<=r.COLOR_ATTACHMENT0+8&&h.push(u);l.drawBuffersEXT(h)}t.saveClear(),t.clearBit=16640,e=t.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),t.restoreClear(),i.unbind(t)}else e=t.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",e),this._rendering=!1,this._rendered=!0}}),lf=nf.extend((function(){return{texture:null,outputs:{color:{}}}}),(function(){}),{getOutput:function(t,e){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),hf=nf.extend((function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}}),(function(){var t=new fn({fragment:this.shader});this.pass=t}),{render:function(t,e){this.trigger("beforerender",t),this._rendering=!0;var r=t.gl;for(var i in this.inputLinks){var n=(c=this.inputLinks[i]).node.getOutput(t,c.pin);this.pass.setUniform(i,n)}if(this.outputs){this.pass.outputs={};var a={};for(var o in this.outputs){var s=this.updateParameter(o,t);isNaN(s.width)&&this.updateParameter(o,t);var l=this.outputs[o],h=this._compositor.allocateTexture(s);this._outputTextures[o]=h,"string"==typeof(u=l.attachment||r.COLOR_ATTACHMENT0)&&(u=r[u]),a[u]=h}for(var u in this._compositor.getFrameBuffer().bind(t),a)this._compositor.getFrameBuffer().attach(a[u],u);this.pass.render(t),this._compositor.getFrameBuffer().updateMipmap(t)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(t),this.pass.render(t,e);for(var i in this.inputLinks){var c;(c=this.inputLinks[i]).node.removeReference(c.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",t)},updateParameter:function(t,e){var r,i,n=this.outputs[t],a=n.parameters,o=n._parametersCopy;if(o||(o=n._parametersCopy={}),a)for(var s in a)"width"!==s&&"height"!==s&&(o[s]=a[s]);return r="function"==typeof a.width?a.width.call(this,e):a.width,i="function"==typeof a.height?a.height.call(this,e):a.height,r=Math.ceil(r),i=Math.ceil(i),o.width===r&&o.height===i||this._outputTextures[t]&&this._outputTextures[t].dispose(e),o.width=r,o.height=i,o},setParameter:function(t,e){this.pass.setUniform(t,e)},getParameter:function(t){return this.pass.getUniform(t)},setParameters:function(t){for(var e in t)this.setParameter(e,t[e])},define:function(t,e){this.pass.material.define("fragment",t,e)},undefine:function(t){this.pass.material.undefine("fragment",t)},removeReference:function(t){this._outputReferences[t]--,0===this._outputReferences[t]&&(this.outputs[t].keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t]))},clear:function(){nf.prototype.clear.call(this),this.pass.material.disableTexturesAll()}}),uf="@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n",cf="\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end",df="@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",ff="@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n",pf="@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end",mf="\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end",gf="@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end",_f="@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end",vf="@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end";!function(t){t.import("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"),t.import(uf),t.import("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"),t.import(cf),t.import("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"),t.import(df),t.import(ff),t.import(pf),t.import(mf),t.import(gf),t.import("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"),t.import(_f),t.import(vf)}(Xt);var yf=/^#source\((.*?)\)/;function xf(t,e,r){var i,n,a,o,s=t.type||"filter";if("filter"===s){var l=t.shader.trim(),h=yf.exec(l);if(h?i=Xt.source(h[1].trim()):"#"===l.charAt(0)&&(i=e.shaders[l.substr(1)]),i||(i=l),!i)return}if(t.inputs)for(var u in n={},t.inputs)"string"==typeof t.inputs[u]?n[u]=t.inputs[u]:n[u]={node:t.inputs[u].node,pin:t.inputs[u].pin};if(t.outputs)for(var u in a={},t.outputs){var c=t.outputs[u];a[u]={},null!=c.attachment&&(a[u].attachment=c.attachment),null!=c.keepLastFrame&&(a[u].keepLastFrame=c.keepLastFrame),null!=c.outputLastFrame&&(a[u].outputLastFrame=c.outputLastFrame),c.parameters&&(a[u].parameters=Tf(c.parameters))}if(o="scene"===s?new sf({name:t.name,scene:r.scene,camera:r.camera,outputs:a}):"texture"===s?new lf({name:t.name,outputs:a}):new hf({name:t.name,shader:i,inputs:n,outputs:a})){if(t.parameters)for(var u in t.parameters)"string"==typeof(d=t.parameters[u])?"#"===(d=d.trim()).charAt(0)?d=e.textures[d.substr(1)]:o.on("beforerender",Sf(u,Mf(d))):"function"==typeof d&&o.on("beforerender",d),o.setParameter(u,d);if(t.defines&&o.pass)for(var u in t.defines){var d=t.defines[u];o.pass.material.define("fragment",u,d)}}return o}function bf(t,e){return t}function wf(t,e){return e}function Tf(t){var e={};if(!t)return e;["type","minFilter","magFilter","wrapS","wrapT","flipY","useMipmap"].forEach((function(r){var i=t[r];null!=i&&("string"==typeof i&&(i=br[i]),e[r]=i)}));var r=t.scale||1;return["width","height"].forEach((function(i){if(null!=t[i]){var n=t[i];"string"==typeof n?(n=n.trim(),e[i]=(a=Mf(n),o=(o=r)||1,function(t){var e=t.getDevicePixelRatio(),r=t.getWidth()*o,i=t.getHeight()*o;return a(r,i,e)})):e[i]=n}var a,o})),e.width||(e.width=bf),e.height||(e.height=wf),null!=t.useMipmap&&(e.useMipmap=t.useMipmap),e}function Sf(t,e){return function(r){var i=r.getDevicePixelRatio(),n=r.getWidth(),a=r.getHeight(),o=e(n,a,i);this.setParameter(t,o)}}function Mf(t){var e=/^expr\((.*)\)$/.exec(t);if(e)try{var r=new Function("width","height","dpr","return "+e[1]);return r(1,1),r}catch(t){throw new Error("Invalid expression.")}}const Af=function(t,e){for(var r=0,i=1/e,n=t;n>0;)r+=i*(n%e),n=Math.floor(n/e),i/=e;return r};function Cf(t){for(var e=new Uint8Array(t*t*4),r=0,i=new ve,n=0;n<t;n++)for(var a=0;a<t;a++)i.set(2*Math.random()-1,2*Math.random()-1,0).normalize(),e[r++]=255*(.5*i.x+.5),e[r++]=255*(.5*i.y+.5),e[r++]=0,e[r++]=255;return e}function Ef(t){return new Er({pixels:Cf(t),wrapS:br.REPEAT,wrapT:br.REPEAT,width:t,height:t})}function Df(t,e,r){var i=new Float32Array(3*t);e=e||0;for(var n=0;n<t;n++){var a=Af(n+e,2)*(r?1:2)*Math.PI,o=Af(n+e,3)*Math.PI,s=Math.random(),l=Math.cos(a)*Math.sin(o)*s,h=Math.cos(o)*s,u=Math.sin(a)*Math.sin(o)*s;i[3*n]=l,i[3*n+1]=h,i[3*n+2]=u}return i}function Lf(t){t=t||{},this._ssaoPass=new fn({fragment:Xt.source("ecgl.ssao.estimate")}),this._blurPass=new fn({fragment:Xt.source("ecgl.ssao.blur")}),this._framebuffer=new Fi({depthBuffer:!1}),this._ssaoTexture=new Er,this._blurTexture=new Er,this._blurTexture2=new Er,this._depthTex=t.depthTexture,this._normalTex=t.normalTexture,this.setNoiseSize(4),this.setKernelSize(t.kernelSize||12),null!=t.radius&&this.setParameter("radius",t.radius),null!=t.power&&this.setParameter("power",t.power),this._normalTex||(this._ssaoPass.material.disableTexture("normalTex"),this._blurPass.material.disableTexture("normalTex")),this._depthTex||this._blurPass.material.disableTexture("depthTex"),this._blurPass.material.setUniform("normalTex",this._normalTex),this._blurPass.material.setUniform("depthTex",this._depthTex)}Xt.import("@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),Lf.prototype.setDepthTexture=function(t){this._depthTex=t},Lf.prototype.setNormalTexture=function(t){this._normalTex=t,this._ssaoPass.material[t?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},Lf.prototype.update=function(t,e,r){var i=t.getWidth(),n=t.getHeight(),a=this._ssaoPass,o=this._blurPass;a.setUniform("kernel",this._kernels[r%this._kernels.length]),a.setUniform("depthTex",this._depthTex),null!=this._normalTex&&a.setUniform("normalTex",this._normalTex),a.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var s=new Ve;Ve.transpose(s,e.worldTransform),a.setUniform("projection",e.projectionMatrix.array),a.setUniform("projectionInv",e.invProjectionMatrix.array),a.setUniform("viewInverseTranspose",s.array);var l=this._ssaoTexture,h=this._blurTexture,u=this._blurTexture2;l.width=i/2,l.height=n/2,h.width=i,h.height=n,u.width=i,u.height=n,this._framebuffer.attach(l),this._framebuffer.bind(t),t.gl.clearColor(1,1,1,1),t.gl.clear(t.gl.COLOR_BUFFER_BIT),a.render(t),o.setUniform("textureSize",[i/2,n/2]),o.setUniform("projection",e.projectionMatrix.array),this._framebuffer.attach(h),o.setUniform("direction",0),o.setUniform("ssaoTexture",l),o.render(t),this._framebuffer.attach(u),o.setUniform("textureSize",[i,n]),o.setUniform("direction",1),o.setUniform("ssaoTexture",h),o.render(t),this._framebuffer.unbind(t);var c=t.clearColor;t.gl.clearColor(c[0],c[1],c[2],c[3])},Lf.prototype.getTargetTexture=function(){return this._blurTexture2},Lf.prototype.setParameter=function(t,e){"noiseTexSize"===t?this.setNoiseSize(e):"kernelSize"===t?this.setKernelSize(e):"intensity"===t?this._ssaoPass.material.set("intensity",e):this._ssaoPass.setUniform(t,e)},Lf.prototype.setKernelSize=function(t){this._kernelSize=t,this._ssaoPass.material.define("fragment","KERNEL_SIZE",t),this._kernels=this._kernels||[];for(var e=0;e<30;e++)this._kernels[e]=Df(t,e*t,!!this._normalTex)},Lf.prototype.setNoiseSize=function(t){var e=this._ssaoPass.getUniform("noiseTex");e?(e.data=Cf(t),e.width=e.height=t,e.dirty()):(e=Ef(t),this._ssaoPass.setUniform("noiseTex",Ef(t))),this._ssaoPass.setUniform("noiseTexSize",[t,t])},Lf.prototype.dispose=function(t){this._blurTexture.dispose(t),this._ssaoTexture.dispose(t),this._blurTexture2.dispose(t)};const Pf=Lf;function Of(t){t=t||{},this._ssrPass=new fn({fragment:Xt.source("ecgl.ssr.main"),clearColor:[0,0,0,0]}),this._blurPass1=new fn({fragment:Xt.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blurPass2=new fn({fragment:Xt.source("ecgl.ssr.blur"),clearColor:[0,0,0,0]}),this._blendPass=new fn({fragment:Xt.source("clay.compositor.blend")}),this._blendPass.material.disableTexturesAll(),this._blendPass.material.enableTexture(["texture1","texture2"]),this._ssrPass.setUniform("gBufferTexture1",t.normalTexture),this._ssrPass.setUniform("gBufferTexture2",t.depthTexture),this._blurPass1.setUniform("gBufferTexture1",t.normalTexture),this._blurPass1.setUniform("gBufferTexture2",t.depthTexture),this._blurPass2.setUniform("gBufferTexture1",t.normalTexture),this._blurPass2.setUniform("gBufferTexture2",t.depthTexture),this._blurPass2.material.define("fragment","VERTICAL"),this._blurPass2.material.define("fragment","BLEND"),this._ssrTexture=new Er({type:br.HALF_FLOAT}),this._texture2=new Er({type:br.HALF_FLOAT}),this._texture3=new Er({type:br.HALF_FLOAT}),this._prevTexture=new Er({type:br.HALF_FLOAT}),this._currentTexture=new Er({type:br.HALF_FLOAT}),this._frameBuffer=new Fi({depthBuffer:!1}),this._normalDistribution=null,this._totalSamples=256,this._samplePerFrame=4,this._ssrPass.material.define("fragment","SAMPLE_PER_FRAME",this._samplePerFrame),this._ssrPass.material.define("fragment","TOTAL_SAMPLES",this._totalSamples),this._downScale=1}Xt.import("@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),Of.prototype.setAmbientCubemap=function(t,e){this._ssrPass.material.set("specularCubemap",t),this._ssrPass.material.set("specularIntensity",e);var r=t&&e;this._ssrPass.material[r?"enableTexture":"disableTexture"]("specularCubemap")},Of.prototype.update=function(t,e,r,i){var n=t.getWidth(),a=t.getHeight(),o=this._ssrTexture,s=this._texture2,l=this._texture3;o.width=this._prevTexture.width=this._currentTexture.width=n/this._downScale,o.height=this._prevTexture.height=this._currentTexture.height=a/this._downScale,s.width=l.width=n,s.height=l.height=a;var h=this._frameBuffer,u=this._ssrPass,c=this._blurPass1,d=this._blurPass2,f=this._blendPass,p=new Ve,m=new Ve;Ve.transpose(p,e.worldTransform),Ve.transpose(m,e.viewMatrix),u.setUniform("sourceTexture",r),u.setUniform("projection",e.projectionMatrix.array),u.setUniform("projectionInv",e.invProjectionMatrix.array),u.setUniform("toViewSpace",p.array),u.setUniform("toWorldSpace",m.array),u.setUniform("nearZ",e.near);var g=i/this._totalSamples*this._samplePerFrame;if(u.setUniform("jitterOffset",g),u.setUniform("sampleOffset",i*this._samplePerFrame),c.setUniform("textureSize",[o.width,o.height]),d.setUniform("textureSize",[n,a]),d.setUniform("sourceTexture",r),c.setUniform("projection",e.projectionMatrix.array),d.setUniform("projection",e.projectionMatrix.array),h.attach(o),h.bind(t),u.render(t),this._physicallyCorrect&&(h.attach(this._currentTexture),f.setUniform("texture1",this._prevTexture),f.setUniform("texture2",o),f.material.set({weight1:i>=1?.95:0,weight2:i>=1?.05:1}),f.render(t)),h.attach(s),c.setUniform("texture",this._physicallyCorrect?this._currentTexture:o),c.render(t),h.attach(l),d.setUniform("texture",s),d.render(t),h.unbind(t),this._physicallyCorrect){var _=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=_}},Of.prototype.getTargetTexture=function(){return this._texture3},Of.prototype.setParameter=function(t,e){"maxIteration"===t?this._ssrPass.material.define("fragment","MAX_ITERATION",e):this._ssrPass.setUniform(t,e)},Of.prototype.setPhysicallyCorrect=function(t){t?(this._normalDistribution||(this._normalDistribution=gn.generateNormalDistribution(64,this._totalSamples)),this._ssrPass.material.define("fragment","PHYSICALLY_CORRECT"),this._ssrPass.material.set("normalDistribution",this._normalDistribution),this._ssrPass.material.set("normalDistributionSize",[64,this._totalSamples])):this._ssrPass.material.undefine("fragment","PHYSICALLY_CORRECT"),this._physicallyCorrect=t},Of.prototype.setSSAOTexture=function(t){var e=this._blurPass2;t?(e.material.enableTexture("ssaoTex"),e.material.set("ssaoTex",t)):e.material.disableTexture("ssaoTex")},Of.prototype.isFinished=function(t){return!this._physicallyCorrect||t>this._totalSamples/this._samplePerFrame},Of.prototype.dispose=function(t){this._ssrTexture.dispose(t),this._texture2.dispose(t),this._texture3.dispose(t),this._prevTexture.dispose(t),this._currentTexture.dispose(t),this._frameBuffer.dispose(t)};const Nf=Of,If=[0,0,-.321585265978,-.154972575841,.458126042375,.188473391593,.842080129861,.527766490688,.147304551086,-.659453822776,-.331943915203,-.940619700594,.0479226680259,.54812163202,.701581552186,-.709825561388,-.295436780218,.940589268233,-.901489676764,.237713156085,.973570876096,-.109899459384,-.866792314779,-.451805525005,.330975007087,.800048655954,-.344275183665,.381779221166,-.386139432542,-.437418421534,-.576478634965,-.0148463392551,.385798197415,-.262426961053,-.666302061145,.682427250835,-.628010632582,-.732836215494,.10163141741,-.987658134403,.711995289051,-.320024291314,.0296005138058,.950296523438,.0130612307608,-.351024443122,-.879596633704,-.10478487883,.435712737232,.504254490347,.779203817497,.206477676721,.388264289969,-.896736162545,-.153106280781,-.629203242522,-.245517550697,.657969239148,.126830499058,.26862328493,-.634888119007,-.302301223431,.617074219636,.779817204925];function Rf(t,e,r,i,n){var a=t.gl;e.setUniform(a,"1i",r,n),a.activeTexture(a.TEXTURE0+n),i.isRenderable()?i.bind(t):i.unbind(t)}function Bf(t,e,r,i,n){var a,o,s,l,h=t.gl;return function(n,u,c){if(!l||l.material!==n.material){var d=n.material,f=n.__program,p=d.get("roughness");null==p&&(p=1);var m=d.get("normalMap")||e,g=d.get("roughnessMap"),_=d.get("bumpMap"),v=d.get("uvRepeat"),y=d.get("uvOffset"),x=d.get("detailUvRepeat"),b=d.get("detailUvOffset"),w=!!_&&d.isTextureEnabled("bumpMap"),T=!!g&&d.isTextureEnabled("roughnessMap"),S=d.isDefined("fragment","DOUBLE_SIDED");_=_||r,g=g||i,c!==u?(u.set("normalMap",m),u.set("bumpMap",_),u.set("roughnessMap",g),u.set("useBumpMap",w),u.set("useRoughnessMap",T),u.set("doubleSide",S),null!=v&&u.set("uvRepeat",v),null!=y&&u.set("uvOffset",y),null!=x&&u.set("detailUvRepeat",x),null!=b&&u.set("detailUvOffset",b),u.set("roughness",p)):(f.setUniform(h,"1f","roughness",p),a!==m&&Rf(t,f,"normalMap",m,0),o!==_&&_&&Rf(t,f,"bumpMap",_,1),s!==g&&g&&Rf(t,f,"roughnessMap",g,2),null!=v&&f.setUniform(h,"2f","uvRepeat",v),null!=y&&f.setUniform(h,"2f","uvOffset",y),null!=x&&f.setUniform(h,"2f","detailUvRepeat",x),null!=b&&f.setUniform(h,"2f","detailUvOffset",b),f.setUniform(h,"1i","useBumpMap",+w),f.setUniform(h,"1i","useRoughnessMap",+T),f.setUniform(h,"1i","doubleSide",+S)),a=m,o=_,s=g,l=n}}}function Ff(t){t=t||{},this._depthTex=new Er({format:br.DEPTH_COMPONENT,type:br.UNSIGNED_INT}),this._normalTex=new Er({type:br.HALF_FLOAT}),this._framebuffer=new Fi,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,Fi.DEPTH_ATTACHMENT),this._normalMaterial=new lt({shader:new Xt(Xt.source("ecgl.normal.vertex"),Xt.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=nn.createBlank("#000"),this._defaultBumpMap=nn.createBlank("#000"),this._defaultRoughessMap=nn.createBlank("#000"),this._debugPass=new fn({fragment:Xt.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}Xt.import("@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"),Ff.prototype.getDepthTexture=function(){return this._depthTex},Ff.prototype.getNormalTexture=function(){return this._normalTex},Ff.prototype.update=function(t,e,r){var i=t.getWidth(),n=t.getHeight(),a=this._depthTex,o=this._normalTex,s=this._normalMaterial;a.width=i,a.height=n,o.width=i,o.height=n;var l=e.getRenderList(r).opaque;this._framebuffer.bind(t),t.gl.clearColor(0,0,0,0),t.gl.clear(t.gl.COLOR_BUFFER_BIT|t.gl.DEPTH_BUFFER_BIT),t.gl.disable(t.gl.BLEND),t.renderPass(l,r,{getMaterial:function(){return s},ifRender:function(t){return t.renderNormal},beforeRender:Bf(t,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:t.opaqueSortCompare}),this._framebuffer.unbind(t)},Ff.prototype.renderDebug=function(t){this._debugPass.render(t)},Ff.prototype.dispose=function(t){this._depthTex.dispose(t),this._normalTex.dispose(t)};const zf=Ff;function kf(t){t=t||{},this._edgePass=new fn({fragment:Xt.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",t.normalTexture),this._edgePass.setUniform("depthTexture",t.depthTexture),this._targetTexture=new Er({type:br.HALF_FLOAT}),this._frameBuffer=new Fi,this._frameBuffer.attach(this._targetTexture)}kf.prototype.update=function(t,e,r,i){var n=t.getWidth(),a=t.getHeight(),o=this._targetTexture;o.width=n,o.height=a;var s=this._frameBuffer;s.bind(t),this._edgePass.setUniform("projectionInv",e.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[n,a]),this._edgePass.setUniform("texture",r),this._edgePass.render(t),s.unbind(t)},kf.prototype.getTargetTexture=function(){return this._targetTexture},kf.prototype.setParameter=function(t,e){this._edgePass.setUniform(t,e)},kf.prototype.dispose=function(t){this._targetTexture.dispose(t),this._frameBuffer.dispose(t)};const Gf=kf,Uf={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(clay.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(clay.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_8_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_4_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_2_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bloom_composite",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(clay.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},defines:{}},{name:"FXAA",shader:"#source(clay.compositor.fxaa)",inputs:{texture:"composite"}}]};function Hf(t,e){return{color:{parameters:{width:t,height:e}}}}Xt.import(uf),Xt.import(cf),Xt.import(df),Xt.import(ff),Xt.import(pf),Xt.import(mf),Xt.import(gf),Xt.import(_f),Xt.import(vf),Xt.import("@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"),Xt.import("@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end");var Vf=["composite","FXAA"];function Wf(){this._width,this._height,this._dpr,this._sourceTexture=new Er({type:br.HALF_FLOAT}),this._depthTexture=new Er({format:br.DEPTH_COMPONENT,type:br.UNSIGNED_INT}),this._framebuffer=new Fi,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,Fi.DEPTH_ATTACHMENT),this._normalPass=new zf,this._compositor=function(t,e){var r=new of;e=e||{};var i={textures:{},parameters:{}};for(var n in t.parameters){var a=t.parameters[n];i.parameters[n]=Tf(a)}return function(t,e,r,i){if(t.textures){var n={},a=0,o=!1,s=r.textureRootPath;f.each(t.textures,(function(t,e){var r,l=t.path,h=Tf(t.parameters);if(Array.isArray(l)&&6===l.length)s&&(l=l.map((function(t){return f.relative2absolute(t,s)}))),r=new Mi(h);else{if("string"!=typeof l)return;s&&(l=f.relative2absolute(l,s)),r=new Er(h)}r.load(l),a++,r.once("success",(function(){n[e]=r,0==--a&&(i(n),o=!0)}))})),0!==a||o||i(n)}else i({})}(t,0,e,(function(n){i.textures=n,function(n,a){for(var o=0;o<t.nodes.length;o++){var s=xf(t.nodes[o],i,e);s&&r.addNode(s)}}()})),r}(Uf);var t=this._compositor.getNodeByName("source");t.texture=this._sourceTexture;var e=this._compositor.getNodeByName("coc");this._sourceNode=t,this._cocNode=e,this._compositeNode=this._compositor.getNodeByName("composite"),this._fxaaNode=this._compositor.getNodeByName("FXAA"),this._dofBlurNodes=["dof_far_blur","dof_near_blur","dof_coc_blur"].map((function(t){return this._compositor.getNodeByName(t)}),this),this._dofBlurKernel=0,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=Vf.map((function(t){return this._compositor.getNodeByName(t)}),this);var r={normalTexture:this._normalPass.getNormalTexture(),depthTexture:this._normalPass.getDepthTexture()};this._ssaoPass=new Pf(r),this._ssrPass=new Nf(r),this._edgePass=new Gf(r)}Wf.prototype.resize=function(t,e,r){t*=r=r||1,e*=r;var i=this._sourceTexture,n=this._depthTexture;i.width=t,i.height=e,n.width=t,n.height=e;var a={getWidth:function(){return t},getHeight:function(){return e},getDevicePixelRatio:function(){return r}};function o(t,e){if("function"==typeof t[e]){var r=t[e].__original||t[e];t[e]=function(t){return r.call(this,a)},t[e].__original=r}}this._compositor.nodes.forEach((function(t){for(var e in t.outputs){var r=t.outputs[e].parameters;r&&(o(r,"width"),o(r,"height"))}for(var i in t.parameters)o(t.parameters,i)})),this._width=t,this._height=e,this._dpr=r},Wf.prototype.getWidth=function(){return this._width},Wf.prototype.getHeight=function(){return this._height},Wf.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},Wf.prototype._getPrevNode=function(t){for(var e=Vf.indexOf(t.name)-1,r=this._finalNodesChain[e];r&&!this._compositor.getNodeByName(r.name);)e-=1,r=this._finalNodesChain[e];return r},Wf.prototype._getNextNode=function(t){for(var e=Vf.indexOf(t.name)+1,r=this._finalNodesChain[e];r&&!this._compositor.getNodeByName(r.name);)e+=1,r=this._finalNodesChain[e];return r},Wf.prototype._addChainNode=function(t){var e=this._getPrevNode(t),r=this._getNextNode(t);e&&(t.inputs.texture=e.name,r?(t.outputs=Hf(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=t.name):t.outputs=null,this._compositor.addNode(t))},Wf.prototype._removeChainNode=function(t){var e=this._getPrevNode(t),r=this._getNextNode(t);e&&(r?(e.outputs=Hf(this.getWidth.bind(this),this.getHeight.bind(this)),r.inputs.texture=e.name):e.outputs=null,this._compositor.removeNode(t))},Wf.prototype.updateNormal=function(t,e,r,i){this._ifRenderNormalPass()&&this._normalPass.update(t,e,r)},Wf.prototype.updateSSAO=function(t,e,r,i){this._ssaoPass.update(t,r,i)},Wf.prototype.enableSSAO=function(){this._enableSSAO=!0},Wf.prototype.disableSSAO=function(){this._enableSSAO=!1},Wf.prototype.enableSSR=function(){this._enableSSR=!0},Wf.prototype.disableSSR=function(){this._enableSSR=!1},Wf.prototype.getSSAOTexture=function(){return this._ssaoPass.getTargetTexture()},Wf.prototype.getSourceFrameBuffer=function(){return this._framebuffer},Wf.prototype.getSourceTexture=function(){return this._sourceTexture},Wf.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},Wf.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},Wf.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},Wf.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},Wf.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},Wf.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},Wf.prototype.enableColorCorrection=function(){this._compositeNode.define("COLOR_CORRECTION"),this._enableColorCorrection=!0},Wf.prototype.disableColorCorrection=function(){this._compositeNode.undefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},Wf.prototype.enableEdge=function(){this._enableEdge=!0},Wf.prototype.disableEdge=function(){this._enableEdge=!1},Wf.prototype.setBloomIntensity=function(t){this._compositeNode.setParameter("bloomIntensity",t)},Wf.prototype.setSSAOParameter=function(t,e){switch(t){case"quality":var r={low:6,medium:12,high:32,ultra:62}[e]||12;this._ssaoPass.setParameter("kernelSize",r);break;case"radius":this._ssaoPass.setParameter(t,e),this._ssaoPass.setParameter("bias",e/200);break;case"intensity":this._ssaoPass.setParameter(t,e)}},Wf.prototype.setDOFParameter=function(t,e){switch(t){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(t,e);break;case"blurRadius":for(var r=0;r<this._dofBlurNodes.length;r++)this._dofBlurNodes[r].setParameter("blurRadius",e);break;case"quality":var i={low:4,medium:8,high:16,ultra:32}[e]||8;for(this._dofBlurKernelSize=i,r=0;r<this._dofBlurNodes.length;r++)this._dofBlurNodes[r].pass.material.define("POISSON_KERNEL_SIZE",i);this._dofBlurKernel=new Float32Array(2*i)}},Wf.prototype.setSSRParameter=function(t,e){if(null!=e)switch(t){case"quality":var r={low:10,medium:15,high:30,ultra:80}[e]||20,i={low:32,medium:16,high:8,ultra:4}[e]||16;this._ssrPass.setParameter("maxIteration",r),this._ssrPass.setParameter("pixelStride",i);break;case"maxRoughness":this._ssrPass.setParameter("minGlossiness",Math.max(Math.min(1-e,1),0));break;case"physical":this.setPhysicallyCorrectSSR(e);break;default:console.warn("Unkown SSR parameter "+t)}},Wf.prototype.setPhysicallyCorrectSSR=function(t){this._ssrPass.setPhysicallyCorrect(t)},Wf.prototype.setEdgeColor=function(t){var e=mo.parseColor(t);this._edgePass.setParameter("edgeColor",e)},Wf.prototype.setExposure=function(t){this._compositeNode.setParameter("exposure",Math.pow(2,t))},Wf.prototype.setColorLookupTexture=function(t,e){this._compositeNode.pass.material.setTextureImage("lut",this._enableColorCorrection?t:"none",e,{minFilter:mo.Texture.NEAREST,magFilter:mo.Texture.NEAREST,flipY:!1})},Wf.prototype.setColorCorrection=function(t,e){this._compositeNode.setParameter(t,e)},Wf.prototype.isSSREnabled=function(){return this._enableSSR},Wf.prototype.composite=function(t,e,r,i,n){var a=this._sourceTexture,o=a;this._enableEdge&&(this._edgePass.update(t,r,a,n),a=o=this._edgePass.getTargetTexture()),this._enableSSR&&(this._ssrPass.update(t,r,a,n),o=this._ssrPass.getTargetTexture(),this._ssrPass.setSSAOTexture(this._enableSSAO?this._ssaoPass.getTargetTexture():null)),this._sourceNode.texture=o,this._cocNode.setParameter("depth",this._depthTexture);for(var s=this._dofBlurKernel,l=this._dofBlurKernelSize,h=n%Math.floor(If.length/2/l),u=0;u<2*l;u++)s[u]=If[u+h*l*2];for(u=0;u<this._dofBlurNodes.length;u++)this._dofBlurNodes[u].setParameter("percent",n/30),this._dofBlurNodes[u].setParameter("poissonKernel",s);this._cocNode.setParameter("zNear",r.near),this._cocNode.setParameter("zFar",r.far),this._compositor.render(t,i)},Wf.prototype.dispose=function(t){this._sourceTexture.dispose(t),this._depthTexture.dispose(t),this._framebuffer.dispose(t),this._compositor.dispose(t),this._normalPass.dispose(t),this._ssaoPass.dispose(t)};const jf=Wf;function Xf(t){for(var e=[],r=0;r<30;r++)e.push([Af(r,2),Af(r,3)]);this._haltonSequence=e,this._frame=0,this._sourceTex=new Er,this._sourceFb=new Fi,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new Er,this._outputTex=new Er;var i=this._blendPass=new fn({fragment:Xt.source("clay.compositor.blend")});i.material.disableTexturesAll(),i.material.enableTexture(["texture1","texture2"]),this._blendFb=new Fi({depthBuffer:!1}),this._outputPass=new fn({fragment:Xt.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(t){t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)}}Xf.prototype={constructor:Xf,jitterProjection:function(t,e){var r=t.viewport,i=r.devicePixelRatio||t.getDevicePixelRatio(),n=r.width*i,a=r.height*i,o=this._haltonSequence[this._frame%this._haltonSequence.length],s=new Ve;s.array[12]=(2*o[0]-1)/n,s.array[13]=(2*o[1]-1)/a,Ve.mul(e.projectionMatrix,s,e.projectionMatrix),Ve.invert(e.invProjectionMatrix,e.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(t,e){this._prevFrameTex.width=t,this._prevFrameTex.height=e,this._outputTex.width=t,this._outputTex.height=e,this._sourceTex.width=t,this._sourceTex.height=e,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(t,e,r){var i=this._blendPass;0===this._frame?(i.setUniform("weight1",0),i.setUniform("weight2",1)):(i.setUniform("weight1",.9),i.setUniform("weight2",.1)),i.setUniform("texture1",this._prevFrameTex),i.setUniform("texture2",e||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(t),i.render(t),this._blendFb.unbind(t),r||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(t));var n=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=n,this._frame++},dispose:function(t){this._sourceFb.dispose(t),this._blendFb.dispose(t),this._prevFrameTex.dispose(t),this._outputTex.dispose(t),this._sourceTex.dispose(t),this._outputPass.dispose(t),this._blendPass.dispose(t)}};const qf=Xf;function Zf(t){t=t||"perspective",this.layer=null,this.scene=new _i,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.setProjection(t),this._compositor=new jf,this._temporalSS=new qf,this._shadowMapPass=new rf;for(var e=[],r=0,i=0;i<30;i++){for(var n=[],a=0;a<6;a++)n.push(4*Af(r,2)-2),n.push(4*Af(r,3)-2),r++;e.push(n)}this._pcfKernels=e,this.scene.on("beforerender",(function(t,e,r){this.needsTemporalSS()&&this._temporalSS.jitterProjection(t,r)}),this)}Zf.prototype.setProjection=function(t){var e=this.camera;e&&e.update(),"perspective"===t?this.camera instanceof Ai||(this.camera=new Ai,e&&this.camera.setLocalTransform(e.localTransform)):this.camera instanceof hn||(this.camera=new hn,e&&this.camera.setLocalTransform(e.localTransform)),this.camera.near=.1,this.camera.far=2e3},Zf.prototype.setViewport=function(t,e,r,i,n){this.camera instanceof Ai&&(this.camera.aspect=r/i),n=n||1,this.viewport.x=t,this.viewport.y=e,this.viewport.width=r,this.viewport.height=i,this.viewport.devicePixelRatio=n,this._compositor.resize(r*n,i*n),this._temporalSS.resize(r*n,i*n)},Zf.prototype.containPoint=function(t,e){var r=this.viewport;return e=this.layer.renderer.getHeight()-e,t>=r.x&&e>=r.y&&t<=r.x+r.width&&e<=r.y+r.height};var Yf=new _t;Zf.prototype.castRay=function(t,e,r){var i=this.layer.renderer,n=i.viewport;return i.viewport=this.viewport,i.screenToNDC(t,e,Yf),this.camera.castRay(Yf,r),i.viewport=n,r},Zf.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var t=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var e=0;e<t.transparent.length;e++){var r=t.transparent[e].geometry;r.needsSortVerticesProgressively&&r.needsSortVerticesProgressively()&&(this._needsSortProgressively=!0),r.needsSortTrianglesProgressively&&r.needsSortTrianglesProgressively()&&(this._needsSortProgressively=!0)}this._frame=0,this._temporalSS.resetFrame()},Zf.prototype.render=function(t,e){this._doRender(t,e,this._frame),this._frame++},Zf.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},Zf.prototype.needsTemporalSS=function(){var t=this._enableTemporalSS;return"auto"===t&&(t=this._enablePostEffect),t},Zf.prototype.hasDOF=function(){return this._enableDOF},Zf.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},Zf.prototype._doRender=function(t,e,r){var i=this.scene,n=this.camera;r=r||0,this._updateTransparent(t,i,n,r),e||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(t,i,n,!0)),this._updateShadowPCFKernel(r);var a,o=t.clearColor;t.gl.clearColor(o[0],o[1],o[2],o[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(t,n),this._compositor.updateNormal(t,i,n,this._temporalSS.getFrame())),this._updateSSAO(t,i,n,this._temporalSS.getFrame()),this._enablePostEffect?((a=this._compositor.getSourceFrameBuffer()).bind(t),t.gl.clear(t.gl.DEPTH_BUFFER_BIT|t.gl.COLOR_BUFFER_BIT),t.render(i,n,!0,!0),a.unbind(t),this.needsTemporalSS()&&e?(this._compositor.composite(t,i,n,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),t.setViewport(this.viewport),this._temporalSS.render(t)):(t.setViewport(this.viewport),this._compositor.composite(t,i,n,null,0))):this.needsTemporalSS()&&e?((a=this._temporalSS.getSourceFrameBuffer()).bind(t),t.saveClear(),t.clearBit=t.gl.DEPTH_BUFFER_BIT|t.gl.COLOR_BUFFER_BIT,t.render(i,n,!0,!0),t.restoreClear(),a.unbind(t),t.setViewport(this.viewport),this._temporalSS.render(t)):(t.setViewport(this.viewport),t.render(i,n,!0,!0))},Zf.prototype._updateTransparent=function(t,e,r,i){for(var n=new ve,a=new Ve,o=r.getWorldPosition(),s=e.getRenderList(r).transparent,l=0;l<s.length;l++){var h=s[l],u=h.geometry;Ve.invert(a,h.worldTransform),ve.transformMat4(n,o,a),u.needsSortTriangles&&u.needsSortTriangles()&&u.doSortTriangles(n,i),u.needsSortVertices&&u.needsSortVertices()&&u.doSortVertices(n,i)}},Zf.prototype._updateSSAO=function(t,e,r){var i=this._enableSSAO&&this._enablePostEffect;i&&this._compositor.updateSSAO(t,e,r,this._temporalSS.getFrame());for(var n=e.getRenderList(r),a=0;a<n.opaque.length;a++){var o=n.opaque[a];o.renderNormal&&o.material[i?"enableTexture":"disableTexture"]("ssaoMap"),i&&o.material.set("ssaoMap",this._compositor.getSSAOTexture())}},Zf.prototype._updateShadowPCFKernel=function(t){for(var e=this._pcfKernels[t%this._pcfKernels.length],r=this.scene.getRenderList(this.camera).opaque,i=0;i<r.length;i++)r[i].receiveShadow&&(r[i].material.set("pcfKernel",e),r[i].material.define("fragment","PCF_KERNEL_SIZE",e.length/2))},Zf.prototype.dispose=function(t){this._compositor.dispose(t.gl),this._temporalSS.dispose(t.gl),this._shadowMapPass.dispose(t)},Zf.prototype.setPostEffect=function(t,e){var r=this._compositor;this._enablePostEffect=t.get("enable");var i=t.getModel("bloom"),n=t.getModel("edge"),a=t.getModel("DOF",t.getModel("depthOfField")),o=t.getModel("SSAO",t.getModel("screenSpaceAmbientOcclusion")),s=t.getModel("SSR",t.getModel("screenSpaceReflection")),l=t.getModel("FXAA"),h=t.getModel("colorCorrection");i.get("enable")?r.enableBloom():r.disableBloom(),a.get("enable")?r.enableDOF():r.disableDOF(),s.get("enable")?r.enableSSR():r.disableSSR(),h.get("enable")?r.enableColorCorrection():r.disableColorCorrection(),n.get("enable")?r.enableEdge():r.disableEdge(),l.get("enable")?r.enableFXAA():r.disableFXAA(),this._enableDOF=a.get("enable"),this._enableSSAO=o.get("enable"),this._enableSSAO?r.enableSSAO():r.disableSSAO(),r.setBloomIntensity(i.get("intensity")),r.setEdgeColor(n.get("color")),r.setColorLookupTexture(h.get("lookupTexture"),e),r.setExposure(h.get("exposure")),["radius","quality","intensity"].forEach((function(t){r.setSSAOParameter(t,o.get(t))})),["quality","maxRoughness","physical"].forEach((function(t){r.setSSRParameter(t,s.get(t))})),["quality","focalDistance","focalRange","blurRadius","fstop"].forEach((function(t){r.setDOFParameter(t,a.get(t))})),["brightness","contrast","saturation"].forEach((function(t){r.setColorCorrection(t,h.get(t))}))},Zf.prototype.setDOFFocusOnPoint=function(t){if(this._enablePostEffect){if(t>this.camera.far||t<this.camera.near)return;return this._compositor.setDOFParameter("focalDistance",t),!0}},Zf.prototype.setTemporalSuperSampling=function(t){this._enableTemporalSS=t.get("enable")},Zf.prototype.isLinearSpace=function(){return this._enablePostEffect},Zf.prototype.setRootNode=function(t){if(this.rootNode!==t){for(var e=this.rootNode.children(),r=0;r<e.length;r++)t.add(e[r]);t!==this.scene&&this.scene.add(t),this.rootNode=t}},Zf.prototype.add=function(t){this.rootNode.add(t)},Zf.prototype.remove=function(t){this.rootNode.remove(t)},Zf.prototype.removeAll=function(t){this.rootNode.removeAll(t)},Object.assign(Zf.prototype,h);const Kf=Zf;function Qf(t,e){var r=kd(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});r.y=e.getHeight()-r.y-r.height,this.viewGL.setViewport(r.x,r.y,r.width,r.height,e.getDevicePixelRatio());var i=t.get("boxWidth"),n=t.get("boxHeight"),a=t.get("boxDepth");this.getAxis("x").setExtent(-i/2,i/2),this.getAxis("y").setExtent(a/2,-a/2),this.getAxis("z").setExtent(-n/2,n/2),this.size=[i,n,a]}function Jf(t,e){var r={};t.eachSeries((function(t){if(t.coordinateSystem===this){var e=t.getData();["x","y","z"].forEach((function(t){e.mapDimensionsAll(t,!0).forEach((function(i){!function(t,e){r[t]=r[t]||[1/0,-1/0],r[t][0]=Math.min(e[0],r[t][0]),r[t][1]=Math.max(e[1],r[t][1])}(t,e.getDataExtent(i,!0))}))}))}}),this),["xAxis3D","yAxis3D","zAxis3D"].forEach((function(e){t.eachComponent(e,(function(t){var n=e.charAt(0),a=t.getReferringComponents("grid3D").models[0],o=a.coordinateSystem;if(o===this){var s=o.getAxis(n);if(!s){var l=i.helper.createScale(r[n]||[1/0,-1/0],t);(s=new pd(n,l)).type=t.get("type");var h="category"===s.type;s.onBand=h&&t.get("boundaryGap"),s.inverse=t.get("inverse"),t.axis=s,s.model=t,s.getLabelModel=function(){return t.getModel("axisLabel",a.getModel("axisLabel"))},s.getTickModel=function(){return t.getModel("axisTick",a.getModel("axisTick"))},o.addAxis(s)}}}),this)}),this),this.resize(this.model,e)}var $f={dimensions:dd.prototype.dimensions,create:function(t,e){var r=[];t.eachComponent("grid3D",(function(t){t.__viewGL=t.__viewGL||new Kf;var e=new dd;e.model=t,e.viewGL=t.__viewGL,t.coordinateSystem=e,r.push(e),e.resize=Qf,e.update=Jf}));var i=["xAxis3D","yAxis3D","zAxis3D"];return t.eachSeries((function(e){if("cartesian3D"===e.get("coordinateSystem")){if(null==(n=e.getReferringComponents("grid3D").models[0])){var r=function(t,e){return i.map((function(r){var i=t.getReferringComponents(r).models[0];return null==i&&(i=e.getComponent(r)),i}))}(e,t),n=r[0].getCoordSysModel();r.forEach((function(t){t.getCoordSysModel()}))}var a=n.coordinateSystem;e.coordinateSystem=a}})),r}};i.registerCoordinateSystem("grid3D",$f),i.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},(function(t,e){e.eachComponent({mainType:"grid3D",query:t},(function(e){e.setView(t)}))})),i.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},(function(t,e){})),i.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},(function(t,e){}));const tp={defaultOption:{shading:null,realisticMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},lambertMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},colorMaterial:{textureTiling:1,textureOffset:0,detailTexture:null},hatchingMaterial:{textureTiling:1,textureOffset:0,paperColor:"#fff"}}},ep={getFilledRegions:function(t,e){var r,n=(t||[]).slice();if("string"==typeof e?r=(e=i.getMap(e))&&e.geoJson:e&&e.features&&(r=e),!r)return[];for(var a={},o=r.features,s=0;s<n.length;s++)a[n[s].name]=n[s];for(s=0;s<o.length;s++){var l=o[s].properties.name;a[l]||n.push({name:l})}return n},defaultOption:{show:!0,zlevel:-10,map:"",left:0,top:0,width:"100%",height:"100%",boxWidth:100,boxHeight:10,boxDepth:"auto",regionHeight:3,environment:"auto",groundPlane:{show:!1,color:"#aaa"},shading:"lambert",light:{main:{alpha:40,beta:30}},viewControl:{alpha:40,beta:0,distance:100,orthographicSize:60,minAlpha:5,minBeta:-80,maxBeta:80},label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}};var rp=i.extendComponentModel({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var t=this.option;t.regions=this.getFilledRegions(t.regions,t.map);var e=i.helper.createDimensions(["value"],t.data,{encodeDef:this.get("encode"),dimsDef:this.get("dimensions")}),r=new i.List(e,this);r.initData(t.regions);var n={};r.each((function(t){var e=r.getName(t),i=r.getItemModel(t);n[e]=i})),this._regionModelMap=n,this._data=r},getData:function(){return this._data},getRegionModel:function(t){var e=this.getData().getName(t);return this._regionModelMap[e]||new i.Model(null,this)},getRegionPolygonCoords:function(t){var e=this.getData().getName(t),r=this.coordinateSystem.getRegion(e);return r?r.geometries:[]},getFormattedLabel:function(t,e){var r=this._data.getName(t),i=this.getRegionModel(t),n=i.get("normal"===e?["label","formatter"]:["emphasis","label","formatter"]);null==n&&(n=i.get(["label","formatter"]));var a={name:r};if("function"==typeof n)return a.status=e,n(a);if("string"==typeof n){var o=a.seriesName;return n.replace("{a}",null!=o?o:"")}return r},defaultOption:{regions:[]}});i.util.merge(rp.prototype,ep),i.util.merge(rp.prototype,Uo),i.util.merge(rp.prototype,Ho),i.util.merge(rp.prototype,Vo),i.util.merge(rp.prototype,tp);const ip=np;function np(t,e,r){r=r||2;var i,n,a,o,s,l,h,u=e&&e.length,c=u?e[0]*r:t.length,d=ap(t,0,c,r,!0),f=[];if(!d)return f;if(u&&(d=function(t,e,r,i){var n,a,o,s=[];for(n=0,a=e.length;n<a;n++)(o=ap(t,e[n]*i,n<a-1?e[n+1]*i:t.length,i,!1))===o.next&&(o.steiner=!0),s.push(mp(o));for(s.sort(dp),n=0;n<s.length;n++)fp(s[n],r),r=op(r,r.next);return r}(t,e,d,r)),t.length>80*r){i=a=t[0],n=o=t[1];for(var p=r;p<c;p+=r)(s=t[p])<i&&(i=s),(l=t[p+1])<n&&(n=l),s>a&&(a=s),l>o&&(o=l);h=Math.max(a-i,o-n)}return sp(d,f,r,i,n,h),f}function ap(t,e,r,i,n){var a,o;if(n===Ap(t,e,r,i)>0)for(a=e;a<r;a+=i)o=Tp(a,t[a],t[a+1],o);else for(a=r-i;a>=e;a-=i)o=Tp(a,t[a],t[a+1],o);return o&&yp(o,o.next)&&(Sp(o),o=o.next),o}function op(t,e){if(!t)return t;e||(e=t);var r,i=t;do{if(r=!1,i.steiner||!yp(i,i.next)&&0!==vp(i.prev,i,i.next))i=i.next;else{if(Sp(i),(i=e=i.prev)===i.next)return null;r=!0}}while(r||i!==e);return e}function sp(t,e,r,i,n,a,o){if(t){!o&&a&&function(t,e,r,i){var n=t;do{null===n.z&&(n.z=pp(n.x,n.y,e,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,r,i,n,a,o,s,l,h=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,i=r,s=0,e=0;e<h&&(s++,i=i.nextZ);e++);for(l=h;s>0||l>0&&i;)0!==s&&(0===l||!i||r.z<=i.z)?(n=r,r=r.nextZ,s--):(n=i,i=i.nextZ,l--),a?a.nextZ=n:t=n,n.prevZ=a,a=n;r=i}a.nextZ=null,h*=2}while(o>1)}(n)}(t,i,n,a);for(var s,l,h=t;t.prev!==t.next;)if(s=t.prev,l=t.next,a?hp(t,i,n,a):lp(t))e.push(s.i/r),e.push(t.i/r),e.push(l.i/r),Sp(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?sp(t=up(t,e,r),e,r,i,n,a,2):2===o&&cp(t,e,r,i,n,a):sp(op(t),e,r,i,n,a,1);break}}}function lp(t){var e=t.prev,r=t,i=t.next;if(vp(e,r,i)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(gp(e.x,e.y,r.x,r.y,i.x,i.y,n.x,n.y)&&vp(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function hp(t,e,r,i){var n=t.prev,a=t,o=t.next;if(vp(n,a,o)>=0)return!1;for(var s=n.x<a.x?n.x<o.x?n.x:o.x:a.x<o.x?a.x:o.x,l=n.y<a.y?n.y<o.y?n.y:o.y:a.y<o.y?a.y:o.y,h=n.x>a.x?n.x>o.x?n.x:o.x:a.x>o.x?a.x:o.x,u=n.y>a.y?n.y>o.y?n.y:o.y:a.y>o.y?a.y:o.y,c=pp(s,l,e,r,i),d=pp(h,u,e,r,i),f=t.nextZ;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&gp(n.x,n.y,a.x,a.y,o.x,o.y,f.x,f.y)&&vp(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=c;){if(f!==t.prev&&f!==t.next&&gp(n.x,n.y,a.x,a.y,o.x,o.y,f.x,f.y)&&vp(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function up(t,e,r){var i=t;do{var n=i.prev,a=i.next.next;!yp(n,a)&&xp(n,i,i.next,a)&&bp(n,a)&&bp(a,n)&&(e.push(n.i/r),e.push(i.i/r),e.push(a.i/r),Sp(i),Sp(i.next),i=t=a),i=i.next}while(i!==t);return i}function cp(t,e,r,i,n,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&_p(o,s)){var l=wp(o,s);return o=op(o,o.next),l=op(l,l.next),sp(o,e,r,i,n,a),void sp(l,e,r,i,n,a)}s=s.next}o=o.next}while(o!==t)}function dp(t,e){return t.x-e.x}function fp(t,e){if(e=function(t,e){var r,i=e,n=t.x,a=t.y,o=-1/0;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=n&&s>o){if(o=s,s===n){if(a===i.y)return i;if(a===i.next.y)return i.next}r=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!r)return null;if(n===o)return r.prev;var l,h=r,u=r.x,c=r.y,d=1/0;for(i=r.next;i!==h;)n>=i.x&&i.x>=u&&n!==i.x&&gp(a<c?n:o,a,u,c,a<c?o:n,a,i.x,i.y)&&((l=Math.abs(a-i.y)/(n-i.x))<d||l===d&&i.x>r.x)&&bp(i,t)&&(r=i,d=l),i=i.next;return r}(t,e)){var r=wp(e,t);op(r,r.next)}}function pp(t,e,r,i,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)/n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function mp(t){var e=t,r=t;do{e.x<r.x&&(r=e),e=e.next}while(e!==t);return r}function gp(t,e,r,i,n,a,o,s){return(n-o)*(e-s)-(t-o)*(a-s)>=0&&(t-o)*(i-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(n-o)*(i-s)>=0}function _p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&xp(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&bp(t,e)&&bp(e,t)&&function(t,e){var r=t,i=!1,n=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&n<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==t);return i}(t,e)}function vp(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function yp(t,e){return t.x===e.x&&t.y===e.y}function xp(t,e,r,i){return!!(yp(t,e)&&yp(r,i)||yp(t,i)&&yp(r,e))||vp(t,e,r)>0!=vp(t,e,i)>0&&vp(r,i,t)>0!=vp(r,i,e)>0}function bp(t,e){return vp(t.prev,t,t.next)<0?vp(t,e,t.next)>=0&&vp(t,t.prev,e)>=0:vp(t,e,t.prev)<0||vp(t,t.next,e)<0}function wp(t,e){var r=new Mp(t.i,t.x,t.y),i=new Mp(e.i,e.x,e.y),n=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,a.next=i,i.prev=a,i}function Tp(t,e,r,i){var n=new Mp(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Sp(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 Mp(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ap(t,e,r,i){for(var n=0,a=e,o=r-i;a<r;a+=i)n+=(t[o]-t[a])*(t[a+1]+t[o+1]),o=a;return n}function Cp(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function Ep(t,e,r,i,n){var a=r,o=t[e];Cp(t,e,i);for(var s=r;s<i;s++)n(t[s],o)<0&&(Cp(t,s,a),a++);return Cp(t,i,a),a}function Dp(t,e,r,i){if(r<i){var n=Ep(t,Math.floor((r+i)/2),r,i,e);Dp(t,e,r,n-1),Dp(t,e,n+1,i)}}function Lp(){this._parts=[]}np.deviation=function(t,e,r,i){var n=e&&e.length,a=n?e[0]*r:t.length,o=Math.abs(Ap(t,0,a,r));if(n)for(var s=0,l=e.length;s<l;s++){var h=e[s]*r,u=s<l-1?e[s+1]*r:t.length;o-=Math.abs(Ap(t,h,u,r))}var c=0;for(s=0;s<i.length;s+=3){var d=i[s]*r,f=i[s+1]*r,p=i[s+2]*r;c+=Math.abs((t[d]-t[p])*(t[f+1]-t[d+1])-(t[d]-t[f])*(t[p+1]-t[d+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},Lp.prototype.step=function(t,e,r){var i=t.length;if(0===r){this._parts=[],this._sorted=!1;var n=Math.floor(i/2);this._parts.push({pivot:n,left:0,right:i-1}),this._currentSortPartIdx=0}if(!this._sorted){var a=this._parts;if(0===a.length)return this._sorted=!0,!0;if(a.length<512){for(var o=0;o<a.length;o++)a[o].pivot=Ep(t,a[o].pivot,a[o].left,a[o].right,e);var s=[];for(o=0;o<a.length;o++){var l,h=a[o].left;(l=a[o].pivot-1)>h&&s.push({pivot:Math.floor((l+h)/2),left:h,right:l}),h=a[o].pivot+1,(l=a[o].right)>h&&s.push({pivot:Math.floor((l+h)/2),left:h,right:l})}a=this._parts=s}else for(o=0;o<Math.floor(a.length/10);o++){var u=a.length-1-this._currentSortPartIdx;if(Dp(t,e,a[u].left,a[u].right),this._currentSortPartIdx++,this._currentSortPartIdx===a.length)return this._sorted=!0,!0}return!1}},Lp.sort=Dp;const Pp=Lp;var Op=Rc.vec3,Np=Op.create(),Ip=Op.create(),Rp=Op.create();const Bp={needsSortTriangles:function(){return this.indices&&this.sortTriangles},needsSortTrianglesProgressively:function(){return this.needsSortTriangles()&&this.triangleCount>=2e4},doSortTriangles:function(t,e){var r=this.indices;if(0===e){var i=this.attributes.position;t=t.array,this._triangleZList&&this._triangleZList.length===this.triangleCount||(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new r.constructor(r.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var n,a=0,o=0;o<r.length;){i.get(r[o++],Np),i.get(r[o++],Ip),i.get(r[o++],Rp);var s=Op.sqrDist(Np,t),l=Op.sqrDist(Ip,t),h=Op.sqrDist(Rp,t),u=Math.min(s,l);u=Math.min(u,h),3===o?(n=u,u=0):u-=n,this._triangleZList[a++]=u}}var c=this._sortedTriangleIndices;for(o=0;o<c.length;o++)c[o]=o;if(this.triangleCount<2e4)0===e&&this._simpleSort(!0);else for(o=0;o<3;o++)this._progressiveQuickSort(3*e+o);var d=this._indicesTmp,f=this._triangleZListTmp,p=this._triangleZList;for(o=0;o<this.triangleCount;o++){var m=3*c[o],g=3*o;d[g++]=r[m++],d[g++]=r[m++],d[g]=r[m],f[o]=p[c[o]]}var _=this._indicesTmp;this._indicesTmp=this.indices,this.indices=_,_=this._triangleZListTmp,this._triangleZListTmp=this._triangleZList,this._triangleZList=_,this.dirtyIndices()},_simpleSort:function(t){var e=this._triangleZList,r=this._sortedTriangleIndices;function i(t,r){return e[r]-e[t]}t?Array.prototype.sort.call(r,i):Pp.sort(r,i,0,r.length-1)},_progressiveQuickSort:function(t){var e=this._triangleZList,r=this._sortedTriangleIndices;this._quickSort=this._quickSort||new Pp,this._quickSort.step(r,(function(t,r){return e[r]-e[t]}),t)}};function Fp(t,e){const r=t.getItemVisual(e,"style");if(r)return r[t.getVisual("drawType")]}function zp(t,e){const r=t.getItemVisual(e,"style");return r&&r.opacity}function kp(t,e,r){this._labelsMesh=new ed,this._labelTextureSurface=new Hc({width:512,height:512,devicePixelRatio:r.getDevicePixelRatio(),onupdate:function(){r.getZr().refresh()}}),this._api=r,this._labelsMesh.material.set("textureAtlas",this._labelTextureSurface.getTexture())}kp.prototype.getLabelPosition=function(t,e,r){return[0,0,0]},kp.prototype.getLabelDistance=function(t,e,r){return 0},kp.prototype.getMesh=function(){return this._labelsMesh},kp.prototype.updateData=function(t,e,r){null==e&&(e=0),null==r&&(r=t.count()),this._labelsVisibilitiesBits&&this._labelsVisibilitiesBits.length===r-e||(this._labelsVisibilitiesBits=new Uint8Array(r-e));for(var i=["label","show"],n=["emphasis","label","show"],a=e;a<r;a++){var o=t.getItemModel(a),s=o.get(i),l=o.get(n);null==l&&(l=s);var h=(s?1:0)|(l?2:0);this._labelsVisibilitiesBits[a-e]=h}this._start=e,this._end=r,this._data=t},kp.prototype.updateLabels=function(t){if(this._data){for(var e=(t=t||[]).length>0,r={},n=0;n<t.length;n++)r[t[n]]=!0;this._labelsMesh.geometry.convertToDynamicArray(!0),this._labelTextureSurface.clear();for(var a=["label"],o=["emphasis","label"],s=this._data.hostModel,l=this._data,h=s.getModel(a),u=s.getModel(o,h),c={left:"right",right:"left",top:"center",bottom:"center"},d={left:"middle",right:"middle",top:"bottom",bottom:"top"},f=this._start;f<this._end;f++){var p=!1;if(e&&r[f]&&(p=!0),this._labelsVisibilitiesBits[f-this._start]&(p?2:1)){var m=l.getItemModel(f).getModel(p?o:a,p?u:h),g=m.get("distance")||0,_=m.get("position"),v=m.getModel("textStyle"),y=this._api.getDevicePixelRatio(),x=s.getFormattedLabel(f,p?"emphasis":"normal");if(null==x||""===x)return;var b=new i.graphic.Text({style:Sc(v,{text:x,fill:v.get("color")||Fp(l,f)||"#000",align:"left",verticalAlign:"top",opacity:Sn(v.get("opacity"),zp(l,f),1)})}),w=b.getBoundingRect();w.height*=1.2;var T=this._labelTextureSurface.add(b),S=c[_]||"center",M=d[_]||"bottom";this._labelsMesh.geometry.addSprite(this.getLabelPosition(f,_,g),[w.width*y,w.height*y],T,S,M,this.getLabelDistance(f,_,g)*y)}}this._labelsMesh.material.set("uvScale",this._labelTextureSurface.getCoordsScale()),this._labelTextureSurface.getZr().refreshImmediately(),this._labelsMesh.geometry.convertToTypedArray(),this._labelsMesh.geometry.dirty()}};const Gp=kp;var Up=Rc.vec3;function Hp(t){this.rootNode=new mo.Node,this._triangulationResults={},this._shadersMap=mo.COMMON_SHADERS.reduce((function(t,e){return t[e]=mo.createShader("ecgl."+e),t}),{}),this._linesShader=mo.createShader("ecgl.meshLines3D");var e={};mo.COMMON_SHADERS.forEach((function(t){e[t]=new mo.Material({shader:mo.createShader("ecgl."+t)})})),this._groundMaterials=e,this._groundMesh=new mo.Mesh({geometry:new mo.PlaneGeometry({dynamic:!0}),castShadow:!1,renderNormal:!0,$ignorePicking:!0}),this._groundMesh.rotation.rotateX(-Math.PI/2),this._labelsBuilder=new Gp(512,512,t),this._labelsBuilder.getMesh().renderOrder=100,this._labelsBuilder.getMesh().material.depthTest=!1,this.rootNode.add(this._labelsBuilder.getMesh()),this._initMeshes(),this._api=t}mo.Shader.import(sd),Hp.prototype={constructor:Hp,extrudeY:!0,update:function(t,e,r,i,n){var a=t.getData();null==i&&(i=0),null==n&&(n=a.count()),this._startIndex=i,this._endIndex=n-1,this._triangulation(t,i,n);var o=this._getShader(t.get("shading"));this._prepareMesh(t,o,r,i,n),this.rootNode.updateWorldTransform(),this._updateRegionMesh(t,r,i,n);var s=t.coordinateSystem;"geo3D"===s.type&&this._updateGroundPlane(t,s,r);var l=this;this._labelsBuilder.updateData(a,i,n),this._labelsBuilder.getLabelPosition=function(t,e,r){var i=a.getName(t),n=r;if("geo3D"===s.type){var o=s.getRegion(i);return o?(u=o.center,s.dataToPoint([u[0],u[1],n])):[NaN,NaN,NaN]}var h=l._triangulationResults[t-l._startIndex],u=l.extrudeY?[(h.max[0]+h.min[0])/2,h.max[1]+n,(h.max[2]+h.min[2])/2]:[(h.max[0]+h.min[0])/2,(h.max[1]+h.min[1])/2,h.max[2]+n]},this._data=a,this._labelsBuilder.updateLabels(),this._updateDebugWireframe(t),this._lastHoverDataIndex=0},_initMeshes:function(){var t=this,e=function(){var e=new mo.Mesh({name:"Polygon",material:new mo.Material({shader:t._shadersMap.lambert}),geometry:new mo.Geometry({sortTriangles:!0,dynamic:!0}),culling:!1,ignorePicking:!0,renderNormal:!0});return Object.assign(e.geometry,Bp),e}(),r=new mo.Mesh({material:new mo.Material({shader:this._linesShader}),castShadow:!1,ignorePicking:!0,$ignorePicking:!0,geometry:new kc({useNativeLine:!1})});this.rootNode.add(e),this.rootNode.add(r),e.material.define("both","VERTEX_COLOR"),e.material.define("fragment","DOUBLE_SIDED"),this._polygonMesh=e,this._linesMesh=r,this.rootNode.add(this._groundMesh)},_getShader:function(t){var e=this._shadersMap[t];return e||(e=this._shadersMap.lambert),e.__shading=t,e},_prepareMesh:function(t,e,r,i,n){for(var a=0,o=0,s=0,l=0,h=i;h<n;h++){var u=this._getRegionPolygonInfo(h),c=this._getRegionLinesInfo(h,t,this._linesMesh.geometry);a+=u.vertexCount,o+=u.triangleCount,s+=c.vertexCount,l+=c.triangleCount}var d=this._polygonMesh,f=d.geometry;["position","normal","texcoord0","color"].forEach((function(t){f.attributes[t].init(a)})),f.indices=a>65535?new Uint32Array(3*o):new Uint16Array(3*o),d.material.shader!==e&&d.material.attachShader(e,!0),mo.setMaterialFromModel(e.__shading,d.material,t,r),s>0&&(this._linesMesh.geometry.resetOffset(),this._linesMesh.geometry.setVertexCount(s),this._linesMesh.geometry.setTriangleCount(l)),this._dataIndexOfVertex=new Uint32Array(a),this._vertexRangeOfDataIndex=new Uint32Array(2*(n-i))},_updateRegionMesh:function(t,e,r,i){for(var n=t.getData(),a=0,o=0,s=!1,l=this._polygonMesh,h=this._linesMesh,u=r;u<i;u++){var c=t.getRegionModel(u),d=c.getModel("itemStyle"),f=Sn(Fp(n,u),d.get("color"),"#fff"),p=Sn(zp(n,u),1),m=mo.parseColor(f),g=mo.parseColor(d.get("borderColor"));m[3]*=p,g[3]*=p;var _=m[3]<.99;l.material.set("color",[1,1,1,1]),s=s||_;for(var v=Sn(c.get("height",!0),t.get("regionHeight")),y=this._updatePolygonGeometry(t,l.geometry,u,v,a,o,m),x=a;x<y.vertexOffset;x++)this._dataIndexOfVertex[x]=u;this._vertexRangeOfDataIndex[2*(u-r)]=a,this._vertexRangeOfDataIndex[2*(u-r)+1]=y.vertexOffset,a=y.vertexOffset,o=y.triangleOffset;var b=d.get("borderWidth"),w=b>0;w&&(b*=e.getDevicePixelRatio(),this._updateLinesGeometry(h.geometry,t,u,v,b,t.coordinateSystem.transform)),h.invisible=!w,h.material.set({color:g})}(l=this._polygonMesh).material.transparent=s,l.material.depthMask=!s,l.geometry.updateBoundingBox(),l.frontFace=this.extrudeY?mo.Mesh.CCW:mo.Mesh.CW,l.material.get("normalMap")&&l.geometry.generateTangents(),l.seriesIndex=t.seriesIndex,l.on("mousemove",this._onmousemove,this),l.on("mouseout",this._onmouseout,this)},_updateDebugWireframe:function(t){var e=t.getModel("debug.wireframe");if(e.get("show")){var r=mo.parseColor(e.get("lineStyle.color")||"rgba(0,0,0,0.5)"),i=Sn(e.get("lineStyle.width"),1),n=this._polygonMesh;n.geometry.generateBarycentric(),n.material.define("both","WIREFRAME_TRIANGLE"),n.material.set("wireframeLineColor",r),n.material.set("wireframeLineWidth",i)}},_onmousemove:function(t){var e=this._dataIndexOfVertex[t.triangle[0]];null==e&&(e=-1),e!==this._lastHoverDataIndex&&(this.downplay(this._lastHoverDataIndex),this.highlight(e),this._labelsBuilder.updateLabels([e])),this._lastHoverDataIndex=e,this._polygonMesh.dataIndex=e},_onmouseout:function(t){t.target&&(this.downplay(this._lastHoverDataIndex),this._lastHoverDataIndex=-1,this._polygonMesh.dataIndex=-1),this._labelsBuilder.updateLabels([])},_updateGroundPlane:function(t,e,r){var i=t.getModel("groundPlane",t);if(this._groundMesh.invisible=!i.get("show",!0),!this._groundMesh.invisible){var n=t.get("shading"),a=this._groundMaterials[n];a||(a=this._groundMaterials.lambert),mo.setMaterialFromModel(n,a,i,r),a.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=a,this._groundMesh.material.set("color",mo.parseColor(i.get("color"))),this._groundMesh.scale.set(e.size[0],e.size[2],1)}},_triangulation:function(t,e,r){this._triangulationResults=[];for(var i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],a=t.coordinateSystem,o=e;o<r;o++){for(var s=[],l=t.getRegionPolygonCoords(o),h=0;h<l.length;h++){var u=l[h].exterior,c=l[h].interiors,d=[],f=[];if(!(u.length<3)){for(var p=0,m=0;m<u.length;m++){var g=u[m];d[p++]=g[0],d[p++]=g[1]}for(m=0;m<c.length;m++)if(!(c[m].length<3)){for(var _=d.length/2,v=0;v<c[m].length;v++)g=c[m][v],d.push(g[0]),d.push(g[1]);f.push(_)}var y=ip(d,f),x=new Float64Array(d.length/2*3),b=[],w=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0],S=0;for(m=0;m<d.length;)Up.set(b,d[m++],0,d[m++]),a&&a.transform&&Up.transformMat4(b,b,a.transform),Up.min(w,w,b),Up.max(T,T,b),x[S++]=b[0],x[S++]=b[1],x[S++]=b[2];Up.min(i,i,w),Up.max(n,n,T),s.push({points:x,indices:y,min:w,max:T})}}this._triangulationResults.push(s)}this._geoBoundingBox=[i,n]},_getRegionPolygonInfo:function(t){for(var e=this._triangulationResults[t-this._startIndex],r=0,i=0,n=0;n<e.length;n++)r+=e[n].points.length/3,i+=e[n].indices.length/3;return{vertexCount:2*r+4*r,triangleCount:2*i+2*r}},_updatePolygonGeometry:function(t,e,r,i,n,a,o){var s=t.get("projectUVOnGround"),l=e.attributes.position,h=e.attributes.normal,u=e.attributes.texcoord0,c=e.attributes.color,d=this._triangulationResults[r-this._startIndex],f=c.value&&o,p=e.indices,m=this.extrudeY?1:2,g=this.extrudeY?2:1,_=[this.rootNode.worldTransform.x.len(),this.rootNode.worldTransform.y.len(),this.rootNode.worldTransform.z.len()],v=Up.mul([],this._geoBoundingBox[0],_),y=Up.mul([],this._geoBoundingBox[1],_),x=Math.max(y[0]-v[0],y[2]-v[2]);function b(t,e,r){var i=n;!function(t,e,r){for(var i=t.points,a=i.length,s=[],h=[],d=0;d<a;d+=3)s[0]=i[d],s[m]=e,s[g]=i[d+2],h[0]=(i[d]*_[0]-v[0])/x,h[1]=(i[d+2]*_[g]-v[2])/x,l.set(n,s),f&&c.set(n,o),u.set(n++,h)}(t,e);for(var s=t.indices.length,h=0;h<s;h++)p[3*a+h]=t.indices[h]+i;a+=t.indices.length/3}for(var w=this.extrudeY?[0,1,0]:[0,0,1],T=Up.negate([],w),S=0;S<d.length;S++){var M=n,A=d[S];b(A,0),b(A,i);for(var C=A.points.length/3,E=0;E<C;E++)h.set(M+E,T),h.set(M+E+C,w);var D=[0,3,1,1,3,2],L=[[],[],[],[]],P=[],O=[],N=[],I=[],R=0;for(E=0;E<C;E++){for(var B=(E+1)%C,F=(A.points[3*B]-A.points[3*E])*_[0],z=(A.points[3*B+2]-A.points[3*E+2])*_[g],k=Math.sqrt(F*F+z*z),G=0;G<4;G++){var U=0===G||3===G,H=3*(U?E:B);L[G][0]=A.points[H],L[G][m]=G>1?i:0,L[G][g]=A.points[H+2],l.set(n+G,L[G]),s?(I[0]=(A.points[H]*_[0]-v[0])/x,I[1]=(A.points[H+2]*_[g]-v[g])/x):(I[0]=(U?R:R+k)/x,I[1]=(L[G][m]*_[m]-v[m])/x),u.set(n+G,I)}for(Up.sub(P,L[1],L[0]),Up.sub(O,L[3],L[0]),Up.cross(N,P,O),Up.normalize(N,N),G=0;G<4;G++)h.set(n+G,N),f&&c.set(n+G,o);for(G=0;G<6;G++)p[3*a+G]=D[G]+n;n+=4,a+=2,R+=k}}return e.dirty(),{vertexOffset:n,triangleOffset:a}},_getRegionLinesInfo:function(t,e,r){var i=0,n=0;return e.getRegionModel(t).getModel("itemStyle").get("borderWidth")>0&&e.getRegionPolygonCoords(t).forEach((function(t){var e=t.exterior,a=t.interiors;i+=r.getPolylineVertexCount(e),n+=r.getPolylineTriangleCount(e);for(var o=0;o<a.length;o++)i+=r.getPolylineVertexCount(a[o]),n+=r.getPolylineTriangleCount(a[o])}),this),{vertexCount:i,triangleCount:n}},_updateLinesGeometry:function(t,e,r,i,n,a){function o(t){for(var e=new Float64Array(3*t.length),r=0,n=[],o=0;o<t.length;o++)n[0]=t[o][0],n[1]=i+.1,n[2]=t[o][1],a&&Up.transformMat4(n,n,a),e[r++]=n[0],e[r++]=n[1],e[r++]=n[2];return e}var s=[1,1,1,1];e.getRegionPolygonCoords(r).forEach((function(e){var r=e.exterior,i=e.interiors;t.addPolyline(o(r),s,n);for(var a=0;a<i.length;a++)t.addPolyline(o(i[a]),s,n)}))},highlight:function(t){var e=this._data;if(e){var r=e.getItemModel(t).getModel(["emphasis","itemStyle"]),n=r.get("color"),a=Sn(r.get("opacity"),zp(e,t),1);if(null==n){var o=Fp(e,t);n=i.color.lift(o,-.4)}null==a&&(a=zp(e,t));var s=mo.parseColor(n);s[3]*=a,this._setColorOfDataIndex(e,t,s)}},downplay:function(t){var e=this._data;if(e){var r=Sn(Fp(e,t),e.getItemModel(t).get(["itemStyle","color"]),"#fff"),i=Sn(zp(e,t),1),n=mo.parseColor(r);n[3]*=i,this._setColorOfDataIndex(e,t,n)}},_setColorOfDataIndex:function(t,e,r){if(!(e<this._startIndex&&e>this._endIndex)){e-=this._startIndex;for(var i=this._vertexRangeOfDataIndex[2*e];i<this._vertexRangeOfDataIndex[2*e+1];i++)this._polygonMesh.geometry.attributes.color.set(i,r);this._polygonMesh.geometry.dirty(),this._api.getZr().refresh()}}};const Vp=Hp;i.extendComponentView({type:"geo3D",__ecgl__:!0,init:function(t,e){this._geo3DBuilder=new Vp(e),this.groupGL=new mo.Node,this._lightRoot=new mo.Node,this._sceneHelper=new Wc(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new Nc({zr:e.getZr()}),this._control.init()},render:function(t,e,r){this.groupGL.add(this._geo3DBuilder.rootNode);var i=t.coordinateSystem;if(i&&i.viewGL){i.viewGL.add(this._lightRoot),t.get("show")?i.viewGL.add(this.groupGL):i.viewGL.remove(this.groupGL);var n=this._control;n.setViewGL(i.viewGL);var a=t.getModel("viewControl");n.setFromViewControlModel(a,0),this._sceneHelper.setScene(i.viewGL.scene),this._sceneHelper.updateLight(t),i.viewGL.setPostEffect(t.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling")),this._geo3DBuilder.update(t,e,r,0,t.getData().count());var o=i.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(t){t.material&&t.material[o]("fragment","SRGB_DECODE")})),n.off("update"),n.on("update",(function(){r.dispatchAction({type:"geo3DChangeCamera",alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance(),center:n.getCenter(),from:this.uid,geo3DId:t.id})})),n.update()}},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r)},dispose:function(){this._control.dispose()}});var Wp={南海诸岛:[32,80],广东:[0,-10],香港:[10,5],澳门:[-10,10],天津:[5,5]},jp={Russia:[100,60],"United States":[-99,38],"United States of America":[-99,38]},Xp=Rc.vec3,qp=Rc.mat4,Zp=[function(t,e){if("china"===t){var r=Wp[e.name];if(r){var i=e.center;i[0]+=r[0]/10.5,i[1]+=-r[1]/14}}},function(t,e){if("world"===t){var r=jp[e.name];if(r){var i=e.center;i[0]=r[0],i[1]=r[1]}}}];function Yp(t,e,r,i,n){this.name=t,this.map=e,this.regionHeight=0,this.regions=[],this._nameCoordMap={},this.loadGeoJson(r,i,n),this.transform=qp.identity(new Float64Array(16)),this.invTransform=qp.identity(new Float64Array(16)),this.extrudeY=!0,this.altitudeAxis}Yp.prototype={constructor:Yp,type:"geo3D",dimensions:["lng","lat","alt"],containPoint:function(){},loadGeoJson:function(t,e,r){var n=i.parseGeoJSON||i.parseGeoJson;try{this.regions=t?n(t):[]}catch(t){throw"Invalid geoJson format\n"+t}e=e||{},r=r||{};for(var a=this.regions,o={},s=0;s<a.length;s++){var l=a[s].name;l=r[l]||l,a[s].name=l,o[l]=a[s],this.addGeoCoord(l,a[s].center);var h=e[l];h&&a[s].transformTo(h.left,h.top,h.width,h.height)}this._regionsMap=o,this._geoRect=null,Zp.forEach((function(t){t(this)}),this)},getGeoBoundingRect:function(){if(this._geoRect)return this._geoRect;for(var t,e=this.regions,r=0;r<e.length;r++){var n=e[r].getBoundingRect();(t=t||n.clone()).union(n)}return this._geoRect=t||new i.graphic.BoundingRect(0,0,0,0)},addGeoCoord:function(t,e){this._nameCoordMap[t]=e},getRegion:function(t){return this._regionsMap[t]},getRegionByCoord:function(t){for(var e=this.regions,r=0;r<e.length;r++)if(e[r].contain(t))return e[r]},setSize:function(t,e,r){this.size=[t,e,r];var i=this.getGeoBoundingRect(),n=t/i.width,a=-r/i.height,o=-t/2-i.x*n,s=r/2-i.y*a,l=this.extrudeY?[o,0,s]:[o,s,0],h=this.extrudeY?[n,1,a]:[n,a,1],u=this.transform;qp.identity(u),qp.translate(u,u,l),qp.scale(u,u,h),qp.invert(this.invTransform,u)},dataToPoint:function(t,e){e=e||[];var r=this.extrudeY?1:2,i=this.extrudeY?2:1,n=t[2];return isNaN(n)&&(n=0),e[0]=t[0],e[i]=t[1],this.altitudeAxis?e[r]=this.altitudeAxis.dataToCoord(n):e[r]=0,e[r]+=this.regionHeight,Xp.transformMat4(e,e,this.transform),e},pointToData:function(t,e){}};const Kp=Yp;function Qp(t,e){var r=kd(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});r.y=e.getHeight()-r.y-r.height,this.viewGL.setViewport(r.x,r.y,r.width,r.height,e.getDevicePixelRatio());var i=this.getGeoBoundingRect(),n=i.width/i.height*(t.get("aspectScale")||.75),a=t.get("boxWidth"),o=t.get("boxDepth"),s=t.get("boxHeight");null==s&&(s=5),isNaN(a)&&isNaN(o)&&(a=100),isNaN(o)?o=a/n:isNaN(a)&&(a=o/n),this.setSize(a,s,o),this.regionHeight=t.get("regionHeight"),this.altitudeAxis&&this.altitudeAxis.setExtent(0,Math.max(s-this.regionHeight,0))}function Jp(t,e){var r=[1/0,-1/0];if(t.eachSeries((function(t){if(t.coordinateSystem===this&&"series.map3D"!==t.type){var e=t.getData(),i=t.coordDimToDataDim("alt"),n=i&&i[0];if(n){var a=e.getDataExtent(n,!0);r[0]=Math.min(r[0],a[0]),r[1]=Math.max(r[1],a[1])}}}),this),r&&isFinite(r[1]-r[0])){var n=i.helper.createScale(r,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new i.Axis("altitude",n),this.resize(this.model,e)}}var $p=0,tm={dimensions:Kp.prototype.dimensions,create:function(t,e){var r=[];if(!i.getMap)throw new Error("geo3D component depends on geo component");function n(t,i){var n=tm.createGeo3D(t);t.__viewGL=t.__viewGL||new Kf,n.viewGL=t.__viewGL,t.coordinateSystem=n,n.model=t,r.push(n),n.resize=Qp,n.resize(t,e),n.update=Jp}return t.eachComponent("geo3D",(function(t,e){n(t)})),t.eachSeriesByType("map3D",(function(t,e){var r=t.get("coordinateSystem");null==r&&(r="geo3D"),"geo3D"===r&&n(t)})),t.eachSeries((function(e){if("geo3D"===e.get("coordinateSystem")){if("series.map3D"===e.type)return;var r=e.getReferringComponents("geo3D").models[0];if(r||(r=t.getComponent("geo3D")),!r)throw new Error('geo "'+Sn(e.get("geo3DIndex"),e.get("geo3DId"),0)+'" not found');e.coordinateSystem=r.coordinateSystem}})),r},createGeo3D:function(t){var e,r=t.get("map");return"string"==typeof r?(e=r,r=i.getMap(r)):r&&r.features&&(r={geoJson:r}),null==e&&(e="GEO_ANONYMOUS_"+$p++),new Kp(e+$p++,e,r&&r.geoJson,r&&r.specialAreas,t.get("nameMap"))}};i.registerCoordinateSystem("geo3D",tm);const em=tm;function rm(t,e){t.id=t.id||t.name||e+""}i.registerAction({type:"geo3DChangeCamera",event:"geo3dcamerachanged",update:"series:updateCamera"},(function(t,e){e.eachComponent({mainType:"geo3D",query:t},(function(e){e.setView(t)}))}));var im=i.extendComponentModel({type:"globe",layoutMode:"box",coordinateSystem:null,init:function(){im.superApply(this,"init",arguments),i.util.each(this.option.layers,(function(t,e){i.util.merge(t,this.defaultLayerOption),rm(t,e)}),this)},mergeOption:function(t){var e=this.option.layers;function r(t){return i.util.reduce(t,(function(t,e,r){return rm(e,r),t[e.id]=e,t}),{})}if(this.option.layers=null,im.superApply(this,"mergeOption",arguments),e&&e.length){var n=r(t.layers),a=r(e);for(var o in n)a[o]?i.util.merge(a[o],n[o],!0):e.push(t.layers[o]);this.option.layers=e}i.util.each(this.option.layers,(function(t){i.util.merge(t,this.defaultLayerOption)}),this)},optionUpdated:function(){this.updateDisplacementHash()},defaultLayerOption:{show:!0,type:"overlay"},defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",baseColor:"#fff",baseTexture:"",heightTexture:"",displacementTexture:"",displacementScale:0,displacementQuality:"medium",globeRadius:100,globeOuterRadius:150,shading:"lambert",light:{main:{time:""}},atmosphere:{show:!1,offset:5,color:"#ffffff",glowPower:6,innerGlowPower:2},viewControl:{autoRotate:!0,panSensitivity:0,targetCoord:null},layers:[]},setDisplacementData:function(t,e,r){this.displacementData=t,this.displacementWidth=e,this.displacementHeight=r},getDisplacementTexture:function(){return this.get("displacementTexture")||this.get("heightTexture")},getDisplacemenScale:function(){var t=this.getDisplacementTexture(),e=this.get("displacementScale");return t&&"none"!==t||(e=0),e},hasDisplacement:function(){return this.getDisplacemenScale()>0},_displacementChanged:!0,_displacementScale:0,updateDisplacementHash:function(){var t=this.getDisplacementTexture(),e=this.getDisplacemenScale();this._displacementChanged=this._displacementTexture!==t||this._displacementScale!==e,this._displacementTexture=t,this._displacementScale=e},isDisplacementChanged:function(){return this._displacementChanged}});i.util.merge(im.prototype,Uo),i.util.merge(im.prototype,Ho),i.util.merge(im.prototype,Vo),i.util.merge(im.prototype,tp);var nm=Math.PI,am=Math.sin,om=Math.cos,sm=Math.tan,lm=Math.asin,hm=Math.atan2,um=nm/180,cm=23.4397*um;function dm(t,e){return hm(am(t)*om(cm)-sm(e)*am(cm),om(t))}function fm(t,e,r){return hm(am(t),om(t)*am(e)-sm(r)*om(e))}function pm(t,e,r){return lm(am(e)*am(r)+om(e)*om(r)*om(t))}var mm={};mm.getPosition=function(t,e,r){var i=um*-r,n=um*e,a=function(t){return function(t){return t.valueOf()/864e5-.5+2440588}(t)-2451545}(t),o=function(t){var e,r,i=(r=function(t){return um*(357.5291+.98560028*t)}(t))+um*(1.9148*am(r)+.02*am(2*r)+3e-4*am(3*r))+102.9372*um+nm;return{dec:(e=i,lm(am(0)*om(cm)+om(0)*am(cm)*am(e))),ra:dm(i,0)}}(a),s=function(t,e){return um*(280.16+360.9856235*t)-e}(a,i)-o.ra;return{azimuth:fm(s,n,o.dec),altitude:pm(s,n,o.dec)}};const gm=mm;mo.Shader.import("@export ecgl.atmosphere.vertex\nattribute vec3 position: POSITION;\nattribute vec3 normal : NORMAL;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 normalMatrix : WORLDINVERSETRANSPOSE;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n v_Normal = normalize((normalMatrix * vec4(normal, 0.0)).xyz);\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n\n\n@export ecgl.atmosphere.fragment\nuniform mat4 viewTranspose: VIEWTRANSPOSE;\nuniform float glowPower;\nuniform vec3 glowColor;\n\nvarying vec3 v_Normal;\n\nvoid main() {\n float intensity = pow(1.0 - dot(v_Normal, (viewTranspose * vec4(0.0, 0.0, 1.0, 0.0)).xyz), glowPower);\n gl_FragColor = vec4(glowColor, intensity * intensity);\n}\n@end"),i.extendComponentView({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(t,e){this.groupGL=new mo.Node,this._sphereGeometry=new mo.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new mo.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new mo.PlaneGeometry,this._earthMesh=new mo.Mesh({renderNormal:!0}),this._atmosphereMesh=new mo.Mesh,this._atmosphereGeometry=new mo.SphereGeometry({widthSegments:80,heightSegments:40}),this._atmosphereMaterial=new mo.Material({shader:new mo.Shader(mo.Shader.source("ecgl.atmosphere.vertex"),mo.Shader.source("ecgl.atmosphere.fragment")),transparent:!0}),this._atmosphereMesh.geometry=this._atmosphereGeometry,this._atmosphereMesh.material=this._atmosphereMaterial,this._atmosphereMesh.frontFace=mo.Mesh.CW,this._lightRoot=new mo.Node,this._sceneHelper=new Wc,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._atmosphereMesh),this.groupGL.add(this._earthMesh),this._control=new Nc({zr:e.getZr()}),this._control.init(),this._layerMeshes={}},render:function(t,e,r){var i=t.coordinateSystem,n=t.get("shading");i.viewGL.add(this._lightRoot),t.get("show")?i.viewGL.add(this.groupGL):i.viewGL.remove(this.groupGL),this._sceneHelper.setScene(i.viewGL.scene),i.viewGL.setPostEffect(t.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling"));var a=this._earthMesh;a.geometry=this._sphereGeometry;var o="ecgl."+n;a.material&&a.material.shader.name===o||(a.material=mo.createMaterial(o)),mo.setMaterialFromModel(n,a.material,t,r),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach((function(t){var e=a.material.get(t);e&&(e.flipY=!1)})),a.material.set("color",mo.parseColor(t.get("baseColor")));var s=.99*i.radius;if(a.scale.set(s,s,s),t.get("atmosphere.show")){a.material.define("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!1,this._atmosphereMaterial.setUniforms({glowPower:t.get("atmosphere.glowPower")||6,glowColor:t.get("atmosphere.color")||"#ffffff"}),a.material.setUniforms({glowPower:t.get("atmosphere.innerGlowPower")||2,glowColor:t.get("atmosphere.color")||"#ffffff"});var l=t.get("atmosphere.offset")||5;this._atmosphereMesh.scale.set(s+l,s+l,s+l)}else a.material.undefine("both","ATMOSPHERE_ENABLED"),this._atmosphereMesh.invisible=!0;var h=a.material.setTextureImage("diffuseMap",t.get("baseTexture"),r,{flipY:!1,anisotropic:8});h&&h.surface&&h.surface.attachToMesh(a);var u=a.material.setTextureImage("bumpMap",t.get("heightTexture"),r,{flipY:!1,anisotropic:8});u&&u.surface&&u.surface.attachToMesh(a),a.material[t.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(t,r),this._displaceVertices(t,r),this._updateViewControl(t,r),this._updateLayers(t,r)},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r)},_updateLayers:function(t,e){var r=t.coordinateSystem,n=t.get("layers"),a=r.radius,o=[],s=[],l=[],h=[];i.util.each(n,(function(t){var n=new i.Model(t),u=n.get("type"),c=mo.loadTexture(n.get("texture"),e,{flipY:!1,anisotropic:8});if(c.surface&&c.surface.attachToMesh(this._earthMesh),"blend"===u){var d=n.get("blendTo"),f=Sn(n.get("intensity"),1);"emission"===d?(l.push(c),h.push(f)):(o.push(c),s.push(f))}else{var p=n.get("id"),m=this._layerMeshes[p];m||(m=this._layerMeshes[p]=new mo.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0})),"lambert"===n.get("shading")?(m.material=m.__lambertMaterial||new mo.Material({autoUpdateTextureStatus:!1,shader:mo.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),m.__lambertMaterial=m.material):(m.material=m.__colorMaterial||new mo.Material({autoUpdateTextureStatus:!1,shader:mo.createShader("ecgl.color"),transparent:!0,depthMask:!1}),m.__colorMaterial=m.material),m.material.enableTexture("diffuseMap");var g=n.get("distance"),_=a+(null==g?r.radius/100:g);m.scale.set(_,_,_),a=_;var v=this._blankTexture||(this._blankTexture=mo.createBlankTexture("rgba(255, 255, 255, 0)"));m.material.set("diffuseMap",v),mo.loadTexture(n.get("texture"),e,{flipY:!1,anisotropic:8},(function(t){t.surface&&t.surface.attachToMesh(m),m.material.set("diffuseMap",t),e.getZr().refresh()})),n.get("show")?this.groupGL.add(m):this.groupGL.remove(m)}}),this);var u=this._earthMesh.material;u.define("fragment","LAYER_DIFFUSEMAP_COUNT",o.length),u.define("fragment","LAYER_EMISSIVEMAP_COUNT",l.length),u.set("layerDiffuseMap",o),u.set("layerDiffuseIntensity",s),u.set("layerEmissiveMap",l),u.set("layerEmissionIntensity",h);var c=t.getModel("debug.wireframe");if(c.get("show")){u.define("both","WIREFRAME_TRIANGLE");var d=mo.parseColor(c.get("lineStyle.color")||"rgba(0,0,0,0.5)"),f=Sn(c.get("lineStyle.width"),1);u.set("wireframeLineWidth",f),u.set("wireframeLineColor",d)}else u.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(t,e){var r=t.coordinateSystem,i=t.getModel("viewControl"),n=(r.viewGL.camera,this),a=this._control;a.setViewGL(r.viewGL);var o,s,l=i.get("targetCoord");null!=l&&(s=l[0]+90,o=l[1]),a.setFromViewControlModel(i,{baseDistance:r.radius,alpha:o,beta:s}),a.off("update"),a.on("update",(function(){e.dispatchAction({type:"globeChangeCamera",alpha:a.getAlpha(),beta:a.getBeta(),distance:a.getDistance()-r.radius,center:a.getCenter(),from:n.uid,globeId:t.id})}))},_displaceVertices:function(t,e){var r=t.get("displacementQuality"),i=t.get("debug.wireframe.show"),n=t.coordinateSystem;if(t.isDisplacementChanged()||r!==this._displacementQuality||i!==this._showDebugWireframe){this._displacementQuality=r,this._showDebugWireframe=i;var a=this._sphereGeometry,o={low:100,medium:200,high:400,ultra:800}[r]||200,s=o/2;(a.widthSegments!==o||i)&&(a.widthSegments=o,a.heightSegments=s,a.build()),this._doDisplaceVertices(a,n),i&&a.generateBarycentric()}},_doDisplaceVertices:function(t,e){var r=t.attributes.position.value,i=t.attributes.texcoord0.value,n=t.__originalPosition;n&&n.length===r.length||((n=new Float32Array(r.length)).set(r),t.__originalPosition=n);for(var a=e.displacementWidth,o=e.displacementHeight,s=e.displacementData,l=0;l<t.vertexCount;l++){var h=3*l,u=2*l,c=n[h+1],d=n[h+2],f=n[h+3],p=i[u++],m=i[u++],g=Math.round(p*(a-1)),_=Math.round(m*(o-1)),v=s?s[_*a+g]:0;r[h+1]=c+c*v,r[h+2]=d+d*v,r[h+3]=f+f*v}t.generateVertexNormals(),t.dirty(),t.updateBoundingBox()},_updateLight:function(t,e){var r=this._earthMesh;this._sceneHelper.updateLight(t);var n=this._sceneHelper.mainLight,a=t.get("light.main.time")||new Date,o=gm.getPosition(i.number.parseDate(a),0,0),s=Math.cos(o.altitude);n.position.y=-s*Math.cos(o.azimuth),n.position.x=Math.sin(o.altitude),n.position.z=s*Math.sin(o.azimuth),n.lookAt(r.getWorldPosition())},dispose:function(t,e){this.groupGL.removeAll(),this._control.dispose()}});var _m=Rc.vec3;function vm(t){this.radius=t,this.viewGL=null,this.altitudeAxis,this.displacementData=null,this.displacementWidth,this.displacementHeight}vm.prototype={constructor:vm,dimensions:["lng","lat","alt"],type:"globe",containPoint:function(){},setDisplacementData:function(t,e,r){this.displacementData=t,this.displacementWidth=e,this.displacementHeight=r},_getDisplacementScale:function(t,e){var r=(t+180)/360*(this.displacementWidth-1),i=(90-e)/180*(this.displacementHeight-1),n=Math.round(r)+Math.round(i)*this.displacementWidth;return this.displacementData[n]},dataToPoint:function(t,e){var r=t[0],i=t[1],n=t[2]||0,a=this.radius;this.displacementData&&(a*=1+this._getDisplacementScale(r,i)),this.altitudeAxis&&(a+=this.altitudeAxis.dataToCoord(n)),r=r*Math.PI/180,i=i*Math.PI/180;var o=Math.cos(i)*a;return(e=e||[])[0]=-o*Math.cos(r+Math.PI),e[1]=Math.sin(i)*a,e[2]=o*Math.sin(r+Math.PI),e},pointToData:function(t,e){var r=t[0],i=t[1],n=t[2],a=_m.len(t);r/=a,i/=a,n/=a;var o=Math.asin(i),s=Math.atan2(n,-r);s<0&&(s=2*Math.PI+s);var l=180*o/Math.PI,h=180*s/Math.PI-180;return(e=e||[])[0]=h,e[1]=l,e[2]=a-this.radius,this.altitudeAxis&&(e[2]=this.altitudeAxis.coordToData(e[2])),e}};const ym=vm;function xm(t,e){var r=kd(t.getBoxLayoutParams(),{width:e.getWidth(),height:e.getHeight()});r.y=e.getHeight()-r.y-r.height,this.viewGL.setViewport(r.x,r.y,r.width,r.height,e.getDevicePixelRatio()),this.radius=t.get("globeRadius");var i=t.get("globeOuterRadius");this.altitudeAxis&&this.altitudeAxis.setExtent(0,i-this.radius)}function bm(t,e){var r=[1/0,-1/0];if(t.eachSeries((function(t){if(t.coordinateSystem===this){var e=t.getData(),i=t.coordDimToDataDim("alt"),n=i&&i[0];if(n){var a=e.getDataExtent(n,!0);r[0]=Math.min(r[0],a[0]),r[1]=Math.max(r[1],a[1])}}}),this),r&&isFinite(r[1]-r[0])){var n=i.helper.createScale(r,{type:"value",min:"dataMin",max:"dataMax"});this.altitudeAxis=new i.Axis("altitude",n),this.resize(this.model,e)}}var wm={dimensions:ym.prototype.dimensions,create:function(t,e){var r=[];return t.eachComponent("globe",(function(t){t.__viewGL=t.__viewGL||new Kf;var i=new ym;i.viewGL=t.__viewGL,t.coordinateSystem=i,i.model=t,r.push(i),i.resize=xm,i.resize(t,e),i.update=bm})),t.eachSeries((function(e){if("globe"===e.get("coordinateSystem")){var r=e.getReferringComponents("globe").models[0];if(r||(r=t.getComponent("globe")),!r)throw new Error('globe "'+Sn(e.get("globe3DIndex"),e.get("globe3DId"),0)+'" not found');var i=r.coordinateSystem;e.coordinateSystem=i}})),t.eachComponent("globe",(function(t,r){var i=t.coordinateSystem,n=t.getDisplacementTexture(),a=t.getDisplacemenScale();if(t.isDisplacementChanged()){if(t.hasDisplacement()){var o=!0;mo.loadTexture(n,e,(function(r){var i=function(t,e){var r=document.createElement("canvas"),i=r.getContext("2d"),n=t.width,a=t.height;r.width=n,r.height=a,i.drawImage(t,0,0,n,a);for(var o=i.getImageData(0,0,n,a).data,s=new Float32Array(o.length/4),l=0;l<o.length/4;l++){var h=o[4*l];s[l]=h/255*e}return{data:s,width:n,height:a}}(r.image,a);t.setDisplacementData(i.data,i.width,i.height),o||e.dispatchAction({type:"globeUpdateDisplacment"})})),o=!1}else i.setDisplacementData(null,0,0);i.setDisplacementData(t.displacementData,t.displacementWidth,t.displacementHeight)}})),r}};i.registerCoordinateSystem("globe",wm),i.registerAction({type:"globeChangeCamera",event:"globecamerachanged",update:"series:updateCamera"},(function(t,e){e.eachComponent({mainType:"globe",query:t},(function(e){e.setView(t)}))})),i.registerAction({type:"globeUpdateDisplacment",event:"globedisplacementupdated",update:"update"},(function(t,e){}));var Tm=Rc.mat4,Sm=512,Mm=.6435011087932844,Am=Math.PI,Cm=.1;function Em(){this.width=0,this.height=0,this.altitudeScale=1,this.boxHeight="auto",this.altitudeExtent,this.bearing=0,this.pitch=0,this.center=[0,0],this._origin,this.zoom=0,this._initialZoom,this.maxPitch=60,this.zoomOffset=0}Em.prototype={constructor:Em,dimensions:["lng","lat","alt"],containPoint:function(){},setCameraOption:function(t){this.bearing=t.bearing,this.pitch=t.pitch,this.center=t.center,this.zoom=t.zoom,this._origin||(this._origin=this.projectOnTileWithScale(this.center,Sm)),null==this._initialZoom&&(this._initialZoom=this.zoom),this.updateTransform()},updateTransform:function(){if(this.height){var t=.5/Math.tan(Mm/2)*this.height*Cm,e=Math.max(Math.min(this.pitch,this.maxPitch),0)/180*Math.PI,r=Mm/2,i=Math.PI/2+e,n=Math.sin(r)*t/Math.sin(Math.PI-i-r),a=1.1*(Math.cos(Math.PI/2-e)*n+t);this.pitch>50&&(a=1e3);var o=[];Tm.perspective(o,Mm,this.width/this.height,1,a),this.viewGL.camera.projectionMatrix.setArray(o),this.viewGL.camera.decomposeProjectionMatrix(),o=Tm.identity([]);var s=this.dataToPoint(this.center);Tm.scale(o,o,[1,-1,1]),Tm.translate(o,o,[0,0,-t]),Tm.rotateX(o,o,e),Tm.rotateZ(o,o,-this.bearing/180*Math.PI),Tm.translate(o,o,[-s[0]*this.getScale()*Cm,-s[1]*this.getScale()*Cm,0]),this.viewGL.camera.viewMatrix.array=o;var l=[];Tm.invert(l,o),this.viewGL.camera.worldTransform.array=l,this.viewGL.camera.decomposeWorldTransform();var h,u=Sm*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var c=this.altitudeExtent[1]-this.altitudeExtent[0];h=this.boxHeight/c*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else h=u/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*Cm;this.viewGL.rootNode.scale.set(this.getScale()*Cm,this.getScale()*Cm,h)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(t,e){return this.projectOnTileWithScale(t,this.getScale()*Sm,e)},projectOnTileWithScale:function(t,e,r){var i=t[0],n=t[1]*Am/180,a=e*(i*Am/180+Am)/(2*Am),o=e*(Am-Math.log(Math.tan(Am/4+.5*n)))/(2*Am);return(r=r||[])[0]=a,r[1]=o,r},unprojectFromTile:function(t,e){return this.unprojectOnTileWithScale(t,this.getScale()*Sm,e)},unprojectOnTileWithScale:function(t,e,r){var i=t[0],n=t[1],a=i/e*(2*Am)-Am,o=2*(Math.atan(Math.exp(Am-n/e*(2*Am)))-Am/4);return(r=r||[])[0]=180*a/Am,r[1]=180*o/Am,r},dataToPoint:function(t,e){return(e=this.projectOnTileWithScale(t,Sm,e))[0]-=this._origin[0],e[1]-=this._origin[1],e[2]=isNaN(t[2])?0:t[2],isNaN(t[2])||(e[2]=t[2],this.altitudeExtent&&(e[2]-=this.altitudeExtent[0])),e}};const Dm=Em;function Lm(){Dm.apply(this,arguments)}function Pm(t,e,r){function i(t,e){var r=e.getWidth(),i=e.getHeight(),n=e.getDevicePixelRatio();this.viewGL.setViewport(0,0,r,i,n),this.width=r,this.height=i,this.altitudeScale=t.get("altitudeScale"),this.boxHeight=t.get("boxHeight")}function n(t,e){if("auto"!==this.model.get("boxHeight")){var r=[1/0,-1/0];t.eachSeries((function(t){if(t.coordinateSystem===this){var e=t.getData(),i=t.coordDimToDataDim("alt")[0];if(i){var n=e.getDataExtent(i,!0);r[0]=Math.min(r[0],n[0]),r[1]=Math.max(r[1],n[1])}}}),this),r&&isFinite(r[1]-r[0])&&(this.altitudeExtent=r)}}return{dimensions:e.prototype.dimensions,create:function(a,o){var s=[];return a.eachComponent(t,(function(t){var r=t.__viewGL;r||(r=t.__viewGL=new Kf).setRootNode(new mo.Node);var a=new e;a.viewGL=t.__viewGL,a.resize=i,a.resize(t,o),s.push(a),t.coordinateSystem=a,a.model=t,a.update=n})),a.eachSeries((function(e){if(e.get("coordinateSystem")===t){var r=e.getReferringComponents(t).models[0];if(r||(r=a.getComponent(t)),!r)throw new Error(t+' "'+Sn(e.get(t+"Index"),e.get(t+"Id"),0)+'" not found');e.coordinateSystem=r.coordinateSystem}})),r&&r(s,a,o),s}}}Lm.prototype=new Dm,Lm.prototype.constructor=Lm,Lm.prototype.type="mapbox3D";var Om=Pm("mapbox3D",Lm,(function(t){t.forEach((function(t){t.setCameraOption(t.model.getMapboxCameraOption())}))}));i.registerCoordinateSystem("mapbox3D",Om);var Nm=["zoom","center","pitch","bearing"],Im=i.extendComponentModel({type:"mapbox3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,style:"mapbox://styles/mapbox/light-v9",center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMapboxCameraOption:function(){var t=this;return Nm.reduce((function(e,r){return e[r]=t.get(r),e}),{})},setMapboxCameraOption:function(t){null!=t&&Nm.forEach((function(e){null!=t[e]&&(this.option[e]=t[e])}),this)},getMapbox:function(){return this._mapbox},setMapbox:function(t){this._mapbox=t}});function Rm(t,e){if(this.id=t,this.zr=e,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!mapboxgl)throw new Error("Mapbox GL library must be included. See https://www.mapbox.com/mapbox-gl-js/api/");this._mapbox=new mapboxgl.Map({container:this.dom}),this._initEvents()}i.util.merge(Im.prototype,Ho),i.util.merge(Im.prototype,Vo),Rm.prototype.resize=function(){this._mapbox.resize()},Rm.prototype.getMapbox=function(){return this._mapbox},Rm.prototype.clear=function(){},Rm.prototype.refresh=function(){this._mapbox.resize()};var Bm=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel"];Rm.prototype._initEvents=function(){var t=this._mapbox.getCanvasContainer();this._handlers=this._handlers||{contextmenu:function(t){return t.preventDefault(),!1}},Bm.forEach((function(e){this._handlers[e]=function(e){var r={};for(var i in e)r[i]=e[i];r.bubbles=!1;var n=new e.constructor(e.type,r);t.dispatchEvent(n)},this.zr.dom.addEventListener(e,this._handlers[e])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},Rm.prototype.dispose=function(){Bm.forEach((function(t){this.zr.dom.removeEventListener(t,this._handlers[t])}),this)};const Fm=Rm,zm="\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end";function km(){Dm.apply(this,arguments),this.maxPitch=85,this.zoomOffset=1}mo.Shader.import(zm),i.extendComponentView({type:"mapbox3D",__ecgl__:!0,init:function(t,e){var r=e.getZr();this._zrLayer=new Fm("mapbox3D",r),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new mo.Node,this._sceneHelper=new Wc(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var i=this._zrLayer.getMapbox(),n=this._dispatchInteractAction.bind(this,e,i);["zoom","rotate","drag","pitch","rotate","move"].forEach((function(t){i.on(t,n)})),this._groundMesh=new mo.Mesh({geometry:new mo.PlaneGeometry,material:new mo.Material({shader:new mo.Shader({vertex:mo.Shader.source("ecgl.displayShadow.vertex"),fragment:mo.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},render:function(t,e,r){var i=this._zrLayer.getMapbox(),n=t.get("style"),a=JSON.stringify(n);a!==this._oldStyleStr&&n&&i.setStyle(n),this._oldStyleStr=a,i.setCenter(t.get("center")),i.setZoom(t.get("zoom")),i.setPitch(t.get("pitch")),i.setBearing(t.get("bearing")),t.setMapbox(i);var o=t.coordinateSystem;o.viewGL.scene.add(this._lightRoot),o.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(o.viewGL.scene),this._sceneHelper.updateLight(t),o.viewGL.setPostEffect(t.getModel("postEffect"),r),o.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling")),this._mapbox3DModel=t},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r),t.coordinateSystem.viewGL.scene.traverse((function(t){t.material&&(t.material.define("fragment","NORMAL_UP_AXIS",2),t.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(t,e,r,i){t.coordinateSystem.setCameraOption(i),this._updateGroundMesh(),r.getZr().refresh()},_dispatchInteractAction:function(t,e,r){t.dispatchAction({type:"mapbox3DChangeCamera",pitch:e.getPitch(),zoom:e.getZoom(),center:e.getCenter().toArray(),bearing:e.getBearing(),mapbox3DId:this._mapbox3DModel&&this._mapbox3DModel.id})},_updateGroundMesh:function(){if(this._mapbox3DModel){var t=this._mapbox3DModel.coordinateSystem,e=t.dataToPoint(t.center);this._groundMesh.position.set(e[0],e[1],-.001);var r=new mo.Plane(new mo.Vector3(0,0,1),0),i=t.viewGL.camera.castRay(new mo.Vector2(-1,-1)),n=t.viewGL.camera.castRay(new mo.Vector2(1,1)),a=i.intersectPlane(r),o=n.intersectPlane(r),s=a.dist(o)/t.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(t,e){this._zrLayer&&this._zrLayer.dispose(),e.getZr().painter.delLayer(-1e3)}}),i.registerAction({type:"mapbox3DChangeCamera",event:"mapbox3dcamerachanged",update:"mapbox3D:updateCamera"},(function(t,e){e.eachComponent({mainType:"mapbox3D",query:t},(function(e){e.setMapboxCameraOption(t)}))})),km.prototype=new Dm,km.prototype.constructor=km,km.prototype.type="maptalks3D";var Gm=Pm("maptalks3D",km,(function(t){t.forEach((function(t){t.setCameraOption(t.model.getMaptalksCameraOption())}))}));i.registerCoordinateSystem("maptalks3D",Gm);var Um=["zoom","center","pitch","bearing"],Hm=i.extendComponentModel({type:"maptalks3D",layoutMode:"box",coordinateSystem:null,defaultOption:{zlevel:-10,urlTemplate:"http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",attribution:'© <a href="http://osm.org">OpenStreetMap</a> contributors, © <a href="https://carto.com/">CARTO</a>',center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMaptalksCameraOption:function(){var t=this;return Um.reduce((function(e,r){return e[r]=t.get(r),e}),{})},setMaptalksCameraOption:function(t){null!=t&&Um.forEach((function(e){null!=t[e]&&(this.option[e]=t[e])}),this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(t){this._maptalks=t}});function Vm(t,e,r,i){if(this.id=t,this.zr=e,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!maptalks)throw new Error("Maptalks library must be included. See https://maptalks.org");this._maptalks=new maptalks.Map(this.dom,{center:r,zoom:i,doubleClickZoom:!1,fog:!1}),this._initEvents()}i.util.merge(Hm.prototype,Ho),i.util.merge(Hm.prototype,Vo),Vm.prototype.resize=function(){this._maptalks.checkSize()},Vm.prototype.getMaptalks=function(){return this._maptalks},Vm.prototype.clear=function(){},Vm.prototype.refresh=function(){this._maptalks.checkSize()};var Wm=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];Vm.prototype._initEvents=function(){var t=this.dom;this._handlers=this._handlers||{contextmenu:function(t){return t.preventDefault(),!1}},Wm.forEach((function(e){this._handlers[e]=function(r){var i={};for(var n in r)i[n]=r[n];i.bubbles=!1;var a=new r.constructor(r.type,i);"mousewheel"===e||"DOMMouseScroll"===e?t.dispatchEvent(a):t.firstElementChild.dispatchEvent(a)},this.zr.dom.addEventListener(e,this._handlers[e])}),this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},Vm.prototype.dispose=function(){Wm.forEach((function(t){this.zr.dom.removeEventListener(t,this._handlers[t])}),this),this._maptalks.remove()};const jm=Vm;mo.Shader.import(zm),i.extendComponentView({type:"maptalks3D",__ecgl__:!0,init:function(t,e){this._groundMesh=new mo.Mesh({geometry:new mo.PlaneGeometry,material:new mo.Material({shader:new mo.Shader({vertex:mo.Shader.source("ecgl.displayShadow.vertex"),fragment:mo.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(t,e){var r=e.getZr();this._zrLayer=new jm("maptalks3D",r,t.get("center"),t.get("zoom")),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new mo.Node,this._sceneHelper=new Wc(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var i=this._zrLayer.getMaptalks(),n=this._dispatchInteractAction.bind(this,e,i);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend","animating"].forEach((function(t){i.on(t,n)}))},render:function(t,e,r){this._zrLayer||this._initMaptalksLayer(t,r);var i=this._zrLayer.getMaptalks(),n=t.get("urlTemplate"),a=i.getBaseLayer();n!==this._oldUrlTemplate&&(a?a.setOptions({urlTemplate:n,attribution:t.get("attribution")}):(a=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:n,subdomains:["a","b","c"],attribution:t.get("attribution")}),i.setBaseLayer(a))),this._oldUrlTemplate=n,i.setCenter(t.get("center")),i.setZoom(t.get("zoom"),{animation:!1}),i.setPitch(t.get("pitch")),i.setBearing(t.get("bearing")),t.setMaptalks(i);var o=t.coordinateSystem;o.viewGL.scene.add(this._lightRoot),o.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(o.viewGL.scene),this._sceneHelper.updateLight(t),o.viewGL.setPostEffect(t.getModel("postEffect"),r),o.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling")),this._maptalks3DModel=t},afterRender:function(t,e,r,i){var n=i.renderer;this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r),t.coordinateSystem.viewGL.scene.traverse((function(t){t.material&&(t.material.define("fragment","NORMAL_UP_AXIS",2),t.material.define("fragment","NORMAL_FRONT_AXIS",1))}))},updateCamera:function(t,e,r,i){t.coordinateSystem.setCameraOption(i),this._updateGroundMesh(),r.getZr().refresh()},_dispatchInteractAction:function(t,e,r){var i;t.dispatchAction({type:"maptalks3DChangeCamera",pitch:e.getPitch(),zoom:(i=e.getResolution(),19-Math.log(i/Xm)/Math.LN2+1),center:e.getCenter().toArray(),bearing:e.getBearing(),maptalks3DId:this._maptalks3DModel&&this._maptalks3DModel.id})},_updateGroundMesh:function(){if(this._maptalks3DModel){var t=this._maptalks3DModel.coordinateSystem,e=t.dataToPoint(t.center);this._groundMesh.position.set(e[0],e[1],-.001);var r=new mo.Plane(new mo.Vector3(0,0,1),0),i=t.viewGL.camera.castRay(new mo.Vector2(-1,-1)),n=t.viewGL.camera.castRay(new mo.Vector2(1,1)),a=i.intersectPlane(r),o=n.intersectPlane(r),s=a.dist(o)/t.viewGL.rootNode.scale.x;this._groundMesh.scale.set(s,s,1)}},dispose:function(t,e){this._zrLayer&&this._zrLayer.dispose(),e.getZr().painter.delLayer(-1e3)}});const Xm=12756274*Math.PI/(256*Math.pow(2,20));i.registerAction({type:"maptalks3DChangeCamera",event:"maptalks3dcamerachanged",update:"maptalks3D:updateCamera"},(function(t,e){e.eachComponent({mainType:"maptalks3D",query:t},(function(e){e.setMaptalksCameraOption(t)}))}));var qm=Rc.vec3,Zm=i.helper.dataStack.isDimensionStacked;function Ym(t,e,r){for(var i=t.getDataExtent(e),n=t.getDataExtent(r),a=i[1]-i[0]||i[0],o=n[1]-n[0]||n[0],s=new Uint8Array(2500),l=0;l<t.count();l++){var h=t.get(e,l),u=t.get(r,l),c=Math.floor((h-i[0])/a*49),d=50*Math.floor((u-n[0])/o*49)+c;s[d]=s[d]||1}var f=0;for(l=0;l<s.length;l++)s[l]&&f++;return f/s.length}var Km=Rc.vec3,Qm=i.helper.dataStack.isDimensionStacked;function Jm(t,e){var r=Qm(t,e[2]);return{dimension:r?t.getCalculationInfo("stackResultDimension"):e[2],isStacked:r}}i.registerLayout((function(t,e){t.eachSeriesByType("bar3D",(function(t){var e=t.coordinateSystem,r=e&&e.type;"globe"===r?function(t,e){var r=t.getData(),n=t.get("minHeight")||0,a=t.get("barSize"),o=["lng","lat","alt"].map((function(e){return t.coordDimToDataDim(e)[0]}));if(null==a){var s=e.radius*Math.PI,l=Ym(r,o[0],o[1]);a=[s/Math.sqrt(r.count()/l),s/Math.sqrt(r.count()/l)]}else i.util.isArray(a)||(a=[a,a]);var h=Jm(r,o);r.each(o,(function(t,i,o,s){var l=r.get(h.dimension,s),u=h.isStacked?l-o:e.altitudeAxis.scale.getExtent()[0],c=Math.max(e.altitudeAxis.dataToCoord(o),n),d=e.dataToPoint([t,i,u]),f=e.dataToPoint([t,i,l]),p=Km.sub([],f,d);Km.normalize(p,p);var m=[a[0],c,a[1]];r.setItemLayout(s,[d,p,m])})),r.setLayout("orient",ve.UP.array)}(t,e):"cartesian3D"===r?function(t,e){var r=t.getData(),n=t.get("barSize");if(null==n){var a,o,s=e.size,l=e.getAxis("x"),h=e.getAxis("y");a="category"===l.type?.7*l.getBandWidth():.6*Math.round(s[0]/Math.sqrt(r.count())),o="category"===h.type?.7*h.getBandWidth():.6*Math.round(s[1]/Math.sqrt(r.count())),n=[a,o]}else i.util.isArray(n)||(n=[n,n]);var u=e.getAxis("z").scale.getExtent(),c=function(t){var e=t[0],r=t[1];return!(e>0&&r>0||e<0&&r<0)}(u),d=["x","y","z"].map((function(e){return t.coordDimToDataDim(e)[0]})),f=Zm(r,d[2]),p=f?r.getCalculationInfo("stackResultDimension"):d[2];r.each(d,(function(t,i,a,o){var s=r.get(p,o),l=f?s-a:c?0:u[0],h=e.dataToPoint([t,i,l]),d=e.dataToPoint([t,i,s]),m=qm.dist(h,d),g=[0,d[1]<h[1]?-1:1,0];0===Math.abs(m)&&(m=.1);var _=[n[0],m,n[1]];r.setItemLayout(o,[h,g,_])})),r.setLayout("orient",[1,0,0])}(t,e):"geo3D"===r?function(t,e){var r=t.getData(),n=t.get("barSize"),a=t.get("minHeight")||0,o=["lng","lat","alt"].map((function(e){return t.coordDimToDataDim(e)[0]}));if(null==n){var s=Math.min(e.size[0],e.size[2]),l=Ym(r,o[0],o[1]);n=[s/Math.sqrt(r.count()/l),s/Math.sqrt(r.count()/l)]}else i.util.isArray(n)||(n=[n,n]);var h=[0,1,0],u=Jm(r,o);r.each(o,(function(t,i,o,s){var l=r.get(u.dimension,s),c=u.isStacked?l-o:e.altitudeAxis.scale.getExtent()[0],d=Math.max(e.altitudeAxis.dataToCoord(o),a),f=e.dataToPoint([t,i,c]),p=[n[0],d,n[1]];r.setItemLayout(s,[f,h,p])})),r.setLayout("orient",[1,0,0])}(t,e):("mapbox3D"===r||"maptalks3D"===r)&&function(t,e){var r=t.getData(),n=t.coordDimToDataDim("lng")[0],a=t.coordDimToDataDim("lat")[0],o=t.coordDimToDataDim("alt")[0],s=t.get("barSize"),l=t.get("minHeight")||0;if(null==s){var h=r.getDataExtent(n),u=r.getDataExtent(a),c=e.dataToPoint([h[0],u[0]]),d=e.dataToPoint([h[1],u[1]]),f=Math.min(Math.abs(c[0]-d[0]),Math.abs(c[1]-d[1]))||1,p=Ym(r,n,a);s=[f/Math.sqrt(r.count()/p),f/Math.sqrt(r.count()/p)]}else i.util.isArray(s)||(s=[s,s]),s[0]/=e.getScale()/16,s[1]/=e.getScale()/16;var m=[0,0,1],g=[n,a,o],_=Jm(r,g);r.each(g,(function(t,i,n,a){var o=r.get(_.dimension,a),h=_.isStacked?o-n:0,u=e.dataToPoint([t,i,h]),c=e.dataToPoint([t,i,o]),d=Math.max(c[2]-u[2],l),f=[s[0],d,s[1]];r.setItemLayout(a,[u,m,f])})),r.setLayout("orient",[1,0,0])}(t,e)}))}));const $m={getFormattedLabel:function(t,e,r,n,a){r=r||"normal";var o=t.getData(n).getItemModel(e),s=t.getDataParams(e,n);null!=a&&s.value instanceof Array&&(s.value=s.value[a]);var l,h=o.get("normal"===r?["label","formatter"]:["emphasis","label","formatter"]);return null==h&&(h=o.get(["label","formatter"])),"function"==typeof h?(s.status=r,l=h(s)):"string"==typeof h&&(l=i.format.formatTpl(h,s)),l},normalizeToArray:function(t){return t instanceof Array?t:null==t?[]:[t]}};var tg,eg,rg,ig,ng,ag,og,sg,lg=Rc.vec3,hg=Rc.mat3,ug=Ur.extend((function(){return{attributes:{position:new Ur.Attribute("position","float",3,"POSITION"),normal:new Ur.Attribute("normal","float",3,"NORMAL"),color:new Ur.Attribute("color","float",4,"COLOR"),prevPosition:new Ur.Attribute("prevPosition","float",3),prevNormal:new Ur.Attribute("prevNormal","float",3)},dynamic:!0,enableNormal:!1,bevelSize:1,bevelSegments:0,_dataIndices:null,_vertexOffset:0,_triangleOffset:0}}),{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0},setBarCount:function(t){var e=this.enableNormal,r=this.getBarVertexCount()*t,i=this.getBarTriangleCount()*t;this.vertexCount!==r&&(this.attributes.position.init(r),e?this.attributes.normal.init(r):this.attributes.normal.value=null,this.attributes.color.init(r)),this.triangleCount!==i&&(this.indices=r>65535?new Uint32Array(3*i):new Uint16Array(3*i),this._dataIndices=new Uint32Array(r))},getBarVertexCount:function(){var t=this.bevelSize>0?this.bevelSegments:0;return t>0?this._getBevelBarVertexCount(t):this.enableNormal?24:8},getBarTriangleCount:function(){var t=this.bevelSize>0?this.bevelSegments:0;return t>0?this._getBevelBarTriangleCount(t):12},_getBevelBarVertexCount:function(t){return 4*(t+1)*(t+1)*2},_getBevelBarTriangleCount:function(t){return(4*t+3+1)*(2*t+1)*2+4},setColor:function(t,e){for(var r=this.getBarVertexCount(),i=r*(t+1),n=r*t;n<i;n++)this.attributes.color.set(n,e);this.dirtyAttribute("color")},getDataIndexOfVertex:function(t){return this._dataIndices?this._dataIndices[t]:null},addBar:function(){for(var t=lg.create,e=lg.scaleAndAdd,r=t(),i=t(),n=t(),a=t(),o=t(),s=t(),l=t(),h=[],u=[],c=0;c<8;c++)h[c]=t();var d=[[0,1,5,4],[2,3,7,6],[4,5,6,7],[3,2,1,0],[0,4,7,3],[1,2,6,5]],f=[0,1,2,0,2,3],p=[];for(c=0;c<d.length;c++)for(var m=d[c],g=0;g<2;g++){for(var _=[],v=0;v<3;v++)_.push(m[f[3*g+v]]);p.push(_)}return function(t,c,m,g,_,v){var y=this._vertexOffset;if(this.bevelSize>0&&this.bevelSegments>0)this._addBevelBar(t,c,m,g,this.bevelSize,this.bevelSegments,_);else{lg.copy(n,c),lg.normalize(n,n),lg.cross(a,m,n),lg.normalize(a,a),lg.cross(i,n,a),lg.normalize(a,a),lg.negate(o,i),lg.negate(s,n),lg.negate(l,a),e(h[0],t,i,g[0]/2),e(h[0],h[0],a,g[2]/2),e(h[1],t,i,g[0]/2),e(h[1],h[1],l,g[2]/2),e(h[2],t,o,g[0]/2),e(h[2],h[2],l,g[2]/2),e(h[3],t,o,g[0]/2),e(h[3],h[3],a,g[2]/2),e(r,t,n,g[1]),e(h[4],r,i,g[0]/2),e(h[4],h[4],a,g[2]/2),e(h[5],r,i,g[0]/2),e(h[5],h[5],l,g[2]/2),e(h[6],r,o,g[0]/2),e(h[6],h[6],l,g[2]/2),e(h[7],r,o,g[0]/2),e(h[7],h[7],a,g[2]/2);var x=this.attributes;if(this.enableNormal){u[0]=i,u[1]=o,u[2]=n,u[3]=s,u[4]=a,u[5]=l;for(var b=this._vertexOffset,w=0;w<d.length;w++){for(var T=3*this._triangleOffset,S=0;S<6;S++)this.indices[T++]=b+f[S];b+=4,this._triangleOffset+=2}for(w=0;w<d.length;w++){var M=u[w];for(S=0;S<4;S++){var A=d[w][S];x.position.set(this._vertexOffset,h[A]),x.normal.set(this._vertexOffset,M),x.color.set(this._vertexOffset++,_)}}}else{for(w=0;w<p.length;w++){for(T=3*this._triangleOffset,S=0;S<3;S++)this.indices[T+S]=p[w][S]+this._vertexOffset;this._triangleOffset++}for(w=0;w<h.length;w++)x.position.set(this._vertexOffset,h[w]),x.color.set(this._vertexOffset++,_)}}var C=this._vertexOffset;for(w=y;w<C;w++)this._dataIndices[w]=v}}(),_addBevelBar:(tg=lg.create(),eg=lg.create(),rg=lg.create(),ig=hg.create(),ng=[],ag=[1,-1,-1,1],og=[1,1,-1,-1],sg=[2,0],function(t,e,r,i,n,a,o){lg.copy(eg,e),lg.normalize(eg,eg),lg.cross(rg,r,eg),lg.normalize(rg,rg),lg.cross(tg,eg,rg),lg.normalize(rg,rg),ig[0]=tg[0],ig[1]=tg[1],ig[2]=tg[2],ig[3]=eg[0],ig[4]=eg[1],ig[5]=eg[2],ig[6]=rg[0],ig[7]=rg[1],ig[8]=rg[2],n=Math.min(i[0],i[2])/2*n;for(var s=0;s<3;s++)ng[s]=Math.max(i[s]-2*n,0);var l=(i[0]-ng[0])/2,h=(i[1]-ng[1])/2,u=(i[2]-ng[2])/2,c=[],d=[],f=this._vertexOffset,p=[];for(s=0;s<2;s++){p[s]=p[s]=[];for(var m=0;m<=a;m++)for(var g=0;g<4;g++){(0===m&&0===s||1===s&&m===a)&&p[s].push(f);for(var _=0;_<=a;_++){var v=_/a*Math.PI/2+Math.PI/2*g,y=m/a*Math.PI/2+Math.PI/2*s;d[0]=l*Math.cos(v)*Math.sin(y),d[1]=h*Math.cos(y),d[2]=u*Math.sin(v)*Math.sin(y),c[0]=d[0]+ag[g]*ng[0]/2,c[1]=d[1]+h+sg[s]*ng[1]/2,c[2]=d[2]+og[g]*ng[2]/2,Math.abs(l-h)<1e-6&&Math.abs(h-u)<1e-6||(d[0]/=l*l,d[1]/=h*h,d[2]/=u*u),lg.normalize(d,d),lg.transformMat3(c,c,ig),lg.transformMat3(d,d,ig),lg.add(c,c,t),this.attributes.position.set(f,c),this.enableNormal&&this.attributes.normal.set(f,d),this.attributes.color.set(f,o),f++}}}var x=4*a+3,b=2*a+1,w=x+1;for(g=0;g<b;g++)for(s=0;s<=x;s++){var T=g*w+s+this._vertexOffset,S=g*w+(s+1)%w+this._vertexOffset,M=(g+1)*w+(s+1)%w+this._vertexOffset,A=(g+1)*w+s+this._vertexOffset;this.setTriangleIndices(this._triangleOffset++,[M,T,S]),this.setTriangleIndices(this._triangleOffset++,[M,A,T])}this.setTriangleIndices(this._triangleOffset++,[p[0][0],p[0][2],p[0][1]]),this.setTriangleIndices(this._triangleOffset++,[p[0][0],p[0][3],p[0][2]]),this.setTriangleIndices(this._triangleOffset++,[p[1][0],p[1][1],p[1][2]]),this.setTriangleIndices(this._triangleOffset++,[p[1][0],p[1][2],p[1][3]]),this._vertexOffset=f})});i.util.defaults(ug.prototype,Ic),i.util.defaults(ug.prototype,Bp);const cg=ug;var dg=Rc.vec3;function fg(t,e,r){var n=t.getData(),a=t.getRawValue(e),o=i.util.isArray(a)?function(t){var a=[],o=function(t,e){var r=[];return i.util.each(t.dimensions,(function(e){var i=t.getDimensionInfo(e),n=i.otherDims.tooltip;null!=n&&!1!==n&&(r[n]=i.name)})),r}(n);function s(t,e){var o=n.getDimensionInfo(e);if(o&&!1!==o.otherDims.tooltip){var s=o.type,l="- "+(o.tooltipName||o.name)+": "+("ordinal"===s?t+"":"time"===s?r?"":i.format.formatTime("yyyy/MM/dd hh:mm:ss",t):i.format.addCommas(t));l&&a.push(i.format.encodeHTML(l))}}return o.length?i.util.each(o,(function(t){s(n.get(t,e),t)})):i.util.each(t,s),"<br/>"+a.join("<br/>")}(a):i.format.encodeHTML(i.format.addCommas(a)),s=n.getName(e),l=Fp(n,e);i.util.isObject(l)&&l.colorStops&&(l=(l.colorStops[0]||{}).color),l=l||"transparent";var h=i.format.getTooltipMarker(l),u=t.name;return"\0-"===u&&(u=""),u=u?i.format.encodeHTML(u)+(r?": ":"<br/>"):"",r?h+u+o:u+h+(s?i.format.encodeHTML(s)+": "+o:o)}function pg(t,e,r){r=r||t.getSource();var n=e||i.getCoordinateSystemDimensions(t.get("coordinateSystem"))||["x","y","z"],a=i.helper.createDimensions(r,{dimensionsDefine:r.dimensionsDefine||t.get("dimensions"),encodeDefine:r.encodeDefine||t.get("encode"),coordDimensions:n.map((function(e){var r=t.getReferringComponents(e+"Axis3D").models[0];return{type:r&&"category"===r.get("type")?"ordinal":"float",name:e}}))});"cartesian3D"===t.get("coordinateSystem")&&a.forEach((function(e){if(n.indexOf(e.coordDim)>=0){var r=t.getReferringComponents(e.coordDim+"Axis3D").models[0];r&&"category"===r.get("type")&&(e.ordinalMeta=r.getOrdinalMeta())}}));var o=i.helper.dataStack.enableDataStack(t,a,{byIndex:!0,stackedCoordDimension:"z"}),s=new i.List(a,t);return s.setCalculationInfo(o),s.initData(r),s}i.extendChartView({type:"bar3D",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this._api=e,this._labelsBuilder=new Gp(256,256,e);var r=this;this._labelsBuilder.getLabelPosition=function(t,e,i){if(r._data){var n=r._data.getItemLayout(t),a=n[0],o=n[1],s=n[2][1];return dg.scaleAndAdd([],a,o,i+s)}return[0,0]},this._labelsBuilder.getMesh().renderOrder=100},render:function(t,e,r){var i=this._prevBarMesh;this._prevBarMesh=this._barMesh,this._barMesh=i,this._barMesh||(this._barMesh=new mo.Mesh({geometry:new cg,shadowDepthMaterial:new mo.Material({shader:new mo.Shader(mo.Shader.source("ecgl.sm.depth.vertex"),mo.Shader.source("ecgl.sm.depth.fragment"))}),culling:"cartesian3D"===t.coordinateSystem.type,renderOrder:10,renderNormal:!0})),this.groupGL.remove(this._prevBarMesh),this.groupGL.add(this._barMesh),this.groupGL.add(this._labelsBuilder.getMesh());var n=t.coordinateSystem;if(this._doRender(t,r),n&&n.viewGL){n.viewGL.add(this.groupGL);var a=n.viewGL.isLinearSpace()?"define":"undefine";this._barMesh.material[a]("fragment","SRGB_DECODE")}this._data=t.getData(),this._labelsBuilder.updateData(this._data),this._labelsBuilder.updateLabels(),this._updateAnimation(t)},_updateAnimation:function(t){mo.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevBarMesh,this._barMesh,t)},_doRender:function(t,e){var r=t.getData(),i=t.get("shading"),n="color"!==i,a=this,o=this._barMesh,s="ecgl."+i;o.material&&o.material.shader.name===s||(o.material=mo.createMaterial(s,["VERTEX_COLOR"])),mo.setMaterialFromModel(i,o.material,t,e),o.geometry.enableNormal=n,o.geometry.resetOffset();var l=t.get("bevelSize"),h=t.get("bevelSmoothness");o.geometry.bevelSegments=h,o.geometry.bevelSize=l;var u=[],c=new Float32Array(4*r.count()),d=0,f=0,p=!1;r.each((function(t){if(r.hasValue(t)){var e=Fp(r,t),i=zp(r,t);null==i&&(i=1),mo.parseColor(e,u),u[3]*=i,c[d++]=u[0],c[d++]=u[1],c[d++]=u[2],c[d++]=u[3],u[3]>0&&(f++,u[3]<.99&&(p=!0))}})),o.geometry.setBarCount(f);var m=r.getLayout("orient"),g=this._barIndexOfData=new Int32Array(r.count());f=0,r.each((function(t){if(r.hasValue(t)){var e=r.getItemLayout(t),i=e[0],n=e[1],o=e[2],s=4*t;u[0]=c[s++],u[1]=c[s++],u[2]=c[s++],u[3]=c[s++],u[3]>0&&(a._barMesh.geometry.addBar(i,n,m,o,u,t),g[t]=f++)}else g[t]=-1})),o.geometry.dirty(),o.geometry.updateBoundingBox();var _=o.material;_.transparent=p,_.depthMask=!p,o.geometry.sortTriangles=p,this._initHandler(t,e)},_initHandler:function(t,e){var r=t.getData(),i=this._barMesh,n="cartesian3D"===t.coordinateSystem.type;i.seriesIndex=t.seriesIndex;var a=-1;i.off("mousemove"),i.off("mouseout"),i.on("mousemove",(function(t){var o=i.geometry.getDataIndexOfVertex(t.triangle[0]);o!==a&&(this._downplay(a),this._highlight(o),this._labelsBuilder.updateLabels([o]),n&&e.dispatchAction({type:"grid3DShowAxisPointer",value:[r.get("x",o),r.get("y",o),r.get("z",o,!0)]})),a=o,i.dataIndex=o}),this),i.on("mouseout",(function(t){this._downplay(a),this._labelsBuilder.updateLabels(),a=-1,i.dataIndex=-1,n&&e.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_highlight:function(t){var e=this._data;if(e){var r=this._barIndexOfData[t];if(!(r<0)){var n=e.getItemModel(t).getModel("emphasis.itemStyle"),a=n.get("color"),o=n.get("opacity");if(null==a){var s=Fp(e,t);a=i.color.lift(s,-.4)}null==o&&(o=zp(e,t));var l=mo.parseColor(a);l[3]*=o,this._barMesh.geometry.setColor(r,l),this._api.getZr().refresh()}}},_downplay:function(t){var e=this._data;if(e){var r=this._barIndexOfData[t];if(!(r<0)){var i=Fp(e,t),n=zp(e,t),a=mo.parseColor(i);a[3]*=n,this._barMesh.geometry.setColor(r,a),this._api.getZr().refresh()}}},highlight:function(t,e,r,i){this._toggleStatus("highlight",t,e,r,i)},downplay:function(t,e,r,i){this._toggleStatus("downplay",t,e,r,i)},_toggleStatus:function(t,e,r,n,a){var o=e.getData(),s=Mn(o,a),l=this;null!=s?i.util.each($m.normalizeToArray(s),(function(e){"highlight"===t?this._highlight(e):this._downplay(e)}),this):o.each((function(e){"highlight"===t?l._highlight(e):l._downplay(e)}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});var mg=i.extendSeriesModel({type:"series.bar3D",dependencies:["globe"],visualStyleAccessPathvisu:"itemStyle",getInitialData:function(t,e){return pg(this)},getFormattedLabel:function(t,e,r,i){var n=$m.getFormattedLabel(this,t,e,r,i);return null==n&&(n=this.getData().get("z",t)),n},formatTooltip:function(t){return fg(this,t)},defaultOption:{coordinateSystem:"cartesian3D",globeIndex:0,grid3DIndex:0,zlevel:-10,bevelSize:0,bevelSmoothness:2,onGridPlane:"xy",shading:"color",minHeight:0,itemStyle:{opacity:1},label:{show:!1,distance:2,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},emphasis:{label:{show:!0}},animationDurationUpdate:500}});i.util.merge(mg.prototype,tp),i.registerProcessor((function(t,e){t.eachSeriesByType("bar3d",(function(t){var e=t.getData();e.filterSelf((function(t){return e.hasValue(t)}))}))})),i.extendSeriesModel({type:"series.line3D",dependencies:["grid3D"],visualStyleAccessPath:"lineStyle",getInitialData:function(t,e){return pg(this)},formatTooltip:function(t){return fg(this,t)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,lineStyle:{width:2},animationDurationUpdate:500}});var gg=Rc.vec3;function _g(t,e,r){(e=e||document.createElement("canvas")).width=t,e.height=t;var i=e.getContext("2d");return r&&r(i),e}mo.Shader.import(sd),i.extendChartView({type:"line3D",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this._api=e},render:function(t,e,r){var i=this._prevLine3DMesh;this._prevLine3DMesh=this._line3DMesh,this._line3DMesh=i,this._line3DMesh||(this._line3DMesh=new mo.Mesh({geometry:new kc({useNativeLine:!1,sortTriangles:!0}),material:new mo.Material({shader:mo.createShader("ecgl.meshLines3D")}),renderOrder:10}),this._line3DMesh.geometry.pick=this._pick.bind(this)),this.groupGL.remove(this._prevLine3DMesh),this.groupGL.add(this._line3DMesh);var n=t.coordinateSystem;if(n&&n.viewGL){n.viewGL.add(this.groupGL);var a=n.viewGL.isLinearSpace()?"define":"undefine";this._line3DMesh.material[a]("fragment","SRGB_DECODE")}this._doRender(t,r),this._data=t.getData(),this._camera=n.viewGL.camera,this.updateCamera(),this._updateAnimation(t)},updateCamera:function(){this._updateNDCPosition()},_doRender:function(t,e){var r=t.getData(),i=this._line3DMesh;i.geometry.resetOffset();var n=r.getLayout("points"),a=[],o=new Float32Array(n.length/3*4),s=0,l=!1;r.each((function(t){var e=Fp(r,t),i=zp(r,t);null==i&&(i=1),mo.parseColor(e,a),a[3]*=i,o[s++]=a[0],o[s++]=a[1],o[s++]=a[2],o[s++]=a[3],a[3]<.99&&(l=!0)})),i.geometry.setVertexCount(i.geometry.getPolylineVertexCount(n)),i.geometry.setTriangleCount(i.geometry.getPolylineTriangleCount(n)),i.geometry.addPolyline(n,o,Sn(t.get("lineStyle.width"),1)),i.geometry.dirty(),i.geometry.updateBoundingBox();var h=i.material;h.transparent=l,h.depthMask=!l;var u=t.getModel("debug.wireframe");u.get("show")?(i.geometry.createAttribute("barycentric","float",3),i.geometry.generateBarycentric(),i.material.set("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",mo.parseColor(u.get("lineStyle.color")||"rgba(0,0,0,0.5)")),i.material.set("wireframeLineWidth",Sn(u.get("lineStyle.width"),1))):i.material.set("both","WIREFRAME_TRIANGLE"),this._points=n,this._initHandler(t,e)},_updateAnimation:function(t){mo.updateVertexAnimation([["prevPosition","position"],["prevPositionPrev","positionPrev"],["prevPositionNext","positionNext"]],this._prevLine3DMesh,this._line3DMesh,t)},_initHandler:function(t,e){var r=t.getData(),i=t.coordinateSystem,n=this._line3DMesh,a=-1;n.seriesIndex=t.seriesIndex,n.off("mousemove"),n.off("mouseout"),n.on("mousemove",(function(t){var o=i.pointToData(t.point.array),s=r.indicesOfNearest("x",o[0])[0];s!==a&&(e.dispatchAction({type:"grid3DShowAxisPointer",value:[r.get("x",s),r.get("y",s),r.get("z",s)]}),n.dataIndex=s),a=s}),this),n.on("mouseout",(function(t){a=-1,n.dataIndex=-1,e.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateNDCPosition:function(){var t=new Ve,e=this._camera;Ve.multiply(t,e.projectionMatrix,e.viewMatrix);var r=this._positionNDC,i=this._points,n=i.length/3;r&&r.length/2===n||(r=this._positionNDC=new Float32Array(2*n));for(var a=[],o=0;o<n;o++){var s=3*o,l=2*o;a[0]=i[s],a[1]=i[s+1],a[2]=i[s+2],a[3]=1,gg.transformMat4(a,a,t.array),r[l]=a[0]/a[3],r[l+1]=a[1]/a[3]}},_pick:function(t,e,r,i,n,a){var o=this._positionNDC,s=this._data.hostModel.get("lineStyle.width"),l=-1,h=.5*r.viewport.width,u=.5*r.viewport.height;t=(t+1)*h,e=(e+1)*u;for(var c=1;c<o.length/2;c++){var d=(o[2*(c-1)]+1)*h,f=(o[2*(c-1)+1]+1)*u,p=(o[2*c]+1)*h,m=(o[2*c+1]+1)*u;Lh(d,f,p,m,s,t,e)&&(l=(d-t)*(d-t)+(f-e)*(f-e)<(p-t)*(p-t)+(m-e)*(m-e)?c-1:c)}if(l>=0){var g=3*l,_=new ve(this._points[g],this._points[g+1],this._points[g+2]);a.push({dataIndex:l,point:_,pointWorld:_.clone(),target:this._line3DMesh,distance:this._camera.getWorldPosition().dist(_)})}},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}}),i.registerLayout((function(t,e){t.eachSeriesByType("line3D",(function(t){var e=t.getData(),r=t.coordinateSystem;if(r){if("cartesian3D"!==r.type)return;var i=new Float32Array(3*e.count()),n=[],a=[],o=r.dimensions.map((function(e){return t.coordDimToDataDim(e)[0]}));r&&e.each(o,(function(t,e,o,s){n[0]=t,n[1]=e,n[2]=o,r.dataToPoint(n,a),i[3*s]=a[0],i[3*s+1]=a[1],i[3*s+2]=a[2]})),e.setLayout("points",i)}}))})),i.extendSeriesModel({type:"series.scatter3D",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,getInitialData:function(t,e){return pg(this)},getFormattedLabel:function(t,e,r,i){var n=$m.getFormattedLabel(this,t,e,r,i);if(null==n){var a=this.getData(),o=a.dimensions[a.dimensions.length-1];n=a.get(o,t)}return n},formatTooltip:function(t){return fg(this,t)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,progressive:1e5,progressiveThreshold:1e5,grid3DIndex:0,globeIndex:0,symbol:"circle",symbolSize:10,blendMode:"source-over",label:{show:!1,position:"right",distance:5,textStyle:{fontSize:14,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:3}},itemStyle:{opacity:.8},emphasis:{label:{show:!0}},animationDurationUpdate:500}});var vg={getMarginByStyle:function(t){var e=t.minMargin||0,r=0;t.stroke&&"none"!==t.stroke&&(r=null==t.lineWidth?1:t.lineWidth);var i=t.shadowBlur||0,n=t.shadowOffsetX||0,a=t.shadowOffsetY||0,o={};return o.left=Math.max(r/2,-n+i,e),o.right=Math.max(r/2,n+i,e),o.top=Math.max(r/2,-a+i,e),o.bottom=Math.max(r/2,a+i,e),o},createSymbolSprite:function(t,e,r,n){var a=function(t,e,r,n){i.util.isArray(e)||(e=[e,e]);var a=vg.getMarginByStyle(r,void 0),o=e[0]+a.left+a.right,s=e[1]+a.top+a.bottom,l=i.helper.createSymbol(t,0,0,e[0],e[1]),h=Math.max(o,s);l.x=a.left,l.y=a.top,o>s?l.y+=(h-s)/2:l.x+=(h-o)/2;var u=l.getBoundingRect();return l.x-=u.x,l.y-=u.y,l.setStyle(r),l.update(),l.__size=h,l}(t,e,r),o=vg.getMarginByStyle(r);return{image:_g(a.__size,n,(function(t){i.innerDrawElementOnCanvas(t,a)})),margin:o}},createSDFFromCanvas:function(t,e,r,i){return _g(e,i,(function(e){var i=t.getContext("2d").getImageData(0,0,t.width,t.height);e.putImageData(function(t,e,r){var i=e.width,n=e.height,a=t.canvas.width,o=t.canvas.height,s=i/a,l=n/o;function h(t){return t<128?1:-1}function u(t,a){var o=1/0;t=Math.floor(t*s);for(var u=(a=Math.floor(a*l))*i+t,c=h(e.data[4*u]),d=Math.max(a-r,0);d<Math.min(a+r,n);d++)for(var f=Math.max(t-r,0);f<Math.min(t+r,i);f++){u=d*i+f;var p=f-t,m=d-a;if(c!==h(e.data[4*u])){var g=p*p+m*m;g<o&&(o=g)}}return c*Math.sqrt(o)}for(var c=t.createImageData(a,o),d=0;d<o;d++)for(var f=0;f<a;f++){var p=u(f,d)/r*.5+.5,m=4*(d*a+f);c.data[m++]=255*(1-p),c.data[m++]=255*(1-p),c.data[m++]=255*(1-p),c.data[m++]=255}return c}(e,i,r),0,0)}))},createSimpleSprite:function(t,e){return _g(t,e,(function(e){var r=t/2;e.beginPath(),e.arc(r,r,60,0,2*Math.PI,!1),e.closePath();var i=e.createRadialGradient(r,r,0,r,r,r);i.addColorStop(0,"rgba(255, 255, 255, 1)"),i.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),i.addColorStop(1,"rgba(255, 255, 255, 0)"),e.fillStyle=i,e.fill()}))}};const yg=vg;var xg=Rc.vec3;const bg={needsSortVertices:function(){return this.sortVertices},needsSortVerticesProgressively:function(){return this.needsSortVertices()&&this.vertexCount>=2e4},doSortVertices:function(t,e){var r=this.indices,i=xg.create();if(!r){r=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var n=0;n<r.length;n++)r[n]=n}if(0===e){var a,o=this.attributes.position,s=(t=t.array,0);for(this._zList&&this._zList.length===this.vertexCount||(this._zList=new Float32Array(this.vertexCount)),n=0;n<this.vertexCount;n++){o.get(n,i);var l=xg.sqrDist(i,t);isNaN(l)&&(l=1e7,s++),0===n?(a=l,l=0):l-=a,this._zList[n]=l}this._noneCount=s}if(this.vertexCount<2e4)0===e&&this._simpleSort(this._noneCount/this.vertexCount>.05);else for(n=0;n<3;n++)this._progressiveQuickSort(3*e+n);this.dirtyIndices()},_simpleSort:function(t){var e=this._zList,r=this.indices;function i(t,r){return e[r]-e[t]}t?Array.prototype.sort.call(r,i):Pp.sort(r,i,0,r.length-1)},_progressiveQuickSort:function(t){var e=this._zList,r=this.indices;this._quickSort=this._quickSort||new Pp,this._quickSort.step(r,(function(t,r){return e[r]-e[t]}),t)}};var wg=Rc.vec4;mo.Shader.import("@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end");const Tg=mo.Mesh.extend((function(){var t=new mo.Geometry({dynamic:!0,attributes:{color:new mo.Geometry.Attribute("color","float",4,"COLOR"),position:new mo.Geometry.Attribute("position","float",3,"POSITION"),size:new mo.Geometry.Attribute("size","float",1),prevPosition:new mo.Geometry.Attribute("prevPosition","float",3),prevSize:new mo.Geometry.Attribute("prevSize","float",1)}});Object.assign(t,bg);var e=new mo.Material({shader:mo.createShader("ecgl.sdfSprite"),transparent:!0,depthMask:!1});e.enableTexture("sprite"),e.define("both","VERTEX_COLOR"),e.define("both","VERTEX_SIZE");var r=new mo.Texture2D({image:document.createElement("canvas"),flipY:!1});return e.set("sprite",r),t.pick=this._pick.bind(this),{geometry:t,material:e,mode:mo.Mesh.POINTS,sizeScale:1}}),{_pick:function(t,e,r,i,n,a){var o=this._positionNDC;if(o)for(var s=r.viewport,l=2/s.width,h=2/s.height,u=this.geometry.vertexCount-1;u>=0;u--){var c,d=o[2*(c=this.geometry.indices?this.geometry.indices[u]:u)],f=o[2*c+1],p=this.geometry.attributes.size.get(c)/this.sizeScale/2;if(t>d-p*l&&t<d+p*l&&e>f-p*h&&e<f+p*h){var m=new mo.Vector3,g=new mo.Vector3;this.geometry.attributes.position.get(c,m.array),mo.Vector3.transformMat4(g,m,this.worldTransform),a.push({vertexIndex:c,point:m,pointWorld:g,target:this,distance:g.distance(i.getWorldPosition())})}}},updateNDCPosition:function(t,e,r){var i=this._positionNDC,n=this.geometry;i&&i.length/2===n.vertexCount||(i=this._positionNDC=new Float32Array(2*n.vertexCount));for(var a=wg.create(),o=0;o<n.vertexCount;o++)n.attributes.position.get(o,a),a[3]=1,wg.transformMat4(a,a,t.array),wg.scale(a,a,1/a[3]),i[2*o]=a[0],i[2*o+1]=a[1]}});function Sg(t,e){this.rootNode=new mo.Node,this.is2D=t,this._labelsBuilder=new Gp(256,256,e),this._labelsBuilder.getMesh().renderOrder=100,this.rootNode.add(this._labelsBuilder.getMesh()),this._api=e,this._spriteImageCanvas=document.createElement("canvas"),this._startDataIndex=0,this._endDataIndex=0,this._sizeScale=1}Sg.prototype={constructor:Sg,highlightOnMouseover:!0,update:function(t,e,r,i,n){var a=this._prevMesh;this._prevMesh=this._mesh,this._mesh=a;var o=t.getData();if(null==i&&(i=0),null==n&&(n=o.count()),this._startDataIndex=i,this._endDataIndex=n-1,!this._mesh){var s=this._prevMesh&&this._prevMesh.material;this._mesh=new Tg({renderOrder:10,frustumCulling:!1}),s&&(this._mesh.material=s)}s=this._mesh.material;var l=this._mesh.geometry,h=l.attributes;this.rootNode.remove(this._prevMesh),this.rootNode.add(this._mesh),this._setPositionTextureToMesh(this._mesh,this._positionTexture);var u=this._getSymbolInfo(t,i,n),c=r.getDevicePixelRatio(),d=t.getModel("itemStyle").getItemStyle(),f=t.get("large"),p=1;u.maxSize>2?(p=this._updateSymbolSprite(t,d,u,c),s.enableTexture("sprite")):s.disableTexture("sprite"),h.position.init(n-i);var m=[];if(f){s.undefine("VERTEX_SIZE"),s.undefine("VERTEX_COLOR");var g=o.getVisual("color"),_=o.getVisual("opacity");mo.parseColor(g,m),m[3]*=_,s.set({color:m,u_Size:u.maxSize*this._sizeScale})}else s.set({color:[1,1,1,1]}),s.define("VERTEX_SIZE"),s.define("VERTEX_COLOR"),h.size.init(n-i),h.color.init(n-i),this._originalOpacity=new Float32Array(n-i);for(var v=o.getLayout("points"),y=h.position.value,x=0;x<n-i;x++){var b=3*x,w=2*x;if(this.is2D?(y[b]=v[w],y[b+1]=v[w+1],y[b+2]=-10):(y[b]=v[b],y[b+1]=v[b+1],y[b+2]=v[b+2]),!f){g=Fp(o,x),_=zp(o,x),mo.parseColor(g,m),m[3]*=_,h.color.set(x,m),m[3];var T=o.getItemVisual(x,"symbolSize");T=T instanceof Array?Math.max(T[0],T[1]):T,isNaN(T)&&(T=0),h.size.value[x]=T*p*this._sizeScale,this._originalOpacity[x]=m[3]}}this._mesh.sizeScale=p,l.updateBoundingBox(),l.dirty(),this._updateMaterial(t,d);var S=t.coordinateSystem;S&&S.viewGL&&s[S.viewGL.isLinearSpace()?"define":"undefine"]("fragment","SRGB_DECODE"),f||this._updateLabelBuilder(t,i,n),this._updateHandler(t,e,r),this._updateAnimation(t),this._api=r},getPointsMesh:function(){return this._mesh},updateLabels:function(t){this._labelsBuilder.updateLabels(t)},hideLabels:function(){this.rootNode.remove(this._labelsBuilder.getMesh())},showLabels:function(){this.rootNode.add(this._labelsBuilder.getMesh())},_updateSymbolSprite:function(t,e,r,i){r.maxSize=Math.min(2*r.maxSize,200);var n,a,o=[];return r.aspect>1?(o[0]=r.maxSize,o[1]=r.maxSize/r.aspect):(o[1]=r.maxSize,o[0]=r.maxSize*r.aspect),o[0]=o[0]||1,o[1]=o[1]||1,this._symbolType===r.type&&(a=o,(n=this._symbolSize)&&a&&n[0]===a[0]&&n[1]===a[1])&&this._lineWidth===e.lineWidth||(yg.createSymbolSprite(r.type,o,{fill:"#fff",lineWidth:e.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(o[0]/2,10)},this._spriteImageCanvas),yg.createSDFFromCanvas(this._spriteImageCanvas,Math.min(this._spriteImageCanvas.width,32),20,this._mesh.material.get("sprite").image),this._symbolType=r.type,this._symbolSize=o,this._lineWidth=e.lineWidth),this._spriteImageCanvas.width/r.maxSize*i},_updateMaterial:function(t,e){var r="lighter"===t.get("blendMode")?mo.additiveBlend:null,i=this._mesh.material;i.blend=r,i.set("lineWidth",e.lineWidth/20);var n=mo.parseColor(e.stroke);i.set("strokeColor",n),i.transparent=!0,i.depthMask=!1,i.depthTest=!this.is2D,i.sortVertices=!this.is2D},_updateLabelBuilder:function(t,e,r){var i=t.getData(),n=this._mesh.geometry,a=n.attributes.position.value,o=(e=this._startDataIndex,this._mesh.sizeScale);this._labelsBuilder.updateData(i,e,r),this._labelsBuilder.getLabelPosition=function(t,r,i){var n=3*(t-e);return[a[n],a[n+1],a[n+2]]},this._labelsBuilder.getLabelDistance=function(t,r,i){return n.attributes.size.get(t-e)/o/2+i},this._labelsBuilder.updateLabels()},_updateAnimation:function(t){mo.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,t)},_updateHandler:function(t,e,r){var i,n=t.getData(),a=this._mesh,o=this,s=-1,l=t.coordinateSystem&&"cartesian3D"===t.coordinateSystem.type;l&&(i=t.coordinateSystem.model),a.seriesIndex=t.seriesIndex,a.off("mousemove"),a.off("mouseout"),a.on("mousemove",(function(e){var h=e.vertexIndex+o._startDataIndex;h!==s&&(this.highlightOnMouseover&&(this.downplay(n,s),this.highlight(n,h),this._labelsBuilder.updateLabels([h])),l&&r.dispatchAction({type:"grid3DShowAxisPointer",value:[n.get(t.coordDimToDataDim("x")[0],h),n.get(t.coordDimToDataDim("y")[0],h),n.get(t.coordDimToDataDim("z")[0],h)],grid3DIndex:i.componentIndex})),a.dataIndex=h,s=h}),this),a.on("mouseout",(function(t){var e=t.vertexIndex+o._startDataIndex;this.highlightOnMouseover&&(this.downplay(n,e),this._labelsBuilder.updateLabels()),s=-1,a.dataIndex=-1,l&&r.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:i.componentIndex})}),this)},updateLayout:function(t,e,r){var i=t.getData();if(this._mesh){var n=this._mesh.geometry.attributes.position.value,a=i.getLayout("points");if(this.is2D)for(var o=0;o<a.length/2;o++){var s=3*o,l=2*o;n[s]=a[l],n[s+1]=a[l+1],n[s+2]=-10}else for(o=0;o<a.length;o++)n[o]=a[o];this._mesh.geometry.dirty(),r.getZr().refresh()}},updateView:function(t){if(this._mesh){var e=new Ve;Ve.mul(e,t.viewMatrix,this._mesh.worldTransform),Ve.mul(e,t.projectionMatrix,e),this._mesh.updateNDCPosition(e,this.is2D,this._api)}},highlight:function(t,e){if(!(e>this._endDataIndex||e<this._startDataIndex)){var r=t.getItemModel(e).getModel("emphasis.itemStyle"),n=r.get("color"),a=r.get("opacity");if(null==n){var o=Fp(t,e);n=i.color.lift(o,-.4)}null==a&&(a=zp(t,e));var s=mo.parseColor(n);s[3]*=a,this._mesh.geometry.attributes.color.set(e-this._startDataIndex,s),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},downplay:function(t,e){if(!(e>this._endDataIndex||e<this._startDataIndex)){var r=Fp(t,e),i=zp(t,e),n=mo.parseColor(r);n[3]*=i,this._mesh.geometry.attributes.color.set(e-this._startDataIndex,n),this._mesh.geometry.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeOutAll:function(t){if(this._originalOpacity){for(var e=this._mesh.geometry,r=0;r<e.vertexCount;r++){var i=this._originalOpacity[r]*t;e.attributes.color.value[4*r+3]=i}e.dirtyAttribute("color"),this._api.getZr().refresh()}},fadeInAll:function(){this.fadeOutAll(1)},setPositionTexture:function(t){this._mesh&&this._setPositionTextureToMesh(this._mesh,t),this._positionTexture=t},removePositionTexture:function(){this._positionTexture=null,this._mesh&&this._setPositionTextureToMesh(this._mesh,null)},setSizeScale:function(t){if(t!==this._sizeScale){if(this._mesh){var e=this._mesh.material.get("u_Size");this._mesh.material.set("u_Size",e/this._sizeScale*t);var r=this._mesh.geometry.attributes;if(r.size.value)for(var i=0;i<r.size.value.length;i++)r.size.value[i]=r.size.value[i]/this._sizeScale*t}this._sizeScale=t}},_setPositionTextureToMesh:function(t,e){e&&t.material.set("positionTexture",e),t.material[e?"enableTexture":"disableTexture"]("positionTexture")},_getSymbolInfo:function(t,e,r){if(t.get("large"))return(h=Sn(t.get("symbolSize"),1))instanceof Array?(o=Math.max(h[0],h[1]),i=h[0]/h[1]):(o=h,i=1),{maxSize:h,type:t.get("symbol"),aspect:i};for(var i,n=t.getData(),a=n.getItemVisual(0,"symbol")||"circle",o=0,s=e;s<r;s++){var l,h=n.getItemVisual(s,"symbolSize"),u=n.getItemVisual(s,"symbol");if(h instanceof Array)l=h[0]/h[1],o=Math.max(Math.max(h[0],h[1]),o);else{if(isNaN(h))continue;l=1,o=Math.max(h,o)}a=u,i=l}return{maxSize:o,type:a,aspect:i}}};const Mg=Sg;i.extendChartView({type:"scatter3D",hasSymbolVisual:!0,__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this._pointsBuilderList=[],this._currentStep=0},render:function(t,e,r){if(this.groupGL.removeAll(),t.getData().count()){var i=t.coordinateSystem;if(i&&i.viewGL){i.viewGL.add(this.groupGL),this._camera=i.viewGL.camera;var n=this._pointsBuilderList[0];n||(n=this._pointsBuilderList[0]=new Mg(!1,r)),this._pointsBuilderList.length=1,this.groupGL.add(n.rootNode),n.update(t,e,r),n.updateView(i.viewGL.camera)}}},incrementalPrepareRender:function(t,e,r){var i=t.coordinateSystem;i&&i.viewGL&&(i.viewGL.add(this.groupGL),this._camera=i.viewGL.camera),this.groupGL.removeAll(),this._currentStep=0},incrementalRender:function(t,e,r,i){if(!(t.end<=t.start)){var n=this._pointsBuilderList[this._currentStep];n||(n=new Mg(!1,i),this._pointsBuilderList[this._currentStep]=n),this.groupGL.add(n.rootNode),n.update(e,r,i,t.start,t.end),n.updateView(e.coordinateSystem.viewGL.camera),this._currentStep++}},updateCamera:function(){this._pointsBuilderList.forEach((function(t){t.updateView(this._camera)}),this)},highlight:function(t,e,r,i){this._toggleStatus("highlight",t,e,r,i)},downplay:function(t,e,r,i){this._toggleStatus("downplay",t,e,r,i)},_toggleStatus:function(t,e,r,n,a){var o=e.getData(),s=Mn(o,a),l="highlight"===t;null!=s?i.util.each($m.normalizeToArray(s),(function(t){for(var e=0;e<this._pointsBuilderList.length;e++){var r=this._pointsBuilderList[e];l?r.highlight(o,t):r.downplay(o,t)}}),this):o.each((function(t){for(var e=0;e<this._pointsBuilderList.length;e++){var r=this._pointsBuilderList[e];l?r.highlight(o,t):r.downplay(o,t)}}))},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}}),i.registerLayout({seriesType:"scatter3D",reset:function(t){var e=t.coordinateSystem;if(e){var r=e.dimensions;if(r.length<3)return;var i=r.map((function(e){return t.coordDimToDataDim(e)[0]})),n=[],a=[];return{progress:function(t,r){for(var o=new Float32Array(3*(t.end-t.start)),s=t.start;s<t.end;s++){var l=3*(s-t.start);n[0]=r.get(i[0],s),n[1]=r.get(i[1],s),n[2]=r.get(i[2],s),e.dataToPoint(n,a),o[l]=a[0],o[l+1]=a[1],o[l+2]=a[2]}r.setLayout("points",o)}}}}});var Ag=Rc.vec3,Cg=Rc.vec2,Eg=Ag.normalize,Dg=Ag.cross,Lg=Ag.sub,Pg=Ag.add,Og=Ag.create,Ng=Og(),Ig=Og(),Rg=Og(),Bg=Og(),Fg=[],zg=[];function kg(t,e){Cg.copy(Fg,t[0]),Cg.copy(zg,t[1]);var r=[],i=r[0]=Og(),n=r[1]=Og(),a=r[2]=Og(),o=r[3]=Og();e.dataToPoint(Fg,i),e.dataToPoint(zg,o),Eg(Ng,i),Lg(Ig,o,i),Eg(Ig,Ig),Dg(Rg,Ig,Ng),Eg(Rg,Rg),Dg(Ig,Ng,Rg),Pg(n,Ng,Ig),Eg(n,n),Eg(Ng,o),Lg(Ig,i,o),Eg(Ig,Ig),Dg(Rg,Ig,Ng),Eg(Rg,Rg),Dg(Ig,Ng,Rg),Pg(a,Ng,Ig),Eg(a,a),Pg(Bg,i,o),Eg(Bg,Bg);var s=Ag.dot(i,Bg),l=Ag.dot(Bg,n),h=(Math.max(Ag.len(i),Ag.len(o))-s)/l*2;return Ag.scaleAndAdd(n,i,n,h),Ag.scaleAndAdd(a,o,a,h),r}function Gg(t,e){for(var r=new Float32Array(3*t.length),i=0,n=[],a=0;a<t.length;a++)e.dataToPoint(t[a],n),r[i++]=n[0],r[i++]=n[1],r[i++]=n[2];return r}function Ug(t){var e=[];return t.each((function(r){var i=t.getItemModel(r),n=i.option instanceof Array?i.option:i.getShallow("coords",!0);e.push(n)})),{coordsList:e}}function Hg(t,e,r){var i=t.getData(),n=t.get("polyline"),a=Ug(i);i.setLayout("lineType",n?"polyline":"cubicBezier"),i.each((function(t){var o=a.coordsList[t],s=n?Gg(o,e):function(t,e,r){var i=[],n=i[0]=Ag.create(),a=i[1]=Ag.create(),o=i[2]=Ag.create(),s=i[3]=Ag.create();e.dataToPoint(t[0],n),e.dataToPoint(t[1],s);var l=Ag.dist(n,s);return Ag.lerp(a,n,s,.3),Ag.lerp(o,n,s,.3),Ag.scaleAndAdd(a,a,r,Math.min(.1*l,10)),Ag.scaleAndAdd(o,o,r,Math.min(.1*l,10)),i}(o,e,r);i.setItemLayout(t,s)}))}i.registerLayout((function(t,e){t.eachSeriesByType("lines3D",(function(t){var e=t.coordinateSystem;"globe"===e.type?function(t,e){var r=t.getData(),i=t.get("polyline");r.setLayout("lineType",i?"polyline":"cubicBezier");var n=Ug(r);r.each((function(t){var a=n.coordsList[t],o=i?Gg:kg;r.setItemLayout(t,o(a,e))}))}(t,e):"geo3D"===e.type?Hg(t,e,[0,1,0]):"mapbox3D"!==e.type&&"maptalks3D"!==e.type||Hg(t,e,[0,0,1])}))}));var Vg=Rc.vec3;mo.Shader.import("@export ecgl.trail2.vertex\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute float dist;\nattribute float distAll;\nattribute float start;\n\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nuniform float speed : 0;\nuniform float trailLength: 0.3;\nuniform float time;\nuniform float period: 1000;\n\nuniform float spotSize: 1;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n\n#ifdef CONSTANT_SPEED\n float t = mod((speed * time + start) / distAll, 1. + trailLength) - trailLength;\n#else\n float t = mod((time + start) / period, 1. + trailLength) - trailLength;\n#endif\n\n float trailLen = distAll * trailLength;\n\n v_Percent = (dist - t * distAll) / trailLen;\n\n v_SpotPercent = spotSize / distAll;\n\n }\n@end\n\n\n@export ecgl.trail2.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float spotIntensity: 5;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n if (v_Percent > 1.0 || v_Percent < 0.0) {\n discard;\n }\n\n float fade = v_Percent;\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n\n if (v_Percent > (1.0 - v_SpotPercent)) {\n gl_FragColor.rgb *= spotIntensity;\n }\n\n gl_FragColor.a *= fade;\n}\n\n@end");const Wg=mo.Mesh.extend((function(){var t=new mo.Material({shader:new mo.Shader(mo.Shader.source("ecgl.trail2.vertex"),mo.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),e=new kc({dynamic:!0});return e.createAttribute("dist","float",1),e.createAttribute("distAll","float",1),e.createAttribute("start","float",1),{geometry:e,material:t,culling:!1,$ignorePicking:!0}}),{updateData:function(t,e,r){var i=t.hostModel,n=this.geometry,a=i.getModel("effect"),o=a.get("trailWidth")*e.getDevicePixelRatio(),s=a.get("trailLength"),l=i.get("effect.constantSpeed"),h=1e3*i.get("effect.period"),u=null!=l;u?this.material.set("speed",l/1e3):this.material.set("period",h),this.material[u?"define":"undefine"]("vertex","CONSTANT_SPEED");var c=i.get("polyline");n.trailLength=s,this.material.set("trailLength",s),n.resetOffset(),["position","positionPrev","positionNext"].forEach((function(t){n.attributes[t].value=r.attributes[t].value})),["dist","distAll","start","offset","color"].forEach((function(t){n.attributes[t].init(n.vertexCount)})),n.indices=r.indices;var d=[],f=a.get("trailColor"),p=a.get("trailOpacity"),m=null!=f,g=null!=p;this.updateWorldTransform();var _=this.worldTransform.x.len(),v=this.worldTransform.y.len(),y=this.worldTransform.z.len(),x=0,b=0;t.each((function(e){var i=t.getItemLayout(e),a=g?p:zp(t,e),s=Fp(t,e);null==a&&(a=1),(d=mo.parseColor(m?f:s,d))[3]*=a;for(var l=c?r.getPolylineVertexCount(i):r.getCubicCurveVertexCount(i[0],i[1],i[2],i[3]),w=0,T=[],S=[],M=x;M<x+l;M++)n.attributes.position.get(M,T),T[0]*=_,T[1]*=v,T[2]*=y,M>x&&(w+=Vg.dist(T,S)),n.attributes.dist.set(M,w),Vg.copy(S,T);b=Math.max(b,w);var A=Math.random()*(u?w:h);for(M=x;M<x+l;M++)n.attributes.distAll.set(M,w),n.attributes.start.set(M,A),n.attributes.offset.set(M,(r.attributes.offset.get(M)>0?1:-1)*o/2),n.attributes.color.set(M,d);x+=l})),this.material.set("spotSize",.1*b*s),this.material.set("spotIntensity",a.get("spotIntensity")),n.dirty()},setAnimationTime:function(t){this.material.set("time",t)}});function jg(t,e){for(var r=[],i=0;i<e.length;i++)r.push(t.dataToPoint(e[i]));return r}mo.Shader.import(sd),i.extendChartView({type:"lines3D",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this._meshLinesMaterial=new mo.Material({shader:mo.createShader("ecgl.meshLines3D"),transparent:!0,depthMask:!1}),this._linesMesh=new mo.Mesh({geometry:new kc,material:this._meshLinesMaterial,$ignorePicking:!0}),this._trailMesh=new Wg},render:function(t,e,r){this.groupGL.add(this._linesMesh);var i=t.coordinateSystem,n=t.getData();if(i&&i.viewGL){i.viewGL.add(this.groupGL),this._updateLines(t,e,r);var a=i.viewGL.isLinearSpace()?"define":"undefine";this._linesMesh.material[a]("fragment","SRGB_DECODE"),this._trailMesh.material[a]("fragment","SRGB_DECODE")}var o=this._trailMesh;if(o.stopAnimation(),t.get("effect.show")){this.groupGL.add(o),o.updateData(n,r,this._linesMesh.geometry),o.__time=o.__time||0;var s=36e5;this._curveEffectsAnimator=o.animate("",{loop:!0}).when(s,{__time:s}).during((function(){o.setAnimationTime(o.__time)})).start()}else this.groupGL.remove(o),this._curveEffectsAnimator=null;this._linesMesh.material.blend=this._trailMesh.material.blend="lighter"===t.get("blendMode")?mo.additiveBlend:null},pauseEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.pause()},resumeEffect:function(){this._curveEffectsAnimator&&this._curveEffectsAnimator.resume()},toggleEffect:function(){var t=this._curveEffectsAnimator;t&&(t.isPaused()?t.resume():t.pause())},_updateLines:function(t,e,r){var i=t.getData(),n=t.coordinateSystem,a=this._linesMesh.geometry,o=t.get("polyline");a.expandLine=!0;var s=function(t){return null!=t.radius?t.radius:null!=t.size?Math.max(t.size[0],t.size[1],t.size[2]):100}(n);a.segmentScale=s/20;var l="lineStyle.width".split("."),h=r.getDevicePixelRatio(),u=0;i.each((function(t){var e=i.getItemModel(t).get(l);null==e&&(e=1),i.setItemVisual(t,"lineWidth",e),u=Math.max(e,u)})),a.useNativeLine=!1;var c=0,d=0;i.each((function(t){var e=i.getItemLayout(t);o?(c+=a.getPolylineVertexCount(e),d+=a.getPolylineTriangleCount(e)):(c+=a.getCubicCurveVertexCount(e[0],e[1],e[2],e[3]),d+=a.getCubicCurveTriangleCount(e[0],e[1],e[2],e[3]))})),a.setVertexCount(c),a.setTriangleCount(d),a.resetOffset();var f=[];i.each((function(t){var e=i.getItemLayout(t),r=Fp(i,t),n=zp(i,t),s=i.getItemVisual(t,"lineWidth")*h;null==n&&(n=1),(f=mo.parseColor(r,f))[3]*=n,o?a.addPolyline(e,f,s):a.addCubicCurve(e[0],e[1],e[2],e[3],f,s)})),a.dirty()},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}}),i.extendSeriesModel({type:"series.lines3D",dependencies:["globe"],visualStyleAccessPath:"lineStyle",getInitialData:function(t,e){var r=new i.List(["value"],this);return r.hasItemOption=!1,r.initData(t.data,[],(function(t,e,i,n){if(t instanceof Array)return NaN;r.hasItemOption=!0;var a=t.value;return null!=a?a instanceof Array?a[n]:a:void 0})),r},defaultOption:{coordinateSystem:"globe",globeIndex:0,geo3DIndex:0,zlevel:-10,polyline:!1,effect:{show:!1,period:4,trailWidth:4,trailLength:.2,spotIntensity:6},silent:!0,blendMode:"source-over",lineStyle:{width:1,opacity:.5}}}),i.registerAction({type:"lines3DPauseEffect",event:"lines3deffectpaused",update:"series.lines3D:pauseEffect"},(function(){})),i.registerAction({type:"lines3DResumeEffect",event:"lines3deffectresumed",update:"series.lines3D:resumeEffect"},(function(){})),i.registerAction({type:"lines3DToggleEffect",event:"lines3deffectchanged",update:"series.lines3D:toggleEffect"},(function(){}));var Xg=i.extendSeriesModel({type:"series.polygons3D",getRegionModel:function(t){return this.getData().getItemModel(t)},getRegionPolygonCoords:function(t){var e=this.coordinateSystem,r=this.getData().getItemModel(t),i=r.option instanceof Array?r.option:r.getShallow("coords");r.get("multiPolygon")||(i=[i]);for(var n=[],a=0;a<i.length;a++){for(var o=[],s=1;s<i[a].length;s++)o.push(jg(e,i[a][s]));n.push({exterior:jg(e,i[a][0]),interiors:o})}return n},getInitialData:function(t){var e=new i.List(["value"],this);return e.hasItemOption=!1,e.initData(t.data,[],(function(t,r,i,n){if(t instanceof Array)return NaN;e.hasItemOption=!0;var a=t.value;return null!=a?a instanceof Array?a[n]:a:void 0})),e},defaultOption:{show:!0,data:null,multiPolygon:!1,progressiveThreshold:1e3,progressive:1e3,zlevel:-10,label:{show:!1,distance:2,textStyle:{fontSize:20,color:"#000",backgroundColor:"rgba(255,255,255,0.7)",padding:3,borderRadius:4}},itemStyle:{color:"#fff",borderWidth:0,borderColor:"#333"},emphasis:{itemStyle:{color:"#639fc0"},label:{show:!0}}}});i.util.merge(Xg.prototype,tp),i.extendChartView({type:"polygons3D",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this._geo3DBuilderList=[],this._currentStep=0},render:function(t,e,r){this.groupGL.removeAll();var i=t.coordinateSystem;i&&i.viewGL&&i.viewGL.add(this.groupGL);var n=this._geo3DBuilderList[0];n||((n=new Vp(r)).extrudeY="mapbox3D"!==i.type&&"maptalks3D"!==i.type,this._geo3DBuilderList[0]=n),this._updateShaderDefines(i,n),n.update(t,e,r),this._geo3DBuilderList.length=1,this.groupGL.add(n.rootNode)},incrementalPrepareRender:function(t,e,r){this.groupGL.removeAll();var i=t.coordinateSystem;i&&i.viewGL&&i.viewGL.add(this.groupGL),this._currentStep=0},incrementalRender:function(t,e,r,i){var n=this._geo3DBuilderList[this._currentStep],a=e.coordinateSystem;n||((n=new Vp(i)).extrudeY="mapbox3D"!==a.type&&"maptalks3D"!==a.type,this._geo3DBuilderList[this._currentStep]=n),n.update(e,r,i,t.start,t.end),this.groupGL.add(n.rootNode),this._updateShaderDefines(a,n),this._currentStep++},_updateShaderDefines:function(t,e){var r=t.viewGL.isLinearSpace()?"define":"undefine";e.rootNode.traverse((function(e){e.material&&(e.material[r]("fragment","SRGB_DECODE"),"mapbox3D"!==t.type&&"maptalks3D"!==t.type||(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1)))}))},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}});var qg=i.extendSeriesModel({type:"series.surface",dependencies:["globe","grid3D","geo3D"],visualStyleAccessPath:"itemStyle",formatTooltip:function(t){return fg(this,t)},getInitialData:function(t,e){var r=t.data;function n(t){return!(isNaN(t.min)||isNaN(t.max)||isNaN(t.step))}function a(t){var e=i.number.getPrecisionSafe;return Math.max(e(t.min),e(t.max),e(t.step))+1}if(!r)if(t.parametric){var o=t.parametricEquation||{},s=o.u||{},l=o.v||{};["u","v"].forEach((function(t){n(o[t])})),["x","y","z"].forEach((function(t){o[t]}));var h=Math.floor((s.max+s.step-s.min)/s.step),u=Math.floor((l.max+l.step-l.min)/l.step);r=new Float32Array(h*u*5);var c=a(s),d=a(l);for(S=0,M=0;M<u;M++)for(A=0;A<h;A++){var f=A*s.step+s.min,p=M*l.step+l.min,m=i.number.round(Math.min(f,s.max),c),g=i.number.round(Math.min(p,l.max),d);C=o.x(m,g),E=o.y(m,g),P=o.z(m,g),r[S++]=C,r[S++]=E,r[S++]=P,r[S++]=m,r[S++]=g}}else{var _=t.equation||{},v=_.x||{},y=_.y||{};if(["x","y"].forEach((function(t){n(_[t])})),"function"!=typeof _.z)return;var x=Math.floor((v.max+v.step-v.min)/v.step),b=Math.floor((y.max+y.step-y.min)/y.step);r=new Float32Array(x*b*3);for(var w=a(v),T=a(y),S=0,M=0;M<b;M++)for(var A=0;A<x;A++){var C=A*v.step+v.min,E=M*y.step+y.min,D=i.number.round(Math.min(C,v.max),w),L=i.number.round(Math.min(E,y.max),T),P=_.z(D,L);r[S++]=D,r[S++]=L,r[S++]=P}}var O=["x","y","z"];return t.parametric&&O.push("u","v"),pg(this,O,r)},defaultOption:{coordinateSystem:"cartesian3D",zlevel:-10,grid3DIndex:0,shading:"lambert",parametric:!1,wireframe:{show:!0,lineStyle:{color:"rgba(0,0,0,0.5)",width:1}},equation:{x:{min:-1,max:1,step:.1},y:{min:-1,max:1,step:.1},z:null},parametricEquation:{u:{min:-1,max:1,step:.1},v:{min:-1,max:1,step:.1},x:null,y:null,z:null},dataShape:null,itemStyle:{},animationDurationUpdate:500}});i.util.merge(qg.prototype,tp);var Zg=Rc.vec3;function Yg(t,e){for(var r=[],i=0;i<e.length;i++)r.push(t.dataToPoint(e[i]));return r}i.extendChartView({type:"surface",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node},render:function(t,e,r){var i=this._prevSurfaceMesh;this._prevSurfaceMesh=this._surfaceMesh,this._surfaceMesh=i,this._surfaceMesh||(this._surfaceMesh=this._createSurfaceMesh()),this.groupGL.remove(this._prevSurfaceMesh),this.groupGL.add(this._surfaceMesh);var n=t.coordinateSystem,a=t.get("shading"),o=t.getData(),s="ecgl."+a;if(this._surfaceMesh.material&&this._surfaceMesh.material.shader.name===s||(this._surfaceMesh.material=mo.createMaterial(s,["VERTEX_COLOR","DOUBLE_SIDED"])),mo.setMaterialFromModel(a,this._surfaceMesh.material,t,r),n&&n.viewGL){n.viewGL.add(this.groupGL);var l=n.viewGL.isLinearSpace()?"define":"undefine";this._surfaceMesh.material[l]("fragment","SRGB_DECODE")}var h=t.get("parametric"),u=t.get("dataShape");u||(u=this._getDataShape(o,h));var c=t.getModel("wireframe"),d=c.get("lineStyle.width"),f=c.get("show")&&d>0;this._updateSurfaceMesh(this._surfaceMesh,t,u,f);var p=this._surfaceMesh.material;f?(p.define("WIREFRAME_QUAD"),p.set("wireframeLineWidth",d),p.set("wireframeLineColor",mo.parseColor(c.get("lineStyle.color")))):p.undefine("WIREFRAME_QUAD"),this._initHandler(t,r),this._updateAnimation(t)},_updateAnimation:function(t){mo.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,t)},_createSurfaceMesh:function(){var t=new mo.Mesh({geometry:new mo.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new mo.Material({shader:new mo.Shader(mo.Shader.source("ecgl.sm.depth.vertex"),mo.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return t.geometry.createAttribute("barycentric","float",4),t.geometry.createAttribute("prevPosition","float",3),t.geometry.createAttribute("prevNormal","float",3),Object.assign(t.geometry,Bp),t},_initHandler:function(t,e){var r=t.getData(),i=this._surfaceMesh,n=t.coordinateSystem;i.seriesIndex=t.seriesIndex;var a=-1;i.off("mousemove"),i.off("mouseout"),i.on("mousemove",(function(t){var o=function(t,e){for(var r=1/0,n=-1,a=[],o=0;o<t.length;o++){i.geometry.attributes.position.get(t[o],a);var s=Zg.dist(e.array,a);s<r&&(r=s,n=t[o])}return n}(t.triangle,t.point);if(o>=0){var s=[];i.geometry.attributes.position.get(o,s);for(var l=n.pointToData(s),h=1/0,u=-1,c=[],d=0;d<r.count();d++){c[0]=r.get("x",d),c[1]=r.get("y",d),c[2]=r.get("z",d);var f=Zg.squaredDistance(c,l);f<h&&(u=d,h=f)}u!==a&&e.dispatchAction({type:"grid3DShowAxisPointer",value:l}),a=u,i.dataIndex=u}else i.dataIndex=-1}),this),i.on("mouseout",(function(t){a=-1,i.dataIndex=-1,e.dispatchAction({type:"grid3DHideAxisPointer"})}),this)},_updateSurfaceMesh:function(t,e,r,i){var n=t.geometry,a=e.getData(),o=a.getLayout("points"),s=0;a.each((function(t){a.hasValue(t)||s++}));var l=s||i,h=n.attributes.position,u=n.attributes.normal,c=n.attributes.texcoord0,d=n.attributes.barycentric,f=n.attributes.color,p=r[0],m=r[1],g="color"!==e.get("shading");if(l){var _=(p-1)*(m-1)*4;h.init(_),i&&d.init(_)}else h.value=new Float32Array(o);f.init(n.vertexCount),c.init(n.vertexCount);var v,y=[0,3,1,1,3,2],x=[[1,1,0,0],[0,1,0,1],[1,0,0,1],[1,0,1,0]],b=n.indices=new(n.vertexCount>65535?Uint32Array:Uint16Array)((p-1)*(m-1)*6),w=function(t,e,r){r[1]=t*m+e,r[0]=t*m+e+1,r[3]=(t+1)*m+e+1,r[2]=(t+1)*m+e},T=!1;if(l){var S=[],M=[],A=0;g?u.init(n.vertexCount):u.value=null;for(var C=[[],[],[]],E=[],D=[],L=Zg.create(),P=function(t,e,r){var i=3*e;return r[0]=t[i],r[1]=t[i+1],r[2]=t[i+2],r},O=new Float32Array(o.length),N=new Float32Array(o.length/3*4),I=0;I<a.count();I++)if(a.hasValue(I)){var R=mo.parseColor(Fp(a,I)),B=zp(a,I);R[3]*=B,R[3]<.99&&(T=!0);for(var F=0;F<4;F++)N[4*I+F]=R[F]}var z=[1e7,1e7,1e7];for(I=0;I<p-1;I++)for(var k=0;k<m-1;k++){var G=4*(I*(m-1)+k);w(I,k,S);var U=!1;for(F=0;F<4;F++)P(o,S[F],M),v=M,(isNaN(v[0])||isNaN(v[1])||isNaN(v[2]))&&(U=!0);for(F=0;F<4;F++)U?h.set(G+F,z):(P(o,S[F],M),h.set(G+F,M)),i&&d.set(G+F,x[F]);for(F=0;F<6;F++)b[A++]=y[F]+G;if(g&&!U)for(F=0;F<2;F++){for(var H=3*F,V=0;V<3;V++)P(o,X=S[y[H]+V],C[V]);for(Zg.sub(E,C[0],C[1]),Zg.sub(D,C[1],C[2]),Zg.cross(L,E,D),V=0;V<3;V++){var W=3*S[y[H]+V];O[W]=O[W]+L[0],O[W+1]=O[W+1]+L[1],O[W+2]=O[W+2]+L[2]}}}if(g)for(I=0;I<O.length/3;I++)P(O,I,L),Zg.normalize(L,L),O[3*I]=L[0],O[3*I+1]=L[1],O[3*I+2]=L[2];R=[];var j=[];for(I=0;I<p-1;I++)for(k=0;k<m-1;k++)for(G=4*(I*(m-1)+k),w(I,k,S),F=0;F<4;F++){for(V=0;V<4;V++)R[V]=N[4*S[F]+V];f.set(G+F,R),g&&(P(O,S[F],L),u.set(G+F,L));var X=S[F];j[0]=X%m/(m-1),j[1]=Math.floor(X/m)/(p-1),c.set(G+F,j)}}else{for(j=[],I=0;I<a.count();I++)j[0]=I%m/(m-1),j[1]=Math.floor(I/m)/(p-1),R=mo.parseColor(Fp(a,I)),B=zp(a,I),R[3]*=B,R[3]<.99&&(T=!0),f.set(I,R),c.set(I,j);S=[];var q=0;for(I=0;I<p-1;I++)for(k=0;k<m-1;k++)for(w(I,k,S),F=0;F<6;F++)b[q++]=S[y[F]];g?n.generateVertexNormals():u.value=null}t.material.get("normalMap")&&n.generateTangents(),n.updateBoundingBox(),n.dirty(),t.material.transparent=T,t.material.depthMask=!T},_getDataShape:function(t,e){for(var r=-1/0,i=0,n=0,a=!1,o=e?"u":"x",s=t.count(),l=0;l<s;l++){var h=t.get(o,l);h<r&&(n=0,i++),r=h,n++}if(i&&1!==n||(a=!0),!a)return[i+1,n];for(var u=Math.floor(Math.sqrt(s));u>0;){if(Math.floor(s/u)===s/u)return[u,s/u];u--}return[u=Math.floor(Math.sqrt(s)),u]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}}),i.registerLayout((function(t,e){t.eachSeriesByType("surface",(function(t){var e=t.coordinateSystem;e&&e.type;var r=t.getData(),i=new Float32Array(3*r.count()),n=[NaN,NaN,NaN];if(e&&"cartesian3D"===e.type){var a=e.dimensions.map((function(e){return t.coordDimToDataDim(e)[0]}));r.each(a,(function(t,a,o,s){var l;l=r.hasValue(s)?e.dataToPoint([t,a,o]):n,i[3*s]=l[0],i[3*s+1]=l[1],i[3*s+2]=l[2]}))}r.setLayout("points",i)}))}));var Kg=i.extendSeriesModel({type:"series.map3D",layoutMode:"box",coordinateSystem:null,visualStyleAccessPath:"itemStyle",optionUpdated:function(t){t=t||{};var e=this.get("coordinateSystem");null!=e&&"geo3D"!==e&&(this.get("groundPlane.show")&&(this.option.groundPlane.show=!1),this._geo=null)},getInitialData:function(t){t.data=this.getFilledRegions(t.data,t.map);var e=i.helper.createDimensions(["value"],t.data),r=new i.List(e,this);r.initData(t.data);var n={};return r.each((function(t){var e=r.getName(t),i=r.getItemModel(t);n[e]=i})),this._regionModelMap=n,r},formatTooltip:function(t){return fg(this,t)},getRegionModel:function(t){var e=this.getData().getName(t);return this._regionModelMap[e]||new i.Model(null,this)},getRegionPolygonCoords:function(t){var e=this.coordinateSystem,r=this.getData().getName(t);if(e.transform)return(i=e.getRegion(r))?i.geometries:[];this._geo||(this._geo=em.createGeo3D(this));for(var i=this._geo.getRegion(r),n=[],a=0;a<i.geometries.length;a++){var o=i.geometries[a],s=[],l=Yg(e,o.exterior);if(s&&s.length)for(var h=0;h<o.interiors.length;h++)s.push(Yg(e,s[h]));n.push({interiors:s,exterior:l})}return n},getFormattedLabel:function(t,e){var r=$m.getFormattedLabel(this,t,e);return null==r&&(r=this.getData().getName(t)),r},defaultOption:{coordinateSystem:"geo3D",data:null}});function Qg(t){this.viewGL=t}i.util.merge(Kg.prototype,ep),i.util.merge(Kg.prototype,Uo),i.util.merge(Kg.prototype,Ho),i.util.merge(Kg.prototype,Vo),i.util.merge(Kg.prototype,tp),i.extendChartView({type:"map3D",__ecgl__:!0,init:function(t,e){this._geo3DBuilder=new Vp(e),this.groupGL=new mo.Node},render:function(t,e,r){var i=t.coordinateSystem;if(i&&i.viewGL){if(this.groupGL.add(this._geo3DBuilder.rootNode),i.viewGL.add(this.groupGL),"geo3D"===i.type){this._sceneHelper||(this._sceneHelper=new Wc,this._sceneHelper.initLight(this.groupGL)),this._sceneHelper.setScene(i.viewGL.scene),this._sceneHelper.updateLight(t),i.viewGL.setPostEffect(t.getModel("postEffect"),r),i.viewGL.setTemporalSuperSampling(t.getModel("temporalSuperSampling"));var n=this._control;n||(n=this._control=new Nc({zr:r.getZr()}),this._control.init());var a=t.getModel("viewControl");n.setViewGL(i.viewGL),n.setFromViewControlModel(a,0),n.off("update"),n.on("update",(function(){r.dispatchAction({type:"map3DChangeCamera",alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance(),from:this.uid,map3DId:t.id})})),this._geo3DBuilder.extrudeY=!0}else this._control&&(this._control.dispose(),this._control=null),this._sceneHelper&&(this._sceneHelper.dispose(),this._sceneHelper=null),t.getData().getLayout("geo3D"),this._geo3DBuilder.extrudeY=!1;this._geo3DBuilder.update(t,e,r,0,t.getData().count());var o=i.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse((function(t){t.material&&t.material[o]("fragment","SRGB_DECODE")}))}},afterRender:function(t,e,r,i){var n=i.renderer,a=t.coordinateSystem;a&&"geo3D"===a.type&&(this._sceneHelper.updateAmbientCubemap(n,t,r),this._sceneHelper.updateSkybox(n,t,r))},dispose:function(){this.groupGL.removeAll(),this._control.dispose()}}),i.registerAction({type:"map3DChangeCamera",event:"map3dcamerachanged",update:"series:updateCamera"},(function(t,e){e.eachComponent({mainType:"series",subType:"map3D",query:t},(function(e){e.setView(t)}))})),i.extendSeriesModel({type:"series.scatterGL",dependencies:["grid","polar","geo","singleAxis"],visualStyleAccessPath:"itemStyle",getInitialData:function(){return i.helper.createList(this)},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,progressive:1e5,progressiveThreshold:1e5,large:!1,symbol:"circle",symbolSize:10,zoomScale:0,blendMode:"source-over",itemStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}}),Qg.prototype.reset=function(t,e){this._updateCamera(e.getWidth(),e.getHeight(),e.getDevicePixelRatio()),this._viewTransform=[1,0,0,1,0,0],this.updateTransform(t,e)},Qg.prototype.updateTransform=function(t,e){var r=t.coordinateSystem;r.getRoamTransform&&($o(this._viewTransform,r.getRoamTransform()),this._setCameraTransform(this._viewTransform),e.getZr().refresh())},Qg.prototype.dataToPoint=function(t,e,r){r=t.dataToPoint(e,null,r);var i=this._viewTransform;i&&Gs(r,r,i)},Qg.prototype.removeTransformInPoint=function(t){return this._viewTransform&&Gs(t,t,this._viewTransform),t},Qg.prototype.getZoom=function(){if(this._viewTransform){var t=this._viewTransform;return 1/Math.max(Math.sqrt(t[0]*t[0]+t[1]*t[1]),Math.sqrt(t[2]*t[2]+t[3]*t[3]))}return 1},Qg.prototype._setCameraTransform=function(t){var e=this.viewGL.camera;e.position.set(t[4],t[5],0),e.scale.set(Math.sqrt(t[0]*t[0]+t[1]*t[1]),Math.sqrt(t[2]*t[2]+t[3]*t[3]),1)},Qg.prototype._updateCamera=function(t,e,r){this.viewGL.setViewport(0,0,t,e,r);var i=this.viewGL.camera;i.left=i.top=0,i.bottom=e,i.right=t,i.near=0,i.far=100};const Jg=Qg;function $g(t){return"_EC_"+t}i.extendChartView({type:"scatterGL",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this.viewGL=new Kf("orthographic"),this.viewGL.add(this.groupGL),this._pointsBuilderList=[],this._currentStep=0,this._sizeScale=1,this._glViewHelper=new Jg(this.viewGL)},render:function(t,e,r){if(this.groupGL.removeAll(),this._glViewHelper.reset(t,r),t.getData().count()){var i=this._pointsBuilderList[0];i||(i=this._pointsBuilderList[0]=new Mg(!0,r)),this._pointsBuilderList.length=1,this.groupGL.add(i.rootNode),this._removeTransformInPoints(t.getData().getLayout("points")),i.update(t,e,r),this.viewGL.setPostEffect(t.getModel("postEffect"),r)}},incrementalPrepareRender:function(t,e,r){this.groupGL.removeAll(),this._glViewHelper.reset(t,r),this._currentStep=0,this.viewGL.setPostEffect(t.getModel("postEffect"),r)},incrementalRender:function(t,e,r,i){if(!(t.end<=t.start)){var n=this._pointsBuilderList[this._currentStep];n||(n=new Mg(!0,i),this._pointsBuilderList[this._currentStep]=n),this.groupGL.add(n.rootNode),this._removeTransformInPoints(e.getData().getLayout("points")),n.setSizeScale(this._sizeScale),n.update(e,r,i,t.start,t.end),i.getZr().refresh(),this._currentStep++}},updateTransform:function(t,e,r){if(t.coordinateSystem.getRoamTransform){this._glViewHelper.updateTransform(t,r);var i=this._glViewHelper.getZoom(),n=Math.max((t.get("zoomScale")||0)*(i-1)+1,0);this._sizeScale=n,this._pointsBuilderList.forEach((function(t){t.setSizeScale(n)}))}},_removeTransformInPoints:function(t){if(t)for(var e=[],r=0;r<t.length;r+=2)e[0]=t[r],e[1]=t[r+1],this._glViewHelper.removeTransformInPoint(e),t[r]=e[0],t[r+1]=e[1]},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}}),i.registerLayout({seriesType:"scatterGL",reset:function(t){var e,r=t.coordinateSystem;if(r){var i=r.dimensions,n=[];1===i.length?e=function(t,e){for(var n=new Float32Array(2*(t.end-t.start)),a=t.start;a<t.end;a++){var o=2*(a-t.start),s=e.get(i[0],a),l=r.dataToPoint(s);n[o]=l[0],n[o+1]=l[1]}e.setLayout("points",n)}:2===i.length&&(e=function(t,e){for(var a=new Float32Array(2*(t.end-t.start)),o=t.start;o<t.end;o++){var s=2*(o-t.start),l=e.get(i[0],o),h=e.get(i[1],o);n[0]=l,n[1]=h,n=r.dataToPoint(n),a[s]=n[0],a[s+1]=n[1]}e.setLayout("points",a)})}return{progress:e}}});var t_=function(){function t(t){this.type="graph",this.nodes=[],this.edges=[],this._nodesMap={},this._edgesMap={},this._directed=t||!1}return t.prototype.isDirected=function(){return this._directed},t.prototype.addNode=function(t,e){t=null==t?""+e:""+t;var r=this._nodesMap;if(!r[$g(t)]){var i=new e_(t,e);return i.hostGraph=this,this.nodes.push(i),r[$g(t)]=i,i}},t.prototype.getNodeByIndex=function(t){var e=this.data.getRawIndex(t);return this.nodes[e]},t.prototype.getNodeById=function(t){return this._nodesMap[$g(t)]},t.prototype.addEdge=function(t,e,r){var i=this._nodesMap,n=this._edgesMap;if("number"==typeof t&&(t=this.nodes[t]),"number"==typeof e&&(e=this.nodes[e]),t instanceof e_||(t=i[$g(t)]),e instanceof e_||(e=i[$g(e)]),t&&e){var a=t.id+"-"+e.id,o=new r_(t,e,r);return o.hostGraph=this,this._directed&&(t.outEdges.push(o),e.inEdges.push(o)),t.edges.push(o),t!==e&&e.edges.push(o),this.edges.push(o),n[a]=o,o}},t.prototype.getEdgeByIndex=function(t){var e=this.edgeData.getRawIndex(t);return this.edges[e]},t.prototype.getEdge=function(t,e){t instanceof e_&&(t=t.id),e instanceof e_&&(e=e.id);var r=this._edgesMap;return this._directed?r[t+"-"+e]:r[t+"-"+e]||r[e+"-"+t]},t.prototype.eachNode=function(t,e){for(var r=this.nodes,i=r.length,n=0;n<i;n++)r[n].dataIndex>=0&&t.call(e,r[n],n)},t.prototype.eachEdge=function(t,e){for(var r=this.edges,i=r.length,n=0;n<i;n++)r[n].dataIndex>=0&&r[n].node1.dataIndex>=0&&r[n].node2.dataIndex>=0&&t.call(e,r[n],n)},t.prototype.breadthFirstTraverse=function(t,e,r,i){if(e instanceof e_||(e=this._nodesMap[$g(e)]),e){for(var n="out"===r?"outEdges":"in"===r?"inEdges":"edges",a=0;a<this.nodes.length;a++)this.nodes[a].__visited=!1;if(!t.call(i,e,null))for(var o=[e];o.length;){var s=o.shift(),l=s[n];for(a=0;a<l.length;a++){var h=l[a],u=h.node1===s?h.node2:h.node1;if(!u.__visited){if(t.call(i,u,s))return;o.push(u),u.__visited=!0}}}}},t.prototype.update=function(){for(var t=this.data,e=this.edgeData,r=this.nodes,i=this.edges,n=0,a=r.length;n<a;n++)r[n].dataIndex=-1;for(n=0,a=t.count();n<a;n++)r[t.getRawIndex(n)].dataIndex=n;for(e.filterSelf((function(t){var r=i[e.getRawIndex(t)];return r.node1.dataIndex>=0&&r.node2.dataIndex>=0})),n=0,a=i.length;n<a;n++)i[n].dataIndex=-1;for(n=0,a=e.count();n<a;n++)i[e.getRawIndex(n)].dataIndex=n},t.prototype.clone=function(){for(var e=new t(this._directed),r=this.nodes,i=this.edges,n=0;n<r.length;n++)e.addNode(r[n].id,r[n].dataIndex);for(n=0;n<i.length;n++){var a=i[n];e.addEdge(a.node1.id,a.node2.id,a.dataIndex)}return e},t}(),e_=function(){function t(t,e){this.inEdges=[],this.outEdges=[],this.edges=[],this.dataIndex=-1,this.id=null==t?"":t,this.dataIndex=null==e?-1:e}return t.prototype.degree=function(){return this.edges.length},t.prototype.inDegree=function(){return this.inEdges.length},t.prototype.outDegree=function(){return this.outEdges.length},t.prototype.getModel=function(t){if(!(this.dataIndex<0))return this.hostGraph.data.getItemModel(this.dataIndex).getModel(t)},t.prototype.getAdjacentDataIndices=function(){for(var t={edge:[],node:[]},e=0;e<this.edges.length;e++){var r=this.edges[e];r.dataIndex<0||(t.edge.push(r.dataIndex),t.node.push(r.node1.dataIndex,r.node2.dataIndex))}return t},t}(),r_=function(){function t(t,e,r){this.dataIndex=-1,this.node1=t,this.node2=e,this.dataIndex=null==r?-1:r}return t.prototype.getModel=function(t){if(!(this.dataIndex<0))return this.hostGraph.edgeData.getItemModel(this.dataIndex).getModel(t)},t.prototype.getAdjacentDataIndices=function(){return{edge:[this.dataIndex],node:[this.node1.dataIndex,this.node2.dataIndex]}},t}();function i_(t,e){return{getValue:function(r){var i=this[t][e];return i.get(i.getDimension(r||"value"),this.dataIndex)},setVisual:function(r,i){this.dataIndex>=0&&this[t][e].setItemVisual(this.dataIndex,r,i)},getVisual:function(r){return this[t][e].getItemVisual(this.dataIndex,r)},setLayout:function(r,i){this.dataIndex>=0&&this[t][e].setItemLayout(this.dataIndex,r,i)},getLayout:function(){return this[t][e].getItemLayout(this.dataIndex)},getGraphicEl:function(){return this[t][e].getItemGraphicEl(this.dataIndex)},getRawIndex:function(){return this[t][e].getRawIndex(this.dataIndex)}}}Aa(e_,i_("hostGraph","data")),Aa(r_,i_("hostGraph","edgeData"));const n_=t_;var a_=wu();function o_(t,e){if(a_(this).mainData===this){var r=Ta({},a_(this).datas);r[this.dataType]=e,c_(e,r,t)}else d_(e,this.dataType,a_(this).mainData,t);return e}function s_(t,e){return t.struct&&t.struct.update(),e}function l_(t,e){return Ea(a_(e).datas,(function(r,i){r!==e&&d_(r.cloneShallow(),i,e,t)})),e}function h_(t){var e=a_(this).mainData;return null==t||null==e?e:a_(e).datas[t]}function u_(){var t=a_(this).mainData;return null==t?[{data:t}]:Da(La(a_(t).datas),(function(e){return{type:e,data:a_(t).datas[e]}}))}function c_(t,e,r){a_(t).datas={},Ea(e,(function(e,i){d_(e,i,t,r)}))}function d_(t,e,r,i){a_(r).datas[e]=t,a_(t).mainData=r,t.dataType=e,i.struct&&(t[i.structAttr]=i.struct,i.struct[i.datasAttr[e]]=t),t.getLinkedData=h_,t.getLinkedDataAll=u_}var f_=i.extendSeriesModel({type:"series.graphGL",visualStyleAccessPath:"itemStyle",hasSymbolVisual:!0,init:function(t){f_.superApply(this,"init",arguments),this.legendDataProvider=function(){return this._categoriesData},this._updateCategoriesData()},mergeOption:function(t){f_.superApply(this,"mergeOption",arguments),this._updateCategoriesData()},getFormattedLabel:function(t,e,r,i){var n=$m.getFormattedLabel(this,t,e,r,i);if(null==n){var a=this.getData(),o=a.dimensions[a.dimensions.length-1];n=a.get(o,t)}return n},getInitialData:function(t,e){var r=t.edges||t.links||[],n=t.data||t.nodes||[],a=this;if(n&&r)return function(t,e,r,n,a){for(var o=new n_(!0),s=0;s<t.length;s++)o.addNode(Sn(t[s].id,t[s].name,s),s);var l,h=[],u=[],c=0;for(s=0;s<e.length;s++){var d=e[s],f=d.source,p=d.target;o.addEdge(f,p,c)&&(u.push(d),h.push(Sn(d.id,f+" > "+p)),c++)}var m=i.helper.createDimensions(["value"],t);(l=new i.List(m,r)).initData(t);var g,_,v,y=new i.List(["value"],r);return y.initData(u,h),a&&a(l,y),_=(g={mainData:l,struct:o,structAttr:"graph",datas:{node:l,edge:y},datasAttr:{node:"data",edge:"edgeData"}}).mainData,(v=g.datas)||(v={main:_},g.datasAttr={main:"data"}),g.datas=g.mainData=null,c_(_,v,g),Ea(v,(function(t){Ea(_.TRANSFERABLE_METHODS,(function(e){t.wrapMethod(e,Pa(o_,g))}))})),_.wrapMethod("cloneShallow",Pa(l_,g)),Ea(_.CHANGABLE_METHODS,(function(t){_.wrapMethod(t,Pa(s_,g))})),function(t,e){if(!t)throw new Error(void 0)}(v[_.dataType]===_),o.update(),o}(n,r,this,0,(function(t,r){t.wrapMethod("getItemModel",(function(t){const e=a._categoriesModels[t.getShallow("category")];return e&&(e.parentModel=t.parentModel,t.parentModel=e),t}));const i=e.getModel([]).getModel;function n(t,e){const r=i.call(this,t,e);return r.resolveParentPath=o,r}function o(t){if(t&&("label"===t[0]||"label"===t[1])){const e=t.slice();return"label"===t[0]?e[0]="edgeLabel":"label"===t[1]&&(e[1]="edgeLabel"),e}return t}r.wrapMethod("getItemModel",(function(t){return t.resolveParentPath=o,t.getModel=n,t}))})).data},getGraph:function(){return this.getData().graph},getEdgeData:function(){return this.getGraph().edgeData},getCategoriesData:function(){return this._categoriesData},formatTooltip:function(t,e,r){if("edge"===r){var n=this.getData(),a=this.getDataParams(t,r),o=n.graph.getEdgeByIndex(t),s=n.getName(o.node1.dataIndex),l=n.getName(o.node2.dataIndex),h=[];return null!=s&&h.push(s),null!=l&&h.push(l),h=i.format.encodeHTML(h.join(" > ")),a.value&&(h+=" : "+i.format.encodeHTML(a.value)),h}return f_.superApply(this,"formatTooltip",arguments)},_updateCategoriesData:function(){var t=(this.option.categories||[]).map((function(t){return null!=t.value?t:Object.assign({value:0},t)})),e=new i.List(["value"],this);e.initData(t),this._categoriesData=e,this._categoriesModels=e.mapArray((function(t){return e.getItemModel(t,!0)}))},setView:function(t){null!=t.zoom&&(this.option.zoom=t.zoom),null!=t.offset&&(this.option.offset=t.offset)},setNodePosition:function(t){for(var e=0;e<t.length/2;e++){var r=t[2*e],i=t[2*e+1],n=this.getData().getRawDataItem(e);n.x=r,n.y=i}},isAnimationEnabled:function(){return f_.superCall(this,"isAnimationEnabled")&&!("force"===this.get("layout")&&this.get("force.layoutAnimation"))},defaultOption:{zlevel:10,z:2,legendHoverLink:!0,layout:"forceAtlas2",forceAtlas2:{initLayout:null,GPU:!0,steps:1,maxSteps:1e3,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,edgeWeightInfluence:1,edgeWeight:[1,4],nodeWeight:[1,4],preventOverlap:!1,gravityCenter:null},focusNodeAdjacency:!0,focusNodeAdjacencyOn:"mouseover",left:"center",top:"center",symbol:"circle",symbolSize:5,roam:!1,center:null,zoom:1,label:{show:!1,formatter:"{b}",position:"right",distance:5,textStyle:{fontSize:14}},itemStyle:{},lineStyle:{color:"#aaa",width:1,opacity:.5},emphasis:{label:{show:!0}},animation:!1}}),p_=Rc.vec2,m_=[[0,0],[1,1]],g_=Ur.extend((function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new Ur.Attribute("position","float",2,"POSITION"),normal:new Ur.Attribute("normal","float",2),offset:new Ur.Attribute("offset","float",1),color:new Ur.Attribute("color","float",4,"COLOR")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(t){var e=this.attributes;this.vertexCount!==t&&(e.position.init(t),e.color.init(t),this.useNativeLine||(e.offset.init(t),e.normal.init(t)),t>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(t){this.triangleCount!==t&&(this.indices=0===t?null:this.vertexCount>65535?new Uint32Array(3*t):new Uint16Array(3*t))},_getCubicCurveApproxStep:function(t,e,r,i){return 1/(p_.dist(t,e)+p_.dist(r,e)+p_.dist(i,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(t,e,r,i){var n=this._getCubicCurveApproxStep(t,e,r,i),a=Math.ceil(1/n);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(t,e,r,i){var n=this._getCubicCurveApproxStep(t,e,r,i),a=Math.ceil(1/n);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(m_)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(m_)},getPolylineVertexCount:function(t){var e;return e="number"==typeof t?t:"number"!=typeof t[0]?t.length:t.length/2,this.useNativeLine?2*(e-1):2*(e-1)+2},getPolylineTriangleCount:function(t){var e;return e="number"==typeof t?t:"number"!=typeof t[0]?t.length:t.length/2,this.useNativeLine?0:2*(e-1)},addCubicCurve:function(t,e,r,i,n,a){null==a&&(a=1);var o=t[0],s=t[1],l=e[0],h=e[1],u=r[0],c=r[1],d=i[0],f=i[1],p=this._getCubicCurveApproxStep(t,e,r,i),m=p*p,g=m*p,_=3*p,v=3*m,y=6*m,x=6*g,b=o-2*l+u,w=s-2*h+c,T=3*(l-u)-o+d,S=3*(h-c)-s+f,M=o,A=s,C=(l-o)*_+b*v+T*g,E=(h-s)*_+w*v+S*g,D=b*y+T*x,L=w*y+S*x,P=T*x,O=S*x,N=0,I=0,R=Math.ceil(1/p),B=new Float32Array(3*(R+1)),F=(B=[],0);for(I=0;I<R+1;I++)B[F++]=M,B[F++]=A,M+=C,A+=E,C+=D,E+=L,D+=P,L+=O,(N+=p)>1&&(M=C>0?Math.min(M,d):Math.max(M,d),A=E>0?Math.min(A,f):Math.max(A,f));this.addPolyline(B,n,a)},addLine:function(t,e,r,i){this.addPolyline([t,e],r,i)},addPolyline:function(){var t=p_.create(),e=p_.create(),r=p_.create(),i=p_.create(),n=[],a=[],o=[];return function(s,l,h,u,c){if(s.length){var d="number"!=typeof s[0];if(null==c&&(c=d?s.length:s.length/2),!(c<2)){null==u&&(u=0),null==h&&(h=1),this._itemVertexOffsets.push(this._vertexOffset);for(var f,p=d?"number"!=typeof l[0]:l.length/4===c,m=this.attributes.position,g=this.attributes.color,_=this.attributes.offset,v=this.attributes.normal,y=this.indices,x=this._vertexOffset,b=0;b<c;b++){if(d)n=s[b+u],f=p?l[b+u]:l;else{var w=2*b+u;if((n=n||[])[0]=s[w],n[1]=s[w+1],p){var T=4*b+u;(f=f||[])[0]=l[T],f[1]=l[T+1],f[2]=l[T+2],f[3]=l[T+3]}else f=l}if(this.useNativeLine)b>1&&(m.copy(x,x-1),g.copy(x,x-1),x++);else{var S;if(b<c-1)if(d?p_.copy(a,s[b+1]):(w=2*(b+1)+u,(a=a||[])[0]=s[w],a[1]=s[w+1]),b>0){p_.sub(t,n,o),p_.sub(e,a,n),p_.normalize(t,t),p_.normalize(e,e),p_.add(i,t,e),p_.normalize(i,i);var M=h/2*Math.min(1/p_.dot(t,i),2);r[0]=-i[1],r[1]=i[0],S=M}else p_.sub(t,a,n),p_.normalize(t,t),r[0]=-t[1],r[1]=t[0],S=h/2;else p_.sub(t,n,o),p_.normalize(t,t),r[0]=-t[1],r[1]=t[0],S=h/2;v.set(x,r),v.set(x+1,r),_.set(x,S),_.set(x+1,-S),p_.copy(o,n),m.set(x,n),m.set(x+1,n),g.set(x,f),g.set(x+1,f),x+=2}if(this.useNativeLine)g.set(x,f),m.set(x,n),x++;else if(b>0){var A=3*this._faceOffset;(y=this.indices)[A]=x-4,y[A+1]=x-3,y[A+2]=x-2,y[A+3]=x-3,y[A+4]=x-1,y[A+5]=x-2,this._faceOffset+=2}}this._vertexOffset=x}}}}(),setItemColor:function(t,e){for(var r=this._itemVertexOffsets[t],i=t<this._itemVertexOffsets.length-1?this._itemVertexOffsets[t+1]:this._vertexOffset,n=r;n<i;n++)this.attributes.color.set(n,e);this.dirty("color")}});i.util.defaults(g_.prototype,Ic);const __=g_;mo.Shader.import("@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end");var v_={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};function y_(t){var e={type:mo.Texture.FLOAT,minFilter:mo.Texture.NEAREST,magFilter:mo.Texture.NEAREST};this._positionSourceTex=new mo.Texture2D(e),this._positionSourceTex.flipY=!1,this._positionTex=new mo.Texture2D(e),this._positionPrevTex=new mo.Texture2D(e),this._forceTex=new mo.Texture2D(e),this._forcePrevTex=new mo.Texture2D(e),this._weightedSumTex=new mo.Texture2D(e),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new mo.Texture2D(e),this._globalSpeedPrevTex=new mo.Texture2D(e),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new fn({fragment:mo.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new fn({fragment:mo.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new fn({fragment:mo.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new fn({fragment:mo.Shader.source("clay.compositor.output")});var r=function(t){t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ONE)};this._edgeForceMesh=new mo.Mesh({geometry:new mo.Geometry({attributes:{node1:new mo.Geometry.Attribute("node1","float",2),node2:new mo.Geometry.Attribute("node2","float",2),weight:new mo.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new mo.Material({transparent:!0,shader:mo.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:r,depthMask:!1,depthText:!1}),mode:mo.Mesh.POINTS}),this._weightedSumMesh=new mo.Mesh({geometry:new mo.Geometry({attributes:{node:new mo.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new mo.Material({transparent:!0,shader:mo.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:r,depthMask:!1,depthText:!1}),mode:mo.Mesh.POINTS}),this._framebuffer=new Fi({depthBuffer:!1}),this._dummyCamera=new mo.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}y_.prototype.updateOption=function(t){for(var e in v_)this[e]=v_[e];var r=this._nodes.length;if(this.jitterTolerence=r>5e4?10:r>5e3?1:.1,this.scaling=r>100?2:10,t)for(var e in v_)null!=t[e]&&(this[e]=t[e]);if(this.repulsionByDegree)for(var i=this._positionSourceTex.pixels,n=0;n<this._nodes.length;n++)i[4*n+2]=(this._nodes[n].degree||0)+1},y_.prototype._updateGravityCenter=function(t){var e=this._nodes,r=this._edges;if(this.gravityCenter)this._gravityCenter=this.gravityCenter;else{for(var i=[1/0,1/0],n=[-1/0,-1/0],a=0;a<e.length;a++)i[0]=Math.min(e[a].x,i[0]),i[1]=Math.min(e[a].y,i[1]),n[0]=Math.max(e[a].x,n[0]),n[1]=Math.max(e[a].y,n[1]);this._gravityCenter=[.5*(i[0]+n[0]),.5*(i[1]+n[1])]}for(a=0;a<r.length;a++){var o=r[a].node1,s=r[a].node2;e[o].degree=(e[o].degree||0)+1,e[s].degree=(e[s].degree||0)+1}},y_.prototype.initData=function(t,e){this._nodes=t,this._edges=e,this._updateGravityCenter();var r=Math.ceil(Math.sqrt(t.length)),i=r,n=new Float32Array(r*i*4);this._resize(r,i);for(var a=0,o=0;o<t.length;o++){var s=t[o];n[a++]=s.x||0,n[a++]=s.y||0,n[a++]=s.mass||1,n[a++]=s.size||1}this._positionSourceTex.pixels=n;var l=this._edgeForceMesh.geometry,h=e.length;l.attributes.node1.init(2*h),l.attributes.node2.init(2*h),l.attributes.weight.init(2*h);var u=[];for(o=0;o<e.length;o++){var c=l.attributes,d=e[o].weight;null==d&&(d=1),c.node1.set(o,this.getNodeUV(e[o].node1,u)),c.node2.set(o,this.getNodeUV(e[o].node2,u)),c.weight.set(o,d),c.node1.set(o+h,this.getNodeUV(e[o].node2,u)),c.node2.set(o+h,this.getNodeUV(e[o].node1,u)),c.weight.set(o+h,d)}var f=this._weightedSumMesh.geometry;for(f.attributes.node.init(t.length),o=0;o<t.length;o++)f.attributes.node.set(o,this.getNodeUV(o,u));l.dirty(),f.dirty(),this._nodeRepulsionPass.material.define("fragment","NODE_COUNT",t.length),this._nodeRepulsionPass.material.setUniform("textureSize",[r,i]),this._inited=!1,this._frame=0},y_.prototype.getNodes=function(){return this._nodes},y_.prototype.getEdges=function(){return this._edges},y_.prototype.step=function(t){this._inited||(this._initFromSource(t),this._inited=!0),this._frame++,this._framebuffer.attach(this._forceTex),this._framebuffer.bind(t);var e=this._nodeRepulsionPass;e.setUniform("strongGravityMode",this.strongGravityMode),e.setUniform("gravity",this.gravity),e.setUniform("gravityCenter",this._gravityCenter),e.setUniform("scaling",this.scaling),e.setUniform("preventOverlap",this.preventOverlap),e.setUniform("positionTex",this._positionPrevTex),e.render(t);var r=this._edgeForceMesh;r.material.set("linLogMode",this.linLogMode),r.material.set("edgeWeightInfluence",this.edgeWeightInfluence),r.material.set("preventOverlap",this.preventOverlap),r.material.set("positionTex",this._positionPrevTex),t.gl.enable(t.gl.BLEND),t.renderPass([r],this._dummyCamera),this._framebuffer.attach(this._weightedSumTex),t.gl.clearColor(0,0,0,0),t.gl.clear(t.gl.COLOR_BUFFER_BIT),t.gl.enable(t.gl.BLEND);var i=this._weightedSumMesh;i.material.set("positionTex",this._positionPrevTex),i.material.set("forceTex",this._forceTex),i.material.set("forcePrevTex",this._forcePrevTex),t.renderPass([i],this._dummyCamera),this._framebuffer.attach(this._globalSpeedTex);var n=this._globalSpeedPass;n.setUniform("globalSpeedPrevTex",this._globalSpeedPrevTex),n.setUniform("weightedSumTex",this._weightedSumTex),n.setUniform("jitterTolerence",this.jitterTolerence),t.gl.disable(t.gl.BLEND),n.render(t);var a=this._positionPass;this._framebuffer.attach(this._positionTex),a.setUniform("globalSpeedTex",this._globalSpeedTex),a.setUniform("positionTex",this._positionPrevTex),a.setUniform("forceTex",this._forceTex),a.setUniform("forcePrevTex",this._forcePrevTex),a.render(t),this._framebuffer.unbind(t),this._swapTexture()},y_.prototype.update=function(t,e,r){null==e&&(e=1),e=Math.max(e,1);for(var i=0;i<e;i++)this.step(t);r&&r()},y_.prototype.getNodePositionTexture=function(){return this._inited?this._positionPrevTex:this._positionSourceTex},y_.prototype.getNodeUV=function(t,e){e=e||[];var r=this._positionTex.width,i=this._positionTex.height;return e[0]=t%r/(r-1),e[1]=Math.floor(t/r)/(i-1)||0,e},y_.prototype.getNodePosition=function(t,e){var r=this._positionArr,i=this._positionTex.width,n=this._positionTex.height,a=i*n;r&&r.length===4*a||(r=this._positionArr=new Float32Array(4*a)),this._framebuffer.bind(t),this._framebuffer.attach(this._positionPrevTex),t.gl.readPixels(0,0,i,n,t.gl.RGBA,t.gl.FLOAT,r),this._framebuffer.unbind(t),e||(e=new Float32Array(2*this._nodes.length));for(var o=0;o<this._nodes.length;o++)e[2*o]=r[4*o],e[2*o+1]=r[4*o+1];return e},y_.prototype.getTextureData=function(t,e){var r=this["_"+e+"Tex"],i=r.width,n=r.height;this._framebuffer.bind(t),this._framebuffer.attach(r);var a=new Float32Array(i*n*4);return t.gl.readPixels(0,0,i,n,t.gl.RGBA,t.gl.FLOAT,a),this._framebuffer.unbind(t),a},y_.prototype.getTextureSize=function(){return{width:this._positionTex.width,height:this._positionTex.height}},y_.prototype.isFinished=function(t){return this._frame>t},y_.prototype._swapTexture=function(){var t=this._positionPrevTex;this._positionPrevTex=this._positionTex,this._positionTex=t,t=this._forcePrevTex,this._forcePrevTex=this._forceTex,this._forceTex=t,t=this._globalSpeedPrevTex,this._globalSpeedPrevTex=this._globalSpeedTex,this._globalSpeedTex=t},y_.prototype._initFromSource=function(t){this._framebuffer.attach(this._positionPrevTex),this._framebuffer.bind(t),this._copyPass.setUniform("texture",this._positionSourceTex),this._copyPass.render(t),t.gl.clearColor(0,0,0,0),this._framebuffer.attach(this._forcePrevTex),t.gl.clear(t.gl.COLOR_BUFFER_BIT),this._framebuffer.attach(this._globalSpeedPrevTex),t.gl.clear(t.gl.COLOR_BUFFER_BIT),this._framebuffer.unbind(t)},y_.prototype._resize=function(t,e){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach((function(r){this[r].width=t,this[r].height=e,this[r].dirty()}),this)},y_.prototype.dispose=function(t){this._framebuffer.dispose(t),this._copyPass.dispose(t),this._nodeRepulsionPass.dispose(t),this._positionPass.dispose(t),this._globalSpeedPass.dispose(t),this._edgeForceMesh.geometry.dispose(t),this._weightedSumMesh.geometry.dispose(t),this._positionSourceTex.dispose(t),this._positionTex.dispose(t),this._positionPrevTex.dispose(t),this._forceTex.dispose(t),this._forcePrevTex.dispose(t),this._weightedSumTex.dispose(t),this._globalSpeedTex.dispose(t),this._globalSpeedPrevTex.dispose(t)};const x_=y_;var b_=function(){var t=function(){return new Float32Array(2)},e=function(t,e){var r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)},r=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},i=function(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t},n=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},a=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},o=function(t,e){return t[0]=e[0],t[1]=e[1],t},s=function(t,e,r){return t[0]=e,t[1]=r,t};function l(){this.subRegions=[],this.nSubRegions=0,this.node=null,this.mass=0,this.centerOfMass=null,this.bbox=new Float32Array(4),this.size=0}var h=l.prototype;function u(){this.position=new Float32Array(2),this.force=t(),this.forcePrev=t(),this.mass=1,this.inDegree=0,this.outDegree=0}function c(t,e){this.source=t,this.target=e,this.weight=1}function d(){this.autoSettings=!0,this.barnesHutOptimize=!0,this.barnesHutTheta=1.5,this.repulsionByDegree=!0,this.linLogMode=!1,this.strongGravityMode=!1,this.gravity=1,this.scaling=1,this.edgeWeightInfluence=1,this.jitterTolerence=.1,this.preventOverlap=!1,this.dissuadeHubs=!1,this.rootRegion=new l,this.rootRegion.centerOfMass=t(),this.nodes=[],this.edges=[],this.bbox=new Float32Array(4),this.gravityCenter=null,this._massArr=null,this._swingingArr=null,this._sizeArr=null,this._globalSpeed=0}h.beforeUpdate=function(){for(var t=0;t<this.nSubRegions;t++)this.subRegions[t].beforeUpdate();this.mass=0,this.centerOfMass&&(this.centerOfMass[0]=0,this.centerOfMass[1]=0),this.nSubRegions=0,this.node=null},h.afterUpdate=function(){this.subRegions.length=this.nSubRegions;for(var t=0;t<this.nSubRegions;t++)this.subRegions[t].afterUpdate()},h.addNode=function(t){if(0===this.nSubRegions){if(null==this.node)return void(this.node=t);this._addNodeToSubRegion(this.node),this.node=null}this._addNodeToSubRegion(t),this._updateCenterOfMass(t)},h.findSubRegion=function(t,e){for(var r=0;r<this.nSubRegions;r++){var i=this.subRegions[r];if(i.contain(t,e))return i}},h.contain=function(t,e){return this.bbox[0]<=t&&this.bbox[2]>=t&&this.bbox[1]<=e&&this.bbox[3]>=e},h.setBBox=function(t,e,r,i){this.bbox[0]=t,this.bbox[1]=e,this.bbox[2]=r,this.bbox[3]=i,this.size=(r-t+i-e)/2},h._newSubRegion=function(){var t=this.subRegions[this.nSubRegions];return t||(t=new l,this.subRegions[this.nSubRegions]=t),this.nSubRegions++,t},h._addNodeToSubRegion=function(t){var e=this.findSubRegion(t.position[0],t.position[1]),r=this.bbox;if(!e){var i=(r[0]+r[2])/2,n=(r[1]+r[3])/2,a=(r[2]-r[0])/2,o=(r[3]-r[1])/2,s=t.position[0]>=i?1:0,l=t.position[1]>=n?1:0;(e=this._newSubRegion()).setBBox(s*a+r[0],l*o+r[1],(s+1)*a+r[0],(l+1)*o+r[1])}e.addNode(t)},h._updateCenterOfMass=function(t){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var e=this.centerOfMass[0]*this.mass,r=this.centerOfMass[1]*this.mass;e+=t.position[0]*t.mass,r+=t.position[1]*t.mass,this.mass+=t.mass,this.centerOfMass[0]=e/this.mass,this.centerOfMass[1]=r/this.mass};var f=d.prototype;f.initNodes=function(t,e,r){var i=e.length;this.nodes.length=0;for(var n=void 0!==r,a=0;a<i;a++){var o=new u;o.position[0]=t[2*a],o.position[1]=t[2*a+1],o.mass=e[a],n&&(o.size=r[a]),this.nodes.push(o)}this._massArr=e,this._swingingArr=new Float32Array(i),n&&(this._sizeArr=r)},f.initEdges=function(t,e){var r=t.length/2;this.edges.length=0;for(var i=0;i<r;i++){var n=t[2*i],a=t[2*i+1],o=this.nodes[n],s=this.nodes[a];if(!o||!s)return void console.error("Node not exists, try initNodes before initEdges");o.outDegree++,s.inDegree++;var l=new c(o,s);e&&(l.weight=e[i]),this.edges.push(l)}},f.updateSettings=function(){if(this.repulsionByDegree)for(var t=0;t<this.nodes.length;t++)(e=this.nodes[t]).mass=e.inDegree+e.outDegree+1;else for(t=0;t<this.nodes.length;t++){var e;(e=this.nodes[t]).mass=this._massArr[t]}},f.update=function(){var a=this.nodes.length;if(this.updateSettings(),this.updateBBox(),this.barnesHutOptimize){this.rootRegion.setBBox(this.bbox[0],this.bbox[1],this.bbox[2],this.bbox[3]),this.rootRegion.beforeUpdate();for(var l=0;l<a;l++)this.rootRegion.addNode(this.nodes[l]);this.rootRegion.afterUpdate()}for(l=0;l<a;l++){var h=this.nodes[l];o(h.forcePrev,h.force),s(h.force,0,0)}for(l=0;l<a;l++){var u=this.nodes[l];if(this.barnesHutOptimize)this.applyRegionToNodeRepulsion(this.rootRegion,u);else for(var c=l+1;c<a;c++){var d=this.nodes[c];this.applyNodeToNodeRepulsion(u,d,!1)}this.gravity>0&&(this.strongGravityMode?this.applyNodeStrongGravity(u):this.applyNodeGravity(u))}for(l=0;l<this.edges.length;l++)this.applyEdgeAttraction(this.edges[l]);var f=0,p=0,m=t();for(l=0;l<a;l++)h=this.nodes[l],f+=(_=e(h.force,h.forcePrev))*h.mass,n(m,h.force,h.forcePrev),p+=.5*r(m)*h.mass,this._swingingArr[l]=_;var g=this.jitterTolerence*this.jitterTolerence*p/f;for(this._globalSpeed>0&&(g=Math.min(g/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=g,l=0;l<a;l++){h=this.nodes[l];var _=this._swingingArr[l],v=.1*g/(1+g*Math.sqrt(_)),y=r(h.force);y>0&&(v=Math.min(y*v,10)/y,i(h.position,h.position,h.force,v))}},f.applyRegionToNodeRepulsion=function(){var e=t();return function(t,r){if(t.node)this.applyNodeToNodeRepulsion(t.node,r,!0);else{a(e,r.position,t.centerOfMass);var n=e[0]*e[0]+e[1]*e[1];if(n>this.barnesHutTheta*t.size*t.size){var o=this.scaling*r.mass*t.mass/n;i(r.force,r.force,e,o)}else for(var s=0;s<t.nSubRegions;s++)this.applyRegionToNodeRepulsion(t.subRegions[s],r)}}}(),f.applyNodeToNodeRepulsion=function(){var e=t();return function(t,r,n){if(t!=r){a(e,t.position,r.position);var o=e[0]*e[0]+e[1]*e[1];if(0!==o){var s;if(this.preventOverlap){var l=Math.sqrt(o);if((l=l-t.size-r.size)>0)s=this.scaling*t.mass*r.mass/(l*l);else{if(!(l<0))return;s=100*this.scaling*t.mass*r.mass}}else s=this.scaling*t.mass*r.mass/o;i(t.force,t.force,e,s),i(r.force,r.force,e,-s)}}}}(),f.applyEdgeAttraction=function(){var e=t();return function(t){var n=t.source,o=t.target;a(e,n.position,o.position);var s,l,h=r(e);s=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?t.weight:Math.pow(t.weight,this.edgeWeightInfluence),this.preventOverlap&&(h=h-n.size-o.size)<=0||(l=this.linLogMode?-s*Math.log(h+1)/(h+1):-s,i(n.force,n.force,e,l),i(o.force,o.force,e,-l))}}(),f.applyNodeGravity=function(){var e=t();return function(t){a(e,this.gravityCenter,t.position);var n=r(e);i(t.force,t.force,e,this.gravity*t.mass/(n+1))}}(),f.applyNodeStrongGravity=function(){var e=t();return function(t){a(e,this.gravityCenter,t.position),i(t.force,t.force,e,this.gravity*t.mass)}}(),f.updateBBox=function(){for(var t=1/0,e=1/0,r=-1/0,i=-1/0,n=0;n<this.nodes.length;n++){var a=this.nodes[n].position;t=Math.min(t,a[0]),e=Math.min(e,a[1]),r=Math.max(r,a[0]),i=Math.max(i,a[1])}this.bbox[0]=t,this.bbox[1]=e,this.bbox[2]=r,this.bbox[3]=i},f.getGlobalSpeed=function(){return this._globalSpeed};var p=null;self.onmessage=function(t){switch(t.data.cmd){case"init":(p=new d).initNodes(t.data.nodesPosition,t.data.nodesMass,t.data.nodesSize),p.initEdges(t.data.edges,t.data.edgesWeight);break;case"updateConfig":if(p)for(var e in t.data.config)p[e]=t.data.config[e];break;case"update":var r=t.data.steps;if(p){for(var i=0;i<r;i++)p.update();var n=p.nodes.length,a=new Float32Array(2*n);for(i=0;i<n;i++){var o=p.nodes[i];a[2*i]=o.position[0],a[2*i+1]=o.position[1]}self.postMessage({buffer:a.buffer,globalSpeed:p.getGlobalSpeed()},[a.buffer])}else{var s=new Float32Array;self.postMessage({buffer:s.buffer,globalSpeed:p.getGlobalSpeed()},[s.buffer])}}}}.toString();b_=b_.slice(b_.indexOf("{")+1,b_.lastIndexOf("}"));var w_={barnesHutOptimize:!0,barnesHutTheta:1.5,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null},T_=function(t){for(var e in w_)this[e]=w_[e];if(t)for(var e in t)this[e]=t[e];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new Er({type:br.FLOAT,flipY:!1,minFilter:br.NEAREST,magFilter:br.NEAREST})};T_.prototype.initData=function(t,e){var r=new Blob([b_]),i=window.URL.createObjectURL(r);this._worker=new Worker(i),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=t,this._edges=e,this._frame=0;for(var n=t.length,a=e.length,o=new Float32Array(2*n),s=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(2*a),u=new Float32Array(a),c=0;c<t.length;c++){var d=t[c];o[2*c]=d.x,o[2*c+1]=d.y,s[c]=null==d.mass?1:d.mass,l[c]=null==d.size?1:d.size}for(c=0;c<e.length;c++){var f=e[c],p=f.node1,m=f.node2;h[2*c]=p,h[2*c+1]=m,u[c]=null==f.weight?1:f.weight}var g=Math.ceil(Math.sqrt(t.length)),_=g,v=new Float32Array(g*_*4),y=this._positionTex;y.width=g,y.height=_,y.pixels=v,this._worker.postMessage({cmd:"init",nodesPosition:o,nodesMass:s,nodesSize:l,edges:h,edgesWeight:u}),this._globalSpeed=1/0},T_.prototype.updateOption=function(t){var e={};for(var r in w_)e[r]=w_[r];var i=this._nodes,n=this._edges,a=i.length;if(e.jitterTolerence=a>5e4?10:a>5e3?1:.1,e.scaling=a>100?2:10,e.barnesHutOptimize=a>1e3,t)for(var r in w_)null!=t[r]&&(e[r]=t[r]);if(!e.gravityCenter){for(var o=[1/0,1/0],s=[-1/0,-1/0],l=0;l<i.length;l++)o[0]=Math.min(i[l].x,o[0]),o[1]=Math.min(i[l].y,o[1]),s[0]=Math.max(i[l].x,s[0]),s[1]=Math.max(i[l].y,s[1]);e.gravityCenter=[.5*(o[0]+s[0]),.5*(o[1]+s[1])]}for(l=0;l<n.length;l++){var h=n[l].node1,u=n[l].node2;i[h].degree=(i[h].degree||0)+1,i[u].degree=(i[u].degree||0)+1}this._worker&&this._worker.postMessage({cmd:"updateConfig",config:e})},T_.prototype.update=function(t,e,r){null==e&&(e=1),e=Math.max(e,1),this._frame+=e,this._onupdate=r,this._worker&&this._worker.postMessage({cmd:"update",steps:Math.round(e)})},T_.prototype._$onupdate=function(t){if(!this._disposed){var e=new Float32Array(t.data.buffer);this._globalSpeed=t.data.globalSpeed,this._positionArr=e,this._updateTexture(e),this._onupdate&&this._onupdate()}},T_.prototype.getNodePositionTexture=function(){return this._positionTex},T_.prototype.getNodeUV=function(t,e){e=e||[];var r=this._positionTex.width,i=this._positionTex.height;return e[0]=t%r/(r-1),e[1]=Math.floor(t/r)/(i-1),e},T_.prototype.getNodes=function(){return this._nodes},T_.prototype.getEdges=function(){return this._edges},T_.prototype.isFinished=function(t){return this._frame>t},T_.prototype.getNodePosition=function(t,e){if(e||(e=new Float32Array(2*this._nodes.length)),this._positionArr)for(var r=0;r<this._positionArr.length;r++)e[r]=this._positionArr[r];return e},T_.prototype._updateTexture=function(t){for(var e=this._positionTex.pixels,r=0,i=0;i<t.length;)e[r++]=t[i++],e[r++]=t[i++],e[r++]=1,e[r++]=1;this._positionTex.dirty()},T_.prototype.dispose=function(t){this._disposed=!0,this._worker=null};const S_=T_,M_=m.extend((function(){return{zr:null,viewGL:null,minZoom:.2,maxZoom:5,_needsUpdate:!1,_dx:0,_dy:0,_zoom:1}}),(function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._update=this._update.bind(this)}),{init:function(){var t=this.zr;t.on("mousedown",this._mouseDownHandler),t.on("mousewheel",this._mouseWheelHandler),t.on("globalout",this._mouseUpHandler),t.animation.on("frame",this._update)},setTarget:function(t){this._target=t},setZoom:function(t){this._zoom=Math.max(Math.min(t,this.maxZoom),this.minZoom),this._needsUpdate=!0},setOffset:function(t){this._dx=t[0],this._dy=t[1],this._needsUpdate=!0},getZoom:function(){return this._zoom},getOffset:function(){return[this._dx,this._dy]},_update:function(){if(this._target&&this._needsUpdate){var t=this._target,e=this._zoom;t.position.x=this._dx,t.position.y=this._dy,t.scale.set(e,e,e),this.zr.refresh(),this._needsUpdate=!1,this.trigger("update")}},_mouseDownHandler:function(t){if(!t.target){var e=t.offsetX,r=t.offsetY;if(!this.viewGL||this.viewGL.containPoint(e,r)){this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler);var i=this._convertPos(e,r);this._x=i.x,this._y=i.y}}},_convertPos:function(t,e){var r=this.viewGL.camera,i=this.viewGL.viewport;return{x:(t-i.x)/i.width*(r.right-r.left)+r.left,y:(e-i.y)/i.height*(r.bottom-r.top)+r.top}},_mouseMoveHandler:function(t){var e=this._convertPos(t.offsetX,t.offsetY);this._dx+=e.x-this._x,this._dy+=e.y-this._y,this._x=e.x,this._y=e.y,this._needsUpdate=!0},_mouseUpHandler:function(t){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_mouseWheelHandler:function(t){var e=(t=t.event).wheelDelta||-t.detail;if(0!==e){var r=t.offsetX,i=t.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,i)){var n=e>0?1.1:.9,a=Math.max(Math.min(this._zoom*n,this.maxZoom),this.minZoom);n=a/this._zoom;var o=this._convertPos(r,i),s=(o.x-this._dx)*(n-1),l=(o.y-this._dy)*(n-1);this._dx-=s,this._dy-=l,this._zoom=a,this._needsUpdate=!0}}},dispose:function(){var t=this.zr;t.off("mousedown",this._mouseDownHandler),t.off("mousemove",this._mouseMoveHandler),t.off("mouseup",this._mouseUpHandler),t.off("mousewheel",this._mouseWheelHandler),t.off("globalout",this._mouseUpHandler),t.animation.off("frame",this._update)}});var A_=Rc.vec2;mo.Shader.import("@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end");var C_,E_=1;function D_(t){return t instanceof Array||(t=[t,t]),t}function L_(){}i.extendChartView({type:"graphGL",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this.viewGL=new Kf("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new Mg(!0,e),this._forceEdgesMesh=new mo.Mesh({material:new mo.Material({shader:mo.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new mo.Geometry({attributes:{node:new mo.Geometry.Attribute("node","float",2),color:new mo.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:mo.Mesh.LINES}),this._edgesMesh=new mo.Mesh({material:new mo.Material({shader:mo.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new __({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new M_({zr:e.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(t,e,r){this.groupGL.add(this._pointsBuilder.rootNode),this._model=t,this._api=r,this._initLayout(t,e,r),this._pointsBuilder.update(t,e,r),this._forceLayoutInstance instanceof x_||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(t,r),this._control.off("update"),this._control.on("update",(function(){r.dispatchAction({type:"graphGLRoam",seriesId:t.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)}),this),this._control.setZoom(Sn(t.get("zoom"),1)),this._control.setOffset(t.get("offset")||[0,0]);var i=this._pointsBuilder.getPointsMesh();if(i.off("mousemove",this._mousemoveHandler),i.off("mouseout",this._mouseOutHandler,this),r.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,t.get("focusNodeAdjacency")){var n=t.get("focusNodeAdjacencyOn");"click"===n?r.getZr().on("click",this._clickHandler):"mouseover"===n&&(i.on("mousemove",this._mousemoveHandler,this),i.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1)}this._lastMouseOverDataIndex=-1},_clickHandler:function(t){if(!this._layouting){var e=this._pointsBuilder.getPointsMesh().dataIndex;e>=0?this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:e}):this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id})}},_mousemoveHandler:function(t){if(!this._layouting){var e=this._pointsBuilder.getPointsMesh().dataIndex;e>=0?e!==this._lastMouseOverDataIndex&&this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:e}):this._mouseOutHandler(t),this._lastMouseOverDataIndex=e}},_mouseOutHandler:function(t){this._layouting||(this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id}),this._lastMouseOverDataIndex=-1)},_updateForceEdgesGeometry:function(t,e){var r=this._forceEdgesMesh.geometry,i=e.getEdgeData(),n=0,a=this._forceLayoutInstance,o=2*i.count();r.attributes.node.init(o),r.attributes.color.init(o),i.each((function(e){var o=t[e];r.attributes.node.set(n,a.getNodeUV(o.node1)),r.attributes.node.set(n+1,a.getNodeUV(o.node2));var s=Fp(i,o.dataIndex),l=mo.parseColor(s);l[3]*=Sn(zp(i,o.dataIndex),1),r.attributes.color.set(n,l),r.attributes.color.set(n+1,l),n+=2})),r.dirty()},_updateMeshLinesGeometry:function(){var t=this._model.getEdgeData(),e=this._edgesMesh.geometry,r=(t=this._model.getEdgeData(),this._model.getData().getLayout("points"));e.resetOffset(),e.setVertexCount(t.count()*e.getLineVertexCount()),e.setTriangleCount(t.count()*e.getLineTriangleCount());var i=[],n=[],a=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*t.count()),this._edgeIndicesMap=new Float32Array(t.count()),t.each((function(o){var s=t.graph.getEdgeByIndex(o),l=2*s.node1.dataIndex,h=2*s.node2.dataIndex;i[0]=r[l],i[1]=r[l+1],n[0]=r[h],n[1]=r[h+1];var u=Fp(t,s.dataIndex),c=mo.parseColor(u);c[3]*=Sn(zp(t,s.dataIndex),1);var d=t.getItemModel(s.dataIndex),f=Sn(d.get(a),1)*this._api.getDevicePixelRatio();e.addLine(i,n,c,f);for(var p=0;p<4;p++)this._originalEdgeColors[4*s.dataIndex+p]=c[p];this._edgeIndicesMap[s.dataIndex]=o}),this),e.dirty()},_updateForceNodesGeometry:function(t){for(var e=this._pointsBuilder.getPointsMesh(),r=[],i=0;i<t.count();i++)this._forceLayoutInstance.getNodeUV(i,r),e.geometry.attributes.position.set(i,r);e.geometry.dirty("position")},_initLayout:function(t,e,r){var n=t.get("layout"),a=t.getGraph(),o=kd(t.getBoxLayoutParams(),{width:r.getWidth(),height:r.getHeight()});"force"===n&&(n="forceAtlas2"),this.stopLayout(t,e,r,{beforeLayout:!0});var s=t.getData(),l=t.getData();if("forceAtlas2"===n){var h=t.getModel("forceAtlas2"),u=this._forceLayoutInstance,c=[],d=[],f=s.getDataExtent("value"),p=l.getDataExtent("value"),m=Sn(h.get("edgeWeight"),1),g=Sn(h.get("nodeWeight"),1);"number"==typeof m&&(m=[m,m]),"number"==typeof g&&(g=[g,g]);var _=0,v={},y=new Float32Array(2*s.count());if(a.eachNode((function(t){var e,r,n=t.dataIndex,a=s.get("value",n);if(s.hasItemOption){var l=s.getItemModel(n);e=l.get("x"),r=l.get("y")}null==e&&(e=o.x+Math.random()*o.width,r=o.y+Math.random()*o.height),y[2*_]=e,y[2*_+1]=r,v[t.id]=_++;var h=i.number.linearMap(a,f,g);isNaN(h)&&(h=isNaN(g[0])?1:g[0]),c.push({x:e,y:r,mass:h,size:s.getItemVisual(n,"symbolSize")})})),s.setLayout("points",y),a.eachEdge((function(t){var e=t.dataIndex,r=s.get("value",e),n=i.number.linearMap(r,p,m);isNaN(n)&&(n=isNaN(m[0])?1:m[0]),d.push({node1:v[t.node1.id],node2:v[t.node2.id],weight:n,dataIndex:e})})),!u){var x=h.get("GPU");this._forceLayoutInstance&&((!x||this._forceLayoutInstance instanceof x_)&&(x||this._forceLayoutInstance instanceof S_)||(this._forceLayoutInstanceToDispose=this._forceLayoutInstance)),u=this._forceLayoutInstance=x?new x_:new S_}u.initData(c,d),u.updateOption(h.option),this._updateForceEdgesGeometry(u.getEdges(),t),this._updatePositionTexture(),r.dispatchAction({type:"graphGLStartLayout",from:this.uid})}else y=new Float32Array(2*s.count()),_=0,a.eachNode((function(t){var e,r,i=t.dataIndex;if(s.hasItemOption){var n=s.getItemModel(i);e=n.get("x"),r=n.get("y")}y[_++]=e,y[_++]=r})),s.setLayout("points",y),this._updateAfterLayout(t,e,r)},_updatePositionTexture:function(){var t=this._forceLayoutInstance.getNodePositionTexture();this._pointsBuilder.setPositionTexture(t),this._forceEdgesMesh.material.set("positionTex",t)},startLayout:function(t,e,r,i){if(!i||null==i.from||i.from===this.uid){var n=this.viewGL,a=(r=this._api,this._forceLayoutInstance),o=this._model.getData(),s=this._model.getModel("forceAtlas2");if(a&&(this.groupGL.remove(this._edgesMesh),this.groupGL.add(this._forceEdgesMesh),this._forceLayoutInstance)){this._updateForceNodesGeometry(t.getData()),this._pointsBuilder.hideLabels();var l=this,h=this._layoutId=E_++,u=s.getShallow("maxSteps"),c=s.getShallow("steps"),d=0,f=Math.max(2*c,20),p=function(e){if(e===l._layoutId)return a.isFinished(u)?(r.dispatchAction({type:"graphGLStopLayout",from:l.uid}),void r.dispatchAction({type:"graphGLFinishLayout",points:o.getLayout("points"),from:l.uid})):void a.update(n.layer.renderer,c,(function(){l._updatePositionTexture(),(d+=c)>=f&&(l._syncNodePosition(t),d=0),r.getZr().refresh(),go((function(){p(e)}))}))};go((function(){l._forceLayoutInstanceToDispose&&(l._forceLayoutInstanceToDispose.dispose(n.layer.renderer),l._forceLayoutInstanceToDispose=null),p(h)})),this._layouting=!0}}},stopLayout:function(t,e,r,i){i&&null!=i.from&&i.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(i&&i.beforeLayout||(this._syncNodePosition(t),this._updateAfterLayout(t,e,r)),this._api.getZr().refresh(),this._layouting=!1))},_syncNodePosition:function(t){var e=this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);t.getData().setLayout("points",e),t.setNodePosition(e)},_updateAfterLayout:function(t,e,r){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(t,e,r),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(t,e,r,i){var n=this._model.getData();this._downplayAll();var a=i.dataIndex,o=n.graph,s=[],l=o.getNodeByIndex(a);s.push(l),l.edges.forEach((function(t){t.dataIndex<0||(t.node1!==l&&s.push(t.node1),t.node2!==l&&s.push(t.node2))}),this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),s.forEach((function(t){this._pointsBuilder.highlight(n,t.dataIndex)}),this),this._pointsBuilder.updateLabels(s.map((function(t){return t.dataIndex})));var h=[];l.edges.forEach((function(t){t.dataIndex>=0&&(this._highlightEdge(t.dataIndex),h.push(t))}),this),this._focusNodes=s,this._focusEdges=h},unfocusNodeAdjacency:function(t,e,r,i){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(t){var e=this._model.getEdgeData().getItemModel(t),r=mo.parseColor(e.get("emphasis.lineStyle.color")||e.get("lineStyle.color")),i=Sn(e.get("emphasis.lineStyle.opacity"),e.get("lineStyle.opacity"),1);r[3]*=i,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],r)},_downplayAll:function(){this._focusNodes&&this._focusNodes.forEach((function(t){this._pointsBuilder.downplay(this._model.getData(),t.dataIndex)}),this),this._focusEdges&&this._focusEdges.forEach((function(t){this._downplayEdge(t.dataIndex)}),this)},_downplayEdge:function(t){var e=this._getColor(t,[]);this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)},_setEdgeFade:(C_=[],function(t,e){this._getColor(t,C_),C_[3]*=e,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],C_)}),_getColor:function(t,e){for(var r=0;r<4;r++)e[r]=this._originalEdgeColors[4*t+r];return e},_fadeOutEdgesAll:function(t){this._model.getData().graph.eachEdge((function(e){this._setEdgeFade(e.dataIndex,t)}),this)},_fadeInEdgesAll:function(){this._fadeOutEdgesAll(1)},_updateCamera:function(t,e){this.viewGL.setViewport(0,0,e.getWidth(),e.getHeight(),e.getDevicePixelRatio());for(var r=this.viewGL.camera,i=t.getData().getLayout("points"),n=A_.create(1/0,1/0),a=A_.create(-1/0,-1/0),o=[],s=0;s<i.length;)o[0]=i[s++],o[1]=i[s++],A_.min(n,n,o),A_.max(a,a,o);var l=(a[1]+n[1])/2,h=(a[0]+n[0])/2;if(!(h>r.left&&h<r.right&&l<r.bottom&&l>r.top)){var u=Math.max(a[0]-n[0],10),c=u/e.getWidth()*e.getHeight();u*=1.4,c*=1.4,n[0]-=.2*u,r.left=n[0],r.top=l-c/2,r.bottom=l+c/2,r.right=u+n[0],r.near=0,r.far=100}},dispose:function(){var t=this.viewGL.layer.renderer;this._forceLayoutInstance&&this._forceLayoutInstance.dispose(t),this.groupGL.removeAll(),this._layoutId=-1},remove:function(){this.groupGL.removeAll(),this._control.dispose()}}),i.registerVisual((function(t){const e={};t.eachSeriesByType("graphGL",(function(t){var r=t.getCategoriesData(),n=t.getData(),a={};r.each((function(i){var n=r.getName(i);a["ec-"+n]=i;var o=r.getItemModel(i),s=o.getModel("itemStyle").getItemStyle();s.fill||(s.fill=t.getColorFromPalette(n,e)),r.setItemVisual(i,"style",s);var l=["symbol","symbolSize","symbolKeepAspect"];for(let t=0;t<l.length;t++){var h=o.getShallow(l[t],!0);null!=h&&r.setItemVisual(i,l[t],h)}})),r.count()&&n.each((function(t){let e=n.getItemModel(t).getShallow("category");if(null!=e){"string"==typeof e&&(e=a["ec-"+e]);var o=r.getItemVisual(e,"style"),s=n.ensureUniqueItemVisual(t,"style");i.util.extend(s,o);var l=["symbol","symbolSize","symbolKeepAspect"];for(let i=0;i<l.length;i++)n.setItemVisual(t,l[i],r.getItemVisual(e,l[i]))}}))}))})),i.registerVisual((function(t){t.eachSeriesByType("graphGL",(function(t){var e=t.getGraph(),r=t.getEdgeData(),n=D_(t.get("edgeSymbol")),a=D_(t.get("edgeSymbolSize"));r.setVisual("drawType","stroke"),r.setVisual("fromSymbol",n&&n[0]),r.setVisual("toSymbol",n&&n[1]),r.setVisual("fromSymbolSize",a&&a[0]),r.setVisual("toSymbolSize",a&&a[1]),r.setVisual("style",t.getModel("lineStyle").getLineStyle()),r.each((function(t){var n=r.getItemModel(t),a=e.getEdgeByIndex(t),o=D_(n.getShallow("symbol",!0)),s=D_(n.getShallow("symbolSize",!0)),l=n.getModel("lineStyle").getLineStyle(),h=r.ensureUniqueItemVisual(t,"style");switch(i.util.extend(h,l),h.stroke){case"source":var u=a.node1.getVisual("style");h.stroke=u&&u.fill;break;case"target":u=a.node2.getVisual("style"),h.stroke=u&&u.fill}o[0]&&a.setVisual("fromSymbol",o[0]),o[1]&&a.setVisual("toSymbol",o[1]),s[0]&&a.setVisual("fromSymbolSize",s[0]),s[1]&&a.setVisual("toSymbolSize",s[1])}))}))})),i.registerAction({type:"graphGLRoam",event:"graphglroam",update:"series.graphGL:roam"},(function(t,e){e.eachComponent({mainType:"series",query:t},(function(e){e.setView(t)}))})),i.registerAction({type:"graphGLStartLayout",event:"graphgllayoutstarted",update:"series.graphGL:startLayout"},L_),i.registerAction({type:"graphGLStopLayout",event:"graphgllayoutstopped",update:"series.graphGL:stopLayout"},L_),i.registerAction({type:"graphGLFocusNodeAdjacency",event:"graphGLFocusNodeAdjacency",update:"series.graphGL:focusNodeAdjacency"},L_),i.registerAction({type:"graphGLUnfocusNodeAdjacency",event:"graphGLUnfocusNodeAdjacency",update:"series.graphGL:unfocusNodeAdjacency"},L_);const P_=Ur.extend((function(){return{dynamic:!0,attributes:{position:new Ur.Attribute("position","float",3,"POSITION")}}}),{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0},setLineCount:function(t){var e=this.attributes,r=4*t,i=2*t;this.vertexCount!==r&&e.position.init(r),this.triangleCount!==i&&(this.indices=0===i?null:this.vertexCount>65535?new Uint32Array(3*i):new Uint16Array(3*i))},addLine:function(t){var e=this._vertexOffset;this.attributes.position.set(e,[t[0],t[1],1]),this.attributes.position.set(e+1,[t[0],t[1],-1]),this.attributes.position.set(e+2,[t[0],t[1],2]),this.attributes.position.set(e+3,[t[0],t[1],-2]),this.setTriangleIndices(this._faceOffset++,[e,e+1,e+2]),this.setTriangleIndices(this._faceOffset++,[e+1,e+2,e+3]),this._vertexOffset+=4}});Xt.import("@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n");var O_=function(){this.motionBlurFactor=.99,this.vectorFieldTexture=new Er({type:br.FLOAT,flipY:!1}),this.particleLife=[5,20],this._particleType="point",this._particleSize=1,this.particleColor=[1,1,1,1],this.particleSpeedScaling=1,this._thisFrameTexture=null,this._particlePass=null,this._spawnTexture=null,this._particleTexture0=null,this._particleTexture1=null,this._particlePointsMesh=null,this._surfaceFrameBuffer=null,this._elapsedTime=0,this._scene=null,this._camera=null,this._lastFrameTexture=null,this._supersampling=1,this._downsampleTextures=[],this._width=512,this._height=512,this.init()};O_.prototype={constructor:O_,init:function(){var t={type:br.FLOAT,minFilter:br.NEAREST,magFilter:br.NEAREST,useMipmap:!1};this._spawnTexture=new Er(t),this._particleTexture0=new Er(t),this._particleTexture1=new Er(t),this._frameBuffer=new Fi({depthBuffer:!1}),this._particlePass=new fn({fragment:Xt.source("ecgl.vfParticle.particle.fragment")}),this._particlePass.setUniform("velocityTexture",this.vectorFieldTexture),this._particlePass.setUniform("spawnTexture",this._spawnTexture),this._downsamplePass=new fn({fragment:Xt.source("clay.compositor.downsample")});var e=new Tr({renderOrder:10,material:new lt({shader:new Xt(Xt.source("ecgl.vfParticle.renderPoints.vertex"),Xt.source("ecgl.vfParticle.renderPoints.fragment"))}),mode:Tr.POINTS,geometry:new Ur({dynamic:!0,mainAttribute:"texcoord0"})}),r=new Tr({renderOrder:10,material:new lt({shader:new Xt(Xt.source("ecgl.vfParticle.renderLines.vertex"),Xt.source("ecgl.vfParticle.renderLines.fragment"))}),geometry:new P_,culling:!1}),i=new Tr({material:new lt({shader:new Xt(Xt.source("ecgl.color.vertex"),Xt.source("ecgl.color.fragment"))}),geometry:new Gi});i.material.enableTexture("diffuseMap"),this._particlePointsMesh=e,this._particleLinesMesh=r,this._lastFrameFullQuadMesh=i,this._camera=new hn,this._thisFrameTexture=new Er,this._lastFrameTexture=new Er},setParticleDensity:function(t,e){for(var r=new Float32Array(t*e*4),i=0,n=this.particleLife,a=0;a<t;a++)for(var o=0;o<e;o++,i++){r[4*i]=Math.random(),r[4*i+1]=Math.random(),r[4*i+2]=Math.random();var s=(n[1]-n[0])*Math.random()+n[0];r[4*i+3]=s}"line"===this._particleType?this._setLineGeometry(t,e):this._setPointsGeometry(t,e),this._spawnTexture.width=t,this._spawnTexture.height=e,this._spawnTexture.pixels=r,this._particleTexture0.width=this._particleTexture1.width=t,this._particleTexture0.height=this._particleTexture1.height=e,this._particlePass.setUniform("textureSize",[t,e])},_setPointsGeometry:function(t,e){var r=t*e,i=this._particlePointsMesh.geometry,n=i.attributes;n.texcoord0.init(r);for(var a=0,o=0;o<t;o++)for(var s=0;s<e;s++,a++)n.texcoord0.value[2*a]=o/t,n.texcoord0.value[2*a+1]=s/e;i.dirty()},_setLineGeometry:function(t,e){var r=t*e,i=this._getParticleMesh().geometry;i.setLineCount(r),i.resetOffset();for(var n=0;n<t;n++)for(var a=0;a<e;a++)i.addLine([n/t,a/e]);i.dirty()},_getParticleMesh:function(){return"line"===this._particleType?this._particleLinesMesh:this._particlePointsMesh},update:function(t,e,r,i){var n=this._getParticleMesh(),a=this._frameBuffer,o=this._particlePass;i&&this._updateDownsampleTextures(t,e),n.material.set("size",this._particleSize*this._supersampling),n.material.set("color",this.particleColor),o.setUniform("speedScaling",this.particleSpeedScaling),a.attach(this._particleTexture1),o.setUniform("firstFrameTime",i?(this.particleLife[1]+this.particleLife[0])/2:0),o.setUniform("particleTexture",this._particleTexture0),o.setUniform("deltaTime",r),o.setUniform("elapsedTime",this._elapsedTime),o.render(t,a),n.material.set("particleTexture",this._particleTexture1),n.material.set("prevParticleTexture",this._particleTexture0),a.attach(this._thisFrameTexture),a.bind(t),t.gl.clear(t.gl.DEPTH_BUFFER_BIT|t.gl.COLOR_BUFFER_BIT);var s=this._lastFrameFullQuadMesh;s.material.set("diffuseMap",this._lastFrameTexture),s.material.set("color",[1,1,1,this.motionBlurFactor]),this._camera.update(!0),t.renderPass([s,n],this._camera),a.unbind(t),this._downsample(t),this._swapTexture(),this._elapsedTime+=r},_downsample:function(t){var e=this._downsampleTextures;if(0!==e.length)for(var r=0,i=this._thisFrameTexture,n=e[r];n;)this._frameBuffer.attach(n),this._downsamplePass.setUniform("texture",i),this._downsamplePass.setUniform("textureSize",[i.width,i.height]),this._downsamplePass.render(t,this._frameBuffer),i=n,n=e[++r]},getSurfaceTexture:function(){var t=this._downsampleTextures;return t.length>0?t[t.length-1]:this._lastFrameTexture},setRegion:function(t){this._particlePass.setUniform("region",t)},resize:function(t,e){this._lastFrameTexture.width=t*this._supersampling,this._lastFrameTexture.height=e*this._supersampling,this._thisFrameTexture.width=t*this._supersampling,this._thisFrameTexture.height=e*this._supersampling,this._width=t,this._height=e},setParticleSize:function(t){var e=this._getParticleMesh();if(t<=2)return e.material.disableTexture("spriteTexture"),void(e.material.transparent=!1);this._spriteTexture||(this._spriteTexture=new Er),this._spriteTexture.image&&this._spriteTexture.image.width===t||(this._spriteTexture.image=function(t){var e=document.createElement("canvas");e.width=e.height=t;var r=e.getContext("2d");return r.fillStyle="#fff",r.arc(t/2,t/2,t/2,0,2*Math.PI),r.fill(),e}(t),this._spriteTexture.dirty()),e.material.transparent=!0,e.material.enableTexture("spriteTexture"),e.material.set("spriteTexture",this._spriteTexture),this._particleSize=t},setGradientTexture:function(t){var e=this._getParticleMesh().material;e[t?"enableTexture":"disableTexture"]("gradientTexture"),e.setUniform("gradientTexture",t)},setColorTextureImage:function(t,e){this._getParticleMesh().material.setTextureImage("colorTexture",t,e,{flipY:!0})},setParticleType:function(t){this._particleType=t},clearFrame:function(t){var e=this._frameBuffer;e.attach(this._lastFrameTexture),e.bind(t),t.gl.clear(t.gl.DEPTH_BUFFER_BIT|t.gl.COLOR_BUFFER_BIT),e.unbind(t)},setSupersampling:function(t){this._supersampling=t,this.resize(this._width,this._height)},_updateDownsampleTextures:function(t,e){for(var r=this._downsampleTextures,i=Math.max(Math.floor(Math.log(this._supersampling/e.getDevicePixelRatio())/Math.log(2)),0),n=2,a=this._width*this._supersampling,o=this._height*this._supersampling,s=0;s<i;s++)r[s]=r[s]||new Er,r[s].width=a/n,r[s].height=o/n,n*=2;for(;s<r.length;s++)r[s].dispose(t);r.length=i},_swapTexture:function(){var t=this._particleTexture0;this._particleTexture0=this._particleTexture1,this._particleTexture1=t,t=this._thisFrameTexture,this._thisFrameTexture=this._lastFrameTexture,this._lastFrameTexture=t},dispose:function(t){t.disposeFrameBuffer(this._frameBuffer),t.disposeTexture(this.vectorFieldTexture),t.disposeTexture(this._spawnTexture),t.disposeTexture(this._particleTexture0),t.disposeTexture(this._particleTexture1),t.disposeTexture(this._thisFrameTexture),t.disposeTexture(this._lastFrameTexture),t.disposeGeometry(this._particleLinesMesh.geometry),t.disposeGeometry(this._particlePointsMesh.geometry),t.disposeGeometry(this._lastFrameFullQuadMesh.geometry),this._spriteTexture&&t.disposeTexture(this._spriteTexture),this._particlePass.dispose(t),this._downsamplePass.dispose(t),this._downsampleTextures.forEach((function(e){e.dispose(t)}))}};const N_=O_;i.extendChartView({type:"flowGL",__ecgl__:!0,init:function(t,e){this.viewGL=new Kf("orthographic"),this.groupGL=new mo.Node,this.viewGL.add(this.groupGL),this._particleSurface=new N_;var r=new mo.Mesh({geometry:new mo.PlaneGeometry,material:new mo.Material({shader:new mo.Shader({vertex:mo.Shader.source("ecgl.color.vertex"),fragment:mo.Shader.source("ecgl.color.fragment")}),transparent:!0})});r.material.enableTexture("diffuseMap"),this.groupGL.add(r),this._planeMesh=r},render:function(t,e,r){var i=this._particleSurface;i.setParticleType(t.get("particleType")),i.setSupersampling(t.get("supersampling")),this._updateData(t,r),this._updateCamera(r.getWidth(),r.getHeight(),r.getDevicePixelRatio());var n=Sn(t.get("particleDensity"),128);i.setParticleDensity(n,n);var a=this._planeMesh,o=+new Date,s=this,l=!0;a.__percent=0,a.stopAnimation(),a.animate("",{loop:!0}).when(1e5,{__percent:1}).during((function(){var t=+new Date,e=Math.min(t-o,20);o+=e,s._renderer&&(i.update(s._renderer,r,e/1e3,l),a.material.set("diffuseMap",i.getSurfaceTexture())),l=!1})).start();var h=t.getModel("itemStyle"),u=mo.parseColor(h.get("color"));u[3]*=Sn(h.get("opacity"),1),a.material.set("color",u),i.setColorTextureImage(t.get("colorTexture"),r),i.setParticleSize(t.get("particleSize")),i.particleSpeedScaling=t.get("particleSpeed"),i.motionBlurFactor=1-Math.pow(.1,t.get("particleTrail"))},updateTransform:function(t,e,r){this._updateData(t,r)},afterRender:function(t,e,r,i){var n=i.renderer;this._renderer=n},_updateData:function(t,e){var r=t.coordinateSystem,i=r.dimensions.map((function(e){return t.coordDimToDataDim(e)[0]})),n=t.getData(),a=n.getDataExtent(i[0]),o=n.getDataExtent(i[1]),s=t.get("gridWidth"),l=t.get("gridHeight");if(null==s||"auto"===s){var h=(a[1]-a[0])/(o[1]-o[0]);s=Math.round(Math.sqrt(h*n.count()))}null!=l&&"auto"!==l||(l=Math.ceil(n.count()/s));var u=this._particleSurface.vectorFieldTexture,c=u.pixels;if(c&&c.length===l*s*4)for(var d=0;d<c.length;d++)c[d]=0;else c=u.pixels=new Float32Array(s*l*4);var f=0,p=1/0,m=new Float32Array(2*n.count()),g=0,_=[[1/0,1/0],[-1/0,-1/0]];n.each([i[0],i[1],"vx","vy"],(function(t,e,i,n){var a=r.dataToPoint([t,e]);m[g++]=a[0],m[g++]=a[1],_[0][0]=Math.min(a[0],_[0][0]),_[0][1]=Math.min(a[1],_[0][1]),_[1][0]=Math.max(a[0],_[1][0]),_[1][1]=Math.max(a[1],_[1][1]);var o=Math.sqrt(i*i+n*n);f=Math.max(f,o),p=Math.min(p,o)})),n.each(["vx","vy"],(function(t,e,r){var i=Math.round((m[2*r]-_[0][0])/(_[1][0]-_[0][0])*(s-1)),n=4*((l-1-Math.round((m[2*r+1]-_[0][1])/(_[1][1]-_[0][1])*(l-1)))*s+i);c[n]=t/f*.5+.5,c[n+1]=e/f*.5+.5,c[n+3]=1})),u.width=s,u.height=l,"bmap"===t.get("coordinateSystem")&&this._fillEmptyPixels(u),u.dirty(),this._updatePlanePosition(_[0],_[1],t,e),this._updateGradientTexture(n.getVisual("visualMeta"),[p,f])},_fillEmptyPixels:function(t){var e=t.pixels,r=t.width,i=t.height;function n(t,n,a){t=Math.max(Math.min(t,r-1),0);var o=4*((n=Math.max(Math.min(n,i-1),0))*(r-1)+t);return 0!==e[o+3]&&(a[0]=e[o],a[1]=e[o+1],!0)}function a(t,e,r){r[0]=t[0]+e[0],r[1]=t[1]+e[1]}for(var o=[],s=[],l=[],h=[],u=[],c=0,d=0;d<i;d++)for(var f=0;f<r;f++){var p=4*(d*(r-1)+f);0===e[p+3]&&(c=o[0]=o[1]=0,n(f-1,d,s)&&(c++,a(s,o,o)),n(f+1,d,l)&&(c++,a(l,o,o)),n(f,d-1,h)&&(c++,a(h,o,o)),n(f,d+1,u)&&(c++,a(u,o,o)),o[0]/=c,o[1]/=c,e[p]=o[0],e[p+1]=o[1]),e[p+3]=1}},_updateGradientTexture:function(t,e){if(t&&t.length){this._gradientTexture=this._gradientTexture||new mo.Texture2D({image:document.createElement("canvas")});var r=this._gradientTexture,i=r.image;i.width=200,i.height=1;var n=i.getContext("2d"),a=n.createLinearGradient(0,.5,i.width,.5);t[0].stops.forEach((function(t){var r;e[1]===e[0]?r=0:(r=t.value/e[1],r=Math.min(Math.max(r,0),1)),a.addColorStop(r,t.color)})),n.fillStyle=a,n.fillRect(0,0,i.width,i.height),r.dirty(),this._particleSurface.setGradientTexture(this._gradientTexture)}else this._particleSurface.setGradientTexture(null)},_updatePlanePosition:function(t,e,r,i){var n=this._limitInViewportAndFullFill(t,e,r,i);t=n.leftTop,e=n.rightBottom,this._particleSurface.setRegion(n.region),this._planeMesh.position.set((t[0]+e[0])/2,i.getHeight()-(t[1]+e[1])/2,0);var a=e[0]-t[0],o=e[1]-t[1];this._planeMesh.scale.set(a/2,o/2,1),this._particleSurface.resize(Math.max(Math.min(a,2048),1),Math.max(Math.min(o,2048),1)),this._renderer&&this._particleSurface.clearFrame(this._renderer)},_limitInViewportAndFullFill:function(t,e,r,i){var n=[Math.max(t[0],0),Math.max(t[1],0)],a=[Math.min(e[0],i.getWidth()),Math.min(e[1],i.getHeight())];if("bmap"===r.get("coordinateSystem")){var o=r.getData().getDataExtent(r.coordDimToDataDim("lng")[0]);Math.floor(o[1]-o[0])>=359&&(n[0]>0&&(n[0]=0),a[0]<i.getWidth()&&(a[0]=i.getWidth()))}var s=e[0]-t[0],l=e[1]-t[1],h=a[0]-n[0],u=a[1]-n[1];return{leftTop:n,rightBottom:a,region:[(n[0]-t[0])/s,1-u/l-(n[1]-t[1])/l,h/s,u/l]}},_updateCamera:function(t,e,r){this.viewGL.setViewport(0,0,t,e,r);var i=this.viewGL.camera;i.left=i.bottom=0,i.top=e,i.right=t,i.near=0,i.far=100,i.position.z=10},remove:function(){this._planeMesh.stopAnimation(),this.groupGL.removeAll()},dispose:function(){this._renderer&&this._particleSurface.dispose(this._renderer),this.groupGL.removeAll()}}),i.extendSeriesModel({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualStyleAccessPath:"itemStyle",getInitialData:function(t,e){var r=i.getCoordinateSystemDimensions(this.get("coordinateSystem"))||["x","y"];r.push("vx","vy");var n=i.helper.createDimensions(r,this.getSource(),{encodeDef:this.get("encode"),dimsDef:this.get("dimensions")}),a=new i.List(n,this);return a.initData(this.getSource()),a},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,supersampling:1,particleType:"point",particleDensity:128,particleSize:1,particleSpeed:1,particleTrail:2,colorTexture:null,gridWidth:"auto",gridHeight:"auto",itemStyle:{color:"#fff",opacity:.8}}});var I_=i.extendSeriesModel({type:"series.linesGL",dependencies:["grid","geo"],visualStyleAccessPath:"lineStyle",streamEnabled:!0,init:function(t){var e=this._processFlatCoordsArray(t.data);this._flatCoords=e.flatCoords,this._flatCoordsOffset=e.flatCoordsOffset,e.flatCoords&&(t.data=new Float32Array(e.count)),I_.superApply(this,"init",arguments)},mergeOption:function(t){var e=this._processFlatCoordsArray(t.data);this._flatCoords=e.flatCoords,this._flatCoordsOffset=e.flatCoordsOffset,e.flatCoords&&(t.data=new Float32Array(e.count)),I_.superApply(this,"mergeOption",arguments)},appendData:function(t){var e=this._processFlatCoordsArray(t.data);e.flatCoords&&(this._flatCoords?(this._flatCoords=Wa(this._flatCoords,e.flatCoords),this._flatCoordsOffset=Wa(this._flatCoordsOffset,e.flatCoordsOffset)):(this._flatCoords=e.flatCoords,this._flatCoordsOffset=e.flatCoordsOffset),t.data=new Float32Array(e.count)),this.getRawData().appendData(t.data)},_getCoordsFromItemModel:function(t){var e=this.getData().getItemModel(t);return e.option instanceof Array?e.option:e.getShallow("coords")},getLineCoordsCount:function(t){return this._flatCoordsOffset?this._flatCoordsOffset[2*t+1]:this._getCoordsFromItemModel(t).length},getLineCoords:function(t,e){if(this._flatCoordsOffset){for(var r=this._flatCoordsOffset[2*t],i=this._flatCoordsOffset[2*t+1],n=0;n<i;n++)e[n]=e[n]||[],e[n][0]=this._flatCoords[r+2*n],e[n][1]=this._flatCoords[r+2*n+1];return i}var a=this._getCoordsFromItemModel(t);for(n=0;n<a.length;n++)e[n]=e[n]||[],e[n][0]=a[n][0],e[n][1]=a[n][1];return a.length},_processFlatCoordsArray:function(t){var e=0;if(this._flatCoords&&(e=this._flatCoords.length),"number"==typeof t[0]){for(var r=t.length,i=new Uint32Array(r),n=new Float64Array(r),a=0,o=0,s=0,l=0;l<r;){s++;var h=t[l++];i[o++]=a+e,i[o++]=h;for(var u=0;u<h;u++){var c=t[l++],d=t[l++];n[a++]=c,n[a++]=d}}return{flatCoordsOffset:new Uint32Array(i.buffer,0,o),flatCoords:n,count:s}}return{flatCoordsOffset:null,flatCoords:null,count:t.length}},getInitialData:function(t,e){var r=new i.List(["value"],this);return r.hasItemOption=!1,r.initData(t.data,[],(function(t,e,i,n){if(t instanceof Array)return NaN;r.hasItemOption=!0;var a=t.value;return null!=a?a instanceof Array?a[n]:a:void 0})),r},defaultOption:{coordinateSystem:"geo",zlevel:10,progressive:1e4,progressiveThreshold:5e4,blendMode:"source-over",lineStyle:{opacity:.8},postEffect:{enable:!1,colorCorrection:{exposure:0,brightness:0,contrast:1,saturation:1,enable:!0}}}});i.extendChartView({type:"linesGL",__ecgl__:!0,init:function(t,e){this.groupGL=new mo.Node,this.viewGL=new Kf("orthographic"),this.viewGL.add(this.groupGL),this._glViewHelper=new Jg(this.viewGL),this._nativeLinesShader=mo.createShader("ecgl.lines3D"),this._meshLinesShader=mo.createShader("ecgl.meshLines3D"),this._linesMeshes=[],this._currentStep=0},render:function(t,e,r){this.groupGL.removeAll(),this._glViewHelper.reset(t,r);var i=this._linesMeshes[0];i||(i=this._linesMeshes[0]=this._createLinesMesh(t)),this._linesMeshes.length=1,this.groupGL.add(i),this._updateLinesMesh(t,i,0,t.getData().count()),this.viewGL.setPostEffect(t.getModel("postEffect"),r)},incrementalPrepareRender:function(t,e,r){this.groupGL.removeAll(),this._glViewHelper.reset(t,r),this._currentStep=0,this.viewGL.setPostEffect(t.getModel("postEffect"),r)},incrementalRender:function(t,e,r,i){var n=this._linesMeshes[this._currentStep];n||(n=this._createLinesMesh(e),this._linesMeshes[this._currentStep]=n),this._updateLinesMesh(e,n,t.start,t.end),this.groupGL.add(n),i.getZr().refresh(),this._currentStep++},updateTransform:function(t,e,r){t.coordinateSystem.getRoamTransform&&this._glViewHelper.updateTransform(t,r)},_createLinesMesh:function(t){return new mo.Mesh({$ignorePicking:!0,material:new mo.Material({shader:mo.createShader("ecgl.lines3D"),transparent:!0,depthMask:!1,depthTest:!1}),geometry:new __({segmentScale:10,useNativeLine:!0,dynamic:!1}),mode:mo.Mesh.LINES,culling:!1})},_updateLinesMesh:function(t,e,r,i){var n=t.getData();e.material.blend="lighter"===t.get("blendMode")?mo.additiveBlend:null;var a=t.get("lineStyle.curveness")||0,o=t.get("polyline"),s=e.geometry,l=t.coordinateSystem,h=Sn(t.get("lineStyle.width"),1);h>1?(e.material.shader!==this._meshLinesShader&&e.material.attachShader(this._meshLinesShader),e.mode=mo.Mesh.TRIANGLES):(e.material.shader!==this._nativeLinesShader&&e.material.attachShader(this._nativeLinesShader),e.mode=mo.Mesh.LINES),r=r||0,i=i||n.count(),s.resetOffset();var u=0,c=0,d=[],f=[],p=[],m=[],g=[],_=.3,v=.7;function y(){f[0]=d[0]*v+m[0]*_-(d[1]-m[1])*a,f[1]=d[1]*v+m[1]*_-(m[0]-d[0])*a,p[0]=d[0]*_+m[0]*v-(d[1]-m[1])*a,p[1]=d[1]*_+m[1]*v-(m[0]-d[0])*a}if(o||0!==a)for(var x=r;x<i;x++)if(o){var b=t.getLineCoordsCount(x);u+=s.getPolylineVertexCount(b),c+=s.getPolylineTriangleCount(b)}else t.getLineCoords(x,g),this._glViewHelper.dataToPoint(l,g[0],d),this._glViewHelper.dataToPoint(l,g[1],m),y(),u+=s.getCubicCurveVertexCount(d,f,p,m),c+=s.getCubicCurveTriangleCount(d,f,p,m);else{var w=i-r;u+=w*s.getLineVertexCount(),c+=w*s.getLineVertexCount()}s.setVertexCount(u),s.setTriangleCount(c);var T=r,S=[];for(x=r;x<i;x++){mo.parseColor(Fp(n,T),S);var M=Sn(zp(n,T),1);S[3]*=M,b=t.getLineCoords(x,g);for(var A=0;A<b;A++)this._glViewHelper.dataToPoint(l,g[A],g[A]);o?s.addPolyline(g,S,h,0,b):0!==a?(d=g[0],m=g[1],y(),s.addCubicCurve(d,f,p,m,S,h)):s.addPolyline(g,S,h,0,2),T++}},dispose:function(){this.groupGL.removeAll()},remove:function(){this.groupGL.removeAll()}})},83:e=>{e.exports=t}},r={};function i(t){if(r[t])return r[t].exports;var n=r[t]={exports:{}};return e[t](n,n.exports,i),n.exports}return i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i(583)})()}));
|