@antv/g-webgpu 2.0.36 → 2.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-webgpu
3
3
  * @description A renderer implemented by WebGPU
4
- * @version 2.0.36
5
- * @date 11/27/2024, 2:19:26 PM
4
+ * @version 2.0.38
5
+ * @date 12/26/2024, 8:37:21 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -11,17 +11,17 @@
11
11
  * @antv/g-math
12
12
  * @description Geometry util
13
13
  * @version 3.0.0
14
- * @date 11/27/2024, 2:15:58 PM
14
+ * @date 12/26/2024, 8:33:42 AM
15
15
  * @author AntVis
16
16
  * @docs https://g.antv.antgroup.com/
17
17
  */function Qn(e,t,r,n){var i=e-r,a=t-n;return Math.sqrt(i*i+a*a)}function $n(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function Jn(e,t,r,n,i){var a=1-i;return a*a*a*e+3*t*i*a*a+3*r*i*i*a+n*i*i*i}function ei(e,t,r,n,i,a,o,s,u){if(0===u)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=Qn(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,o],[t,n,a,s]);var l=function(e,t,r,n,i,a,o,s,u){var l=Jn(e,r,i,o,u),c=Jn(t,n,a,s,u),f=$n(e,t,r,n,u),d=$n(r,n,i,a,u),h=$n(i,a,o,s,u),_=$n(f.x,f.y,d.x,d.y,u),p=$n(d.x,d.y,h.x,h.y,u);return[[e,t,f.x,f.y,_.x,_.y,l,c],[l,c,p.x,p.y,h.x,h.y,o,s]]}(e,t,r,n,i,a,o,s,.5),c=[].concat(m(l[0]),[u-1]),f=[].concat(m(l[1]),[u-1]);return ei.apply(void 0,m(c))+ei.apply(void 0,m(f))}function ti(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function ri(e,t,r,n,i,a,o){if(0===o)return(Qn(e,t,r,n)+Qn(r,n,i,a)+Qn(e,t,i,a))/2;var s=function(e,t,r,n,i,a,o){var s=ti(e,r,i,o),u=ti(t,n,a,o),l=$n(e,t,r,n,o),c=$n(r,n,i,a,o);return[[e,t,l.x,l.y,s,u],[s,u,c.x,c.y,i,a]]}(e,t,r,n,i,a,.5),u=s[0],l=s[1];return u.push(o-1),l.push(o-1),ri.apply(void 0,m(u))+ri.apply(void 0,m(l))}
18
18
  /*!
19
19
  * @antv/g-plugin-device-renderer
20
20
  * @description A G plugin of renderer implementation with GPUDevice
21
- * @version 2.2.11
22
- * @date 11/27/2024, 2:18:28 PM
21
+ * @version 2.2.13
22
+ * @date 12/26/2024, 8:36:21 AM
23
23
  * @author AntVis
24
24
  * @docs https://g.antv.antgroup.com/
25
25
  */
26
- var ni=u((function e(){l(this,e),this.drawcalls=[]}));ni.tag="c-renderable-3d";var ii=function(){return u((function e(){l(this,e),this.lights=[]}),[{key:"addLight",value:function(e){this.lights.push(e),this.sortLights()}},{key:"removeLight",value:function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()}},{key:"addFog",value:function(e){this.fog=e}},{key:"removeFog",value:function(e){this.fog=null}},{key:"getFog",value:function(){return this.fog}},{key:"getAllLights",value:function(){return this.lights}},{key:"getDefines",value:function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach((function(t){e[t.define]||(e[t.define]=0),e[t.define]++})),e}},{key:"sortLights",value:function(){this.lights.sort((function(e,t){return e.order-t.order}))}}])}(),ai=["style"],oi=function(e){function r(e){var n,i=e.style,a=g(e,ai);return l(this,r),(n=h(this,r,[o({type:t.Shape.MESH,style:o({x:"",y:"",z:"",lineWidth:0},i)},a)])).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return p(r,e),u(r,[{key:"destroy",value:function(){A(r,"destroy",this,3)([]);var e=this.style.geometry.meshes,t=e.indexOf(this);e.splice(t,1),t=(e=this.style.material.meshes).indexOf(this),e.splice(t,1)}}])}(t.DisplayObject);oi.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["x","y","z","geometry","material"]));var si=function(){return u((function e(){l(this,e)}),[{key:"update",value:function(e){var t=e.x,r=void 0===t?0:t,n=e.y,i=void 0===n?0:n,a=e.z,o=void 0===a?0:a,s=e.geometry.computeBoundingBox();return{cx:r,cy:i,cz:o,hwidth:s.halfExtents[0],hheight:s.halfExtents[1],hdepth:s.halfExtents[2]}}}])}(),ui=function(){return u((function e(){l(this,e),this.counter=0,this.id2DisplayObjectMap={}}),[{key:"getId",value:function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t}},{key:"getById",value:function(e){return this.id2DisplayObjectMap[e]}},{key:"deleteById",value:function(e){delete this.id2DisplayObjectMap[e]}},{key:"reset",value:function(){this.counter=0,this.id2DisplayObjectMap={}}},{key:"decodePickingColor",value:function(e){var t=C(e,3);return t[0]+256*t[1]+65536*t[2]-1}},{key:"encodePickingColor",value:function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]}}])}(),li=function(){return u((function e(){l(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={}}),[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(O(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0}},{key:"setDefineBool",value:function(e,t){return this.setDefineString(e,t?"1":null)}},{key:"getDefineString",value:function(e){return void 0===(t=this.defines[e])?null:t;var t}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&He("1"===t),null!==t}}])}(),ci=function(){return u((function e(t){l(this,e),this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=t;var r=t.queryLimits();this.uniformBufferWordAlignment=r.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=r.uniformBufferMaxPageWordSize}),[{key:"isSupportedUBO",value:function(){return"WebGL1"!==this.device.queryVendorInfo().platformString}},{key:"findPageIndex",value:function(e){return e/this.uniformBufferMaxPageWordSize|0}},{key:"allocateChunk",value:function(e){e=rt(e,this.uniformBufferWordAlignment),He(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=rt(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t}},{key:"ensureShadowBuffer",value:function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=rt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){He(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=rt(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*n);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),n<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(n,"]"))}}},{key:"mapBufferF32",value:function(){return ze(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=ze(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:4*this.currentBufferWordSize,usage:me.UNIFORM,hint:ge.DYNAMIC}));var t=rt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())ze(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}}},{key:"destroy",value:function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null}}])}();function fi(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function di(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function hi(e){return 0}var _i=u((function e(){l(this,e),this.keys=[],this.values=[]})),pi=function(){return u((function e(t,r){l(this,e),this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=r}),[{key:"findBucketIndex",value:function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1}},{key:"findBucket",value:function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)}},{key:"get",value:function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]}},{key:"add",value:function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new _i);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)}},{key:"delete",value:function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}}},{key:"clear",value:function(){this.buckets.clear()}},{key:"size",value:function(){var e,t=0,r=An(this.buckets.values());try{for(r.s();!(e=r.n()).done;){t+=e.value.values.length}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"values",value:P().mark((function e(){var t,r,n,i;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=An(this.buckets.values()),e.prev=1,t.s();case 3:if((r=t.n()).done){e.next=14;break}i=(n=r.value).values.length-1;case 6:if(i<0){e.next=12;break}return e.next=9,n.values[i];case 9:i--,e.next=6;break;case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),t.e(e.t0);case 19:return e.prev=19,t.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,this,[[1,16,19,22]])}))}])}();function Ei(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return function(e,t,r,n){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:ir(e,"vert",t,n),preprocessedFrag:ir(e,"frag",r,n)}}(e.queryVendorInfo(),n,i,r)}function vi(e,t){return He(""!==e.preprocessedVert&&""!==t.preprocessedVert),He(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Ri(e,t){return e=fi(e,t.blendMode),e=fi(e,t.blendSrcFactor),e=fi(e,t.blendDstFactor)}function mi(e,t){return e=Ri(e,t.rgbBlendState),e=fi(e=Ri(e,t.alphaBlendState),t.channelWriteMask)}function gi(e,t){for(var r,n,i,a,o,s,u,l,c=0;t.attachmentsState.length>c;c++)e=mi(e,t.attachmentsState[c]);return e=function(e,t){return fi(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=fi(e,t.depthCompare),e=fi(e,t.depthWrite?1:0),e=fi(e,null===(r=t.stencilFront)||void 0===r?void 0:r.compare),e=fi(e,null===(n=t.stencilFront)||void 0===n?void 0:n.passOp),e=fi(e,null===(i=t.stencilFront)||void 0===i?void 0:i.failOp),e=fi(e,null===(a=t.stencilFront)||void 0===a?void 0:a.depthFailOp),e=fi(e,null===(o=t.stencilBack)||void 0===o?void 0:o.compare),e=fi(e,null===(s=t.stencilBack)||void 0===s?void 0:s.passOp),e=fi(e,null===(u=t.stencilBack)||void 0===u?void 0:u.failOp),e=fi(e,null===(l=t.stencilBack)||void 0===l?void 0:l.depthFailOp),e=fi(e,t.stencilWrite?1:0),e=fi(e,t.cullMode),e=fi(e,t.frontFace?1:0),e=fi(e,t.polygonOffset?1:0)}function Ti(e){var t=0;t=fi(t,e.program.id),null!==e.inputLayout&&(t=fi(t,e.inputLayout.id)),t=gi(t,e.megaStateDescriptor);for(var r=0;e.colorAttachmentFormats.length>r;r++)t=fi(t,e.colorAttachmentFormats[r]||0);return di(t=fi(t,e.depthStencilAttachmentFormat||0))}function Ai(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=fi(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var a=e.uniformBufferBindings[i];null!==a&&null!==a.buffer&&(t=fi(t,a.buffer.id),t=fi(t,a.binding),t=fi(t,a.offset),t=fi(t,a.size))}return di(t)}var yi=function(){return u((function e(t){l(this,e),this.bindingsCache=new pi(At,Ai),this.renderPipelinesCache=new pi(Mt,Ti),this.inputLayoutsCache=new pi(xt,hi),this.programCache=new pi(vi,hi),this.samplerCache=new pi(Bt,hi),this.device=t}),[{key:"createBindings",value:function(e){var t,r=this.bindingsCache.get(e);if(null===r){var n={samplerBindings:(t=e).samplerBindings&&Rt(t.samplerBindings,Dt),uniformBufferBindings:t.uniformBufferBindings&&Rt(t.uniformBufferBindings,bt),storageBufferBindings:t.storageBufferBindings&&Rt(t.storageBufferBindings,bt),storageTextureBindings:t.storageTextureBindings&&Rt(t.storageTextureBindings,Lt),pipeline:t.pipeline};n.uniformBufferBindings=n.uniformBufferBindings.filter((function(e){return e.size>0})),r=this.device.createBindings(n),this.bindingsCache.add(n,r)}return r}},{key:"createRenderPipeline",value:function(e){var t,r,n,i=this.renderPipelinesCache.get(e);if(null===i){var a=(r=(t=e).program,n=t.topology,{inputLayout:t.inputLayout,megaStateDescriptor:t.megaStateDescriptor&&ct(t.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:t.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:t.depthStencilAttachmentFormat,sampleCount:t.sampleCount});i=this.device.createRenderPipeline(o(o({},a),{},{colorAttachmentFormats:e.colorAttachmentFormats.filter((function(e){return e}))})),this.renderPipelinesCache.add(a,i)}return i}},{key:"createInputLayout",value:function(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter((function(e){return!!e}));var t,r=this.inputLayoutsCache.get(e);if(null===r){var n={vertexBufferDescriptors:Rt((t=e).vertexBufferDescriptors,Ut),indexBufferFormat:t.indexBufferFormat,program:t.program};r=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,r)}return r}},{key:"createProgramSimple",value:function(e){var t,r=e.vert,n=e.preprocessedFrag,i=e.preprocessedVert,a=null;if(i&&n&&(a=this.programCache.get({vert:r,frag:e.frag,preprocessedFrag:n,preprocessedVert:i})),null===a){var o=Ei(this.device,e),s=o.preprocessedVert,u=o.preprocessedFrag;e.preprocessedVert=s,e.preprocessedFrag=u;var l={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};a=this.device.createProgramSimple({vertex:{glsl:s},fragment:{glsl:u}},r),this.programCache.add(l,a)}return a}},{key:"createSampler",value:function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t}},{key:"destroy",value:function(){var e,t=An(this.bindingsCache.values());try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}var r,n=An(this.renderPipelinesCache.values());try{for(n.s();!(r=n.n()).done;){r.value.destroy()}}catch(e){n.e(e)}finally{n.f()}var i,a=An(this.inputLayoutsCache.values());try{for(a.s();!(i=a.n()).done;){i.value.destroy()}}catch(e){a.e(e)}finally{a.f()}var o,s=An(this.programCache.values());try{for(s.s();!(o=s.n()).done;){o.value.destroy()}}catch(e){s.e(e)}finally{s.f()}var u,l=An(this.samplerCache.values());try{for(l.s();!(u=l.n()).done;){u.value.destroy()}}catch(e){l.e(e)}finally{l.f()}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}}])}(),Si=function(e){return e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping",e}({}),Ci=function(e){return e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.ColorMax=3]="ColorMax",e[e.DepthStencil=4]="DepthStencil",e}({}),Pi=function(){return u((function e(){l(this,e),this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]}),[{key:"setDebugName",value:function(e){this.debugName=e}},{key:"pushDebugThumbnail",value:function(e){this.debugThumbnails[e]=!0}},{key:"setViewport",value:function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n}},{key:"attachRenderTargetID",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;He(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r}},{key:"attachResolveTexture",value:function(e){this.resolveTextureInputIDs.push(e)}},{key:"attachOcclusionQueryPool",value:function(e){this.descriptor.occlusionQueryPool=e}},{key:"exec",value:function(e){He(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){He(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}])}(),Ni=function(){return u((function e(t,r){l(this,e),this.dimension=ye.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=Se.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.sampleCount=r.sampleCount,He(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))}),[{key:"setDebugName",value:function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)}},{key:"matchesDescription",value:function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount}},{key:"reset",value:function(e){He(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.attachment.destroy()}}])}(),Mi=function(){return u((function e(t,r){l(this,e),this.dimension=ye.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=Se.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.texture=t.createTexture(this)}),[{key:"matchesDescription",value:function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){He(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}])}(),Oi=u((function e(){l(this,e),this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]})),Ii=function(){return u((function e(t){l(this,e),this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=t}),[{key:"acquireRenderTargetForDescription",value:function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new Ni(this.device,e)}},{key:"acquireSingleSampledTextureForDescription",value:function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new Mi(this.device,e)}},{key:"beginGraphBuilder",value:function(){He(null===this.currentGraph),this.currentGraph=new Oi}},{key:"pushPass",value:function(e){var t=new Pi;e(t),this.currentGraph.passes.push(t)}},{key:"createRenderTargetID",value:function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1}},{key:"createResolveTextureID",value:function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1}},{key:"findMostRecentPassThatAttachedRenderTarget",value:function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null}},{key:"resolveRenderTargetPassAttachmentSlot",value:function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]}},{key:"findPassForResolveRenderTarget",value:function(e){var t=ze(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return He(void 0===t.resolveTextureOutputExternalTextures[r]),t}},{key:"resolveRenderTarget",value:function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)}},{key:"resolveRenderTargetToExternalTexture",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);He(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r}},{key:"getRenderTargetDescription",value:function(e){return ze(this.currentGraph.renderTargetDescriptions[e])}},{key:"scheduleAddUseCount",value:function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){var n=t.renderTargetIDs[r];void 0!==n&&(this.renderTargetOutputCount[n]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[n]++)}for(var i=0;t.resolveTextureInputIDs.length>i;i++){var a=t.resolveTextureInputIDs[i];if(void 0!==a)this.resolveTextureUseCount[a]++,this.renderTargetResolveCount[e.resolveTextureRenderTargetIDs[a]]++}}},{key:"acquireRenderTargetForID",value:function(e,t){if(void 0===t)return null;if(He(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]}},{key:"releaseRenderTargetForID",value:function(e,t){if(void 0===e)return null;var r=ze(this.renderTargetAliveForID[e]);return t?(He(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(He(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,this.renderTargetAliveForID[e]=void 0,this.renderTargetDeadPool.push(r)),r}},{key:"acquireResolveTextureInputTextureForID",value:function(e,t){var r=e.resolveTextureRenderTargetIDs[t];He(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=ze(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return ze(n.texture)}},{key:"determineResolveParam",value:function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],a=t.resolveTextureOutputExternalTextures[r],o=void 0!==i,s=void 0!==a;He(!(o&&s));var u=null,l=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(l=!0),o){He(e.resolveTextureRenderTargetIDs[i]===n),He(this.resolveTextureUseCount[i]>0),He(this.renderTargetOutputCount[n]>0);var f=ze(this.renderTargetAliveForID[n]);if(null!==f.texture&&1===this.renderTargetOutputCount[n])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var d=ze(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(d),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,"".concat(f.debugName," (Resolve ").concat(i,")"))}u=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(u=a,c=t.resolveTextureOutputExternalTextureLevel[r]):u=null;return{resolveTo:u,store:l,level:c}}},{key:"schedulePass",value:function(e,t){for(var r=t.renderTargetIDs[Ci.DepthStencil],n=Ci.Color0;Ci.ColorMax>=n;n++){var i=t.renderTargetIDs[n],a=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=a,t.descriptor.colorAttachment[n]=null!==a?a.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var o=this.determineResolveParam(e,t,n),s=o.store,u=o.level;t.descriptor.colorResolveTo[n]=o.resolveTo,t.descriptor.colorResolveToLevel[n]=u,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==a&&a.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var l=this.acquireRenderTargetForID(e,r);t.renderTargets[Ci.DepthStencil]=l,t.descriptor.depthStencilAttachment=null!==l?l.attachment:null;var c=this.determineResolveParam(e,t,Ci.DepthStencil),f=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=f,t.descriptor.depthClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var d=0,h=0,_=0,p=0;t.renderTargets.length>p;p++){var E=t.renderTargets[p];if(E){var v=E.width>>>t.renderTargetLevels[p],R=E.height>>>t.renderTargetLevels[p];0===d&&(d=v,h=R,_=E.sampleCount),He(v===d),He(R===h),He(E.sampleCount===_),E.needsClear=!1}}d>0&&h>0&&(t.viewportX*=d,t.viewportY*=h,t.viewportW*=d,t.viewportH*=h);for(var m=0;t.resolveTextureInputIDs.length>m;m++){t.resolveTextureInputTextures[m]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[m])}for(var g=0;t.renderTargetIDs.length>g;g++)this.releaseRenderTargetForID(t.renderTargetIDs[g],!0);for(var T=0;t.renderTargetExtraRefs.length>T;T++)t.renderTargetExtraRefs[T]&&this.releaseRenderTargetForID(t.renderTargetIDs[T],!0)}},{key:"scheduleGraph",value:function(e){He(0===this.renderTargetOutputCount.length),He(0===this.renderTargetResolveCount.length),He(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(var r=0;this.singleSampledTextureDeadPool.length>r;r++)this.singleSampledTextureDeadPool[r].age++;et(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),et(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),et(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var n=0;e.passes.length>n;n++)this.scheduleAddUseCount(e,e.passes[n]);for(var i=0;e.passes.length>i;i++)this.schedulePass(e,e.passes[i]);for(var a=0;this.renderTargetOutputCount.length>a;a++)He(0===this.renderTargetOutputCount[a]);for(var o=0;this.renderTargetResolveCount.length>o;o++)He(0===this.renderTargetResolveCount[o]);for(var s=0;this.resolveTextureUseCount.length>s;s++)He(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)He(void 0===this.renderTargetAliveForID[u]);for(var l=0;this.renderTargetDeadPool.length>l;l++)1>this.renderTargetDeadPool[l].age||(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;this.singleSampledTextureDeadPool.length>c;c++)1>this.singleSampledTextureDeadPool[c].age||(this.singleSampledTextureDeadPool[c].destroy(),this.singleSampledTextureDeadPool.splice(c--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0}},{key:"execPass",value:function(e){He(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.pushDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.popDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null}},{key:"execGraph",value:function(e){var t=this;this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEach((function(e){t.execPass(e)})),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0}},{key:"execute",value:function(){var e=ze(this.currentGraph);this.execGraph(e),this.currentGraph=null}},{key:"getDebug",value:function(){return this}},{key:"getPasses",value:function(){return this.currentGraph.passes}},{key:"getPassDebugThumbnails",value:function(e){return e.debugThumbnails}},{key:"getPassRenderTargetID",value:function(e,t){return e.renderTargetIDs[t]}},{key:"getRenderTargetIDDebugName",value:function(e){return this.currentGraph.renderTargetDebugNames[e]}},{key:"getResolveTextureForID",value:function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return He(r>=0),ze(t.resolveTextureInputTextures[r])}},{key:"getRenderTargetAttachment",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null}},{key:"getRenderTargetTexture",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null}},{key:"newGraphBuilder",value:function(){return this.beginGraphBuilder(),this}},{key:"destroy",value:function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)He(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)He(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var r=0;this.renderTargetDeadPool.length>r;r++)this.renderTargetDeadPool[r].destroy();for(var n=0;this.singleSampledTextureDeadPool.length>n;n++)this.singleSampledTextureDeadPool[n].destroy()}}])}(),xi=function(e){return e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT",e}({});function Bi(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536,n=x(e,0,r)/r;return t&&(n=1-n),65535&65535*n}function Di(e,t){return(16777215&e|(255&t)<<24)>>>0}function bi(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function Li(e,t){return Di(bi(0,t),e)}function Fi(e,t){return He(t>=0),(4294967040&e|t>>>8&255)>>>0}function Ui(e){return Di(0,e)}function ki(e,t){return He(t>=0),(4278190335&e|t<<8)>>>0}var wi=U(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Gi=U(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function Vi(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=a,4}var Xi=function(e){return e[e.None=0]="None",e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags",e}({}),Wi=function(){return u((function e(){l(this,e),this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=it(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=it(4,(function(){return 0})),this.flags=0,this.vertexBuffers=null,this.indexBuffer=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={inputLayout:null,megaStateDescriptor:ct(dt),program:null,topology:Re.TRIANGLES,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}),[{key:"reset",value:function(){this.sortKey=0,this.flags=Xi.AllowSkippingIfPipelineNotReady,this.vertexBuffers=null,this.indexBuffer=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){var t,r;lt(this.renderPipelineDescriptor.megaStateDescriptor,e.renderPipelineDescriptor.megaStateDescriptor),this.renderPipelineDescriptor.program=e.renderPipelineDescriptor.program,this.renderPipelineDescriptor.inputLayout=e.renderPipelineDescriptor.inputLayout,this.renderPipelineDescriptor.topology=e.renderPipelineDescriptor.topology,this.renderPipelineDescriptor.colorAttachmentFormats.length=Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length,e.renderPipelineDescriptor.colorAttachmentFormats.length);for(var n=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>n;n++)this.renderPipelineDescriptor.colorAttachmentFormats[n]=e.renderPipelineDescriptor.colorAttachmentFormats[n];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.uniformBuffer=e.uniformBuffer,this.uniforms=m(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.vertexBuffers=e.vertexBuffers,this.indexBuffer=e.indexBuffer,this.flags=this.flags&~Xi.InheritedFlags|e.flags&Xi.InheritedFlags,this.sortKey=e.sortKey;var i=this.bindingDescriptors[0],a=e.bindingDescriptors[0];this.setBindingLayout({numSamplers:null===(t=a.samplerBindings)||void 0===t?void 0:t.length,numUniformBuffers:null===(r=a.uniformBufferBindings)||void 0===r?void 0:r.length});for(var o=0;Math.min(i.uniformBufferBindings.length,a.uniformBufferBindings.length)>o;o++)i.uniformBufferBindings[o].size=e.bindingDescriptors[0].uniformBufferBindings[o].size;this.setSamplerBindingsFromTextureMappings(a.samplerBindings);for(var s=0;e.dynamicUniformBufferByteOffsets.length>s;s++)this.dynamicUniformBufferByteOffsets[s]=e.dynamicUniformBufferByteOffsets[s]}},{key:"validate",value:function(){for(var e=0;this.bindingDescriptors.length>e;e++)for(var t=this.bindingDescriptors[e],r=0;r<(null===(n=t.uniformBufferBindings)||void 0===n?void 0:n.length);r++){var n;He(t.uniformBufferBindings[r].size>0)}He(this.drawCount>0)}},{key:"setProgram",value:function(e){this.renderPipelineDescriptor.program=e}},{key:"setMegaStateFlags",value:function(e){return lt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor}},{key:"getMegaStateFlags",value:function(){return this.renderPipelineDescriptor.megaStateDescriptor}},{key:"setVertexInput",value:function(e,t,r){this.vertexBuffers=t,this.indexBuffer=r,this.renderPipelineDescriptor.inputLayout=e}},{key:"setBindingLayout",value:function(e){He(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers);for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({binding:t,buffer:null,size:0});for(var r=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>r;r++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null})}},{key:"drawIndexes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=nt(this.flags,Xi.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"drawIndexesInstanced",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.flags=nt(this.flags,Xi.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t}},{key:"drawPrimitives",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=nt(this.flags,Xi.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"setUniforms",value:function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value;if(B(t)||Array.isArray(t)||t instanceof Float32Array){var i=B(t)?[t]:t,a=4-r%4;if(4!==a)if(a<(i.length>4?4:i.length)){r+=a;for(var o=0;a>o;o++)n.push(0)}else;r+=i.length,n.push.apply(n,m(i))}}));var i=4-n.length%4;if(4!==i)for(var a=0;i>a;a++)n.push(0);for(var o=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),u=0;n.length>u;u+=4)o+=Vi(s,o,n[u],n[u+1],n[u+2],n[u+3])}}},{key:"setUniformBuffer",value:function(e){this.uniformBuffer=e}},{key:"allocateUniformBuffer",value:function(e,t){var r;return He((null===(r=this.bindingDescriptors[0].uniformBufferBindings)||void 0===r?void 0:r.length)<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].size=t<<2,this.getUniformBufferOffset(e)}},{key:"getUniformBufferOffset",value:function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2}},{key:"mapUniformBufferF32",value:function(e){return this.uniformBuffer.mapBufferF32()}},{key:"getUniformBuffer",value:function(){return this.uniformBuffer}},{key:"setSamplerBindingsFromTextureMappings",value:function(e){e=e.filter((function(e){return e}));for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler):(r.texture=null,r.sampler=null)}}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=nt(this.flags,Xi.AllowSkippingIfPipelineNotReady,e)}},{key:"setAttachmentFormatsFromRenderPass",value:function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var a=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==a?a.format:null,null!==a&&(-1===n?n=a.sampleCount:He(n===a.sampleCount))}var o=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==o?o.format:null,null!==o&&(-1===n?n=o.sampleCount:He(n===o.sampleCount)),He(n>0),this.renderPipelineDescriptor.sampleCount=n}},{key:"drawOnPass",value:function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(i)){if(this.flags&Xi.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(i)}t.setPipeline(i),t.setVertexInput(this.renderPipelineDescriptor.inputLayout,this.vertexBuffers,this.indexBuffer);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=ze(this.uniformBuffer.buffer),this.bindingDescriptors[0].uniformBufferBindings[a].offset=this.dynamicUniformBufferByteOffsets[a];this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniformsLegacy(t)}));var s=e.createBindings(o(o({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(s),this.flags&Xi.Indexed?t.drawIndexed(this.drawCount,this.drawInstanceCount,this.drawStart,0,0):t.draw(this.drawCount,this.drawInstanceCount,this.drawStart,0),!0}}])}();function Hi(e,t){return e.sortKey-t.sortKey}var zi=function(e){return e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e}({}),Yi=function(){return u((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Hi,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zi.Forwards;l(this,e),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=t,this.executionOrder=r}),[{key:"checkUsePostSort",value:function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500}},{key:"insertSorted",value:function(e){var t,r,n;null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):(n=function(e,t,r){for(var n=0,i=e.length;i>n;){var a=n+(i-n>>>1);0>r(t,e[a])?i=a:n=a+1}return n}(t=this.renderInsts,r=e,this.compareFunction),t.splice(n,0,r)),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=Xi.Draw,this.insertSorted(e)}},{key:"ensureSorted",value:function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)}},{key:"drawOnPassRendererNoReset",value:function(e,t){if(this.ensureSorted(),this.executionOrder===zi.Forwards)for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].drawOnPass(e,t);else for(var n=this.renderInsts.length-1;n>=0;n--)this.renderInsts[n].drawOnPass(e,t)}},{key:"reset",value:function(){this.renderInsts.length=0}},{key:"drawOnPassRenderer",value:function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()}}])}(),Ki=function(){return u((function e(){l(this,e),this.pool=[],this.allocCount=0}),[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new Wi),this.allocCount-1}},{key:"popRenderInst",value:function(){this.allocCount--}},{key:"reset",value:function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0}},{key:"destroy",value:function(){this.pool.length=0,this.allocCount=0}}])}(),ji=function(){return u((function e(t){l(this,e),this.instPool=new Ki,this.templatePool=new Ki,this.simpleRenderInstList=new Yi,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t}),[{key:"newRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r}},{key:"submitRenderInst",value:function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.currentRenderInstList).submitRenderInst(e)}},{key:"setCurrentRenderInstList",value:function(e){He(null===this.simpleRenderInstList),this.currentRenderInstList=e}},{key:"pushTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=Xi.Template,r}},{key:"popTemplateRenderInst",value:function(){this.templatePool.popRenderInst()}},{key:"getTemplateRenderInst",value:function(){return this.templatePool.pool[this.templatePool.allocCount-1]}},{key:"resetRenderInsts",value:function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),He(0===this.templatePool.allocCount)}},{key:"destroy",value:function(){this.instPool.destroy(),this.renderCache.destroy()}},{key:"disableSimpleMode",value:function(){this.simpleRenderInstList=null}},{key:"drawOnPassRenderer",value:function(e){ze(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){ze(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}])}(),Zi=function(){return u((function e(t){l(this,e),this.parameters=t}),[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new yi(e),this.renderGraph=new Ii(this.device),this.renderInstManager=new ji(this.renderCache),this.uniformBuffer=new ci(this.device)}},{key:"pushTemplateRenderInst",value:function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e}},{key:"prepareToRender",value:function(){this.uniformBuffer.prepareToRender()}},{key:"destroy",value:function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()}},{key:"getCache",value:function(){return this.renderCache}},{key:"getDefines",value:function(){var e,t,r;return{USE_TONEMAPPING:(null===(e=this.parameters)||void 0===e?void 0:e.toneMapping)&&(null===(t=this.parameters)||void 0===t?void 0:t.toneMapping)!==Si.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}}}])}(),qi=function(){return u((function e(t){l(this,e),this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.format=t}),[{key:"setDimensions",value:function(e,t,r){this.width=e,this.height=t,this.sampleCount=r}},{key:"copyDimensions",value:function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}])}();function Qi(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var $i=Qi(Ke(.88,.88,.88,1)),Ji=Qi(Ze),ea=Qi(Qe),ta=function(e){return e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4",e}({});function ra(e,t){var r=function(e){return e.antialiasingMode===ta.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function na(e,t,r){var n=function(e){if(e===Ci.Color0)return be.U8_RGBA_RT;if(e===Ci.DepthStencil)return be.D24_S8;throw Error("whoops")}(e),i=new qi(n);return ra(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}var ia=function(){return u((function e(){l(this,e),this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}),[{key:"reset",value:function(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}},{key:"copy",value:function(e){this.texture=e.texture,this.sampler=e.sampler,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias}}])}(),aa=function(){return u((function e(){l(this,e),this.inputTexture=null,this.outputTexture=null}),[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),He(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Mi(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))}},{key:"getTextureForSampling",value:function(){return null!==this.inputTexture?this.inputTexture.texture:null}},{key:"getTextureForResolving",value:function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture}},{key:"destroy",value:function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)}}])}(),oa=["style"],sa=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,n=g(e,oa);return l(this,t),h(this,t,[o({type:t.tag,style:o({intensity:Math.PI},r)},n)])}return p(t,e),u(t)}(t.DisplayObject);sa.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["intensity"])),sa.tag="light";var ua=["style"],la=function(e){return e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR",e}({}),ca=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,n=g(e,ua);return l(this,t),h(this,t,[o({type:t.tag,style:o({type:la.NONE,fill:"black",start:1,end:1e3,density:0},r)},n)])}return p(t,e),u(t)}(t.DisplayObject);function fa(e,t,r){var n=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:arguments.length>3&&void 0!==arguments[3]?arguments[3]:ge.STATIC});return n.setSubData(0,new Uint8Array(r)),n}ca.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["type","density","start","end"])),ca.tag="fog";var da,ha,_a=function(e){return e.CHANGED="changed",e}({}),pa=function(e){function r(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l(this,r),(t=h(this,r)).drawMode=Re.TRIANGLES,t.vertexBuffers=[],t.vertices=[],t.inputLayoutDescriptor={vertexBufferDescriptors:[],indexBufferFormat:null,program:null},t.vertexCount=0,t.instancedCount=0,t.indexStart=0,t.primitiveStart=0,t.dirty=!0,t.meshes=[],t.device=e,t.props=n,t}return p(r,e),u(r,[{key:"validate",value:function(e){return!0}},{key:"build",value:function(e){}},{key:"computeBoundingBox",value:function(){return new t.AABB}},{key:"setIndexBuffer",value:function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=fa(this.device,me.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this.inputLayoutDescriptor.indexBufferFormat=be.U32_R,this}},{key:"setVertexBuffer",value:function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={arrayStride:e.byteStride,stepMode:e.stepMode,attributes:[]},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,a=e.location,o=e.divisor,s=t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.find((function(e){return e.shaderLocation===a}));s?(s.format=n,s.offset=i,s.divisor=o):t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.push({format:n,offset:i,shaderLocation:a,divisor:o})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var a=fa(this.device,me.VERTEX,i.buffer,ge.DYNAMIC);return this.vertexBuffers[r]=a,this}},{key:"getVertexBuffer",value:function(e){return this.vertexBuffers[e]}},{key:"updateVertexBuffer",value:function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e];if(i){var a=i.arrayStride,o=this.inputLayoutDescriptor.vertexBufferDescriptors[e].attributes.find((function(e){return e.shaderLocation===t}));if(o)this.getVertexBuffer(e).setSubData(o.offset+r*a,n);this.emit(_a.CHANGED)}}},{key:"updateIndices",value:function(e){return this.indexBuffer&&this.indexBuffer.setSubData(arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this}},{key:"destroy",value:function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0}}])}(Le),Ea=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).features={},e.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",e.vert="#define GLSLIFY 1\nlayout(location = 0) in vec2 a_Position;\n\nout vec2 v_TexCoord;\n\nvoid main() {\n v_TexCoord = 0.5 * (a_Position + 1.0);\n gl_Position = vec4(a_Position, 0., 1.);\n\n #ifdef VIEWPORT_ORIGIN_TL\n v_TexCoord.y = 1.0 - v_TexCoord.y;\n #endif\n}",e.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nfloat MonochromeNTSC(vec3 t_Color) {\n // NTSC primaries.\n return dot(t_Color.rgb, vec3(0.299, 0.587, 0.114));\n}\n\nvec4 FXAA(PD_SAMPLER_2D(t_Texture), in vec2 t_PixelCenter, in vec2 t_InvResolution) {\n // FXAA v2, based on implementations:\n // http://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/\n // https://github.com/mitsuhiko/webgl-meincraft\n\n float lumaMM = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy).rgb);\n\n #if 1\n vec2 t_PixelTopLeft = t_PixelCenter.xy - t_InvResolution.xy * 0.5;\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy) .rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 0.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(0.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 1.0)).rgb);\n #else\n // We're at the pixel center -- pixel edges are 0.5 units away.\n // NOTE(jstpierre): mitsuhiko's port seems to get this wrong?\n vec2 t_PixelSize = t_InvResolution.xy * 0.5;\n\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, -1.0)).rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, -1.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, 1.0)).rgb);\n #endif\n\n vec2 dir; \n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n const float FXAA_REDUCE_MIN = 1.0/128.0;\n const float FXAA_REDUCE_MUL = 1.0/8.0;\n const float FXAA_SPAN_MAX = 8.0;\n\n float dirReduce = max(\n (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\n FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_InvResolution.xy;\n\n float lumaMin = min(lumaMM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaMM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec4 rgbA = (1.0/2.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (1.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (0.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = MonochromeNTSC(rgbB.rgb);\n\n vec4 rgbOutput = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;\n return rgbOutput;\n}\n\nvoid main() {\n outputColor = FXAA(PP_SAMPLER_2D(u_Texture), v_TexCoord.xy, u_InvResolution.xy);\n}",e}return p(t,e),u(t)}(li),va=it(1,(function(){return new ia}));function Ra(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Ci.Color0,n);var a=e.resolveRenderTarget(n);i.attachResolveTexture(a);var o=t.renderInstManager.newRenderInst();o.setUniformBuffer(t.uniformBuffer),o.setAllowSkippingIfPipelineNotReady(!1),o.setMegaStateFlags(ht),o.setBindingLayout({numUniformBuffers:1,numSamplers:1}),o.drawPrimitives(3);var s=o.allocateUniformBuffer(0,4);Vi(o.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new Ea,l=t.renderCache.createProgramSimple(u);o.setProgram(l),da||((da=new pa(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([1,3,-3,-1,1,-1])}),da.vertexCount=3,ha=t.getCache().createInputLayout(da.inputLayoutDescriptor)),i.exec((function(e,r){va[0].texture=r.getResolveTextureForID(a),o.setSamplerBindingsFromTextureMappings(va),o.setVertexInput(ha,da.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null),o.drawOnPass(t.renderCache,e)}))}))}var ma=function(e){return e.PROJECTION_MATRIX="u_ProjectionMatrix",e.VIEW_MATRIX="u_ViewMatrix",e.CAMERA_POSITION="u_CameraPosition",e.DEVICE_PIXEL_RATIO="u_DevicePixelRatio",e.VIEWPORT="u_Viewport",e.IS_ORTHO="u_IsOrtho",e.IS_PICKING="u_IsPicking",e}({}),ga=function(){function e(t,r,n,i,a){l(this,e),this.renderLists={leftEye:new Yi,rightEye:new Yi,picking:new Yi},this.cameras=[],this.renderHelper=t,this.lightPool=r,this.texturePool=n,this.batchManager=i,this.options=a}return u(e,[{key:"getDevice",value:function(){return this.device}},{key:"getSwapChain",value:function(){return this.swapChain}},{key:"getRenderLists",value:function(){return this.renderLists}},{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,a=r.config,s=r.renderingContext.root.ownerDocument.defaultView;a.disableRenderHooks=!0;var u=function(e){var t=e.target;t.nodeName!==sa.tag?t.nodeName!==ca.tag?(t.renderable3D||(t.renderable3D=new ni),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},l=function(e){var r=e.target;if(r.nodeName!==sa.tag)if(r.nodeName!==ca.tag){if(r.nodeName===t.Shape.MESH){var i,a;if(null!==(i=r.style.geometry)&&void 0!==i&&i.meshes){var o=r.style.geometry.meshes.indexOf(r);o>-1&&r.style.geometry.meshes.splice(o,1)}if(null!==(a=r.style.material)&&void 0!==a&&a.meshes){var s=r.style.material.meshes.indexOf(r);s>-1&&r.style.material.meshes.splice(s,1)}}n.swapChain&&n.batchManager.remove(r),delete r.renderable3D}else n.lightPool.removeFog(r);else n.lightPool.removeLight(r)},c=function(e){if(n.swapChain){var t=e.target,r=e.attrName,i=e.newValue;"zIndex"===r?t.parentNode.forEach((function(e){n.batchManager.changeRenderOrder(e,e.sortable.renderOrder)})):n.batchManager.updateAttribute(t,r,i)}},f=function(e){if(n.swapChain){var r=e.target;(r.nodeName===t.Shape.FRAGMENT?r.childNodes:[r]).forEach((function(e){n.batchManager.updateAttribute(e,"modelMatrix",null)}))}};i.hooks.initAsync.tapPromise(e.tag,M(P().mark((function e(){var i,a;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s.addEventListener(t.ElementEvent.MOUNTED,u),s.addEventListener(t.ElementEvent.UNMOUNTED,l),s.addEventListener(t.ElementEvent.ATTR_MODIFIED,c),s.addEventListener(t.ElementEvent.BOUNDS_CHANGED,f),n.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,i=n.context.contextService.getDomElement(),n.context.contextService.resize((a=n.context.config).width,a.height),e.next=10,n.context.deviceContribution.createSwapChain(i);case 10:n.swapChain=e.sent,n.device=n.swapChain.getDevice(),n.renderHelper.setDevice(n.device),n.renderHelper.renderInstManager.disableSimpleMode(),n.swapChain.configureSwapChain(i.width,i.height),s.addEventListener(t.CanvasEvent.RESIZE,(function(){n.swapChain.configureSwapChain(i.width,i.height)})),n.batchManager.attach(o({device:n.device},r));case 17:case"end":return e.stop()}}),e)})))),i.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),n.batchManager.destroy(),n.texturePool.destroy(),s.removeEventListener(t.ElementEvent.MOUNTED,u),s.removeEventListener(t.ElementEvent.UNMOUNTED,l),s.removeEventListener(t.ElementEvent.ATTR_MODIFIED,c),s.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,f),n.device.destroy(),n.device.checkForLeaks(),a.disableRenderHooks=!1})),i.hooks.beginFrame.tap(e.tag,(function(e){var r,i=null==e?void 0:e.session,a=n.context.config,o=a.width,s=a.height;if(i){var u=i.renderState.baseLayer;u||(u=i.renderState.layers[0]),n.swapChain.configureSwapChain(u.framebufferWidth,u.framebufferHeight,u.framebuffer);var l=e.getViewerPose(i.referenceSpace);l&&l.views.forEach((function(e,t){var r=i.renderState.baseLayer.getViewport(e),a=U.apply(q,m(e.transform.matrix));a[12]*=o,a[13]*=s,a[14]*=500,a[12]+=o/2,a[13]-=s/2,a[14]+=250;var l=U.apply(q,m(e.projectionMatrix)),c=w(L(),a);V(c,c,Q(1,-1,1));var f=e.transform.position;n.cameras[t]={viewport:{x:r.x/u.framebufferWidth,y:r.y/u.framebufferHeight,width:r.width/u.framebufferWidth,height:r.height/u.framebufferHeight},projectionMatrix:l,viewMatrix:c,cameraPosition:[f.x,f.y,f.z],isOrtho:!1}}))}else{var c=n.context.camera;n.cameras=[{viewport:{x:0,y:0,width:1,height:1},projectionMatrix:c.getPerspective(),viewMatrix:c.getViewTransform(),cameraPosition:c.getPosition(),isOrtho:c.isOrtho()}]}var f,d=n.swapChain.getCanvas(),h=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)f=je;else{var _=t.parseColor(n.context.config.background);f=n.context.config.background?Ke(Number(_.r)/255*Number(_.alpha),Number(_.g)/255*Number(_.alpha),Number(_.b)/255*Number(_.alpha),Number(_.alpha)):qe}var p={backbufferWidth:d.width,backbufferHeight:d.height,antialiasingMode:ta.None},E=na(Ci.Color0,p,Qi(f)),v=na(Ci.DepthStencil,p,ea),R=n.builder.createRenderTargetID(E,"Main Color"),g=n.builder.createRenderTargetID(v,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Ci.Color0,R),e.attachRenderTargetID(Ci.DepthStencil,g),e.exec((function(e,t){n.cameras.forEach((function(r,i){var a=r.viewport,o=t.currentPass,s=o.viewportW,u=o.viewportH;e.setViewport(a.x*s,a.y*u,a.width*s,a.height*u),(0===i?n.renderLists.leftEye:n.renderLists.rightEye).drawOnPassRenderer(h.renderCache,e)}))}))})),null!==(r=n.options)&&void 0!==r&&r.enableFXAA&&Ra(n.builder,n.renderHelper,p,R),n.builder.resolveRenderTargetToExternalTexture(R,n.swapChain.getOnscreenTexture())})),i.hooks.endFrame.tap(e.tag,(function(e){var t=n.renderHelper.renderInstManager,r=n.context.config,i=r.width,a=r.height;if(n.cameras.forEach((function(e,r){var o=e.viewport,s=e.cameraPosition,u=e.viewMatrix,l=e.projectionMatrix,c=e.isOrtho,f=o.width,d=o.height,h=n.renderHelper.pushTemplateRenderInst();h.setBindingLayout({numUniformBuffers:2,numSamplers:0}),h.setMegaStateFlags(_t({depthWrite:!0,blendConstant:je},{rgbBlendMode:_e.ADD,alphaBlendMode:_e.ADD,rgbBlendSrcFactor:he.SRC_ALPHA,alphaBlendSrcFactor:he.ONE,rgbBlendDstFactor:he.ONE_MINUS_SRC_ALPHA,alphaBlendDstFactor:he.ONE_MINUS_SRC_ALPHA})),h.setUniforms(0,[{name:ma.PROJECTION_MATRIX,value:l},{name:ma.VIEW_MATRIX,value:u},{name:ma.CAMERA_POSITION,value:s},{name:ma.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:ma.VIEWPORT,value:[i*f,a*d]},{name:ma.IS_ORTHO,value:c?1:0},{name:ma.IS_PICKING,value:0}]),n.batchManager.render(0===r?n.renderLists.leftEye:n.renderLists.rightEye),t.popTemplateRenderInst()})),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),t.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var o=n.captureOptions,s=o.type,u=o.encoderOptions,l=n.context.contextService.getDomElement().toDataURL(s,u);n.resolveCapturePromise(l),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))}},{key:"loadTexture",value:function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))}},{key:"toDataURL",value:(r=M(P().mark((function e(t){var r=this;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.enableCapture=!0,this.captureOptions=t,this.capturePromise=new Promise((function(e){r.resolveCapturePromise=function(t){e(t)}})),e.abrupt("return",this.capturePromise);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})}]);var r}();ga.tag="RenderGraph";var Ta=function(){function e(t,r,n,i){l(this,e),this.renderHelper=t,this.renderGraphPlugin=r,this.pickingIdGenerator=n,this.batchManager=i}return u(e,[{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,a=r.renderingContext.root.ownerDocument.defaultView,o=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new ni);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)},s=function(e){var t=e.target.renderable3D;t&&n.pickingIdGenerator.deleteById(t.pickingId)};i.hooks.init.tap(e.tag,(function(){a.addEventListener(t.ElementEvent.MOUNTED,o),a.addEventListener(t.ElementEvent.UNMOUNTED,s)})),i.hooks.destroy.tap(e.tag,(function(){a.removeEventListener(t.ElementEvent.MOUNTED,o),a.removeEventListener(t.ElementEvent.UNMOUNTED,s),n.pickingIdGenerator.reset()})),i.hooks.pickSync.tap(e.tag,(function(e){return n.pick(e)})),i.hooks.pick.tapPromise(e.tag,function(){var e=M(P().mark((function e(t){return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.pick(t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"pick",value:function(e){var r=e.topmost,n=e.position,i=n.viewportX,a=n.viewportY,o=this.context.contextService.getDPR(),s=this.context.config.width*o,u=this.context.config.height*o,l=i*o,c=a*o;if(!this.renderHelper.renderGraph||l>s||0>l||c>u||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(x(Math.round(l),0,s-1),x(Math.round(c),0,u-1),1,1),r?1:100);return e.picked=f,e}},{key:"pickByRectangleInDepth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=null,n=1,i=[];do{if(!(r=this.pickByRectangle(e,r)))break;n++,i.push(r)}while(r&&t>=n);return t>1&&this.restorePickingColor(i),i}},{key:"restorePickingColor",value:function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))}},{key:"pickByRectangle",value:function(e,t){var r,n=this,i=this.renderGraphPlugin.getDevice(),a=this.renderGraphPlugin.getRenderLists(),s=this.renderHelper.renderInstManager,u=this.renderHelper.renderGraph.newGraphBuilder(),l=this.context.camera,c=e.x,f=e.y,d=e.width,h=e.height,_={backbufferWidth:d,backbufferHeight:h,antialiasingMode:ta.None},p=na(Ci.Color0,_,Qi(je)),E=u.createRenderTargetID(p,"Picking Color"),v=na(Ci.DepthStencil,_,ea),R=u.createRenderTargetID(v,"Picking Depth"),m=o({},l.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),u.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(Ci.Color0,E),e.attachRenderTargetID(Ci.DepthStencil,R),e.exec((function(e){a.picking.drawOnPassRenderer(s.renderCache,e)})),e.post((function(e){var t,a=e.getRenderTargetTexture(Ci.Color0),o=i.createReadback();m&&m.enabled?l.setViewOffset(m.fullWidth,m.fullHeight,m.offsetX,m.offsetY,m.width,m.height):l.clearViewOffset(),l.setEnableUpdate(!0);try{t=o.readTextureSync(a,0,0,d,h,new Uint8Array(d*h*4))}catch(e){}var s=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(s=n.pickingIdGenerator.decodePickingColor(t)),s>-1){var u=n.pickingIdGenerator.getById(s);u&&u.isVisible()&&u.isInteractive()&&(r=u)}o.destroy()}))}));var g=this.renderHelper.pushTemplateRenderInst();g.setBindingLayout({numUniformBuffers:2,numSamplers:0}),g.setMegaStateFlags(_t({depthWrite:!0},{rgbBlendMode:_e.ADD,rgbBlendSrcFactor:he.ONE,rgbBlendDstFactor:he.ZERO,alphaBlendMode:_e.ADD,alphaBlendSrcFactor:he.ONE,alphaBlendDstFactor:he.ZERO}));var T=this.context.config,A=T.width,y=T.height,S=this.context.contextService.getDPR();return l.setEnableUpdate(!1),l.setViewOffset(A*S,y*S,c,y*S-f,d,h),g.setUniforms(0,[{name:ma.PROJECTION_MATRIX,value:l.getPerspective()},{name:ma.VIEW_MATRIX,value:l.getViewTransform()},{name:ma.CAMERA_POSITION,value:l.getPosition()},{name:ma.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:ma.VIEWPORT,value:[d,h]},{name:ma.IS_ORTHO,value:l.isOrtho()?1:0},{name:ma.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(a.picking,!0),s.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),s.resetRenderInsts(),r}}])}();Ta.tag="WebGLPicker";var Aa=5e-4,ya=function(){return u((function e(){l(this,e),this.clipPathMeshCreated=!1}),[{key:"beforeUploadUBO",value:function(e,t){}},{key:"beforeInitMesh",value:function(e){}},{key:"afterInitMesh",value:function(e){}}])}();var Sa=function(e){return e.CHANGED="changed",e}({}),Ca=function(e){function t(e,r){var n;l(this,t),(n=h(this,t)).props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var i=ct(dt),a=i.cullMode,s=i.depthCompare,u=i.depthWrite,c=i.stencilFront,f=i.stencilBack,d=i.stencilWrite,_=i.frontFace,p=i.polygonOffset,E=i.attachmentsState;return n.device=e,n.props=o({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilFront:c,stencilBack:f,stencilWrite:d,frontFace:_,polygonOffset:p,attachmentsState:E,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return p(t,e),u(t,[{key:"cullMode",get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e}},{key:"frontFace",get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e}},{key:"blendConstant",get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e}},{key:"blendEquation",get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e}},{key:"blendEquationAlpha",get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e}},{key:"blendSrc",get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e}},{key:"blendDst",get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e}},{key:"blendSrcAlpha",get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e}},{key:"blendDstAlpha",get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e}},{key:"depthCompare",get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e}},{key:"depthTest",get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e}},{key:"depthWrite",get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e}},{key:"stencilFront",get:function(){return this.props.stencilFront},set:function(e){this.props.stencilFront=e}},{key:"stencilBack",get:function(){return this.props.stencilBack},set:function(e){this.props.stencilBack=e}},{key:"stencilWrite",get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e}},{key:"stencilRef",get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e}},{key:"polygonOffset",get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e}},{key:"dithering",get:function(){return this.props.dithering},set:function(e){this.props.dithering=e}},{key:"wireframe",get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e}},{key:"wireframeColor",get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e}},{key:"wireframeLineWidth",get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e}},{key:"vertexShader",get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())}},{key:"fragmentShader",get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())}},{key:"compile",value:function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,r){return e.samplers.push(r),""})),this.uniformNames=function(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().replace("\r\n","\n").split("\n").forEach((function(e){var t=ie(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})})),r.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform(?:\s+)(?:\w+)(?:\s?){([^]*?)};?/g,(function(e,n){return n.trim().replace("\r\n","\n").split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",a=n[1]||"",o=a.indexOf("[")>-1;if(a=a.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(o)for(var u=function(e){s.uniforms.forEach((function(r){t.push("".concat(a,"[").concat(e,"].").concat(r.name))}))},l=0;5>l;l++)u(l);else s.uniforms.forEach((function(e){t.push("".concat(a,".").concat(e.name))}))}a&&t.push(a)}})),""})),t}(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,a=e[n],o=t.textures[n];o&&o!==a&&(t.textureDirty=!0),(i=a)&&i.type?(t.textures[n]=a,t.textureDirty=!0,a.on(Ae.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=a,r=!0),O(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()}},{key:"dispatchMutationEvent",value:function(){this.emit(Sa.CHANGED)}}])}(Le),Pa=function(e){function t(e,r){var n;return l(this,t),(n=h(this,t,[e,o({},r)])).defines=o(o({},n.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return p(t,e),u(t)}(Ca);function Na(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function Ma(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var Oa=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=C(e,2);return void 0!==t[1]})))};function Ia(e,t){return 256*(e=x(Math.floor(e),0,255))+(t=x(Math.floor(t),0,255))}var xa=1,Ba="FillTextureMapping",Da=function(e){return e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.PACKED_COLOR=1]="PACKED_COLOR",e[e.PACKED_STYLE=2]="PACKED_STYLE",e[e.PICKING_COLOR=3]="PICKING_COLOR",e[e.POSITION=4]="POSITION",e[e.NORMAL=5]="NORMAL",e[e.UV=6]="UV",e[e.BARYCENTRIC=7]="BARYCENTRIC",e[e.MAX=8]="MAX",e}({}),ba=function(e){return e[e.MODEL_MATRIX0=0]="MODEL_MATRIX0",e[e.MODEL_MATRIX1=1]="MODEL_MATRIX1",e[e.MODEL_MATRIX2=2]="MODEL_MATRIX2",e[e.MODEL_MATRIX3=3]="MODEL_MATRIX3",e[e.PACKED_COLOR=4]="PACKED_COLOR",e[e.PACKED_STYLE1=5]="PACKED_STYLE1",e[e.PACKED_STYLE2=6]="PACKED_STYLE2",e[e.PICKING_COLOR=7]="PICKING_COLOR",e[e.POSITION=8]="POSITION",e[e.NORMAL=9]="NORMAL",e[e.UV=10]="UV",e[e.BARYCENTRIC=11]="BARYCENTRIC",e[e.MAX=12]="MAX",e}({}),La=function(){return u((function e(t,r,n,i,a){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:-1,s=arguments.length>6?arguments[6]:void 0;l(this,e),this.id=xa++,this.gradientAttributeName="fill",this.objects=[],this.program=new li,this.geometryDirty=!0,this.materialDirty=!0,this.textureMappings=[],this.divisor=1,this.mergeXYZIntoModelMatrix=!1,this.checkNodeName=!0,this.maxInstances=1/0,this.inited=!1,this.renderHelper=t,this.texturePool=r,this.lightPool=n,this.drawcallCtors=a,this.index=o,this.context=s}),[{key:"instance",get:function(){return this.objects[0]}},{key:"init",value:function(){this.inited||(this.renderer.beforeInitMesh(this),this.material=new Pa(this.context.device),this.material.defines=o(o({},Na(ba)),this.material.defines),this.geometry=new pa(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))}},{key:"observeGeometryChanged",value:function(){var e=this;this.geometry.on(_a.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))}},{key:"observeMaterialChanged",value:function(){var e=this;this.material.on(Sa.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))}},{key:"shouldMergeColor",value:function(e,r,n){var i=e.parsedStyle[n],a=r.parsedStyle[n];return!i&&!a||(!(!t.isCSSRGB(i)||!t.isCSSRGB(a))||(!(!t.isPattern(i)||!t.isPattern(a)||i.image!==a.image)||!(!Array.isArray(i)||!Array.isArray(a)||e.style[n]!==r.style[n])))}},{key:"shouldMerge",value:function(e,t){return!this.instance||(!this.checkNodeName||this.instance.nodeName===e.nodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))}},{key:"createGeometry",value:function(e){var r,n,i=this,a=L(),o=L(),s=[],u=[],l=[],c=[],f=this.divisor,d=(null===(r=e[0])||void 0===r?void 0:r.nodeName)===t.Shape.CIRCLE||(null===(n=e[0])||void 0===n?void 0:n.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach((function(e){var r,n=e.parsedStyle,f=n.fill,h=n.stroke,_=n.opacity,p=void 0===_?1:_,E=n.fillOpacity,v=void 0===E?1:E,R=n.strokeOpacity,g=void 0===R?1:R,T=n.lineWidth,A=void 0===T?1:T,y=n.visibility,S=n.increasedLineWidthForHitTesting,C=void 0===S?0:S,P=[0,0,0,0];t.isCSSRGB(f)&&(P=[Number(f.r),Number(f.g),Number(f.b),255*Number(f.alpha)]);var N=[0,0,0,0];t.isCSSRGB(h)&&(N=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]),Z(o,i.context.camera.getViewTransform(),a);var M=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];if(i.mergeXYZIntoModelMatrix){var O=e.parsedStyle,I=O.x,x=O.y,B=O.z;Z(a,e.getWorldTransform(),X(a,Q(I,x,B)))}else F(a,e.getWorldTransform());s.push.apply(s,m(a)),u.push(Ia(P[0],P[1]),Ia(P[2],P[3]),Ia(N[0],N[1]),Ia(N[2],N[3])),l.push(p,v,g,A,"hidden"!==y?1:0,d,d,C),c.push.apply(c,m(M).concat([e.sortable.renderOrder*Aa]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Da.MODEL_MATRIX,byteStride:64,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.MODEL_MATRIX0,divisor:f},{format:be.F32_RGBA,bufferByteOffset:16,location:ba.MODEL_MATRIX1,divisor:f},{format:be.F32_RGBA,bufferByteOffset:32,location:ba.MODEL_MATRIX2,divisor:f},{format:be.F32_RGBA,bufferByteOffset:48,location:ba.MODEL_MATRIX3,divisor:f}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Da.PACKED_COLOR,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.PACKED_COLOR,divisor:f}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:Da.PACKED_STYLE,byteStride:32,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.PACKED_STYLE1,divisor:f},{format:be.F32_RGBA,bufferByteOffset:16,location:ba.PACKED_STYLE2,divisor:f}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:Da.PICKING_COLOR,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.PICKING_COLOR,divisor:f}],data:new Float32Array(c)})}},{key:"destroy",value:function(){this.geometry&&this.geometry.destroy()}},{key:"applyRenderInst",value:function(e,t){var r=this,n=!!this.lightPool.getFog();this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilFront={compare:ce.ALWAYS,passOp:Pe.REPLACE},this.material.stencilBack={compare:ce.ALWAYS,passOp:Pe.REPLACE}):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilFront={compare:ce.EQUAL,passOp:Pe.KEEP},this.material.stencilBack={compare:ce.EQUAL,passOp:Pe.KEEP}):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var i=o({},this.material.defines);if(this.material.defines.USE_FOG=n,this.material.defines=o(o(o({},this.lightPool.getDefines()),this.material.defines),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a&&this.textureMappings.push(a),Object.keys(this.material.textures).sort((function(e,t){return r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)})).forEach((function(e){var t=new ia;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture ".concat(e)),t.sampler=r.renderHelper.getCache().createSampler({addressModeU:pe.CLAMP_TO_EDGE,addressModeV:pe.CLAMP_TO_EDGE,minFilter:Ee.POINT,magFilter:Ee.BILINEAR,mipmapFilter:ve.LINEAR,lodMinClamp:0,lodMaxClamp:0}),r.textureMappings.push(t)})),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(!Ma(i,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=o(o({},this.material.defines),Na(ba)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"boolean"==typeof t?r.program.setDefineBool(e,t):r.program.setDefineString(e,"".concat(t))})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.material.geometryDirty=!1),(this.geometryDirty||this.geometry.dirty)&&(this.geometry&&this.geometry.destroy(),this.createGeometry(t),this.material.wireframe&&this.generateWireframe(this.geometry),this.geometryDirty=!1,this.geometry.dirty=!1);var s=this.renderHelper.getCache().createProgramSimple(this.program),u=this.renderHelper.getCache().createInputLayout(o(o({},this.geometry.inputLayoutDescriptor),{},{program:s})),l=!!this.geometry.indexBuffer;e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setVertexInput(u,this.geometry.vertexBuffers.filter((function(e){return!!e})).map((function(e){return{buffer:e,byteOffset:0}})),l?{buffer:this.geometry.indexBuffer,offset:0}:null),this.renderer.beforeUploadUBO(e,this),this.uploadUBO(e),l?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=Li(xi.OPAQUE,t[0].sortable.renderOrder)}},{key:"updateBatchedAttribute",value:function(e,r,n,i){var a=this;if(0!==e.length){if("fill"===n||"stroke"===n){var o=[];e.forEach((function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=[0,0,0,0];t.isCSSRGB(n)&&(a=[Number(n.r),Number(n.g),Number(n.b),255*Number(n.alpha)]);var s=[0,0,0,0];t.isCSSRGB(i)&&(s=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]),o.push(Ia(a[0],a[1]),Ia(a[2],a[3]),Ia(s[0],s[1]),Ia(s[2],s[3]))})),this.geometry.updateVertexBuffer(Da.PACKED_COLOR,ba.PACKED_COLOR,r,new Uint8Array(new Float32Array(o).buffer));var s=this.instance.parsedStyle.fill,u=this.textureMappings.findIndex((function(e){return e.name===Ba}));if(t.isCSSRGB(s))0>u||(this.textureMappings.splice(u,-1),this.material.textureDirty=!0);else{var l=this.createFillGradientTextureMapping([this.instance]);0>u||this.textureMappings.splice(u,1,l),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var c,f,d=[],h=(null===(c=e[0])||void 0===c?void 0:c.nodeName)===t.Shape.CIRCLE||(null===(f=e[0])||void 0===f?void 0:f.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach((function(e){var t=e.parsedStyle,r=t.opacity,n=t.fillOpacity,i=t.strokeOpacity,a=t.lineWidth,o=t.increasedLineWidthForHitTesting;d.push(void 0===r?1:r,void 0===n?1:n,void 0===i?1:i,void 0===a?1:a,"hidden"!==t.visibility?1:0,h,h,void 0===o?0:o)})),this.geometry.updateVertexBuffer(Da.PACKED_STYLE,ba.PACKED_STYLE1,r,new Uint8Array(new Float32Array(d).buffer))}else if("modelMatrix"===n||this.mergeXYZIntoModelMatrix&&("x"===n||"y"===n||"z"===n)){var _=[],p=L();e.forEach((function(e){if(a.mergeXYZIntoModelMatrix){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;Z(p,e.getWorldTransform(),X(p,Q(r,n,i)))}else F(p,e.getWorldTransform());_.push.apply(_,m(p))})),this.geometry.updateVertexBuffer(Da.MODEL_MATRIX,ba.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(_).buffer))}else if("pointerEvents"===n){var E=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];E.push.apply(E,m(r).concat([e.sortable.renderOrder*Aa]))})),this.geometry.updateVertexBuffer(Da.PICKING_COLOR,ba.PICKING_COLOR,r,new Uint8Array(new Float32Array(E).buffer))}}}},{key:"updateAttribute",value:function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0),!0===this.geometryDirty&&0!==this.objects.length&&(this.geometry&&this.geometry.destroy(),this.createGeometry(this.objects),this.geometryDirty=!1)}},{key:"changeRenderOrder",value:function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Da.PICKING_COLOR,ba.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(m(i),[t*Aa])).buffer))}},{key:"generateWireframe",value:function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Da.PICKING_COLOR;e.vertexBuffers.length>i;i++){e.vertices[i]=new Float32Array(e.inputLayoutDescriptor.vertexBufferDescriptors[i].arrayStride/4*r)}for(var a=0,o=new Uint32Array(r),s=0;r>s;s++){for(var u=t[s],l=1;e.vertices.length>l;l++)for(var c=e.inputLayoutDescriptor.vertexBufferDescriptors[l].arrayStride/4,f=0;c>f;f++)e.vertices[l][a*c+f]=n[l][u*c+f];o[s]=a,a++}for(var d=Da.PICKING_COLOR+1;e.vertexBuffers.length>d;d++){var h=e.inputLayoutDescriptor.vertexBufferDescriptors[d],_=e.inputLayoutDescriptor.vertexBufferDescriptors[d].attributes[0];if(_)e.setVertexBuffer({bufferIndex:d,byteStride:h.arrayStride,stepMode:h.stepMode,attributes:[{format:_.format,bufferByteOffset:_.offset,location:_.shaderLocation,divisor:_.divisor}],data:e.vertices[d]})}for(var p=new Float32Array(3*r),E=0;r>E;)for(var v=0;3>v;v++){p[3*o[E++]+v]=1}e.setVertexBuffer({bufferIndex:Da.BARYCENTRIC,byteStride:12,stepMode:Te.VERTEX,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:Number(ba.BARYCENTRIC)}],data:p}),e.setIndexBuffer(o)}},{key:"beforeUploadUBO",value:function(e,t){}},{key:"uploadUBO",value:function(e){var r,n=this,i=this.material,a=this.lightPool.getAllLights(),s=this.lightPool.getFog(),u=!!s,l=null!==(r=i.defines.USE_LIGHT)&&void 0!==r?r:!!a.length,c=[];if(i.defines.USE_WIREFRAME){var f=t.parseColor(i.wireframeColor);c.push({name:"u_WireframeLineColor",value:[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255]}),c.push({name:"u_WireframeLineWidth",value:i.wireframeLineWidth})}if(u&&this.uploadFog(c,s),this.uploadMaterial(c,i),l){var d={};a.forEach((function(e){d[e.define]||(d[e.define]=-1),d[e.define]++,e.uploadUBO(c,d[e.define])}))}c.sort((function(e,t){return n.material.uniformNames.indexOf(e.name)-n.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,c);var h=i.blendEquation,_=i.blendEquationAlpha,p=i.blendSrc,E=i.blendDst,v=i.blendSrcAlpha,R=i.blendDstAlpha,m=Oa({blendConstant:i.blendConstant,depthCompare:i.depthCompare,depthWrite:i.depthWrite,stencilFront:i.stencilFront,stencilBack:i.stencilBack,stencilWrite:i.stencilWrite,stencilRef:i.stencilRef,cullMode:i.cullMode,frontFace:i.frontFace,polygonOffset:i.polygonOffset}),g=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(o({attachmentsState:[{channelWriteMask:this.material.stencilWrite?Ce.NONE:Ce.ALL,rgbBlendState:o(o({},g.rgbBlendState),Oa({blendMode:h,blendSrcFactor:p,blendDstFactor:E})),alphaBlendState:o(o({},g.alphaBlendState),Oa({blendMode:_,blendSrcFactor:v,blendDstFactor:R}))}]},m)),e.setBindingLayout({numUniformBuffers:1,numSamplers:this.textureMappings.length}),e.setSamplerBindingsFromTextureMappings(this.textureMappings)}},{key:"uploadFog",value:function(e,r){var n=r.parsedStyle,i=n.type,a=n.fill,o=n.start,s=n.end,u=n.density;if(t.isCSSRGB(a)){var l=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)];e.push({name:"u_FogInfos",value:[i,o,s,u]}),e.push({name:"u_FogColor",value:l})}}},{key:"uploadMaterial",value:function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,m(r))}},{key:"createFillGradientTextureMapping",value:function(e){var r,n=this,i=e[0],a=i.parsedStyle[this.gradientAttributeName];if(a&&(t.isPattern(a)||Array.isArray(a))){Array.isArray(a)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:a,width:128,height:128,instance:i})):t.isPattern(a)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(a,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var o=this.texturePool.getOrCreateTexture(this.context.device,r,Fe(be.U8_RGBA_NORM,1,1,1));if(o){var s=new ia;return s.name=Ba,s.texture=o,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.context.device.setResourceName(s.texture,"Fill Texture".concat(this.id)),s.sampler=this.renderHelper.getCache().createSampler({addressModeU:pe.CLAMP_TO_EDGE,addressModeV:pe.CLAMP_TO_EDGE,minFilter:Ee.POINT,magFilter:Ee.BILINEAR,mipmapFilter:ve.LINEAR,lodMinClamp:0,lodMaxClamp:0}),s}}return null}}])}(),Fa=function(e){return e[e.PACKED_STYLE=Da.POSITION+1]="PACKED_STYLE",e}(Fa||{}),Ua=function(e){return e[e.PACKED_STYLE3=ba.MAX]="PACKED_STYLE3",e[e.EXTRUDE=1+e.PACKED_STYLE3]="EXTRUDE",e[e.SIZE=1+e.EXTRUDE]="SIZE",e}(Ua||{}),ka=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],wa=function(e){function r(){return l(this,r),h(this,r,arguments)}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = EXTRUDE) in vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec3 a_StylePacked3;\nlayout(location = SIZE) in vec4 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec2 v_Data;\nout vec2 v_Radius;\nout vec3 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size.xy + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size.xy + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n\n bool isBillboard = a_Size.z > 0.5;\n if (isBillboard) {\n float rotation = 0.0;\n bool isSizeAttenuation = a_Size.w > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec2(a_Extrude * radius / radius.y);\n v_StylePacked3 = a_StylePacked3;\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec2 v_Data;\nin vec2 v_Radius;\nin vec3 v_StylePacked3;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n p = abs(p) - b + r;\n return length(max(p, 0.0)) + min(max(p.x, p.y), 0.0) - r;\n}\n\nvoid main() {\n int shape = int(floor(v_StylePacked3.x + 0.5));\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius.y;\n float wh = v_Radius.x / v_Radius.y;\n\n float dist = length(v_Data);\n float antialiased_blur = -fwidth(dist);\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data, 1.0);\n inner_df = sdCircle(v_Data, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data, r, useRadius ? (v_StylePacked3.y - u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Na(Ua))}},{key:"createGeometry",value:function(e){var t=this;A(r,"createGeometry",this,3)([e]);var n=[],i=[];e.forEach((function(e,r){var a=e,o=a.parsedStyle.radius,s=t.shouldOmitStroke(a.parsedStyle),u=t.getSize(e.parsedStyle,a.nodeName),l=t.getPosition(e.parsedStyle,a.nodeName);n.push.apply(n,m(u).concat([a.parsedStyle.isBillboard?1:0,a.parsedStyle.isSizeAttenuation?1:0,ka.indexOf(a.nodeName),o&&o[0]||0,s?1:0])),i.push.apply(i,m(l))})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Da.UV,byteStride:16,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:Ua.EXTRUDE},{format:be.F32_RG,bufferByteOffset:8,location:ba.UV}],data:new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1])}),this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:12,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:ba.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Fa.PACKED_STYLE,byteStride:28,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Ua.SIZE,divisor:1},{format:be.F32_RGB,bufferByteOffset:16,location:Ua.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)})}},{key:"updateAttribute",value:function(e,t,n,i){var a=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n||"isBillboard"===n||"isSizeAttenuation"===n){var o=[];e.forEach((function(e){var t=e,r=a.shouldOmitStroke(t.parsedStyle),n=C(a.getSize(e.parsedStyle,e.nodeName),2);o.push.apply(o,[n[0],n[1]].concat([t.parsedStyle.isBillboard?1:0,t.parsedStyle.isSizeAttenuation?1:0,ka.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0]))})),this.geometry.updateVertexBuffer(Fa.PACKED_STYLE,Ua.SIZE,t,new Uint8Array(new Float32Array(o).buffer))}else if("cx"===n||"cy"===n||"x"===n||"y"===n){var s=[];e.forEach((function(e){var t=C(a.getPosition(e.parsedStyle,e.nodeName),2);s.push(t[0],t[1])})),this.geometry.updateVertexBuffer(Da.POSITION,ba.POSITION,t,new Uint8Array(new Float32Array(s).buffer))}}},{key:"getPosition",value:function(e,r){var n=[0,0,0];if(r===t.Shape.CIRCLE||r===t.Shape.ELLIPSE){var i=e.cx,a=e.cy,o=e.cz;n=[void 0===i?0:i,void 0===a?0:a,void 0===o?0:o]}else if(r===t.Shape.RECT){var s=e.x,u=e.y,l=e.z;n=[void 0===s?0:s,void 0===u?0:u,void 0===l?0:l]}return n}},{key:"getSize",value:function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}else if(r===t.Shape.RECT){n=[e.width/2,e.height/2]}return n}},{key:"shouldOmitStroke",value:function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,a=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(a||1>n)}}])}(La);function Ga(e,t,r,n,i,a){for(var o=i[i.length-3],s=i[i.length-2],u=null!=a?a:x(ri(o,s,e,t,r,n,3)/10,8,100),l=0,c=0,f=1;u>=f;++f){var d=f/u;i.push((l=o+(e-o)*d)+(e+(r-e)*d-l)*d,(c=s+(t-s)*d)+(t+(n-t)*d-c)*d,0)}}function Va(e,t,r,n,i,a,o,s){var u=o[o.length-3],l=o[o.length-2];o.length-=3;var c=null!=s?s:x(ei(u,l,e,t,r,n,i,a,3)/10,8,100),f=0,d=0,h=0,_=0,p=0;o.push(u,l,0);for(var E=1,v=0;c>=E;++E)o.push((h=(d=(f=1-(v=E/c))*f)*f)*u+3*d*v*e+3*f*(_=v*v)*r+(p=_*v)*i,h*l+3*d*v*t+3*f*_*n+p*a,0)}var Xa=1e20,Wa=function(){return u((function e(t,r){l(this,e);var n=t.fontSize,i=void 0===n?24:n,a=t.buffer,o=void 0===a?3:a,s=t.radius,u=void 0===s?8:s,c=t.cutoff,f=void 0===c?.25:c,d=t.fontFamily,h=void 0===d?"sans-serif":d,_=t.fontWeight,p=void 0===_?"normal":_,E=t.fontStyle,v=void 0===E?"normal":E,R=t.canvas;this.buffer=o,this.cutoff=f,this.radius=u;var m=this.size=i+4*o,g=r.offscreenCanvasCreator.getOrCreateCanvas(R);g.width=m,g.height=m;var T=r.offscreenCanvasCreator.getOrCreateContext(R,{willReadFrequently:!0});this.ctx=T,T.font="".concat(v," ").concat(p," ").concat(i,"px ").concat(h),T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(m*m),this.gridInner=new Float64Array(m*m),this.f=new Float64Array(m),this.z=new Float64Array(m+1),this.v=new Uint16Array(m)}),[{key:"draw",value:function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,a=t.actualBoundingBoxRight,o=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),u=Math.min(this.size-this.buffer,o+Math.ceil(n)),l=s+2*this.buffer,c=u+2*this.buffer,f=Math.max(l*c,0),d=new Uint8ClampedArray(f),h={data:d,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:o,glyphLeft:0,glyphAdvance:r};if(0===s||0===u)return h;var _=this.ctx,p=this.buffer,E=this.gridInner,v=this.gridOuter;_.clearRect(p,p,s,u),_.fillText(e,p,p+o);var R=_.getImageData(p,p,s,u);v.fill(Xa,0,f),E.fill(0,0,f);for(var m=0;u>m;m++)for(var g=0;s>g;g++){var T=R.data[4*(m*s+g)+3]/255;if(0!==T){var A=(m+p)*l+g+p;if(1===T)v[A]=0,E[A]=Xa;else{var y=.5-T;v[A]=y>0?y*y:0,E[A]=0>y?y*y:0}}}Ha(v,0,0,l,c,l,this.f,this.v,this.z),Ha(E,p,p,s,u,l,this.f,this.v,this.z);for(var S=0;f>S;S++){d[S]=Math.round(255-255*((Math.sqrt(v[S])-Math.sqrt(E[S]))/this.radius+this.cutoff))}return h}}])}();function Ha(e,t,r,n,i,a,o,s,u){for(var l=t;t+n>l;l++)za(e,r*a+l,a,i,o,s,u);for(var c=r;r+i>c;c++)za(e,c*a+t,1,n,o,s,u)}function za(e,t,r,n,i,a,o){a[0]=0,o[0]=-Xa,o[1]=Xa,i[0]=e[t];for(var s=1,u=0,l=0;n>s;s++){i[s]=e[t+s*r];var c=s*s;do{var f=a[u];l=(i[s]-i[f]+c-f*f)/(s-f)/2}while(o[u]>=l&&--u>-1);a[++u]=s,o[u]=l,o[u+1]=Xa}for(var d=0,h=0;n>d;d++){for(;d>o[h+1];)h++;var _=a[h],p=d-_;e[t+d*r]=i[_]+p*p}}var Ya=function(e){return e[e.PACKED=Da.POSITION+1]="PACKED",e[e.VERTEX_NUM=1+e.PACKED]="VERTEX_NUM",e[e.TRAVEL=1+e.VERTEX_NUM]="TRAVEL",e[e.DASH=1+e.TRAVEL]="DASH",e}(Ya||{}),Ka=function(e){return e[e.PREV=ba.POSITION]="PREV",e[e.POINT1=1+e.PREV]="POINT1",e[e.POINT2=1+e.POINT1]="POINT2",e[e.NEXT=1+e.POINT2]="NEXT",e[e.VERTEX_JOINT=1+e.NEXT]="VERTEX_JOINT",e[e.VERTEX_NUM=1+e.VERTEX_JOINT]="VERTEX_NUM",e[e.TRAVEL=1+e.VERTEX_NUM]="TRAVEL",e[e.DASH=1+e.TRAVEL]="DASH",e}(Ka||{});function ja(e,t,r){return 4*(e?1:0)+2*(t?1:0)+(r?1:0)}function Za(e){if(!(e.nodeName===t.Shape.POLYLINE))return!1;var r=e.parsedStyle.points.points;return r.length&&!O(r[0][2])}var qa=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).segmentNum=-1,u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.segmentNum=u.calcSegmentNum(i),u.gradientAttributeName="stroke",u}return p(r,e),u(r,[{key:"calcSegmentNum",value:function(e){return eo(e,!1,12,this.calcSubpathIndex(e)).instancedCount}},{key:"calcSubpathIndex",value:function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===io})).length;return this.index-r}return 0}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);if(!n)return!1;if(this.index!==t)return!1;var i=this.calcSegmentNum(e);return this.segmentNum===i}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = PREV) in vec3 a_Prev;\nlayout(location = POINT1) in vec3 a_Point1;\nlayout(location = POINT2) in vec3 a_Point2;\nlayout(location = NEXT) in vec3 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\nout vec4 v_Dash;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nconst float u_Expand = 1.0;\nconst float u_MiterLimit = 5.0;\nconst float u_ScaleMode = 1.0;\nconst float u_Alignment = 0.5;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\nout float v_ScalingFactor;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvec2 clip2ScreenSpace(vec4 clip) {\n return u_Viewport * (0.5 * clip.xy / clip.w + 0.5);\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n v_Dash = a_Dash;\n\n vec2 pointA;\n vec2 pointB;\n vec4 clip0;\n vec4 clip1;\n\n float compressed = a_Dash.w;\n float is_billboard = floor(compressed / 4.0);\n compressed -= is_billboard * 4.0;\n float is_size_attenuation = floor(compressed / 2.0);\n compressed -= is_size_attenuation * 2.0;\n float is_3d_polyline = compressed;\n\n bool isBillboard = is_billboard > 0.5;\n bool isSizeAttenuation = is_size_attenuation > 0.5;\n bool is3DPolyline = is_3d_polyline > 0.5;\n if (isBillboard) {\n clip0 = billboard(a_Point1.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n clip1 = billboard(a_Point2.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else if (is3DPolyline) {\n clip0 = project(vec4(a_Point1, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = project(vec4(a_Point2, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n if (isBillboard || is3DPolyline) {\n pointA = clip2ScreenSpace(clip0);\n pointB = clip2ScreenSpace(clip1);\n } else {\n pointA = (u_ModelMatrix * vec4(a_Point1, 1.0)).xy;\n pointB = (u_ModelMatrix * vec4(a_Point2, 1.0)).xy;\n }\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Prev.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Prev, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Prev, 1.0)).xy;\n }\n\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Next.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Next, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 1.0)).xy;\n }\n \n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n // TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n v_ScalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n\n if (isBillboard || is3DPolyline) {\n vec4 clip = mix(clip0, clip1, 0.5);\n gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\nin float v_ScalingFactor;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Na(Ka))}},{key:"createGeometry",value:function(e){var t=this,n=[],i=[],a=[],o=[],s=0,u=0;e.forEach((function(e){var r=eo(e,!1,12,t.calcSubpathIndex(e)),l=r.pointsBuffer,c=r.travelBuffer,f=r.instancedCount,d=e.parsedStyle,h=d.lineDash;o.push(h&&h[0]||0,h&&h[1]||0,d.lineDashOffset||0,ja(d.isBillboard,d.isSizeAttenuation,Za(e))),s+=f;for(var _=0;l.length-12>_;_+=4)i.push(l[_],l[_+1],l[_+2],l[_+3],l[_+4],l[_+5],l[_+6],l[_+7],l[_+8],l[_+9],l[_+10],l[_+11],l[_+12],l[_+13],l[_+14],l[_+15]);a.push.apply(a,m(c)),n.push(0+u,2+u,1+u,0+u,3+u,2+u,4+u,6+u,5+u,4+u,7+u,6+u,4+u,7+u,8+u),u+=9})),i.length&&(this.geometry.setVertexBuffer({bufferIndex:Ya.PACKED,byteStride:64,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:Ka.PREV,divisor:1},{format:be.F32_RGB,bufferByteOffset:16,location:Ka.POINT1,divisor:1},{format:be.F32_R,bufferByteOffset:28,location:Ka.VERTEX_JOINT,divisor:1},{format:be.F32_RGB,bufferByteOffset:32,location:Ka.POINT2,divisor:1},{format:be.F32_RGB,bufferByteOffset:48,location:Ka.NEXT,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Ya.VERTEX_NUM,byteStride:4,stepMode:Te.INSTANCE,attributes:[{format:be.F32_R,bufferByteOffset:0,byteStride:4,location:Ka.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:Ya.TRAVEL,byteStride:4,stepMode:Te.INSTANCE,attributes:[{format:be.F32_R,bufferByteOffset:0,byteStride:4,location:Ka.TRAVEL,divisor:1}],data:new Float32Array(a)}),this.divisor=s/e.length,this.geometry.setVertexBuffer({bufferIndex:Ya.DASH,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Ka.DASH,divisor:this.divisor}],data:new Float32Array(o)}),A(r,"createGeometry",this,3)([e]),this.geometry.vertexCount=15,this.geometry.instancedCount=s,this.geometry.setIndexBuffer(new Uint32Array(n)))}},{key:"updateAttribute",value:function(e,t,n,i){var a=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"radius"===n||"x1"===n||"y1"===n||"x2"===n||"y2"===n||"points"===n||"path"===n||"d"===n||"lineJoin"===n||"lineCap"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var o=[],s=[],u=0;e.forEach((function(e){var t=eo(e,!1,12,a.calcSubpathIndex(e)),r=t.pointsBuffer,n=t.travelBuffer;u=t.instancedCount;for(var i=0;r.length-12>i;i+=4)o.push(r[i],r[i+1],r[i+2],r[i+3],r[i+4],r[i+5],r[i+6],r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]);s.push.apply(s,m(n))})),this.geometry.updateVertexBuffer(Ya.PACKED,Ka.PREV,t*u,new Uint8Array(new Float32Array(o).buffer)),this.geometry.updateVertexBuffer(Ya.TRAVEL,Ka.TRAVEL,t,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n||"isSizeAttenuation"===n){var l=[];e.forEach((function(e){var t=e.parsedStyle,r=t.lineDash;l.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,ja(t.isBillboard,t.isSizeAttenuation,Za(e)))})),this.geometry.updateVertexBuffer(Ya.DASH,Ka.DASH,t,new Uint8Array(new Float32Array(l).buffer))}}}],[{key:"calcSubpathNum",value:function(e){return e.nodeName===t.Shape.PATH?e.parsedStyle.d.absolutePath.filter((function(e){return"M"===e[0]})).length:1}}])}(La),Qa=function(e){return e[e.NONE=0]="NONE",e[e.FILL=1]="FILL",e[e.JOINT_BEVEL=4]="JOINT_BEVEL",e[e.JOINT_MITER=8]="JOINT_MITER",e[e.JOINT_ROUND=12]="JOINT_ROUND",e[e.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",e[e.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",e[e.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",e[e.FILL_EXPAND=24]="FILL_EXPAND",e[e.CAP_BUTT=32]="CAP_BUTT",e[e.CAP_SQUARE=64]="CAP_SQUARE",e[e.CAP_ROUND=96]="CAP_ROUND",e[e.CAP_BUTT2=128]="CAP_BUTT2",e}({}),$a=3,Ja=4;function eo(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=e.parsedStyle,o=a.lineCap,s=a.lineJoin,u=e.sortable.renderOrder*Aa,l=0,c=0,f=e.parsedStyle,d=f.markerStart,h=f.markerEnd,_=f.markerStartOffset,p=f.markerEndOffset,E=[],g=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var T=e.parsedStyle.points.points,A=T.length,P=0,N=0,M=0,O=0,I=0;d&&t.isDisplayObject(d)&&_&&(P=Math.cos(I=Math.atan2(T[1][1]-T[0][1],T[1][0]-T[0][0]))*(_||0),N=Math.sin(I)*(_||0)),h&&t.isDisplayObject(h)&&p&&(M=Math.cos(I=Math.atan2(T[A-2][1]-T[A-1][1],T[A-2][0]-T[A-1][0]))*(p||0),O=Math.sin(I)*(p||0));var x=e.nodeName===t.Shape.POLYLINE;if(E[0]=T.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=P,i=N):r===A-1&&(n=M,i=O),e.push(t[0]+n,t[1]+i,x?t[2]||0:u),e}),[]),e.nodeName===t.Shape.POLYGON){var B;if(r)return g=qn(E[0],[],3),{pointsBuffer:E[0],travelBuffer:[],triangles:g,instancedCount:Math.round(E[0].length/$a)};E[0].push(E[0][0],E[0][1],E[0][2]||u),(B=E[0]).push.apply(B,m(to(E[0][0],E[0][1],E[0][2]||u,E[0][3],E[0][4],E[0][5]||u)))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var D;if(e.nodeName!==t.Shape.PATH){if(D=t.parsePath(t.convertToPath(e,k(L()))),e.nodeName===t.Shape.RECT){var b=e.parsedStyle;0>b.width&&(l+=D.rect.width),0>b.height&&(c+=D.rect.height)}}else D=e.parsedStyle.d;var F=D.absolutePath,U=D.segments,w=0,G=0,V=0,X=0,W=0;if(d&&d.parentNode&&t.isDisplayObject(d)&&_){var H=C(d.parentNode.getStartTangent(),2),z=H[0],Y=H[1];w=Math.cos(W=Math.atan2(z[1]-Y[1],z[0]-Y[0]))*(_||0),G=Math.sin(W)*(_||0)}if(h&&h.parentNode&&t.isDisplayObject(h)&&p){var K=C(h.parentNode.getEndTangent(),2),j=K[0],Z=K[1];V=Math.cos(W=Math.atan2(j[1]-Z[1],j[0]-Z[0]))*(p||0),X=Math.sin(W)*(p||0)}var q=-1,Q=-1;if(F.forEach((function(r,i){var a,o=y(a=r)||v(a)||R(a)||S(),s=o[0],f=o.slice(1),d=F[i+1],h=0===i&&(0!==w||0!==G),_=(i===F.length-1||d&&("M"===d[0]||"Z"===d[0]))&&0!==V&&0!==X;if("M"===s)Q++,E[Q]=[],q=E[Q].length,h?E[Q].push(f[0]-l+w,f[1]-c+G,u,f[0]-l,f[1]-c,u):E[Q].push(f[0]-l,f[1]-c,u);else if("L"===s)_?E[Q].push(f[0]-l+V,f[1]-c+X,u):E[Q].push(f[0]-l,f[1]-c,u);else if("Q"===s)Ga(f[0]-l,f[1]-c,f[2]-l,f[3]-c,E[Q],n),_&&E[Q].push(f[2]-l+V,f[3]-c+X,u);else if("A"===s){for(var p=C(U[i].prePoint,2),g=oe(p[0],p[1],f[0],f[1],f[2],f[3],f[4],f[5],f[6],void 0),T=0;g.length>T;T+=6)Va(g[T]-l,g[T+1]-c,g[T+2]-l,g[T+3]-c,g[T+4]-l,g[T+5]-c,E[Q],n);_&&E[Q].push(f[5]-l+V,f[6]-c+X,u)}else if("C"===s)Va(f[0]-l,f[1]-c,f[2]-l,f[3]-c,f[4]-l,f[5]-c,E[Q],n),_&&E[Q].push(f[4]-l+V,f[5]-c+X,u);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var A,P=1e-4;(Math.abs(E[Q][E[Q].length-2]-E[Q][q])>P||Math.abs(E[Q][E[Q].length-1]-E[Q][q+1])>P)&&E[Q].push(E[Q][q],E[Q][q+1],u),(A=E[Q]).push.apply(A,m(to(E[Q][q],E[Q][q+1],E[Q][q+2],E[Q][q+3],E[Q][q+4],E[Q][q+5])))}})),r){var $=E[i];return{pointsBuffer:$,travelBuffer:[],triangles:g=qn($,[],3),instancedCount:Math.round($.length/$a)}}}var J=function(e){var t;switch(e){case"bevel":t=Qa.JOINT_BEVEL;break;case"round":t=Qa.JOINT_ROUND;break;default:t=Qa.JOINT_MITER}return t}(s),ee=function(e){var t;switch(e){case"square":t=Qa.CAP_SQUARE;break;case"round":t=Qa.CAP_ROUND;break;default:t=Qa.CAP_BUTT}return t}(o),te=ee;ee===Qa.CAP_ROUND&&(te=Qa.JOINT_CAP_ROUND),ee===Qa.CAP_BUTT&&(te=Qa.JOINT_CAP_BUTT),ee===Qa.CAP_SQUARE&&(te=Qa.JOINT_CAP_SQUARE);for(var re=E[i],ne=(Math.round(0/$a)+2)*Ja,ie=0,ae=[],se=[],ue=0;re.length>ue;ue+=$a)ue>1&&(ie+=Math.sqrt(Math.pow(re[ue]-re[ue-$a],2)+Math.pow(re[ue+1]-re[ue+1-$a],2)+Math.pow(re[ue+2]-re[ue+2-$a],2))),se.push(ie),ae[ne++]=re[ue],ae[ne++]=re[ue+1],ae[ne++]=re[ue+2]||0,ae[ne]=J,0===ue&&ee!==Qa.CAP_ROUND&&(ae[ne]+=ee),re.length>ue+2*$a?re.length>ue+$a||(ae[ne]=0):ae[ne]+=te-J,ne++;return ae[ne++]=re[re.length-6],ae[ne++]=re[re.length-5],ae[ne++]=re[re.length-4]||u,ae[ne++]=0,ae[0]=re[0],ae[1]=re[1],ae[2]=re[2]||u,ae[3]=0,ae[4]=re[3],ae[5]=re[4],ae[6]=re[5]||u,ae[7]=ee===Qa.CAP_ROUND?ee:0,{pointsBuffer:ae,travelBuffer:se,triangles:g,instancedCount:Math.round(re.length/$a)}}function to(e,t,r){var n=[(arguments.length>3&&void 0!==arguments[3]?arguments[3]:e)-e,(arguments.length>4&&void 0!==arguments[4]?arguments[4]:t)-t,(arguments.length>5&&void 0!==arguments[5]?arguments[5]:r)-r],i=.01;return[e+n[0]*i,t+n[1]*i,r+n[2]*i]}var ro=function(e){return e[e.PACKED_STYLE=Da.POSITION+1]="PACKED_STYLE",e}(ro||{}),no=function(e){return e[e.PACKED_STYLE3=ba.MAX]="PACKED_STYLE3",e}(no||{}),io=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).trianglesHash=[[],[]],u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.trianglesHash=u.calcSegmentNum(i),u}return p(r,e),u(r,[{key:"calcSegmentNum",value:function(e){var t=eo(e,!0,12,this.calcSubpathIndex(e));return[t.triangles,t.pointsBuffer]}},{key:"calcSubpathIndex",value:function(e){return e.nodeName===t.Shape.PATH?this.index:0}},{key:"compareTrianglesHash",value:function(e){var t=C(this.trianglesHash,2),r=t[0],n=t[1],i=C(e,2),a=i[0],o=i[1];return r.length===a.length&&n.length===o.length&&(!r.some((function(e,t){return e!==a[t]}))&&!n.some((function(e,t){return e!==o[t]})))}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);if(!n)return!1;if(this.index!==t)return!1;var i=this.calcSegmentNum(e);return this.compareTrianglesHash(i)}},{key:"createGeometry",value:function(e){var t=this,n=[],i=[],a=[],o=0;if(e.forEach((function(e,r){var s=eo(e,!0,12,t.calcSubpathIndex(e)),u=s.triangles,l=s.pointsBuffer;if(u.length){var c=e.getGeometryBounds().halfExtents,f=[];l.forEach((function(e,t){t%3!=2&&f.push(e/c[t%3]/2)})),o+=i.length/3,i.push.apply(i,m(l)),a.push.apply(a,f),n.push.apply(n,m(u.map((function(e){return e+o}))))}})),i.length){A(r,"createGeometry",this,3)([e]);var s=[];e.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:12,stepMode:Te.VERTEX,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:ba.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:ro.PACKED_STYLE,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:no.PACKED_STYLE3,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Da.UV,byteStride:8,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:ba.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length/e.length,this.geometry.setIndexBuffer(new Uint32Array(n))}}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(a_Position.xy, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else {\n gl_Position = project(vec4(a_Position.xy, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}",this.material.defines=o(o(o({},this.material.defines),Na(no)),{},{INSTANCED:!0})}},{key:"updateAttribute",value:function(e,t,n,i){if(0!==e.length&&(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n)){var a=[];e.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;a.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(ro.PACKED_STYLE,no.PACKED_STYLE3,t,new Uint8Array(new Float32Array(a).buffer))}}}])}(La),ao=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1],oo=function(e){return e[e.POINT=Da.POSITION+1]="POINT",e[e.CAP=1+e.POINT]="CAP",e[e.DASH=1+e.CAP]="DASH",e}(oo||{}),so=function(e){return e[e.POSITION=ba.POSITION]="POSITION",e[e.UV=ba.UV]="UV",e[e.POINTA=ba.NORMAL]="POINTA",e[e.POINTB=ba.BARYCENTRIC]="POINTB",e[e.CAP=ba.MAX]="CAP",e[e.DASH=ba.MAX+1]="DASH",e}(so||{}),uo={butt:1,round:2,square:3},lo=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).renderHelper=e,u.texturePool=t,u.lightPool=n,u.gradientAttributeName="stroke",u}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n float clampedStrokeWidth = max(strokeWidth, 1.0);\n\n bool isSizeAttenuation = a_Dash.w > 0.5;\n if (isSizeAttenuation) {\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * clampedStrokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(clampedStrokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur;\n if (v_Distance.y < 1.0) {\n blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n } else {\n blur = 1.0 / v_Distance.y;\n }\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * max(blur, 0.5)\n * u_Opacity * u_StrokeOpacity\n * (u_dash_array < 1.0 ? (ceil((u_dash_array * u_dash_ratio) - mod(v_Dash.x + u_dash_offset, u_dash_array))) : 1.0);\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Na(so))}},{key:"calcSubpathIndex",value:function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===io})).length;return this.index-r}return 0}},{key:"createGeometry",value:function(e){var n=this;A(r,"createGeometry",this,3)([e]);var i=[],a=[],o=[],s=[],u=0;e.forEach((function(e){var r,l;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,l=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,lineCap:c.lineCap,lineDash:c.lineDash,lineDashOffset:c.lineDashOffset,isBillboard:c.isBillboard,isSizeAttenuation:c.isSizeAttenuation,markerStart:c.markerStart,markerEnd:c.markerEnd,markerStartOffset:c.markerStartOffset,markerEndOffset:c.markerEndOffset},l=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){for(var d=e.parsedStyle,h=d.d.absolutePath,_=d.lineCap,p=d.lineDash,E=d.lineDashOffset,v=d.markerStart,R=d.markerEnd,m=d.markerStartOffset,g=d.markerEndOffset,T=d.isBillboard,A=d.isSizeAttenuation,y=0,S=0,C=n.calcSubpathIndex(e),P=0;h.length>P;P++){if("M"===h[P][0]){if(y===C){S=P;break}y++}}r={x1:h[S][1],y1:h[S][2],x2:h[S+1][1],y2:h[S+1][2],z1:0,z2:0,lineCap:_,lineDash:p,lineDashOffset:E,isBillboard:T,isSizeAttenuation:A,markerStart:v,markerEnd:R,markerStartOffset:m,markerEndOffset:g},l=e.getTotalLength()}var N=r.x1,M=r.y1,O=r.x2,I=r.y2,x=r.z1,B=r.z2,D=r.lineCap,b=r.isBillboard,L=r.isSizeAttenuation,F=n.calcOffset(r),U=F.startOffsetX,k=F.startOffsetY,w=F.endOffsetX,G=F.endOffsetY,V=n.calcDash(r,l),X=V.dashOffset,W=V.dashSegmentPercent,H=V.dashRatioInEachSegment;a.push(uo[D]),o.push(X,W,H,b||L?1:0),i.push(N+U,M+k,x,O+w,I+G,B),s.push(0+u,2+u,1+u,0+u,3+u,2+u),u+=4})),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:20,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:so.POSITION,divisor:0},{format:be.F32_RG,bufferByteOffset:12,location:so.UV,divisor:0}],data:new Float32Array(ao)}),this.geometry.setVertexBuffer({bufferIndex:oo.POINT,byteStride:24,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:so.POINTA,divisor:1},{format:be.F32_RGB,bufferByteOffset:12,location:so.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:oo.CAP,byteStride:4,stepMode:Te.INSTANCE,attributes:[{format:be.F32_R,bufferByteOffset:0,location:so.CAP,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:oo.DASH,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:so.DASH,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,n,i,a){var o=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,n,i,a]),this.updateBatchedAttribute(e,n,i,a),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"d"===i){var s=[];e.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,lineCap:n.lineCap,isSizeAttenuation:n.isSizeAttenuation,isBillboard:n.isBillboard,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH){var a=e.parsedStyle,u=a.d.absolutePath;r={x1:u[0][1],y1:u[0][2],x2:u[1][1],y2:u[1][2],z1:0,z2:0,lineCap:a.lineCap,isBillboard:a.isBillboard,isSizeAttenuation:a.isSizeAttenuation,markerStart:a.markerStart,markerEnd:a.markerEnd,markerStartOffset:a.markerStartOffset,markerEndOffset:a.markerEndOffset}}var l=r.x1,c=r.y1,f=r.x2,d=r.y2,h=r.z1,_=r.z2,p=o.calcOffset(r);s.push(l+p.startOffsetX,c+p.startOffsetY,h,f+p.endOffsetX,d+p.endOffsetY,_)})),this.geometry.updateVertexBuffer(oo.POINT,so.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isSizeAttenuation"===i||"isBillboard"===i){var u=[];e.forEach((function(e){var t=e.getTotalLength(),r=o.calcDash(e.parsedStyle,t);u.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard||e.parsedStyle.isSizeAttenuation?1:0)})),this.geometry.updateVertexBuffer(oo.DASH,so.DASH,n,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===i){var l=[];e.forEach((function(e){l.push(uo[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(oo.CAP,so.CAP,n,new Uint8Array(new Float32Array(l).buffer))}}},{key:"calcOffset",value:function(e){var r=e.x1,n=e.y1,i=e.x2,a=e.y2,o=e.markerStart,s=e.markerEnd,u=e.markerStartOffset,l=e.markerEndOffset,c=0,f=0,d=0,h=0,_=0;return o&&t.isDisplayObject(o)&&u&&(c=Math.cos(_=Math.atan2(a-n,i-r))*(u||0),f=Math.sin(_)*(u||0)),s&&t.isDisplayObject(s)&&l&&(d=Math.cos(_=Math.atan2(n-a,r-i))*(l||0),h=Math.sin(_)*(l||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:d,endOffsetY:h}}},{key:"calcDash",value:function(e,t){var r=e.lineDash,n=0,i=1,a=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var o=r.reduce((function(e,t){return e+t}),0);0===o?(i=1,a=0):(i=o/t,a=r[1]/o)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:a}}}],[{key:"isLine",value:function(e,r){if(e.nodeName===t.Shape.PATH){for(var n=e.parsedStyle.d.absolutePath,i=0,a=0,o=0;n.length>o;o++){if("M"===n[o][0]){if(i===r){a=o;break}i++}}if("M"===n[a][0]&&"L"===n[a+1][0]&&(void 0===n[a+2]||"M"===n[a+2][0]))return!0}else if(e.nodeName===t.Shape.POLYLINE){for(var s=e.parsedStyle.points.points,u=(s[1][0]-s[1][1])/(s[0][0]-s[0][1]),l=1;s.length-1>l;l++)if((s[l+1][0]-s[l+1][1])/(s[l][0]-s[l][1])!==u)return!1;return!0}return!1}}])}(La),co=function(e){return e[e.PACKED_STYLE=Da.POSITION+1]="PACKED_STYLE",e[e.SIZE=Da.MAX]="SIZE",e}(co||{}),fo=function(e){return e[e.PACKED_STYLE3=ba.MAX]="PACKED_STYLE3",e[e.SIZE=1+e.PACKED_STYLE3]="SIZE",e}(fo||{}),ho=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"shouldMerge",value:function(e,r){var n=A(t,"shouldMerge",this,3)([e,r]);return!!n&&this.instance.parsedStyle.src===e.parsedStyle.src}},{key:"createMaterial",value:function(e){var t=e[0].parsedStyle.src;this.material.defines=o(o({},this.material.defines),Na(fo)),this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = SIZE) in vec2 a_Size;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n // TODO: pointer-events: non-transparent-pixel\n // if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n // discard;\n // }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}";var r=this.texturePool.getOrCreateTexture(this.context.device,t,void 0);this.material.setUniforms({u_Map:r})}},{key:"createGeometry",value:function(e){A(t,"createGeometry",this,3)([e]);var r=[],n=[],i=[];e.forEach((function(e,t){var a=e.parsedStyle,o=a.x,s=a.y,u=a.z,l=a.width,c=a.height,f=a.isBillboard,d=a.billboardRotation,h=a.isSizeAttenuation;r.push(void 0===o?0:o,void 0===s?0:s,void 0===u?0:u),n.push(l,c),i.push(f?1:0,null!=d?d:0,h?1:0,0)})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:12,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:ba.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:co.SIZE,byteStride:8,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:fo.SIZE}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:co.PACKED_STYLE,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:fo.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Da.UV,byteStride:8,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:ba.UV}],data:new Float32Array([0,0,1,0,1,1,0,1])})}},{key:"updateAttribute",value:function(e,r,n,i){if(0!==e.length)if(A(t,"updateAttribute",this,3)([e,r,n,i]),this.updateBatchedAttribute(e,r,n,i),"x"===n||"y"===n||"z"===n){var a=[];e.forEach((function(e){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;a.push(void 0===r?0:r,void 0===n?0:n,void 0===i?0:i)})),this.geometry.updateVertexBuffer(Da.POSITION,ba.POSITION,r,new Uint8Array(new Float32Array(a).buffer))}else if("width"===n||"height"===n){var o=[];e.forEach((function(e){var t=e.parsedStyle;o.push(t.width,t.height)})),this.geometry.updateVertexBuffer(co.SIZE,fo.SIZE,r,new Uint8Array(new Float32Array(o).buffer))}else if("isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var s=[];e.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(co.PACKED_STYLE,fo.PACKED_STYLE3,r,new Uint8Array(new Float32Array(s).buffer))}else if("src"===n){var u=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:u})}}}])}(La);function _o(e,t,r,n){var i=t.width,a=t.height;if(n){if(n.length!==i*a*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*a*r);return e.width=i,e.height=a,e.data=n,e}function po(e,t,r,n,i,a){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=e.data,s=t.data,u=0;i.height>u;u++)for(var l=((r.y+u)*e.width+r.x)*a,c=((n.y+u)*t.width+n.x)*a,f=0;i.width*a>f;f++)s[c+f]=o[l+f];return t}var Eo=function(){function e(t,r){l(this,e),_o(this,t,1,r)}return u(e,[{key:"resize",value:function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var a=_o({},{width:n,height:i},r);po(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=a.data}}(this,e,1)}},{key:"clone",value:function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}}],[{key:"copy",value:function(e,t,r,n,i){po(e,t,r,n,i,1)}}])}();var vo=u((function e(t){l(this,e);var r={},n=[];for(var i in t){var a=t[i],o=r[i]={};for(var s in a){var u=a[+s];if(u&&0!==u.bitmap.width&&0!==u.bitmap.height){var c={x:0,y:0,w:u.bitmap.width+2,h:u.bitmap.height+2};n.push(c),o[s]={rect:c,metrics:u.metrics}}}}var f=function(e){var t,r=0,n=0,i=An(e);try{for(i.s();!(t=i.n()).done;){var a=t.value;r+=a.w*a.h,n=Math.max(n,a.w)}}catch(e){i.e(e)}finally{i.f()}e.sort((function(e,t){return t.h-e.h}));var o,s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}],u=0,l=0,c=An(e);try{for(c.s();!(o=c.n()).done;)for(var f=o.value,d=s.length-1;d>=0;d--){var h=s[d];if(h.w>=f.w&&h.h>=f.h){if(f.x=h.x,f.y=h.y,l=Math.max(l,f.y+f.h),u=Math.max(u,f.x+f.w),f.w===h.w&&f.h===h.h){var _=s.pop();s.length>d&&(s[d]=_)}else f.h===h.h?(h.x+=f.w,h.w-=f.w):f.w===h.w?(h.y+=f.h,h.h-=f.h):(s.push({x:h.x+f.w,y:h.y,w:h.w-f.w,h:f.h}),h.y+=f.h,h.h-=f.h);break}}}catch(e){c.e(e)}finally{c.f()}return{w:u,h:l,fill:r/(u*l)||0}}(n),d=new Eo({width:f.w||1,height:f.h||1});for(var h in t){var _=t[h];for(var p in _){var E=_[+p];if(E&&0!==E.bitmap.width&&0!==E.bitmap.height){var v=r[h][p].rect;Eo.copy(E.bitmap,d,{x:0,y:0},{x:v.x+1,y:v.y+1},E.bitmap)}}}this.image=d,this.positions=r}));var Ro=function(){return u((function e(t){l(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={},this.runtime=t}),[{key:"destroy",value:function(){this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy()}},{key:"getMap",value:function(){return this.glyphMap}},{key:"getAtlas",value:function(){return this.glyphAtlas}},{key:"getAtlasTexture",value:function(){return this.glyphAtlasTexture}},{key:"layout",value:function(e,t,r,n,i,a,o){var s=this,u=[],l=a,c=o,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach((function(e){var n=u.length;Array.from(e).forEach((function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),a=r&&r[n];a&&(u.push({glyph:n,x:l,y:c,scale:1,fontStack:t}),l+=a.metrics.advance+i)}));for(var a=l-i,o=n;u.length>o;o++)u[o].x-=f*a;l=0,c+=r})),u}},{key:"generateAtlas",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,l=[];this.glyphMap[r]||(l=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[r]||{});if(Array.from(new Set(s.split(""))).forEach((function(e){-1===c.indexOf(""+e.charCodeAt(0))&&l.push(e)})),l.length){var f=l.map((function(o){return t.generateSDF(e,r,n,i,a,o)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[r]=o(o({},this.glyphMap[r]),f),this.glyphAtlas=new vo(this.glyphMap);var d=this.glyphAtlas.image,h=d.width,_=d.height,p=d.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=u.createTexture(o(o({},Fe(be.ALPHA,h,_,1)),{},{pixelStore:{unpackFlipY:!1,unpackAlignment:1}})),this.glyphAtlasTexture.setImageData([p])}}},{key:"generateSDF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=a.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new Wa({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25},this.runtime)),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][a]||(this.textMetricsCache[t][a]=s.ctx.measureText(a).width);var u=s.draw(a),l=u.glyphWidth,c=u.glyphHeight,f=u.glyphLeft,d=u.glyphTop,h=u.glyphAdvance;return{id:o,bitmap:new Eo({width:u.width,height:u.height},u.data),metrics:{width:l,height:c,left:f,top:d-24+3,advance:h}}}}])}();var mo=function(e){return e[e.INSTANCED=Da.POSITION+1]="INSTANCED",e[e.TEX=1+e.INSTANCED]="TEX",e}(mo||{}),go=function(e){return e[e.TEX=ba.MAX]="TEX",e[e.OFFSET=1+e.TEX]="OFFSET",e}(go||{}),To=function(e){return e.SDF_MAP="u_SDFMap",e.SDF_MAP_SIZE="u_SDFMapSize",e.FONT_SIZE="u_FontSize",e.GAMMA_SCALE="u_GammaScale",e.STROKE_BLUR="u_StrokeBlur",e.HAS_STROKE="u_HasStroke",e}({}),Ao=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).packedBufferObjectMap=new WeakMap,u.tmpMat4=L(),u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.fontHash=u.calcFontHash(i),u.glyphManager=new Ro(u.context),u}return p(r,e),u(r,[{key:"calcFontHash",value:function(e){e.getBounds();return e.parsedStyle.metrics.font+["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].reduce((function(t,r){return t+e.parsedStyle[r]}),"")}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n&&(this.index===t&&this.fontHash===this.calcFontHash(e))}},{key:"createGeometry",value:function(e){var t=this,r=this.instance,n=r.parsedStyle,i=n.fontSize,a=n.letterSpacing,o=void 0===a?0:a,s=r.parsedStyle.textBaseline,u=void 0===s?"alphabetic":s,l=24/(void 0===i?16:i),c=[],f=[],d=[],h=[],_=0;e.forEach((function(e){var r=e.parsedStyle,n=r.metrics,i=r.dx,a=r.dy,s=n.font,p=n.lines,E=n.height,v=n.lineHeight,R=void 0===i?0:i,g=void 0===a?0:a;"alphabetic"===u&&(u="bottom");var T=0;"middle"===u?T+=-E/2:"bottom"===u?T+=-E:"top"===u||"hanging"===u?T+=0:"ideographic"===u&&(T+=-E);var A=t.glyphManager.getAtlas(),y=t.buildTextBuffers({object:e,lines:p,fontStack:s,lineHeight:l*v,offsetX:l*R,offsetY:l*(T+g),letterSpacing:l*o,glyphAtlas:A,indicesOffset:_}),S=y.indexBuffer,C=y.charUVOffsetBuffer,P=y.charPositionsBuffer;_=y.indicesOffset;var N=h.length;h.push.apply(h,m(y.charPackedBuffer)),t.packedBufferObjectMap.set(e,[N,h.length]),d.push.apply(d,m(C)),f.push.apply(f,m(P)),c.push.apply(c,m(S))})),this.geometry.vertexCount=c.length,this.geometry.setIndexBuffer(new Uint32Array(c)),this.geometry.setVertexBuffer({bufferIndex:mo.INSTANCED,byteStride:128,stepMode:Te.VERTEX,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.MODEL_MATRIX0},{format:be.F32_RGBA,bufferByteOffset:16,location:ba.MODEL_MATRIX1},{format:be.F32_RGBA,bufferByteOffset:32,location:ba.MODEL_MATRIX2},{format:be.F32_RGBA,bufferByteOffset:48,location:ba.MODEL_MATRIX3},{format:be.F32_RGBA,bufferByteOffset:64,location:ba.PACKED_COLOR},{format:be.F32_RGBA,bufferByteOffset:80,location:ba.PACKED_STYLE1},{format:be.F32_RGBA,bufferByteOffset:96,location:ba.PACKED_STYLE2},{format:be.F32_RGBA,bufferByteOffset:112,location:ba.PICKING_COLOR}],data:new Float32Array(h)}),this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:12,stepMode:Te.VERTEX,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:ba.POSITION}],data:new Float32Array(f)}),this.geometry.setVertexBuffer({bufferIndex:mo.TEX,byteStride:16,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:go.TEX},{format:be.F32_RG,bufferByteOffset:8,location:go.OFFSET}],data:new Float32Array(d)})}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n vec2 bufferOffset = vec2(0.7, 2.0);\n vec2 offset = a_Offset * fontScale + + bufferOffset;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked2.w;\n bool isSizeAttenuation = a_StylePacked2.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position );\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float fontScale = u_FontSize / 24.0;\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = fwidth(dist);\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < epsilon) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=de.BACK,this.material.defines=o(o({},this.material.defines),Na(go));var t=this.instance.parsedStyle,r=t.fontSize,n=void 0===r?16:r,a=t.fontFamily,s=void 0===a?"sans-serif":a,u=t.fontWeight,l=void 0===u?"normal":u,c=t.fontStyle,f=void 0===c?"normal":c,d=t.metrics.font,h=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,d,s,""+l,f,h,this.context.device);var _=this.glyphManager.getAtlasTexture(),p=this.glyphManager.getAtlas();this.context.device.setResourceName(_,"TextSDF Texture");var E=p.image,v=E.width,R=E.height;this.material.setUniforms(i(i(i(i(i(i({},To.SDF_MAP,_),To.SDF_MAP_SIZE,[v,R]),To.FONT_SIZE,n),To.GAMMA_SCALE,1),To.STROKE_BLUR,.2),To.HAS_STROKE,this.index))}},{key:"changeRenderOrder",value:function(e,t){for(var r=this.geometry.vertices[mo.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[mo.INSTANCED].arrayStride/4,i=C(this.packedBufferObjectMap.get(e),2),a=i[0],o=i[1],s=r.slice(a,o),u=0;o-a>u;u+=n)s[u+n-1]=t*Aa;this.geometry.updateVertexBuffer(mo.INSTANCED,ba.MODEL_MATRIX0,a/n,new Uint8Array(s.buffer))}},{key:"updateAttribute",value:function(e,n,i,a){var o=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,n,i,a]),"text"===i||"fontFamily"===i||"fontSize"===i||"fontWeight"===i||"fontStyle"===i||"fontVariant"===i||"textBaseline"===i||"letterSpacing"===i||"wordWrapWidth"===i||"lineHeight"===i||"wordWrap"===i||"textAlign"===i||"x"===i||"y"===i||"dx"===i||"dy"===i)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===i||"fill"===i||"fillOpacity"===i||"stroke"===i||"strokeOpacity"===i||"opacity"===i||"lineWidth"===i||"visibility"===i||"pointerEvents"===i||"isBillboard"===i||"billboardRotation"===i||"isSizeAttenuation"===i){var s=this.geometry.vertices[mo.INSTANCED],u=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[mo.INSTANCED].arrayStride/4;e.forEach((function(e){var r,n=e.parsedStyle,i=n.fill,a=n.stroke,l=n.opacity,c=void 0===l?1:l,f=n.fillOpacity,d=void 0===f?1:f,h=n.strokeOpacity,_=void 0===h?1:h,p=n.lineWidth,E=void 0===p?1:p,v=n.visibility,R=n.isBillboard,m=n.billboardRotation,g=n.isSizeAttenuation,T=[0,0,0,0];t.isCSSRGB(i)&&(T=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]);var A=[0,0,0,0];t.isCSSRGB(a)&&(A=[Number(a.r),Number(a.g),Number(a.b),255*Number(a.alpha)]);for(var y=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=F(o.tmpMat4,e.getWorldTransform()),P=C(o.packedBufferObjectMap.get(e),2),N=P[0],M=P[1],O=s.slice(N,M),I=0;M-N>I;I+=u)O[I+0]=S[0],O[I+1]=S[1],O[I+2]=S[2],O[I+3]=S[3],O[I+4]=S[4],O[I+5]=S[5],O[I+6]=S[6],O[I+7]=S[7],O[I+8]=S[8],O[I+9]=S[9],O[I+10]=S[10],O[I+11]=S[11],O[I+12]=S[12],O[I+13]=S[13],O[I+14]=S[14],O[I+15]=S[15],O[I+16]=Ia(T[0],T[1]),O[I+17]=Ia(T[2],T[3]),O[I+18]=Ia(A[0],A[1]),O[I+19]=Ia(A[2],A[3]),O[I+20]=c,O[I+21]=d,O[I+22]=_,O[I+23]=E,O[I+24]="hidden"!==v?1:0,O[I+25]=R?1:0,O[I+26]=g?1:0,O[I+27]=null!=m?m:0,O[I+28]=y[0],O[I+29]=y[1],O[I+30]=y[2];o.geometry.updateVertexBuffer(mo.INSTANCED,ba.MODEL_MATRIX0,N/u,new Uint8Array(O.buffer))}))}}},{key:"buildTextBuffers",value:function(e){var r,n=e.object,i=e.lines,a=e.fontStack,o=e.lineHeight,s=e.letterSpacing,u=e.offsetX,l=e.offsetY,c=e.glyphAtlas,f=e.indicesOffset,d=n.parsedStyle,h=d.textAlign,_=void 0===h?"start":h,p=d.fill,E=d.stroke,v=d.opacity,R=void 0===v?1:v,g=d.fillOpacity,T=void 0===g?1:g,A=d.strokeOpacity,y=void 0===A?1:A,S=d.lineWidth,C=void 0===S?1:S,P=d.visibility,N=d.isBillboard,M=d.billboardRotation,O=d.isSizeAttenuation,I=d.x,x=void 0===I?0:I,B=d.y,D=void 0===B?0:B,b=d.z,L=void 0===b?0:b,U=[0,0,0,0];t.isCSSRGB(p)&&(U=[Number(p.r),Number(p.g),Number(p.b),255*Number(p.alpha)]);var k=[0,0,0,0];t.isCSSRGB(E)&&(k=[Number(E.r),Number(E.g),Number(E.b),255*Number(E.alpha)]);var w=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],G=F(this.tmpMat4,n.getWorldTransform()),V=[],X=[],W=[],H=[],z=f,Y=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],a=t[i.fontStack],o=a&&a[i.glyph];if(o){var s=o.rect;if(s){var u=o.metrics.advance*i.scale/2,l=[i.x+u,i.y],c=(o.metrics.left-4)*i.scale-u+l[0],f=(-o.metrics.top-4)*i.scale+l[1],d=c+s.w*i.scale,h=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:h},br:{x:d,y:h},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,a,o,_,s,u,l),c.positions);return Y.forEach((function(e){var t=[];t.push.apply(t,m(G));var r=[].concat(t,[Ia(U[0],U[1]),Ia(U[2],U[3]),Ia(k[0],k[1]),Ia(k[2],k[3]),R,T,y,C,"hidden"!==P?1:0,N?1:0,O?1:0,null!=M?M:0],m(w),[n.sortable.renderOrder*Aa]);V.push.apply(V,m(r).concat(m(r),m(r),m(r))),X.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),X.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),X.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),X.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),W.push(x,D,L,x,D,L,x,D,L,x,D,L),H.push(0+z,2+z,1+z),H.push(2+z,0+z,3+z),z+=4})),{indexBuffer:H,charUVOffsetBuffer:X,charPositionsBuffer:W,charPackedBuffer:V,indicesOffset:z}}},{key:"destroy",value:function(){A(r,"destroy",this,3)([]),this.glyphManager.destroy()}}])}(La),yo=function(e){function r(){var e;l(this,r);for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return(e=h(this,r,[].concat(n))).mergeXYZIntoModelMatrix=!1,e}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,n){var i=A(r,"shouldMerge",this,3)([e,n]);return!!i&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===e.parsedStyle.material&&this.instance.parsedStyle.geometry===e.parsedStyle.geometry)}},{key:"updateAttribute",value:function(e,t,n,i){0!==e.length&&(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i))}},{key:"createMaterial",value:function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()}},{key:"createGeometry",value:function(e){this.geometry=this.instance.parsedStyle.geometry,A(r,"createGeometry",this,3)([e]),this.geometry.build(e),this.observeGeometryChanged()}}])}(La),So=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle.fill;return r&&!r.isNone&&t.push(wa),this.needDrawStrokeSeparately(e)&&t.push(qa),t}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,a=t.lineWidth,o=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&a>0&&(1>o||l)}}])}(ya),Co=function(e){function r(){return l(this,r),h(this,r,arguments)}return p(r,e),u(r,[{key:"getDrawcallCtors",value:function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=r.opacity,o=r.strokeOpacity,s=r.lineWidth,u=i&&!i.isNone,l=qa.calcSubpathNum(e),c=[];if(!(e.nodeName===t.Shape.POLYLINE||null!=n&&n.isNone))for(var f=0;l>f;f++)c.push(io);for(var d=0;l>d;d++)if(0!==o&&0!==a&&0!==s&&u){var h=lo.isLine(e,d);c.push(h?lo:qa)}return c}}])}(ya),Po=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[ho]}}])}(ya),No=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle,n=r.stroke,i=r.lineWidth;return!(!n||n.isNone||!(void 0===i?1:i))&&t.push(Ao),t.push(Ao),t}},{key:"beforeUploadUBO",value:function(e,t){t.material.setUniforms(i({},To.HAS_STROKE,1===t.instance.renderable3D.drawcalls.length?0:1-t.index))}}])}(ya),Mo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[lo]}}])}(ya),Oo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[yo]}}])}(ya),Io=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle,n=r.fill,i=r.radius,a=i&&i.length&&i.some((function(e){return e!==i[0]}));return null!=n&&n.isNone||a||t.push(wa),a&&t.push(io),(a||this.needDrawStrokeSeparately(e))&&t.push(qa),t}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,a=t.lineWidth,o=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&a>0&&(1>o||l)}}])}(ya),xo=1,Bo=function(){return u((function e(t,r,n,i){l(this,e),this.drawcalls=[],this.pendingUpdatePatches={},this.stencilRefCache={},this.renderHelper=t,this.rendererFactory=r,this.texturePool=n,this.lightPool=i}),[{key:"destroy",value:function(){this.drawcalls.forEach((function(e){e.destroy()})),this.drawcalls=[],this.pendingUpdatePatches={}}},{key:"render",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r||this.updatePendingPatches(),this.drawcalls.forEach((function(n){n.init();var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var a=t.renderHelper.renderInstManager.newRenderInst();a.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(a,i),t.renderHelper.renderInstManager.submitRenderInst(a,e),r||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))}},{key:"attach",value:function(e){this.context=e}},{key:"add",value:function(e){var t=this,r=e.renderable3D;if(r&&!r.drawcalls.length){var n=this.rendererFactory[e.nodeName];n&&n.getDrawcallCtors(e).forEach((function(i,a,o){var s=t.drawcalls.find((function(t){return i===t.constructor&&t.index===a&&t.maxInstances>t.objects.length&&t.shouldMerge(e,a)}));s&&s.key===e.parsedStyle.batchKey||((s=new i(t.renderHelper,t.texturePool,t.lightPool,e,o,a,t.context)).renderer=n,t.drawcalls.push(s),e.parsedStyle.batchKey&&(s.key=e.parsedStyle.batchKey)),s&&(s.objects.push(e),r.drawcalls[a]=s,s.geometryDirty=!0)}))}}},{key:"remove",value:function(e){var t=this,r=e.renderable3D;r&&(r.drawcalls.forEach((function(r){if(r){var n=r.objects.indexOf(e);if(n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length)t.drawcalls.splice(t.drawcalls.indexOf(r),1).forEach((function(e){e.destroy()}))}})),r.drawcalls=[])}},{key:"updateAttribute",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.renderable3D,o=this.rendererFactory[e.nodeName];if(o){var s=o.getDrawcallCtors(e);if(s.forEach((function(s,u,l){var c=a.drawcalls.find((function(e){return e&&e.index===u&&e.constructor===s}));if(c||((c=a.drawcalls[u])&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&n.drawcalls.splice(n.drawcalls.indexOf(c),1),a.drawcalls[a.drawcalls.indexOf(c)]=void 0),(c=n.drawcalls.find((function(t){return s===t.constructor&&t.index===u&&t.maxInstances>t.objects.length&&t.shouldMerge(e,u)})))?c.geometryDirty=!0:((c=new s(n.renderHelper,n.texturePool,n.lightPool,e,l,u,n.context)).renderer=o,c.init(),n.drawcalls.push(c)),c.objects.push(e),a.drawcalls[u]=c),c.inited&&!c.geometryDirty)if(c.shouldMerge(e,u)){var f=c.objects.indexOf(e);if(i)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;n.pendingUpdatePatches[d]||(n.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===n.pendingUpdatePatches[d].objectIndices.indexOf(f)&&n.pendingUpdatePatches[d].objectIndices.push(f)}}else n.remove(e),n.add(e);else n.remove(e),n.add(e)})),a.drawcalls.length>s.length)for(var u=a.drawcalls.length-1;u>=s.length;u--){var l=a.drawcalls[u];l.objects.splice(l.objects.indexOf(e),1),l.geometryDirty=!0,0===l.objects.length&&this.drawcalls.splice(this.drawcalls.indexOf(l),1),a.drawcalls.pop()}}}},{key:"changeRenderOrder",value:function(e,t){var r=e.renderable3D;r&&r.drawcalls.length&&r.drawcalls.forEach((function(r){r&&r.inited&&!r.geometryDirty&&r.inited&&r.changeRenderOrder(e,t)}))}},{key:"getStencilRef",value:function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=xo++),this.stencilRefCache[e.entity]}},{key:"updatePendingPatches",value:function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,a=r.name,o=r.value;i.sort((function(e,t){return e-t}));var s=[];i.forEach((function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])})),s.forEach((function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],a,o)}))})),this.pendingUpdatePatches={}}}])}(),Do=function(){return u((function e(t,r){l(this,e),this.textureCache={},this.context=t,this.runtime=r}),[{key:"getOrCreateTexture",value:function(e,r,n,i){var a,s=this,u="string"==typeof r?r:r.src||"";if(u&&this.textureCache[u])(a=this.textureCache[u]).emit(Ae.LOADED);else if(a=e.createTexture(o({format:be.U8_RGBA_NORM,width:1,height:1,depthOrArrayLayers:1,mipLevelCount:1,dimension:ye.TEXTURE_2D,usage:Se.SAMPLED,pixelStore:{unpackFlipY:!1}},n)),u&&(this.textureCache[u]=a),I(r)){var l,c=this.context.config.createImage;c?l=c(r):t.isBrowser&&(l=new window.Image),l&&(l.onload=function(){var e=function(e){s.textureCache[u].setImageData([e]),s.textureCache[u].emit(Ae.LOADED),s.context.renderingService.dirtify(),i&&i(s.textureCache[u],e)};s.runtime.globalThis.createImageBitmap?s.runtime.globalThis.createImageBitmap(l).then((function(t){return e(t)})).catch((function(){e(l)})):e(l)},l.onerror=function(){},l.crossOrigin="Anonymous",l.src=r)}else a.setImageData([r]),a.emit(Ae.LOADED),this.context.renderingService.dirtify();return a}},{key:"getOrCreateCanvas",value:function(){return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(this.context.config.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var t=e.gradients,r=e.instance.getGeometryBounds().halfExtents,n=2*r[0]||1,i=2*r[1]||1,a=this.context.config.offscreenCanvas,s=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(a),u=this.runtime.offscreenCanvasCreator.getOrCreateContext(a);s.width=n,s.height=i;var l=this.context.imagePool;t.forEach((function(e){var t=l.getOrCreateGradient(o(o({type:e.type},e.value),{},{width:n,height:i,min:[0,0]}),u);u.fillStyle=t,u.fillRect(0,0,n,i)}))}},{key:"getOrCreatePattern",value:function(e,r,n){var i,a=e.image,o=e.repetition,s=e.transform,u=r.getGeometryBounds().halfExtents,l=2*u[0]||1,c=2*u[1]||1,f=this.context.config.offscreenCanvas,d=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(f),h=this.runtime.offscreenCanvasCreator.getOrCreateContext(f);if(d.width=l,d.height=c,I(a)){var _=this.context.imagePool.getImageSync(a,r,n);i=null==_?void 0:_.img}else i=a;var p=i&&h.createPattern(i,o);if(s){var E=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));p.setTransform({a:E[0],b:E[1],c:E[4],d:E[5],e:E[12],f:E[13]})}h.fillStyle=p,h.fillRect(0,0,l,c)}},{key:"destroy",value:function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}}}])}(),bo=function(e){function r(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l(this,r),(e=h(this,r)).name="device-renderer",e.parameters={toneMapping:Si.NONE,toneMappingExposure:1},e.options=t,e}return p(r,e),u(r,[{key:"init",value:function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new si;var n=new Zi(this.parameters),a=new ii,o=new Do(this.context,e),s=new ui,u=new So,l=new Co,c=(i(i(i(i(i(i(i(i(i(i(r={},t.Shape.CIRCLE,u),t.Shape.ELLIPSE,u),t.Shape.POLYLINE,l),t.Shape.PATH,l),t.Shape.POLYGON,l),t.Shape.RECT,new Io),t.Shape.IMAGE,new Po),t.Shape.LINE,new Mo),t.Shape.TEXT,new No),t.Shape.MESH,new Oo),i(i(r,t.Shape.GROUP,void 0),t.Shape.HTML,void 0)),f=new Bo(n,c,o,a),d=new ga(n,a,o,f,this.options);this.addRenderingPlugin(d),this.addRenderingPlugin(new Ta(n,d,s,f))}},{key:"destroy",value:function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]}},{key:"getRenderGraphPlugin",value:function(){return this.plugins[0]}},{key:"getDevice",value:function(){return this.getRenderGraphPlugin().getDevice()}},{key:"getSwapChain",value:function(){return this.getRenderGraphPlugin().getSwapChain()}},{key:"loadTexture",value:function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)}},{key:"toDataURL",value:function(e){return this.getRenderGraphPlugin().toDataURL(e)}},{key:"setParameters",value:function(e){this.parameters=o(o({},this.parameters),e)}}])}(t.AbstractRendererPlugin),Lo=Object.freeze({__proto__:null,AntialiasingMode:ta,Batch:ya,BufferGeometry:pa,DeviceProgram:li,DynamicUniformBuffer:ci,FILL_TEXTURE_MAPPING:Ba,Fog:ca,FogType:la,GeometryEvent:_a,HashMap:pi,ImageDrawcall:ho,Instanced:La,InstancedFillDrawcall:io,InstancedLineDrawcall:lo,InstancedPathDrawcall:qa,JOINT_TYPE:Qa,Light:sa,Material:Ca,MaterialEvent:Sa,Mesh:oi,MeshDrawcall:yo,Plugin:bo,RGAttachmentSlot:Ci,RenderCache:yi,RenderGraphPlugin:ga,RenderHelper:Zi,RenderInst:Wi,RenderInstExecutionOrder:zi,RenderInstFlags:Xi,RenderInstList:Yi,RenderInstManager:ji,Renderable3D:ni,RendererLayer:xi,SDFDrawcall:wa,ShaderMaterial:Pa,SingleSampledTexture:Mi,TemporalTexture:aa,TextDrawcall:Ao,TextUniform:To,TextureMapping:ia,TexturePool:Do,TinySDF:Wa,ToneMapping:Si,VertexAttributeBufferIndex:Da,VertexAttributeLocation:ba,bezierCurveTo:Va,compareDefines:Ma,definedProps:Oa,enumToObject:Na,fillColor:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r.a;return e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:Vi,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},hashCodeNumberFinish:di,hashCodeNumberUpdate:fi,makeAttachmentClearDescriptor:Qi,makeBackbufferDescSimple:na,makeDataBuffer:fa,makeDepthKey:Bi,makeSortKey:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&xi.TRANSLUCENT?Ui(e):Li(e,t)},makeSortKeyOpaque:Li,makeSortKeyTranslucent:Ui,nullHashFunc:hi,opaqueBlackFullClearRenderPassDescriptor:Ji,opaqueWhiteFullClearRenderPassDescriptor:ea,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===Oe.NEGATIVE_ONE?function(e){Z(e,wi,e)}(e):t===Oe.ZERO&&function(e){Z(e,Gi,e)}(e))},pushFXAAPass:Ra,quadCurveTo:Ga,renderInstCompareNone:null,renderInstCompareSortKey:Hi,segmentInstanceGeometry:ao,setBackbufferDescSimple:ra,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t){var r=!!(e>>>31&1),n=Bi(t,r,arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536);return r?ki(e,n):Fi(e,n)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?ki(e,t):Fi(e,t)},setSortKeyLayer:Di,setSortKeyOpaqueDepth:Fi,setSortKeyProgramKey:bi,setSortKeyTranslucentDepth:ki,standardFullClearRenderPassDescriptor:$i,updateBuffer:eo}),Fo=function(){function e(){l(this,e)}return u(e,[{key:"apply",value:function(t,r){var n=this,i=t.renderingService,a=t.renderingContext,o=t.config;this.context=t;var s=a.root.ownerDocument.defaultView,u=function(e){i.hooks.pointerMove.call(e)},l=function(e){i.hooks.pointerUp.call(e)},c=function(e){i.hooks.pointerDown.call(e)},f=function(e){i.hooks.pointerOver.call(e)},d=function(e){i.hooks.pointerOut.call(e)},h=function(e){i.hooks.pointerCancel.call(e)},_=function(e){i.hooks.pointerWheel.call(e)},p=function(e){i.hooks.click.call(e)};i.hooks.init.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?function(e){r.globalThis.document.addEventListener("pointermove",u,!0),e.addEventListener("pointerdown",c,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",l,!0),r.globalThis.addEventListener("pointercancel",h,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",u,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",f,!0),r.globalThis.addEventListener("mouseup",l,!0)}(e),s.supportsTouchEvents&&function(e){e.addEventListener("touchstart",c,!0),e.addEventListener("touchend",l,!0),e.addEventListener("touchmove",u,!0),e.addEventListener("touchcancel",h,!0)}(e),o.useNativeClickEvent&&e.addEventListener("click",p,!0),e.addEventListener("wheel",_,{passive:!0,capture:!0})})),i.hooks.destroy.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):s.supportsPointerEvents&&(e.style.touchAction=""),s.supportsPointerEvents?function(e){r.globalThis.document.removeEventListener("pointermove",u,!0),e.removeEventListener("pointerdown",c,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",l,!0),r.globalThis.removeEventListener("pointercancel",h,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",u,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",f,!0),r.globalThis.removeEventListener("mouseup",l,!0)}(e),s.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",c,!0),e.removeEventListener("touchend",l,!0),e.removeEventListener("touchmove",u,!0),e.removeEventListener("touchcancel",h,!0)}(e),o.useNativeClickEvent&&e.removeEventListener("click",p,!0),e.removeEventListener("wheel",_,!0)}))}}])}();Fo.tag="DOMInteraction";var Uo=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="dom-interaction",e}return p(t,e),u(t,[{key:"init",value:function(){this.addRenderingPlugin(new Fo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),ko=Object.freeze({__proto__:null,Plugin:Uo}),wo=function(){function e(){l(this,e),this.displayObjectHTMLElementMap=new WeakMap}return u(e,[{key:"joinTransformMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];return"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")}},{key:"apply",value:function(r,n){var i=this,a=r.camera,o=r.renderingContext,s=r.renderingService;this.context=r;var u=o.root.ownerDocument.defaultView,l=u.context.eventService.nativeHTMLMap,c=function(e,t){t.style.transform=i.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){i.$camera||(i.$camera=i.createCamera(a));var n=i.getOrCreateEl(r);i.$camera.appendChild(n),Object.keys(r.attributes).forEach((function(e){i.updateAttribute(e,r)})),c(r,n),l.set(n,r)}},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&i.$camera){var n=i.getOrCreateEl(r);n&&(n.remove(),l.delete(n))}},h=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&i.updateAttribute(e.attrName,r)},_=function(e){var r=e.target;(r.nodeName===t.Shape.FRAGMENT?r.childNodes:[r]).forEach((function(e){if(e.nodeName===t.Shape.HTML){var r=i.getOrCreateEl(e);c(e,r)}}))},p=function(){if(i.$camera){var e=i.context.config,t=e.height;i.$camera.parentElement.style.width="".concat(e.width||0,"px"),i.$camera.parentElement.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){u.addEventListener(t.CanvasEvent.RESIZE,p),u.addEventListener(t.ElementEvent.MOUNTED,f),u.addEventListener(t.ElementEvent.UNMOUNTED,d),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,_)})),s.hooks.endFrame.tap(e.tag,(function(){i.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(i.$camera.style.transform=i.joinTransformMatrix(a.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){i.$camera&&i.$camera.remove(),u.removeEventListener(t.CanvasEvent.RESIZE,p),u.removeEventListener(t.ElementEvent.MOUNTED,f),u.removeEventListener(t.ElementEvent.UNMOUNTED,d),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,_)}))}},{key:"createCamera",value:function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,a=this.context.contextService.getDomElement(),o=a.parentNode;if(o){var s="g-canvas-camera",u=o.querySelector("#".concat(s));if(!u){var l=(r||document).createElement("div");l.style.overflow="hidden",l.style.pointerEvents="none",l.style.position="absolute",l.style.left="0px",l.style.top="0px",l.style.width="".concat(n||0,"px"),l.style.height="".concat(i||0,"px");var c=(r||document).createElement("div");u=c,c.id=s,c.style.position="absolute",c.style.left="".concat(a.offsetLeft||0,"px"),c.style.top="".concat(a.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),c.style.pointerEvents="none",c.style.width="100%",c.style.height="100%",l.appendChild(c),o.appendChild(l)}return u}return null}},{key:"getOrCreateEl",value:function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),r}},{key:"updateAttribute",value:function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;I(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"x":n.style.left="".concat(r.parsedStyle.x,"px");break;case"y":n.style.top="".concat(r.parsedStyle.y,"px");break;case"transformOrigin":var a=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(a[0].buildCSSText(null,null,"")," ").concat(a[1].buildCSSText(null,null,""));break;case"width":var o=r.parsedStyle.width;n.style.width=B(o)?"".concat(o,"px"):""+o;break;case"height":var s=r.parsedStyle.height;n.style.height=B(s)?"".concat(s,"px"):""+s;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":var u=r.parsedStyle.pointerEvents;n.style.pointerEvents=void 0===u?"auto":u;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var l=r.parsedStyle.fill,c="";t.isCSSRGB(l)?c=l.isNone?"transparent":r.getAttribute("fill"):Array.isArray(l)?c=r.getAttribute("fill"):t.isPattern(l),n.style.background=c;break;case"stroke":var f=r.parsedStyle.stroke,d="";t.isCSSRGB(f)?d=f.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(f)?d=r.getAttribute("stroke"):t.isPattern(f),n.style["border-color"]=d,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:O(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e])}}}])}();wo.tag="HTMLRendering";var Go=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="html-renderer",e}return p(t,e),u(t,[{key:"init",value:function(){this.addRenderingPlugin(new wo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Vo=Object.freeze({__proto__:null,Plugin:Go}),Xo=function(){return u((function e(){l(this,e),this.cacheStore=new Map}),[{key:"onRefAdded",value:function(e){}},{key:"has",value:function(e){return this.cacheStore.has(e)}},{key:"put",value:function(e,t,r){return!this.cacheStore.has(e)&&(this.cacheStore.set(e,{value:t,counter:new Set([r])}),this.onRefAdded(r),!0)}},{key:"get",value:function(e,t){var r=this.cacheStore.get(e);return r?(r.counter.has(t)||(r.counter.add(t),this.onRefAdded(t)),r.value):null}},{key:"update",value:function(e,t,r){var n=this.cacheStore.get(e);return!!n&&(n.value=o(o({},n.value),t),n.counter.has(r)||(n.counter.add(r),this.onRefAdded(r)),!0)}},{key:"release",value:function(e,t){var r=this.cacheStore.get(e);return!!r&&(r.counter.delete(t),r.counter.size>0||this.cacheStore.delete(e),!0)}},{key:"releaseRef",value:function(e){var t=this;Array.from(this.cacheStore.keys()).forEach((function(r){t.release(r,e)}))}},{key:"getSize",value:function(){return this.cacheStore.size}},{key:"clear",value:function(){this.cacheStore.clear()}}])}(),Wo=[],Ho=[],zo=function(){function e(){l(this,e)}return u(e,null,[{key:"stop",value:function(){e.rafId&&((arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api).cancelAnimationFrame(e.rafId),e.rafId=null)}},{key:"executeTask",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api;(Wo.length>0||Ho.length>0)&&(Ho.forEach((function(e){return e()})),Ho=Wo.splice(0,e.TASK_NUM_PER_FRAME),e.rafId=t.requestAnimationFrame((function(){e.executeTask(t)})))}},{key:"sliceImage",value:function(t,r,n,i){for(var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e.api,s=t.naturalWidth||t.width,u=t.naturalHeight||t.height,l=r-a,c=n-a,f=Math.ceil(s/l),d=Math.ceil(u/c),h={tileSize:[r,n],gridSize:[d,f],tiles:Array(d).fill(null).map((function(){return Array(f).fill(null)}))},_=function(e){for(var a=function(a){Wo.push((function(){var f=a*l,d=e*c,_=[Math.min(r,s-f),Math.min(n,u-d)],p=_[0],E=_[1],v=o.createCanvas();v.width=r,v.height=n,v.getContext("2d").drawImage(t,f,d,p,E,0,0,p,E),h.tiles[e][a]={x:f,y:d,tileX:a,tileY:e,data:v},i()}))},d=0;f>d;d++)a(d)},p=0;d>p;p++)_(p);return e.stop(),e.executeTask(),h}}])}();zo.TASK_NUM_PER_FRAME=10;var Yo=new Xo;Yo.onRefAdded=function(e){var r=this;e.addEventListener(t.ElementEvent.DESTROY,(function(){r.releaseRef(e)}),{once:!0})};var Ko=function(){return u((function e(t,r){l(this,e),this.gradientCache={},this.patternCache={},this.context=t,this.runtime=r}),[{key:"getImageSync",value:function(e,t,r){var n=I(e)?e:e.src;if(Yo.has(n)){var i=Yo.get(n,t);if(i.img.complete)return null==r||r(i),i}return this.getOrCreateImage(e,t).then((function(e){null==r||r(e)})).catch((function(){})),null}},{key:"getOrCreateImage",value:function(e,r){var n=I(e)?e:e.src;if(!I(e)&&!Yo.has(n)){var i={img:e,size:[e.naturalWidth||e.width,e.naturalHeight||e.height],tileSize:jo(e)};Yo.put(n,i,r)}if(Yo.has(n)){var a=Yo.get(n,r);return a.img.complete?Promise.resolve(a):new Promise((function(e,t){a.img.addEventListener("load",(function(){a.size=[a.img.naturalWidth||a.img.width,a.img.naturalHeight||a.img.height],a.tileSize=jo(a.img),e(a)})),a.img.addEventListener("error",(function(e){t(e)}))}))}var o=this.context.config.createImage;return new Promise((function(e,i){var a;if(o?a=o(n):t.isBrowser&&(a=new window.Image),a){var s={img:a,size:[0,0],tileSize:jo(a)};Yo.put(n,s,r),a.onload=function(){s.size=[a.naturalWidth||a.width,a.naturalHeight||a.height],s.tileSize=jo(s.img),e(s)},a.onerror=function(e){i(e)},a.crossOrigin="Anonymous",a.src=n}}))}},{key:"createDownSampledImage",value:(r=M(P().mark((function e(t,r){var n,i,a,s,u,l,c,f,d,h,_,p,E,v;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getOrCreateImage(t,r);case 2:if(void 0===(n=e.sent).downSamplingRate){e.next=5;break}return e.abrupt("return",n);case 5:if(u=void 0===(s=(a="boolean"==typeof(i=this.context.config.enableLargeImageOptimization)?{}:i).maxDownSampledImageSize)?2048:s,c=void 0===(l=a.downSamplingRateThreshold)?.5:l,f=this.runtime.globalThis.createImageBitmap,d=C(n.size,2),p=n.img,E=Math.min((u+u)/((h=d[0])+(_=d[1])),Math.max(.01,Math.min(c,.5))),v=o(o({},n),{},{downSamplingRate:E}),Yo.update(n.img.src,v,r),!f){e.next=25;break}return e.prev=14,e.next=17,f(n.img,{resizeWidth:h*E,resizeHeight:_*E});case 17:p=e.sent,e.next=23;break;case 20:e.prev=20,e.t0=e.catch(14),E=1;case 23:e.next=26;break;case 25:E=1;case 26:return v=o(o({},this.getImageSync(t,r)),{},{downSampled:p,downSamplingRate:E}),Yo.update(n.img.src,v,r),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e,t){return r.apply(this,arguments)})},{key:"createImageTiles",value:(e=M(P().mark((function e(r,n,i,a){var s,u,l;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getOrCreateImage(r,a);case 2:return s=e.sent,zo.api={requestAnimationFrame:(u=a.ownerDocument.defaultView).requestAnimationFrame,cancelAnimationFrame:u.cancelAnimationFrame,createCanvas:function(){return t.OffscreenCanvasCreator.createCanvas()}},l=o(o({},s),zo.sliceImage(s.img,s.tileSize[0],s.tileSize[0],i)),Yo.update(s.img.src,l,a),e.abrupt("return",l);case 8:case"end":return e.stop()}}),e,this)}))),function(t,r,n,i){return e.apply(this,arguments)})},{key:"releaseImage",value:function(e,t){Yo.release(I(e)?e:e.src,t)}},{key:"releaseImageRef",value:function(e){Yo.releaseRef(e)}},{key:"getOrCreatePatternSync",value:function(e,r,n,i,a,o,s){var u=this.generatePatternKey(r);if(u&&this.patternCache[u])return this.patternCache[u];var l,c=r.image,f=r.repetition,d=r.transform,h=!1;if(I(c)){var _=this.getImageSync(c,e,s);l=null==_?void 0:_.img}else i?(l=i,h=!0):l=c;var p,E=l&&n.createPattern(l,f);E&&(p=d?t.parsedTransformToMat4(t.parseTransform(d),new t.DisplayObject({})):k(L()),h&&V(p,p,[1/a,1/a,1]),E.setTransform({a:p[0],b:p[1],c:p[4],d:p[5],e:p[12]+o[0],f:p[13]+o[1]}));return u&&E&&(this.patternCache[u]=E),E}},{key:"getOrCreateGradient",value:function(e,r){var n=this.generateGradientKey(e),i=e.type,a=e.steps,o=e.min,s=e.width,u=e.height,l=e.cx,c=e.cy,f=e.size;if(this.gradientCache[n])return this.gradientCache[n];var d=null;if(i===t.GradientType.LinearGradient){var h=t.computeLinearGradient(o,s,u,e.angle);d=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(i===t.GradientType.RadialGradient){var _=t.computeRadialGradient(o,s,u,l,c,f),p=_.x,E=_.y;d=r.createRadialGradient(p,E,0,p,E,_.r)}return d&&(a.forEach((function(e){var r,n=e.offset;n.unit===t.UnitType.kPercentage&&(null===(r=d)||void 0===r||r.addColorStop(n.value/100,""+e.color))})),this.gradientCache[n]=d),this.gradientCache[n]}},{key:"generateGradientKey",value:function(e){var t=e.min,r=e.width,n=e.height,i=e.steps,a=e.angle,o=e.cx,s=e.cy,u=e.size;return"gradient-".concat(e.type,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat((null==u?void 0:""+u)||0,"-").concat(t[0],"-").concat(t[1],"-").concat(r,"-").concat(n,"-").concat(i.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))}},{key:"generatePatternKey",value:function(e){var t=e.image,r=e.repetition;return I(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0}}]);var e,r}();function jo(e){if(!e.complete)return[0,0];var t=e.naturalWidth||e.width,r=e.naturalHeight||e.height,n=256;return[256,512].forEach((function(e){1e3>Math.ceil(r/e)*Math.ceil(t/e)&&(n=e)})),[n,n]}Ko.isSupportTile=!!t.OffscreenCanvasCreator.createCanvas();var Zo=function(){function e(){l(this,e)}return u(e,[{key:"apply",value:function(r){var n=r.renderingService,i=r.imagePool,a=r.renderingContext.root.ownerDocument.defaultView,o=function(e,t,r){var n=e.parsedStyle,i=n.width,a=n.height;i&&!a?e.setAttribute("height",r/t*i):!i&&a&&e.setAttribute("width",t/r*a)},s=function(e){var r=e.target,a=r.attributes;if(r.nodeName===t.Shape.IMAGE){var s=a.keepAspectRatio;i.getImageSync(a.src,r,(function(e){var t=e.img;s&&o(r,t.width,t.height),r.renderable.dirty=!0,n.dirtify()}))}},u=function(e){var r=e.target,a=e.prevValue,s=e.newValue;r.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&(a!==s&&i.releaseImage(a,r),I(s)&&i.getOrCreateImage(s,r).then((function(e){var t=e.img;r.attributes.keepAspectRatio&&o(r,t.width,t.height),r.renderable.dirty=!0,n.dirtify()})).catch((function(){})))};n.hooks.init.tap(e.tag,(function(){a.addEventListener(t.ElementEvent.MOUNTED,s),a.addEventListener(t.ElementEvent.ATTR_MODIFIED,u)})),n.hooks.destroy.tap(e.tag,(function(){a.removeEventListener(t.ElementEvent.MOUNTED,s),a.removeEventListener(t.ElementEvent.ATTR_MODIFIED,u)}))}}])}();Zo.tag="LoadImage";var qo=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="image-loader",e}return p(t,e),u(t,[{key:"init",value:function(e){this.context.imagePool=new Ko(this.context,e),this.addRenderingPlugin(new Zo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Qo=function(){return u((function e(t){l(this,e),this.canvasConfig=t.config,this.deviceRendererPlugin=t.deviceRendererPlugin}),[{key:"init",value:function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=I(t)?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.resize(this.canvasConfig.width,this.canvasConfig.height)}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getContext",value:function(){return this.deviceRendererPlugin.getDevice().canvasContext}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,r){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}}},{key:"getDPR",value:function(){return this.dpr}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}},{key:"toDataURL",value:(e=M(P().mark((function e(t){return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return","");case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),$o=function(e){function t(e,r){var n;return l(this,t),(n=h(this,t)).name="webgpu-context-register",n.rendererPlugin=e,n.config=r,n}return p(t,e),u(t,[{key:"init",value:function(){this.context.ContextService=Qo,this.context.deviceRendererPlugin=this.rendererPlugin;var e=this.config;this.context.deviceContribution=new Tn({shaderCompilerPath:null==e?void 0:e.shaderCompilerPath,onContextLost:null==e?void 0:e.onContextLost})}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(t.AbstractRendererPlugin),Jo=function(e){function r(e){var n;l(this,r),(n=h(this,r,[o({enableSizeAttenuation:!1},e)])).clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var i=new bo;return n.registerPlugin(new $o(i,e)),n.registerPlugin(new qo),n.registerPlugin(i),n.registerPlugin(new Uo),n.registerPlugin(new Go),n}return p(r,e),u(r)}(t.AbstractRenderer);e.DeviceRenderer=Lo,e.DomInteraction=ko,e.HTMLRenderer=Vo,e.Renderer=Jo}));
26
+ var ni=u((function e(){l(this,e),this.drawcalls=[]}));ni.tag="c-renderable-3d";var ii=function(){return u((function e(){l(this,e),this.lights=[]}),[{key:"addLight",value:function(e){this.lights.push(e),this.sortLights()}},{key:"removeLight",value:function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()}},{key:"addFog",value:function(e){this.fog=e}},{key:"removeFog",value:function(e){this.fog=null}},{key:"getFog",value:function(){return this.fog}},{key:"getAllLights",value:function(){return this.lights}},{key:"getDefines",value:function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach((function(t){e[t.define]||(e[t.define]=0),e[t.define]++})),e}},{key:"sortLights",value:function(){this.lights.sort((function(e,t){return e.order-t.order}))}}])}(),ai=["style"],oi=function(e){function r(e){var n,i=e.style,a=g(e,ai);return l(this,r),(n=h(this,r,[o({type:t.Shape.MESH,style:o({x:"",y:"",z:"",lineWidth:0},i)},a)])).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return p(r,e),u(r,[{key:"destroy",value:function(){A(r,"destroy",this,3)([]);var e=this.style.geometry.meshes,t=e.indexOf(this);e.splice(t,1),t=(e=this.style.material.meshes).indexOf(this),e.splice(t,1)}}])}(t.DisplayObject);oi.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["x","y","z","geometry","material"]));var si=function(){return u((function e(){l(this,e)}),[{key:"update",value:function(e){var t=e.x,r=void 0===t?0:t,n=e.y,i=void 0===n?0:n,a=e.z,o=void 0===a?0:a,s=e.geometry.computeBoundingBox();return{cx:r,cy:i,cz:o,hwidth:s.halfExtents[0],hheight:s.halfExtents[1],hdepth:s.halfExtents[2]}}}])}(),ui=function(){return u((function e(){l(this,e),this.counter=0,this.id2DisplayObjectMap={}}),[{key:"getId",value:function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t}},{key:"getById",value:function(e){return this.id2DisplayObjectMap[e]}},{key:"deleteById",value:function(e){delete this.id2DisplayObjectMap[e]}},{key:"reset",value:function(){this.counter=0,this.id2DisplayObjectMap={}}},{key:"decodePickingColor",value:function(e){var t=C(e,3);return t[0]+256*t[1]+65536*t[2]-1}},{key:"encodePickingColor",value:function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]}}])}(),li=function(){return u((function e(){l(this,e),this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={}}),[{key:"definesChanged",value:function(){this.preprocessedVert="",this.preprocessedFrag=""}},{key:"setDefineString",value:function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(O(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0}},{key:"setDefineBool",value:function(e,t){return this.setDefineString(e,t?"1":null)}},{key:"getDefineString",value:function(e){return void 0===(t=this.defines[e])?null:t;var t}},{key:"getDefineBool",value:function(e){var t=this.getDefineString(e);return null!==t&&He("1"===t),null!==t}}])}(),ci=function(){return u((function e(t){l(this,e),this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=t;var r=t.queryLimits();this.uniformBufferWordAlignment=r.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=r.uniformBufferMaxPageWordSize}),[{key:"isSupportedUBO",value:function(){return"WebGL1"!==this.device.queryVendorInfo().platformString}},{key:"findPageIndex",value:function(e){return e/this.uniformBufferMaxPageWordSize|0}},{key:"allocateChunk",value:function(e){e=rt(e,this.uniformBufferWordAlignment),He(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=rt(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t}},{key:"ensureShadowBuffer",value:function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=rt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){He(this.currentWordOffset>e&&this.currentWordOffset>=e+t);var n=rt(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize),i=new Uint8Array(4*n);if(i.set(this.shadowBufferU8,0),this.shadowBufferU8=i,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),n<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(n,"]"))}}},{key:"mapBufferF32",value:function(){return ze(this.shadowBufferF32)}},{key:"prepareToRender",value:function(){if(null!==this.shadowBufferF32){var e=ze(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:4*this.currentBufferWordSize,usage:me.UNIFORM,hint:ge.DYNAMIC}));var t=rt(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())ze(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}}},{key:"destroy",value:function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null}}])}();function fi(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function di(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function hi(e){return 0}var _i=u((function e(){l(this,e),this.keys=[],this.values=[]})),pi=function(){return u((function e(t,r){l(this,e),this.buckets=new Map,this.keyEqualFunc=t,this.keyHashFunc=r}),[{key:"findBucketIndex",value:function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1}},{key:"findBucket",value:function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)}},{key:"get",value:function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]}},{key:"add",value:function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new _i);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)}},{key:"delete",value:function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}}},{key:"clear",value:function(){this.buckets.clear()}},{key:"size",value:function(){var e,t=0,r=An(this.buckets.values());try{for(r.s();!(e=r.n()).done;){t+=e.value.values.length}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"values",value:P().mark((function e(){var t,r,n,i;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=An(this.buckets.values()),e.prev=1,t.s();case 3:if((r=t.n()).done){e.next=14;break}i=(n=r.value).values.length-1;case 6:if(i<0){e.next=12;break}return e.next=9,n.values[i];case 9:i--,e.next=6;break;case 12:e.next=3;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),t.e(e.t0);case 19:return e.prev=19,t.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,this,[[1,16,19,22]])}))}])}();function Ei(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return function(e,t,r,n){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:ir(e,"vert",t,n),preprocessedFrag:ir(e,"frag",r,n)}}(e.queryVendorInfo(),n,i,r)}function vi(e,t){return He(""!==e.preprocessedVert&&""!==t.preprocessedVert),He(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function Ri(e,t){return e=fi(e,t.blendMode),e=fi(e,t.blendSrcFactor),e=fi(e,t.blendDstFactor)}function mi(e,t){return e=Ri(e,t.rgbBlendState),e=fi(e=Ri(e,t.alphaBlendState),t.channelWriteMask)}function gi(e,t){for(var r,n,i,a,o,s,u,l,c=0;t.attachmentsState.length>c;c++)e=mi(e,t.attachmentsState[c]);return e=function(e,t){return fi(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=fi(e,t.depthCompare),e=fi(e,t.depthWrite?1:0),e=fi(e,null===(r=t.stencilFront)||void 0===r?void 0:r.compare),e=fi(e,null===(n=t.stencilFront)||void 0===n?void 0:n.passOp),e=fi(e,null===(i=t.stencilFront)||void 0===i?void 0:i.failOp),e=fi(e,null===(a=t.stencilFront)||void 0===a?void 0:a.depthFailOp),e=fi(e,null===(o=t.stencilBack)||void 0===o?void 0:o.compare),e=fi(e,null===(s=t.stencilBack)||void 0===s?void 0:s.passOp),e=fi(e,null===(u=t.stencilBack)||void 0===u?void 0:u.failOp),e=fi(e,null===(l=t.stencilBack)||void 0===l?void 0:l.depthFailOp),e=fi(e,t.stencilWrite?1:0),e=fi(e,t.cullMode),e=fi(e,t.frontFace?1:0),e=fi(e,t.polygonOffset?1:0)}function Ti(e){var t=0;t=fi(t,e.program.id),null!==e.inputLayout&&(t=fi(t,e.inputLayout.id)),t=gi(t,e.megaStateDescriptor);for(var r=0;e.colorAttachmentFormats.length>r;r++)t=fi(t,e.colorAttachmentFormats[r]||0);return di(t=fi(t,e.depthStencilAttachmentFormat||0))}function Ai(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){var n=e.samplerBindings[r];null!==n&&null!==n.texture&&(t=fi(t,n.texture.id))}for(var i=0;e.uniformBufferBindings.length>i;i++){var a=e.uniformBufferBindings[i];null!==a&&null!==a.buffer&&(t=fi(t,a.buffer.id),t=fi(t,a.binding),t=fi(t,a.offset),t=fi(t,a.size))}return di(t)}var yi=function(){return u((function e(t){l(this,e),this.bindingsCache=new pi(At,Ai),this.renderPipelinesCache=new pi(Mt,Ti),this.inputLayoutsCache=new pi(xt,hi),this.programCache=new pi(vi,hi),this.samplerCache=new pi(Bt,hi),this.device=t}),[{key:"createBindings",value:function(e){var t,r=this.bindingsCache.get(e);if(null===r){var n={samplerBindings:(t=e).samplerBindings&&Rt(t.samplerBindings,Dt),uniformBufferBindings:t.uniformBufferBindings&&Rt(t.uniformBufferBindings,bt),storageBufferBindings:t.storageBufferBindings&&Rt(t.storageBufferBindings,bt),storageTextureBindings:t.storageTextureBindings&&Rt(t.storageTextureBindings,Lt),pipeline:t.pipeline};n.uniformBufferBindings=n.uniformBufferBindings.filter((function(e){return e.size>0})),r=this.device.createBindings(n),this.bindingsCache.add(n,r)}return r}},{key:"createRenderPipeline",value:function(e){var t,r,n,i=this.renderPipelinesCache.get(e);if(null===i){var a=(r=(t=e).program,n=t.topology,{inputLayout:t.inputLayout,megaStateDescriptor:t.megaStateDescriptor&&ct(t.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:t.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:t.depthStencilAttachmentFormat,sampleCount:t.sampleCount});i=this.device.createRenderPipeline(o(o({},a),{},{colorAttachmentFormats:e.colorAttachmentFormats.filter((function(e){return e}))})),this.renderPipelinesCache.add(a,i)}return i}},{key:"createInputLayout",value:function(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter((function(e){return!!e}));var t,r=this.inputLayoutsCache.get(e);if(null===r){var n={vertexBufferDescriptors:Rt((t=e).vertexBufferDescriptors,Ut),indexBufferFormat:t.indexBufferFormat,program:t.program};r=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,r)}return r}},{key:"createProgramSimple",value:function(e){var t,r=e.vert,n=e.preprocessedFrag,i=e.preprocessedVert,a=null;if(i&&n&&(a=this.programCache.get({vert:r,frag:e.frag,preprocessedFrag:n,preprocessedVert:i})),null===a){var o=Ei(this.device,e),s=o.preprocessedVert,u=o.preprocessedFrag;e.preprocessedVert=s,e.preprocessedFrag=u;var l={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};a=this.device.createProgramSimple({vertex:{glsl:s},fragment:{glsl:u}},r),this.programCache.add(l,a)}return a}},{key:"createSampler",value:function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t}},{key:"destroy",value:function(){var e,t=An(this.bindingsCache.values());try{for(t.s();!(e=t.n()).done;){e.value.destroy()}}catch(e){t.e(e)}finally{t.f()}var r,n=An(this.renderPipelinesCache.values());try{for(n.s();!(r=n.n()).done;){r.value.destroy()}}catch(e){n.e(e)}finally{n.f()}var i,a=An(this.inputLayoutsCache.values());try{for(a.s();!(i=a.n()).done;){i.value.destroy()}}catch(e){a.e(e)}finally{a.f()}var o,s=An(this.programCache.values());try{for(s.s();!(o=s.n()).done;){o.value.destroy()}}catch(e){s.e(e)}finally{s.f()}var u,l=An(this.samplerCache.values());try{for(l.s();!(u=l.n()).done;){u.value.destroy()}}catch(e){l.e(e)}finally{l.f()}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()}}])}(),Si=function(e){return e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping",e}({}),Ci=function(e){return e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.ColorMax=3]="ColorMax",e[e.DepthStencil=4]="DepthStencil",e}({}),Pi=function(){return u((function e(){l(this,e),this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]}),[{key:"setDebugName",value:function(e){this.debugName=e}},{key:"pushDebugThumbnail",value:function(e){this.debugThumbnails[e]=!0}},{key:"setViewport",value:function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n}},{key:"attachRenderTargetID",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;He(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r}},{key:"attachResolveTexture",value:function(e){this.resolveTextureInputIDs.push(e)}},{key:"attachOcclusionQueryPool",value:function(e){this.descriptor.occlusionQueryPool=e}},{key:"exec",value:function(e){He(null===this.execFunc),this.execFunc=e}},{key:"post",value:function(e){He(null===this.postFunc),this.postFunc=e}},{key:"addExtraRef",value:function(e){this.renderTargetExtraRefs[e]=!0}}])}(),Ni=function(){return u((function e(t,r){l(this,e),this.dimension=ye.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=Se.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.sampleCount=r.sampleCount,He(this.sampleCount>=1),this.sampleCount>1?this.attachment=t.createRenderTarget(this):(this.texture=t.createTexture(this),this.attachment=t.createRenderTargetFromTexture(this.texture))}),[{key:"setDebugName",value:function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)}},{key:"matchesDescription",value:function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount}},{key:"reset",value:function(e){He(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.attachment.destroy()}}])}(),Mi=function(){return u((function e(t,r){l(this,e),this.dimension=ye.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=Se.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=r.format,this.width=r.width,this.height=r.height,this.texture=t.createTexture(this)}),[{key:"matchesDescription",value:function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height}},{key:"reset",value:function(e){He(this.matchesDescription(e)),this.age=0}},{key:"destroy",value:function(){this.texture.destroy()}}])}(),Oi=u((function e(){l(this,e),this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]})),Ii=function(){return u((function e(t){l(this,e),this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=t}),[{key:"acquireRenderTargetForDescription",value:function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new Ni(this.device,e)}},{key:"acquireSingleSampledTextureForDescription",value:function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new Mi(this.device,e)}},{key:"beginGraphBuilder",value:function(){He(null===this.currentGraph),this.currentGraph=new Oi}},{key:"pushPass",value:function(e){var t=new Pi;e(t),this.currentGraph.passes.push(t)}},{key:"createRenderTargetID",value:function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1}},{key:"createResolveTextureID",value:function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1}},{key:"findMostRecentPassThatAttachedRenderTarget",value:function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null}},{key:"resolveRenderTargetPassAttachmentSlot",value:function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]}},{key:"findPassForResolveRenderTarget",value:function(e){var t=ze(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return He(void 0===t.resolveTextureOutputExternalTextures[r]),t}},{key:"resolveRenderTarget",value:function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)}},{key:"resolveRenderTargetToExternalTexture",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);He(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r}},{key:"getRenderTargetDescription",value:function(e){return ze(this.currentGraph.renderTargetDescriptions[e])}},{key:"scheduleAddUseCount",value:function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){var n=t.renderTargetIDs[r];void 0!==n&&(this.renderTargetOutputCount[n]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[n]++)}for(var i=0;t.resolveTextureInputIDs.length>i;i++){var a=t.resolveTextureInputIDs[i];if(void 0!==a)this.resolveTextureUseCount[a]++,this.renderTargetResolveCount[e.resolveTextureRenderTargetIDs[a]]++}}},{key:"acquireRenderTargetForID",value:function(e,t){if(void 0===t)return null;if(He(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]}},{key:"releaseRenderTargetForID",value:function(e,t){if(void 0===e)return null;var r=ze(this.renderTargetAliveForID[e]);return t?(He(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(He(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,this.renderTargetAliveForID[e]=void 0,this.renderTargetDeadPool.push(r)),r}},{key:"acquireResolveTextureInputTextureForID",value:function(e,t){var r=e.resolveTextureRenderTargetIDs[t];He(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=ze(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return ze(n.texture)}},{key:"determineResolveParam",value:function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],a=t.resolveTextureOutputExternalTextures[r],o=void 0!==i,s=void 0!==a;He(!(o&&s));var u=null,l=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(l=!0),o){He(e.resolveTextureRenderTargetIDs[i]===n),He(this.resolveTextureUseCount[i]>0),He(this.renderTargetOutputCount[n]>0);var f=ze(this.renderTargetAliveForID[n]);if(null!==f.texture&&1===this.renderTargetOutputCount[n])u=null,l=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var d=ze(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(d),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,"".concat(f.debugName," (Resolve ").concat(i,")"))}u=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(u=a,c=t.resolveTextureOutputExternalTextureLevel[r]):u=null;return{resolveTo:u,store:l,level:c}}},{key:"schedulePass",value:function(e,t){for(var r=t.renderTargetIDs[Ci.DepthStencil],n=Ci.Color0;Ci.ColorMax>=n;n++){var i=t.renderTargetIDs[n],a=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=a,t.descriptor.colorAttachment[n]=null!==a?a.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var o=this.determineResolveParam(e,t,n),s=o.store,u=o.level;t.descriptor.colorResolveTo[n]=o.resolveTo,t.descriptor.colorResolveToLevel[n]=u,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==a&&a.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var l=this.acquireRenderTargetForID(e,r);t.renderTargets[Ci.DepthStencil]=l,t.descriptor.depthStencilAttachment=null!==l?l.attachment:null;var c=this.determineResolveParam(e,t,Ci.DepthStencil),f=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=f,t.descriptor.depthClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==l&&l.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var d=0,h=0,_=0,p=0;t.renderTargets.length>p;p++){var E=t.renderTargets[p];if(E){var v=E.width>>>t.renderTargetLevels[p],R=E.height>>>t.renderTargetLevels[p];0===d&&(d=v,h=R,_=E.sampleCount),He(v===d),He(R===h),He(E.sampleCount===_),E.needsClear=!1}}d>0&&h>0&&(t.viewportX*=d,t.viewportY*=h,t.viewportW*=d,t.viewportH*=h);for(var m=0;t.resolveTextureInputIDs.length>m;m++){t.resolveTextureInputTextures[m]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[m])}for(var g=0;t.renderTargetIDs.length>g;g++)this.releaseRenderTargetForID(t.renderTargetIDs[g],!0);for(var T=0;t.renderTargetExtraRefs.length>T;T++)t.renderTargetExtraRefs[T]&&this.releaseRenderTargetForID(t.renderTargetIDs[T],!0)}},{key:"scheduleGraph",value:function(e){He(0===this.renderTargetOutputCount.length),He(0===this.renderTargetResolveCount.length),He(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(var r=0;this.singleSampledTextureDeadPool.length>r;r++)this.singleSampledTextureDeadPool[r].age++;et(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),et(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),et(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(var n=0;e.passes.length>n;n++)this.scheduleAddUseCount(e,e.passes[n]);for(var i=0;e.passes.length>i;i++)this.schedulePass(e,e.passes[i]);for(var a=0;this.renderTargetOutputCount.length>a;a++)He(0===this.renderTargetOutputCount[a]);for(var o=0;this.renderTargetResolveCount.length>o;o++)He(0===this.renderTargetResolveCount[o]);for(var s=0;this.resolveTextureUseCount.length>s;s++)He(0===this.resolveTextureUseCount[s]);for(var u=0;this.renderTargetAliveForID.length>u;u++)He(void 0===this.renderTargetAliveForID[u]);for(var l=0;this.renderTargetDeadPool.length>l;l++)1>this.renderTargetDeadPool[l].age||(this.renderTargetDeadPool[l].destroy(),this.renderTargetDeadPool.splice(l--,1));for(var c=0;this.singleSampledTextureDeadPool.length>c;c++)1>this.singleSampledTextureDeadPool[c].age||(this.singleSampledTextureDeadPool[c].destroy(),this.singleSampledTextureDeadPool.splice(c--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0}},{key:"execPass",value:function(e){He(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.pushDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.popDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null}},{key:"execGraph",value:function(e){var t=this;this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEach((function(e){t.execPass(e)})),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0}},{key:"execute",value:function(){var e=ze(this.currentGraph);this.execGraph(e),this.currentGraph=null}},{key:"getDebug",value:function(){return this}},{key:"getPasses",value:function(){return this.currentGraph.passes}},{key:"getPassDebugThumbnails",value:function(e){return e.debugThumbnails}},{key:"getPassRenderTargetID",value:function(e,t){return e.renderTargetIDs[t]}},{key:"getRenderTargetIDDebugName",value:function(e){return this.currentGraph.renderTargetDebugNames[e]}},{key:"getResolveTextureForID",value:function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return He(r>=0),ze(t.resolveTextureInputTextures[r])}},{key:"getRenderTargetAttachment",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null}},{key:"getRenderTargetTexture",value:function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null}},{key:"newGraphBuilder",value:function(){return this.beginGraphBuilder(),this}},{key:"destroy",value:function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)He(void 0===this.renderTargetAliveForID[e]);for(var t=0;this.singleSampledTextureForResolveTextureID.length>t;t++)He(void 0===this.singleSampledTextureForResolveTextureID[t]);for(var r=0;this.renderTargetDeadPool.length>r;r++)this.renderTargetDeadPool[r].destroy();for(var n=0;this.singleSampledTextureDeadPool.length>n;n++)this.singleSampledTextureDeadPool[n].destroy()}}])}(),xi=function(e){return e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT",e}({});function Bi(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536,n=x(e,0,r)/r;return t&&(n=1-n),65535&65535*n}function Di(e,t){return(16777215&e|(255&t)<<24)>>>0}function bi(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function Li(e,t){return Di(bi(0,t),e)}function Fi(e,t){return He(t>=0),(4294967040&e|t>>>8&255)>>>0}function Ui(e){return Di(0,e)}function ki(e,t){return He(t>=0),(4278190335&e|t<<8)>>>0}var wi=U(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Gi=U(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function Vi(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=a,4}var Xi=function(e){return e[e.None=0]="None",e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags",e}({}),Wi=function(){return u((function e(){l(this,e),this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=it(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=it(4,(function(){return 0})),this.flags=0,this.vertexBuffers=null,this.indexBuffer=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={inputLayout:null,megaStateDescriptor:ct(dt),program:null,topology:Re.TRIANGLES,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}),[{key:"reset",value:function(){this.sortKey=0,this.flags=Xi.AllowSkippingIfPipelineNotReady,this.vertexBuffers=null,this.indexBuffer=null,this.renderPipelineDescriptor.inputLayout=null}},{key:"setFromTemplate",value:function(e){var t,r;lt(this.renderPipelineDescriptor.megaStateDescriptor,e.renderPipelineDescriptor.megaStateDescriptor),this.renderPipelineDescriptor.program=e.renderPipelineDescriptor.program,this.renderPipelineDescriptor.inputLayout=e.renderPipelineDescriptor.inputLayout,this.renderPipelineDescriptor.topology=e.renderPipelineDescriptor.topology,this.renderPipelineDescriptor.colorAttachmentFormats.length=Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length,e.renderPipelineDescriptor.colorAttachmentFormats.length);for(var n=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>n;n++)this.renderPipelineDescriptor.colorAttachmentFormats[n]=e.renderPipelineDescriptor.colorAttachmentFormats[n];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.uniformBuffer=e.uniformBuffer,this.uniforms=m(e.uniforms),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.vertexBuffers=e.vertexBuffers,this.indexBuffer=e.indexBuffer,this.flags=this.flags&~Xi.InheritedFlags|e.flags&Xi.InheritedFlags,this.sortKey=e.sortKey;var i=this.bindingDescriptors[0],a=e.bindingDescriptors[0];this.setBindingLayout({numSamplers:null===(t=a.samplerBindings)||void 0===t?void 0:t.length,numUniformBuffers:null===(r=a.uniformBufferBindings)||void 0===r?void 0:r.length});for(var o=0;Math.min(i.uniformBufferBindings.length,a.uniformBufferBindings.length)>o;o++)i.uniformBufferBindings[o].size=e.bindingDescriptors[0].uniformBufferBindings[o].size;this.setSamplerBindingsFromTextureMappings(a.samplerBindings);for(var s=0;e.dynamicUniformBufferByteOffsets.length>s;s++)this.dynamicUniformBufferByteOffsets[s]=e.dynamicUniformBufferByteOffsets[s]}},{key:"validate",value:function(){for(var e=0;this.bindingDescriptors.length>e;e++)for(var t=this.bindingDescriptors[e],r=0;r<(null===(n=t.uniformBufferBindings)||void 0===n?void 0:n.length);r++){var n;He(t.uniformBufferBindings[r].size>0)}He(this.drawCount>0)}},{key:"setProgram",value:function(e){this.renderPipelineDescriptor.program=e}},{key:"setMegaStateFlags",value:function(e){return lt(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor}},{key:"getMegaStateFlags",value:function(){return this.renderPipelineDescriptor.megaStateDescriptor}},{key:"setVertexInput",value:function(e,t,r){this.vertexBuffers=t,this.indexBuffer=r,this.renderPipelineDescriptor.inputLayout=e}},{key:"setBindingLayout",value:function(e){He(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers);for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({binding:t,buffer:null,size:0});for(var r=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>r;r++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null})}},{key:"drawIndexes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=nt(this.flags,Xi.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"drawIndexesInstanced",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.flags=nt(this.flags,Xi.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t}},{key:"drawPrimitives",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.flags=nt(this.flags,Xi.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1}},{key:"setUniforms",value:function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value;if(B(t)||Array.isArray(t)||t instanceof Float32Array){var i=B(t)?[t]:t,a=4-r%4;if(4!==a)if(a<(i.length>4?4:i.length)){r+=a;for(var o=0;a>o;o++)n.push(0)}else;r+=i.length,n.push.apply(n,m(i))}}));var i=4-n.length%4;if(4!==i)for(var a=0;i>a;a++)n.push(0);for(var o=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),u=0;n.length>u;u+=4)o+=Vi(s,o,n[u],n[u+1],n[u+2],n[u+3])}}},{key:"setUniformBuffer",value:function(e){this.uniformBuffer=e}},{key:"allocateUniformBuffer",value:function(e,t){var r;return He((null===(r=this.bindingDescriptors[0].uniformBufferBindings)||void 0===r?void 0:r.length)<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].size=t<<2,this.getUniformBufferOffset(e)}},{key:"getUniformBufferOffset",value:function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2}},{key:"mapUniformBufferF32",value:function(e){return this.uniformBuffer.mapBufferF32()}},{key:"getUniformBuffer",value:function(){return this.uniformBuffer}},{key:"setSamplerBindingsFromTextureMappings",value:function(e){e=e.filter((function(e){return e}));for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler):(r.texture=null,r.sampler=null)}}},{key:"setAllowSkippingIfPipelineNotReady",value:function(e){this.flags=nt(this.flags,Xi.AllowSkippingIfPipelineNotReady,e)}},{key:"setAttachmentFormatsFromRenderPass",value:function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var a=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==a?a.format:null,null!==a&&(-1===n?n=a.sampleCount:He(n===a.sampleCount))}var o=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==o?o.format:null,null!==o&&(-1===n?n=o.sampleCount:He(n===o.sampleCount)),He(n>0),this.renderPipelineDescriptor.sampleCount=n}},{key:"drawOnPass",value:function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var i=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(i)){if(this.flags&Xi.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(i)}t.setPipeline(i),t.setVertexInput(this.renderPipelineDescriptor.inputLayout,this.vertexBuffers,this.indexBuffer);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=ze(this.uniformBuffer.buffer),this.bindingDescriptors[0].uniformBufferBindings[a].offset=this.dynamicUniformBufferByteOffsets[a];this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniformsLegacy(t)}));var s=e.createBindings(o(o({},this.bindingDescriptors[0]),{},{pipeline:i}));return t.setBindings(s),this.flags&Xi.Indexed?t.drawIndexed(this.drawCount,this.drawInstanceCount,this.drawStart,0,0):t.draw(this.drawCount,this.drawInstanceCount,this.drawStart,0),!0}}])}();function Hi(e,t){return e.sortKey-t.sortKey}var zi=function(e){return e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e}({}),Yi=function(){return u((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Hi,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zi.Forwards;l(this,e),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=t,this.executionOrder=r}),[{key:"checkUsePostSort",value:function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500}},{key:"insertSorted",value:function(e){var t,r,n;null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):(n=function(e,t,r){for(var n=0,i=e.length;i>n;){var a=n+(i-n>>>1);0>r(t,e[a])?i=a:n=a+1}return n}(t=this.renderInsts,r=e,this.compareFunction),t.splice(n,0,r)),this.checkUsePostSort()}},{key:"submitRenderInst",value:function(e){e.flags|=Xi.Draw,this.insertSorted(e)}},{key:"ensureSorted",value:function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)}},{key:"drawOnPassRendererNoReset",value:function(e,t){if(this.ensureSorted(),this.executionOrder===zi.Forwards)for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].drawOnPass(e,t);else for(var n=this.renderInsts.length-1;n>=0;n--)this.renderInsts[n].drawOnPass(e,t)}},{key:"reset",value:function(){this.renderInsts.length=0}},{key:"drawOnPassRenderer",value:function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()}}])}(),Ki=function(){return u((function e(){l(this,e),this.pool=[],this.allocCount=0}),[{key:"allocRenderInstIndex",value:function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new Wi),this.allocCount-1}},{key:"popRenderInst",value:function(){this.allocCount--}},{key:"reset",value:function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0}},{key:"destroy",value:function(){this.pool.length=0,this.allocCount=0}}])}(),ji=function(){return u((function e(t){l(this,e),this.instPool=new Ki,this.templatePool=new Ki,this.simpleRenderInstList=new Yi,this.currentRenderInstList=this.simpleRenderInstList,this.renderCache=t}),[{key:"newRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r}},{key:"submitRenderInst",value:function(e){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.currentRenderInstList).submitRenderInst(e)}},{key:"setCurrentRenderInstList",value:function(e){He(null===this.simpleRenderInstList),this.currentRenderInstList=e}},{key:"pushTemplateRenderInst",value:function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=Xi.Template,r}},{key:"popTemplateRenderInst",value:function(){this.templatePool.popRenderInst()}},{key:"getTemplateRenderInst",value:function(){return this.templatePool.pool[this.templatePool.allocCount-1]}},{key:"resetRenderInsts",value:function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),He(0===this.templatePool.allocCount)}},{key:"destroy",value:function(){this.instPool.destroy(),this.renderCache.destroy()}},{key:"disableSimpleMode",value:function(){this.simpleRenderInstList=null}},{key:"drawOnPassRenderer",value:function(e){ze(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)}},{key:"drawOnPassRendererNoReset",value:function(e){ze(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)}}])}(),Zi=function(){return u((function e(t){l(this,e),this.parameters=t}),[{key:"getDevice",value:function(){return this.device}},{key:"setDevice",value:function(e){this.device=e,this.renderCache=new yi(e),this.renderGraph=new Ii(this.device),this.renderInstManager=new ji(this.renderCache),this.uniformBuffer=new ci(this.device)}},{key:"pushTemplateRenderInst",value:function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e}},{key:"prepareToRender",value:function(){this.uniformBuffer.prepareToRender()}},{key:"destroy",value:function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()}},{key:"getCache",value:function(){return this.renderCache}},{key:"getDefines",value:function(){var e,t,r;return{USE_TONEMAPPING:(null===(e=this.parameters)||void 0===e?void 0:e.toneMapping)&&(null===(t=this.parameters)||void 0===t?void 0:t.toneMapping)!==Si.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}}}])}(),qi=function(){return u((function e(t){l(this,e),this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load",this.format=t}),[{key:"setDimensions",value:function(e,t,r){this.width=e,this.height=t,this.sampleCount=r}},{key:"copyDimensions",value:function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount}}])}();function Qi(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var $i=Qi(Ke(.88,.88,.88,1)),Ji=Qi(Ze),ea=Qi(Qe),ta=function(e){return e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4",e}({});function ra(e,t){var r=function(e){return e.antialiasingMode===ta.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function na(e,t,r){var n=function(e){if(e===Ci.Color0)return be.U8_RGBA_RT;if(e===Ci.DepthStencil)return be.D24_S8;throw Error("whoops")}(e),i=new qi(n);return ra(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}var ia=function(){return u((function e(){l(this,e),this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}),[{key:"reset",value:function(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}},{key:"copy",value:function(e){this.texture=e.texture,this.sampler=e.sampler,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias}}])}(),aa=function(){return u((function e(){l(this,e),this.inputTexture=null,this.outputTexture=null}),[{key:"setDescription",value:function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),He(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new Mi(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))}},{key:"getTextureForSampling",value:function(){return null!==this.inputTexture?this.inputTexture.texture:null}},{key:"getTextureForResolving",value:function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture}},{key:"destroy",value:function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)}}])}(),oa=["style"],sa=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,n=g(e,oa);return l(this,t),h(this,t,[o({type:t.tag,style:o({intensity:Math.PI},r)},n)])}return p(t,e),u(t)}(t.DisplayObject);sa.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["intensity"])),sa.tag="light";var ua=["style"],la=function(e){return e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR",e}({}),ca=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.style,n=g(e,ua);return l(this,t),h(this,t,[o({type:t.tag,style:o({type:la.NONE,fill:"black",start:1,end:1e3,density:0},r)},n)])}return p(t,e),u(t)}(t.DisplayObject);function fa(e,t,r){var n=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:arguments.length>3&&void 0!==arguments[3]?arguments[3]:ge.STATIC});return n.setSubData(0,new Uint8Array(r)),n}ca.PARSED_STYLE_LIST=new Set([].concat(m(t.DisplayObject.PARSED_STYLE_LIST),["type","density","start","end"])),ca.tag="fog";var da,ha,_a=function(e){return e.CHANGED="changed",e}({}),pa=function(e){function r(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l(this,r),(t=h(this,r)).drawMode=Re.TRIANGLES,t.vertexBuffers=[],t.vertices=[],t.inputLayoutDescriptor={vertexBufferDescriptors:[],indexBufferFormat:null,program:null},t.vertexCount=0,t.instancedCount=0,t.indexStart=0,t.primitiveStart=0,t.dirty=!0,t.meshes=[],t.device=e,t.props=n,t}return p(r,e),u(r,[{key:"validate",value:function(e){return!0}},{key:"build",value:function(e){}},{key:"computeBoundingBox",value:function(){return new t.AABB}},{key:"setIndexBuffer",value:function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=fa(this.device,me.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this.inputLayoutDescriptor.indexBufferFormat=be.U32_R,this}},{key:"setVertexBuffer",value:function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={arrayStride:e.byteStride,stepMode:e.stepMode,attributes:[]},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,a=e.location,o=e.divisor,s=t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.find((function(e){return e.shaderLocation===a}));s?(s.format=n,s.offset=i,s.divisor=o):t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.push({format:n,offset:i,shaderLocation:a,divisor:o})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var a=fa(this.device,me.VERTEX,i.buffer,ge.DYNAMIC);return this.vertexBuffers[r]=a,this}},{key:"getVertexBuffer",value:function(e){return this.vertexBuffers[e]}},{key:"updateVertexBuffer",value:function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e];if(i){var a=i.arrayStride,o=this.inputLayoutDescriptor.vertexBufferDescriptors[e].attributes.find((function(e){return e.shaderLocation===t}));if(o)this.getVertexBuffer(e).setSubData(o.offset+r*a,n);this.emit(_a.CHANGED)}}},{key:"updateIndices",value:function(e){return this.indexBuffer&&this.indexBuffer.setSubData(arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this}},{key:"destroy",value:function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0}}])}(Le),Ea=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).features={},e.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",e.vert="#define GLSLIFY 1\nlayout(location = 0) in vec2 a_Position;\n\nout vec2 v_TexCoord;\n\nvoid main() {\n v_TexCoord = 0.5 * (a_Position + 1.0);\n gl_Position = vec4(a_Position, 0., 1.);\n\n #ifdef VIEWPORT_ORIGIN_TL\n v_TexCoord.y = 1.0 - v_TexCoord.y;\n #endif\n}",e.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nfloat MonochromeNTSC(vec3 t_Color) {\n // NTSC primaries.\n return dot(t_Color.rgb, vec3(0.299, 0.587, 0.114));\n}\n\nvec4 FXAA(PD_SAMPLER_2D(t_Texture), in vec2 t_PixelCenter, in vec2 t_InvResolution) {\n // FXAA v2, based on implementations:\n // http://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/\n // https://github.com/mitsuhiko/webgl-meincraft\n\n float lumaMM = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy).rgb);\n\n #if 1\n vec2 t_PixelTopLeft = t_PixelCenter.xy - t_InvResolution.xy * 0.5;\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy) .rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 0.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(0.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 1.0)).rgb);\n #else\n // We're at the pixel center -- pixel edges are 0.5 units away.\n // NOTE(jstpierre): mitsuhiko's port seems to get this wrong?\n vec2 t_PixelSize = t_InvResolution.xy * 0.5;\n\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, -1.0)).rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, -1.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, 1.0)).rgb);\n #endif\n\n vec2 dir; \n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n const float FXAA_REDUCE_MIN = 1.0/128.0;\n const float FXAA_REDUCE_MUL = 1.0/8.0;\n const float FXAA_SPAN_MAX = 8.0;\n\n float dirReduce = max(\n (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\n FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_InvResolution.xy;\n\n float lumaMin = min(lumaMM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaMM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec4 rgbA = (1.0/2.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (1.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (0.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = MonochromeNTSC(rgbB.rgb);\n\n vec4 rgbOutput = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;\n return rgbOutput;\n}\n\nvoid main() {\n outputColor = FXAA(PP_SAMPLER_2D(u_Texture), v_TexCoord.xy, u_InvResolution.xy);\n}",e}return p(t,e),u(t)}(li),va=it(1,(function(){return new ia}));function Ra(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID(Ci.Color0,n);var a=e.resolveRenderTarget(n);i.attachResolveTexture(a);var o=t.renderInstManager.newRenderInst();o.setUniformBuffer(t.uniformBuffer),o.setAllowSkippingIfPipelineNotReady(!1),o.setMegaStateFlags(ht),o.setBindingLayout({numUniformBuffers:1,numSamplers:1}),o.drawPrimitives(3);var s=o.allocateUniformBuffer(0,4);Vi(o.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var u=new Ea,l=t.renderCache.createProgramSimple(u);o.setProgram(l),da||((da=new pa(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([1,3,-3,-1,1,-1])}),da.vertexCount=3,ha=t.getCache().createInputLayout(da.inputLayoutDescriptor)),i.exec((function(e,r){va[0].texture=r.getResolveTextureForID(a),o.setSamplerBindingsFromTextureMappings(va),o.setVertexInput(ha,da.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null),o.drawOnPass(t.renderCache,e)}))}))}var ma=function(e){return e.PROJECTION_MATRIX="u_ProjectionMatrix",e.VIEW_MATRIX="u_ViewMatrix",e.CAMERA_POSITION="u_CameraPosition",e.DEVICE_PIXEL_RATIO="u_DevicePixelRatio",e.VIEWPORT="u_Viewport",e.IS_ORTHO="u_IsOrtho",e.IS_PICKING="u_IsPicking",e}({}),ga=function(){function e(t,r,n,i,a){l(this,e),this.renderLists={leftEye:new Yi,rightEye:new Yi,picking:new Yi},this.cameras=[],this.renderHelper=t,this.lightPool=r,this.texturePool=n,this.batchManager=i,this.options=a}return u(e,[{key:"getDevice",value:function(){return this.device}},{key:"getSwapChain",value:function(){return this.swapChain}},{key:"getRenderLists",value:function(){return this.renderLists}},{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,a=r.config,s=r.renderingContext.root.ownerDocument.defaultView;a.disableRenderHooks=!0;var u=function(e){var t=e.target;t.nodeName!==sa.tag?t.nodeName!==ca.tag?(t.renderable3D||(t.renderable3D=new ni),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},l=function(e){var r=e.target;if(r.nodeName!==sa.tag)if(r.nodeName!==ca.tag){if(r.nodeName===t.Shape.MESH){var i,a;if(null!==(i=r.style.geometry)&&void 0!==i&&i.meshes){var o=r.style.geometry.meshes.indexOf(r);o>-1&&r.style.geometry.meshes.splice(o,1)}if(null!==(a=r.style.material)&&void 0!==a&&a.meshes){var s=r.style.material.meshes.indexOf(r);s>-1&&r.style.material.meshes.splice(s,1)}}n.swapChain&&n.batchManager.remove(r),delete r.renderable3D}else n.lightPool.removeFog(r);else n.lightPool.removeLight(r)},c=function(e){if(n.swapChain){var t=e.target,r=e.attrName,i=e.newValue;"zIndex"===r?t.parentNode.forEach((function(e){n.batchManager.changeRenderOrder(e,e.sortable.renderOrder)})):n.batchManager.updateAttribute(t,r,i)}},f=function(e){if(n.swapChain){var r=e.target;(r.nodeName===t.Shape.FRAGMENT?r.childNodes:[r]).forEach((function(e){n.batchManager.updateAttribute(e,"modelMatrix",null)}))}};i.hooks.initAsync.tapPromise(e.tag,M(P().mark((function e(){var i,a;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s.addEventListener(t.ElementEvent.MOUNTED,u),s.addEventListener(t.ElementEvent.UNMOUNTED,l),s.addEventListener(t.ElementEvent.ATTR_MODIFIED,c),s.addEventListener(t.ElementEvent.BOUNDS_CHANGED,f),n.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,i=n.context.contextService.getDomElement(),n.context.contextService.resize((a=n.context.config).width,a.height),e.next=10,n.context.deviceContribution.createSwapChain(i);case 10:n.swapChain=e.sent,n.device=n.swapChain.getDevice(),n.renderHelper.setDevice(n.device),n.renderHelper.renderInstManager.disableSimpleMode(),n.swapChain.configureSwapChain(i.width,i.height),s.addEventListener(t.CanvasEvent.RESIZE,(function(){n.swapChain.configureSwapChain(i.width,i.height)})),n.batchManager.attach(o({device:n.device},r));case 17:case"end":return e.stop()}}),e)})))),i.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),n.batchManager.destroy(),n.texturePool.destroy(),s.removeEventListener(t.ElementEvent.MOUNTED,u),s.removeEventListener(t.ElementEvent.UNMOUNTED,l),s.removeEventListener(t.ElementEvent.ATTR_MODIFIED,c),s.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,f),n.device.destroy(),n.device.checkForLeaks(),a.disableRenderHooks=!1})),i.hooks.beginFrame.tap(e.tag,(function(e){var r,i=null==e?void 0:e.session,a=n.context.config,o=a.width,s=a.height;if(i){var u=i.renderState.baseLayer;u||(u=i.renderState.layers[0]),n.swapChain.configureSwapChain(u.framebufferWidth,u.framebufferHeight,u.framebuffer);var l=e.getViewerPose(i.referenceSpace);l&&l.views.forEach((function(e,t){var r=i.renderState.baseLayer.getViewport(e),a=U.apply(q,m(e.transform.matrix));a[12]*=o,a[13]*=s,a[14]*=500,a[12]+=o/2,a[13]-=s/2,a[14]+=250;var l=U.apply(q,m(e.projectionMatrix)),c=w(L(),a);V(c,c,Q(1,-1,1));var f=e.transform.position;n.cameras[t]={viewport:{x:r.x/u.framebufferWidth,y:r.y/u.framebufferHeight,width:r.width/u.framebufferWidth,height:r.height/u.framebufferHeight},projectionMatrix:l,viewMatrix:c,cameraPosition:[f.x,f.y,f.z],isOrtho:!1}}))}else{var c=n.context.camera;n.cameras=[{viewport:{x:0,y:0,width:1,height:1},projectionMatrix:c.getPerspective(),viewMatrix:c.getViewTransform(),cameraPosition:c.getPosition(),isOrtho:c.isOrtho()}]}var f,d=n.swapChain.getCanvas(),h=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)f=je;else{var _=t.parseColor(n.context.config.background);f=n.context.config.background?Ke(Number(_.r)/255*Number(_.alpha),Number(_.g)/255*Number(_.alpha),Number(_.b)/255*Number(_.alpha),Number(_.alpha)):qe}var p={backbufferWidth:d.width,backbufferHeight:d.height,antialiasingMode:ta.None},E=na(Ci.Color0,p,Qi(f)),v=na(Ci.DepthStencil,p,ea),R=n.builder.createRenderTargetID(E,"Main Color"),g=n.builder.createRenderTargetID(v,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID(Ci.Color0,R),e.attachRenderTargetID(Ci.DepthStencil,g),e.exec((function(e,t){n.cameras.forEach((function(r,i){var a=r.viewport,o=t.currentPass,s=o.viewportW,u=o.viewportH;e.setViewport(a.x*s,a.y*u,a.width*s,a.height*u),(0===i?n.renderLists.leftEye:n.renderLists.rightEye).drawOnPassRenderer(h.renderCache,e)}))}))})),null!==(r=n.options)&&void 0!==r&&r.enableFXAA&&Ra(n.builder,n.renderHelper,p,R),n.builder.resolveRenderTargetToExternalTexture(R,n.swapChain.getOnscreenTexture())})),i.hooks.endFrame.tap(e.tag,(function(e){var t=n.renderHelper.renderInstManager,r=n.context.config,i=r.width,a=r.height;if(n.cameras.forEach((function(e,r){var o=e.viewport,s=e.cameraPosition,u=e.viewMatrix,l=e.projectionMatrix,c=e.isOrtho,f=o.width,d=o.height,h=n.renderHelper.pushTemplateRenderInst();h.setBindingLayout({numUniformBuffers:2,numSamplers:0}),h.setMegaStateFlags(_t({depthWrite:!0,blendConstant:je},{rgbBlendMode:_e.ADD,alphaBlendMode:_e.ADD,rgbBlendSrcFactor:he.SRC_ALPHA,alphaBlendSrcFactor:he.ONE,rgbBlendDstFactor:he.ONE_MINUS_SRC_ALPHA,alphaBlendDstFactor:he.ONE_MINUS_SRC_ALPHA})),h.setUniforms(0,[{name:ma.PROJECTION_MATRIX,value:l},{name:ma.VIEW_MATRIX,value:u},{name:ma.CAMERA_POSITION,value:s},{name:ma.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:ma.VIEWPORT,value:[i*f,a*d]},{name:ma.IS_ORTHO,value:c?1:0},{name:ma.IS_PICKING,value:0}]),n.batchManager.render(0===r?n.renderLists.leftEye:n.renderLists.rightEye),t.popTemplateRenderInst()})),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),t.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var o=n.captureOptions,s=o.type,u=o.encoderOptions,l=n.context.contextService.getDomElement().toDataURL(s,u);n.resolveCapturePromise(l),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))}},{key:"loadTexture",value:function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))}},{key:"toDataURL",value:(r=M(P().mark((function e(t){var r=this;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.enableCapture=!0,this.captureOptions=t,this.capturePromise=new Promise((function(e){r.resolveCapturePromise=function(t){e(t)}})),e.abrupt("return",this.capturePromise);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})}]);var r}();ga.tag="RenderGraph";var Ta=function(){function e(t,r,n,i){l(this,e),this.renderHelper=t,this.renderGraphPlugin=r,this.pickingIdGenerator=n,this.batchManager=i}return u(e,[{key:"apply",value:function(r){var n=this;this.context=r;var i=r.renderingService,a=r.renderingContext.root.ownerDocument.defaultView,o=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new ni);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)},s=function(e){var t=e.target.renderable3D;t&&n.pickingIdGenerator.deleteById(t.pickingId)};i.hooks.init.tap(e.tag,(function(){a.addEventListener(t.ElementEvent.MOUNTED,o),a.addEventListener(t.ElementEvent.UNMOUNTED,s)})),i.hooks.destroy.tap(e.tag,(function(){a.removeEventListener(t.ElementEvent.MOUNTED,o),a.removeEventListener(t.ElementEvent.UNMOUNTED,s),n.pickingIdGenerator.reset()})),i.hooks.pickSync.tap(e.tag,(function(e){return n.pick(e)})),i.hooks.pick.tapPromise(e.tag,function(){var e=M(P().mark((function e(t){return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.pick(t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"pick",value:function(e){var r=e.topmost,n=e.position,i=n.viewportX,a=n.viewportY,o=this.context.contextService.getDPR(),s=this.context.config.width*o,u=this.context.config.height*o,l=i*o,c=a*o;if(!this.renderHelper.renderGraph||l>s||0>l||c>u||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(x(Math.round(l),0,s-1),x(Math.round(c),0,u-1),1,1),r?1:100);return e.picked=f,e}},{key:"pickByRectangleInDepth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=null,n=1,i=[];do{if(!(r=this.pickByRectangle(e,r)))break;n++,i.push(r)}while(r&&t>=n);return t>1&&this.restorePickingColor(i),i}},{key:"restorePickingColor",value:function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))}},{key:"pickByRectangle",value:function(e,t){var r,n=this,i=this.renderGraphPlugin.getDevice(),a=this.renderGraphPlugin.getRenderLists(),s=this.renderHelper.renderInstManager,u=this.renderHelper.renderGraph.newGraphBuilder(),l=this.context.camera,c=e.x,f=e.y,d=e.width,h=e.height,_={backbufferWidth:d,backbufferHeight:h,antialiasingMode:ta.None},p=na(Ci.Color0,_,Qi(je)),E=u.createRenderTargetID(p,"Picking Color"),v=na(Ci.DepthStencil,_,ea),R=u.createRenderTargetID(v,"Picking Depth"),m=o({},l.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),u.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID(Ci.Color0,E),e.attachRenderTargetID(Ci.DepthStencil,R),e.exec((function(e){a.picking.drawOnPassRenderer(s.renderCache,e)})),e.post((function(e){var t,a=e.getRenderTargetTexture(Ci.Color0),o=i.createReadback();m&&m.enabled?l.setViewOffset(m.fullWidth,m.fullHeight,m.offsetX,m.offsetY,m.width,m.height):l.clearViewOffset(),l.setEnableUpdate(!0);try{t=o.readTextureSync(a,0,0,d,h,new Uint8Array(d*h*4))}catch(e){}var s=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(s=n.pickingIdGenerator.decodePickingColor(t)),s>-1){var u=n.pickingIdGenerator.getById(s);u&&u.isVisible()&&u.isInteractive()&&(r=u)}o.destroy()}))}));var g=this.renderHelper.pushTemplateRenderInst();g.setBindingLayout({numUniformBuffers:2,numSamplers:0}),g.setMegaStateFlags(_t({depthWrite:!0},{rgbBlendMode:_e.ADD,rgbBlendSrcFactor:he.ONE,rgbBlendDstFactor:he.ZERO,alphaBlendMode:_e.ADD,alphaBlendSrcFactor:he.ONE,alphaBlendDstFactor:he.ZERO}));var T=this.context.config,A=T.width,y=T.height,S=this.context.contextService.getDPR();return l.setEnableUpdate(!1),l.setViewOffset(A*S,y*S,c,y*S-f,d,h),g.setUniforms(0,[{name:ma.PROJECTION_MATRIX,value:l.getPerspective()},{name:ma.VIEW_MATRIX,value:l.getViewTransform()},{name:ma.CAMERA_POSITION,value:l.getPosition()},{name:ma.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:ma.VIEWPORT,value:[d,h]},{name:ma.IS_ORTHO,value:l.isOrtho()?1:0},{name:ma.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(a.picking,!0),s.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),s.resetRenderInsts(),r}}])}();Ta.tag="WebGLPicker";var Aa=5e-4,ya=function(){return u((function e(){l(this,e),this.clipPathMeshCreated=!1}),[{key:"beforeUploadUBO",value:function(e,t){}},{key:"beforeInitMesh",value:function(e){}},{key:"afterInitMesh",value:function(e){}}])}();var Sa=function(e){return e.CHANGED="changed",e}({}),Ca=function(e){function t(e,r){var n;l(this,t),(n=h(this,t)).props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var i=ct(dt),a=i.cullMode,s=i.depthCompare,u=i.depthWrite,c=i.stencilFront,f=i.stencilBack,d=i.stencilWrite,_=i.frontFace,p=i.polygonOffset,E=i.attachmentsState;return n.device=e,n.props=o({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:u,stencilFront:c,stencilBack:f,stencilWrite:d,frontFace:_,polygonOffset:p,attachmentsState:E,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return p(t,e),u(t,[{key:"cullMode",get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e}},{key:"frontFace",get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e}},{key:"blendConstant",get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e}},{key:"blendEquation",get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e}},{key:"blendEquationAlpha",get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e}},{key:"blendSrc",get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e}},{key:"blendDst",get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e}},{key:"blendSrcAlpha",get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e}},{key:"blendDstAlpha",get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e}},{key:"depthCompare",get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e}},{key:"depthTest",get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e}},{key:"depthWrite",get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e}},{key:"stencilFront",get:function(){return this.props.stencilFront},set:function(e){this.props.stencilFront=e}},{key:"stencilBack",get:function(){return this.props.stencilBack},set:function(e){this.props.stencilBack=e}},{key:"stencilWrite",get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e}},{key:"stencilRef",get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e}},{key:"polygonOffset",get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e}},{key:"dithering",get:function(){return this.props.dithering},set:function(e){this.props.dithering=e}},{key:"wireframe",get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e}},{key:"wireframeColor",get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e}},{key:"wireframeLineWidth",get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e}},{key:"vertexShader",get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())}},{key:"fragmentShader",get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())}},{key:"compile",value:function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,r){return e.samplers.push(r),""})),this.uniformNames=function(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().replace("\r\n","\n").split("\n").forEach((function(e){var t=ie(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})})),r.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform(?:\s+)(?:\w+)(?:\s?){([^]*?)};?/g,(function(e,n){return n.trim().replace("\r\n","\n").split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",a=n[1]||"",o=a.indexOf("[")>-1;if(a=a.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(o)for(var u=function(e){s.uniforms.forEach((function(r){t.push("".concat(a,"[").concat(e,"].").concat(r.name))}))},l=0;5>l;l++)u(l);else s.uniforms.forEach((function(e){t.push("".concat(a,".").concat(e.name))}))}a&&t.push(a)}})),""})),t}(this.props.fragmentShader)}},{key:"setUniforms",value:function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,a=e[n],o=t.textures[n];o&&o!==a&&(t.textureDirty=!0),(i=a)&&i.type?(t.textures[n]=a,t.textureDirty=!0,a.on(Ae.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=a,r=!0),O(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()}},{key:"dispatchMutationEvent",value:function(){this.emit(Sa.CHANGED)}}])}(Le),Pa=function(e){function t(e,r){var n;return l(this,t),(n=h(this,t,[e,o({},r)])).defines=o(o({},n.defines),{},{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return p(t,e),u(t)}(Ca);function Na(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function Ma(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var Oa=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=C(e,2);return void 0!==t[1]})))};function Ia(e,t){return 256*(e=x(Math.floor(e),0,255))+(t=x(Math.floor(t),0,255))}var xa=1,Ba="FillTextureMapping",Da=function(e){return e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.PACKED_COLOR=1]="PACKED_COLOR",e[e.PACKED_STYLE=2]="PACKED_STYLE",e[e.PICKING_COLOR=3]="PICKING_COLOR",e[e.POSITION=4]="POSITION",e[e.NORMAL=5]="NORMAL",e[e.UV=6]="UV",e[e.BARYCENTRIC=7]="BARYCENTRIC",e[e.MAX=8]="MAX",e}({}),ba=function(e){return e[e.MODEL_MATRIX0=0]="MODEL_MATRIX0",e[e.MODEL_MATRIX1=1]="MODEL_MATRIX1",e[e.MODEL_MATRIX2=2]="MODEL_MATRIX2",e[e.MODEL_MATRIX3=3]="MODEL_MATRIX3",e[e.PACKED_COLOR=4]="PACKED_COLOR",e[e.PACKED_STYLE1=5]="PACKED_STYLE1",e[e.PACKED_STYLE2=6]="PACKED_STYLE2",e[e.PICKING_COLOR=7]="PICKING_COLOR",e[e.POSITION=8]="POSITION",e[e.NORMAL=9]="NORMAL",e[e.UV=10]="UV",e[e.BARYCENTRIC=11]="BARYCENTRIC",e[e.MAX=12]="MAX",e}({}),La=function(){return u((function e(t,r,n,i,a){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:-1,s=arguments.length>6?arguments[6]:void 0;l(this,e),this.id=xa++,this.gradientAttributeName="fill",this.objects=[],this.program=new li,this.geometryDirty=!0,this.materialDirty=!0,this.textureMappings=[],this.divisor=1,this.mergeXYZIntoModelMatrix=!1,this.checkNodeName=!0,this.maxInstances=1/0,this.inited=!1,this.renderHelper=t,this.texturePool=r,this.lightPool=n,this.drawcallCtors=a,this.index=o,this.context=s}),[{key:"instance",get:function(){return this.objects[0]}},{key:"init",value:function(){this.inited||(this.renderer.beforeInitMesh(this),this.material=new Pa(this.context.device),this.material.defines=o(o({},Na(ba)),this.material.defines),this.geometry=new pa(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))}},{key:"observeGeometryChanged",value:function(){var e=this;this.geometry.on(_a.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))}},{key:"observeMaterialChanged",value:function(){var e=this;this.material.on(Sa.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))}},{key:"shouldMergeColor",value:function(e,r,n){var i=e.parsedStyle[n],a=r.parsedStyle[n];return!i&&!a||(!(!t.isCSSRGB(i)||!t.isCSSRGB(a))||(!(!t.isPattern(i)||!t.isPattern(a)||i.image!==a.image)||!(!Array.isArray(i)||!Array.isArray(a)||e.style[n]!==r.style[n])))}},{key:"shouldMerge",value:function(e,t){return!this.instance||(!this.checkNodeName||this.instance.nodeName===e.nodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))}},{key:"createGeometry",value:function(e){var r,n,i=this,a=L(),o=L(),s=[],u=[],l=[],c=[],f=this.divisor,d=(null===(r=e[0])||void 0===r?void 0:r.nodeName)===t.Shape.CIRCLE||(null===(n=e[0])||void 0===n?void 0:n.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach((function(e){var r,n=e.parsedStyle,f=n.fill,h=n.stroke,_=n.opacity,p=void 0===_?1:_,E=n.fillOpacity,v=void 0===E?1:E,R=n.strokeOpacity,g=void 0===R?1:R,T=n.lineWidth,A=void 0===T?1:T,y=n.visibility,S=n.increasedLineWidthForHitTesting,C=void 0===S?0:S,P=[0,0,0,0];t.isCSSRGB(f)&&(P=[Number(f.r),Number(f.g),Number(f.b),255*Number(f.alpha)]);var N=[0,0,0,0];t.isCSSRGB(h)&&(N=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]),Z(o,i.context.camera.getViewTransform(),a);var M=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];if(i.mergeXYZIntoModelMatrix){var O=e.parsedStyle,I=O.x,x=O.y,B=O.z;Z(a,e.getWorldTransform(),X(a,Q(I,x,B)))}else F(a,e.getWorldTransform());s.push.apply(s,m(a)),u.push(Ia(P[0],P[1]),Ia(P[2],P[3]),Ia(N[0],N[1]),Ia(N[2],N[3])),l.push(p,v,g,A,"hidden"!==y?1:0,d,d,C),c.push.apply(c,m(M).concat([e.sortable.renderOrder*Aa]))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:Da.MODEL_MATRIX,byteStride:64,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.MODEL_MATRIX0,divisor:f},{format:be.F32_RGBA,bufferByteOffset:16,location:ba.MODEL_MATRIX1,divisor:f},{format:be.F32_RGBA,bufferByteOffset:32,location:ba.MODEL_MATRIX2,divisor:f},{format:be.F32_RGBA,bufferByteOffset:48,location:ba.MODEL_MATRIX3,divisor:f}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Da.PACKED_COLOR,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.PACKED_COLOR,divisor:f}],data:new Float32Array(u)}),this.geometry.setVertexBuffer({bufferIndex:Da.PACKED_STYLE,byteStride:32,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.PACKED_STYLE1,divisor:f},{format:be.F32_RGBA,bufferByteOffset:16,location:ba.PACKED_STYLE2,divisor:f}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:Da.PICKING_COLOR,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.PICKING_COLOR,divisor:f}],data:new Float32Array(c)})}},{key:"destroy",value:function(){this.geometry&&this.geometry.destroy()}},{key:"applyRenderInst",value:function(e,t){var r=this,n=!!this.lightPool.getFog();this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilFront={compare:ce.ALWAYS,passOp:Pe.REPLACE},this.material.stencilBack={compare:ce.ALWAYS,passOp:Pe.REPLACE}):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilFront={compare:ce.EQUAL,passOp:Pe.KEEP},this.material.stencilBack={compare:ce.EQUAL,passOp:Pe.KEEP}):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var i=o({},this.material.defines);if(this.material.defines.USE_FOG=n,this.material.defines=o(o(o({},this.lightPool.getDefines()),this.material.defines),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a&&this.textureMappings.push(a),Object.keys(this.material.textures).sort((function(e,t){return r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)})).forEach((function(e){var t=new ia;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture ".concat(e)),t.sampler=r.renderHelper.getCache().createSampler({addressModeU:pe.CLAMP_TO_EDGE,addressModeV:pe.CLAMP_TO_EDGE,minFilter:Ee.POINT,magFilter:Ee.BILINEAR,mipmapFilter:ve.LINEAR,lodMinClamp:0,lodMaxClamp:0}),r.textureMappings.push(t)})),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(!Ma(i,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=o(o({},this.material.defines),Na(ba)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"boolean"==typeof t?r.program.setDefineBool(e,t):r.program.setDefineString(e,"".concat(t))})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.material.geometryDirty=!1),(this.geometryDirty||this.geometry.dirty)&&(this.geometry&&this.geometry.destroy(),this.createGeometry(t),this.material.wireframe&&this.generateWireframe(this.geometry),this.geometryDirty=!1,this.geometry.dirty=!1);var s=this.renderHelper.getCache().createProgramSimple(this.program),u=this.renderHelper.getCache().createInputLayout(o(o({},this.geometry.inputLayoutDescriptor),{},{program:s})),l=!!this.geometry.indexBuffer;e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setVertexInput(u,this.geometry.vertexBuffers.filter((function(e){return!!e})).map((function(e){return{buffer:e,byteOffset:0}})),l?{buffer:this.geometry.indexBuffer,offset:0}:null),this.renderer.beforeUploadUBO(e,this),this.uploadUBO(e),l?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=Li(xi.OPAQUE,t[0].sortable.renderOrder)}},{key:"updateBatchedAttribute",value:function(e,r,n,i){var a=this;if(0!==e.length){if("fill"===n||"stroke"===n){var o=[];e.forEach((function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=[0,0,0,0];t.isCSSRGB(n)&&(a=[Number(n.r),Number(n.g),Number(n.b),255*Number(n.alpha)]);var s=[0,0,0,0];t.isCSSRGB(i)&&(s=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]),o.push(Ia(a[0],a[1]),Ia(a[2],a[3]),Ia(s[0],s[1]),Ia(s[2],s[3]))})),this.geometry.updateVertexBuffer(Da.PACKED_COLOR,ba.PACKED_COLOR,r,new Uint8Array(new Float32Array(o).buffer));var s=this.instance.parsedStyle.fill,u=this.textureMappings.findIndex((function(e){return e.name===Ba}));if(t.isCSSRGB(s))0>u||(this.textureMappings.splice(u,-1),this.material.textureDirty=!0);else{var l=this.createFillGradientTextureMapping([this.instance]);0>u||this.textureMappings.splice(u,1,l),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var c,f,d=[],h=(null===(c=e[0])||void 0===c?void 0:c.nodeName)===t.Shape.CIRCLE||(null===(f=e[0])||void 0===f?void 0:f.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach((function(e){var t=e.parsedStyle,r=t.opacity,n=t.fillOpacity,i=t.strokeOpacity,a=t.lineWidth,o=t.increasedLineWidthForHitTesting;d.push(void 0===r?1:r,void 0===n?1:n,void 0===i?1:i,void 0===a?1:a,"hidden"!==t.visibility?1:0,h,h,void 0===o?0:o)})),this.geometry.updateVertexBuffer(Da.PACKED_STYLE,ba.PACKED_STYLE1,r,new Uint8Array(new Float32Array(d).buffer))}else if("modelMatrix"===n||this.mergeXYZIntoModelMatrix&&("x"===n||"y"===n||"z"===n)){var _=[],p=L();e.forEach((function(e){if(a.mergeXYZIntoModelMatrix){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;Z(p,e.getWorldTransform(),X(p,Q(r,n,i)))}else F(p,e.getWorldTransform());_.push.apply(_,m(p))})),this.geometry.updateVertexBuffer(Da.MODEL_MATRIX,ba.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(_).buffer))}else if("pointerEvents"===n){var E=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];E.push.apply(E,m(r).concat([e.sortable.renderOrder*Aa]))})),this.geometry.updateVertexBuffer(Da.PICKING_COLOR,ba.PICKING_COLOR,r,new Uint8Array(new Float32Array(E).buffer))}}}},{key:"updateAttribute",value:function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0),!0===this.geometryDirty&&0!==this.objects.length&&(this.geometry&&this.geometry.destroy(),this.createGeometry(this.objects),this.geometryDirty=!1)}},{key:"changeRenderOrder",value:function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(Da.PICKING_COLOR,ba.PICKING_COLOR,n,new Uint8Array(new Float32Array([].concat(m(i),[t*Aa])).buffer))}},{key:"generateWireframe",value:function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=Da.PICKING_COLOR;e.vertexBuffers.length>i;i++){e.vertices[i]=new Float32Array(e.inputLayoutDescriptor.vertexBufferDescriptors[i].arrayStride/4*r)}for(var a=0,o=new Uint32Array(r),s=0;r>s;s++){for(var u=t[s],l=1;e.vertices.length>l;l++)for(var c=e.inputLayoutDescriptor.vertexBufferDescriptors[l].arrayStride/4,f=0;c>f;f++)e.vertices[l][a*c+f]=n[l][u*c+f];o[s]=a,a++}for(var d=Da.PICKING_COLOR+1;e.vertexBuffers.length>d;d++){var h=e.inputLayoutDescriptor.vertexBufferDescriptors[d],_=e.inputLayoutDescriptor.vertexBufferDescriptors[d].attributes[0];if(_)e.setVertexBuffer({bufferIndex:d,byteStride:h.arrayStride,stepMode:h.stepMode,attributes:[{format:_.format,bufferByteOffset:_.offset,location:_.shaderLocation,divisor:_.divisor}],data:e.vertices[d]})}for(var p=new Float32Array(3*r),E=0;r>E;)for(var v=0;3>v;v++){p[3*o[E++]+v]=1}e.setVertexBuffer({bufferIndex:Da.BARYCENTRIC,byteStride:12,stepMode:Te.VERTEX,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:Number(ba.BARYCENTRIC)}],data:p}),e.setIndexBuffer(o)}},{key:"beforeUploadUBO",value:function(e,t){}},{key:"uploadUBO",value:function(e){var r,n=this,i=this.material,a=this.lightPool.getAllLights(),s=this.lightPool.getFog(),u=!!s,l=null!==(r=i.defines.USE_LIGHT)&&void 0!==r?r:!!a.length,c=[];if(i.defines.USE_WIREFRAME){var f=t.parseColor(i.wireframeColor);c.push({name:"u_WireframeLineColor",value:[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255]}),c.push({name:"u_WireframeLineWidth",value:i.wireframeLineWidth})}if(u&&this.uploadFog(c,s),this.uploadMaterial(c,i),l){var d={};a.forEach((function(e){d[e.define]||(d[e.define]=-1),d[e.define]++,e.uploadUBO(c,d[e.define])}))}c.sort((function(e,t){return n.material.uniformNames.indexOf(e.name)-n.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,c);var h=i.blendEquation,_=i.blendEquationAlpha,p=i.blendSrc,E=i.blendDst,v=i.blendSrcAlpha,R=i.blendDstAlpha,m=Oa({blendConstant:i.blendConstant,depthCompare:i.depthCompare,depthWrite:i.depthWrite,stencilFront:i.stencilFront,stencilBack:i.stencilBack,stencilWrite:i.stencilWrite,stencilRef:i.stencilRef,cullMode:i.cullMode,frontFace:i.frontFace,polygonOffset:i.polygonOffset}),g=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(o({attachmentsState:[{channelWriteMask:this.material.stencilWrite?Ce.NONE:Ce.ALL,rgbBlendState:o(o({},g.rgbBlendState),Oa({blendMode:h,blendSrcFactor:p,blendDstFactor:E})),alphaBlendState:o(o({},g.alphaBlendState),Oa({blendMode:_,blendSrcFactor:v,blendDstFactor:R}))}]},m)),e.setBindingLayout({numUniformBuffers:1,numSamplers:this.textureMappings.length}),e.setSamplerBindingsFromTextureMappings(this.textureMappings)}},{key:"uploadFog",value:function(e,r){var n=r.parsedStyle,i=n.type,a=n.fill,o=n.start,s=n.end,u=n.density;if(t.isCSSRGB(a)){var l=[Number(a.r)/255,Number(a.g)/255,Number(a.b)/255,Number(a.alpha)];e.push({name:"u_FogInfos",value:[i,o,s,u]}),e.push({name:"u_FogColor",value:l})}}},{key:"uploadMaterial",value:function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,m(r))}},{key:"createFillGradientTextureMapping",value:function(e){var r,n=this,i=e[0],a=i.parsedStyle[this.gradientAttributeName];if(a&&(t.isPattern(a)||Array.isArray(a))){Array.isArray(a)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:a,width:128,height:128,instance:i})):t.isPattern(a)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(a,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var o=this.texturePool.getOrCreateTexture(this.context.device,r,Fe(be.U8_RGBA_NORM,1,1,1));if(o){var s=new ia;return s.name=Ba,s.texture=o,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.context.device.setResourceName(s.texture,"Fill Texture".concat(this.id)),s.sampler=this.renderHelper.getCache().createSampler({addressModeU:pe.CLAMP_TO_EDGE,addressModeV:pe.CLAMP_TO_EDGE,minFilter:Ee.POINT,magFilter:Ee.BILINEAR,mipmapFilter:ve.LINEAR,lodMinClamp:0,lodMaxClamp:0}),s}}return null}}])}(),Fa=function(e){return e[e.PACKED_STYLE=Da.POSITION+1]="PACKED_STYLE",e}(Fa||{}),Ua=function(e){return e[e.PACKED_STYLE3=ba.MAX]="PACKED_STYLE3",e[e.EXTRUDE=1+e.PACKED_STYLE3]="EXTRUDE",e[e.SIZE=1+e.EXTRUDE]="SIZE",e}(Ua||{}),ka=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],wa=function(e){function r(){return l(this,r),h(this,r,arguments)}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = EXTRUDE) in vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec3 a_StylePacked3;\nlayout(location = SIZE) in vec4 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec2 v_Data;\nout vec2 v_Radius;\nout vec3 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size.xy + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size.xy + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n\n bool isBillboard = a_Size.z > 0.5;\n if (isBillboard) {\n float rotation = 0.0;\n bool isSizeAttenuation = a_Size.w > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec2(a_Extrude * radius / radius.y);\n v_StylePacked3 = a_StylePacked3;\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec2 v_Data;\nin vec2 v_Radius;\nin vec3 v_StylePacked3;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n p = abs(p) - b + r;\n return length(max(p, 0.0)) + min(max(p.x, p.y), 0.0) - r;\n}\n\nvoid main() {\n int shape = int(floor(v_StylePacked3.x + 0.5));\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius.y;\n float wh = v_Radius.x / v_Radius.y;\n\n float dist = length(v_Data);\n float antialiased_blur = -fwidth(dist);\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data, 1.0);\n inner_df = sdCircle(v_Data, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data, r, useRadius ? (v_StylePacked3.y - u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Na(Ua))}},{key:"createGeometry",value:function(e){var t=this;A(r,"createGeometry",this,3)([e]);var n=[],i=[];e.forEach((function(e,r){var a=e,o=a.parsedStyle.radius,s=t.shouldOmitStroke(a.parsedStyle),u=t.getSize(e.parsedStyle,a.nodeName),l=t.getPosition(e.parsedStyle,a.nodeName);n.push.apply(n,m(u).concat([a.parsedStyle.isBillboard?1:0,a.parsedStyle.isSizeAttenuation?1:0,ka.indexOf(a.nodeName),o&&o[0]||0,s?1:0])),i.push.apply(i,m(l))})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Da.UV,byteStride:16,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:Ua.EXTRUDE},{format:be.F32_RG,bufferByteOffset:8,location:ba.UV}],data:new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1])}),this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:12,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:ba.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Fa.PACKED_STYLE,byteStride:28,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Ua.SIZE,divisor:1},{format:be.F32_RGB,bufferByteOffset:16,location:Ua.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)})}},{key:"updateAttribute",value:function(e,t,n,i){var a=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n||"isBillboard"===n||"isSizeAttenuation"===n){var o=[];e.forEach((function(e){var t=e,r=a.shouldOmitStroke(t.parsedStyle),n=C(a.getSize(e.parsedStyle,e.nodeName),2);o.push.apply(o,[n[0],n[1]].concat([t.parsedStyle.isBillboard?1:0,t.parsedStyle.isSizeAttenuation?1:0,ka.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0]))})),this.geometry.updateVertexBuffer(Fa.PACKED_STYLE,Ua.SIZE,t,new Uint8Array(new Float32Array(o).buffer))}else if("cx"===n||"cy"===n||"x"===n||"y"===n){var s=[];e.forEach((function(e){var t=C(a.getPosition(e.parsedStyle,e.nodeName),2);s.push(t[0],t[1])})),this.geometry.updateVertexBuffer(Da.POSITION,ba.POSITION,t,new Uint8Array(new Float32Array(s).buffer))}}},{key:"getPosition",value:function(e,r){var n=[0,0,0];if(r===t.Shape.CIRCLE||r===t.Shape.ELLIPSE){var i=e.cx,a=e.cy,o=e.cz;n=[void 0===i?0:i,void 0===a?0:a,void 0===o?0:o]}else if(r===t.Shape.RECT){var s=e.x,u=e.y,l=e.z;n=[void 0===s?0:s,void 0===u?0:u,void 0===l?0:l]}return n}},{key:"getSize",value:function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}else if(r===t.Shape.RECT){n=[e.width/2,e.height/2]}return n}},{key:"shouldOmitStroke",value:function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,a=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(a||1>n)}}])}(La);function Ga(e,t,r,n,i,a){for(var o=i[i.length-3],s=i[i.length-2],u=null!=a?a:x(ri(o,s,e,t,r,n,3)/10,8,100),l=0,c=0,f=1;u>=f;++f){var d=f/u;i.push((l=o+(e-o)*d)+(e+(r-e)*d-l)*d,(c=s+(t-s)*d)+(t+(n-t)*d-c)*d,0)}}function Va(e,t,r,n,i,a,o,s){var u=o[o.length-3],l=o[o.length-2];o.length-=3;var c=null!=s?s:x(ei(u,l,e,t,r,n,i,a,3)/10,8,100),f=0,d=0,h=0,_=0,p=0;o.push(u,l,0);for(var E=1,v=0;c>=E;++E)o.push((h=(d=(f=1-(v=E/c))*f)*f)*u+3*d*v*e+3*f*(_=v*v)*r+(p=_*v)*i,h*l+3*d*v*t+3*f*_*n+p*a,0)}var Xa=1e20,Wa=function(){return u((function e(t,r){l(this,e);var n=t.fontSize,i=void 0===n?24:n,a=t.buffer,o=void 0===a?3:a,s=t.radius,u=void 0===s?8:s,c=t.cutoff,f=void 0===c?.25:c,d=t.fontFamily,h=void 0===d?"sans-serif":d,_=t.fontWeight,p=void 0===_?"normal":_,E=t.fontStyle,v=void 0===E?"normal":E,R=t.canvas;this.buffer=o,this.cutoff=f,this.radius=u;var m=this.size=i+4*o,g=r.offscreenCanvasCreator.getOrCreateCanvas(R);g.width=m,g.height=m;var T=r.offscreenCanvasCreator.getOrCreateContext(R,{willReadFrequently:!0});this.ctx=T,T.font="".concat(v," ").concat(p," ").concat(i,"px ").concat(h),T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(m*m),this.gridInner=new Float64Array(m*m),this.f=new Float64Array(m),this.z=new Float64Array(m+1),this.v=new Uint16Array(m)}),[{key:"draw",value:function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,a=t.actualBoundingBoxRight,o=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),u=Math.min(this.size-this.buffer,o+Math.ceil(n)),l=s+2*this.buffer,c=u+2*this.buffer,f=Math.max(l*c,0),d=new Uint8ClampedArray(f),h={data:d,width:l,height:c,glyphWidth:s,glyphHeight:u,glyphTop:o,glyphLeft:0,glyphAdvance:r};if(0===s||0===u)return h;var _=this.ctx,p=this.buffer,E=this.gridInner,v=this.gridOuter;_.clearRect(p,p,s,u),_.fillText(e,p,p+o);var R=_.getImageData(p,p,s,u);v.fill(Xa,0,f),E.fill(0,0,f);for(var m=0;u>m;m++)for(var g=0;s>g;g++){var T=R.data[4*(m*s+g)+3]/255;if(0!==T){var A=(m+p)*l+g+p;if(1===T)v[A]=0,E[A]=Xa;else{var y=.5-T;v[A]=y>0?y*y:0,E[A]=0>y?y*y:0}}}Ha(v,0,0,l,c,l,this.f,this.v,this.z),Ha(E,p,p,s,u,l,this.f,this.v,this.z);for(var S=0;f>S;S++){d[S]=Math.round(255-255*((Math.sqrt(v[S])-Math.sqrt(E[S]))/this.radius+this.cutoff))}return h}}])}();function Ha(e,t,r,n,i,a,o,s,u){for(var l=t;t+n>l;l++)za(e,r*a+l,a,i,o,s,u);for(var c=r;r+i>c;c++)za(e,c*a+t,1,n,o,s,u)}function za(e,t,r,n,i,a,o){a[0]=0,o[0]=-Xa,o[1]=Xa,i[0]=e[t];for(var s=1,u=0,l=0;n>s;s++){i[s]=e[t+s*r];var c=s*s;do{var f=a[u];l=(i[s]-i[f]+c-f*f)/(s-f)/2}while(o[u]>=l&&--u>-1);a[++u]=s,o[u]=l,o[u+1]=Xa}for(var d=0,h=0;n>d;d++){for(;d>o[h+1];)h++;var _=a[h],p=d-_;e[t+d*r]=i[_]+p*p}}var Ya=function(e){return e[e.PACKED=Da.POSITION+1]="PACKED",e[e.VERTEX_NUM=1+e.PACKED]="VERTEX_NUM",e[e.TRAVEL=1+e.VERTEX_NUM]="TRAVEL",e[e.DASH=1+e.TRAVEL]="DASH",e}(Ya||{}),Ka=function(e){return e[e.PREV=ba.POSITION]="PREV",e[e.POINT1=1+e.PREV]="POINT1",e[e.POINT2=1+e.POINT1]="POINT2",e[e.NEXT=1+e.POINT2]="NEXT",e[e.VERTEX_JOINT=1+e.NEXT]="VERTEX_JOINT",e[e.VERTEX_NUM=1+e.VERTEX_JOINT]="VERTEX_NUM",e[e.TRAVEL=1+e.VERTEX_NUM]="TRAVEL",e[e.DASH=1+e.TRAVEL]="DASH",e}(Ka||{});function ja(e,t,r){return 4*(e?1:0)+2*(t?1:0)+(r?1:0)}function Za(e){if(!(e.nodeName===t.Shape.POLYLINE))return!1;var r=e.parsedStyle.points.points;return r.length&&!O(r[0][2])}var qa=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).segmentNum=-1,u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.segmentNum=u.calcSegmentNum(i),u.gradientAttributeName="stroke",u}return p(r,e),u(r,[{key:"calcSegmentNum",value:function(e){return eo(e,!1,12,this.calcSubpathIndex(e)).instancedCount}},{key:"calcSubpathIndex",value:function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===io})).length;return this.index-r}return 0}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);if(!n)return!1;if(this.index!==t)return!1;var i=this.calcSegmentNum(e);return this.segmentNum===i}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = PREV) in vec3 a_Prev;\nlayout(location = POINT1) in vec3 a_Point1;\nlayout(location = POINT2) in vec3 a_Point2;\nlayout(location = NEXT) in vec3 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\nout vec4 v_Dash;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nconst float u_Expand = 1.0;\nconst float u_MiterLimit = 5.0;\nconst float u_ScaleMode = 1.0;\nconst float u_Alignment = 0.5;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\nout float v_ScalingFactor;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvec2 clip2ScreenSpace(vec4 clip) {\n return u_Viewport * (0.5 * clip.xy / clip.w + 0.5);\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n v_Dash = a_Dash;\n\n vec2 pointA;\n vec2 pointB;\n vec4 clip0;\n vec4 clip1;\n\n float compressed = a_Dash.w;\n float is_billboard = floor(compressed / 4.0);\n compressed -= is_billboard * 4.0;\n float is_size_attenuation = floor(compressed / 2.0);\n compressed -= is_size_attenuation * 2.0;\n float is_3d_polyline = compressed;\n\n bool isBillboard = is_billboard > 0.5;\n bool isSizeAttenuation = is_size_attenuation > 0.5;\n bool is3DPolyline = is_3d_polyline > 0.5;\n if (isBillboard) {\n clip0 = billboard(a_Point1.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n clip1 = billboard(a_Point2.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else if (is3DPolyline) {\n clip0 = project(vec4(a_Point1, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = project(vec4(a_Point2, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n if (isBillboard || is3DPolyline) {\n pointA = clip2ScreenSpace(clip0);\n pointB = clip2ScreenSpace(clip1);\n } else {\n pointA = (u_ModelMatrix * vec4(a_Point1, 1.0)).xy;\n pointB = (u_ModelMatrix * vec4(a_Point2, 1.0)).xy;\n }\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Prev.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Prev, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Prev, 1.0)).xy;\n }\n\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Next.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Next, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 1.0)).xy;\n }\n \n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n // TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n v_ScalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n\n if (isBillboard || is3DPolyline) {\n vec4 clip = mix(clip0, clip1, 0.5);\n gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\nin float v_ScalingFactor;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Na(Ka))}},{key:"createGeometry",value:function(e){var t=this,n=[],i=[],a=[],o=[],s=0,u=0;e.forEach((function(e){var r=eo(e,!1,12,t.calcSubpathIndex(e)),l=r.pointsBuffer,c=r.travelBuffer,f=r.instancedCount,d=e.parsedStyle,h=d.lineDash;o.push(h&&h[0]||0,h&&h[1]||0,d.lineDashOffset||0,ja(d.isBillboard,d.isSizeAttenuation,Za(e))),s+=f;for(var _=0;l.length-12>_;_+=4)i.push(l[_],l[_+1],l[_+2],l[_+3],l[_+4],l[_+5],l[_+6],l[_+7],l[_+8],l[_+9],l[_+10],l[_+11],l[_+12],l[_+13],l[_+14],l[_+15]);a.push.apply(a,m(c)),n.push(0+u,2+u,1+u,0+u,3+u,2+u,4+u,6+u,5+u,4+u,7+u,6+u,4+u,7+u,8+u),u+=9})),i.length&&(this.geometry.setVertexBuffer({bufferIndex:Ya.PACKED,byteStride:64,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:Ka.PREV,divisor:1},{format:be.F32_RGB,bufferByteOffset:16,location:Ka.POINT1,divisor:1},{format:be.F32_R,bufferByteOffset:28,location:Ka.VERTEX_JOINT,divisor:1},{format:be.F32_RGB,bufferByteOffset:32,location:Ka.POINT2,divisor:1},{format:be.F32_RGB,bufferByteOffset:48,location:Ka.NEXT,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Ya.VERTEX_NUM,byteStride:4,stepMode:Te.INSTANCE,attributes:[{format:be.F32_R,bufferByteOffset:0,byteStride:4,location:Ka.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:Ya.TRAVEL,byteStride:4,stepMode:Te.INSTANCE,attributes:[{format:be.F32_R,bufferByteOffset:0,byteStride:4,location:Ka.TRAVEL,divisor:1}],data:new Float32Array(a)}),this.divisor=s/e.length,this.geometry.setVertexBuffer({bufferIndex:Ya.DASH,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:Ka.DASH,divisor:this.divisor}],data:new Float32Array(o)}),A(r,"createGeometry",this,3)([e]),this.geometry.vertexCount=15,this.geometry.instancedCount=s,this.geometry.setIndexBuffer(new Uint32Array(n)))}},{key:"updateAttribute",value:function(e,t,n,i){var a=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"radius"===n||"x1"===n||"y1"===n||"x2"===n||"y2"===n||"points"===n||"path"===n||"d"===n||"lineJoin"===n||"lineCap"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var o=[],s=[],u=0;e.forEach((function(e){var t=eo(e,!1,12,a.calcSubpathIndex(e)),r=t.pointsBuffer,n=t.travelBuffer;u=t.instancedCount;for(var i=0;r.length-12>i;i+=4)o.push(r[i],r[i+1],r[i+2],r[i+3],r[i+4],r[i+5],r[i+6],r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]);s.push.apply(s,m(n))})),this.geometry.updateVertexBuffer(Ya.PACKED,Ka.PREV,t*u,new Uint8Array(new Float32Array(o).buffer)),this.geometry.updateVertexBuffer(Ya.TRAVEL,Ka.TRAVEL,t,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n||"isSizeAttenuation"===n){var l=[];e.forEach((function(e){var t=e.parsedStyle,r=t.lineDash;l.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,ja(t.isBillboard,t.isSizeAttenuation,Za(e)))})),this.geometry.updateVertexBuffer(Ya.DASH,Ka.DASH,t,new Uint8Array(new Float32Array(l).buffer))}}}],[{key:"calcSubpathNum",value:function(e){return e.nodeName===t.Shape.PATH?e.parsedStyle.d.absolutePath.filter((function(e){return"M"===e[0]})).length:1}}])}(La),Qa=function(e){return e[e.NONE=0]="NONE",e[e.FILL=1]="FILL",e[e.JOINT_BEVEL=4]="JOINT_BEVEL",e[e.JOINT_MITER=8]="JOINT_MITER",e[e.JOINT_ROUND=12]="JOINT_ROUND",e[e.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",e[e.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",e[e.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",e[e.FILL_EXPAND=24]="FILL_EXPAND",e[e.CAP_BUTT=32]="CAP_BUTT",e[e.CAP_SQUARE=64]="CAP_SQUARE",e[e.CAP_ROUND=96]="CAP_ROUND",e[e.CAP_BUTT2=128]="CAP_BUTT2",e}({}),$a=3,Ja=4;function eo(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=e.parsedStyle,o=a.lineCap,s=a.lineJoin,u=e.sortable.renderOrder*Aa,l=0,c=0,f=e.parsedStyle,d=f.markerStart,h=f.markerEnd,_=f.markerStartOffset,p=f.markerEndOffset,E=[],g=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var T=e.parsedStyle.points.points,A=T.length,P=0,N=0,M=0,O=0,I=0;d&&t.isDisplayObject(d)&&_&&(P=Math.cos(I=Math.atan2(T[1][1]-T[0][1],T[1][0]-T[0][0]))*(_||0),N=Math.sin(I)*(_||0)),h&&t.isDisplayObject(h)&&p&&(M=Math.cos(I=Math.atan2(T[A-2][1]-T[A-1][1],T[A-2][0]-T[A-1][0]))*(p||0),O=Math.sin(I)*(p||0));var x=e.nodeName===t.Shape.POLYLINE;if(E[0]=T.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=P,i=N):r===A-1&&(n=M,i=O),e.push(t[0]+n,t[1]+i,x?t[2]||0:u),e}),[]),e.nodeName===t.Shape.POLYGON){var B;if(r)return g=qn(E[0],[],3),{pointsBuffer:E[0],travelBuffer:[],triangles:g,instancedCount:Math.round(E[0].length/$a)};E[0].push(E[0][0],E[0][1],E[0][2]||u),(B=E[0]).push.apply(B,m(to(E[0][0],E[0][1],E[0][2]||u,E[0][3],E[0][4],E[0][5]||u)))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var D;if(e.nodeName!==t.Shape.PATH){if(D=t.parsePath(t.convertToPath(e,k(L()))),e.nodeName===t.Shape.RECT){var b=e.parsedStyle;0>b.width&&(l+=D.rect.width),0>b.height&&(c+=D.rect.height)}}else D=e.parsedStyle.d;var F=D.absolutePath,U=D.segments,w=0,G=0,V=0,X=0,W=0;if(d&&d.parentNode&&t.isDisplayObject(d)&&_){var H=C(d.parentNode.getStartTangent(),2),z=H[0],Y=H[1];w=Math.cos(W=Math.atan2(z[1]-Y[1],z[0]-Y[0]))*(_||0),G=Math.sin(W)*(_||0)}if(h&&h.parentNode&&t.isDisplayObject(h)&&p){var K=C(h.parentNode.getEndTangent(),2),j=K[0],Z=K[1];V=Math.cos(W=Math.atan2(j[1]-Z[1],j[0]-Z[0]))*(p||0),X=Math.sin(W)*(p||0)}var q=-1,Q=-1;if(F.forEach((function(r,i){var a,o=y(a=r)||v(a)||R(a)||S(),s=o[0],f=o.slice(1),d=F[i+1],h=0===i&&(0!==w||0!==G),_=(i===F.length-1||d&&("M"===d[0]||"Z"===d[0]))&&0!==V&&0!==X;if("M"===s)Q++,E[Q]=[],q=E[Q].length,h?E[Q].push(f[0]-l+w,f[1]-c+G,u,f[0]-l,f[1]-c,u):E[Q].push(f[0]-l,f[1]-c,u);else if("L"===s)_?E[Q].push(f[0]-l+V,f[1]-c+X,u):E[Q].push(f[0]-l,f[1]-c,u);else if("Q"===s)Ga(f[0]-l,f[1]-c,f[2]-l,f[3]-c,E[Q],n),_&&E[Q].push(f[2]-l+V,f[3]-c+X,u);else if("A"===s){for(var p=C(U[i].prePoint,2),g=oe(p[0],p[1],f[0],f[1],f[2],f[3],f[4],f[5],f[6],void 0),T=0;g.length>T;T+=6)Va(g[T]-l,g[T+1]-c,g[T+2]-l,g[T+3]-c,g[T+4]-l,g[T+5]-c,E[Q],n);_&&E[Q].push(f[5]-l+V,f[6]-c+X,u)}else if("C"===s)Va(f[0]-l,f[1]-c,f[2]-l,f[3]-c,f[4]-l,f[5]-c,E[Q],n),_&&E[Q].push(f[4]-l+V,f[5]-c+X,u);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var A,P=1e-4;(Math.abs(E[Q][E[Q].length-2]-E[Q][q])>P||Math.abs(E[Q][E[Q].length-1]-E[Q][q+1])>P)&&E[Q].push(E[Q][q],E[Q][q+1],u),(A=E[Q]).push.apply(A,m(to(E[Q][q],E[Q][q+1],E[Q][q+2],E[Q][q+3],E[Q][q+4],E[Q][q+5])))}})),r){var $=E[i];return{pointsBuffer:$,travelBuffer:[],triangles:g=qn($,[],3),instancedCount:Math.round($.length/$a)}}}var J=function(e){var t;switch(e){case"bevel":t=Qa.JOINT_BEVEL;break;case"round":t=Qa.JOINT_ROUND;break;default:t=Qa.JOINT_MITER}return t}(s),ee=function(e){var t;switch(e){case"square":t=Qa.CAP_SQUARE;break;case"round":t=Qa.CAP_ROUND;break;default:t=Qa.CAP_BUTT}return t}(o),te=ee;ee===Qa.CAP_ROUND&&(te=Qa.JOINT_CAP_ROUND),ee===Qa.CAP_BUTT&&(te=Qa.JOINT_CAP_BUTT),ee===Qa.CAP_SQUARE&&(te=Qa.JOINT_CAP_SQUARE);for(var re=E[i],ne=(Math.round(0/$a)+2)*Ja,ie=0,ae=[],se=[],ue=0;re.length>ue;ue+=$a)ue>1&&(ie+=Math.sqrt(Math.pow(re[ue]-re[ue-$a],2)+Math.pow(re[ue+1]-re[ue+1-$a],2)+Math.pow(re[ue+2]-re[ue+2-$a],2))),se.push(ie),ae[ne++]=re[ue],ae[ne++]=re[ue+1],ae[ne++]=re[ue+2]||0,ae[ne]=J,0===ue&&ee!==Qa.CAP_ROUND&&(ae[ne]+=ee),re.length>ue+2*$a?re.length>ue+$a||(ae[ne]=0):ae[ne]+=te-J,ne++;return ae[ne++]=re[re.length-6],ae[ne++]=re[re.length-5],ae[ne++]=re[re.length-4]||u,ae[ne++]=0,ae[0]=re[0],ae[1]=re[1],ae[2]=re[2]||u,ae[3]=0,ae[4]=re[3],ae[5]=re[4],ae[6]=re[5]||u,ae[7]=ee===Qa.CAP_ROUND?ee:0,{pointsBuffer:ae,travelBuffer:se,triangles:g,instancedCount:Math.round(re.length/$a)}}function to(e,t,r){var n=[(arguments.length>3&&void 0!==arguments[3]?arguments[3]:e)-e,(arguments.length>4&&void 0!==arguments[4]?arguments[4]:t)-t,(arguments.length>5&&void 0!==arguments[5]?arguments[5]:r)-r],i=.01;return[e+n[0]*i,t+n[1]*i,r+n[2]*i]}var ro=function(e){return e[e.PACKED_STYLE=Da.POSITION+1]="PACKED_STYLE",e}(ro||{}),no=function(e){return e[e.PACKED_STYLE3=ba.MAX]="PACKED_STYLE3",e}(no||{}),io=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).trianglesHash=[[],[]],u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.trianglesHash=u.calcSegmentNum(i),u}return p(r,e),u(r,[{key:"calcSegmentNum",value:function(e){var t=eo(e,!0,12,this.calcSubpathIndex(e));return[t.triangles,t.pointsBuffer]}},{key:"calcSubpathIndex",value:function(e){return e.nodeName===t.Shape.PATH?this.index:0}},{key:"compareTrianglesHash",value:function(e){var t=C(this.trianglesHash,2),r=t[0],n=t[1],i=C(e,2),a=i[0],o=i[1];return r.length===a.length&&n.length===o.length&&(!r.some((function(e,t){return e!==a[t]}))&&!n.some((function(e,t){return e!==o[t]})))}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);if(!n)return!1;if(this.index!==t)return!1;var i=this.calcSegmentNum(e);return this.compareTrianglesHash(i)}},{key:"createGeometry",value:function(e){var t=this,n=[],i=[],a=[],o=0;if(e.forEach((function(e,r){var s=eo(e,!0,12,t.calcSubpathIndex(e)),u=s.triangles,l=s.pointsBuffer;if(u.length){var c=e.getGeometryBounds().halfExtents,f=[];l.forEach((function(e,t){t%3!=2&&f.push(e/c[t%3]/2)})),o+=i.length/3,i.push.apply(i,m(l)),a.push.apply(a,f),n.push.apply(n,m(u.map((function(e){return e+o}))))}})),i.length){A(r,"createGeometry",this,3)([e]);var s=[];e.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:12,stepMode:Te.VERTEX,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:ba.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:ro.PACKED_STYLE,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:no.PACKED_STYLE3,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:Da.UV,byteStride:8,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:ba.UV}],data:new Float32Array(a)}),this.geometry.vertexCount=n.length/e.length,this.geometry.setIndexBuffer(new Uint32Array(n))}}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(a_Position.xy, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else {\n gl_Position = project(vec4(a_Position.xy, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}",this.material.defines=o(o(o({},this.material.defines),Na(no)),{},{INSTANCED:!0})}},{key:"updateAttribute",value:function(e,t,n,i){if(0!==e.length&&(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i),"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n)){var a=[];e.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;a.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(ro.PACKED_STYLE,no.PACKED_STYLE3,t,new Uint8Array(new Float32Array(a).buffer))}}}])}(La),ao=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1],oo=function(e){return e[e.POINT=Da.POSITION+1]="POINT",e[e.CAP=1+e.POINT]="CAP",e[e.DASH=1+e.CAP]="DASH",e}(oo||{}),so=function(e){return e[e.POSITION=ba.POSITION]="POSITION",e[e.UV=ba.UV]="UV",e[e.POINTA=ba.NORMAL]="POINTA",e[e.POINTB=ba.BARYCENTRIC]="POINTB",e[e.CAP=ba.MAX]="CAP",e[e.DASH=ba.MAX+1]="DASH",e}(so||{}),uo={butt:1,round:2,square:3},lo=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).renderHelper=e,u.texturePool=t,u.lightPool=n,u.gradientAttributeName="stroke",u}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n float clampedStrokeWidth = max(strokeWidth, 1.0);\n\n bool isSizeAttenuation = a_Dash.w > 0.5;\n if (isSizeAttenuation) {\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * clampedStrokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(clampedStrokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur;\n if (v_Distance.y < 1.0) {\n blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n } else {\n blur = 1.0 / v_Distance.y;\n }\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * max(blur, 0.5)\n * u_Opacity * u_StrokeOpacity\n * (u_dash_array < 1.0 ? (ceil((u_dash_array * u_dash_ratio) - mod(v_Dash.x + u_dash_offset, u_dash_array))) : 1.0);\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=o(o({},this.material.defines),Na(so))}},{key:"calcSubpathIndex",value:function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===io})).length;return this.index-r}return 0}},{key:"createGeometry",value:function(e){var n=this;A(r,"createGeometry",this,3)([e]);var i=[],a=[],o=[],s=[],u=0;e.forEach((function(e){var r,l;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,l=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,lineCap:c.lineCap,lineDash:c.lineDash,lineDashOffset:c.lineDashOffset,isBillboard:c.isBillboard,isSizeAttenuation:c.isSizeAttenuation,markerStart:c.markerStart,markerEnd:c.markerEnd,markerStartOffset:c.markerStartOffset,markerEndOffset:c.markerEndOffset},l=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){for(var d=e.parsedStyle,h=d.d.absolutePath,_=d.lineCap,p=d.lineDash,E=d.lineDashOffset,v=d.markerStart,R=d.markerEnd,m=d.markerStartOffset,g=d.markerEndOffset,T=d.isBillboard,A=d.isSizeAttenuation,y=0,S=0,C=n.calcSubpathIndex(e),P=0;h.length>P;P++){if("M"===h[P][0]){if(y===C){S=P;break}y++}}r={x1:h[S][1],y1:h[S][2],x2:h[S+1][1],y2:h[S+1][2],z1:0,z2:0,lineCap:_,lineDash:p,lineDashOffset:E,isBillboard:T,isSizeAttenuation:A,markerStart:v,markerEnd:R,markerStartOffset:m,markerEndOffset:g},l=e.getTotalLength()}var N=r.x1,M=r.y1,O=r.x2,I=r.y2,x=r.z1,B=r.z2,D=r.lineCap,b=r.isBillboard,L=r.isSizeAttenuation,F=n.calcOffset(r),U=F.startOffsetX,k=F.startOffsetY,w=F.endOffsetX,G=F.endOffsetY,V=n.calcDash(r,l),X=V.dashOffset,W=V.dashSegmentPercent,H=V.dashRatioInEachSegment;a.push(uo[D]),o.push(X,W,H,b||L?1:0),i.push(N+U,M+k,x,O+w,I+G,B),s.push(0+u,2+u,1+u,0+u,3+u,2+u),u+=4})),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:20,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:so.POSITION,divisor:0},{format:be.F32_RG,bufferByteOffset:12,location:so.UV,divisor:0}],data:new Float32Array(ao)}),this.geometry.setVertexBuffer({bufferIndex:oo.POINT,byteStride:24,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:so.POINTA,divisor:1},{format:be.F32_RGB,bufferByteOffset:12,location:so.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:oo.CAP,byteStride:4,stepMode:Te.INSTANCE,attributes:[{format:be.F32_R,bufferByteOffset:0,location:so.CAP,divisor:1}],data:new Float32Array(a)}),this.geometry.setVertexBuffer({bufferIndex:oo.DASH,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:so.DASH,divisor:1}],data:new Float32Array(o)})}},{key:"updateAttribute",value:function(e,n,i,a){var o=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,n,i,a]),this.updateBatchedAttribute(e,n,i,a),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"d"===i){var s=[];e.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,lineCap:n.lineCap,isSizeAttenuation:n.isSizeAttenuation,isBillboard:n.isBillboard,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH){var a=e.parsedStyle,u=a.d.absolutePath;r={x1:u[0][1],y1:u[0][2],x2:u[1][1],y2:u[1][2],z1:0,z2:0,lineCap:a.lineCap,isBillboard:a.isBillboard,isSizeAttenuation:a.isSizeAttenuation,markerStart:a.markerStart,markerEnd:a.markerEnd,markerStartOffset:a.markerStartOffset,markerEndOffset:a.markerEndOffset}}var l=r.x1,c=r.y1,f=r.x2,d=r.y2,h=r.z1,_=r.z2,p=o.calcOffset(r);s.push(l+p.startOffsetX,c+p.startOffsetY,h,f+p.endOffsetX,d+p.endOffsetY,_)})),this.geometry.updateVertexBuffer(oo.POINT,so.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isSizeAttenuation"===i||"isBillboard"===i){var u=[];e.forEach((function(e){var t=e.getTotalLength(),r=o.calcDash(e.parsedStyle,t);u.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard||e.parsedStyle.isSizeAttenuation?1:0)})),this.geometry.updateVertexBuffer(oo.DASH,so.DASH,n,new Uint8Array(new Float32Array(u).buffer))}else if("lineCap"===i){var l=[];e.forEach((function(e){l.push(uo[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(oo.CAP,so.CAP,n,new Uint8Array(new Float32Array(l).buffer))}}},{key:"calcOffset",value:function(e){var r=e.x1,n=e.y1,i=e.x2,a=e.y2,o=e.markerStart,s=e.markerEnd,u=e.markerStartOffset,l=e.markerEndOffset,c=0,f=0,d=0,h=0,_=0;return o&&t.isDisplayObject(o)&&u&&(c=Math.cos(_=Math.atan2(a-n,i-r))*(u||0),f=Math.sin(_)*(u||0)),s&&t.isDisplayObject(s)&&l&&(d=Math.cos(_=Math.atan2(n-a,r-i))*(l||0),h=Math.sin(_)*(l||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:d,endOffsetY:h}}},{key:"calcDash",value:function(e,t){var r=e.lineDash,n=0,i=1,a=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var o=r.reduce((function(e,t){return e+t}),0);0===o?(i=1,a=0):(i=o/t,a=r[1]/o)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:a}}}],[{key:"isLine",value:function(e,r){if(e.nodeName===t.Shape.PATH){for(var n=e.parsedStyle.d.absolutePath,i=0,a=0,o=0;n.length>o;o++){if("M"===n[o][0]){if(i===r){a=o;break}i++}}if("M"===n[a][0]&&"L"===n[a+1][0]&&(void 0===n[a+2]||"M"===n[a+2][0]))return!0}else if(e.nodeName===t.Shape.POLYLINE){for(var s=e.parsedStyle.points.points,u=(s[1][0]-s[1][1])/(s[0][0]-s[0][1]),l=1;s.length-1>l;l++)if((s[l+1][0]-s[l+1][1])/(s[l][0]-s[l][1])!==u)return!1;return!0}return!1}}])}(La),co=function(e){return e[e.PACKED_STYLE=Da.POSITION+1]="PACKED_STYLE",e[e.SIZE=Da.MAX]="SIZE",e}(co||{}),fo=function(e){return e[e.PACKED_STYLE3=ba.MAX]="PACKED_STYLE3",e[e.SIZE=1+e.PACKED_STYLE3]="SIZE",e}(fo||{}),ho=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"shouldMerge",value:function(e,r){var n=A(t,"shouldMerge",this,3)([e,r]);return!!n&&this.instance.parsedStyle.src===e.parsedStyle.src}},{key:"createMaterial",value:function(e){var t=e[0].parsedStyle.src;this.material.defines=o(o({},this.material.defines),Na(fo)),this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = SIZE) in vec2 a_Size;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n // TODO: pointer-events: non-transparent-pixel\n // if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n // discard;\n // }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}";var r=this.texturePool.getOrCreateTexture(this.context.device,t,void 0);this.material.setUniforms({u_Map:r})}},{key:"createGeometry",value:function(e){A(t,"createGeometry",this,3)([e]);var r=[],n=[],i=[];e.forEach((function(e,t){var a=e.parsedStyle,o=a.x,s=a.y,u=a.z,l=a.width,c=a.height,f=a.isBillboard,d=a.billboardRotation,h=a.isSizeAttenuation;r.push(void 0===o?0:o,void 0===s?0:s,void 0===u?0:u),n.push(l,c),i.push(f?1:0,null!=d?d:0,h?1:0,0)})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:12,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:ba.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:co.SIZE,byteStride:8,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:fo.SIZE}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:co.PACKED_STYLE,byteStride:16,stepMode:Te.INSTANCE,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:fo.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Da.UV,byteStride:8,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:ba.UV}],data:new Float32Array([0,0,1,0,1,1,0,1])})}},{key:"updateAttribute",value:function(e,r,n,i){if(0!==e.length)if(A(t,"updateAttribute",this,3)([e,r,n,i]),this.updateBatchedAttribute(e,r,n,i),"x"===n||"y"===n||"z"===n){var a=[];e.forEach((function(e){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;a.push(void 0===r?0:r,void 0===n?0:n,void 0===i?0:i)})),this.geometry.updateVertexBuffer(Da.POSITION,ba.POSITION,r,new Uint8Array(new Float32Array(a).buffer))}else if("width"===n||"height"===n){var o=[];e.forEach((function(e){var t=e.parsedStyle;o.push(t.width,t.height)})),this.geometry.updateVertexBuffer(co.SIZE,fo.SIZE,r,new Uint8Array(new Float32Array(o).buffer))}else if("isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var s=[];e.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(co.PACKED_STYLE,fo.PACKED_STYLE3,r,new Uint8Array(new Float32Array(s).buffer))}else if("src"===n){var u=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:u})}}}])}(La);function _o(e,t,r,n){var i=t.width,a=t.height;if(n){if(n.length!==i*a*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*a*r);return e.width=i,e.height=a,e.data=n,e}function po(e,t,r,n,i,a){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var o=e.data,s=t.data,u=0;i.height>u;u++)for(var l=((r.y+u)*e.width+r.x)*a,c=((n.y+u)*t.width+n.x)*a,f=0;i.width*a>f;f++)s[c+f]=o[l+f];return t}var Eo=function(){function e(t,r){l(this,e),_o(this,t,1,r)}return u(e,[{key:"resize",value:function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var a=_o({},{width:n,height:i},r);po(e,a,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=a.data}}(this,e,1)}},{key:"clone",value:function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))}}],[{key:"copy",value:function(e,t,r,n,i){po(e,t,r,n,i,1)}}])}();var vo=u((function e(t){l(this,e);var r={},n=[];for(var i in t){var a=t[i],o=r[i]={};for(var s in a){var u=a[+s];if(u&&0!==u.bitmap.width&&0!==u.bitmap.height){var c={x:0,y:0,w:u.bitmap.width+2,h:u.bitmap.height+2};n.push(c),o[s]={rect:c,metrics:u.metrics}}}}var f=function(e){var t,r=0,n=0,i=An(e);try{for(i.s();!(t=i.n()).done;){var a=t.value;r+=a.w*a.h,n=Math.max(n,a.w)}}catch(e){i.e(e)}finally{i.f()}e.sort((function(e,t){return t.h-e.h}));var o,s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}],u=0,l=0,c=An(e);try{for(c.s();!(o=c.n()).done;)for(var f=o.value,d=s.length-1;d>=0;d--){var h=s[d];if(h.w>=f.w&&h.h>=f.h){if(f.x=h.x,f.y=h.y,l=Math.max(l,f.y+f.h),u=Math.max(u,f.x+f.w),f.w===h.w&&f.h===h.h){var _=s.pop();s.length>d&&(s[d]=_)}else f.h===h.h?(h.x+=f.w,h.w-=f.w):f.w===h.w?(h.y+=f.h,h.h-=f.h):(s.push({x:h.x+f.w,y:h.y,w:h.w-f.w,h:f.h}),h.y+=f.h,h.h-=f.h);break}}}catch(e){c.e(e)}finally{c.f()}return{w:u,h:l,fill:r/(u*l)||0}}(n),d=new Eo({width:f.w||1,height:f.h||1});for(var h in t){var _=t[h];for(var p in _){var E=_[+p];if(E&&0!==E.bitmap.width&&0!==E.bitmap.height){var v=r[h][p].rect;Eo.copy(E.bitmap,d,{x:0,y:0},{x:v.x+1,y:v.y+1},E.bitmap)}}}this.image=d,this.positions=r}));var Ro=function(){return u((function e(t){l(this,e),this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={},this.runtime=t}),[{key:"destroy",value:function(){this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy()}},{key:"getMap",value:function(){return this.glyphMap}},{key:"getAtlas",value:function(){return this.glyphAtlas}},{key:"getAtlasTexture",value:function(){return this.glyphAtlasTexture}},{key:"layout",value:function(e,t,r,n,i,a,o){var s=this,u=[],l=a,c=o,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach((function(e){var n=u.length;Array.from(e).forEach((function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),a=r&&r[n];a&&(u.push({glyph:n,x:l,y:c,scale:1,fontStack:t}),l+=a.metrics.advance+i)}));for(var a=l-i,o=n;u.length>o;o++)u[o].x-=f*a;l=0,c+=r})),u}},{key:"generateAtlas",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",s=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,l=[];this.glyphMap[r]||(l=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[r]||{});if(Array.from(new Set(s.split(""))).forEach((function(e){-1===c.indexOf(""+e.charCodeAt(0))&&l.push(e)})),l.length){var f=l.map((function(o){return t.generateSDF(e,r,n,i,a,o)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[r]=o(o({},this.glyphMap[r]),f),this.glyphAtlas=new vo(this.glyphMap);var d=this.glyphAtlas.image,h=d.width,_=d.height,p=d.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=u.createTexture(o(o({},Fe(be.ALPHA,h,_,1)),{},{pixelStore:{unpackFlipY:!1,unpackAlignment:1}})),this.glyphAtlasTexture.setImageData([p])}}},{key:"generateSDF",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=a.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new Wa({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25},this.runtime)),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][a]||(this.textMetricsCache[t][a]=s.ctx.measureText(a).width);var u=s.draw(a),l=u.glyphWidth,c=u.glyphHeight,f=u.glyphLeft,d=u.glyphTop,h=u.glyphAdvance;return{id:o,bitmap:new Eo({width:u.width,height:u.height},u.data),metrics:{width:l,height:c,left:f,top:d-24+3,advance:h}}}}])}();var mo=function(e){return e[e.INSTANCED=Da.POSITION+1]="INSTANCED",e[e.TEX=1+e.INSTANCED]="TEX",e}(mo||{}),go=function(e){return e[e.TEX=ba.MAX]="TEX",e[e.OFFSET=1+e.TEX]="OFFSET",e}(go||{}),To=function(e){return e.SDF_MAP="u_SDFMap",e.SDF_MAP_SIZE="u_SDFMapSize",e.FONT_SIZE="u_FontSize",e.GAMMA_SCALE="u_GammaScale",e.STROKE_BLUR="u_StrokeBlur",e.HAS_STROKE="u_HasStroke",e}({}),Ao=function(e){function r(e,t,n,i,a,o,s){var u;return l(this,r),(u=h(this,r,[e,t,n,i,a,o,s])).packedBufferObjectMap=new WeakMap,u.tmpMat4=L(),u.renderHelper=e,u.texturePool=t,u.lightPool=n,u.fontHash=u.calcFontHash(i),u.glyphManager=new Ro(u.context),u}return p(r,e),u(r,[{key:"calcFontHash",value:function(e){e.getBounds();return e.parsedStyle.metrics.font+["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].reduce((function(t,r){return t+e.parsedStyle[r]}),"")}},{key:"shouldMerge",value:function(e,t){var n=A(r,"shouldMerge",this,3)([e,t]);return!!n&&(this.index===t&&this.fontHash===this.calcFontHash(e))}},{key:"createGeometry",value:function(e){var t=this,r=this.instance,n=r.parsedStyle,i=n.fontSize,a=n.letterSpacing,o=void 0===a?0:a,s=r.parsedStyle.textBaseline,u=void 0===s?"alphabetic":s,l=24/(void 0===i?16:i),c=[],f=[],d=[],h=[],_=0;e.forEach((function(e){var r=e.parsedStyle,n=r.metrics,i=r.dx,a=r.dy,s=n.font,p=n.lines,E=n.height,v=n.lineHeight,R=void 0===i?0:i,g=void 0===a?0:a;"alphabetic"===u&&(u="bottom");var T=0;"middle"===u?T+=-E/2:"bottom"===u?T+=-E:"top"===u||"hanging"===u?T+=0:"ideographic"===u&&(T+=-E);var A=t.glyphManager.getAtlas(),y=t.buildTextBuffers({object:e,lines:p,fontStack:s,lineHeight:l*v,offsetX:l*R,offsetY:l*(T+g),letterSpacing:l*o,glyphAtlas:A,indicesOffset:_}),S=y.indexBuffer,C=y.charUVOffsetBuffer,P=y.charPositionsBuffer;_=y.indicesOffset;var N=h.length;h.push.apply(h,m(y.charPackedBuffer)),t.packedBufferObjectMap.set(e,[N,h.length]),d.push.apply(d,m(C)),f.push.apply(f,m(P)),c.push.apply(c,m(S))})),this.geometry.vertexCount=c.length,this.geometry.setIndexBuffer(new Uint32Array(c)),this.geometry.setVertexBuffer({bufferIndex:mo.INSTANCED,byteStride:128,stepMode:Te.VERTEX,attributes:[{format:be.F32_RGBA,bufferByteOffset:0,location:ba.MODEL_MATRIX0},{format:be.F32_RGBA,bufferByteOffset:16,location:ba.MODEL_MATRIX1},{format:be.F32_RGBA,bufferByteOffset:32,location:ba.MODEL_MATRIX2},{format:be.F32_RGBA,bufferByteOffset:48,location:ba.MODEL_MATRIX3},{format:be.F32_RGBA,bufferByteOffset:64,location:ba.PACKED_COLOR},{format:be.F32_RGBA,bufferByteOffset:80,location:ba.PACKED_STYLE1},{format:be.F32_RGBA,bufferByteOffset:96,location:ba.PACKED_STYLE2},{format:be.F32_RGBA,bufferByteOffset:112,location:ba.PICKING_COLOR}],data:new Float32Array(h)}),this.geometry.setVertexBuffer({bufferIndex:Da.POSITION,byteStride:12,stepMode:Te.VERTEX,attributes:[{format:be.F32_RGB,bufferByteOffset:0,location:ba.POSITION}],data:new Float32Array(f)}),this.geometry.setVertexBuffer({bufferIndex:mo.TEX,byteStride:16,stepMode:Te.VERTEX,attributes:[{format:be.F32_RG,bufferByteOffset:0,location:go.TEX},{format:be.F32_RG,bufferByteOffset:8,location:go.OFFSET}],data:new Float32Array(d)})}},{key:"createMaterial",value:function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n vec2 bufferOffset = vec2(0.7, 2.0);\n vec2 offset = a_Offset * fontScale + + bufferOffset;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked2.w;\n bool isSizeAttenuation = a_StylePacked2.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position );\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float fontScale = u_FontSize / 24.0;\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = fwidth(dist);\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < epsilon) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=de.BACK,this.material.defines=o(o({},this.material.defines),Na(go));var t=this.instance.parsedStyle,r=t.fontSize,n=void 0===r?16:r,a=t.fontFamily,s=void 0===a?"sans-serif":a,u=t.fontWeight,l=void 0===u?"normal":u,c=t.fontStyle,f=void 0===c?"normal":c,d=t.metrics.font,h=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,d,s,""+l,f,h,this.context.device);var _=this.glyphManager.getAtlasTexture(),p=this.glyphManager.getAtlas();this.context.device.setResourceName(_,"TextSDF Texture");var E=p.image,v=E.width,R=E.height;this.material.setUniforms(i(i(i(i(i(i({},To.SDF_MAP,_),To.SDF_MAP_SIZE,[v,R]),To.FONT_SIZE,n),To.GAMMA_SCALE,1),To.STROKE_BLUR,.2),To.HAS_STROKE,this.index))}},{key:"changeRenderOrder",value:function(e,t){for(var r=this.geometry.vertices[mo.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[mo.INSTANCED].arrayStride/4,i=C(this.packedBufferObjectMap.get(e),2),a=i[0],o=i[1],s=r.slice(a,o),u=0;o-a>u;u+=n)s[u+n-1]=t*Aa;this.geometry.updateVertexBuffer(mo.INSTANCED,ba.MODEL_MATRIX0,a/n,new Uint8Array(s.buffer))}},{key:"updateAttribute",value:function(e,n,i,a){var o=this;if(0!==e.length)if(A(r,"updateAttribute",this,3)([e,n,i,a]),"text"===i||"fontFamily"===i||"fontSize"===i||"fontWeight"===i||"fontStyle"===i||"fontVariant"===i||"textBaseline"===i||"letterSpacing"===i||"wordWrapWidth"===i||"lineHeight"===i||"wordWrap"===i||"textAlign"===i||"x"===i||"y"===i||"dx"===i||"dy"===i)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===i||"fill"===i||"fillOpacity"===i||"stroke"===i||"strokeOpacity"===i||"opacity"===i||"lineWidth"===i||"visibility"===i||"pointerEvents"===i||"isBillboard"===i||"billboardRotation"===i||"isSizeAttenuation"===i){var s=this.geometry.vertices[mo.INSTANCED],u=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[mo.INSTANCED].arrayStride/4;e.forEach((function(e){var r,n=e.parsedStyle,i=n.fill,a=n.stroke,l=n.opacity,c=void 0===l?1:l,f=n.fillOpacity,d=void 0===f?1:f,h=n.strokeOpacity,_=void 0===h?1:h,p=n.lineWidth,E=void 0===p?1:p,v=n.visibility,R=n.isBillboard,m=n.billboardRotation,g=n.isSizeAttenuation,T=[0,0,0,0];t.isCSSRGB(i)&&(T=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]);var A=[0,0,0,0];t.isCSSRGB(a)&&(A=[Number(a.r),Number(a.g),Number(a.b),255*Number(a.alpha)]);for(var y=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],S=F(o.tmpMat4,e.getWorldTransform()),P=C(o.packedBufferObjectMap.get(e),2),N=P[0],M=P[1],O=s.slice(N,M),I=0;M-N>I;I+=u)O[I+0]=S[0],O[I+1]=S[1],O[I+2]=S[2],O[I+3]=S[3],O[I+4]=S[4],O[I+5]=S[5],O[I+6]=S[6],O[I+7]=S[7],O[I+8]=S[8],O[I+9]=S[9],O[I+10]=S[10],O[I+11]=S[11],O[I+12]=S[12],O[I+13]=S[13],O[I+14]=S[14],O[I+15]=S[15],O[I+16]=Ia(T[0],T[1]),O[I+17]=Ia(T[2],T[3]),O[I+18]=Ia(A[0],A[1]),O[I+19]=Ia(A[2],A[3]),O[I+20]=c,O[I+21]=d,O[I+22]=_,O[I+23]=E,O[I+24]="hidden"!==v?1:0,O[I+25]=R?1:0,O[I+26]=g?1:0,O[I+27]=null!=m?m:0,O[I+28]=y[0],O[I+29]=y[1],O[I+30]=y[2];o.geometry.updateVertexBuffer(mo.INSTANCED,ba.MODEL_MATRIX0,N/u,new Uint8Array(O.buffer))}))}}},{key:"buildTextBuffers",value:function(e){var r,n=e.object,i=e.lines,a=e.fontStack,o=e.lineHeight,s=e.letterSpacing,u=e.offsetX,l=e.offsetY,c=e.glyphAtlas,f=e.indicesOffset,d=n.parsedStyle,h=d.textAlign,_=void 0===h?"start":h,p=d.fill,E=d.stroke,v=d.opacity,R=void 0===v?1:v,g=d.fillOpacity,T=void 0===g?1:g,A=d.strokeOpacity,y=void 0===A?1:A,S=d.lineWidth,C=void 0===S?1:S,P=d.visibility,N=d.isBillboard,M=d.billboardRotation,O=d.isSizeAttenuation,I=d.x,x=void 0===I?0:I,B=d.y,D=void 0===B?0:B,b=d.z,L=void 0===b?0:b,U=[0,0,0,0];t.isCSSRGB(p)&&(U=[Number(p.r),Number(p.g),Number(p.b),255*Number(p.alpha)]);var k=[0,0,0,0];t.isCSSRGB(E)&&(k=[Number(E.r),Number(E.g),Number(E.b),255*Number(E.alpha)]);var w=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],G=F(this.tmpMat4,n.getWorldTransform()),V=[],X=[],W=[],H=[],z=f,Y=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],a=t[i.fontStack],o=a&&a[i.glyph];if(o){var s=o.rect;if(s){var u=o.metrics.advance*i.scale/2,l=[i.x+u,i.y],c=(o.metrics.left-4)*i.scale-u+l[0],f=(-o.metrics.top-4)*i.scale+l[1],d=c+s.w*i.scale,h=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:h},br:{x:d,y:h},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,a,o,_,s,u,l),c.positions);return Y.forEach((function(e){var t=[];t.push.apply(t,m(G));var r=[].concat(t,[Ia(U[0],U[1]),Ia(U[2],U[3]),Ia(k[0],k[1]),Ia(k[2],k[3]),R,T,y,C,"hidden"!==P?1:0,N?1:0,O?1:0,null!=M?M:0],m(w),[n.sortable.renderOrder*Aa]);V.push.apply(V,m(r).concat(m(r),m(r),m(r))),X.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),X.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),X.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),X.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),W.push(x,D,L,x,D,L,x,D,L,x,D,L),H.push(0+z,2+z,1+z),H.push(2+z,0+z,3+z),z+=4})),{indexBuffer:H,charUVOffsetBuffer:X,charPositionsBuffer:W,charPackedBuffer:V,indicesOffset:z}}},{key:"destroy",value:function(){A(r,"destroy",this,3)([]),this.glyphManager.destroy()}}])}(La),yo=function(e){function r(){var e;l(this,r);for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return(e=h(this,r,[].concat(n))).mergeXYZIntoModelMatrix=!1,e}return p(r,e),u(r,[{key:"shouldMerge",value:function(e,n){var i=A(r,"shouldMerge",this,3)([e,n]);return!!i&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===e.parsedStyle.material&&this.instance.parsedStyle.geometry===e.parsedStyle.geometry)}},{key:"updateAttribute",value:function(e,t,n,i){0!==e.length&&(A(r,"updateAttribute",this,3)([e,t,n,i]),this.updateBatchedAttribute(e,t,n,i))}},{key:"createMaterial",value:function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()}},{key:"createGeometry",value:function(e){this.geometry=this.instance.parsedStyle.geometry,A(r,"createGeometry",this,3)([e]),this.geometry.build(e),this.observeGeometryChanged()}}])}(La),So=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle.fill;return r&&!r.isNone&&t.push(wa),this.needDrawStrokeSeparately(e)&&t.push(qa),t}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,a=t.lineWidth,o=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&a>0&&(1>o||l)}}])}(ya),Co=function(e){function r(){return l(this,r),h(this,r,arguments)}return p(r,e),u(r,[{key:"getDrawcallCtors",value:function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,a=r.opacity,o=r.strokeOpacity,s=r.lineWidth,u=i&&!i.isNone,l=qa.calcSubpathNum(e),c=[];if(!(e.nodeName===t.Shape.POLYLINE||null!=n&&n.isNone))for(var f=0;l>f;f++)c.push(io);for(var d=0;l>d;d++)if(0!==o&&0!==a&&0!==s&&u){var h=lo.isLine(e,d);c.push(h?lo:qa)}return c}}])}(ya),Po=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[ho]}}])}(ya),No=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle,n=r.stroke,i=r.lineWidth;return!(!n||n.isNone||!(void 0===i?1:i))&&t.push(Ao),t.push(Ao),t}},{key:"beforeUploadUBO",value:function(e,t){t.material.setUniforms(i({},To.HAS_STROKE,1===t.instance.renderable3D.drawcalls.length?0:1-t.index))}}])}(ya),Mo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[lo]}}])}(ya),Oo=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(){return[yo]}}])}(ya),Io=function(e){function t(){return l(this,t),h(this,t,arguments)}return p(t,e),u(t,[{key:"getDrawcallCtors",value:function(e){var t=[],r=e.parsedStyle,n=r.fill,i=r.radius,a=i&&i.length&&i.some((function(e){return e!==i[0]}));return null!=n&&n.isNone||a||t.push(wa),a&&t.push(io),(a||this.needDrawStrokeSeparately(e))&&t.push(qa),t}},{key:"needDrawStrokeSeparately",value:function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,a=t.lineWidth,o=t.strokeOpacity,s=r&&!r.isNone,u=n&&!n.isNone,l=i&&i.length&&i.every((function(e){return 0!==e}));return!s||u&&a>0&&(1>o||l)}}])}(ya),xo=1,Bo=function(){return u((function e(t,r,n,i){l(this,e),this.drawcalls=[],this.pendingUpdatePatches={},this.stencilRefCache={},this.renderHelper=t,this.rendererFactory=r,this.texturePool=n,this.lightPool=i}),[{key:"destroy",value:function(){this.drawcalls.forEach((function(e){e.destroy()})),this.drawcalls=[],this.pendingUpdatePatches={}}},{key:"render",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r||this.updatePendingPatches(),this.drawcalls.forEach((function(n){n.init();var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var a=t.renderHelper.renderInstManager.newRenderInst();a.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(a,i),t.renderHelper.renderInstManager.submitRenderInst(a,e),r||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))}},{key:"attach",value:function(e){this.context=e}},{key:"add",value:function(e){var t=this,r=e.renderable3D;if(r&&!r.drawcalls.length){var n=this.rendererFactory[e.nodeName];n&&n.getDrawcallCtors(e).forEach((function(i,a,o){var s=t.drawcalls.find((function(t){return i===t.constructor&&t.index===a&&t.maxInstances>t.objects.length&&t.shouldMerge(e,a)}));s&&s.key===e.parsedStyle.batchKey||((s=new i(t.renderHelper,t.texturePool,t.lightPool,e,o,a,t.context)).renderer=n,t.drawcalls.push(s),e.parsedStyle.batchKey&&(s.key=e.parsedStyle.batchKey)),s&&(s.objects.push(e),r.drawcalls[a]=s,s.geometryDirty=!0)}))}}},{key:"remove",value:function(e){var t=this,r=e.renderable3D;r&&(r.drawcalls.forEach((function(r){if(r){var n=r.objects.indexOf(e);if(n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length)t.drawcalls.splice(t.drawcalls.indexOf(r),1).forEach((function(e){e.destroy()}))}})),r.drawcalls=[])}},{key:"updateAttribute",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.renderable3D,o=this.rendererFactory[e.nodeName];if(o){var s=o.getDrawcallCtors(e);if(s.forEach((function(s,u,l){var c=a.drawcalls.find((function(e){return e&&e.index===u&&e.constructor===s}));if(c||((c=a.drawcalls[u])&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&n.drawcalls.splice(n.drawcalls.indexOf(c),1),a.drawcalls[a.drawcalls.indexOf(c)]=void 0),(c=n.drawcalls.find((function(t){return s===t.constructor&&t.index===u&&t.maxInstances>t.objects.length&&t.shouldMerge(e,u)})))?c.geometryDirty=!0:((c=new s(n.renderHelper,n.texturePool,n.lightPool,e,l,u,n.context)).renderer=o,c.init(),n.drawcalls.push(c)),c.objects.push(e),a.drawcalls[u]=c),c.inited&&!c.geometryDirty)if(c.shouldMerge(e,u)){var f=c.objects.indexOf(e);if(i)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;n.pendingUpdatePatches[d]||(n.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===n.pendingUpdatePatches[d].objectIndices.indexOf(f)&&n.pendingUpdatePatches[d].objectIndices.push(f)}}else n.remove(e),n.add(e);else n.remove(e),n.add(e)})),a.drawcalls.length>s.length)for(var u=a.drawcalls.length-1;u>=s.length;u--){var l=a.drawcalls[u];l.objects.splice(l.objects.indexOf(e),1),l.geometryDirty=!0,0===l.objects.length&&this.drawcalls.splice(this.drawcalls.indexOf(l),1),a.drawcalls.pop()}}}},{key:"changeRenderOrder",value:function(e,t){var r=e.renderable3D;r&&r.drawcalls.length&&r.drawcalls.forEach((function(r){r&&r.inited&&!r.geometryDirty&&r.inited&&r.changeRenderOrder(e,t)}))}},{key:"getStencilRef",value:function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=xo++),this.stencilRefCache[e.entity]}},{key:"updatePendingPatches",value:function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,a=r.name,o=r.value;i.sort((function(e,t){return e-t}));var s=[];i.forEach((function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])})),s.forEach((function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],a,o)}))})),this.pendingUpdatePatches={}}}])}(),Do=function(){return u((function e(t,r){l(this,e),this.textureCache={},this.context=t,this.runtime=r}),[{key:"getOrCreateTexture",value:function(e,t,r,n){var i,a=this,s="string"==typeof t?t:t.src||"";if(s&&this.textureCache[s])(i=this.textureCache[s]).emit(Ae.LOADED);else if(i=e.createTexture(o({format:be.U8_RGBA_NORM,width:1,height:1,depthOrArrayLayers:1,mipLevelCount:1,dimension:ye.TEXTURE_2D,usage:Se.SAMPLED,pixelStore:{unpackFlipY:!1}},r)),s&&(this.textureCache[s]=i),I(t)){var u=this.context.config.createImage();u&&(u.onload=function(){var e=function(e){a.textureCache[s].setImageData([e]),a.textureCache[s].emit(Ae.LOADED),a.context.renderingService.dirtify(),n&&n(a.textureCache[s],e)};a.runtime.globalThis.createImageBitmap?a.runtime.globalThis.createImageBitmap(u).then((function(t){return e(t)})).catch((function(){e(u)})):e(u)},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=t)}else i.setImageData([t]),i.emit(Ae.LOADED),this.context.renderingService.dirtify();return i}},{key:"getOrCreateCanvas",value:function(){return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(this.context.config.offscreenCanvas)}},{key:"getOrCreateGradient",value:function(e){var t=e.gradients,r=e.instance.getGeometryBounds().halfExtents,n=2*r[0]||1,i=2*r[1]||1,a=this.context.config.offscreenCanvas,s=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(a),u=this.runtime.offscreenCanvasCreator.getOrCreateContext(a);s.width=n,s.height=i;var l=this.context.imagePool;t.forEach((function(e){var t=l.getOrCreateGradient(o(o({type:e.type},e.value),{},{width:n,height:i,min:[0,0]}),u);u.fillStyle=t,u.fillRect(0,0,n,i)}))}},{key:"getOrCreatePattern",value:function(e,r,n){var i,a=e.image,o=e.repetition,s=e.transform,u=r.getGeometryBounds().halfExtents,l=2*u[0]||1,c=2*u[1]||1,f=this.context.config.offscreenCanvas,d=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(f),h=this.runtime.offscreenCanvasCreator.getOrCreateContext(f);if(d.width=l,d.height=c,I(a)){var _=this.context.imagePool.getImageSync(a,r,n);i=null==_?void 0:_.img}else i=a;var p=i&&h.createPattern(i,o);if(s){var E=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));p.setTransform({a:E[0],b:E[1],c:E[4],d:E[5],e:E[12],f:E[13]})}h.fillStyle=p,h.fillRect(0,0,l,c)}},{key:"destroy",value:function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}}}])}(),bo=function(e){function r(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l(this,r),(e=h(this,r)).name="device-renderer",e.parameters={toneMapping:Si.NONE,toneMappingExposure:1},e.options=t,e}return p(r,e),u(r,[{key:"init",value:function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new si;var n=new Zi(this.parameters),a=new ii,o=new Do(this.context,e),s=new ui,u=new So,l=new Co,c=(i(i(i(i(i(i(i(i(i(i(r={},t.Shape.CIRCLE,u),t.Shape.ELLIPSE,u),t.Shape.POLYLINE,l),t.Shape.PATH,l),t.Shape.POLYGON,l),t.Shape.RECT,new Io),t.Shape.IMAGE,new Po),t.Shape.LINE,new Mo),t.Shape.TEXT,new No),t.Shape.MESH,new Oo),i(i(r,t.Shape.GROUP,void 0),t.Shape.HTML,void 0)),f=new Bo(n,c,o,a),d=new ga(n,a,o,f,this.options);this.addRenderingPlugin(d),this.addRenderingPlugin(new Ta(n,d,s,f))}},{key:"destroy",value:function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]}},{key:"getRenderGraphPlugin",value:function(){return this.plugins[0]}},{key:"getDevice",value:function(){return this.getRenderGraphPlugin().getDevice()}},{key:"getSwapChain",value:function(){return this.getRenderGraphPlugin().getSwapChain()}},{key:"loadTexture",value:function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)}},{key:"toDataURL",value:function(e){return this.getRenderGraphPlugin().toDataURL(e)}},{key:"setParameters",value:function(e){this.parameters=o(o({},this.parameters),e)}}])}(t.AbstractRendererPlugin),Lo=Object.freeze({__proto__:null,AntialiasingMode:ta,Batch:ya,BufferGeometry:pa,DeviceProgram:li,DynamicUniformBuffer:ci,FILL_TEXTURE_MAPPING:Ba,Fog:ca,FogType:la,GeometryEvent:_a,HashMap:pi,ImageDrawcall:ho,Instanced:La,InstancedFillDrawcall:io,InstancedLineDrawcall:lo,InstancedPathDrawcall:qa,JOINT_TYPE:Qa,Light:sa,Material:Ca,MaterialEvent:Sa,Mesh:oi,MeshDrawcall:yo,Plugin:bo,RGAttachmentSlot:Ci,RenderCache:yi,RenderGraphPlugin:ga,RenderHelper:Zi,RenderInst:Wi,RenderInstExecutionOrder:zi,RenderInstFlags:Xi,RenderInstList:Yi,RenderInstManager:ji,Renderable3D:ni,RendererLayer:xi,SDFDrawcall:wa,ShaderMaterial:Pa,SingleSampledTexture:Mi,TemporalTexture:aa,TextDrawcall:Ao,TextUniform:To,TextureMapping:ia,TexturePool:Do,TinySDF:Wa,ToneMapping:Si,VertexAttributeBufferIndex:Da,VertexAttributeLocation:ba,bezierCurveTo:Va,compareDefines:Ma,definedProps:Oa,enumToObject:Na,fillColor:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r.a;return e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:Vi,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},hashCodeNumberFinish:di,hashCodeNumberUpdate:fi,makeAttachmentClearDescriptor:Qi,makeBackbufferDescSimple:na,makeDataBuffer:fa,makeDepthKey:Bi,makeSortKey:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&xi.TRANSLUCENT?Ui(e):Li(e,t)},makeSortKeyOpaque:Li,makeSortKeyTranslucent:Ui,nullHashFunc:hi,opaqueBlackFullClearRenderPassDescriptor:Ji,opaqueWhiteFullClearRenderPassDescriptor:ea,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===Oe.NEGATIVE_ONE?function(e){Z(e,wi,e)}(e):t===Oe.ZERO&&function(e){Z(e,Gi,e)}(e))},pushFXAAPass:Ra,quadCurveTo:Ga,renderInstCompareNone:null,renderInstCompareSortKey:Hi,segmentInstanceGeometry:ao,setBackbufferDescSimple:ra,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t){var r=!!(e>>>31&1),n=Bi(t,r,arguments.length>2&&void 0!==arguments[2]?arguments[2]:65536);return r?ki(e,n):Fi(e,n)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?ki(e,t):Fi(e,t)},setSortKeyLayer:Di,setSortKeyOpaqueDepth:Fi,setSortKeyProgramKey:bi,setSortKeyTranslucentDepth:ki,standardFullClearRenderPassDescriptor:$i,updateBuffer:eo}),Fo=function(){function e(){l(this,e)}return u(e,[{key:"apply",value:function(t,r){var n=this,i=t.renderingService,a=t.renderingContext,o=t.config;this.context=t;var s=a.root.ownerDocument.defaultView,u=function(e){i.hooks.pointerMove.call(e)},l=function(e){i.hooks.pointerUp.call(e)},c=function(e){i.hooks.pointerDown.call(e)},f=function(e){i.hooks.pointerOver.call(e)},d=function(e){i.hooks.pointerOut.call(e)},h=function(e){i.hooks.pointerCancel.call(e)},_=function(e){i.hooks.pointerWheel.call(e)},p=function(e){i.hooks.click.call(e)};i.hooks.init.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?function(e){r.globalThis.document.addEventListener("pointermove",u,!0),e.addEventListener("pointerdown",c,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",l,!0),r.globalThis.addEventListener("pointercancel",h,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",u,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",f,!0),r.globalThis.addEventListener("mouseup",l,!0)}(e),s.supportsTouchEvents&&function(e){e.addEventListener("touchstart",c,!0),e.addEventListener("touchend",l,!0),e.addEventListener("touchmove",u,!0),e.addEventListener("touchcancel",h,!0)}(e),o.useNativeClickEvent&&e.addEventListener("click",p,!0),e.addEventListener("wheel",_,{passive:!0,capture:!0})})),i.hooks.destroy.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):s.supportsPointerEvents&&(e.style.touchAction=""),s.supportsPointerEvents?function(e){r.globalThis.document.removeEventListener("pointermove",u,!0),e.removeEventListener("pointerdown",c,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",l,!0),r.globalThis.removeEventListener("pointercancel",h,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",u,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",f,!0),r.globalThis.removeEventListener("mouseup",l,!0)}(e),s.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",c,!0),e.removeEventListener("touchend",l,!0),e.removeEventListener("touchmove",u,!0),e.removeEventListener("touchcancel",h,!0)}(e),o.useNativeClickEvent&&e.removeEventListener("click",p,!0),e.removeEventListener("wheel",_,!0)}))}}])}();Fo.tag="DOMInteraction";var Uo=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="dom-interaction",e}return p(t,e),u(t,[{key:"init",value:function(){this.addRenderingPlugin(new Fo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),ko=Object.freeze({__proto__:null,Plugin:Uo}),wo=function(){function e(){l(this,e),this.displayObjectHTMLElementMap=new WeakMap}return u(e,[{key:"joinTransformMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];return"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")}},{key:"apply",value:function(r,n){var i=this,a=r.camera,o=r.renderingContext,s=r.renderingService;this.context=r;var u=o.root.ownerDocument.defaultView,l=u.context.eventService.nativeHTMLMap,c=function(e,t){t.style.transform=i.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){i.$camera||(i.$camera=i.createCamera(a));var n=i.getOrCreateEl(r);i.$camera.appendChild(n),Object.keys(r.attributes).forEach((function(e){i.updateAttribute(e,r)})),c(r,n),l.set(n,r)}},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&i.$camera){var n=i.getOrCreateEl(r);n&&(n.remove(),l.delete(n))}},h=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&i.updateAttribute(e.attrName,r)},_=function(e){var r=e.target;(r.nodeName===t.Shape.FRAGMENT?r.childNodes:[r]).forEach((function(e){if(e.nodeName===t.Shape.HTML){var r=i.getOrCreateEl(e);c(e,r)}}))},p=function(){if(i.$camera){var e=i.context.config,t=e.height;i.$camera.parentElement.style.width="".concat(e.width||0,"px"),i.$camera.parentElement.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){u.addEventListener(t.CanvasEvent.RESIZE,p),u.addEventListener(t.ElementEvent.MOUNTED,f),u.addEventListener(t.ElementEvent.UNMOUNTED,d),u.addEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.addEventListener(t.ElementEvent.BOUNDS_CHANGED,_)})),s.hooks.endFrame.tap(e.tag,(function(){i.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(i.$camera.style.transform=i.joinTransformMatrix(a.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){i.$camera&&i.$camera.remove(),u.removeEventListener(t.CanvasEvent.RESIZE,p),u.removeEventListener(t.ElementEvent.MOUNTED,f),u.removeEventListener(t.ElementEvent.UNMOUNTED,d),u.removeEventListener(t.ElementEvent.ATTR_MODIFIED,h),u.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,_)}))}},{key:"createCamera",value:function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,a=this.context.contextService.getDomElement(),o=a.parentNode;if(o){var s="g-canvas-camera",u=o.querySelector("#".concat(s));if(!u){var l=(r||document).createElement("div");l.style.overflow="hidden",l.style.pointerEvents="none",l.style.position="absolute",l.style.left="0px",l.style.top="0px",l.style.width="".concat(n||0,"px"),l.style.height="".concat(i||0,"px");var c=(r||document).createElement("div");u=c,c.id=s,c.style.position="absolute",c.style.left="".concat(a.offsetLeft||0,"px"),c.style.top="".concat(a.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),c.style.pointerEvents="none",c.style.width="100%",c.style.height="100%",l.appendChild(c),o.appendChild(l)}return u}return null}},{key:"getOrCreateEl",value:function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),r}},{key:"updateAttribute",value:function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;I(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"x":n.style.left="".concat(r.parsedStyle.x,"px");break;case"y":n.style.top="".concat(r.parsedStyle.y,"px");break;case"transformOrigin":var a=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(a[0].buildCSSText(null,null,"")," ").concat(a[1].buildCSSText(null,null,""));break;case"width":var o=r.parsedStyle.width;n.style.width=B(o)?"".concat(o,"px"):""+o;break;case"height":var s=r.parsedStyle.height;n.style.height=B(s)?"".concat(s,"px"):""+s;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":var u=r.parsedStyle.pointerEvents;n.style.pointerEvents=void 0===u?"auto":u;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var l=r.parsedStyle.fill,c="";t.isCSSRGB(l)?c=l.isNone?"transparent":r.getAttribute("fill"):Array.isArray(l)?c=r.getAttribute("fill"):t.isPattern(l),n.style.background=c;break;case"stroke":var f=r.parsedStyle.stroke,d="";t.isCSSRGB(f)?d=f.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(f)?d=r.getAttribute("stroke"):t.isPattern(f),n.style["border-color"]=d,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:O(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e])}}}])}();wo.tag="HTMLRendering";var Go=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="html-renderer",e}return p(t,e),u(t,[{key:"init",value:function(){this.addRenderingPlugin(new wo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Vo=Object.freeze({__proto__:null,Plugin:Go}),Xo=function(){return u((function e(){l(this,e),this.cacheStore=new Map}),[{key:"onRefAdded",value:function(e){}},{key:"has",value:function(e){return this.cacheStore.has(e)}},{key:"put",value:function(e,t,r){return!this.cacheStore.has(e)&&(this.cacheStore.set(e,{value:t,counter:new Set([r])}),this.onRefAdded(r),!0)}},{key:"get",value:function(e,t){var r=this.cacheStore.get(e);return r?(r.counter.has(t)||(r.counter.add(t),this.onRefAdded(t)),r.value):null}},{key:"update",value:function(e,t,r){var n=this.cacheStore.get(e);return!!n&&(n.value=o(o({},n.value),t),n.counter.has(r)||(n.counter.add(r),this.onRefAdded(r)),!0)}},{key:"release",value:function(e,t){var r=this.cacheStore.get(e);return!!r&&(r.counter.delete(t),r.counter.size>0||this.cacheStore.delete(e),!0)}},{key:"releaseRef",value:function(e){var t=this;Array.from(this.cacheStore.keys()).forEach((function(r){t.release(r,e)}))}},{key:"getSize",value:function(){return this.cacheStore.size}},{key:"clear",value:function(){this.cacheStore.clear()}}])}(),Wo=[],Ho=[],zo=function(){function e(){l(this,e)}return u(e,null,[{key:"stop",value:function(){e.rafId&&((arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api).cancelAnimationFrame(e.rafId),e.rafId=null)}},{key:"executeTask",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api;(Wo.length>0||Ho.length>0)&&(Ho.forEach((function(e){return e()})),Ho=Wo.splice(0,e.TASK_NUM_PER_FRAME),e.rafId=t.requestAnimationFrame((function(){e.executeTask(t)})))}},{key:"sliceImage",value:function(t,r,n,i){for(var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e.api,s=t.naturalWidth||t.width,u=t.naturalHeight||t.height,l=r-a,c=n-a,f=Math.ceil(s/l),d=Math.ceil(u/c),h={tileSize:[r,n],gridSize:[d,f],tiles:Array(d).fill(null).map((function(){return Array(f).fill(null)}))},_=function(e){for(var a=function(a){Wo.push((function(){var f=a*l,d=e*c,_=[Math.min(r,s-f),Math.min(n,u-d)],p=_[0],E=_[1],v=o.createCanvas();v.width=r,v.height=n,v.getContext("2d").drawImage(t,f,d,p,E,0,0,p,E),h.tiles[e][a]={x:f,y:d,tileX:a,tileY:e,data:v},i()}))},d=0;f>d;d++)a(d)},p=0;d>p;p++)_(p);return e.stop(),e.executeTask(),h}}])}();zo.TASK_NUM_PER_FRAME=10;var Yo=new Xo;Yo.onRefAdded=function(e){var r=this;e.addEventListener(t.ElementEvent.DESTROY,(function(){r.releaseRef(e)}),{once:!0})};var Ko=function(){return u((function e(t,r){l(this,e),this.gradientCache={},this.patternCache={},this.context=t,this.runtime=r}),[{key:"getImageSync",value:function(e,t,r){var n=I(e)?e:e.src;if(Yo.has(n)){var i=Yo.get(n,t);if(i.img.complete)return null==r||r(i),i}return this.getOrCreateImage(e,t).then((function(e){null==r||r(e)})).catch((function(){})),null}},{key:"getOrCreateImage",value:function(e,t){var r=this,n=I(e)?e:e.src;if(!I(e)&&!Yo.has(n)){var i={img:e,size:[e.naturalWidth||e.width,e.naturalHeight||e.height],tileSize:jo(e)};Yo.put(n,i,t)}if(Yo.has(n)){var a=Yo.get(n,t);return a.img.complete?Promise.resolve(a):new Promise((function(e,t){a.img.addEventListener("load",(function(){a.size=[a.img.naturalWidth||a.img.width,a.img.naturalHeight||a.img.height],a.tileSize=jo(a.img),e(a)})),a.img.addEventListener("error",(function(e){t(e)}))}))}return new Promise((function(e,i){var a=r.context.config.createImage();if(a){var o={img:a,size:[0,0],tileSize:jo(a)};Yo.put(n,o,t),a.onload=function(){o.size=[a.naturalWidth||a.width,a.naturalHeight||a.height],o.tileSize=jo(o.img),e(o)},a.onerror=function(e){i(e)},a.crossOrigin="Anonymous",a.src=n}}))}},{key:"createDownSampledImage",value:(r=M(P().mark((function e(t,r){var n,i,a,s,u,l,c,f,d,h,_,p,E,v;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getOrCreateImage(t,r);case 2:if(void 0===(n=e.sent).downSamplingRate){e.next=5;break}return e.abrupt("return",n);case 5:if(u=void 0===(s=(a="boolean"==typeof(i=this.context.config.enableLargeImageOptimization)?{}:i).maxDownSampledImageSize)?2048:s,c=void 0===(l=a.downSamplingRateThreshold)?.5:l,f=this.runtime.globalThis.createImageBitmap,d=C(n.size,2),p=n.img,E=Math.min((u+u)/((h=d[0])+(_=d[1])),Math.max(.01,Math.min(c,.5))),v=o(o({},n),{},{downSamplingRate:E}),Yo.update(n.img.src,v,r),!f){e.next=25;break}return e.prev=14,e.next=17,f(n.img,{resizeWidth:h*E,resizeHeight:_*E});case 17:p=e.sent,e.next=23;break;case 20:e.prev=20,e.t0=e.catch(14),E=1;case 23:e.next=26;break;case 25:E=1;case 26:return v=o(o({},this.getImageSync(t,r)),{},{downSampled:p,downSamplingRate:E}),Yo.update(n.img.src,v,r),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e,t){return r.apply(this,arguments)})},{key:"createImageTiles",value:(e=M(P().mark((function e(r,n,i,a){var s,u,l;return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getOrCreateImage(r,a);case 2:return s=e.sent,zo.api={requestAnimationFrame:(u=a.ownerDocument.defaultView).requestAnimationFrame,cancelAnimationFrame:u.cancelAnimationFrame,createCanvas:function(){return t.OffscreenCanvasCreator.createCanvas()}},l=o(o({},s),zo.sliceImage(s.img,s.tileSize[0],s.tileSize[0],i)),Yo.update(s.img.src,l,a),e.abrupt("return",l);case 8:case"end":return e.stop()}}),e,this)}))),function(t,r,n,i){return e.apply(this,arguments)})},{key:"releaseImage",value:function(e,t){Yo.release(I(e)?e:e.src,t)}},{key:"releaseImageRef",value:function(e){Yo.releaseRef(e)}},{key:"getOrCreatePatternSync",value:function(e,r,n,i,a,o,s){var u=this.generatePatternKey(r);if(u&&this.patternCache[u])return this.patternCache[u];var l,c=r.image,f=r.repetition,d=r.transform,h=!1;if(I(c)){var _=this.getImageSync(c,e,s);l=null==_?void 0:_.img}else i?(l=i,h=!0):l=c;var p,E=l&&n.createPattern(l,f);E&&(p=d?t.parsedTransformToMat4(t.parseTransform(d),new t.DisplayObject({})):k(L()),h&&V(p,p,[1/a,1/a,1]),E.setTransform({a:p[0],b:p[1],c:p[4],d:p[5],e:p[12]+o[0],f:p[13]+o[1]}));return u&&E&&(this.patternCache[u]=E),E}},{key:"getOrCreateGradient",value:function(e,r){var n=this.generateGradientKey(e),i=e.type,a=e.steps,o=e.min,s=e.width,u=e.height,l=e.cx,c=e.cy,f=e.size;if(this.gradientCache[n])return this.gradientCache[n];var d=null;if(i===t.GradientType.LinearGradient){var h=t.computeLinearGradient(o,s,u,e.angle);d=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(i===t.GradientType.RadialGradient){var _=t.computeRadialGradient(o,s,u,l,c,f),p=_.x,E=_.y;d=r.createRadialGradient(p,E,0,p,E,_.r)}return d&&(a.forEach((function(e){var r,n=e.offset;n.unit===t.UnitType.kPercentage&&(null===(r=d)||void 0===r||r.addColorStop(n.value/100,""+e.color))})),this.gradientCache[n]=d),this.gradientCache[n]}},{key:"generateGradientKey",value:function(e){var t=e.min,r=e.width,n=e.height,i=e.steps,a=e.angle,o=e.cx,s=e.cy,u=e.size;return"gradient-".concat(e.type,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat((null==u?void 0:""+u)||0,"-").concat(t[0],"-").concat(t[1],"-").concat(r,"-").concat(n,"-").concat(i.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))}},{key:"generatePatternKey",value:function(e){var t=e.image,r=e.repetition;return I(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0}}]);var e,r}();function jo(e){if(!e.complete)return[0,0];var t=e.naturalWidth||e.width,r=e.naturalHeight||e.height,n=256;return[256,512].forEach((function(e){1e3>Math.ceil(r/e)*Math.ceil(t/e)&&(n=e)})),[n,n]}Ko.isSupportTile=!!t.OffscreenCanvasCreator.createCanvas();var Zo=function(){function e(){l(this,e)}return u(e,[{key:"apply",value:function(r){var n=r.renderingService,i=r.imagePool,a=r.renderingContext.root.ownerDocument.defaultView,o=function(e,t,r){var n=e.parsedStyle,i=n.width,a=n.height;i&&!a?e.setAttribute("height",r/t*i):!i&&a&&e.setAttribute("width",t/r*a)},s=function(e){var r=e.target,a=r.attributes;if(r.nodeName===t.Shape.IMAGE){var s=a.keepAspectRatio;i.getImageSync(a.src,r,(function(e){var t=e.img;s&&o(r,t.width,t.height),r.renderable.dirty=!0,n.dirtify()}))}},u=function(e){var r=e.target,a=e.prevValue,s=e.newValue;r.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&(a!==s&&i.releaseImage(a,r),I(s)&&i.getOrCreateImage(s,r).then((function(e){var t=e.img;r.attributes.keepAspectRatio&&o(r,t.width,t.height),r.renderable.dirty=!0,n.dirtify()})).catch((function(){})))};n.hooks.init.tap(e.tag,(function(){a.addEventListener(t.ElementEvent.MOUNTED,s),a.addEventListener(t.ElementEvent.ATTR_MODIFIED,u)})),n.hooks.destroy.tap(e.tag,(function(){a.removeEventListener(t.ElementEvent.MOUNTED,s),a.removeEventListener(t.ElementEvent.ATTR_MODIFIED,u)}))}}])}();Zo.tag="LoadImage";var qo=function(e){function t(){var e;l(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=h(this,t,[].concat(n))).name="image-loader",e}return p(t,e),u(t,[{key:"init",value:function(e){this.context.imagePool=new Ko(this.context,e),this.addRenderingPlugin(new Zo)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Qo=function(){return u((function e(t){l(this,e),this.canvasConfig=t.config,this.deviceRendererPlugin=t.deviceRendererPlugin}),[{key:"init",value:function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=I(t)?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.resize(this.canvasConfig.width,this.canvasConfig.height)}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getContext",value:function(){return this.deviceRendererPlugin.getDevice().canvasContext}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,r){if(this.dpr=this.canvasConfig.devicePixelRatio,this.$canvas){var n=this.getDPR();this.$canvas.width=n*e,this.$canvas.height=n*r,t.setDOMSize(this.$canvas,e,r)}}},{key:"getDPR",value:function(){return this.dpr}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}},{key:"toDataURL",value:(e=M(P().mark((function e(t){return P().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return","");case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),$o=function(e){function t(e,r){var n;return l(this,t),(n=h(this,t)).name="webgpu-context-register",n.rendererPlugin=e,n.config=r,n}return p(t,e),u(t,[{key:"init",value:function(){this.context.ContextService=Qo,this.context.deviceRendererPlugin=this.rendererPlugin;var e=this.config;this.context.deviceContribution=new Tn({shaderCompilerPath:null==e?void 0:e.shaderCompilerPath,onContextLost:null==e?void 0:e.onContextLost})}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(t.AbstractRendererPlugin),Jo=function(e){function r(e){var n;l(this,r),(n=h(this,r,[o({enableSizeAttenuation:!1},e)])).clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var i=new bo;return n.registerPlugin(new $o(i,e)),n.registerPlugin(new qo),n.registerPlugin(i),n.registerPlugin(new Uo),n.registerPlugin(new Go),n}return p(r,e),u(r)}(t.AbstractRenderer);e.DeviceRenderer=Lo,e.DomInteraction=ko,e.HTMLRenderer=Vo,e.Renderer=Jo}));
27
27
  //# sourceMappingURL=index.umd.min.js.map