/*! * Copyright (c) 2012 - 2023, Anaconda, Inc., and Bokeh Contributors * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of Anaconda nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ (function(root, factory) { factory(root["Bokeh"], "3.1.1"); })(this, function(Bokeh, version) { let define; return (function(modules, entry, aliases, externals) { const bokeh = typeof Bokeh !== "undefined" && (version != null ? Bokeh[version] : Bokeh); if (bokeh != null) { return bokeh.register_plugin(modules, entry, aliases); } else { throw new Error("Cannot find Bokeh " + version + ". You have to load it prior to loading plugins."); } }) ({ 503: function _(n,c,f,i,o){i(),n(504)}, 504: function _(t,_,r,e,o){e();const a=t(1);o("get_regl",t(505).get_regl),a.__exportStar(t(513),r),a.__exportStar(t(517),r),a.__exportStar(t(518),r),a.__exportStar(t(520),r),a.__exportStar(t(521),r),a.__exportStar(t(522),r),a.__exportStar(t(523),r),a.__exportStar(t(524),r),a.__exportStar(t(519),r),a.__exportStar(t(525),r)}, 505: function _(t,i,e,_,a){_();const r=t(1),o=r.__importDefault(t(506)),n=t(507),s=r.__importDefault(t(509)),l=r.__importDefault(t(510)),p=r.__importDefault(t(511)),h=r.__importDefault(t(512));let c=null;e.get_regl=function(t){return null==c&&(c=new u(t)),c};class u{constructor(t){try{this._regl=(0,o.default)({gl:t,extensions:["ANGLE_instanced_arrays","EXT_blend_minmax"]}),this._regl_available=!0,this._line_geometry=this._regl.buffer({usage:"static",type:"float",data:[[-2,0],[-1,-1],[1,-1],[1,1],[-1,1]]}),this._line_triangles=this._regl.elements({usage:"static",primitive:"triangle fan",data:[0,1,2,3,4]})}catch(t){this._regl_available=!1}}buffer(t){return this._regl.buffer(t)}clear(t,i){this._viewport={x:0,y:0,width:t,height:i},this._regl.clear({color:[0,0,0,0]})}get has_webgl(){return this._regl_available}get scissor(){return this._scissor}set_scissor(t,i,e,_){this._scissor={x:t,y:i,width:e,height:_}}get viewport(){return this._viewport}dashed_line(){return null==this._dashed_line&&(this._dashed_line=function(t,i,e){const _={vert:`#define DASHED\n\n${s.default}`,frag:`#define DASHED\n\n${l.default}`,attributes:{a_position:{buffer:i,divisor:0},a_point_prev:(t,i)=>i.points.to_attribute_config(),a_point_start:(t,i)=>i.points.to_attribute_config(2*Float32Array.BYTES_PER_ELEMENT),a_point_end:(t,i)=>i.points.to_attribute_config(4*Float32Array.BYTES_PER_ELEMENT),a_point_next:(t,i)=>i.points.to_attribute_config(6*Float32Array.BYTES_PER_ELEMENT),a_show_prev:(t,i)=>i.show.to_attribute_config(),a_show_curr:(t,i)=>i.show.to_attribute_config(Uint8Array.BYTES_PER_ELEMENT),a_show_next:(t,i)=>i.show.to_attribute_config(2*Uint8Array.BYTES_PER_ELEMENT),a_length_so_far:(t,i)=>i.length_so_far.to_attribute_config()},uniforms:{u_canvas_size:t.prop("canvas_size"),u_pixel_ratio:t.prop("pixel_ratio"),u_antialias:t.prop("antialias"),u_line_color:t.prop("line_color"),u_linewidth:t.prop("linewidth"),u_miter_limit:t.prop("miter_limit"),u_line_join:t.prop("line_join"),u_line_cap:t.prop("line_cap"),u_dash_tex:t.prop("dash_tex"),u_dash_tex_info:t.prop("dash_tex_info"),u_dash_scale:t.prop("dash_scale"),u_dash_offset:t.prop("dash_offset")},elements:e,instances:t.prop("nsegments"),blend:{enable:!0,equation:"max",func:{srcRGB:1,srcAlpha:1,dstRGB:1,dstAlpha:1}},depth:{enable:!1},scissor:{enable:!0,box:t.prop("scissor")},viewport:t.prop("viewport")};return t(_)}(this._regl,this._line_geometry,this._line_triangles)),this._dashed_line}get_dash(t){return null==this._dash_cache&&(this._dash_cache=new n.DashCache(this._regl)),this._dash_cache.get(t)}marker_no_hatch(t){null==this._marker_no_hatch_map&&(this._marker_no_hatch_map=new Map);let i=this._marker_no_hatch_map.get(t);return null==i&&(i=function(t,i){const e={vert:p.default,frag:` #define USE_${i.toUpperCase()}\n ${h.default}\n `,attributes:{a_position:{buffer:t.buffer([[-.5,-.5],[-.5,.5],[.5,.5],[.5,-.5]]),divisor:0},a_center:(t,i)=>i.center.to_attribute_config(),a_width:(t,i)=>i.width.to_attribute_config(),a_height:(t,i)=>i.height.to_attribute_config(),a_angle:(t,i)=>i.angle.to_attribute_config(),a_linewidth:(t,i)=>i.linewidth.to_attribute_config(),a_line_color:(t,i)=>i.line_color.to_attribute_config(),a_fill_color:(t,i)=>i.fill_color.to_attribute_config(),a_line_cap:(t,i)=>i.line_cap.to_attribute_config(),a_line_join:(t,i)=>i.line_join.to_attribute_config(),a_show:(t,i)=>i.show.to_attribute_config()},uniforms:{u_canvas_size:t.prop("canvas_size"),u_pixel_ratio:t.prop("pixel_ratio"),u_antialias:t.prop("antialias"),u_border_radius:t.prop("border_radius"),u_size_hint:t.prop("size_hint")},count:4,primitive:"triangle fan",instances:t.prop("nmarkers"),blend:{enable:!0,func:{srcRGB:"one",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}},depth:{enable:!1},scissor:{enable:!0,box:t.prop("scissor")},viewport:t.prop("viewport")};return t(e)}(this._regl,t),this._marker_no_hatch_map.set(t,i)),i}marker_hatch(t){null==this._marker_hatch_map&&(this._marker_hatch_map=new Map);let i=this._marker_hatch_map.get(t);return null==i&&(i=function(t,i){const e={vert:`#define HATCH\n${p.default}`,frag:`#define USE_${i.toUpperCase()}\n#define HATCH\n${h.default}`,attributes:{a_position:{buffer:t.buffer([[-.5,-.5],[-.5,.5],[.5,.5],[.5,-.5]]),divisor:0},a_center:(t,i)=>i.center.to_attribute_config(),a_width:(t,i)=>i.width.to_attribute_config(),a_height:(t,i)=>i.height.to_attribute_config(),a_angle:(t,i)=>i.angle.to_attribute_config(),a_linewidth:(t,i)=>i.linewidth.to_attribute_config(),a_line_color:(t,i)=>i.line_color.to_attribute_config(),a_fill_color:(t,i)=>i.fill_color.to_attribute_config(),a_line_cap:(t,i)=>i.line_cap.to_attribute_config(),a_line_join:(t,i)=>i.line_join.to_attribute_config(),a_show:(t,i)=>i.show.to_attribute_config(),a_hatch_pattern:(t,i)=>i.hatch_pattern.to_attribute_config(),a_hatch_scale:(t,i)=>i.hatch_scale.to_attribute_config(),a_hatch_weight:(t,i)=>i.hatch_weight.to_attribute_config(),a_hatch_color:(t,i)=>i.hatch_color.to_attribute_config()},uniforms:{u_canvas_size:t.prop("canvas_size"),u_pixel_ratio:t.prop("pixel_ratio"),u_antialias:t.prop("antialias"),u_border_radius:t.prop("border_radius"),u_size_hint:t.prop("size_hint")},count:4,primitive:"triangle fan",instances:t.prop("nmarkers"),blend:{enable:!0,func:{srcRGB:"one",srcAlpha:"one",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"}},depth:{enable:!1},scissor:{enable:!0,box:t.prop("scissor")},viewport:t.prop("viewport")};return t(e)}(this._regl,t),this._marker_hatch_map.set(t,i)),i}solid_line(){return null==this._solid_line&&(this._solid_line=function(t,i,e){const _={vert:s.default,frag:l.default,attributes:{a_position:{buffer:i,divisor:0},a_point_prev:(t,i)=>i.points.to_attribute_config(),a_point_start:(t,i)=>i.points.to_attribute_config(2*Float32Array.BYTES_PER_ELEMENT),a_point_end:(t,i)=>i.points.to_attribute_config(4*Float32Array.BYTES_PER_ELEMENT),a_point_next:(t,i)=>i.points.to_attribute_config(6*Float32Array.BYTES_PER_ELEMENT),a_show_prev:(t,i)=>i.show.to_attribute_config(),a_show_curr:(t,i)=>i.show.to_attribute_config(Uint8Array.BYTES_PER_ELEMENT),a_show_next:(t,i)=>i.show.to_attribute_config(2*Uint8Array.BYTES_PER_ELEMENT)},uniforms:{u_canvas_size:t.prop("canvas_size"),u_pixel_ratio:t.prop("pixel_ratio"),u_antialias:t.prop("antialias"),u_line_color:t.prop("line_color"),u_linewidth:t.prop("linewidth"),u_miter_limit:t.prop("miter_limit"),u_line_join:t.prop("line_join"),u_line_cap:t.prop("line_cap")},elements:e,instances:t.prop("nsegments"),blend:{enable:!0,equation:"max",func:{srcRGB:1,srcAlpha:1,dstRGB:1,dstAlpha:1}},depth:{enable:!1},scissor:{enable:!0,box:t.prop("scissor")},viewport:t.prop("viewport")};return t(_)}(this._regl,this._line_geometry,this._line_triangles)),this._solid_line}}e.ReglWrapper=u,u.__name__="ReglWrapper"}, 506: function _(e,t,r,n,a){var i,o;i=this,o=function(){"use strict";var e=function(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof Uint8ClampedArray},t=function(e,t){for(var r=Object.keys(t),n=0;n=0&&(0|e)===e||n("invalid parameter type, ("+e+")"+i(t)+". must be a nonnegative integer")},oneOf:f,shaderError:function(e,t,n,i,o){if(!e.getShaderParameter(t,e.COMPILE_STATUS)){var f=e.getShaderInfoLog(t),u=i===e.FRAGMENT_SHADER?"fragment":"vertex";g(n,"string",u+" shader source must be a string",o);var c=h(n,o),l=function(e){var t=[];return e.split("\n").forEach((function(e){if(!(e.length<5)){var r=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(e);r?t.push(new d(0|r[1],0|r[2],r[3].trim())):e.length>0&&t.push(new d("unknown",0,e))}})),t}(f);!function(e,t){t.forEach((function(t){var r=e[t.file];if(r){var n=r.index[t.line];if(n)return n.errors.push(t),void(r.hasErrors=!0)}e.unknown.hasErrors=!0,e.unknown.lines[0].errors.push(t)}))}(c,l),Object.keys(c).forEach((function(e){var t=c[e];if(t.hasErrors){var n=[""],a=[""];i("file number "+e+": "+t.name+"\n","color:red;text-decoration:underline;font-weight:bold"),t.lines.forEach((function(e){if(e.errors.length>0){i(s(e.number,4)+"| ","background-color:yellow; font-weight:bold"),i(e.line+r,"color:red; background-color:yellow; font-weight:bold");var t=0;e.errors.forEach((function(n){var a=n.message,o=/^\s*'(.*)'\s*:\s*(.*)$/.exec(a);if(o){var f=o[1];a=o[2],"assign"===f&&(f="="),t=Math.max(e.line.indexOf(f,t),0)}else t=0;i(s("| ",6)),i(s("^^^",t+3)+r,"font-weight:bold"),i(s("| ",6)),i(a+r,"font-weight:bold")})),i(s("| ",6)+r)}else i(s(e.number,4)+"| "),i(e.line+r,"color:red")})),"undefined"==typeof document||window.chrome?console.log(n.join("")):(a[0]=n.join("%c"),console.log.apply(console,a))}function i(e,t){n.push(e),a.push(t||"")}})),a.raise("Error compiling "+u+" shader, "+c[0].name)}},linkError:function(e,t,n,i,o){if(!e.getProgramParameter(t,e.LINK_STATUS)){var f=e.getProgramInfoLog(t),u=h(n,o),s='Error linking program with vertex shader, "'+h(i,o)[0].name+'", and fragment shader "'+u[0].name+'"';"undefined"!=typeof document?console.log("%c"+s+r+"%c"+f,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(s+r+f),a.raise(s)}},callSite:p,saveCommandRef:b,saveDrawInfo:function(e,t,r,n){function a(e){return e?n.id(e):0}function i(e,t){Object.keys(t).forEach((function(t){e[n.id(t)]=!0}))}b(e),e._fragId=a(e.static.frag),e._vertId=a(e.static.vert);var o=e._uniformSet={};i(o,t.static),i(o,t.dynamic);var f=e._attributeSet={};i(f,r.static),i(f,r.dynamic),e._hasCount="count"in e.static||"count"in e.dynamic||"elements"in e.static||"elements"in e.dynamic},framebufferFormat:function(e,t,r){e.texture?f(e.texture._texture.internalformat,t,"unsupported texture format for attachment"):f(e.renderbuffer._renderbuffer.format,r,"unsupported renderbuffer format for attachment")},guessCommand:m,texture2D:function(e,t,r){var n,i=t.width,o=t.height,f=t.channels;a(i>0&&i<=r.maxTextureSize&&o>0&&o<=r.maxTextureSize,"invalid texture shape"),e.wrapS===y&&e.wrapT===y||a(z(i)&&z(o),"incompatible wrap mode for texture, both width and height must be power of 2"),1===t.mipmask?1!==i&&1!==o&&a(e.minFilter!==w&&e.minFilter!==_&&e.minFilter!==A&&e.minFilter!==k,"min filter requires mipmap"):(a(z(i)&&z(o),"texture must be a square power of 2 to support mipmapping"),a(t.mipmask===(i<<1)-1,"missing or incomplete mipmap data")),t.type===S&&(r.extensions.indexOf("oes_texture_float_linear")<0&&a(e.minFilter===x&&e.magFilter===x,"filter not supported, must enable oes_texture_float_linear"),a(!e.genMipmaps,"mipmap generation not supported with float textures"));var u=t.images;for(n=0;n<16;++n)if(u[n]){var s=i>>n,c=o>>n;a(t.mipmask&1<0&&i<=n.maxTextureSize&&o>0&&o<=n.maxTextureSize,"invalid texture shape"),a(i===o,"cube map must be square"),a(t.wrapS===y&&t.wrapT===y,"wrap mode not supported by cube map");for(var u=0;u>l,p=o>>l;a(s.mipmask&1<1&&t===r&&('"'===t||"'"===t))return['"'+R(e.substr(1,e.length-2))+'"'];var n=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(e);if(n)return M(e.substr(0,n.index)).concat(M(n[1])).concat(M(e.substr(n.index+n[0].length)));var a=e.split(".");if(1===a.length)return['"'+R(e)+'"'];for(var i=[],o=0;o0,"invalid pixel ratio"))):F.raise("invalid arguments to regl"),r&&("canvas"===r.nodeName.toLowerCase()?a=r:n=r),!i){if(!a){F("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var h=function(e,r,n){var a,i=document.createElement("canvas");function o(){var t=window.innerWidth,r=window.innerHeight;if(e!==document.body){var a=i.getBoundingClientRect();t=a.right-a.left,r=a.bottom-a.top}i.width=n*t,i.height=n*r}return t(i.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),e.appendChild(i),e===document.body&&(i.style.position="absolute",t(e.style,{margin:0,padding:0})),e!==document.body&&"function"==typeof ResizeObserver?(a=new ResizeObserver((function(){setTimeout(o)}))).observe(e):window.addEventListener("resize",o,!1),o(),{canvas:i,onDestroy:function(){a?a.disconnect():window.removeEventListener("resize",o),e.removeChild(i)}}}(n||document.body,0,l);if(!h)return null;a=h.canvas,p=h.onDestroy}void 0===u.premultipliedAlpha&&(u.premultipliedAlpha=!0),i=function(e,t){function r(r){try{return e.getContext(r,t)}catch(e){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}(a,u)}return i?{gl:i,canvas:a,container:n,extensions:s,optionalExtensions:c,pixelRatio:l,profile:d,onDone:m,onDestroy:p}:(p(),m("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function Y(e,t){for(var r=Array(e),n=0;n65535)<<4,t|=r=((e>>>=t)>255)<<3,t|=r=((e>>>=r)>15)<<2,(t|=r=((e>>>=r)>3)<<1)|(e>>>=r)>>1}function ne(){var e=Y(8,(function(){return[]}));function t(t){var r=function(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}(t),n=e[re(r)>>2];return n.length>0?n.pop():new ArrayBuffer(r)}function r(t){e[re(t.byteLength)>>2].push(t)}return{alloc:t,free:r,allocType:function(e,r){var n=null;switch(e){case X:n=new Int8Array(t(r),0,r);break;case $:n=new Uint8Array(t(r),0,r);break;case K:n=new Int16Array(t(2*r),0,r);break;case J:n=new Uint16Array(t(2*r),0,r);break;case Z:n=new Int32Array(t(4*r),0,r);break;case ee:n=new Uint32Array(t(4*r),0,r);break;case te:n=new Float32Array(t(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(e){r(e.buffer)}}}var ae=ne();ae.zero=ne();var ie=3553,oe=6408,fe=5126,ue=36160,se=function(e,t){var r=1;t.ext_texture_filter_anisotropic&&(r=e.getParameter(34047));var n=1,a=1;t.webgl_draw_buffers&&(n=e.getParameter(34852),a=e.getParameter(36063));var i=!!t.oes_texture_float;if(i){var o=e.createTexture();e.bindTexture(ie,o),e.texImage2D(ie,0,oe,1,1,0,oe,fe,null);var f=e.createFramebuffer();if(e.bindFramebuffer(ue,f),e.framebufferTexture2D(ue,36064,ie,o,0),e.bindTexture(ie,null),36053!==e.checkFramebufferStatus(ue))i=!1;else{e.viewport(0,0,1,1),e.clearColor(1,0,0,1),e.clear(16384);var u=ae.allocType(fe,4);e.readPixels(0,0,1,1,oe,fe,u),e.getError()?i=!1:(e.deleteFramebuffer(f),e.deleteTexture(o),i=1===u[0]),ae.freeType(u)}}var s=!0;if("undefined"==typeof navigator||!(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))){var c=e.createTexture(),l=ae.allocType(5121,36);e.activeTexture(33984),e.bindTexture(34067,c),e.texImage2D(34069,0,oe,3,3,0,oe,5121,l),ae.freeType(l),e.bindTexture(34067,null),e.deleteTexture(c),s=!e.getError()}return{colorBits:[e.getParameter(3410),e.getParameter(3411),e.getParameter(3412),e.getParameter(3413)],depthBits:e.getParameter(3414),stencilBits:e.getParameter(3415),subpixelBits:e.getParameter(3408),extensions:Object.keys(t).filter((function(e){return!!t[e]})),maxAnisotropic:r,maxDrawbuffers:n,maxColorAttachments:a,pointSizeDims:e.getParameter(33901),lineWidthDims:e.getParameter(33902),maxViewportDims:e.getParameter(3386),maxCombinedTextureUnits:e.getParameter(35661),maxCubeMapSize:e.getParameter(34076),maxRenderbufferSize:e.getParameter(34024),maxTextureUnits:e.getParameter(34930),maxTextureSize:e.getParameter(3379),maxAttributes:e.getParameter(34921),maxVertexUniforms:e.getParameter(36347),maxVertexTextureUnits:e.getParameter(35660),maxVaryingVectors:e.getParameter(36348),maxFragmentUniforms:e.getParameter(36349),glsl:e.getParameter(35724),renderer:e.getParameter(7937),vendor:e.getParameter(7936),version:e.getParameter(7938),readFloat:i,npotTextureCube:s}};function ce(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||e(t.data))}var le=function(e){return Object.keys(e).map((function(t){return e[t]}))},de={shape:function(e){for(var t=[],r=e;r.length;r=r[0])t.push(r.length);return t},flatten:function(e,t,r,n){var a=1;if(t.length)for(var i=0;i>>31<<15,i=(n<<1>>>24)-127,o=n>>13&1023;if(i<-24)t[r]=a;else if(i<-14){var f=-14-i;t[r]=a+(o+1024>>f)}else t[r]=i>15?a+31744:a+(i+15<<10)+o}return t}function Ne(t){return Array.isArray(t)||e(t)}var qe=function(e){return!(e&e-1||!e)},Qe=34467,Ye=3553,Xe=34067,$e=34069,Ke=6408,Je=6406,Ze=6407,et=6409,tt=6410,rt=32854,nt=32855,at=36194,it=32819,ot=32820,ft=33635,ut=34042,st=6402,ct=34041,lt=35904,dt=35906,mt=36193,pt=33776,ht=33777,bt=33778,vt=33779,gt=35986,yt=35987,xt=34798,wt=35840,At=35841,_t=35842,kt=35843,St=36196,Ot=5121,Et=5123,Tt=5125,Dt=5126,jt=10242,Ct=10243,zt=10497,Ft=33071,Vt=33648,Bt=10240,It=10241,Pt=9728,Lt=9729,Rt=9984,Mt=9985,Ut=9986,Wt=9987,Gt=33170,Ht=4352,Nt=4353,qt=4354,Qt=34046,Yt=3317,Xt=37440,$t=37441,Kt=37443,Jt=37444,Zt=33984,er=[Rt,Ut,Mt,Wt],tr=[0,et,tt,Ze,Ke],rr={};function nr(e){return"[object "+e+"]"}rr[et]=rr[Je]=rr[st]=1,rr[ct]=rr[tt]=2,rr[Ze]=rr[lt]=3,rr[Ke]=rr[dt]=4;var ar=nr("HTMLCanvasElement"),ir=nr("OffscreenCanvas"),or=nr("CanvasRenderingContext2D"),fr=nr("ImageBitmap"),ur=nr("HTMLImageElement"),sr=nr("HTMLVideoElement"),cr=Object.keys(he).concat([ar,ir,or,fr,ur,sr]),lr=[];lr[Ot]=1,lr[Dt]=4,lr[mt]=2,lr[Et]=2,lr[Tt]=4;var dr=[];function mr(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function pr(e){return!!Array.isArray(e)&&!(0===e.length||!Ne(e[0]))}function hr(e){return Object.prototype.toString.call(e)}function br(e){return hr(e)===ar}function vr(e){return hr(e)===ir}function gr(e){if(!e)return!1;var t=hr(e);return cr.indexOf(t)>=0||mr(e)||pr(e)||ce(e)}function yr(e){return 0|he[Object.prototype.toString.call(e)]}function xr(e,t){return ae.allocType(e.type===mt?Dt:e.type,t)}function wr(e,t){e.type===mt?(e.data=He(t),ae.freeType(t)):e.data=t}function Ar(e,t,r,n,a,i){var o;if(o=void 0!==dr[e]?dr[e]:rr[e]*lr[t],i&&(o*=6),a){for(var f=0,u=r;u>=1;)f+=o*u*u,u/=2;return f}return o*r*n}function _r(r,n,a,i,o,f,u){var s={"don't care":Ht,"dont care":Ht,nice:qt,fast:Nt},c={repeat:zt,clamp:Ft,mirror:Vt},l={nearest:Pt,linear:Lt},d=t({mipmap:Wt,"nearest mipmap nearest":Rt,"linear mipmap nearest":Mt,"nearest mipmap linear":Ut,"linear mipmap linear":Wt},l),m={none:0,browser:Jt},p={uint8:Ot,rgba4:it,rgb565:ft,"rgb5 a1":ot},h={alpha:Je,luminance:et,"luminance alpha":tt,rgb:Ze,rgba:Ke,rgba4:rt,"rgb5 a1":nt,rgb565:at},b={};n.ext_srgb&&(h.srgb=lt,h.srgba=dt),n.oes_texture_float&&(p.float32=p.float=Dt),n.oes_texture_half_float&&(p.float16=p["half float"]=mt),n.webgl_depth_texture&&(t(h,{depth:st,"depth stencil":ct}),t(p,{uint16:Et,uint32:Tt,"depth stencil":ut})),n.webgl_compressed_texture_s3tc&&t(b,{"rgb s3tc dxt1":pt,"rgba s3tc dxt1":ht,"rgba s3tc dxt3":bt,"rgba s3tc dxt5":vt}),n.webgl_compressed_texture_atc&&t(b,{"rgb atc":gt,"rgba atc explicit alpha":yt,"rgba atc interpolated alpha":xt}),n.webgl_compressed_texture_pvrtc&&t(b,{"rgb pvrtc 4bppv1":wt,"rgb pvrtc 2bppv1":At,"rgba pvrtc 4bppv1":_t,"rgba pvrtc 2bppv1":kt}),n.webgl_compressed_texture_etc1&&(b["rgb etc1"]=St);var v=Array.prototype.slice.call(r.getParameter(Qe));Object.keys(b).forEach((function(e){var t=b[e];v.indexOf(t)>=0&&(h[e]=t)}));var g=Object.keys(h);a.textureFormats=g;var y=[];Object.keys(h).forEach((function(e){var t=h[e];y[t]=e}));var x=[];Object.keys(p).forEach((function(e){var t=p[e];x[t]=e}));var w=[];Object.keys(l).forEach((function(e){var t=l[e];w[t]=e}));var A=[];Object.keys(d).forEach((function(e){var t=d[e];A[t]=e}));var _=[];Object.keys(c).forEach((function(e){var t=c[e];_[t]=e}));var k=g.reduce((function(e,t){var r=h[t];return r===et||r===Je||r===et||r===tt||r===st||r===ct||n.ext_srgb&&(r===lt||r===dt)?e[r]=r:r===nt||t.indexOf("rgba")>=0?e[r]=Ke:e[r]=Ze,e}),{});function S(){this.internalformat=Ke,this.format=Ke,this.type=Ot,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=Jt,this.width=0,this.height=0,this.channels=0}function O(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function E(e,t){if("object"==typeof t&&t){if("premultiplyAlpha"in t&&(F.type(t.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(F.type(t.flipY,"boolean","invalid texture flip"),e.flipY=t.flipY),"alignment"in t&&(F.oneOf(t.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=t.alignment),"colorSpace"in t&&(F.parameter(t.colorSpace,m,"invalid colorSpace"),e.colorSpace=m[t.colorSpace]),"type"in t){var r=t.type;F(n.oes_texture_float||!("float"===r||"float32"===r),"you must enable the OES_texture_float extension in order to use floating point textures."),F(n.oes_texture_half_float||!("half float"===r||"float16"===r),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),F(n.webgl_depth_texture||!("uint16"===r||"uint32"===r||"depth stencil"===r),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),F.parameter(r,p,"invalid texture type"),e.type=p[r]}var i=e.width,o=e.height,f=e.channels,u=!1;"shape"in t?(F(Array.isArray(t.shape)&&t.shape.length>=2,"shape must be an array"),i=t.shape[0],o=t.shape[1],3===t.shape.length&&(f=t.shape[2],F(f>0&&f<=4,"invalid number of channels"),u=!0),F(i>=0&&i<=a.maxTextureSize,"invalid width"),F(o>=0&&o<=a.maxTextureSize,"invalid height")):("radius"in t&&(i=o=t.radius,F(i>=0&&i<=a.maxTextureSize,"invalid radius")),"width"in t&&(i=t.width,F(i>=0&&i<=a.maxTextureSize,"invalid width")),"height"in t&&(o=t.height,F(o>=0&&o<=a.maxTextureSize,"invalid height")),"channels"in t&&(f=t.channels,F(f>0&&f<=4,"invalid number of channels"),u=!0)),e.width=0|i,e.height=0|o,e.channels=0|f;var s=!1;if("format"in t){var c=t.format;F(n.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),F.parameter(c,h,"invalid texture format");var l=e.internalformat=h[c];e.format=k[l],c in p&&("type"in t||(e.type=p[c])),c in b&&(e.compressed=!0),s=!0}!u&&s?e.channels=rr[e.format]:u&&!s?e.channels!==tr[e.format]&&(e.format=e.internalformat=tr[e.channels]):s&&u&&F(e.channels===rr[e.format],"number of channels inconsistent with specified format")}}function T(e){r.pixelStorei(Xt,e.flipY),r.pixelStorei($t,e.premultiplyAlpha),r.pixelStorei(Kt,e.colorSpace),r.pixelStorei(Yt,e.unpackAlignment)}function D(){S.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function j(t,r){var n=null;if(gr(r)?n=r:r&&(F.type(r,"object","invalid pixel data type"),E(t,r),"x"in r&&(t.xOffset=0|r.x),"y"in r&&(t.yOffset=0|r.y),gr(r.data)&&(n=r.data)),F(!t.compressed||n instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),r.copy){F(!n,"can not specify copy and data field for the same texture");var i=o.viewportWidth,f=o.viewportHeight;t.width=t.width||i-t.xOffset,t.height=t.height||f-t.yOffset,t.needsCopy=!0,F(t.xOffset>=0&&t.xOffset=0&&t.yOffset0&&t.width<=i&&t.height>0&&t.height<=f,"copy texture read out of bounds")}else if(n){if(e(n))t.channels=t.channels||4,t.data=n,"type"in r||t.type!==Ot||(t.type=yr(n));else if(mr(n))t.channels=t.channels||4,function(e,t){var r=t.length;switch(e.type){case Ot:case Et:case Tt:case Dt:var n=ae.allocType(e.type,r);n.set(t),e.data=n;break;case mt:e.data=He(t);break;default:F.raise("unsupported texture type, must specify a typed array")}}(t,n),t.alignment=1,t.needsFree=!0;else if(ce(n)){var u=n.data;Array.isArray(u)||t.type!==Ot||(t.type=yr(u));var s,c,l,d,m,p,h=n.shape,b=n.stride;3===h.length?(l=h[2],p=b[2]):(F(2===h.length,"invalid ndarray pixel data, must be 2 or 3D"),l=1,p=1),s=h[0],c=h[1],d=b[0],m=b[1],t.alignment=1,t.width=s,t.height=c,t.channels=l,t.format=t.internalformat=tr[l],t.needsFree=!0,function(e,t,r,n,a,i){for(var o=e.width,f=e.height,u=e.channels,s=xr(e,o*f*u),c=0,l=0;l=0,"oes_texture_float extension not enabled"):t.type===mt&&F(a.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function C(e,t,n){var a=e.element,o=e.data,f=e.internalformat,u=e.format,s=e.type,c=e.width,l=e.height;T(e),a?r.texImage2D(t,n,u,u,s,a):e.compressed?r.compressedTexImage2D(t,n,f,c,l,0,o):e.needsCopy?(i(),r.copyTexImage2D(t,n,u,e.xOffset,e.yOffset,c,l,0)):r.texImage2D(t,n,u,c,l,0,u,s,o||null)}function z(e,t,n,a,o){var f=e.element,u=e.data,s=e.internalformat,c=e.format,l=e.type,d=e.width,m=e.height;T(e),f?r.texSubImage2D(t,o,n,a,c,l,f):e.compressed?r.compressedTexSubImage2D(t,o,n,a,s,d,m,u):e.needsCopy?(i(),r.copyTexSubImage2D(t,o,n,a,e.xOffset,e.yOffset,d,m)):r.texSubImage2D(t,o,n,a,d,m,c,l,u)}var V=[];function B(){return V.pop()||new D}function I(e){e.needsFree&&ae.freeType(e.data),D.call(e),V.push(e)}function P(){S.call(this),this.genMipmaps=!1,this.mipmapHint=Ht,this.mipmask=0,this.images=Array(16)}function L(e,t,r){var n=e.images[0]=B();e.mipmask=1,n.width=e.width=t,n.height=e.height=r,n.channels=e.channels=4}function R(e,t){var r=null;if(gr(t))O(r=e.images[0]=B(),e),j(r,t),e.mipmask=1;else if(E(e,t),Array.isArray(t.mipmap))for(var n=t.mipmap,a=0;a>=a,r.height>>=a,j(r,n[a]),e.mipmask|=1<=0&&!("faces"in t)&&(e.genMipmaps=!0)}if("mag"in t){var n=t.mag;F.parameter(n,l),e.magFilter=l[n]}var i=e.wrapS,o=e.wrapT;if("wrap"in t){var f=t.wrap;"string"==typeof f?(F.parameter(f,c),i=o=c[f]):Array.isArray(f)&&(F.parameter(f[0],c),F.parameter(f[1],c),i=c[f[0]],o=c[f[1]])}else{if("wrapS"in t){var u=t.wrapS;F.parameter(u,c),i=c[u]}if("wrapT"in t){var m=t.wrapT;F.parameter(m,c),o=c[m]}}if(e.wrapS=i,e.wrapT=o,"anisotropic"in t){var p=t.anisotropic;F("number"==typeof p&&p>=1&&p<=a.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var h=!1;switch(typeof t.mipmap){case"string":F.parameter(t.mipmap,s,"invalid mipmap hint"),e.mipmapHint=s[t.mipmap],e.genMipmaps=!0,h=!0;break;case"boolean":h=e.genMipmaps=t.mipmap;break;case"object":F(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,h=!0;break;default:F.raise("invalid mipmap type")}h&&!("min"in t)&&(e.minFilter=Rt)}}function q(e,t){r.texParameteri(t,It,e.minFilter),r.texParameteri(t,Bt,e.magFilter),r.texParameteri(t,jt,e.wrapS),r.texParameteri(t,Ct,e.wrapT),n.ext_texture_filter_anisotropic&&r.texParameteri(t,Qt,e.anisotropic),e.genMipmaps&&(r.hint(Gt,e.mipmapHint),r.generateMipmap(t))}var Q=0,Y={},X=a.maxTextureUnits,$=Array(X).map((function(){return null}));function K(e){S.call(this),this.mipmask=0,this.internalformat=Ke,this.id=Q++,this.refCount=1,this.target=e,this.texture=r.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new H,u.profile&&(this.stats={size:0})}function J(e){r.activeTexture(Zt),r.bindTexture(e.target,e.texture)}function Z(){var e=$[0];e?r.bindTexture(e.target,e.texture):r.bindTexture(Ye,null)}function ee(e){var t=e.texture;F(t,"must not double destroy texture");var n=e.unit,a=e.target;n>=0&&(r.activeTexture(Zt+n),r.bindTexture(a,null),$[n]=null),r.deleteTexture(t),e.texture=null,e.params=null,e.pixels=null,e.refCount=0,delete Y[e.id],f.textureCount--}return t(K.prototype,{bind:function(){var e=this;e.bindCount+=1;var t=e.unit;if(t<0){for(var n=0;n0)continue;a.unit=-1}$[n]=e,t=n;break}t>=X&&F.raise("insufficient number of texture units"),u.profile&&f.maxTextureUnits>u)-o,s.height=s.height||(n.height>>u)-f,F(n.type===s.type&&n.format===s.format&&n.internalformat===s.internalformat,"incompatible format for texture.subimage"),F(o>=0&&f>=0&&o+s.width<=n.width&&f+s.height<=n.height,"texture.subimage write out of bounds"),F(n.mipmask&1<>f;++f){var s=a>>f,c=o>>f;if(!s||!c)break;r.texImage2D(Ye,f,n.format,s,c,0,n.format,n.type,null)}return Z(),u.profile&&(n.stats.size=Ar(n.internalformat,n.type,a,o,!1,!1)),i},i._reglType="texture2d",i._texture=n,u.profile&&(i.stats=n.stats),i.destroy=function(){n.decRef()},i},createCube:function(e,t,n,i,o,s){var c=new K(Xe);Y[c.id]=c,f.cubeCount++;var l=new Array(6);function d(e,t,r,n,i,o){var f,s=c.texInfo;for(H.call(s),f=0;f<6;++f)l[f]=W();if("number"!=typeof e&&e)if("object"==typeof e)if(t)R(l[0],e),R(l[1],t),R(l[2],r),R(l[3],n),R(l[4],i),R(l[5],o);else if(N(s,e),E(c,e),"faces"in e){var m=e.faces;for(F(Array.isArray(m)&&6===m.length,"cube faces must be a length 6 array"),f=0;f<6;++f)F("object"==typeof m[f]&&!!m[f],"invalid input for cube map face"),O(l[f],c),R(l[f],m[f])}else for(f=0;f<6;++f)R(l[f],e);else F.raise("invalid arguments to cube map");else{var p=0|e||1;for(f=0;f<6;++f)L(l[f],p,p)}for(O(c,l[0]),F.optional((function(){a.npotTextureCube||F(qe(c.width)&&qe(c.height),"your browser does not support non power or two texture dimensions")})),s.genMipmaps?c.mipmask=(l[0].width<<1)-1:c.mipmask=l[0].mipmask,F.textureCube(c,s,l,a),c.internalformat=l[0].internalformat,d.width=l[0].width,d.height=l[0].height,J(c),f=0;f<6;++f)M(l[f],$e+f);for(q(s,Xe),Z(),u.profile&&(c.stats.size=Ar(c.internalformat,c.type,d.width,d.height,s.genMipmaps,!0)),d.format=y[c.internalformat],d.type=x[c.type],d.mag=w[s.magFilter],d.min=A[s.minFilter],d.wrapS=_[s.wrapS],d.wrapT=_[s.wrapT],f=0;f<6;++f)G(l[f]);return d}return d(e,t,n,i,o,s),d.subimage=function(e,t,r,n,a){F(!!t,"must specify image data"),F("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var i=0|r,o=0|n,f=0|a,u=B();return O(u,c),u.width=0,u.height=0,j(u,t),u.width=u.width||(c.width>>f)-i,u.height=u.height||(c.height>>f)-o,F(c.type===u.type&&c.format===u.format&&c.internalformat===u.internalformat,"incompatible format for texture.subimage"),F(i>=0&&o>=0&&i+u.width<=c.width&&o+u.height<=c.height,"texture.subimage write out of bounds"),F(c.mipmask&1<>a;++a)r.texImage2D($e+n,a,c.format,t>>a,t>>a,0,c.format,c.type,null);return Z(),u.profile&&(c.stats.size=Ar(c.internalformat,c.type,d.width,d.height,!1,!0)),d}},d._reglType="textureCube",d._texture=c,u.profile&&(d.stats=c.stats),d.destroy=function(){c.decRef()},d},clear:function(){for(var e=0;e>t,e.height>>t,0,e.internalformat,e.type,null);else for(var n=0;n<6;++n)r.texImage2D($e+n,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);q(e.texInfo,e.target)}))},refresh:function(){for(var e=0;e=2,"invalid renderbuffer shape"),f=0|m[0],u=0|m[1]}else"radius"in d&&(f=u=0|d.radius),"width"in d&&(f=0|d.width),"height"in d&&(u=0|d.height);"format"in d&&(F.parameter(d.format,i,"invalid renderbuffer format"),s=i[d.format])}else"number"==typeof t?(f=0|t,u="number"==typeof n?0|n:f):t?F.raise("invalid arguments to renderbuffer constructor"):f=u=1;if(F(f>0&&u>0&&f<=r.maxRenderbufferSize&&u<=r.maxRenderbufferSize,"invalid renderbuffer size"),f!==c.width||u!==c.height||s!==c.format)return l.width=c.width=f,l.height=c.height=u,c.format=s,e.bindRenderbuffer(kr,c.renderbuffer),e.renderbufferStorage(kr,s,f,u),F(0===e.getError(),"invalid render buffer format"),a.profile&&(c.stats.size=Er(c.format,c.width,c.height)),l.format=o[c.format],l}return u[c.id]=c,n.renderbufferCount++,l(t,f),l.resize=function(t,n){var i=0|t,o=0|n||i;return i===c.width&&o===c.height||(F(i>0&&o>0&&i<=r.maxRenderbufferSize&&o<=r.maxRenderbufferSize,"invalid renderbuffer size"),l.width=c.width=i,l.height=c.height=o,e.bindRenderbuffer(kr,c.renderbuffer),e.renderbufferStorage(kr,c.format,i,o),F(0===e.getError(),"invalid render buffer format"),a.profile&&(c.stats.size=Er(c.format,c.width,c.height))),l},l._reglType="renderbuffer",l._renderbuffer=c,a.profile&&(l.stats=c.stats),l.destroy=function(){c.decRef()},l},clear:function(){le(u).forEach(c)},restore:function(){le(u).forEach((function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(kr,t.renderbuffer),e.renderbufferStorage(kr,t.format,t.width,t.height)})),e.bindRenderbuffer(kr,null)}}},Dr=36160,jr=36161,Cr=3553,zr=34069,Fr=36064,Vr=36096,Br=36128,Ir=33306,Pr=36053,Lr=6402,Rr=[6407,6408],Mr=[];Mr[6408]=4,Mr[6407]=3;var Ur=[];Ur[5121]=1,Ur[5126]=4,Ur[36193]=2;var Wr=33189,Gr=36168,Hr=34041,Nr=[32854,32855,36194,35907,34842,34843,34836],qr={};qr[Pr]="complete",qr[36054]="incomplete attachment",qr[36057]="incomplete dimensions",qr[36055]="incomplete, missing attachment",qr[36061]="unsupported";var Qr=5126,Yr=34962,Xr=34963,$r=["attributes","elements","offset","count","primitive","instances"];function Kr(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=Qr,this.offset=0,this.stride=0,this.divisor=0}var Jr=35632,Zr=35633,en=35718,tn=35721,rn=6408,nn=5121,an=3333,on=5126;function fn(t,r,n,a,i,o,f){function u(u){var s;null===r.next?(F(i.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),s=nn):(F(null!==r.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),s=r.next.colorAttachments[0].texture._texture.type,F.optional((function(){o.oes_texture_float?(F(s===nn||s===on,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),s===on&&F(f.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):F(s===nn,"Reading from a framebuffer is only allowed for the type 'uint8'")})));var c=0,l=0,d=a.framebufferWidth,m=a.framebufferHeight,p=null;e(u)?p=u:u&&(F.type(u,"object","invalid arguments to regl.read()"),c=0|u.x,l=0|u.y,F(c>=0&&c=0&&l0&&d+c<=a.framebufferWidth,"invalid width for read pixels"),F(m>0&&m+l<=a.framebufferHeight,"invalid height for read pixels"),n();var h=d*m*4;return p||(s===nn?p=new Uint8Array(h):s===on&&(p=p||new Float32Array(h))),F.isTypedArray(p,"data buffer for regl.read() must be a typedarray"),F(p.byteLength>=h,"data buffer for regl.read() too small"),t.pixelStorei(an,4),t.readPixels(c,l,d,m,rn,s,p),p}return function(e){return e&&"framebuffer"in e?function(e){var t;return r.setFBO({framebuffer:e.framebuffer},(function(){t=u(e)})),t}(e):u(e)}}function un(e){return Array.prototype.slice.call(e)}function sn(e){return un(e).join("")}var cn="xyzw".split(""),ln=5121,dn=1,mn=2,pn=0,hn=1,bn=2,vn=3,gn=4,yn=5,xn=6,wn="dither",An="blend.enable",_n="blend.color",kn="blend.equation",Sn="blend.func",On="depth.enable",En="depth.func",Tn="depth.range",Dn="depth.mask",jn="colorMask",Cn="cull.enable",zn="cull.face",Fn="frontFace",Vn="lineWidth",Bn="polygonOffset.enable",In="polygonOffset.offset",Pn="sample.alpha",Ln="sample.enable",Rn="sample.coverage",Mn="stencil.enable",Un="stencil.mask",Wn="stencil.func",Gn="stencil.opFront",Hn="stencil.opBack",Nn="scissor.enable",qn="scissor.box",Qn="viewport",Yn="profile",Xn="framebuffer",$n="vert",Kn="frag",Jn="elements",Zn="primitive",ea="count",ta="offset",ra="instances",na="vao",aa="Width",ia="Height",oa=Xn+aa,fa=Xn+ia,ua=Qn+aa,sa=Qn+ia,ca="drawingBuffer",la=ca+aa,da=ca+ia,ma=[Sn,kn,Wn,Gn,Hn,Rn,Qn,qn,In],pa=34962,ha=34963,ba=3553,va=34067,ga=2884,ya=3042,xa=3024,wa=2960,Aa=2929,_a=3089,ka=32823,Sa=32926,Oa=32928,Ea=5126,Ta=35664,Da=35665,ja=35666,Ca=5124,za=35667,Fa=35668,Va=35669,Ba=35670,Ia=35671,Pa=35672,La=35673,Ra=35674,Ma=35675,Ua=35676,Wa=35678,Ga=35680,Ha=4,Na=1028,qa=1029,Qa=2304,Ya=2305,Xa=32775,$a=32776,Ka=519,Ja=7680,Za=0,ei=1,ti=32774,ri=513,ni=36160,ai=36064,ii={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},oi=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],fi={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},ui={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},si={frag:35632,vert:35633},ci={cw:Qa,ccw:Ya};function li(t){return Array.isArray(t)||e(t)||ce(t)}function di(e){return e.sort((function(e,t){return e===Qn?-1:t===Qn?1:e=1,n>=2,t)}if(r===gn){var a=e.data;return new mi(a.thisDep,a.contextDep,a.propDep,t)}if(r===yn)return new mi(!1,!1,!1,t);if(r===xn){for(var i=!1,o=!1,f=!1,u=0;u=1&&(o=!0),c>=2&&(f=!0)}else s.type===gn&&(i=i||s.data.thisDep,o=o||s.data.contextDep,f=f||s.data.propDep)}return new mi(i,o,f,t)}return new mi(r===vn,r===bn,r===hn,t)}var vi=new mi(!1,!1,!1,(function(){}));function gi(e,r,n,a,i,o,f,u,s,c,l,d,m,p,h){var b=c.Record,v={add:32774,subtract:32778,"reverse subtract":32779};n.ext_blend_minmax&&(v.min=Xa,v.max=$a);var g=n.angle_instanced_arrays,y=n.webgl_draw_buffers,x=n.oes_vertex_array_object,w={dirty:!0,profile:h.profile},A={},_=[],k={},S={};function O(e){return e.replace(".","_")}function E(e,t,r){var n=O(e);_.push(e),A[n]=w[n]=!!r,k[n]=t}function T(e,t,r){var n=O(e);_.push(e),Array.isArray(r)?(w[n]=r.slice(),A[n]=r.slice()):w[n]=A[n]=r,S[n]=t}E(wn,xa),E(An,ya),T(_n,"blendColor",[0,0,0,0]),T(kn,"blendEquationSeparate",[ti,ti]),T(Sn,"blendFuncSeparate",[ei,Za,ei,Za]),E(On,Aa,!0),T(En,"depthFunc",ri),T(Tn,"depthRange",[0,1]),T(Dn,"depthMask",!0),T(jn,jn,[!0,!0,!0,!0]),E(Cn,ga),T(zn,"cullFace",qa),T(Fn,Fn,Ya),T(Vn,Vn,1),E(Bn,ka),T(In,"polygonOffset",[0,0]),E(Pn,Sa),E(Ln,Oa),T(Rn,"sampleCoverage",[1,!1]),E(Mn,wa),T(Un,"stencilMask",-1),T(Wn,"stencilFunc",[Ka,0,-1]),T(Gn,"stencilOpSeparate",[Na,Ja,Ja,Ja]),T(Hn,"stencilOpSeparate",[qa,Ja,Ja,Ja]),E(Nn,_a),T(qn,"scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),T(Qn,Qn,[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var D={gl:e,context:m,strings:r,next:A,current:w,draw:d,elements:o,buffer:i,shader:l,attributes:c.state,vao:c,uniforms:s,framebuffer:u,extensions:n,timer:p,isBufferArgs:li},j={primTypes:Te,compareFuncs:fi,blendFuncs:ii,blendEquations:v,stencilOps:ui,glTypes:be,orientationType:ci};F.optional((function(){D.isArrayLike=Ne})),y&&(j.backBuffer=[qa],j.drawBuffer=Y(a.maxDrawbuffers,(function(e){return 0===e?[0]:Y(e,(function(e){return ai+e}))})));var C=0;function z(){var e=function(){var e=0,r=[],n=[];function a(){var r=[],n=[];return t((function(){r.push.apply(r,un(arguments))}),{def:function(){var t="v"+e++;return n.push(t),arguments.length>0&&(r.push(t,"="),r.push.apply(r,un(arguments)),r.push(";")),t},toString:function(){return sn([n.length>0?"var "+n.join(",")+";":"",sn(r)])}})}function i(){var e=a(),r=a(),n=e.toString,i=r.toString;function o(t,n){r(t,n,"=",e.def(t,n),";")}return t((function(){e.apply(e,un(arguments))}),{def:e.def,entry:e,exit:r,save:o,set:function(t,r,n){o(t,r),e(t,r,"=",n,";")},toString:function(){return n()+i()}})}var o=a(),f={};return{global:o,link:function(t){for(var a=0;a=0,'unknown parameter "'+t+'"',d.commandStr)}))}t(m),t(p)}));var h=function(e,t){var r=e.static;if("string"==typeof r[Kn]&&"string"==typeof r[$n]){if(Object.keys(t.dynamic).length>0)return null;var n=t.static,a=Object.keys(n);if(a.length>0&&"number"==typeof n[a[0]]){for(var i=[],o=0;o=0,"invalid "+e,r.commandStr)):u=!1,"height"in i?(f=0|i.height,F.command(f>=0,"invalid "+e,r.commandStr)):u=!1,new mi(!u&&t&&t.thisDep,!u&&t&&t.contextDep,!u&&t&&t.propDep,(function(e,t){var r=e.shared.context,n=o;"width"in i||(n=t.def(r,".",oa,"-",s));var a=f;return"height"in i||(a=t.def(r,".",fa,"-",c)),[s,c,n,a]}))}if(e in a){var l=a[e],d=bi(l,(function(t,r){var n=t.invoke(r,l);F.optional((function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)}));var a=t.shared.context,i=r.def(n,".x|0"),o=r.def(n,".y|0"),f=r.def('"width" in ',n,"?",n,".width|0:","(",a,".",oa,"-",i,")"),u=r.def('"height" in ',n,"?",n,".height|0:","(",a,".",fa,"-",o,")");return F.optional((function(){t.assert(r,f+">=0&&"+u+">=0","invalid "+e)})),[i,o,f,u]}));return t&&(d.thisDep=d.thisDep||t.thisDep,d.contextDep=d.contextDep||t.contextDep,d.propDep=d.propDep||t.propDep),d}return t?new mi(t.thisDep,t.contextDep,t.propDep,(function(e,t){var r=e.shared.context;return[0,0,t.def(r,".",oa),t.def(r,".",fa)]})):null}var o=i(Qn);if(o){var f=o;o=new mi(o.thisDep,o.contextDep,o.propDep,(function(e,t){var r=f.append(e,t),n=e.shared.context;return t.set(n,"."+ua,r[2]),t.set(n,"."+sa,r[3]),r}))}return{viewport:o,scissor_box:i(qn)}}(e,y,d),w=function(e,t){var r=e.static,n=e.dynamic,a={},i=!1,f=function(){if(na in r){var e=r[na];return null!==e&&null===c.getVAO(e)&&(e=c.createVAO(e)),i=!0,a.vao=e,hi((function(t){var r=c.getVAO(e);return r?t.link(r):"null"}))}if(na in n){i=!0;var t=n[na];return bi(t,(function(e,r){var n=e.invoke(r,t);return r.def(e.shared.vao+".getVAO("+n+")")}))}return null}(),u=!1,s=function(){if(Jn in r){var e=r[Jn];if(a.elements=e,li(e)){var s=a.elements=o.create(e,!0);e=o.getElements(s),u=!0}else e&&(e=o.getElements(e),u=!0,F.command(e,"invalid elements",t.commandStr));var c=hi((function(t,r){if(e){var n=t.link(e);return t.ELEMENTS=n,n}return t.ELEMENTS=null,null}));return c.value=e,c}if(Jn in n){u=!0;var l=n[Jn];return bi(l,(function(e,t){var r=e.shared,n=r.isBufferArgs,a=r.elements,i=e.invoke(t,l),o=t.def("null"),f=t.def(n,"(",i,")"),u=e.cond(f).then(o,"=",a,".createStream(",i,");").else(o,"=",a,".getElements(",i,");");return F.optional((function(){e.assert(u.else,"!"+i+"||"+o,"invalid elements")})),t.entry(u),t.exit(e.cond(f).then(a,".destroyStream(",o,");")),e.ELEMENTS=o,o}))}return i?new mi(f.thisDep,f.contextDep,f.propDep,(function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.elements+".getElements("+e.shared.vao+".currentVAO.elements):null")})):null}();function l(e,o){if(e in r){var s=0|r[e];return o?a.offset=s:a.instances=s,F.command(!o||s>=0,"invalid "+e,t.commandStr),hi((function(e,t){return o&&(e.OFFSET=s),s}))}if(e in n){var c=n[e];return bi(c,(function(t,r){var n=t.invoke(r,c);return o&&(t.OFFSET=n,F.optional((function(){t.assert(r,n+">=0","invalid "+e)}))),n}))}if(o){if(u)return hi((function(e,t){return e.OFFSET=0,0}));if(i)return new mi(f.thisDep,f.contextDep,f.propDep,(function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.offset:0")}))}else if(i)return new mi(f.thisDep,f.contextDep,f.propDep,(function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.instances:-1")}));return null}var d=l(ta,!0),m=function(){if(Zn in r){var e=r[Zn];return a.primitive=e,F.commandParameter(e,Te,"invalid primitve",t.commandStr),hi((function(t,r){return Te[e]}))}if(Zn in n){var o=n[Zn];return bi(o,(function(e,t){var r=e.constants.primTypes,n=e.invoke(t,o);return F.optional((function(){e.assert(t,n+" in "+r,"invalid primitive, must be one of "+Object.keys(Te))})),t.def(r,"[",n,"]")}))}return u?pi(s)?s.value?hi((function(e,t){return t.def(e.ELEMENTS,".primType")})):hi((function(){return Ha})):new mi(s.thisDep,s.contextDep,s.propDep,(function(e,t){var r=e.ELEMENTS;return t.def(r,"?",r,".primType:",Ha)})):i?new mi(f.thisDep,f.contextDep,f.propDep,(function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.primitive:"+Ha)})):null}(),p=function(){if(ea in r){var e=0|r[ea];return a.count=e,F.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),hi((function(){return e}))}if(ea in n){var o=n[ea];return bi(o,(function(e,t){var r=e.invoke(t,o);return F.optional((function(){e.assert(t,"typeof "+r+'==="number"&&'+r+">=0&&"+r+"===("+r+"|0)","invalid vertex count")})),r}))}if(u){if(pi(s)){if(s)return d?new mi(d.thisDep,d.contextDep,d.propDep,(function(e,t){var r=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return F.optional((function(){e.assert(t,r+">=0","invalid vertex offset/element buffer too small")})),r})):hi((function(e,t){return t.def(e.ELEMENTS,".vertCount")}));var c=hi((function(){return-1}));return F.optional((function(){c.MISSING=!0})),c}var l=new mi(s.thisDep||d.thisDep,s.contextDep||d.contextDep,s.propDep||d.propDep,(function(e,t){var r=e.ELEMENTS;return e.OFFSET?t.def(r,"?",r,".vertCount-",e.OFFSET,":-1"):t.def(r,"?",r,".vertCount:-1")}));return F.optional((function(){l.DYNAMIC=!0})),l}if(i){var m=new mi(f.thisDep,f.contextDep,f.propDep,(function(e,t){return t.def(e.shared.vao,".currentVAO?",e.shared.vao,".currentVAO.count:-1")}));return m}return null}(),h=l(ra,!1);return{elements:s,primitive:m,count:p,instances:h,offset:d,vao:f,vaoActive:i,elementsActive:u,static:a}}(e,d),A=function(e,t){var r=e.static,n=e.dynamic,i={};return _.forEach((function(e){var o=O(e);function f(t,a){if(e in r){var f=t(r[e]);i[o]=hi((function(){return f}))}else if(e in n){var u=n[e];i[o]=bi(u,(function(e,t){return a(e,t,e.invoke(t,u))}))}}switch(e){case Cn:case An:case wn:case Mn:case On:case Nn:case Bn:case Pn:case Ln:case Dn:return f((function(r){return F.commandType(r,"boolean",e,t.commandStr),r}),(function(t,r,n){return F.optional((function(){t.assert(r,"typeof "+n+'==="boolean"',"invalid flag "+e,t.commandStr)})),n}));case En:return f((function(r){return F.commandParameter(r,fi,"invalid "+e,t.commandStr),fi[r]}),(function(t,r,n){var a=t.constants.compareFuncs;return F.optional((function(){t.assert(r,n+" in "+a,"invalid "+e+", must be one of "+Object.keys(fi))})),r.def(a,"[",n,"]")}));case Tn:return f((function(e){return F.command(Ne(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]&&e[0]<=e[1],"depth range is 2d array",t.commandStr),e}),(function(e,t,r){return F.optional((function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===2&&typeof "+r+'[0]==="number"&&typeof '+r+'[1]==="number"&&'+r+"[0]<="+r+"[1]","depth range must be a 2d array")})),[t.def("+",r,"[0]"),t.def("+",r,"[1]")]}));case Sn:return f((function(e){F.commandType(e,"object","blend.func",t.commandStr);var r="srcRGB"in e?e.srcRGB:e.src,n="srcAlpha"in e?e.srcAlpha:e.src,a="dstRGB"in e?e.dstRGB:e.dst,i="dstAlpha"in e?e.dstAlpha:e.dst;return F.commandParameter(r,ii,o+".srcRGB",t.commandStr),F.commandParameter(n,ii,o+".srcAlpha",t.commandStr),F.commandParameter(a,ii,o+".dstRGB",t.commandStr),F.commandParameter(i,ii,o+".dstAlpha",t.commandStr),F.command(-1===oi.indexOf(r+", "+a),"unallowed blending combination (srcRGB, dstRGB) = ("+r+", "+a+")",t.commandStr),[ii[r],ii[a],ii[n],ii[i]]}),(function(t,r,n){var a=t.constants.blendFuncs;function i(i,o){var f=r.def('"',i,o,'" in ',n,"?",n,".",i,o,":",n,".",i);return F.optional((function(){t.assert(r,f+" in "+a,"invalid "+e+"."+i+o+", must be one of "+Object.keys(ii))})),f}F.optional((function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid blend func, must be an object")}));var o=i("src","RGB"),f=i("dst","RGB");F.optional((function(){var e=t.constants.invalidBlendCombinations;t.assert(r,e+".indexOf("+o+'+", "+'+f+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")}));var u=r.def(a,"[",o,"]"),s=r.def(a,"[",i("src","Alpha"),"]");return[u,r.def(a,"[",f,"]"),s,r.def(a,"[",i("dst","Alpha"),"]")]}));case kn:return f((function(r){return"string"==typeof r?(F.commandParameter(r,v,"invalid "+e,t.commandStr),[v[r],v[r]]):"object"==typeof r?(F.commandParameter(r.rgb,v,e+".rgb",t.commandStr),F.commandParameter(r.alpha,v,e+".alpha",t.commandStr),[v[r.rgb],v[r.alpha]]):void F.commandRaise("invalid blend.equation",t.commandStr)}),(function(t,r,n){var a=t.constants.blendEquations,i=r.def(),o=r.def(),f=t.cond("typeof ",n,'==="string"');return F.optional((function(){function r(e,r,n){t.assert(e,n+" in "+a,"invalid "+r+", must be one of "+Object.keys(v))}r(f.then,e,n),t.assert(f.else,n+"&&typeof "+n+'==="object"',"invalid "+e),r(f.else,e+".rgb",n+".rgb"),r(f.else,e+".alpha",n+".alpha")})),f.then(i,"=",o,"=",a,"[",n,"];"),f.else(i,"=",a,"[",n,".rgb];",o,"=",a,"[",n,".alpha];"),r(f),[i,o]}));case _n:return f((function(e){return F.command(Ne(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),Y(4,(function(t){return+e[t]}))}),(function(e,t,r){return F.optional((function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===4","blend.color must be a 4d array")})),Y(4,(function(e){return t.def("+",r,"[",e,"]")}))}));case Un:return f((function(e){return F.commandType(e,"number",o,t.commandStr),0|e}),(function(e,t,r){return F.optional((function(){e.assert(t,"typeof "+r+'==="number"',"invalid stencil.mask")})),t.def(r,"|0")}));case Wn:return f((function(r){F.commandType(r,"object",o,t.commandStr);var n=r.cmp||"keep",a=r.ref||0,i="mask"in r?r.mask:-1;return F.commandParameter(n,fi,e+".cmp",t.commandStr),F.commandType(a,"number",e+".ref",t.commandStr),F.commandType(i,"number",e+".mask",t.commandStr),[fi[n],a,i]}),(function(e,t,r){var n=e.constants.compareFuncs;return F.optional((function(){function a(){e.assert(t,Array.prototype.join.call(arguments,""),"invalid stencil.func")}a(r+"&&typeof ",r,'==="object"'),a('!("cmp" in ',r,")||(",r,".cmp in ",n,")")})),[t.def('"cmp" in ',r,"?",n,"[",r,".cmp]",":",Ja),t.def(r,".ref|0"),t.def('"mask" in ',r,"?",r,".mask|0:-1")]}));case Gn:case Hn:return f((function(r){F.commandType(r,"object",o,t.commandStr);var n=r.fail||"keep",a=r.zfail||"keep",i=r.zpass||"keep";return F.commandParameter(n,ui,e+".fail",t.commandStr),F.commandParameter(a,ui,e+".zfail",t.commandStr),F.commandParameter(i,ui,e+".zpass",t.commandStr),[e===Hn?qa:Na,ui[n],ui[a],ui[i]]}),(function(t,r,n){var a=t.constants.stencilOps;function i(i){return F.optional((function(){t.assert(r,'!("'+i+'" in '+n+")||("+n+"."+i+" in "+a+")","invalid "+e+"."+i+", must be one of "+Object.keys(ui))})),r.def('"',i,'" in ',n,"?",a,"[",n,".",i,"]:",Ja)}return F.optional((function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)})),[e===Hn?qa:Na,i("fail"),i("zfail"),i("zpass")]}));case In:return f((function(e){F.commandType(e,"object",o,t.commandStr);var r=0|e.factor,n=0|e.units;return F.commandType(r,"number",o+".factor",t.commandStr),F.commandType(n,"number",o+".units",t.commandStr),[r,n]}),(function(t,r,n){return F.optional((function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)})),[r.def(n,".factor|0"),r.def(n,".units|0")]}));case zn:return f((function(e){var r=0;return"front"===e?r=Na:"back"===e&&(r=qa),F.command(!!r,o,t.commandStr),r}),(function(e,t,r){return F.optional((function(){e.assert(t,r+'==="front"||'+r+'==="back"',"invalid cull.face")})),t.def(r,'==="front"?',Na,":",qa)}));case Vn:return f((function(e){return F.command("number"==typeof e&&e>=a.lineWidthDims[0]&&e<=a.lineWidthDims[1],"invalid line width, must be a positive number between "+a.lineWidthDims[0]+" and "+a.lineWidthDims[1],t.commandStr),e}),(function(e,t,r){return F.optional((function(){e.assert(t,"typeof "+r+'==="number"&&'+r+">="+a.lineWidthDims[0]+"&&"+r+"<="+a.lineWidthDims[1],"invalid line width")})),r}));case Fn:return f((function(e){return F.commandParameter(e,ci,o,t.commandStr),ci[e]}),(function(e,t,r){return F.optional((function(){e.assert(t,r+'==="cw"||'+r+'==="ccw"',"invalid frontFace, must be one of cw,ccw")})),t.def(r+'==="cw"?'+Qa+":"+Ya)}));case jn:return f((function(e){return F.command(Ne(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map((function(e){return!!e}))}),(function(e,t,r){return F.optional((function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===4","invalid color.mask")})),Y(4,(function(e){return"!!"+r+"["+e+"]"}))}));case Rn:return f((function(e){F.command("object"==typeof e&&e,o,t.commandStr);var r="value"in e?e.value:1,n=!!e.invert;return F.command("number"==typeof r&&r>=0&&r<=1,"sample.coverage.value must be a number between 0 and 1",t.commandStr),[r,n]}),(function(e,t,r){return F.optional((function(){e.assert(t,r+"&&typeof "+r+'==="object"',"invalid sample.coverage")})),[t.def('"value" in ',r,"?+",r,".value:1"),t.def("!!",r,".invert")]}))}})),i}(e,d),k=function(e,t,n){var a=e.static,i=e.dynamic;function o(e){if(e in a){var t=r.id(a[e]);F.optional((function(){l.shader(si[e],t,F.guessCommand())}));var n=hi((function(){return t}));return n.id=t,n}if(e in i){var o=i[e];return bi(o,(function(t,r){var n=t.invoke(r,o),a=r.def(t.shared.strings,".id(",n,")");return F.optional((function(){r(t.shared.shader,".shader(",si[e],",",a,",",t.command,");")})),a}))}return null}var f,u=o(Kn),s=o($n),c=null;return pi(u)&&pi(s)?(c=l.program(s.id,u.id,null,n),f=hi((function(e,t){return e.link(c)}))):f=new mi(u&&u.thisDep||s&&s.thisDep,u&&u.contextDep||s&&s.contextDep,u&&u.propDep||s&&s.propDep,(function(e,t){var r,n=e.shared.shader;r=u?u.append(e,t):t.def(n,".",Kn);var a=n+".program("+(s?s.append(e,t):t.def(n,".",$n))+","+r;return F.optional((function(){a+=","+e.command})),t.def(a+")")})),{frag:u,vert:s,progVar:f,program:c}}(e,0,h);function S(e){var t=x[e];t&&(A[e]=t)}S(Qn),S(O(qn));var E=Object.keys(A).length>0,T={framebuffer:y,draw:w,shader:k,state:A,dirty:E,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(T.profile=function(e){var t,r=e.static,n=e.dynamic;if(Yn in r){var a=!!r[Yn];(t=hi((function(e,t){return a}))).enable=a}else if(Yn in n){var i=n[Yn];t=bi(i,(function(e,t){return e.invoke(t,i)}))}return t}(e),T.uniforms=function(e,t){var r=e.static,n=e.dynamic,a={};return Object.keys(r).forEach((function(e){var n,i=r[e];if("number"==typeof i||"boolean"==typeof i)n=hi((function(){return i}));else if("function"==typeof i){var o=i._reglType;"texture2d"===o||"textureCube"===o?n=hi((function(e){return e.link(i)})):"framebuffer"===o||"framebufferCube"===o?(F.command(i.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),n=hi((function(e){return e.link(i.color[0])}))):F.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else Ne(i)?n=hi((function(t){return t.global.def("[",Y(i.length,(function(r){return F.command("number"==typeof i[r]||"boolean"==typeof i[r],"invalid uniform "+e,t.commandStr),i[r]})),"]")})):F.commandRaise('invalid or missing data for uniform "'+e+'"',t.commandStr);n.value=i,a[e]=n})),Object.keys(n).forEach((function(e){var t=n[e];a[e]=bi(t,(function(e,r){return e.invoke(r,t)}))})),a}(f,d),T.drawVAO=T.scopeVAO=w.vao,!T.drawVAO&&k.program&&!h&&n.angle_instanced_arrays&&w.static.elements){var D=!0,j=k.program.attributes.map((function(e){var r=t.static[e];return D=D&&!!r,r}));if(D&&j.length>0){var C=c.getVAO(c.createVAO({attributes:j,elements:w.static.elements}));T.drawVAO=new mi(null,null,null,(function(e,t){return e.link(C)})),T.useVAO=!0}}return h?T.useVAO=!0:T.attributes=function(e,t){var n=e.static,a=e.dynamic,o={};return Object.keys(n).forEach((function(e){var a=n[e],f=r.id(e),u=new b;if(li(a))u.state=dn,u.buffer=i.getBuffer(i.create(a,pa,!1,!0)),u.type=0;else{var s=i.getBuffer(a);if(s)u.state=dn,u.buffer=s,u.type=0;else if(F.command("object"==typeof a&&a,"invalid data for attribute "+e,t.commandStr),"constant"in a){var c=a.constant;u.buffer="null",u.state=mn,"number"==typeof c?u.x=c:(F.command(Ne(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,t.commandStr),cn.forEach((function(e,t){t=0,'invalid offset for attribute "'+e+'"',t.commandStr);var d=0|a.stride;F.command(d>=0&&d<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',t.commandStr);var m=0|a.size;F.command(!("size"in a)||m>0&&m<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',t.commandStr);var p=!!a.normalized,h=0;"type"in a&&(F.commandParameter(a.type,be,"invalid type for attribute "+e,t.commandStr),h=be[a.type]);var v=0|a.divisor;F.optional((function(){"divisor"in a&&(F.command(0===v||g,'cannot specify divisor for attribute "'+e+'", instancing not supported',t.commandStr),F.command(v>=0,'invalid divisor for attribute "'+e+'"',t.commandStr));var r=t.commandStr,n=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(a).forEach((function(t){F.command(n.indexOf(t)>=0,'unknown parameter "'+t+'" for attribute pointer "'+e+'" (valid parameters are '+n+")",r)}))})),u.buffer=s,u.state=dn,u.size=m,u.normalized=p,u.type=h||s.dtype,u.offset=l,u.stride=d,u.divisor=v}}o[e]=hi((function(e,t){var r=e.attribCache;if(f in r)return r[f];var n={isStream:!1};return Object.keys(u).forEach((function(e){n[e]=u[e]})),u.buffer&&(n.buffer=e.link(u.buffer),n.type=n.type||n.buffer+".dtype"),r[f]=n,n}))})),Object.keys(a).forEach((function(e){var t=a[e];o[e]=bi(t,(function(r,n){var a=r.invoke(n,t),i=r.shared,o=r.constants,f=i.isBufferArgs,u=i.buffer;F.optional((function(){r.assert(n,a+"&&(typeof "+a+'==="object"||typeof '+a+'==="function")&&('+f+"("+a+")||"+u+".getBuffer("+a+")||"+u+".getBuffer("+a+".buffer)||"+f+"("+a+'.buffer)||("constant" in '+a+"&&(typeof "+a+'.constant==="number"||'+i.isArrayLike+"("+a+".constant))))",'invalid dynamic attribute "'+e+'"')}));var s={isStream:n.def(!1)},c=new b;c.state=dn,Object.keys(c).forEach((function(e){s[e]=n.def(""+c[e])}));var l=s.buffer,d=s.type;function m(e){n(s[e],"=",a,".",e,"|0;")}return n("if(",f,"(",a,")){",s.isStream,"=true;",l,"=",u,".createStream(",pa,",",a,");",d,"=",l,".dtype;","}else{",l,"=",u,".getBuffer(",a,");","if(",l,"){",d,"=",l,".dtype;",'}else if("constant" in ',a,"){",s.state,"=",mn,";","if(typeof "+a+'.constant === "number"){',s[cn[0]],"=",a,".constant;",cn.slice(1).map((function(e){return s[e]})).join("="),"=0;","}else{",cn.map((function(e,t){return s[e]+"="+a+".constant.length>"+t+"?"+a+".constant["+t+"]:0;"})).join(""),"}}else{","if(",f,"(",a,".buffer)){",l,"=",u,".createStream(",pa,",",a,".buffer);","}else{",l,"=",u,".getBuffer(",a,".buffer);","}",d,'="type" in ',a,"?",o.glTypes,"[",a,".type]:",l,".dtype;",s.normalized,"=!!",a,".normalized;"),m("size"),m("offset"),m("stride"),m("divisor"),n("}}"),n.exit("if(",s.isStream,"){",u,".destroyStream(",l,");","}"),s}))})),o}(t,d),T.context=function(e){var t=e.static,r=e.dynamic,n={};return Object.keys(t).forEach((function(e){var r=t[e];n[e]=hi((function(e,t){return"number"==typeof r||"boolean"==typeof r?""+r:e.link(r)}))})),Object.keys(r).forEach((function(e){var t=r[e];n[e]=bi(t,(function(e,r){return e.invoke(r,t)}))})),n}(s),T}function B(e,t,r){var n=e.shared.context,a=e.scope();Object.keys(r).forEach((function(i){t.save(n,"."+i);var o=r[i].append(e,t);Array.isArray(o)?a(n,".",i,"=[",o.join(),"];"):a(n,".",i,"=",o,";")})),t(a)}function I(e,t,r,n){var a,i=e.shared,o=i.gl,f=i.framebuffer;y&&(a=t.def(i.extensions,".webgl_draw_buffers"));var u,s=e.constants,c=s.drawBuffer,l=s.backBuffer;u=r?r.append(e,t):t.def(f,".next"),n||t("if(",u,"!==",f,".cur){"),t("if(",u,"){",o,".bindFramebuffer(",ni,",",u,".framebuffer);"),y&&t(a,".drawBuffersWEBGL(",c,"[",u,".colorAttachments.length]);"),t("}else{",o,".bindFramebuffer(",ni,",null);"),y&&t(a,".drawBuffersWEBGL(",l,");"),t("}",f,".cur=",u,";"),n||t("}")}function P(e,t,r){var n=e.shared,a=n.gl,i=e.current,o=e.next,f=n.current,u=n.next,s=e.cond(f,".dirty");_.forEach((function(t){var n,c,l=O(t);if(!(l in r.state))if(l in o){n=o[l],c=i[l];var d=Y(w[l].length,(function(e){return s.def(n,"[",e,"]")}));s(e.cond(d.map((function(e,t){return e+"!=="+c+"["+t+"]"})).join("||")).then(a,".",S[l],"(",d,");",d.map((function(e,t){return c+"["+t+"]="+e})).join(";"),";"))}else{n=s.def(u,".",l);var m=e.cond(n,"!==",f,".",l);s(m),l in k?m(e.cond(n).then(a,".enable(",k[l],");").else(a,".disable(",k[l],");"),f,".",l,"=",n,";"):m(a,".",S[l],"(",n,");",f,".",l,"=",n,";")}})),0===Object.keys(r.state).length&&s(f,".dirty=false;"),t(s)}function L(e,t,r,n){var a=e.shared,i=e.current,o=a.current,f=a.gl;di(Object.keys(r)).forEach((function(a){var u=r[a];if(!n||n(u)){var s=u.append(e,t);if(k[a]){var c=k[a];pi(u)?t(f,s?".enable(":".disable(",c,");"):t(e.cond(s).then(f,".enable(",c,");").else(f,".disable(",c,");")),t(o,".",a,"=",s,";")}else if(Ne(s)){var l=i[a];t(f,".",S[a],"(",s,");",s.map((function(e,t){return l+"["+t+"]="+e})).join(";"),";")}else t(f,".",S[a],"(",s,");",o,".",a,"=",s,";")}}))}function R(e,t){g&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function M(e,t,r,n,a){var i,o,f,u=e.shared,s=e.stats,c=u.current,l=u.timer,d=r.profile;function m(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function h(e){e(i=t.def(),"=",m(),";"),"string"==typeof a?e(s,".count+=",a,";"):e(s,".count++;"),p&&(n?e(o=t.def(),"=",l,".getNumPendingQueries();"):e(l,".beginQuery(",s,");"))}function b(e){e(s,".cpuTime+=",m(),"-",i,";"),p&&(n?e(l,".pushScopeStats(",o,",",l,".getNumPendingQueries(),",s,");"):e(l,".endQuery();"))}function v(e){var r=t.def(c,".profile");t(c,".profile=",e,";"),t.exit(c,".profile=",r,";")}if(d){if(pi(d))return void(d.enable?(h(t),b(t.exit),v("true")):v("false"));v(f=d.append(e,t))}else f=t.def(c,".profile");var g=e.block();h(g),t("if(",f,"){",g,"}");var y=e.block();b(y),t.exit("if(",f,"){",y,"}")}function U(e,t,r,n,a){var i=e.shared;n.forEach((function(n){var o,f=n.name,u=r.attributes[f];if(u){if(!a(u))return;o=u.append(e,t)}else{if(!a(vi))return;var s=e.scopeAttrib(f);F.optional((function(){e.assert(t,s+".state","missing attribute "+f)})),o={},Object.keys(new b).forEach((function(e){o[e]=t.def(s,".",e)}))}!function(r,n,a){var o=i.gl,f=t.def(r,".location"),u=t.def(i.attributes,"[",f,"]"),s=a.state,c=a.buffer,l=[a.x,a.y,a.z,a.w],d=["buffer","normalized","offset","stride"];function m(){t("if(!",u,".buffer){",o,".enableVertexAttribArray(",f,");}");var r,i=a.type;if(r=a.size?t.def(a.size,"||",n):n,t("if(",u,".type!==",i,"||",u,".size!==",r,"||",d.map((function(e){return u+"."+e+"!=="+a[e]})).join("||"),"){",o,".bindBuffer(",pa,",",c,".buffer);",o,".vertexAttribPointer(",[f,r,i,a.normalized,a.stride,a.offset],");",u,".type=",i,";",u,".size=",r,";",d.map((function(e){return u+"."+e+"="+a[e]+";"})).join(""),"}"),g){var s=a.divisor;t("if(",u,".divisor!==",s,"){",e.instancing,".vertexAttribDivisorANGLE(",[f,s],");",u,".divisor=",s,";}")}}function p(){t("if(",u,".buffer){",o,".disableVertexAttribArray(",f,");",u,".buffer=null;","}if(",cn.map((function(e,t){return u+"."+e+"!=="+l[t]})).join("||"),"){",o,".vertexAttrib4f(",f,",",l,");",cn.map((function(e,t){return u+"."+e+"="+l[t]+";"})).join(""),"}")}s===dn?m():s===mn?p():(t("if(",s,"===",dn,"){"),m(),t("}else{"),p(),t("}"))}(e.link(n),function(e){switch(e){case Ta:case za:case Ia:return 2;case Da:case Fa:case Pa:return 3;case ja:case Va:case La:return 4;default:return 1}}(n.info.type),o)}))}function G(e,t,n,a,i,o){for(var f,u=e.shared,s=u.gl,c={},l=0;l1){if(!b)continue;var v=m.replace("[0]","");if(c[v])continue;c[v]=1}var g,y=e.link(d)+".location";if(b){if(!i(b))continue;if(pi(b)){var x=b.value;if(F.command(null!=x,'missing uniform "'+m+'"',e.commandStr),p===Wa||p===Ga){F.command("function"==typeof x&&(p===Wa&&("texture2d"===x._reglType||"framebuffer"===x._reglType)||p===Ga&&("textureCube"===x._reglType||"framebufferCube"===x._reglType)),"invalid texture for uniform "+m,e.commandStr);var w=e.link(x._texture||x.color[0]._texture);t(s,".uniform1i(",y,",",w+".bind());"),t.exit(w,".unbind();")}else if(p===Ra||p===Ma||p===Ua){F.optional((function(){F.command(Ne(x),"invalid matrix for uniform "+m,e.commandStr),F.command(p===Ra&&4===x.length||p===Ma&&9===x.length||p===Ua&&16===x.length,"invalid length for matrix uniform "+m,e.commandStr)}));var A=e.global.def("new Float32Array(["+Array.prototype.slice.call(x)+"])"),_=2;p===Ma?_=3:p===Ua&&(_=4),t(s,".uniformMatrix",_,"fv(",y,",false,",A,");")}else{switch(p){case Ea:1===h?F.commandType(x,"number","uniform "+m,e.commandStr):F.command(Ne(x)&&x.length===h,"uniform "+m,e.commandStr),f="1f";break;case Ta:F.command(Ne(x)&&x.length&&x.length%2==0&&x.length<=2*h,"uniform "+m,e.commandStr),f="2f";break;case Da:F.command(Ne(x)&&x.length&&x.length%3==0&&x.length<=3*h,"uniform "+m,e.commandStr),f="3f";break;case ja:F.command(Ne(x)&&x.length&&x.length%4==0&&x.length<=4*h,"uniform "+m,e.commandStr),f="4f";break;case Ba:1===h?F.commandType(x,"boolean","uniform "+m,e.commandStr):F.command(Ne(x)&&x.length===h,"uniform "+m,e.commandStr),f="1i";break;case Ca:1===h?F.commandType(x,"number","uniform "+m,e.commandStr):F.command(Ne(x)&&x.length===h,"uniform "+m,e.commandStr),f="1i";break;case Ia:case za:F.command(Ne(x)&&x.length&&x.length%2==0&&x.length<=2*h,"uniform "+m,e.commandStr),f="2i";break;case Pa:case Fa:F.command(Ne(x)&&x.length&&x.length%3==0&&x.length<=3*h,"uniform "+m,e.commandStr),f="3i";break;case La:case Va:F.command(Ne(x)&&x.length&&x.length%4==0&&x.length<=4*h,"uniform "+m,e.commandStr),f="4i"}h>1?(f+="v",x=e.global.def("["+Array.prototype.slice.call(x)+"]")):x=Ne(x)?Array.prototype.slice.call(x):x,t(s,".uniform",f,"(",y,",",x,");")}continue}g=b.append(e,t)}else{if(!i(vi))continue;g=t.def(u.uniforms,"[",r.id(m),"]")}p===Wa?(F(!Array.isArray(g),"must specify a scalar prop for textures"),t("if(",g,"&&",g,'._reglType==="framebuffer"){',g,"=",g,".color[0];","}")):p===Ga&&(F(!Array.isArray(g),"must specify a scalar prop for cube maps"),t("if(",g,"&&",g,'._reglType==="framebufferCube"){',g,"=",g,".color[0];","}")),F.optional((function(){function r(r,n){e.assert(t,r,'bad data or missing for uniform "'+m+'". '+n)}function n(e,t){1===t&&F(!Array.isArray(g),"must not specify an array type for uniform"),r("Array.isArray("+g+") && typeof "+g+'[0]===" '+e+'" || typeof '+g+'==="'+e+'"',"invalid type, expected "+e)}function a(t,n,a){Array.isArray(g)?F(g.length&&g.length%t==0&&g.length<=t*a,"must have length of "+(1===a?"":"n * ")+t):r(u.isArrayLike+"("+g+")&&"+g+".length && "+g+".length % "+t+" === 0 && "+g+".length<="+t*a,"invalid vector, should have length of "+(1===a?"":"n * ")+t,e.commandStr)}function i(t){F(!Array.isArray(g),"must not specify a value type"),r("typeof "+g+'==="function"&&'+g+'._reglType==="texture'+(t===ba?"2d":"Cube")+'"',"invalid texture type",e.commandStr)}switch(p){case Ca:n("number",h);break;case za:a(2,0,h);break;case Fa:a(3,0,h);break;case Va:a(4,0,h);break;case Ea:n("number",h);break;case Ta:a(2,0,h);break;case Da:a(3,0,h);break;case ja:a(4,0,h);break;case Ba:n("boolean",h);break;case Ia:a(2,0,h);break;case Pa:a(3,0,h);break;case La:case Ra:a(4,0,h);break;case Ma:a(9,0,h);break;case Ua:a(16,0,h);break;case Wa:i(ba);break;case Ga:i(va)}}));var k=1;switch(p){case Wa:case Ga:var S=t.def(g,"._texture");t(s,".uniform1i(",y,",",S,".bind());"),t.exit(S,".unbind();");continue;case Ca:case Ba:f="1i";break;case za:case Ia:f="2i",k=2;break;case Fa:case Pa:f="3i",k=3;break;case Va:case La:f="4i",k=4;break;case Ea:f="1f";break;case Ta:f="2f",k=2;break;case Da:f="3f",k=3;break;case ja:f="4f",k=4;break;case Ra:f="Matrix2fv";break;case Ma:f="Matrix3fv";break;case Ua:f="Matrix4fv"}if(-1===f.indexOf("Matrix")&&h>1&&(f+="v",k=1),"M"===f.charAt(0)){t(s,".uniform",f,"(",y,",");var O=Math.pow(p-Ra+2,2),E=e.global.def("new Float32Array(",O,")");Array.isArray(g)?t("false,(",Y(O,(function(e){return E+"["+e+"]="+g[e]})),",",E,")"):t("false,(Array.isArray(",g,")||",g," instanceof Float32Array)?",g,":(",Y(O,(function(e){return E+"["+e+"]="+g+"["+e+"]"})),",",E,")"),t(");")}else if(k>1){for(var T=[],D=[],j=0;j=0","missing vertex count")}))):(a=u.def(o,".",ea),F.optional((function(){e.assert(u,a+">=0","missing vertex count")}))),a}();if("number"==typeof p){if(0===p)return}else r("if(",p,"){"),r.exit("}");g&&(c=s(ra),l=e.instancing);var h=u+".type",b=f.elements&&pi(f.elements)&&!f.vaoActive;function v(){function e(){r(l,".drawElementsInstancedANGLE(",[d,p,h,m+"<<(("+h+"-"+ln+")>>1)",c],");")}function t(){r(l,".drawArraysInstancedANGLE(",[d,m,p,c],");")}u&&"null"!==u?b?e():(r("if(",u,"){"),e(),r("}else{"),t(),r("}")):t()}function y(){function e(){r(i+".drawElements("+[d,p,h,m+"<<(("+h+"-"+ln+")>>1)"]+");")}function t(){r(i+".drawArrays("+[d,m,p]+");")}u&&"null"!==u?b?e():(r("if(",u,"){"),e(),r("}else{"),t(),r("}")):t()}g&&("number"!=typeof c||c>=0)?"string"==typeof c?(r("if(",c,">0){"),v(),r("}else if(",c,"<0){"),y(),r("}")):v():y()}function N(e,t,r,n,a){var i=z(),o=i.proc("body",a);return F.optional((function(){i.commandStr=t.commandStr,i.command=i.link(t.commandStr)})),g&&(i.instancing=o.def(i.shared.extensions,".angle_instanced_arrays")),e(i,o,r,n),i.compile().body}function q(e,t,r,n){R(e,t),r.useVAO?r.drawVAO?t(e.shared.vao,".setVAO(",r.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),U(e,t,r,n.attributes,(function(){return!0}))),G(e,t,r,n.uniforms,(function(){return!0}),!1),H(e,t,t,r)}function Q(e,t,r,n){function a(){return!0}e.batchId="a1",R(e,t),U(e,t,r,n.attributes,a),G(e,t,r,n.uniforms,a,!1),H(e,t,t,r)}function X(e,t,r,n){R(e,t);var a=r.contextDep,i=t.def(),o=t.def();e.shared.props=o,e.batchId=i;var f=e.scope(),u=e.scope();function s(e){return e.contextDep&&a||e.propDep}function c(e){return!s(e)}if(t(f.entry,"for(",i,"=0;",i,"<","a1",";++",i,"){",o,"=","a0","[",i,"];",u,"}",f.exit),r.needsContext&&B(e,u,r.context),r.needsFramebuffer&&I(e,u,r.framebuffer),L(e,u,r.state,s),r.profile&&s(r.profile)&&M(e,u,r,!1,!0),n)r.useVAO?r.drawVAO?s(r.drawVAO)?u(e.shared.vao,".setVAO(",r.drawVAO.append(e,u),");"):f(e.shared.vao,".setVAO(",r.drawVAO.append(e,f),");"):f(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(f(e.shared.vao,".setVAO(null);"),U(e,f,r,n.attributes,c),U(e,u,r,n.attributes,s)),G(e,f,r,n.uniforms,c,!1),G(e,u,r,n.uniforms,s,!0),H(e,f,u,r);else{var l=e.global.def("{}"),d=r.shader.progVar.append(e,u),m=u.def(d,".id"),p=u.def(l,"[",m,"]");u(e.shared.gl,".useProgram(",d,".program);","if(!",p,"){",p,"=",l,"[",m,"]=",e.link((function(t){return N(Q,e,r,t,2)})),"(",d,");}",p,".call(this,a0[",i,"],",i,");")}}function $(e,t,r){var n=t.static[r];if(n&&function(e){if("object"==typeof e&&!Ne(e)){for(var t=Object.keys(e),r=0;r0&&r(e.shared.current,".dirty=true;"),e.shared.vao&&r(e.shared.vao,".setVAO(null);")}(f,u),function(e,t){var n=e.proc("scope",3);e.batchId="a2";var a=e.shared,i=a.current;function o(r){var i=t.shader[r];i&&n.set(a.shader,"."+r,i.append(e,n))}B(e,n,t.context),t.framebuffer&&t.framebuffer.append(e,n),di(Object.keys(t.state)).forEach((function(r){var i=t.state[r].append(e,n);Ne(i)?i.forEach((function(t,a){n.set(e.next[r],"["+a+"]",t)})):n.set(a.next,"."+r,i)})),M(e,n,t,!0,!0),[Jn,ta,ea,ra,Zn].forEach((function(r){var i=t.draw[r];i&&n.set(a.draw,"."+r,""+i.append(e,n))})),Object.keys(t.uniforms).forEach((function(i){var o=t.uniforms[i].append(e,n);Array.isArray(o)&&(o="["+o.join()+"]"),n.set(a.uniforms,"["+r.id(i)+"]",o)})),Object.keys(t.attributes).forEach((function(r){var a=t.attributes[r].append(e,n),i=e.scopeAttrib(r);Object.keys(new b).forEach((function(e){n.set(i,"."+e,a[e])}))})),t.scopeVAO&&n.set(a.vao,".targetVAO",t.scopeVAO.append(e,n)),o($n),o(Kn),Object.keys(t.state).length>0&&(n(i,".dirty=true;"),n.exit(i,".dirty=true;")),n("a1(",e.shared.context,",a0,",e.batchId,");")}(f,u),function(e,t){var r=e.proc("batch",2);e.batchId="0",R(e,r);var n=!1,a=!0;Object.keys(t.context).forEach((function(e){n=n||t.context[e].propDep})),n||(B(e,r,t.context),a=!1);var i=t.framebuffer,o=!1;function f(e){return e.contextDep&&n||e.propDep}i?(i.propDep?n=o=!0:i.contextDep&&n&&(o=!0),o||I(e,r,i)):I(e,r,null),t.state.viewport&&t.state.viewport.propDep&&(n=!0),P(e,r,t),L(e,r,t.state,(function(e){return!f(e)})),t.profile&&f(t.profile)||M(e,r,t,!1,"a1"),t.contextDep=n,t.needsContext=a,t.needsFramebuffer=o;var u=t.shader.progVar;if(u.contextDep&&n||u.propDep)X(e,r,t,null);else{var s=u.append(e,r);if(r(e.shared.gl,".useProgram(",s,".program);"),t.shader.program)X(e,r,t,t.shader.program);else{r(e.shared.vao,".setVAO(null);");var c=e.global.def("{}"),l=r.def(s,".id"),d=r.def(c,"[",l,"]");r(e.cond(d).then(d,".call(this,a0,a1);").else(d,"=",c,"[",l,"]=",e.link((function(r){return N(X,e,t,r,2)})),"(",s,");",d,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&r(e.shared.current,".dirty=true;"),e.shared.vao&&r(e.shared.vao,".setVAO(null);")}(f,u),t(f.compile(),{destroy:function(){u.shader.program.destroy()}})}}}var yi=34918,xi=34919,wi=35007,Ai=function(e,t){if(!t.ext_disjoint_timer_query)return null;var r=[];function n(e){r.push(e)}var a=[];function i(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var o=[];function f(e){o.push(e)}var u=[];function s(e,t,r){var n=o.pop()||new i;n.startQueryIndex=e,n.endQueryIndex=t,n.sum=0,n.stats=r,u.push(n)}var c=[],l=[];return{beginQuery:function(e){var n=r.pop()||t.ext_disjoint_timer_query.createQueryEXT();t.ext_disjoint_timer_query.beginQueryEXT(wi,n),a.push(n),s(a.length-1,a.length,e)},endQuery:function(){t.ext_disjoint_timer_query.endQueryEXT(wi)},pushScopeStats:s,update:function(){var e,r,i=a.length;if(0!==i){l.length=Math.max(l.length,i+1),c.length=Math.max(c.length,i+1),c[0]=0,l[0]=0;var o=0;for(e=0,r=0;r0)if(Array.isArray(r[0])){f=ye(r);for(var c=1,l=1;l0)if("number"==typeof t[0]){var i=ae.allocType(d.dtype,t.length);Oe(i,t),p(i,a),ae.freeType(i)}else if(Array.isArray(t[0])||e(t[0])){n=ye(t);var o=ge(t,n,d.dtype);p(o,a),ae.freeType(o)}else F.raise("invalid buffer data")}else if(ce(t)){n=t.shape;var f=t.stride,u=0,s=0,c=0,l=0;1===n.length?(u=n[0],s=1,c=f[0],l=0):2===n.length?(u=n[0],s=n[1],c=f[0],l=f[1]):F.raise("invalid shape");var h=Array.isArray(t.data)?d.dtype:Se(t.data),b=ae.allocType(h,u*s);Ee(b,t.data,u,s,c,l,t.offset),p(b,a),ae.freeType(b)}else F.raise("invalid data for buffer subdata");return m},n.profile&&(m.stats=d.stats),m.destroy=function(){l(d)},m},createStream:function(e,t){var r=u.pop();return r||(r=new f(e)),r.bind(),c(r,t,we,0,1,!1),r},destroyStream:function(e){u.push(e)},clear:function(){le(o).forEach(l),u.forEach(l)},getBuffer:function(e){return e&&e._buffer instanceof f?e._buffer:null},restore:function(){le(o).forEach((function(e){e.buffer=t.createBuffer(),t.bindBuffer(e.type,e.buffer),t.bufferData(e.type,e.persistentData||e.byteLength,e.usage)}))},_initBuffer:c}}(a,l,n,(function(e){return A.destroyBuffer(e)})),w=function(t,r,n,a){var i={},o=0,f={uint8:Fe,uint16:Be};function u(e){this.id=o++,i[this.id]=this,this.buffer=e,this.primType=Ce,this.vertCount=0,this.type=0}r.oes_element_index_uint&&(f.uint32=Pe),u.prototype.bind=function(){this.buffer.bind()};var s=[];function c(a,i,o,f,u,s,c){var l;if(a.buffer.bind(),i){var d=c;c||e(i)&&(!ce(i)||e(i.data))||(d=r.oes_element_index_uint?Pe:Be),n._initBuffer(a.buffer,i,o,d,3)}else t.bufferData(Le,s,o),a.buffer.dtype=l||Fe,a.buffer.usage=o,a.buffer.dimension=3,a.buffer.byteLength=s;if(l=c,!c){switch(a.buffer.dtype){case Fe:case ze:l=Fe;break;case Be:case Ve:l=Be;break;case Pe:case Ie:l=Pe;break;default:F.raise("unsupported type for element array")}a.buffer.dtype=l}a.type=l,F(l!==Pe||!!r.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var m=u;m<0&&(m=a.buffer.byteLength,l===Be?m>>=1:l===Pe&&(m>>=2)),a.vertCount=m;var p=f;if(f<0){p=Ce;var h=a.buffer.dimension;1===h&&(p=De),2===h&&(p=je),3===h&&(p=Ce)}a.primType=p}function l(e){a.elementsCount--,F(null!==e.buffer,"must not double destroy elements"),delete i[e.id],e.buffer.destroy(),e.buffer=null}return{create:function(t,r){var i=n.create(null,Le,!0),o=new u(i._buffer);function s(t){if(t)if("number"==typeof t)i(t),o.primType=Ce,o.vertCount=0|t,o.type=Fe;else{var r=null,n=Me,a=-1,u=-1,l=0,d=0;Array.isArray(t)||e(t)||ce(t)?r=t:(F.type(t,"object","invalid arguments for elements"),"data"in t&&(r=t.data,F(Array.isArray(r)||e(r)||ce(r),"invalid data for element buffer")),"usage"in t&&(F.parameter(t.usage,ve,"invalid element buffer usage"),n=ve[t.usage]),"primitive"in t&&(F.parameter(t.primitive,Te,"invalid element buffer primitive"),a=Te[t.primitive]),"count"in t&&(F("number"==typeof t.count&&t.count>=0,"invalid vertex count for elements"),u=0|t.count),"type"in t&&(F.parameter(t.type,f,"invalid buffer type"),d=f[t.type]),"length"in t?l=0|t.length:(l=u,d===Be||d===Ve?l*=2:d!==Pe&&d!==Ie||(l*=4))),c(o,r,n,a,u,l,d)}else i(),o.primType=Ce,o.vertCount=0,o.type=Fe;return s}return a.elementsCount++,s(t),s._reglType="elements",s._elements=o,s.subdata=function(e,t){return i.subdata(e,t),s},s.destroy=function(){l(o)},s},createStream:function(e){var t=s.pop();return t||(t=new u(n.create(null,Le,!0,!1)._buffer)),c(t,e,Re,-1,-1,0,0),t},destroyStream:function(e){s.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof u?e._elements:null},clear:function(){le(i).forEach(l)}}}(a,d,x,l),A=function(t,r,n,a,i,o,f){for(var u=n.maxAttributes,s=new Array(u),c=0;c{for(var e=Object.keys(t),r=0;r=0,'invalid option for vao: "'+e[r]+'" valid options are '+$r)})),F(Array.isArray(a),"attributes must be an array")}F(a.length0,"must specify at least one attribute");var c={},l=n.attributes;l.length=a.length;for(var d=0;d=b.byteLength?m.subdata(b):(m.destroy(),n.buffers[d]=null)),n.buffers[d]||(m=n.buffers[d]=i.create(p,Yr,!1,!0)),h.buffer=i.getBuffer(m),h.size=0|h.buffer.dimension,h.normalized=!1,h.type=h.buffer.dtype,h.offset=0,h.stride=0,h.divisor=0,h.state=1,c[d]=1):i.getBuffer(p)?(h.buffer=i.getBuffer(p),h.size=0|h.buffer.dimension,h.normalized=!1,h.type=h.buffer.dtype,h.offset=0,h.stride=0,h.divisor=0,h.state=1):i.getBuffer(p.buffer)?(h.buffer=i.getBuffer(p.buffer),h.size=0|(+p.size||h.buffer.dimension),h.normalized=!!p.normalized||!1,"type"in p?(F.parameter(p.type,be,"invalid buffer type"),h.type=be[p.type]):h.type=h.buffer.dtype,h.offset=0|(p.offset||0),h.stride=0|(p.stride||0),h.divisor=0|(p.divisor||0),h.state=1,F(h.size>=1&&h.size<=4,"size must be between 1 and 4"),F(h.offset>=0,"invalid offset"),F(h.stride>=0&&h.stride<=255,"stride must be between 0 and 255"),F(h.divisor>=0,"divisor must be positive"),F(!h.divisor||!!r.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in p?(F(d>0,"first attribute must not be a constant"),h.x=+p.x||0,h.y=+p.y||0,h.z=+p.z||0,h.w=+p.w||0,h.state=2):F(!1,"invalid attribute spec for location "+d)}for(var v=0;v1)for(var v=0;v1&&(y=y.replace("[0]","")),u(b,new f(y,r.id(y),e.getUniformLocation(m,y),c))}var x=e.getProgramParameter(m,tn);a.profile&&(t.stats.attributesCount=x);var w=t.attributes;for(o=0;oe&&(e=t.stats.uniformsCount)})),e},n.getMaxAttributesCount=function(){var e=0;return l.forEach((function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)})),e}),{clear:function(){var t=e.deleteShader.bind(e);le(i).forEach(t),i={},le(o).forEach(t),o={},l.forEach((function(t){e.deleteProgram(t.program)})),l.length=0,c={},n.shaderCount=0},program:function(r,a,f,u){F.command(r>=0,"missing vertex shader",f),F.command(a>=0,"missing fragment shader",f);var s=c[a];s||(s=c[a]={});var d=s[r];if(d&&(d.refCount++,!u))return d;var h=new m(a,r);return n.shaderCount++,p(h,f,u),d||(s[r]=h),l.push(h),t(h,{destroy:function(){if(h.refCount--,h.refCount<=0){e.deleteProgram(h.program);var t=l.indexOf(h);l.splice(t,1),n.shaderCount--}s[h.vertId].refCount<=0&&(e.deleteShader(o[h.vertId]),delete o[h.vertId],delete c[h.fragId][h.vertId]),Object.keys(c[h.fragId]).length||(e.deleteShader(i[h.fragId]),delete i[h.fragId],delete c[h.fragId])}})},restore:function(){i={},o={};for(var e=0;e=zr&&t=2,"invalid shape for framebuffer"),o=C[0],d=C[1]}else"radius"in j&&(o=d=j.radius),"width"in j&&(o=j.width),"height"in j&&(d=j.height);("color"in j||"colors"in j)&&(y=j.color||j.colors,Array.isArray(y)&&F(1===y.length||r.webgl_draw_buffers,"multiple render targets not supported")),y||("colorCount"in j&&(S=0|j.colorCount,F(S>0,"invalid color buffer count")),"colorTexture"in j&&(x=!!j.colorTexture,w="rgba4"),"colorType"in j&&(_=j.colorType,x?(F(r.oes_texture_float||!("float"===_||"float32"===_),"you must enable OES_texture_float in order to use floating point framebuffer objects"),F(r.oes_texture_half_float||!("half float"===_||"float16"===_),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===_||"float16"===_?(F(r.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),w="rgba16f"):"float"!==_&&"float32"!==_||(F(r.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),w="rgba32f"),F.oneOf(_,c,"invalid color type")),"colorFormat"in j&&(w=j.colorFormat,u.indexOf(w)>=0?x=!0:s.indexOf(w)>=0?x=!1:F.optional((function(){x?F.oneOf(j.colorFormat,u,"invalid color format for texture"):F.oneOf(j.colorFormat,s,"invalid color format for renderbuffer")})))),("depthTexture"in j||"depthStencilTexture"in j)&&(D=!(!j.depthTexture&&!j.depthStencilTexture),F(!D||r.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in j&&("boolean"==typeof j.depth?p=j.depth:(O=j.depth,g=!1)),"stencil"in j&&("boolean"==typeof j.stencil?g=j.stencil:(E=j.stencil,p=!1)),"depthStencil"in j&&("boolean"==typeof j.depthStencil?p=g=j.depthStencil:(T=j.depthStencil,p=!1,g=!1))}else o=d=1;var z=null,V=null,B=null,I=null;if(Array.isArray(y))z=y.map(h);else if(y)z=[h(y)];else for(z=new Array(S),a=0;a=0||z[a].renderbuffer&&Nr.indexOf(z[a].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+a+" is invalid"),z[a]&&z[a].texture){var L=Mr[z[a].texture._texture.format]*Ur[z[a].texture._texture.type];null===P?P=L:F(P===L,"all color attachments much have the same number of bits per pixel.")}return m(V,o,d),F(!V||V.texture&&V.texture._texture.format===Lr||V.renderbuffer&&V.renderbuffer._renderbuffer.format===Wr,"invalid depth attachment for framebuffer object"),m(B,o,d),F(!B||B.renderbuffer&&B.renderbuffer._renderbuffer.format===Gr,"invalid stencil attachment for framebuffer object"),m(I,o,d),F(!I||I.texture&&I.texture._texture.format===Hr||I.renderbuffer&&I.renderbuffer._renderbuffer.format===Hr,"invalid depth-stencil attachment for framebuffer object"),A(i),i.width=o,i.height=d,i.colorAttachments=z,i.depthAttachment=V,i.stencilAttachment=B,i.depthStencilAttachment=I,l.color=z.map(v),l.depth=v(V),l.stencil=v(B),l.depthStencil=v(I),l.width=i.width,l.height=i.height,k(i),l}return o.framebufferCount++,l(e,a),t(l,{resize:function(e,t){F(f.next!==i,"can not resize a framebuffer which is currently in use");var r=Math.max(0|e,1),n=Math.max(0|t||r,1);if(r===i.width&&n===i.height)return l;for(var a=i.colorAttachments,o=0;o=2,"invalid shape for framebuffer"),F(g[0]===g[1],"cube framebuffer must be square"),d=g[0]}else"radius"in v&&(d=0|v.radius),"width"in v?(d=0|v.width,"height"in v&&F(v.height===d,"must be square")):"height"in v&&(d=0|v.height);("color"in v||"colors"in v)&&(m=v.color||v.colors,Array.isArray(m)&&F(1===m.length||r.webgl_draw_buffers,"multiple render targets not supported")),m||("colorCount"in v&&(b=0|v.colorCount,F(b>0,"invalid color buffer count")),"colorType"in v&&(F.oneOf(v.colorType,c,"invalid color type"),h=v.colorType),"colorFormat"in v&&(p=v.colorFormat,F.oneOf(v.colorFormat,u,"invalid color format for texture"))),"depth"in v&&(l.depth=v.depth),"stencil"in v&&(l.stencil=v.stencil),"depthStencil"in v&&(l.depthStencil=v.depthStencil)}else d=1;if(m)if(Array.isArray(m))for(s=[],n=0;n0&&(l.depth=i[0].depth,l.stencil=i[0].stencil,l.depthStencil=i[0].depthStencil),i[n]?i[n](l):i[n]=S(l)}return t(o,{width:d,height:d,color:s})}return o(e),t(o,{faces:i,resize:function(e){var t,r=0|e;if(F(r>0&&r<=n.maxCubeMapSize,"invalid radius for cube fbo"),r===o.width)return o;var a=o.color;for(t=0;t=0;--e){var t=C[e];t&&t(v,null,0)}a.flush(),m&&m.update()}function L(){!I&&C.length>0&&(I=G.next(P))}function R(){I&&(G.cancel(P),I=null)}function M(e){e.preventDefault(),o=!0,R(),z.forEach((function(e){e()}))}function U(e){a.getError(),o=!1,f.restore(),_.restore(),x.restore(),k.restore(),S.restore(),O.restore(),A.restore(),m&&m.restore(),E.procs.refresh(),L(),V.forEach((function(e){e()}))}function N(e){function r(e,t){var r={},n={};return Object.keys(e).forEach((function(a){var i=e[a];if(W.isDynamic(i))n[a]=W.unbox(i,a);else{if(t&&Array.isArray(i))for(var o=0;o0)return l.call(this,function(e){for(;m.length=0,"cannot cancel a frame twice"),C[t]=function e(){var t=zi(C,e);C[t]=C[C.length-1],C.length-=1,C.length<=0&&R()}}}}function $(){var e=D.viewport,t=D.scissor_box;e[0]=e[1]=t[0]=t[1]=0,v.viewportWidth=v.framebufferWidth=v.drawingBufferWidth=e[2]=t[2]=a.drawingBufferWidth,v.viewportHeight=v.framebufferHeight=v.drawingBufferHeight=e[3]=t[3]=a.drawingBufferHeight}function K(){v.tick+=1,v.time=Z(),$(),E.procs.poll()}function J(){k.refresh(),$(),E.procs.refresh(),m&&m.update()}function Z(){return(H()-p)/1e3}J();var ee=t(N,{clear:function(e){if(F("object"==typeof e&&e,"regl.clear() takes an object as input"),"framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var r=0;r<6;++r)q(t({framebuffer:e.framebuffer.faces[r]},e),Y);else q(e,Y);else Y(0,e)},prop:W.define.bind(null,Di),context:W.define.bind(null,ji),this:W.define.bind(null,Ci),draw:N({}),buffer:function(e){return x.create(e,Oi,!1,!1)},elements:function(e){return w.create(e,!1)},texture:k.create2D,cube:k.createCube,renderbuffer:S.create,framebuffer:O.create,framebufferCube:O.createCube,vao:A.createVAO,attributes:i,frame:X,on:function(e,t){var r;switch(F.type(t,"function","listener callback must be a function"),e){case"frame":return X(t);case"lost":r=z;break;case"restore":r=V;break;case"destroy":r=B;break;default:F.raise("invalid event, must be one of frame,lost,restore,destroy")}return r.push(t),{cancel:function(){for(var e=0;e=0},read:T,destroy:function(){C.length=0,R(),j&&(j.removeEventListener(Ei,M),j.removeEventListener(Ti,U)),_.clear(),O.clear(),S.clear(),A.clear(),k.clear(),w.clear(),x.clear(),m&&m.clear(),B.forEach((function(e){e()}))},_gl:a,_refresh:J,poll:function(){K(),m&&m.update()},now:Z,stats:l});return n.onDone(null,ee),ee}},"object"==typeof r&&void 0!==t?t.exports=o():"function"==typeof define&&define.amd?define(o):i.createREGL=o()}, 507: function _(t,e,a,s,r){s();const n=t(508),_=t(10),o=t(13);class c{constructor(t){this._regl=t,this._map=new Map}_create_texture(t){const e=t.length;let a=0;const s=[];let r=0,_=0;for(let n=0;nc[f+1]&&f++;const s=t[f],n=c[f]+.5*s;let o=.5*s-Math.abs(a-n);f%2==1&&(o=-o),m[e]=Math.round(255*(o-r)/(_-r))}return[[a,u,r,_],this._regl.texture({shape:[l,1,1],data:m,wrapS:"repeat",format:"alpha",type:"uint8",mag:"linear",min:"linear"})]}_get_key(t){return t.join(",")}_get_or_create(t){const e=this._get_key(t);let a=this._map.get(e);if(null==a){const s=(0,n.gcd)(t);if(s>1){t=(0,o.map)(t,(t=>t/s)),a=this._get_or_create(t);const[r,n,_]=a;a=[r,n,s],this._map.set(e,a)}else{const[r,n]=this._create_texture(t);a=[r,n,s],this._map.set(e,a)}}return a}get(t){return t.length%2==1&&(t=(0,_.concat)([t,t])),this._get_or_create(t)}}a.DashCache=c,c.__name__="DashCache"}, 508: function _(n,t,e,r,o){function u(n,t){let e,r;n>t?(e=n,r=t):(e=t,r=n);let o=e%r;for(;0!=o;)e=r,r=o,o=e%r;return r}r(),e.gcd=function(n){let t=n[0];for(let e=1;e0}_set_data(){const s=this._set_data_points(),i=s.length/2-2;null==this._show&&(this._show=new a.Uint8Buffer(this.regl_wrapper));const t=this._show.get_sized_array(i+1);let _=isFinite(s[2])&&isFinite(s[3]);for(let e=1;es/255)),this._linewidth=s.line_width.value,this._linewidth<1&&(this._color[3]*=this._linewidth,this._linewidth=1),this._line_dash=(0,o.resolve_line_dash)(s.line_dash.value),this._is_dashed()&&([this._dash_tex_info,this._dash_tex,this._dash_scale]=this.regl_wrapper.get_dash(this._line_dash),this._dash_offset=s.line_dash_offset.value)}}t.BaseLineGL=r,r.__name__="BaseLineGL"}, 514: function _(e,t,s,i,h){i();class a{constructor(e,t){this.nvertices=0,this.size_changed=!1,this.data_changed=!1,this.visuals_changed=!1,this.glyph=t,this.regl_wrapper=e}set_data_changed(){const{data_size:e}=this.glyph;e!=this.nvertices&&(this.nvertices=e,this.size_changed=!0),this.data_changed=!0}set_visuals_changed(){this.visuals_changed=!0}render(e,t,s){if(0==t.length)return!0;const{width:i,height:h}=this.glyph.renderer.plot_view.canvas_view.webgl.canvas,a={pixel_ratio:this.glyph.renderer.plot_view.canvas_view.pixel_ratio,width:i,height:h};return this.draw(t,s,a),!0}}s.BaseGLGlyph=a,a.__name__="BaseGLGlyph"}, 515: function _(r,t,a,e,s){e();const i=r(516),_=r(21);class n{constructor(r){this.regl_wrapper=r,this.is_scalar=!0}get_sized_array(r){return null!=this.array&&this.array.length==r||(this.array=this.new_array(r)),this.array}is_normalized(){return!1}get length(){return null!=this.array?this.array.length:0}set_from_array(r){const t=r.length,a=this.get_sized_array(t);for(let e=0;e0&&(l[o]=n[o]);for(let e=1;e2&&t[0]==t[e-1]&&s[0]==s[e-1]&&isFinite(t[0])&&isFinite(s[0]),null==this._points&&(this._points=new _.Float32Buffer(this.regl_wrapper));const i=this._points.get_sized_array(2*(e+2));for(let h=1;h1||s.length<_){this._show_all=!1,n.fill(0),r=0;for(const e of s)1!=h&&i._marker_types.get(e)!=t||(n[e]=255,r++)}else this._show_all&&a==_||(this._show_all=!0,n.fill(255));this._show.update(),0!=r&&this._draw_one_marker_type(t,e,i)}}_get_visuals(){return this.glyph.visuals}_set_data(){const s=this.nvertices;null==this._centers&&(this._centers=new r.Float32Buffer(this.regl_wrapper),this._widths=new r.Float32Buffer(this.regl_wrapper),this._heights=this._widths,this._angles=new r.Float32Buffer(this.regl_wrapper));const t=this._centers.get_sized_array(2*s);for(let e=0;e2&&e[0]==e[i-1]&&s[0]==s[i-1]&&isFinite(e[0])&&isFinite(s[0]);const a="center"==t?2*i:2*i-1;null==this._points&&(this._points=new r.Float32Buffer(this.regl_wrapper));const n=this._points.get_sized_array(2*(a+2));let l=isFinite(e[0]+s[0]),h=2;"center"==t&&(n[h++]=l?e[0]:NaN,n[h++]=s[0]);for(let a=0;a