From 4a6245e2a2b4f307a7e53240dc0fc6a0e2ef74d1 Mon Sep 17 00:00:00 2001 From: Jamie Wong Date: Wed, 20 Dec 2017 09:27:57 -0500 Subject: [PATCH] Switch to parcel-bundler --- .gitignore | 1 + dev.html | 15 ++++ dist/speedscope.js | 151 +++++++++++++++++++++++++++++++++++- package.json | 7 +- index.tsx => speedscope.tsx | 0 5 files changed, 169 insertions(+), 5 deletions(-) create mode 100644 dev.html rename index.tsx => speedscope.tsx (100%) diff --git a/.gitignore b/.gitignore index 3c3629e..6bc4134 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.cache diff --git a/dev.html b/dev.html new file mode 100644 index 0000000..2a91528 --- /dev/null +++ b/dev.html @@ -0,0 +1,15 @@ + + + + + + + SpeedScope + + + + +
+ + + diff --git a/dist/speedscope.js b/dist/speedscope.js index 3a23c9d..289968e 100644 --- a/dist/speedscope.js +++ b/dist/speedscope.js @@ -1 +1,150 @@ -!function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var f="function"==typeof require&&require;if(!s&&f)return f(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;or&&(t=a)}}(0,t.length,n=>i(e,r(t,n)),n);return r(t,a)}Object.defineProperty(n,"__esModule",{value:!0});const o=e("preact"),s=e("aphrodite"),f=e("regl"),u=e("./math"),c=e("./utils");var l;(l||(l={})).MONOSPACE="Courier, monospace";var d;!function(e){e[e.LABEL=12]="LABEL"}(d||(d={}));class p{constructor(e){this.profile=e,this.layers=[],this.duration=0,this.frameColors=new Map,e.forEachSample(this.appendSample.bind(this)),this.layers=this.layers.map(p.mergeAdjacentFrames),this.selectFrameColors(e)}getDuration(){return this.duration}getLayers(){return this.layers}getFrameColors(){return this.frameColors}appendFrame(e,t,n,r){for(;e>=this.layers.length;)this.layers.push([]);const i={node:t,start:this.duration,end:this.duration+n,parent:r,children:[]};return this.layers[e].push(i),r&&r.children.push(i),i}appendSample(e,t){let n=null;for(let r=0;r0?t[t.length-1]:null;e&&p.shouldMergeFrames(e,n)?(t.pop(),t.push(p.mergeFrames(e,n))):t.push(n)}return t}selectFrameColors(e){function t(e){return(e.file||"").split("/").concat(e.name.split(/\W/))}function n(e,n){const r=t(e),i=t(n),a=Math.min(r.length,i.length);let o=0;for(let e=0;ei.join()?s:-s}const r=[];this.profile.forEachFrame(e=>r.push(e)),r.sort(n);const i=[];let a=0;for(let e=0;e{e?(this.canvas=e,this.ctx=this.canvas.getContext("webgl"),this.renderCanvas()):this.canvas=null}),this.overlayCanvasRef=(e=>{e?(this.overlayCanvas=e,this.overlayCtx=this.overlayCanvas.getContext("2d"),this.renderCanvas()):(this.overlayCanvas=null,this.overlayCtx=null)}),this.LOGICAL_VIEW_SPACE_FRAME_HEIGHT=16,this.renderCanvas=c.atMostOnceAFrame(()=>{!this.canvas||this.canvas.getBoundingClientRect().width<2?requestAnimationFrame(()=>this.renderCanvas()):(this.renderer||this.preprocess(this.props.flamechart),this.renderRects(),this.renderLabels())}),this.lastDragPos=null,this.onMouseDown=(e=>{this.lastDragPos=new u.Vec2(e.offsetX,e.offsetY)}),this.onMouseDrag=(e=>{if(!this.lastDragPos)return;const t=new u.Vec2(e.offsetX,e.offsetY);this.pan(this.lastDragPos.minus(t)),this.lastDragPos=t}),this.onMouseMove=(e=>{if(this.lastDragPos)return e.preventDefault(),void this.onMouseDrag(e);this.hoveredLabel=null;const t=new u.Vec2(e.offsetX,e.offsetY),n=this.logicalToPhysicalViewSpace().transformPosition(t),r=this.configSpaceToPhysicalViewSpace().inverseTransformPosition(n);if(r){for(let e of this.labels)if(e.configSpaceBounds.contains(r)){this.hoveredLabel=e;break}this.props.setNodeHover(this.hoveredLabel?this.hoveredLabel.node:null,t),this.renderCanvas()}}),this.onWheel=(e=>{if(e.preventDefault(),e.metaKey||e.ctrlKey){let t=1+e.deltaY/100;e.ctrlKey&&(t=1+e.deltaY/40),this.zoom(new u.Vec2(e.offsetX,e.offsetY),t)}else this.pan(new u.Vec2(e.deltaX,e.deltaY)),this.hoveredLabel=null,this.props.setNodeHover(null,new u.Vec2);this.renderCanvas()}),this.onWindowMouseUp=(e=>{this.lastDragPos=null})}preprocess(e){if(!this.canvas||!this.ctx)return;const t=[],r=[],i=e.getLayers(),a=e.getFrameColors();this.labels=[];for(let e=0;e{this.setState({hoveredNode:e,logicalSpaceMouse:t})}),this.containerRef=(e=>{this.container=e||null}),this.state={hoveredNode:null,logicalSpaceMouse:new u.Vec2}}formatTime(e){const t=this.props.flamechart.getDuration();return`${(e/1e3).toFixed(2)}ms (${(100*e/t).toFixed()}%)`}renderTooltip(){if(!this.container)return null;const{hoveredNode:e,logicalSpaceMouse:t}=this.state;if(!e)return null;const{width:n,height:r}=this.container.getBoundingClientRect(),i={};return t.x+7+v.TOOLTIP_WIDTH_MAX{const r=[],i=[],a=(e,t)=>{function n(e){r.push(e.flatten()),i.push(t)}n(e.topLeft()),n(e.bottomLeft()),n(e.topRight()),n(e.bottomLeft()),n(e.topRight()),n(e.bottomRight())};for(let e=0;et.configSpaceToNDC.flatten(),physicalSize:(e,t)=>t.physicalSize.flatten()},primitive:"triangles",count:i.length})})},{"./math":4,"./utils":40,aphrodite:7,preact:35,regl:37}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("../profile");n.importFromBGFlameGraph=function(e){const t=function(e){const t=[];return e.replace(/^(.*) (\d+)$/gm,(e,n,r)=>(t.push({stack:n.split(";").map(e=>({key:e,name:e})),duration:parseInt(r,10)}),e)),t}(e),n=t.reduce((e,t)=>e+t.duration,0),i=new r.Profile(n);for(let e of t)i.appendSample(e.stack,e.duration);return i}},{"../profile":39}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("preact"),i=e("aphrodite"),a=e("./import/bg-flamegraph"),o=e("./flamechart");const s=i.StyleSheet.create({root:{width:"100vw",height:"100vh",overflow:"hidden"}});r.render(r.h(class extends r.Component{constructor(){super(...arguments),this.onDrop=(e=>{const t=new FileReader;t.addEventListener("loadend",()=>{const e=a.importFromBGFlameGraph(t.result),n=new o.Flamechart(e);this.setState({profile:e,flamechart:n})}),t.readAsText(e.dataTransfer.files.item(0)),e.preventDefault()}),this.onDragOver=(e=>{e.preventDefault()})}componentDidMount(){window.addEventListener("resize",()=>{this.forceUpdate()})}render(){const{flamechart:e}=this.state;return r.h("div",{onDrop:this.onDrop,onDragOver:this.onDragOver,className:i.css(s.root)},e&&r.h(o.FlamechartView,{flamechart:e}))}},null),document.body)},{"./flamechart":1,"./import/bg-flamegraph":2,aphrodite:7,preact:35}],4:[function(e,t,n){"use strict";function r(e,t,n){return en?n:e}Object.defineProperty(n,"__esModule",{value:!0}),n.clamp=r;class i{constructor(e=0,t=0){this.x=e,this.y=t}withX(e){return new i(e,this.y)}withY(e){return new i(this.x,e)}plus(e){return new i(this.x+e.x,this.y+e.y)}minus(e){return new i(this.x-e.x,this.y-e.y)}times(e){return new i(this.x*e,this.y*e)}timesPointwise(e){return new i(this.x*e.x,this.y*e.y)}dot(e){return this.x*e.x+this.y*e.y}length2(){return this.dot(this)}length(){return Math.sqrt(this.length2())}static min(e,t){return new i(Math.min(e.x,t.x),Math.min(e.y,t.y))}static max(e,t){return new i(Math.max(e.x,t.x),Math.max(e.y,t.y))}flatten(){return[this.x,this.y]}}n.Vec2=i;class a{constructor(e=1,t=0,n=0,r=0,i=1,a=0){this.m00=e,this.m01=t,this.m02=n,this.m10=r,this.m11=i,this.m12=a}withScale(e){let{m00:t,m01:n,m02:r,m10:i,m11:o,m12:s}=this;return t=e.x,o=e.y,new a(t,n,r,i,o,s)}static withScale(e){return(new a).withScale(e)}scaledBy(e){return a.withScale(e).times(this)}getScale(){return new i(this.m00,this.m11)}withTranslation(e){let{m00:t,m01:n,m02:r,m10:i,m11:o,m12:s}=this;return r=e.x,s=e.y,new a(t,n,r,i,o,s)}static withTranslation(e){return(new a).withTranslation(e)}getTranslation(){return new i(this.m02,this.m12)}translatedBy(e){return a.withTranslation(e).times(this)}static betweenRects(e,t){return a.withTranslation(e.origin.times(-1)).scaledBy(new i(t.size.x/e.size.x,t.size.y/e.size.y)).translatedBy(t.origin)}times(e){const t=this.m00*e.m00+this.m01*e.m10,n=this.m00*e.m01+this.m01*e.m11,r=this.m00*e.m02+this.m01*e.m12+this.m02,i=this.m10*e.m00+this.m11*e.m10,o=this.m10*e.m01+this.m11*e.m11,s=this.m10*e.m02+this.m11*e.m12+this.m12;return new a(t,n,r,i,o,s)}timesScalar(e){const{m00:t,m01:n,m02:r,m10:i,m11:o,m12:s}=this;return new a(e*t,e*n,e*r,e*i,e*o,e*s)}det(){const{m00:e,m01:t,m02:n,m10:r,m11:i,m12:a}=this;return e*(1*i-0*a)-t*(1*r-0*a)+n*(0*r-0*i)}adj(){const{m00:e,m01:t,m02:n,m10:r,m11:i,m12:o}=this;return new a(+(1*i-0*o),-(1*t-0*n),+(t*o-n*i),-(1*r-0*o),+(1*e-0*n),-(e*o-n*r))}inverted(){const e=this.det();if(0===e)return null;return this.adj().timesScalar(1/e)}transformVector(e){return new i(e.x*this.m00+e.y*this.m01,e.x*this.m10+e.y*this.m11)}inverseTransformVector(e){const t=this.inverted();return t?t.transformVector(e):null}transformPosition(e){return new i(e.x*this.m00+e.y*this.m01+this.m02,e.x*this.m10+e.y*this.m11+this.m12)}inverseTransformPosition(e){const t=this.inverted();return t?t.transformPosition(e):null}transformRect(e){return new o(this.transformPosition(e.origin),this.transformVector(e.size))}flatten(){return[this.m00,this.m10,0,this.m01,this.m11,0,this.m02,this.m12,1]}}n.AffineTransform=a;class o{constructor(e=new i,t=new i){this.origin=e,this.size=t}isEmpty(){return 0==this.width()||0==this.height()}width(){return this.size.x}height(){return this.size.y}left(){return this.origin.x}right(){return this.left()+this.width()}top(){return this.origin.y}bottom(){return this.top()+this.height()}topLeft(){return this.origin}topRight(){return this.origin.plus(new i(this.width(),0))}bottomRight(){return this.origin.plus(this.size)}bottomLeft(){return this.origin.plus(new i(0,this.height()))}withOrigin(e){return new o(e,this.size)}withSize(e){return new o(this.origin,e)}closestPointTo(e){return new i(r(e.x,this.left(),this.right()),r(e.y,this.top(),this.bottom()))}distanceFrom(e){return e.minus(this.closestPointTo(e)).length()}contains(e){return 0===this.distanceFrom(e)}intersectWith(e){const t=i.max(this.topLeft(),e.topLeft()),n=i.max(t,i.min(this.bottomRight(),e.bottomRight()));return new o(t,n.minus(t))}}n.Rect=o},{}],5:[function(e,t,n){(function(n){"use strict";var r=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=Object.assign||function(e){for(var t=1;t0&&function(e){if(null==f&&null==(f=document.querySelector("style[data-aphrodite]"))){var t=document.head||document.getElementsByTagName("head")[0];(f=document.createElement("style")).type="text/css",f.setAttribute("data-aphrodite",""),t.appendChild(f)}f.styleSheet?f.styleSheet.cssText+=e:f.appendChild(document.createTextNode(e))}(e)};n.flushToStyleTag=b;n.getRenderedClassNames=function(){return Object.keys(c)};n.addRenderedClassNames=function(e){e.forEach(function(e){c[e]=!0})};n.injectAndGetClassName=function(e,n,r){var i={classNameBits:[],definitionBits:[]};if(function e(t,n){for(var r=0;rf){for(var t=0,n=o.length-s;t0&&(e[f]=c)}else{var m=(0,a.default)(r,f,u,e,n);m&&(e[f]=m),(0,i.default)(n,f,e)}}return e}var n=e.prefixMap,r=e.plugins;return t};var i=r(e("../utils/prefixProperty")),a=r(e("../utils/prefixValue")),o=r(e("../utils/addNewValuesOnly")),s=r(e("../utils/isObject"));t.exports=n.default},{"../utils/addNewValuesOnly":30,"../utils/isObject":32,"../utils/prefixProperty":33,"../utils/prefixValue":34}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if("string"==typeof t&&!(0,r.default)(t)&&t.indexOf("calc(")>-1)return i.map(function(e){return t.replace(/calc\(/g,e+"calc(")})};var r=function(e){return e&&e.__esModule?e:{default:e}}(e("css-in-js-utils/lib/isPrefixedValue")),i=["-webkit-","-moz-",""];t.exports=n.default},{"css-in-js-utils/lib/isPrefixedValue":15}],19:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if("string"==typeof t&&!(0,r.default)(t)&&t.indexOf("cross-fade(")>-1)return i.map(function(e){return t.replace(/cross-fade\(/g,e+"cross-fade(")})};var r=function(e){return e&&e.__esModule?e:{default:e}}(e("css-in-js-utils/lib/isPrefixedValue")),i=["-webkit-",""];t.exports=n.default},{"css-in-js-utils/lib/isPrefixedValue":15}],20:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if("cursor"===e&&i.hasOwnProperty(t))return r.map(function(e){return e+t})};var r=["-webkit-","-moz-",""],i={"zoom-in":!0,"zoom-out":!0,grab:!0,grabbing:!0};t.exports=n.default},{}],21:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if("string"==typeof t&&!(0,r.default)(t)&&t.indexOf("filter(")>-1)return i.map(function(e){return t.replace(/filter\(/g,e+"filter(")})};var r=function(e){return e&&e.__esModule?e:{default:e}}(e("css-in-js-utils/lib/isPrefixedValue")),i=["-webkit-",""];t.exports=n.default},{"css-in-js-utils/lib/isPrefixedValue":15}],22:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if("display"===e&&r.hasOwnProperty(t))return r[t]};var r={flex:["-webkit-box","-moz-box","-ms-flexbox","-webkit-flex","flex"],"inline-flex":["-webkit-inline-box","-moz-inline-box","-ms-inline-flexbox","-webkit-inline-flex","inline-flex"]};t.exports=n.default},{}],23:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){i.hasOwnProperty(e)&&(n[i[e]]=r[t]||t)};var r={"space-around":"distribute","space-between":"justify","flex-start":"start","flex-end":"end"},i={alignContent:"msFlexLinePack",alignSelf:"msFlexItemAlign",alignItems:"msFlexAlign",justifyContent:"msFlexPack",order:"msFlexOrder",flexGrow:"msFlexPositive",flexShrink:"msFlexNegative",flexBasis:"msFlexPreferredSize"};t.exports=n.default},{}],24:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){"flexDirection"===e&&"string"==typeof t&&(t.indexOf("column")>-1?n.WebkitBoxOrient="vertical":n.WebkitBoxOrient="horizontal",t.indexOf("reverse")>-1?n.WebkitBoxDirection="reverse":n.WebkitBoxDirection="normal"),i.hasOwnProperty(e)&&(n[i[e]]=r[t]||t)};var r={"space-around":"justify","space-between":"justify","flex-start":"start","flex-end":"end","wrap-reverse":"multiple",wrap:"multiple"},i={alignItems:"WebkitBoxAlign",justifyContent:"WebkitBoxPack",flexWrap:"WebkitBoxLines"};t.exports=n.default},{}],25:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if("string"==typeof t&&!(0,r.default)(t)&&a.test(t))return i.map(function(e){return e+t})};var r=function(e){return e&&e.__esModule?e:{default:e}}(e("css-in-js-utils/lib/isPrefixedValue")),i=["-webkit-","-moz-",""],a=/linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/;t.exports=n.default},{"css-in-js-utils/lib/isPrefixedValue":15}],26:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if("string"==typeof t&&!(0,r.default)(t)&&t.indexOf("image-set(")>-1)return i.map(function(e){return t.replace(/image-set\(/g,e+"image-set(")})};var r=function(e){return e&&e.__esModule?e:{default:e}}(e("css-in-js-utils/lib/isPrefixedValue")),i=["-webkit-",""];t.exports=n.default},{"css-in-js-utils/lib/isPrefixedValue":15}],27:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if("position"===e&&"sticky"===t)return["-webkit-sticky","sticky"]},t.exports=n.default},{}],28:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if(i.hasOwnProperty(e)&&a.hasOwnProperty(t))return r.map(function(e){return e+t})};var r=["-webkit-","-moz-",""],i={maxHeight:!0,maxWidth:!0,width:!0,height:!0,columnWidth:!0,minWidth:!0,minHeight:!0},a={"min-content":!0,"max-content":!0,"fill-available":!0,"fit-content":!0,"contain-floats":!0};t.exports=n.default},{}],29:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n,r){if("string"==typeof t&&s.hasOwnProperty(e)){var u=function(e,t){if((0,a.default)(e))return e;for(var n=e.split(/,(?![^()]*(?:\([^()]*\))?\))/g),r=0,o=n.length;r-1&&"order"!==l)for(var d=t[c],p=0,m=d.length;p-1)return c;var l=u.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function(e){return!/-webkit-|-ms-/.test(e)}).join(",");return e.indexOf("Moz")>-1?l:(n["Webkit"+(0,o.default)(e)]=c,n["Moz"+(0,o.default)(e)]=l,u)}};var i=r(e("css-in-js-utils/lib/hyphenateProperty")),a=r(e("css-in-js-utils/lib/isPrefixedValue")),o=r(e("../../utils/capitalizeString")),s={transition:!0,transitionProperty:!0,WebkitTransition:!0,WebkitTransitionProperty:!0,MozTransition:!0,MozTransitionProperty:!0},f={Webkit:"-webkit-",Moz:"-moz-",ms:"-ms-"};t.exports=n.default},{"../../utils/capitalizeString":31,"css-in-js-utils/lib/hyphenateProperty":14,"css-in-js-utils/lib/isPrefixedValue":15}],30:[function(e,t,n){"use strict";function r(e,t){-1===e.indexOf(t)&&e.push(t)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t){if(Array.isArray(t))for(var n=0,i=t.length;n2;)k.push(arguments[a]);for(t&&null!=t.children&&(k.length||k.push(t.children),delete t.children);k.length;)if((r=k.pop())&&void 0!==r.pop)for(a=r.length;a--;)k.push(r[a]);else"boolean"==typeof r&&(r=null),(i="function"!=typeof e)&&(null==r?r="":"number"==typeof r?r=String(r):"string"!=typeof r&&(i=!1)),i&&n?o[o.length-1]+=r:o===S?o=[r]:o.push(r),n=i;var s=new function(){};return s.nodeName=e,s.children=o,s.attributes=null==t?void 0:t,s.key=null==t?void 0:t.key,void 0!==_.vnode&&_.vnode(s),s}function n(e,t){for(var n in t)e[n]=t[n];return e}function r(e){!e.__d&&(e.__d=!0)&&1==O.push(e)&&(_.debounceRendering||T)(i)}function i(){var e,t=O;for(O=[];e=t.pop();)e.__d&&y(e)}function a(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&o(e,t.nodeName):n||e._componentConstructor===t.nodeName}function o(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function s(e){var t=n({},e.attributes);t.children=e.children;var r=e.nodeName.defaultProps;if(void 0!==r)for(var i in r)void 0===t[i]&&(t[i]=r[i]);return t}function f(e){var t=e.parentNode;t&&t.removeChild(e)}function u(e,t,n,r,i){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)n&&n(null),r&&r(e);else if("class"!==t||i)if("style"===t){if(r&&"string"!=typeof r&&"string"!=typeof n||(e.style.cssText=r||""),r&&"object"==typeof r){if("string"!=typeof n)for(var a in n)a in r||(e.style[a]="");for(var a in r)e.style[a]="number"==typeof r[a]&&!1===A.test(a)?r[a]+"px":r[a]}}else if("dangerouslySetInnerHTML"===t)r&&(e.innerHTML=r.__html||"");else if("o"==t[0]&&"n"==t[1]){var o=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),r?n||e.addEventListener(t,c,o):e.removeEventListener(t,c,o),(e.__l||(e.__l={}))[t]=r}else if("list"!==t&&"type"!==t&&!i&&t in e)!function(e,t,n){try{e[t]=n}catch(e){}}(e,t,null==r?"":r),null!=r&&!1!==r||e.removeAttribute(t);else{var s=i&&t!==(t=t.replace(/^xlink\:?/,""));null==r||!1===r?s?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof r&&(s?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),r):e.setAttribute(t,r))}else e.className=r||""}function c(e){return this.__l[e.type](_.event&&_.event(e)||e)}function l(){for(var e;e=C.pop();)_.afterMount&&_.afterMount(e),e.componentDidMount&&e.componentDidMount()}function d(e,t,n,r,i,a){E++||(j=null!=i&&void 0!==i.ownerSVGElement,D=null!=e&&!("__preactattr_"in e));var o=p(e,t,n,r,a);return i&&o.parentNode!==i&&i.appendChild(o),--E||(D=!1,a||l()),o}function p(e,t,n,r,i){var c=e,l=j;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||i)?e.nodeValue!=t&&(e.nodeValue=t):(c=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(c,e),m(e,!0))),c.__preactattr_=!0,c;var d=t.nodeName;if("function"==typeof d)return function(e,t,n,r){var i=e&&e._component,a=i,o=e,f=i&&e._componentConstructor===t.nodeName,u=f,c=s(t);for(;i&&!u&&(i=i.__u);)u=i.constructor===t.nodeName;i&&u&&(!r||i._component)?(v(i,c,3,n,r),e=i.base):(a&&!f&&(x(a),e=o=null),i=b(t.nodeName,c,n),e&&!i.__b&&(i.__b=e,o=null),v(i,c,1,n,r),e=i.base,o&&e!==o&&(o._component=null,m(o,!1)));return e}(e,t,n,r);if(j="svg"===d||"foreignObject"!==d&&j,d=String(d),(!e||!o(e,d))&&(c=function(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}(d,j),e)){for(;e.firstChild;)c.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(c,e),m(e,!0)}var h=c.firstChild,g=c.__preactattr_,y=t.children;if(null==g){g=c.__preactattr_={};for(var w=c.attributes,_=w.length;_--;)g[w[_].name]=w[_].value}return!D&&y&&1===y.length&&"string"==typeof y[0]&&null!=h&&void 0!==h.splitText&&null==h.nextSibling?h.nodeValue!=y[0]&&(h.nodeValue=y[0]):(y&&y.length||null!=h)&&function(e,t,n,r,i){var o,s,u,c,l,d=e.childNodes,h=[],b={},g=0,v=0,y=d.length,x=0,w=t?t.length:0;if(0!==y)for(var _=0;_2?[].slice.call(arguments,2):t.children)},Component:w,render:function(e,t,n){return d(n,e,{},!1,t,!1)},rerender:i,options:_};void 0!==t?t.exports=P:self.preact=P}()},{}],36:[function(e,t,n){function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(c===setTimeout)return setTimeout(e,0);if((c===r||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function o(){h&&p&&(h=!1,p.length?m=p.concat(m):b=-1,m.length&&s())}function s(){if(!h){var e=a(o);h=!0;for(var t=m.length;t;){for(p=m,m=[];++b1)for(var n=1;n1&&t===n&&('"'===t||"'"===t))return['"'+v(e.substr(1,e.length-2))+'"'];var r=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(e);if(r)return y(e.substr(0,r.index)).concat(y(r[1])).concat(y(e.substr(r.index+r[0].length)));var i=e.split(".");if(1===i.length)return['"'+v(e)+'"'];for(var a=[],o=0;o0,"invalid pixel ratio")):r=(i=a).canvas:t=a:ke.raise("invalid arguments to regl"),t&&("canvas"===t.nodeName.toLowerCase()?r=t:n=t),!i){if(!r){ke("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var p=function(e,t,n){function r(){var t=window.innerWidth,r=window.innerHeight;if(e!==document.body){var a=e.getBoundingClientRect();t=a.right-a.left,r=a.bottom-a.top}i.width=n*t,i.height=n*r,ue(i.style,{width:t+"px",height:r+"px"})}var i=document.createElement("canvas");return ue(i.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(i),e===document.body&&(i.style.position="absolute",ue(e.style,{margin:0,padding:0})),window.addEventListener("resize",r,!1),r(),{canvas:i,onDestroy:function(){window.removeEventListener("resize",r),e.removeChild(i)}}}(n||document.body,0,u);if(!p)return null;r=p.canvas,d=p.onDestroy}i=function(e,t){function n(n){try{return e.getContext(n,t)}catch(e){return null}}return n("webgl")||n("experimental-webgl")||n("webgl-experimental")}(r,o)}return i?{gl:i,canvas:r,container:n,extensions:s,optionalExtensions:f,pixelRatio:u,profile:c,onDone:l,onDestroy:d}:(d(),l("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function S(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||fe(e.data))}function T(e,t){for(var n=Array(e),r=0;r65535)<<4,e>>>=t,n=(e>255)<<3,e>>>=n,t|=n,n=(e>15)<<2,e>>>=n,t|=n,n=(e>3)<<1,e>>>=n,(t|=n)|e>>1}function O(e){var t=function(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}(e),n=Be[A(t)>>2];return n.length>0?n.pop():new ArrayBuffer(t)}function C(e){Be[A(e.byteLength)>>2].push(e)}function E(e,t,n,r,i,a){for(var o=a,s=0;s>>31<<15,a=(r<<1>>>24)-127,o=r>>13&1023;if(a<-24)t[n]=i;else if(a<-14){var s=-14-a;t[n]=i+(o+1024>>s)}else t[n]=a>15?i+31744:i+(a+15<<10)+o}return t}function z(e){return Array.isArray(e)||fe(e)}function F(e){return"[object "+e+"]"}function R(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function B(e){if(!Array.isArray(e))return!1;return!(0===e.length||!z(e[0]))}function L(e){return Object.prototype.toString.call(e)}function N(e){return L(e)===kn}function V(e){if(!e)return!1;var t=L(e);return On.indexOf(t)>=0||(R(e)||B(e)||S(e))}function I(e){return 0|se[Object.prototype.toString.call(e)]}function H(e,t){return Le.allocType(e.type===Mt?Xt:e.type,t)}function U(e,t){e.type===Mt?(e.data=W(t),Le.freeType(t)):e.data=t}function G(e,t,n,r,i,a){var o;if(o=void 0!==En[e]?En[e]:_n[e]*Cn[t],a&&(o*=6),i){for(var s=0,f=n;f>=1;)s+=o*f*f,f/=2;return s}return o*n*r}function q(e,t,n,r,i,a,o){function s(){this.internalformat=bt,this.format=bt,this.type=Gt,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=0,this.width=0,this.height=0,this.channels=0}function f(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 u(e,r){if("object"==typeof r&&r){if("premultiplyAlpha"in r&&(ke.type(r.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=r.premultiplyAlpha),"flipY"in r&&(ke.type(r.flipY,"boolean","invalid texture flip"),e.flipY=r.flipY),"alignment"in r&&(ke.oneOf(r.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=r.alignment),"colorSpace"in r&&(ke.parameter(r.colorSpace,F,"invalid colorSpace"),e.colorSpace=F[r.colorSpace]),"type"in r){var i=r.type;ke(t.oes_texture_float||!("float"===i||"float32"===i),"you must enable the OES_texture_float extension in order to use floating point textures."),ke(t.oes_texture_half_float||!("half float"===i||"float16"===i),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),ke(t.webgl_depth_texture||!("uint16"===i||"uint32"===i||"depth stencil"===i),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),ke.parameter(i,q,"invalid texture type"),e.type=q[i]}var a=e.width,o=e.height,s=e.channels,f=!1;"shape"in r?(ke(Array.isArray(r.shape)&&r.shape.length>=2,"shape must be an array"),a=r.shape[0],o=r.shape[1],3===r.shape.length&&(s=r.shape[2],ke(s>0&&s<=4,"invalid number of channels"),f=!0),ke(a>=0&&a<=n.maxTextureSize,"invalid width"),ke(o>=0&&o<=n.maxTextureSize,"invalid height")):("radius"in r&&(a=o=r.radius,ke(a>=0&&a<=n.maxTextureSize,"invalid radius")),"width"in r&&(a=r.width,ke(a>=0&&a<=n.maxTextureSize,"invalid width")),"height"in r&&(o=r.height,ke(o>=0&&o<=n.maxTextureSize,"invalid height")),"channels"in r&&(s=r.channels,ke(s>0&&s<=4,"invalid number of channels"),f=!0)),e.width=0|a,e.height=0|o,e.channels=0|s;var u=!1;if("format"in r){var c=r.format;ke(t.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),ke.parameter(c,Q,"invalid texture format");var l=e.internalformat=Q[c];e.format=ne[l],c in q&&("type"in r||(e.type=q[c])),c in X&&(e.compressed=!0),u=!0}!f&&u?e.channels=_n[e.format]:f&&!u?e.channels!==wn[e.format]&&(e.format=e.internalformat=wn[e.channels]):u&&f&&ke(e.channels===_n[e.format],"number of channels inconsistent with specified format")}}function c(t){e.pixelStorei(hn,t.flipY),e.pixelStorei(bn,t.premultiplyAlpha),e.pixelStorei(gn,t.colorSpace),e.pixelStorei(mn,t.unpackAlignment)}function l(){s.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function d(e,t){var r=null;if(V(t)?r=t:t&&(ke.type(t,"object","invalid pixel data type"),u(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),V(t.data)&&(r=t.data)),ke(!e.compressed||r instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),t.copy){ke(!r,"can not specify copy and data field for the same texture");var a=i.viewportWidth,o=i.viewportHeight;e.width=e.width||a-e.xOffset,e.height=e.height||o-e.yOffset,e.needsCopy=!0,ke(e.xOffset>=0&&e.xOffset=0&&e.yOffset0&&e.width<=a&&e.height>0&&e.height<=o,"copy texture read out of bounds")}else if(r){if(fe(r))e.channels=e.channels||4,e.data=r,"type"in t||e.type!==Gt||(e.type=I(r));else if(R(r))e.channels=e.channels||4,function(e,t){var n=t.length;switch(e.type){case Gt:case qt:case Qt:case Xt:var r=Le.allocType(e.type,n);r.set(t),e.data=r;break;case Mt:e.data=W(t);break;default:ke.raise("unsupported texture type, must specify a typed array")}}(e,r),e.alignment=1,e.needsFree=!0;else if(S(r)){var s=r.data;Array.isArray(s)||e.type!==Gt||(e.type=I(s));var f,c,l,d,p,m,h=r.shape,b=r.stride;3===h.length?(l=h[2],m=b[2]):(ke(2===h.length,"invalid ndarray pixel data, must be 2 or 3D"),l=1,m=1),f=h[0],c=h[1],d=b[0],p=b[1],e.alignment=1,e.width=f,e.height=c,e.channels=l,e.format=e.internalformat=wn[l],e.needsFree=!0,function(e,t,n,r,i,a){for(var o=e.width,s=e.height,f=e.channels,u=H(e,o*s*f),c=0,l=0;l=0,"oes_texture_float extension not enabled"):e.type===Mt&&ke(n.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function p(t,n,i){var a=t.element,o=t.data,s=t.internalformat,f=t.format,u=t.type,l=t.width,d=t.height;c(t),a?e.texImage2D(n,i,f,f,u,a):t.compressed?e.compressedTexImage2D(n,i,s,l,d,0,o):t.needsCopy?(r(),e.copyTexImage2D(n,i,f,t.xOffset,t.yOffset,l,d,0)):e.texImage2D(n,i,f,l,d,0,f,u,o)}function m(t,n,i,a,o){var s=t.element,f=t.data,u=t.internalformat,l=t.format,d=t.type,p=t.width,m=t.height;c(t),s?e.texSubImage2D(n,o,i,a,l,d,s):t.compressed?e.compressedTexSubImage2D(n,o,i,a,u,p,m,f):t.needsCopy?(r(),e.copyTexSubImage2D(n,o,i,a,t.xOffset,t.yOffset,p,m)):e.texSubImage2D(n,o,i,a,p,m,l,d,f)}function h(){return re.pop()||new l}function b(e){e.needsFree&&Le.freeType(e.data),l.call(e),re.push(e)}function g(e,t,n){var r=e.images[0]=h();e.mipmask=1,r.width=e.width=t,r.height=e.height=n,r.channels=e.channels=4}function v(e,t){var n=null;if(V(t))f(n=e.images[0]=h(),e),d(n,t),e.mipmask=1;else if(u(e,t),Array.isArray(t.mipmap))for(var r=t.mipmap,i=0;i>=i,n.height>>=i,d(n,r[i]),e.mipmask|=1<=0&&(e.genMipmaps=!0)}if("mag"in t){var i=t.mag;ke.parameter(i,M),e.magFilter=M[i]}var a=e.wrapS,o=e.wrapT;if("wrap"in t){var s=t.wrap;"string"==typeof s?(ke.parameter(s,D),a=o=D[s]):Array.isArray(s)&&(ke.parameter(s[0],D),ke.parameter(s[1],D),a=D[s[0]],o=D[s[1]])}else{if("wrapS"in t){var f=t.wrapS;ke.parameter(f,D),a=D[f]}if("wrapT"in t){var u=t.wrapT;ke.parameter(u,D),o=D[u]}}if(e.wrapS=a,e.wrapT=o,"anisotropic"in t){var c=t.anisotropic;ke("number"==typeof c&&c>=1&&c<=n.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var l=!1;switch(typeof t.mipmap){case"string":ke.parameter(t.mipmap,j,"invalid mipmap hint"),e.mipmapHint=j[t.mipmap],e.genMipmaps=!0,l=!0;break;case"boolean":l=e.genMipmaps=t.mipmap;break;case"object":ke(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,l=!0;break;default:ke.raise("invalid mipmap type")}!l||"min"in t||(e.minFilter=an)}}function T(n,r){e.texParameteri(r,tn,n.minFilter),e.texParameteri(r,en,n.magFilter),e.texParameteri(r,Yt,n.wrapS),e.texParameteri(r,$t,n.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(r,pn,n.anisotropic),n.genMipmaps&&(e.hint(un,n.mipmapHint),e.generateMipmap(r))}function A(t){s.call(this),this.mipmask=0,this.internalformat=bt,this.id=ae++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new _,o.profile&&(this.stats={size:0})}function O(t){e.activeTexture(yn),e.bindTexture(t.target,t.texture)}function C(){var t=ce[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(pt,null)}function E(t){var n=t.texture;ke(n,"must not double destroy texture");var r=t.unit,i=t.target;r>=0&&(e.activeTexture(yn+r),e.bindTexture(i,null),ce[r]=null),e.deleteTexture(n),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete oe[t.id],a.textureCount--}var j={"don't care":cn,"dont care":cn,nice:dn,fast:ln},D={repeat:Kt,clamp:Zt,mirror:Jt},M={nearest:nn,linear:rn},P=ue({mipmap:fn,"nearest mipmap nearest":an,"linear mipmap nearest":on,"nearest mipmap linear":sn,"linear mipmap linear":fn},M),F={none:0,browser:vn},q={uint8:Gt,rgba4:St,rgb565:At,"rgb5 a1":Tt},Q={alpha:gt,luminance:yt,"luminance alpha":xt,rgb:vt,rgba:bt,rgba4:wt,"rgb5 a1":_t,rgb565:kt},X={};t.ext_srgb&&(Q.srgb=jt,Q.srgba=Dt),t.oes_texture_float&&(q.float32=q.float=Xt),t.oes_texture_half_float&&(q.float16=q["half float"]=Mt),t.webgl_depth_texture&&(ue(Q,{depth:Ct,"depth stencil":Et}),ue(q,{uint16:qt,uint32:Qt,"depth stencil":Ot})),t.webgl_compressed_texture_s3tc&&ue(X,{"rgb s3tc dxt1":Pt,"rgba s3tc dxt1":Wt,"rgba s3tc dxt3":zt,"rgba s3tc dxt5":Ft}),t.webgl_compressed_texture_atc&&ue(X,{"rgb atc":Rt,"rgba atc explicit alpha":Bt,"rgba atc interpolated alpha":Lt}),t.webgl_compressed_texture_pvrtc&&ue(X,{"rgb pvrtc 4bppv1":Nt,"rgb pvrtc 2bppv1":Vt,"rgba pvrtc 4bppv1":It,"rgba pvrtc 2bppv1":Ht}),t.webgl_compressed_texture_etc1&&(X["rgb etc1"]=Ut);var Y=Array.prototype.slice.call(e.getParameter(dt));Object.keys(X).forEach(function(e){var t=X[e];Y.indexOf(t)>=0&&(Q[e]=t)});var $=Object.keys(Q);n.textureFormats=$;var K=[];Object.keys(Q).forEach(function(e){var t=Q[e];K[t]=e});var Z=[];Object.keys(q).forEach(function(e){var t=q[e];Z[t]=e});var J=[];Object.keys(M).forEach(function(e){var t=M[e];J[t]=e});var ee=[];Object.keys(P).forEach(function(e){var t=P[e];ee[t]=e});var te=[];Object.keys(D).forEach(function(e){var t=D[e];te[t]=e});var ne=$.reduce(function(e,t){var n=Q[t];return n===yt||n===gt||n===yt||n===xt||n===Ct||n===Et?e[n]=n:n===_t||t.indexOf("rgba")>=0?e[n]=bt:e[n]=vt,e},{}),re=[],ie=[],ae=0,oe={},se=n.maxTextureUnits,ce=Array(se).map(function(){return null});return ue(A.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(t<0){for(var n=0;n0)continue;r.unit=-1}ce[n]=this,t=n;break}t>=se&&ke.raise("insufficient number of texture units"),o.profile&&a.maxTextureUnits>u)-a,c.height=c.height||(s.height>>u)-o,ke(s.type===c.type&&s.format===c.format&&s.internalformat===c.internalformat,"incompatible format for texture.subimage"),ke(a>=0&&o>=0&&a+c.width<=s.width&&o+c.height<=s.height,"texture.subimage write out of bounds"),ke(s.mipmask&1<>f;++f)e.texImage2D(pt,f,s.format,r>>f,a>>f,0,s.format,s.type,null);return C(),o.profile&&(s.stats.size=G(s.internalformat,s.type,r,a,!1,!1)),i},i._reglType="texture2d",i._texture=s,o.profile&&(i.stats=s.stats),i.destroy=function(){s.decRef()},i},createCube:function(t,r,i,s,c,l){function p(e,t,r,i,a,s){var c,l=S.texInfo;for(_.call(l),c=0;c<6;++c)E[c]=x();if("number"!=typeof e&&e)if("object"==typeof e)if(t)v(E[0],e),v(E[1],t),v(E[2],r),v(E[3],i),v(E[4],a),v(E[5],s);else if(k(l,e),u(S,e),"faces"in e){var d=e.faces;for(ke(Array.isArray(d)&&6===d.length,"cube faces must be a length 6 array"),c=0;c<6;++c)ke("object"==typeof d[c]&&!!d[c],"invalid input for cube map face"),f(E[c],S),v(E[c],d[c])}else for(c=0;c<6;++c)v(E[c],e);else ke.raise("invalid arguments to cube map");else{var m=0|e||1;for(c=0;c<6;++c)g(E[c],m,m)}for(f(S,E[0]),l.genMipmaps?S.mipmask=(E[0].width<<1)-1:S.mipmask=E[0].mipmask,ke.textureCube(S,l,E,n),S.internalformat=E[0].internalformat,p.width=E[0].width,p.height=E[0].height,O(S),c=0;c<6;++c)y(E[c],ht+c);for(T(l,mt),C(),o.profile&&(S.stats.size=G(S.internalformat,S.type,p.width,p.height,l.genMipmaps,!0)),p.format=K[S.internalformat],p.type=Z[S.type],p.mag=J[l.magFilter],p.min=ee[l.minFilter],p.wrapS=te[l.wrapS],p.wrapT=te[l.wrapT],c=0;c<6;++c)w(E[c]);return p}var S=new A(mt);oe[S.id]=S,a.cubeCount++;var E=new Array(6);return p(t,r,i,s,c,l),p.subimage=function(e,t,n,r,i){ke(!!t,"must specify image data"),ke("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var a=0|n,o=0|r,s=0|i,u=h();return f(u,S),u.width=0,u.height=0,d(u,t),u.width=u.width||(S.width>>s)-a,u.height=u.height||(S.height>>s)-o,ke(S.type===u.type&&S.format===u.format&&S.internalformat===u.internalformat,"incompatible format for texture.subimage"),ke(a>=0&&o>=0&&a+u.width<=S.width&&o+u.height<=S.height,"texture.subimage write out of bounds"),ke(S.mipmask&1<>i;++i)e.texImage2D(ht+r,i,S.format,n>>i,n>>i,0,S.format,S.type,null);return C(),o.profile&&(S.stats.size=G(S.internalformat,S.type,p.width,p.height,!1,!0)),p}},p._reglType="textureCube",p._texture=S,o.profile&&(p.stats=S.stats),p.destroy=function(){S.decRef()},p},clear:function(){for(var t=0;t>n,t.height>>n,0,t.internalformat,t.type,null);else for(var r=0;r<6;++r)e.texImage2D(ht+r,n,t.internalformat,t.width>>n,t.height>>n,0,t.internalformat,t.type,null);T(t.texInfo,t.target)})}}}function Q(e,t,n){return Mn[e]*t*n}function X(){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=Zn,this.offset=0,this.stride=0,this.divisor=0}function Y(e,t,n,r){function i(e,t,n,r){this.name=e,this.id=t,this.location=n,this.info=r}function a(e,t){for(var n=0;n1)for(var h=0;he&&(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);je(f).forEach(t),f={},je(u).forEach(t),u={},l.forEach(function(t){e.deleteProgram(t.program)}),l.length=0,c={},n.shaderCount=0},program:function(e,t,i){ke.command(e>=0,"missing vertex shader",i),ke.command(t>=0,"missing fragment shader",i);var a=c[t];a||(a=c[t]={});var o=a[e];return o||(o=new function(e,t){this.id=d++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],r.profile&&(this.stats={uniformsCount:0,attributesCount:0})}(t,e),n.shaderCount++,s(o,i),a[e]=o,l.push(o)),o},restore:function(){f={},u={};for(var e=0;e=0&&f=0&&u0&&c+f<=r.framebufferWidth,"invalid width for read pixels"),ke(l>0&&l+u<=r.framebufferHeight,"invalid height for read pixels"),n();var p=c*l*4;return d||(s===ir?d=new Uint8Array(p):s===or&&(d=d||new Float32Array(p))),ke.isTypedArray(d,"data buffer for regl.read() must be a typedarray"),ke(d.byteLength>=p,"data buffer for regl.read() too small"),e.pixelStorei(ar,4),e.readPixels(f,u,c,l,rr,s,d),d}return function(e){return e&&"framebuffer"in e?function(e){var n;return t.setFBO({framebuffer:e.framebuffer},function(){n=o(e)}),n}(e):o(e)}}function K(e){return Array.prototype.slice.call(e)}function Z(e){return K(e).join("")}function J(e){return Array.isArray(e)||fe(e)||S(e)}function ee(e){return e.sort(function(e,t){return e===Ir?-1:t===Ir?1:e=1,r>=2,t)}if(n===hr){var i=e.data;return new te(i.thisDep,i.contextDep,i.propDep,t)}return new te(n===mr,n===pr,n===dr,t)}function ae(e,t,n,r,i,a,o,s,f,u,c,l,d,p,m){function h(e){return e.replace(".","_")}function b(e,t,n){var r=h(e);I.push(e),V[r]=N[r]=!!n,H[r]=t}function g(e,t,n){var r=h(e);I.push(e),Array.isArray(n)?(N[r]=n.slice(),V[r]=n.slice()):N[r]=V[r]=n,U[r]=t}function v(){var e=function(){function e(){var e=[],t=[];return ue(function(){e.push.apply(e,K(arguments))},{def:function(){var r="v"+n++;return t.push(r),arguments.length>0&&(e.push(r,"="),e.push.apply(e,K(arguments)),e.push(";")),r},toString:function(){return Z([t.length>0?"var "+t+";":"",Z(e)])}})}function t(){function t(e,t){r(e,t,"=",n.def(e,t),";")}var n=e(),r=e(),i=n.toString,a=r.toString;return ue(function(){n.apply(n,K(arguments))},{def:n.def,entry:n,exit:r,save:t,set:function(e,r,i){t(e,r),n(e,r,"=",i,";")},toString:function(){return i()+a()}})}var n=0,r=[],i=[],a=e(),o={};return{global:a,link:function(e){for(var t=0;t=0,'unknown parameter "'+e+'"',u.commandStr)})}var t=[Ur,Gr,qr,Qr,Xr,$r,Yr,Kr,Hr].concat(I);e(d),e(p)});var m=function(e,t){var n=e.static,r=e.dynamic;if(Ur in n){var i=n[Ur];return i?(i=s.getFramebuffer(i),ke.command(i,"invalid framebuffer object"),re(function(e,t){var n=e.link(i),r=e.shared;t.set(r.framebuffer,".next",n);var a=r.context;return t.set(a,"."+Zr,n+".width"),t.set(a,"."+Jr,n+".height"),n})):re(function(e,t){var n=e.shared;t.set(n.framebuffer,".next","null");var r=n.context;return t.set(r,"."+Zr,r+"."+ni),t.set(r,"."+Jr,r+"."+ri),"null"})}if(Ur in r){var a=r[Ur];return ie(a,function(e,t){var n=e.invoke(t,a),r=e.shared,i=r.framebuffer,o=t.def(i,".getFramebuffer(",n,")");ke.optional(function(){e.assert(t,"!"+n+"||"+o,"invalid framebuffer object")}),t.set(i,".next",o);var s=r.context;return t.set(s,"."+Zr,o+"?"+o+".width:"+s+"."+ni),t.set(s,"."+Jr,o+"?"+o+".height:"+s+"."+ri),o})}return null}(e),b=function(e,t,n){function r(e){if(e in i){var r=i[e];ke.commandType(r,"object","invalid "+e,n.commandStr);var o,s,f=!0,u=0|r.x,c=0|r.y;return"width"in r?(o=0|r.width,ke.command(o>=0,"invalid "+e,n.commandStr)):f=!1,"height"in r?(s=0|r.height,ke.command(s>=0,"invalid "+e,n.commandStr)):f=!1,new te(!f&&t&&t.thisDep,!f&&t&&t.contextDep,!f&&t&&t.propDep,function(e,t){var n=e.shared.context,i=o;"width"in r||(i=t.def(n,".",Zr,"-",u));var a=s;return"height"in r||(a=t.def(n,".",Jr,"-",c)),[u,c,i,a]})}if(e in a){var l=a[e],d=ie(l,function(t,n){var r=t.invoke(n,l);ke.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)});var i=t.shared.context,a=n.def(r,".x|0"),o=n.def(r,".y|0"),s=n.def('"width" in ',r,"?",r,".width|0:","(",i,".",Zr,"-",a,")"),f=n.def('"height" in ',r,"?",r,".height|0:","(",i,".",Jr,"-",o,")");return ke.optional(function(){t.assert(n,s+">=0&&"+f+">=0","invalid "+e)}),[a,o,s,f]});return t&&(d.thisDep=d.thisDep||t.thisDep,d.contextDep=d.contextDep||t.contextDep,d.propDep=d.propDep||t.propDep),d}return t?new te(t.thisDep,t.contextDep,t.propDep,function(e,t){var n=e.shared.context;return[0,0,t.def(n,".",Zr),t.def(n,".",Jr)]}):null}var i=e.static,a=e.dynamic,o=r(Ir);if(o){var s=o;o=new te(o.thisDep,o.contextDep,o.propDep,function(e,t){var n=s.append(e,t),r=e.shared.context;return t.set(r,"."+ei,n[2]),t.set(r,"."+ti,n[3]),n})}return{viewport:o,scissor_box:r(Vr)}}(e,m,u),g=function(e,t){function n(e,n){if(e in r){var a=0|r[e];return ke.command(!n||a>=0,"invalid "+e,t.commandStr),re(function(e,t){return n&&(e.OFFSET=a),a})}if(e in i){var s=i[e];return ie(s,function(t,r){var i=t.invoke(r,s);return n&&(t.OFFSET=i,ke.optional(function(){t.assert(r,i+">=0","invalid "+e)})),i})}return n&&o?re(function(e,t){return e.OFFSET="0",0}):null}var r=e.static,i=e.dynamic,o=function(){if(Qr in r){var e=r[Qr];J(e)?e=a.getElements(a.create(e,!0)):e&&(e=a.getElements(e),ke.command(e,"invalid elements",t.commandStr));var n=re(function(t,n){if(e){var r=t.link(e);return t.ELEMENTS=r,r}return t.ELEMENTS=null,null});return n.value=e,n}if(Qr in i){var o=i[Qr];return ie(o,function(e,t){var n=e.shared,r=n.isBufferArgs,i=n.elements,a=e.invoke(t,o),s=t.def("null"),f=t.def(r,"(",a,")"),u=e.cond(f).then(s,"=",i,".createStream(",a,");").else(s,"=",i,".getElements(",a,");");return ke.optional(function(){e.assert(u.else,"!"+a+"||"+s,"invalid elements")}),t.entry(u),t.exit(e.cond(f).then(i,".destroyStream(",s,");")),e.ELEMENTS=s,s})}return null}(),s=n($r,!0);return{elements:o,primitive:function(){if(Xr in r){var e=r[Xr];return ke.commandParameter(e,$e,"invalid primitve",t.commandStr),re(function(t,n){return $e[e]})}if(Xr in i){var n=i[Xr];return ie(n,function(e,t){var r=e.constants.primTypes,i=e.invoke(t,n);return ke.optional(function(){e.assert(t,i+" in "+r,"invalid primitive, must be one of "+Object.keys($e))}),t.def(r,"[",i,"]")})}return o?ne(o)?o.value?re(function(e,t){return t.def(e.ELEMENTS,".primType")}):re(function(){return zi}):new te(o.thisDep,o.contextDep,o.propDep,function(e,t){var n=e.ELEMENTS;return t.def(n,"?",n,".primType:",zi)}):null}(),count:function(){if(Yr in r){var e=0|r[Yr];return ke.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),re(function(){return e})}if(Yr in i){var n=i[Yr];return ie(n,function(e,t){var r=e.invoke(t,n);return ke.optional(function(){e.assert(t,"typeof "+r+'==="number"&&'+r+">=0&&"+r+"===("+r+"|0)","invalid vertex count")}),r})}if(o){if(ne(o)){if(o)return s?new te(s.thisDep,s.contextDep,s.propDep,function(e,t){var n=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return ke.optional(function(){e.assert(t,n+">=0","invalid vertex offset/element buffer too small")}),n}):re(function(e,t){return t.def(e.ELEMENTS,".vertCount")});var a=re(function(){return-1});return ke.optional(function(){a.MISSING=!0}),a}var f=new te(o.thisDep||s.thisDep,o.contextDep||s.contextDep,o.propDep||s.propDep,function(e,t){var n=e.ELEMENTS;return e.OFFSET?t.def(n,"?",n,".vertCount-",e.OFFSET,":-1"):t.def(n,"?",n,".vertCount:-1")});return ke.optional(function(){f.DYNAMIC=!0}),f}return null}(),instances:n(Kr,!1),offset:s}}(e,u),v=function(e,t){var n=e.static,i=e.dynamic,a={};return I.forEach(function(e){function o(t,r){if(e in n){var o=t(n[e]);a[s]=re(function(){return o})}else if(e in i){var f=i[e];a[s]=ie(f,function(e,t){return r(e,t,e.invoke(t,f))})}}var s=h(e);switch(e){case Ar:case gr:case br:case zr:case wr:case Nr:case jr:case Mr:case Pr:case Sr:return o(function(n){return ke.commandType(n,"boolean",e,t.commandStr),n},function(t,n,r){return ke.optional(function(){t.assert(n,"typeof "+r+'==="boolean"',"invalid flag "+e,t.commandStr)}),r});case _r:return o(function(n){return ke.commandParameter(n,Zi,"invalid "+e,t.commandStr),Zi[n]},function(t,n,r){var i=t.constants.compareFuncs;return ke.optional(function(){t.assert(n,r+" in "+i,"invalid "+e+", must be one of "+Object.keys(Zi))}),n.def(i,"[",r,"]")});case kr:return o(function(e){return ke.command(z(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,n){return ke.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===2&&typeof "+n+'[0]==="number"&&typeof '+n+'[1]==="number"&&'+n+"[0]<="+n+"[1]","depth range must be a 2d array")}),[t.def("+",n,"[0]"),t.def("+",n,"[1]")]});case xr:return o(function(e){ke.commandType(e,"object","blend.func",t.commandStr);var n="srcRGB"in e?e.srcRGB:e.src,r="srcAlpha"in e?e.srcAlpha:e.src,i="dstRGB"in e?e.dstRGB:e.dst,a="dstAlpha"in e?e.dstAlpha:e.dst;return ke.commandParameter(n,$i,s+".srcRGB",t.commandStr),ke.commandParameter(r,$i,s+".srcAlpha",t.commandStr),ke.commandParameter(i,$i,s+".dstRGB",t.commandStr),ke.commandParameter(a,$i,s+".dstAlpha",t.commandStr),ke.command(-1===Ki.indexOf(n+", "+i),"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+i+")",t.commandStr),[$i[n],$i[i],$i[r],$i[a]]},function(t,n,r){function i(i,o){var s=n.def('"',i,o,'" in ',r,"?",r,".",i,o,":",r,".",i);return ke.optional(function(){t.assert(n,s+" in "+a,"invalid "+e+"."+i+o+", must be one of "+Object.keys($i))}),s}var a=t.constants.blendFuncs;ke.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid blend func, must be an object")});var o=i("src","RGB"),s=i("dst","RGB");ke.optional(function(){var e=t.constants.invalidBlendCombinations;t.assert(n,e+".indexOf("+o+'+", "+'+s+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var f=n.def(a,"[",o,"]"),u=n.def(a,"[",i("src","Alpha"),"]");return[f,n.def(a,"[",s,"]"),u,n.def(a,"[",i("dst","Alpha"),"]")]});case yr:return o(function(n){return"string"==typeof n?(ke.commandParameter(n,R,"invalid "+e,t.commandStr),[R[n],R[n]]):"object"==typeof n?(ke.commandParameter(n.rgb,R,e+".rgb",t.commandStr),ke.commandParameter(n.alpha,R,e+".alpha",t.commandStr),[R[n.rgb],R[n.alpha]]):void ke.commandRaise("invalid blend.equation",t.commandStr)},function(t,n,r){var i=t.constants.blendEquations,a=n.def(),o=n.def(),s=t.cond("typeof ",r,'==="string"');return ke.optional(function(){function n(e,n,r){t.assert(e,r+" in "+i,"invalid "+n+", must be one of "+Object.keys(R))}n(s.then,e,r),t.assert(s.else,r+"&&typeof "+r+'==="object"',"invalid "+e),n(s.else,e+".rgb",r+".rgb"),n(s.else,e+".alpha",r+".alpha")}),s.then(a,"=",o,"=",i,"[",r,"];"),s.else(a,"=",i,"[",r,".rgb];",o,"=",i,"[",r,".alpha];"),n(s),[a,o]});case vr:return o(function(e){return ke.command(z(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),T(4,function(t){return+e[t]})},function(e,t,n){return ke.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","blend.color must be a 4d array")}),T(4,function(e){return t.def("+",n,"[",e,"]")})});case Fr:return o(function(e){return ke.commandType(e,"number",s,t.commandStr),0|e},function(e,t,n){return ke.optional(function(){e.assert(t,"typeof "+n+'==="number"',"invalid stencil.mask")}),t.def(n,"|0")});case Rr:return o(function(n){ke.commandType(n,"object",s,t.commandStr);var r=n.cmp||"keep",i=n.ref||0,a="mask"in n?n.mask:-1;return ke.commandParameter(r,Zi,e+".cmp",t.commandStr),ke.commandType(i,"number",e+".ref",t.commandStr),ke.commandType(a,"number",e+".mask",t.commandStr),[Zi[r],i,a]},function(e,t,n){var r=e.constants.compareFuncs;return ke.optional(function(){function i(){e.assert(t,Array.prototype.join.call(arguments,""),"invalid stencil.func")}i(n+"&&typeof ",n,'==="object"'),i('!("cmp" in ',n,")||(",n,".cmp in ",r,")")}),[t.def('"cmp" in ',n,"?",r,"[",n,".cmp]",":",Hi),t.def(n,".ref|0"),t.def('"mask" in ',n,"?",n,".mask|0:-1")]});case Br:case Lr:return o(function(n){ke.commandType(n,"object",s,t.commandStr);var r=n.fail||"keep",i=n.zfail||"keep",a=n.zpass||"keep";return ke.commandParameter(r,Ji,e+".fail",t.commandStr),ke.commandParameter(i,Ji,e+".zfail",t.commandStr),ke.commandParameter(a,Ji,e+".zpass",t.commandStr),[e===Lr?Ri:Fi,Ji[r],Ji[i],Ji[a]]},function(t,n,r){function i(i){return ke.optional(function(){t.assert(n,'!("'+i+'" in '+r+")||("+r+"."+i+" in "+a+")","invalid "+e+"."+i+", must be one of "+Object.keys(Ji))}),n.def('"',i,'" in ',r,"?",a,"[",r,".",i,"]:",Hi)}var a=t.constants.stencilOps;return ke.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[e===Lr?Ri:Fi,i("fail"),i("zfail"),i("zpass")]});case Dr:return o(function(e){ke.commandType(e,"object",s,t.commandStr);var n=0|e.factor,r=0|e.units;return ke.commandType(n,"number",s+".factor",t.commandStr),ke.commandType(r,"number",s+".units",t.commandStr),[n,r]},function(t,n,r){return ke.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[n.def(r,".factor|0"),n.def(r,".units|0")]});case Or:return o(function(e){var n=0;return"front"===e?n=Fi:"back"===e&&(n=Ri),ke.command(!!n,s,t.commandStr),n},function(e,t,n){return ke.optional(function(){e.assert(t,n+'==="front"||'+n+'==="back"',"invalid cull.face")}),t.def(n,'==="front"?',Fi,":",Ri)});case Er:return o(function(e){return ke.command("number"==typeof e&&e>=r.lineWidthDims[0]&&e<=r.lineWidthDims[1],"invalid line width, must positive number between "+r.lineWidthDims[0]+" and "+r.lineWidthDims[1],t.commandStr),e},function(e,t,n){return ke.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">="+r.lineWidthDims[0]+"&&"+n+"<="+r.lineWidthDims[1],"invalid line width")}),n});case Cr:return o(function(e){return ke.commandParameter(e,ta,s,t.commandStr),ta[e]},function(e,t,n){return ke.optional(function(){e.assert(t,n+'==="cw"||'+n+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),t.def(n+'==="cw"?'+Bi+":"+Li)});case Tr:return o(function(e){return ke.command(z(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map(function(e){return!!e})},function(e,t,n){return ke.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","invalid color.mask")}),T(4,function(e){return"!!"+n+"["+e+"]"})});case Wr:return o(function(e){ke.command("object"==typeof e&&e,s,t.commandStr);var n="value"in e?e.value:1,r=!!e.invert;return ke.command("number"==typeof n&&n>=0&&n<=1,"sample.coverage.value must be a number between 0 and 1",t.commandStr),[n,r]},function(e,t,n){return ke.optional(function(){e.assert(t,n+"&&typeof "+n+'==="object"',"invalid sample.coverage")}),[t.def('"value" in ',n,"?+",n,".value:1"),t.def("!!",n,".invert")]})}}),a}(e,u),y=function(e){function n(e){if(e in i){var n=t.id(i[e]);ke.optional(function(){c.shader(ea[e],n,ke.guessCommand())});var r=re(function(){return n});return r.id=n,r}if(e in a){var o=a[e];return ie(o,function(t,n){var r=t.invoke(n,o),i=n.def(t.shared.strings,".id(",r,")");return ke.optional(function(){n(t.shared.shader,".shader(",ea[e],",",i,",",t.command,");")}),i})}return null}var r,i=e.static,a=e.dynamic,o=n(qr),s=n(Gr),f=null;return ne(o)&&ne(s)?(f=c.program(s.id,o.id),r=re(function(e,t){return e.link(f)})):r=new te(o&&o.thisDep||s&&s.thisDep,o&&o.contextDep||s&&s.contextDep,o&&o.propDep||s&&s.propDep,function(e,t){var n,r=e.shared.shader;n=o?o.append(e,t):t.def(r,".",qr);var i=r+".program("+(s?s.append(e,t):t.def(r,".",Gr))+","+n;return ke.optional(function(){i+=","+e.command}),t.def(i+")")}),{frag:o,vert:s,progVar:r,program:f}}(e);l(Ir),l(h(Vr));var x=Object.keys(v).length>0,w={framebuffer:m,draw:g,shader:y,state:v,dirty:x};return w.profile=function(e){var t,n=e.static,r=e.dynamic;if(Hr in n){var i=!!n[Hr];(t=re(function(e,t){return i})).enable=i}else if(Hr in r){var a=r[Hr];t=ie(a,function(e,t){return e.invoke(t,a)})}return t}(e),w.uniforms=function(e,t){var n=e.static,r=e.dynamic,i={};return Object.keys(n).forEach(function(e){var r,a=n[e];if("number"==typeof a||"boolean"==typeof a)r=re(function(){return a});else if("function"==typeof a){var o=a._reglType;"texture2d"===o||"textureCube"===o?r=re(function(e){return e.link(a)}):"framebuffer"===o||"framebufferCube"===o?(ke.command(a.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),r=re(function(e){return e.link(a.color[0])})):ke.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else z(a)?r=re(function(t){return t.global.def("[",T(a.length,function(n){return ke.command("number"==typeof a[n]||"boolean"==typeof a[n],"invalid uniform "+e,t.commandStr),a[n]}),"]")}):ke.commandRaise('invalid or missing data for uniform "'+e+'"',t.commandStr);r.value=a,i[e]=r}),Object.keys(r).forEach(function(e){var t=r[e];i[e]=ie(t,function(e,n){return e.invoke(n,t)})}),i}(o,u),w.attributes=function(e,n){var r=e.static,a=e.dynamic,o={};return Object.keys(r).forEach(function(e){var a=r[e],s=t.id(e),f=new F;if(J(a))f.state=ur,f.buffer=i.getBuffer(i.create(a,ai,!1,!0)),f.type=0;else{var u=i.getBuffer(a);if(u)f.state=ur,f.buffer=u,f.type=0;else if(ke.command("object"==typeof a&&a,"invalid data for attribute "+e,n.commandStr),a.constant){var c=a.constant;f.buffer="null",f.state=cr,"number"==typeof c?f.x=c:(ke.command(z(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,n.commandStr),sr.forEach(function(e,t){t=0,'invalid offset for attribute "'+e+'"',n.commandStr);var d=0|a.stride;ke.command(d>=0&&d<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',n.commandStr);var p=0|a.size;ke.command(!("size"in a)||p>0&&p<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',n.commandStr);var m=!!a.normalized,h=0;"type"in a&&(ke.commandParameter(a.type,Ve,"invalid type for attribute "+e,n.commandStr),h=Ve[a.type]);var b=0|a.divisor;"divisor"in a&&(ke.command(0===b||B,'cannot specify divisor for attribute "'+e+'", instancing not supported',n.commandStr),ke.command(b>=0,'invalid divisor for attribute "'+e+'"',n.commandStr)),ke.optional(function(){var t=n.commandStr,r=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(a).forEach(function(n){ke.command(r.indexOf(n)>=0,'unknown parameter "'+n+'" for attribute pointer "'+e+'" (valid parameters are '+r+")",t)})}),f.buffer=u,f.state=ur,f.size=p,f.normalized=m,f.type=h||u.dtype,f.offset=l,f.stride=d,f.divisor=b}}o[e]=re(function(e,t){var n=e.attribCache;if(s in n)return n[s];var r={isStream:!1};return Object.keys(f).forEach(function(e){r[e]=f[e]}),f.buffer&&(r.buffer=e.link(f.buffer),r.type=r.type||r.buffer+".dtype"),n[s]=r,r})}),Object.keys(a).forEach(function(e){var t=a[e];o[e]=ie(t,function(n,r){function i(e){r(u[e],"=",a,".",e,"|0;")}var a=n.invoke(r,t),o=n.shared,s=o.isBufferArgs,f=o.buffer;ke.optional(function(){n.assert(r,a+"&&(typeof "+a+'==="object"||typeof '+a+'==="function")&&('+s+"("+a+")||"+f+".getBuffer("+a+")||"+f+".getBuffer("+a+".buffer)||"+s+"("+a+'.buffer)||("constant" in '+a+"&&(typeof "+a+'.constant==="number"||'+o.isArrayLike+"("+a+".constant))))",'invalid dynamic attribute "'+e+'"')});var u={isStream:r.def(!1)},c=new F;c.state=ur,Object.keys(c).forEach(function(e){u[e]=r.def(""+c[e])});var l=u.buffer,d=u.type;return r("if(",s,"(",a,")){",u.isStream,"=true;",l,"=",f,".createStream(",ai,",",a,");",d,"=",l,".dtype;","}else{",l,"=",f,".getBuffer(",a,");","if(",l,"){",d,"=",l,".dtype;",'}else if("constant" in ',a,"){",u.state,"=",cr,";","if(typeof "+a+'.constant === "number"){',u[sr[0]],"=",a,".constant;",sr.slice(1).map(function(e){return u[e]}).join("="),"=0;","}else{",sr.map(function(e,t){return u[e]+"="+a+".constant.length>="+t+"?"+a+".constant["+t+"]:0;"}).join(""),"}}else{","if(",s,"(",a,".buffer)){",l,"=",f,".createStream(",ai,",",a,".buffer);","}else{",l,"=",f,".getBuffer(",a,".buffer);","}",d,'="type" in ',a,"?",o.glTypes,"[",a,".type]:",l,".dtype;",u.normalized,"=!!",a,".normalized;"),i("size"),i("offset"),i("stride"),i("divisor"),r("}}"),r.exit("if(",u.isStream,"){",f,".destroyStream(",l,");","}"),u})}),o}(n,u),w.context=function(e){var t=e.static,n=e.dynamic,r={};return Object.keys(t).forEach(function(e){var n=t[e];r[e]=re(function(e,t){return"number"==typeof n||"boolean"==typeof n?""+n:e.link(n)})}),Object.keys(n).forEach(function(e){var t=n[e];r[e]=ie(t,function(e,n){return e.invoke(n,t)})}),r}(f),w}function x(e,t,n){var r=e.shared.context,i=e.scope();Object.keys(n).forEach(function(a){t.save(r,"."+a);var o=n[a];i(r,".",a,"=",o.append(e,t),";")}),t(i)}function w(e,t,n,r){var i,a=e.shared,o=a.gl,s=a.framebuffer;L&&(i=t.def(a.extensions,".webgl_draw_buffers"));var f,u=e.constants,c=u.drawBuffer,l=u.backBuffer;f=n?n.append(e,t):t.def(s,".next"),r||t("if(",f,"!==",s,".cur){"),t("if(",f,"){",o,".bindFramebuffer(",Xi,",",f,".framebuffer);"),L&&t(i,".drawBuffersWEBGL(",c,"[",f,".colorAttachments.length]);"),t("}else{",o,".bindFramebuffer(",Xi,",null);"),L&&t(i,".drawBuffersWEBGL(",l,");"),t("}",s,".cur=",f,";"),r||t("}")}function _(e,t,n){var r=e.shared,i=r.gl,a=e.current,o=e.next,s=r.current,f=r.next,u=e.cond(s,".dirty");I.forEach(function(t){var r=h(t);if(!(r in n.state)){var c,l;if(r in o){c=o[r],l=a[r];var d=T(N[r].length,function(e){return u.def(c,"[",e,"]")});u(e.cond(d.map(function(e,t){return e+"!=="+l+"["+t+"]"}).join("||")).then(i,".",U[r],"(",d,");",d.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";"))}else{c=u.def(f,".",r);var p=e.cond(c,"!==",s,".",r);u(p),r in H?p(e.cond(c).then(i,".enable(",H[r],");").else(i,".disable(",H[r],");"),s,".",r,"=",c,";"):p(i,".",U[r],"(",c,");",s,".",r,"=",c,";")}}}),0===Object.keys(n.state).length&&u(s,".dirty=false;"),t(u)}function k(e,t,n,r){var i=e.shared,a=e.current,o=i.current,s=i.gl;ee(Object.keys(n)).forEach(function(i){var f=n[i];if(!r||r(f)){var u=f.append(e,t);if(H[i]){var c=H[i];ne(f)?t(s,u?".enable(":".disable(",c,");"):t(e.cond(u).then(s,".enable(",c,");").else(s,".disable(",c,");")),t(o,".",i,"=",u,";")}else if(z(u)){var l=a[i];t(s,".",U[i],"(",u,");",u.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(s,".",U[i],"(",u,");",o,".",i,"=",u,";")}})}function S(e,t){B&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function A(e,t,n,r,i){function a(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function o(e){e(u=t.def(),"=",a(),";"),"string"==typeof i?e(m,".count+=",i,";"):e(m,".count++;"),p&&(r?e(c=t.def(),"=",b,".getNumPendingQueries();"):e(b,".beginQuery(",m,");"))}function s(e){e(m,".cpuTime+=",a(),"-",u,";"),p&&(r?e(b,".pushScopeStats(",c,",",b,".getNumPendingQueries(),",m,");"):e(b,".endQuery();"))}function f(e){var n=t.def(h,".profile");t(h,".profile=",e,";"),t.exit(h,".profile=",n,";")}var u,c,l,d=e.shared,m=e.stats,h=d.current,b=d.timer,g=n.profile;if(g){if(ne(g))return void(g.enable?(o(t),s(t.exit),f("true")):f("false"));f(l=g.append(e,t))}else l=t.def(h,".profile");var v=e.block();o(v),t("if(",l,"){",v,"}");var y=e.block();s(y),t.exit("if(",l,"){",y,"}")}function O(e,t,n,r,i){var a=e.shared;r.forEach(function(r){var o,s=r.name,f=n.attributes[s];if(f){if(!i(f))return;o=f.append(e,t)}else{if(!i(na))return;var u=e.scopeAttrib(s);ke.optional(function(){e.assert(t,u+".state","missing attribute "+s)}),o={},Object.keys(new F).forEach(function(e){o[e]=t.def(u,".",e)})}!function(n,r,i){function o(){t("if(!",c,".buffer){",f,".enableVertexAttribArray(",u,");}");var n,a=i.type;if(n=i.size?t.def(i.size,"||",r):r,t("if(",c,".type!==",a,"||",c,".size!==",n,"||",m.map(function(e){return c+"."+e+"!=="+i[e]}).join("||"),"){",f,".bindBuffer(",ai,",",d,".buffer);",f,".vertexAttribPointer(",[u,n,a,i.normalized,i.stride,i.offset],");",c,".type=",a,";",c,".size=",n,";",m.map(function(e){return c+"."+e+"="+i[e]+";"}).join(""),"}"),B){var o=i.divisor;t("if(",c,".divisor!==",o,"){",e.instancing,".vertexAttribDivisorANGLE(",[u,o],");",c,".divisor=",o,";}")}}function s(){t("if(",c,".buffer){",f,".disableVertexAttribArray(",u,");","}if(",sr.map(function(e,t){return c+"."+e+"!=="+p[t]}).join("||"),"){",f,".vertexAttrib4f(",u,",",p,");",sr.map(function(e,t){return c+"."+e+"="+p[t]+";"}).join(""),"}")}var f=a.gl,u=t.def(n,".location"),c=t.def(a.attributes,"[",u,"]"),l=i.state,d=i.buffer,p=[i.x,i.y,i.z,i.w],m=["buffer","normalized","offset","stride"];l===ur?o():l===cr?s():(t("if(",l,"===",ur,"){"),o(),t("}else{"),s(),t("}"))}(e.link(r),function(e){switch(e){case yi:case ki:case Oi:return 2;case xi:case Si:case Ci:return 3;case wi:case Ti:case Ei:return 4;default:return 1}}(r.info.type),o)})}function C(e,n,r,i,a){for(var o,s=e.shared,f=s.gl,u=0;u1?T(x,function(e){return c+"["+e+"]"}):c);n(");")}}function E(e,t,n,r){function i(i){var a=c[i];return a?a.contextDep&&r.contextDynamic||a.propDep?a.append(e,n):a.append(e,t):t.def(u,".",i)}function a(){function e(){n(b,".drawElementsInstancedANGLE(",[d,m,g,p+"<<(("+g+"-"+fr+")>>1)",h],");")}function t(){n(b,".drawArraysInstancedANGLE(",[d,p,m,h],");")}l?v?e():(n("if(",l,"){"),e(),n("}else{"),t(),n("}")):t()}function o(){function e(){n(f+".drawElements("+[d,m,g,p+"<<(("+g+"-"+fr+")>>1)"]+");")}function t(){n(f+".drawArrays("+[d,p,m]+");")}l?v?e():(n("if(",l,"){"),e(),n("}else{"),t(),n("}")):t()}var s=e.shared,f=s.gl,u=s.draw,c=r.draw,l=function(){var i,a=c.elements,o=t;return a?((a.contextDep&&r.contextDynamic||a.propDep)&&(o=n),i=a.append(e,o)):i=o.def(u,".",Qr),i&&o("if("+i+")"+f+".bindBuffer("+oi+","+i+".buffer.buffer);"),i}(),d=i(Xr),p=i($r),m=function(){var i,a=c.count,o=t;return a?((a.contextDep&&r.contextDynamic||a.propDep)&&(o=n),i=a.append(e,o),ke.optional(function(){a.MISSING&&e.assert(t,"false","missing vertex count"),a.DYNAMIC&&e.assert(o,i+">=0","missing vertex count")})):(i=o.def(u,".",Yr),ke.optional(function(){e.assert(o,i+">=0","missing vertex count")})),i}();if("number"==typeof m){if(0===m)return}else n("if(",m,"){"),n.exit("}");var h,b;B&&(h=i(Kr),b=e.instancing);var g=l+".type",v=c.elements&&ne(c.elements);B&&("number"!=typeof h||h>=0)?"string"==typeof h?(n("if(",h,">0){"),a(),n("}else if(",h,"<0){"),o(),n("}")):a():o()}function j(e,t,n,r,i){var a=v(),o=a.proc("body",i);return ke.optional(function(){a.commandStr=t.commandStr,a.command=a.link(t.commandStr)}),B&&(a.instancing=o.def(a.shared.extensions,".angle_instanced_arrays")),e(a,o,n,r),a.compile().body}function D(e,t,n,r){S(e,t),O(e,t,n,r.attributes,function(){return!0}),C(e,t,n,r.uniforms,function(){return!0}),E(e,t,t,n)}function M(e,t,n,r){function i(){return!0}e.batchId="a1",S(e,t),O(e,t,n,r.attributes,i),C(e,t,n,r.uniforms,i),E(e,t,t,n)}function P(e,t,n,r){function i(e){return e.contextDep&&o||e.propDep}function a(e){return!i(e)}S(e,t);var o=n.contextDep,s=t.def(),f=t.def();e.shared.props=f,e.batchId=s;var u=e.scope(),c=e.scope();if(t(u.entry,"for(",s,"=0;",s,"<","a1",";++",s,"){",f,"=","a0","[",s,"];",c,"}",u.exit),n.needsContext&&x(e,c,n.context),n.needsFramebuffer&&w(e,c,n.framebuffer),k(e,c,n.state,i),n.profile&&i(n.profile)&&A(e,c,n,!1,!0),r)O(e,u,n,r.attributes,a),O(e,c,n,r.attributes,i),C(e,u,n,r.uniforms,a),C(e,c,n,r.uniforms,i),E(e,u,c,n);else{var l=e.global.def("{}"),d=n.shader.progVar.append(e,c),p=c.def(d,".id"),m=c.def(l,"[",p,"]");c(e.shared.gl,".useProgram(",d,".program);","if(!",m,"){",m,"=",l,"[",p,"]=",e.link(function(t){return j(M,e,n,t,2)}),"(",d,");}",m,".call(this,a0[",s,"],",s,");")}}function W(e,t,n){var r=t.static[n];if(r&&function(e){if("object"==typeof e&&!z(e)){for(var t=Object.keys(e),n=0;n0&&n(e.shared.current,".dirty=true;")}(o,s),function(e,n){function r(t){var r=n.shader[t];r&&i.set(a.shader,"."+t,r.append(e,i))}var i=e.proc("scope",3);e.batchId="a2";var a=e.shared,o=a.current;x(e,i,n.context),n.framebuffer&&n.framebuffer.append(e,i),ee(Object.keys(n.state)).forEach(function(t){var r=n.state[t].append(e,i);z(r)?r.forEach(function(n,r){i.set(e.next[t],"["+r+"]",n)}):i.set(a.next,"."+t,r)}),A(e,i,n,!0,!0),[Qr,$r,Yr,Kr,Xr].forEach(function(t){var r=n.draw[t];r&&i.set(a.draw,"."+t,""+r.append(e,i))}),Object.keys(n.uniforms).forEach(function(r){i.set(a.uniforms,"["+t.id(r)+"]",n.uniforms[r].append(e,i))}),Object.keys(n.attributes).forEach(function(t){var r=n.attributes[t].append(e,i),a=e.scopeAttrib(t);Object.keys(new F).forEach(function(e){i.set(a,"."+e,r[e])})}),r(Gr),r(qr),Object.keys(n.state).length>0&&(i(o,".dirty=true;"),i.exit(o,".dirty=true;")),i("a1(",e.shared.context,",a0,",e.batchId,");")}(o,s),function(e,t){function n(e){return e.contextDep&&i||e.propDep}var r=e.proc("batch",2);e.batchId="0",S(e,r);var i=!1,a=!0;Object.keys(t.context).forEach(function(e){i=i||t.context[e].propDep}),i||(x(e,r,t.context),a=!1);var o=t.framebuffer,s=!1;o?(o.propDep?i=s=!0:o.contextDep&&i&&(s=!0),s||w(e,r,o)):w(e,r,null),t.state.viewport&&t.state.viewport.propDep&&(i=!0),_(e,r,t),k(e,r,t.state,function(e){return!n(e)}),t.profile&&n(t.profile)||A(e,r,t,!1,"a1"),t.contextDep=i,t.needsContext=a,t.needsFramebuffer=s;var f=t.shader.progVar;if(f.contextDep&&i||f.propDep)P(e,r,t,null);else{var u=f.append(e,r);if(r(e.shared.gl,".useProgram(",u,".program);"),t.shader.program)P(e,r,t,t.shader.program);else{var c=e.global.def("{}"),l=r.def(u,".id"),d=r.def(c,"[",l,"]");r(e.cond(d).then(d,".call(this,a0,a1);").else(d,"=",c,"[",l,"]=",e.link(function(n){return j(P,e,t,n,2)}),"(",u,");",d,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&r(e.shared.current,".dirty=true;")}(o,s),o.compile()}}}function oe(e,t){for(var n=0;n=0&&(0|e)===e||t("invalid parameter type, ("+e+")"+r(n)+". must be a nonnegative integer")},oneOf:i,shaderError:function(e,t,r,i,o){if(!e.getShaderParameter(t,e.COMPILE_STATUS)){var s=e.getShaderInfoLog(t),u=i===e.FRAGMENT_SHADER?"fragment":"vertex";m(r,"string",u+" shader source must be a string",o);var c=l(r,o),d=function(e){var t=[];return e.split("\n").forEach(function(e){if(!(e.length<5)){var n=/^ERROR\:\s+(\d+)\:(\d+)\:\s*(.*)$/.exec(e);n?t.push(new f(0|n[1],0|n[2],n[3].trim())):e.length>0&&t.push(new f("unknown",0,e))}}),t}(s);!function(e,t){t.forEach(function(t){var n=e[t.file];if(n){var r=n.index[t.line];if(r)return r.errors.push(t),void(n.hasErrors=!0)}e.unknown.hasErrors=!0,e.unknown.lines[0].errors.push(t)})}(c,d),Object.keys(c).forEach(function(e){function t(e,t){r.push(e),i.push(t||"")}var n=c[e];if(n.hasErrors){var r=[""],i=[""];t("file number "+e+": "+n.name+"\n","color:red;text-decoration:underline;font-weight:bold"),n.lines.forEach(function(e){if(e.errors.length>0){t(a(e.number,4)+"| ","background-color:yellow; font-weight:bold"),t(e.line+"\n","color:red; background-color:yellow; font-weight:bold");var n=0;e.errors.forEach(function(r){var i=r.message,o=/^\s*\'(.*)\'\s*\:\s*(.*)$/.exec(i);if(o){var s=o[1];switch(i=o[2],s){case"assign":s="="}n=Math.max(e.line.indexOf(s,n),0)}else n=0;t(a("| ",6)),t(a("^^^",n+3)+"\n","font-weight:bold"),t(a("| ",6)),t(i+"\n","font-weight:bold")}),t(a("| ",6)+"\n")}else t(a(e.number,4)+"| "),t(e.line+"\n","color:red")}),"undefined"!=typeof document?(i[0]=r.join("%c"),console.log.apply(console,i)):console.log(r.join(""))}}),n.raise("Error compiling "+u+" shader, "+c[0].name)}},linkError:function(e,t,r,i,a){if(!e.getProgramParameter(t,e.LINK_STATUS)){var o=e.getProgramInfoLog(t),s=l(r,a),f='Error linking program with vertex shader, "'+l(i,a)[0].name+'", and fragment shader "'+s[0].name+'"';"undefined"!=typeof document?console.log("%c"+f+"\n%c"+o,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(f+"\n"+o),n.raise(f)}},callSite:c,saveCommandRef:d,saveDrawInfo:function(e,t,n,r){function i(e){return e?r.id(e):0}function a(e,t){Object.keys(t).forEach(function(t){e[r.id(t)]=!0})}d(e),e._fragId=i(e.static.frag),e._vertId=i(e.static.vert);var o=e._uniformSet={};a(o,t.static),a(o,t.dynamic);var s=e._attributeSet={};a(s,n.static),a(s,n.dynamic),e._hasCount="count"in e.static||"count"in e.dynamic||"elements"in e.static||"elements"in e.dynamic},framebufferFormat:function(e,t,n){e.texture?i(e.texture._texture.internalformat,t,"unsupported texture format for attachment"):i(e.renderbuffer._renderbuffer.format,n,"unsupported renderbuffer format for attachment")},guessCommand:u,texture2D:function(e,t,r){var i,a=t.width,o=t.height,s=t.channels;n(a>0&&a<=r.maxTextureSize&&o>0&&o<=r.maxTextureSize,"invalid texture shape"),e.wrapS===le&&e.wrapT===le||n(b(a)&&b(o),"incompatible wrap mode for texture, both width and height must be power of 2"),1===t.mipmask?1!==a&&1!==o&&n(e.minFilter!==pe&&e.minFilter!==he&&e.minFilter!==me&&e.minFilter!==be,"min filter requires mipmap"):(n(b(a)&&b(o),"texture must be a square power of 2 to support mipmapping"),n(t.mipmask===(a<<1)-1,"missing or incomplete mipmap data")),t.type===ge&&(r.extensions.indexOf("oes_texture_float_linear")<0&&n(e.minFilter===de&&e.magFilter===de,"filter not supported, must enable oes_texture_float_linear"),n(!e.genMipmaps,"mipmap generation not supported with float textures"));var f=t.images;for(i=0;i<16;++i)if(f[i]){var u=a>>i,c=o>>i;n(t.mipmask&1<0&&a<=i.maxTextureSize&&o>0&&o<=i.maxTextureSize,"invalid texture shape"),n(a===o,"cube map must be square"),n(t.wrapS===le&&t.wrapT===le,"wrap mode not supported by cube map");for(var f=0;f>l,m=o>>l;n(u.mipmask&1<=2,"invalid renderbuffer shape"),a=0|p[0],o=0|p[1]}else"radius"in d&&(a=o=0|d.radius),"width"in d&&(a=0|d.width),"height"in d&&(o=0|d.height);"format"in d&&(ke.parameter(d.format,s,"invalid renderbuffer format"),c=s[d.format])}else"number"==typeof t?(a=0|t,o="number"==typeof r?0|r:a):t?ke.raise("invalid arguments to renderbuffer constructor"):a=o=1;if(ke(a>0&&o>0&&a<=n.maxRenderbufferSize&&o<=n.maxRenderbufferSize,"invalid renderbuffer size"),a!==l.width||o!==l.height||c!==l.format)return u.width=l.width=a,u.height=l.height=o,l.format=c,e.bindRenderbuffer(jn,l.renderbuffer),e.renderbufferStorage(jn,c,a,o),i.profile&&(l.stats.size=Q(l.format,l.width,l.height)),u.format=f[l.format],u}var l=new a(e.createRenderbuffer());return c[l.id]=l,r.renderbufferCount++,u(t,o),u.resize=function(t,r){var a=0|t,o=0|r||a;return a===l.width&&o===l.height?u:(ke(a>0&&o>0&&a<=n.maxRenderbufferSize&&o<=n.maxRenderbufferSize,"invalid renderbuffer size"),u.width=l.width=a,u.height=l.height=o,e.bindRenderbuffer(jn,l.renderbuffer),e.renderbufferStorage(jn,l.format,a,o),i.profile&&(l.stats.size=Q(l.format,l.width,l.height)),u)},u._reglType="renderbuffer",u._renderbuffer=l,i.profile&&(u.stats=l.stats),u.destroy=function(){l.decRef()},u},clear:function(){je(c).forEach(o)},restore:function(){je(c).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(jn,t.renderbuffer),e.renderbufferStorage(jn,t.format,t.width,t.height)}),e.bindRenderbuffer(jn,null)}}},Wn=36160,zn=36161,Fn=3553,Rn=34069,Bn=36064,Ln=36096,Nn=36128,Vn=33306,In=36053,Hn=6402,Un=[6408],Gn=[];Gn[6408]=4;var qn=[];qn[5121]=1,qn[5126]=4,qn[36193]=2;var Qn=33189,Xn=36168,Yn=34041,$n=[32854,32855,36194,35907,34842,34843,34836],Kn={};Kn[In]="complete",Kn[36054]="incomplete attachment",Kn[36057]="incomplete dimensions",Kn[36055]="incomplete, missing attachment",Kn[36061]="unsupported";var Zn=5126,Jn=35632,er=35633,tr=35718,nr=35721,rr=6408,ir=5121,ar=3333,or=5126,sr="xyzw".split(""),fr=5121,ur=1,cr=2,lr=0,dr=1,pr=2,mr=3,hr=4,br="dither",gr="blend.enable",vr="blend.color",yr="blend.equation",xr="blend.func",wr="depth.enable",_r="depth.func",kr="depth.range",Sr="depth.mask",Tr="colorMask",Ar="cull.enable",Or="cull.face",Cr="frontFace",Er="lineWidth",jr="polygonOffset.enable",Dr="polygonOffset.offset",Mr="sample.alpha",Pr="sample.enable",Wr="sample.coverage",zr="stencil.enable",Fr="stencil.mask",Rr="stencil.func",Br="stencil.opFront",Lr="stencil.opBack",Nr="scissor.enable",Vr="scissor.box",Ir="viewport",Hr="profile",Ur="framebuffer",Gr="vert",qr="frag",Qr="elements",Xr="primitive",Yr="count",$r="offset",Kr="instances",Zr=Ur+"Width",Jr=Ur+"Height",ei=Ir+"Width",ti=Ir+"Height",ni="drawingBufferWidth",ri="drawingBufferHeight",ii=[xr,yr,Rr,Br,Lr,Wr,Ir,Vr,Dr],ai=34962,oi=34963,si=3553,fi=34067,ui=2884,ci=3042,li=3024,di=2960,pi=2929,mi=3089,hi=32823,bi=32926,gi=32928,vi=5126,yi=35664,xi=35665,wi=35666,_i=5124,ki=35667,Si=35668,Ti=35669,Ai=35670,Oi=35671,Ci=35672,Ei=35673,ji=35674,Di=35675,Mi=35676,Pi=35678,Wi=35680,zi=4,Fi=1028,Ri=1029,Bi=2304,Li=2305,Ni=32775,Vi=32776,Ii=519,Hi=7680,Ui=0,Gi=1,qi=32774,Qi=513,Xi=36160,Yi=36064,$i={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},Ki=["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"],Zi={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},Ji={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},ea={frag:35632,vert:35633},ta={cw:Bi,ccw:Li},na=new te(!1,!1,!1,function(){}),ra=34918,ia=34919,aa=35007,oa=function(e,t){function n(e){o.push(e)}function r(e){f.push(e)}function i(e,t,n){var r=f.pop()||new function(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null};r.startQueryIndex=e,r.endQueryIndex=t,r.sum=0,r.stats=n,u.push(r)}var a=t.ext_disjoint_timer_query;if(!a)return null;var o=[],s=[],f=[],u=[],c=[],l=[];return{beginQuery:function(e){var t=o.pop()||a.createQueryEXT();a.beginQueryEXT(aa,t),s.push(t),i(s.length-1,s.length,e)},endQuery:function(){a.endQueryEXT(aa)},pushScopeStats:i,update:function(){var e,t,i=s.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,t=0;t=0;--e){var n=H[e];n&&n(O,null,0)}m.flush(),w&&w.update()}function n(){!K&&H.length>0&&(K=Oe.next(t))}function r(){K&&(Oe.cancel(t),K=null)}function i(e){e.preventDefault(),b=!0,r(),U.forEach(function(e){e()})}function a(e){m.getError(),b=!1,g.restore(),z.restore(),E.restore(),F.restore(),R.restore(),B.restore(),w&&w.restore(),L.procs.refresh(),n(),G.forEach(function(e){e()})}function o(e){function t(e){var t={},n={};return Object.keys(e).forEach(function(r){var i=e[r];Ae.isDynamic(i)?n[r]=Ae.unbox(i,r):t[r]=i}),{dynamic:n,static:t}}ke(!!e,"invalid args to regl({...})"),ke.type(e,"object","invalid args to regl({...})");var n=t(e.context||{}),r=t(e.uniforms||{}),i=t(e.attributes||{}),a=t(function(e){function t(e){if(e in n){var t=n[e];delete n[e],Object.keys(t).forEach(function(r){n[e+"."+r]=t[r]})}}var n=ue({},e);return delete n.uniforms,delete n.attributes,delete n.context,"stencil"in n&&n.stencil.op&&(n.stencil.opBack=n.stencil.opFront=n.stencil.op,delete n.stencil.op),t("blend"),t("depth"),t("cull"),t("stencil"),t("polygonOffset"),t("scissor"),t("sample"),n}(e)),o={gpuTime:0,cpuTime:0,count:0},s=L.compile(a,i,r,n,o),f=s.draw,u=s.batch,c=s.scope,l=[];return ue(function(e,t){var n;if(b&&ke.raise("context lost"),"function"==typeof e)return c.call(this,null,e,0);if("function"==typeof t){if("number"==typeof e){for(n=0;n0)return u.call(this,function(e){for(;l.length=0,"cannot cancel a frame twice"),H[n]=t}}}function u(){var e=V.viewport,t=V.scissor_box;e[0]=e[1]=t[0]=t[1]=0,O.viewportWidth=O.framebufferWidth=O.drawingBufferWidth=e[2]=t[2]=m.drawingBufferWidth,O.viewportHeight=O.framebufferHeight=O.drawingBufferHeight=e[3]=t[3]=m.drawingBufferHeight}function c(){O.tick+=1,O.time=d(),u(),L.procs.poll()}function l(){u(),L.procs.refresh(),w&&w.update()}function d(){return(Ce()-_)/1e3}var p=k(e);if(!p)return null;var m=p.gl,h=m.getContextAttributes(),b=m.isContextLost(),g=function(e,t){function n(t){ke.type(t,"string","extension name must be string");var n,i=t.toLowerCase();try{n=r[i]=e.getExtension(i)}catch(e){}return!!n}for(var r={},i=0;i0){var f;if(Array.isArray(t[0])){s=Ue(t);for(var u=1,c=1;c0)if("number"==typeof e[0]){var i=Le.allocType(p.dtype,e.length);M(i,e),d(i,r),Le.freeType(i)}else if(Array.isArray(e[0])||fe(e[0])){n=Ue(e);var a=He(e,n,p.dtype);d(a,r),Le.freeType(a)}else ke.raise("invalid buffer data")}else if(fe(e))d(e,r);else if(S(e)){n=e.shape;var o=e.stride,s=0,f=0,u=0,c=0;1===n.length?(s=n[0],f=1,u=o[0],c=0):2===n.length?(s=n[0],f=n[1],u=o[0],c=o[1]):ke.raise("invalid shape");var m=Array.isArray(e.data)?p.dtype:D(e.data),h=Le.allocType(m,s*f);P(h,e.data,s,f,u,c,e.offset),d(h,r),Le.freeType(h)}else ke.raise("invalid data for buffer subdata");return l},n.profile&&(l.stats=p.stats),l.destroy=function(){o(p)},l},createStream:function(e,t){var n=u.pop();return n||(n=new r(e)),n.bind(),a(n,t,qe,0,1,!1),n},destroyStream:function(e){u.push(e)},clear:function(){je(f).forEach(o),u.forEach(o)},getBuffer:function(e){return e&&e._buffer instanceof r?e._buffer:null},restore:function(){je(f).forEach(function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)})},_initBuffer:a}}(m,y,p),j=function(e,t,n,r){function i(e){this.id=f++,s[this.id]=this,this.buffer=e,this.primType=Je,this.vertCount=0,this.type=0}function a(r,i,a,o,s,f,u){if(r.buffer.bind(),i){var c=u;u||fe(i)&&(!S(i)||fe(i.data))||(c=t.oes_element_index_uint?at:rt),n._initBuffer(r.buffer,i,a,c,3)}else e.bufferData(ot,f,a),r.buffer.dtype=l||tt,r.buffer.usage=a,r.buffer.dimension=3,r.buffer.byteLength=f;var l=u;if(!u){switch(r.buffer.dtype){case tt:case et:l=tt;break;case rt:case nt:l=rt;break;case at:case it:l=at;break;default:ke.raise("unsupported type for element array")}r.buffer.dtype=l}r.type=l,ke(l!==at||!!t.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var d=s;d<0&&(d=r.buffer.byteLength,l===rt?d>>=1:l===at&&(d>>=2)),r.vertCount=d;var p=o;if(o<0){p=Je;var m=r.buffer.dimension;1===m&&(p=Ke),2===m&&(p=Ze),3===m&&(p=Je)}r.primType=p}function o(e){r.elementsCount--,ke(null!==e.buffer,"must not double destroy elements"),delete s[e.id],e.buffer.destroy(),e.buffer=null}var s={},f=0,u={uint8:tt,uint16:rt};t.oes_element_index_uint&&(u.uint32=at),i.prototype.bind=function(){this.buffer.bind()};var c=[];return{create:function(e,t){function s(e){if(e)if("number"==typeof e)f(e),c.primType=Je,c.vertCount=0|e,c.type=tt;else{var t=null,n=ft,r=-1,i=-1,o=0,l=0;Array.isArray(e)||fe(e)||S(e)?t=e:(ke.type(e,"object","invalid arguments for elements"),"data"in e&&(t=e.data,ke(Array.isArray(t)||fe(t)||S(t),"invalid data for element buffer")),"usage"in e&&(ke.parameter(e.usage,Ie,"invalid element buffer usage"),n=Ie[e.usage]),"primitive"in e&&(ke.parameter(e.primitive,$e,"invalid element buffer primitive"),r=$e[e.primitive]),"count"in e&&(ke("number"==typeof e.count&&e.count>=0,"invalid vertex count for elements"),i=0|e.count),"type"in e&&(ke.parameter(e.type,u,"invalid buffer type"),l=u[e.type]),"length"in e?o=0|e.length:(o=i,l===rt||l===nt?o*=2:l!==at&&l!==it||(o*=4))),a(c,t,n,r,i,o,l)}else f(),c.primType=Je,c.vertCount=0,c.type=tt;return s}var f=n.create(null,ot,!0),c=new i(f._buffer);return r.elementsCount++,s(e),s._reglType="elements",s._elements=c,s.subdata=function(e,t){return f.subdata(e,t),s},s.destroy=function(){o(c)},s},createStream:function(e){var t=c.pop();return t||(t=new i(n.create(null,ot,!0,!1)._buffer)),a(t,e,st,-1,-1,0,0),t},destroyStream:function(e){c.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof i?e._elements:null},clear:function(){je(s).forEach(o)}}}(m,x,E,y),W=function(e,t,n,r,i){for(var a=n.maxAttributes,o=new Array(a),s=0;s=Rn&&t=2,"invalid shape for framebuffer"),u=M[0],p=M[1]}else"radius"in D&&(u=p=D.radius),"width"in D&&(u=D.width),"height"in D&&(p=D.height);("color"in D||"colors"in D)&&(v=D.color||D.colors,Array.isArray(v)&&ke(1===v.length||s,"multiple render targets not supported")),v||("colorCount"in D&&(A=0|D.colorCount,ke(A>0,"invalid color buffer count")),"colorTexture"in D&&(k=!!D.colorTexture,S="rgba4"),"colorType"in D&&(T=D.colorType,k?(ke(t.oes_texture_float||!("float"===T||"float32"===T),"you must enable OES_texture_float in order to use floating point framebuffer objects"),ke(t.oes_texture_half_float||!("half float"===T||"float16"===T),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===T||"float16"===T?(ke(t.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),S="rgba16f"):"float"!==T&&"float32"!==T||(ke(t.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),S="rgba32f"),ke.oneOf(T,_,"invalid color type")),"colorFormat"in D&&(S=D.colorFormat,x.indexOf(S)>=0?k=!0:w.indexOf(S)>=0?k=!1:k?ke.oneOf(D.colorFormat,x,"invalid color format for texture"):ke.oneOf(D.colorFormat,w,"invalid color format for renderbuffer"))),("depthTexture"in D||"depthStencilTexture"in D)&&(j=!(!D.depthTexture&&!D.depthStencilTexture),ke(!j||t.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in D&&("boolean"==typeof D.depth?m=D.depth:(O=D.depth,b=!1)),"stencil"in D&&("boolean"==typeof D.stencil?b=D.stencil:(C=D.stencil,m=!1)),"depthStencil"in D&&("boolean"==typeof D.depthStencil?m=b=D.depthStencil:(E=D.depthStencil,m=!1,b=!1))}else u=p=1;var P=null,W=null,z=null,F=null;if(Array.isArray(v))P=v.map(c);else if(v)P=[c(v)];else for(P=new Array(A),a=0;a=0||P[a].renderbuffer&&$n.indexOf(P[a].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+a+" is invalid"),P[a]&&P[a].texture){var B=Gn[P[a].texture._texture.format]*qn[P[a].texture._texture.type];null===R?R=B:ke(R===B,"all color attachments much have the same number of bits per pixel.")}return f(W,u,p),ke(!W||W.texture&&W.texture._texture.format===Hn||W.renderbuffer&&W.renderbuffer._renderbuffer.format===Qn,"invalid depth attachment for framebuffer object"),f(z,u,p),ke(!z||z.renderbuffer&&z.renderbuffer._renderbuffer.format===Xn,"invalid stencil attachment for framebuffer object"),f(F,u,p),ke(!F||F.texture&&F.texture._texture.format===Yn||F.renderbuffer&&F.renderbuffer._renderbuffer.format===Yn,"invalid depth-stencil attachment for framebuffer object"),h(o),o.width=u,o.height=p,o.colorAttachments=P,o.depthAttachment=W,o.stencilAttachment=z,o.depthStencilAttachment=F,i.color=P.map(d),i.depth=d(W),i.stencil=d(z),i.depthStencil=d(F),i.width=o.width,i.height=o.height,g(o),i}var o=new m;return a.framebufferCount++,i(e,r),ue(i,{resize:function(e,t){ke(y.next!==o,"can not resize a framebuffer which is currently in use");var n=0|e,r=0|t||n;if(n===o.width&&r===o.height)return i;for(var a=o.colorAttachments,s=0;s=2,"invalid shape for framebuffer"),ke(m[0]===m[1],"cube framebuffer must be square"),f=m[0]}else"radius"in p&&(f=0|p.radius),"width"in p?(f=0|p.width,"height"in p&&ke(p.height===f,"must be square")):"height"in p&&(f=0|p.height);("color"in p||"colors"in p)&&(u=p.color||p.colors,Array.isArray(u)&&ke(1===u.length||o,"multiple render targets not supported")),u||("colorCount"in p&&(d=0|p.colorCount,ke(d>0,"invalid color buffer count")),"colorType"in p&&(ke.oneOf(p.colorType,_,"invalid color type"),l=p.colorType),"colorFormat"in p&&(c=p.colorFormat,ke.oneOf(p.colorFormat,x,"invalid color format for texture"))),"depth"in p&&(s.depth=p.depth),"stencil"in p&&(s.stencil=p.stencil),"depthStencil"in p&&(s.depthStencil=p.depthStencil)}else f=1;var h;if(u)if(Array.isArray(u))for(h=[],n=0;n0&&(s.depth=a[0].depth,s.stencil=a[0].stencil,s.depthStencil=a[0].depthStencil),a[n]?a[n](s):a[n]=v(s)}return ue(i,{width:f,height:f,color:h})}var a=Array(6);return i(e),ue(i,{faces:a,resize:function(e){var t,r=0|e;if(ke(r>0&&r<=n.maxCubeMapSize,"invalid radius for cube fbo"),r===i.width)return i;var o=i.color;for(t=0;t=0},read:N,destroy:function(){H.length=0,r(),I&&(I.removeEventListener(la,i),I.removeEventListener(da,a)),z.clear(),B.clear(),R.clear(),F.clear(),j.clear(),E.clear(),w&&w.clear(),Q.forEach(function(e){e()})},_gl:m,_refresh:l,poll:function(){c(),w&&w.update()},now:d,stats:y});return p.onDone(null,J),J}})},{}],38:[function(e,t,n){"use strict";t.exports=function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return t>>>0}},{}],39:[function(e,t,n){"use strict";function r(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function i(e){return e[e.length-1]}Object.defineProperty(n,"__esModule",{value:!0});class a{constructor(){this.selfTime=0,this.totalTime=0}getSelfTime(){return this.selfTime}getTotalTime(){return this.totalTime}addToTotalTime(e){this.totalTime+=e}addToSelfTime(e){this.selfTime+=e}}n.HasTimings=a;class o extends a{constructor(e){super(),this.key=e.key,this.name=e.name,this.file=e.file,this.line=e.line,this.col=e.col}}n.Frame=o;class s extends a{constructor(e,t){super(),this.frame=e,this.parent=t,this.children=[]}}n.CallTreeNode=s;n.Profile=class{constructor(e){this.frames=new Map,this.calltreeRoots=[],this.samples=[],this.timeDeltas=[],this.events=[],this.duration=e}getDuration(){return this.duration}getEvents(){return this.events}forEachSample(e){const t=new Map;for(let n=0;n numeric require +// +// anything defined in a previous bundle is accessed via the +// orig method which is the require for previous bundles + +require = (function (modules, cache, entry) { + // Save the require from previous bundle to this closure if any + var previousRequire = typeof require === "function" && require; + + function newRequire(name, jumped) { + if (!cache[name]) { + if (!modules[name]) { + // if we cannot find the module within our internal map or + // cache jump to the current global require ie. the last bundle + // that was added to the page. + var currentRequire = typeof require === "function" && require; + if (!jumped && currentRequire) { + return currentRequire(name, true); + } + + // If there are other bundles on this page the require from the + // previous one is saved to 'previousRequire'. Repeat this as + // many times as there are bundles until the module is found or + // we exhaust the require chain. + if (previousRequire) { + return previousRequire(name, true); + } + + var err = new Error('Cannot find module \'' + name + '\''); + err.code = 'MODULE_NOT_FOUND'; + throw err; + } + + function localRequire(x) { + return newRequire(localRequire.resolve(x)); + } + + localRequire.resolve = function (x) { + return modules[name][1][x] || x; + }; + + var module = cache[name] = new newRequire.Module; + modules[name][0].call(module.exports, localRequire, module, module.exports); + } + + return cache[name].exports; + } + + function Module() { + this.bundle = newRequire; + this.exports = {}; + } + + newRequire.Module = Module; + newRequire.modules = modules; + newRequire.cache = cache; + newRequire.parent = previousRequire; + + for (var i = 0; i < entry.length; i++) { + newRequire(entry[i]); + } + + // Override the current require with this new one + return newRequire; +})({7:[function(require,module,exports) { +"use strict";function t(t,i,s){return ts?s:t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.clamp=t;class i{constructor(t=0,i=0){this.x=t,this.y=i}withX(t){return new i(t,this.y)}withY(t){return new i(this.x,t)}plus(t){return new i(this.x+t.x,this.y+t.y)}minus(t){return new i(this.x-t.x,this.y-t.y)}times(t){return new i(this.x*t,this.y*t)}timesPointwise(t){return new i(this.x*t.x,this.y*t.y)}dot(t){return this.x*t.x+this.y*t.y}length2(){return this.dot(this)}length(){return Math.sqrt(this.length2())}static min(t,s){return new i(Math.min(t.x,s.x),Math.min(t.y,s.y))}static max(t,s){return new i(Math.max(t.x,s.x),Math.max(t.y,s.y))}flatten(){return[this.x,this.y]}}exports.Vec2=i;class s{constructor(t=1,i=0,s=0,e=0,r=1,n=0){this.m00=t,this.m01=i,this.m02=s,this.m10=e,this.m11=r,this.m12=n}withScale(t){let{m00:i,m01:e,m02:r,m10:n,m11:h,m12:m}=this;return i=t.x,h=t.y,new s(i,e,r,n,h,m)}static withScale(t){return(new s).withScale(t)}scaledBy(t){return s.withScale(t).times(this)}getScale(){return new i(this.m00,this.m11)}withTranslation(t){let{m00:i,m01:e,m02:r,m10:n,m11:h,m12:m}=this;return r=t.x,m=t.y,new s(i,e,r,n,h,m)}static withTranslation(t){return(new s).withTranslation(t)}getTranslation(){return new i(this.m02,this.m12)}translatedBy(t){return s.withTranslation(t).times(this)}static betweenRects(t,e){return s.withTranslation(t.origin.times(-1)).scaledBy(new i(e.size.x/t.size.x,e.size.y/t.size.y)).translatedBy(e.origin)}times(t){const i=this.m00*t.m00+this.m01*t.m10,e=this.m00*t.m01+this.m01*t.m11,r=this.m00*t.m02+this.m01*t.m12+this.m02,n=this.m10*t.m00+this.m11*t.m10,h=this.m10*t.m01+this.m11*t.m11,m=this.m10*t.m02+this.m11*t.m12+this.m12;return new s(i,e,r,n,h,m)}timesScalar(t){const{m00:i,m01:e,m02:r,m10:n,m11:h,m12:m}=this;return new s(t*i,t*e,t*r,t*n,t*h,t*m)}det(){const{m00:t,m01:i,m02:s,m10:e,m11:r,m12:n}=this;return t*(1*r-0*n)-i*(1*e-0*n)+s*(0*e-0*r)}adj(){const{m00:t,m01:i,m02:e,m10:r,m11:n,m12:h}=this;return new s(+(1*n-0*h),-(1*i-0*e),+(i*h-e*n),-(1*r-0*h),+(1*t-0*e),-(t*h-e*r))}inverted(){const t=this.det();if(0===t)return null;return this.adj().timesScalar(1/t)}transformVector(t){return new i(t.x*this.m00+t.y*this.m01,t.x*this.m10+t.y*this.m11)}inverseTransformVector(t){const i=this.inverted();return i?i.transformVector(t):null}transformPosition(t){return new i(t.x*this.m00+t.y*this.m01+this.m02,t.x*this.m10+t.y*this.m11+this.m12)}inverseTransformPosition(t){const i=this.inverted();return i?i.transformPosition(t):null}transformRect(t){return new e(this.transformPosition(t.origin),this.transformVector(t.size))}flatten(){return[this.m00,this.m10,0,this.m01,this.m11,0,this.m02,this.m12,1]}}exports.AffineTransform=s;class e{constructor(t=new i,s=new i){this.origin=t,this.size=s}isEmpty(){return 0==this.width()||0==this.height()}width(){return this.size.x}height(){return this.size.y}left(){return this.origin.x}right(){return this.left()+this.width()}top(){return this.origin.y}bottom(){return this.top()+this.height()}topLeft(){return this.origin}topRight(){return this.origin.plus(new i(this.width(),0))}bottomRight(){return this.origin.plus(this.size)}bottomLeft(){return this.origin.plus(new i(0,this.height()))}withOrigin(t){return new e(t,this.size)}withSize(t){return new e(this.origin,t)}closestPointTo(s){return new i(t(s.x,this.left(),this.right()),t(s.y,this.top(),this.bottom()))}distanceFrom(t){return t.minus(this.closestPointTo(t)).length()}contains(t){return 0===this.distanceFrom(t)}intersectWith(t){const s=i.max(this.topLeft(),t.topLeft()),r=i.max(s,i.min(this.bottomRight(),t.bottomRight()));return new e(s,r.minus(s))}}exports.Rect=e; +},{}],8:[function(require,module,exports) { +"use strict";function e(e){let t=null;return function(...n){null==t&&(t=requestAnimationFrame(function(){e(...n),t=null}))}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.atMostOnceAFrame=e; +},{}],5:[function(require,module,exports) { +!function(){"use strict";function e(e,t){var n,o,r,i,l=N;for(i=arguments.length;i-- >2;)x.push(arguments[i]);for(t&&null!=t.children&&(x.length||x.push(t.children),delete t.children);x.length;)if((o=x.pop())&&void 0!==o.pop)for(i=o.length;i--;)x.push(o[i]);else"boolean"==typeof o&&(o=null),(r="function"!=typeof e)&&(null==o?o="":"number"==typeof o?o=String(o):"string"!=typeof o&&(r=!1)),r&&n?l[l.length-1]+=o:l===N?l=[o]:l.push(o),n=r;var a=new function(){};return a.nodeName=e,a.children=l,a.attributes=null==t?void 0:t,a.key=null==t?void 0:t.key,void 0!==C.vnode&&C.vnode(a),a}function t(e,t){for(var n in t)e[n]=t[n];return e}function n(e){!e.__d&&(e.__d=!0)&&1==U.push(e)&&(C.debounceRendering||w)(o)}function o(){var e,t=U;for(U=[];e=t.pop();)e.__d&&b(e)}function r(e,t,n){return"string"==typeof t||"number"==typeof t?void 0!==e.splitText:"string"==typeof t.nodeName?!e._componentConstructor&&i(e,t.nodeName):n||e._componentConstructor===t.nodeName}function i(e,t){return e.__n===t||e.nodeName.toLowerCase()===t.toLowerCase()}function l(e){var n=t({},e.attributes);n.children=e.children;var o=e.nodeName.defaultProps;if(void 0!==o)for(var r in o)void 0===n[r]&&(n[r]=o[r]);return n}function a(e){var t=e.parentNode;t&&t.removeChild(e)}function u(e,t,n,o,r){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)n&&n(null),o&&o(e);else if("class"!==t||r)if("style"===t){if(o&&"string"!=typeof o&&"string"!=typeof n||(e.style.cssText=o||""),o&&"object"==typeof o){if("string"!=typeof n)for(var i in n)i in o||(e.style[i]="");for(var i in o)e.style[i]="number"==typeof o[i]&&!1===k.test(i)?o[i]+"px":o[i]}}else if("dangerouslySetInnerHTML"===t)o&&(e.innerHTML=o.__html||"");else if("o"==t[0]&&"n"==t[1]){var l=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),o?n||e.addEventListener(t,_,l):e.removeEventListener(t,_,l),(e.__l||(e.__l={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e)!function(e,t,n){try{e[t]=n}catch(e){}}(e,t,null==o?"":o),null!=o&&!1!==o||e.removeAttribute(t);else{var a=r&&t!==(t=t.replace(/^xlink\:?/,""));null==o||!1===o?a?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof o&&(a?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),o):e.setAttribute(t,o))}else e.className=o||""}function _(e){return this.__l[e.type](C.event&&C.event(e)||e)}function p(){for(var e;e=S.pop();)C.afterMount&&C.afterMount(e),e.componentDidMount&&e.componentDidMount()}function c(e,t,n,o,r,i){L++||(T=null!=r&&void 0!==r.ownerSVGElement,M=null!=e&&!("__preactattr_"in e));var l=s(e,t,n,o,i);return r&&l.parentNode!==r&&r.appendChild(l),--L||(M=!1,i||p()),l}function s(e,t,n,o,_){var p=e,c=T;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||_)?e.nodeValue!=t&&(e.nodeValue=t):(p=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(p,e),f(e,!0))),p.__preactattr_=!0,p;var d=t.nodeName;if("function"==typeof d)return function(e,t,n,o){var r=e&&e._component,i=r,a=e,u=r&&e._componentConstructor===t.nodeName,_=u,p=l(t);for(;r&&!_&&(r=r.__u);)_=r.constructor===t.nodeName;r&&_&&(!o||r._component)?(v(r,p,3,n,o),e=r.base):(i&&!u&&(y(i),e=a=null),r=h(t.nodeName,p,n),e&&!r.__b&&(r.__b=e,a=null),v(r,p,1,n,o),e=r.base,a&&e!==a&&(a._component=null,f(a,!1)));return e}(e,t,n,o);if(T="svg"===d||"foreignObject"!==d&&T,d=String(d),(!e||!i(e,d))&&(p=function(e,t){var n=t?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n.__n=e,n}(d,T),e)){for(;e.firstChild;)p.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(p,e),f(e,!0)}var m=p.firstChild,b=p.__preactattr_,g=t.children;if(null==b){b=p.__preactattr_={};for(var C=p.attributes,x=C.length;x--;)b[C[x].name]=C[x].value}return!M&&g&&1===g.length&&"string"==typeof g[0]&&null!=m&&void 0!==m.splitText&&null==m.nextSibling?m.nodeValue!=g[0]&&(m.nodeValue=g[0]):(g&&g.length||null!=m)&&function(e,t,n,o,i){var l,u,_,p,c,d=e.childNodes,h=[],m={},v=0,b=0,y=d.length,g=0,C=t?t.length:0;if(0!==y)for(var x=0;x2?[].slice.call(arguments,2):n.children)},Component:g,render:function(e,t,n){return c(n,e,{},!1,t,!1)},rerender:o,options:C};"undefined"!=typeof module?module.exports=E:self.preact=E}(); +},{}],38:[function(require,module,exports) { +"use strict";function e(e){return"string"==typeof e&&t.test(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var t=/-webkit-|-moz-|-ms-/;module.exports=exports.default; +},{}],26:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,u.default)(t)&&t.indexOf("calc(")>-1)return i.map(function(e){return t.replace(/calc\(/g,e+"calc(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),u=e(r),i=["-webkit-","-moz-",""];module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":38}],27:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function r(e,r){if("string"==typeof r&&!(0,s.default)(r)&&r.indexOf("cross-fade(")>-1)return u.map(function(e){return r.replace(/cross-fade\(/g,e+"cross-fade(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=r;var t=require("css-in-js-utils/lib/isPrefixedValue"),s=e(t),u=["-webkit-",""];module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":38}],28:[function(require,module,exports) { +"use strict";function e(e,t){if("cursor"===e&&o.hasOwnProperty(t))return r.map(function(e){return e+t})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var r=["-webkit-","-moz-",""],o={"zoom-in":!0,"zoom-out":!0,grab:!0,grabbing:!0};module.exports=exports.default; +},{}],29:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,i.default)(t)&&t.indexOf("filter(")>-1)return u.map(function(e){return t.replace(/filter\(/g,e+"filter(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),u=["-webkit-",""];module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":38}],30:[function(require,module,exports) { +"use strict";function e(e,l){if("display"===e&&i.hasOwnProperty(l))return i[l]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var i={flex:["-webkit-box","-moz-box","-ms-flexbox","-webkit-flex","flex"],"inline-flex":["-webkit-inline-box","-moz-inline-box","-ms-inline-flexbox","-webkit-inline-flex","inline-flex"]};module.exports=exports.default; +},{}],31:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,i.default)(t)&&t.indexOf("image-set(")>-1)return u.map(function(e){return t.replace(/image-set\(/g,e+"image-set(")})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),u=["-webkit-",""];module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":38}],32:[function(require,module,exports) { +"use strict";function e(e,l,r){s.hasOwnProperty(e)&&(r[s[e]]=t[l]||l)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var t={"space-around":"distribute","space-between":"justify","flex-start":"start","flex-end":"end"},s={alignContent:"msFlexLinePack",alignSelf:"msFlexItemAlign",alignItems:"msFlexAlign",justifyContent:"msFlexPack",order:"msFlexOrder",flexGrow:"msFlexPositive",flexShrink:"msFlexNegative",flexBasis:"msFlexPreferredSize"};module.exports=exports.default; +},{}],33:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e,t){if("string"==typeof t&&!(0,i.default)(t)&&n.test(t))return a.map(function(e){return e+t})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("css-in-js-utils/lib/isPrefixedValue"),i=e(r),a=["-webkit-","-moz-",""],n=/linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/;module.exports=exports.default; +},{"css-in-js-utils/lib/isPrefixedValue":38}],34:[function(require,module,exports) { +"use strict";function e(e,r,o){"flexDirection"===e&&"string"==typeof r&&(r.indexOf("column")>-1?o.WebkitBoxOrient="vertical":o.WebkitBoxOrient="horizontal",r.indexOf("reverse")>-1?o.WebkitBoxDirection="reverse":o.WebkitBoxDirection="normal"),i.hasOwnProperty(e)&&(o[i[e]]=t[r]||r)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e;var t={"space-around":"justify","space-between":"justify","flex-start":"start","flex-end":"end","wrap-reverse":"multiple",wrap:"multiple"},i={alignItems:"WebkitBoxAlign",justifyContent:"WebkitBoxPack",flexWrap:"WebkitBoxLines"};module.exports=exports.default; +},{}],35:[function(require,module,exports) { +"use strict";function e(e,t){if("position"===e&&"sticky"===t)return["-webkit-sticky","sticky"]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e,module.exports=exports.default; +},{}],36:[function(require,module,exports) { +"use strict";function t(t,o){if(n.hasOwnProperty(t)&&i.hasOwnProperty(o))return e.map(function(t){return t+o})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var e=["-webkit-","-moz-",""],n={maxHeight:!0,maxWidth:!0,width:!0,height:!0,columnWidth:!0,minWidth:!0,minHeight:!0},i={"min-content":!0,"max-content":!0,"fill-available":!0,"fit-content":!0,"contain-floats":!0};module.exports=exports.default; +},{}],25:[function(require,module,exports) { +"use strict";function e(e){return e.charAt(0).toUpperCase()+e.slice(1)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e,module.exports=exports.default; +},{}],40:[function(require,module,exports) { +"use strict";function e(e){return e in t?t[e]:t[e]=e.replace(r,"-$&").toLowerCase().replace(s,"-ms-")}var r=/[A-Z]/g,s=/^ms-/,t={};module.exports=e; +},{}],39:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}function t(e){return(0,u.default)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=t;var r=require("hyphenate-style-name"),u=e(r);module.exports=exports.default; +},{"hyphenate-style-name":40}],37:[function(require,module,exports) { +"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t,e){if((0,s.default)(t))return t;for(var r=t.split(/,(?![^()]*(?:\([^()]*\))?\))/g),i=0,o=r.length;i-1&&"order"!==p)for(var d=e[f],c=0,b=d.length;c-1)return s;var u=o.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function(t){return!/-webkit-|-ms-/.test(t)}).join(",");return t.indexOf("Moz")>-1?u:(i["Webkit"+(0,a.default)(t)]=s,i["Moz"+(0,a.default)(t)]=u,o)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=r;var i=require("css-in-js-utils/lib/hyphenateProperty"),n=t(i),o=require("css-in-js-utils/lib/isPrefixedValue"),s=t(o),u=require("../../utils/capitalizeString"),a=t(u),f={transition:!0,transitionProperty:!0,WebkitTransition:!0,WebkitTransitionProperty:!0,MozTransition:!0,MozTransitionProperty:!0},l={Webkit:"-webkit-",Moz:"-moz-",ms:"-ms-"};module.exports=exports.default; +},{"../../utils/capitalizeString":25,"css-in-js-utils/lib/isPrefixedValue":38,"css-in-js-utils/lib/hyphenateProperty":39}],13:[function(require,module,exports) { +var e=require("inline-style-prefixer/static/plugins/calc"),i=require("inline-style-prefixer/static/plugins/crossFade"),t=require("inline-style-prefixer/static/plugins/cursor"),r=require("inline-style-prefixer/static/plugins/filter"),s=require("inline-style-prefixer/static/plugins/flex"),o=require("inline-style-prefixer/static/plugins/flexboxIE"),n=require("inline-style-prefixer/static/plugins/flexboxOld"),a=require("inline-style-prefixer/static/plugins/gradient"),k=require("inline-style-prefixer/static/plugins/imageSet"),m=require("inline-style-prefixer/static/plugins/position"),l=require("inline-style-prefixer/static/plugins/sizing"),b=require("inline-style-prefixer/static/plugins/transition");module.exports={plugins:[e,i,t,r,s,o,n,a,k,m,l,b],prefixMap:{transform:["Webkit","ms"],transformOrigin:["Webkit","ms"],transformOriginX:["Webkit","ms"],transformOriginY:["Webkit","ms"],backfaceVisibility:["Webkit"],perspective:["Webkit"],perspectiveOrigin:["Webkit"],transformStyle:["Webkit"],transformOriginZ:["Webkit"],animation:["Webkit"],animationDelay:["Webkit"],animationDirection:["Webkit"],animationFillMode:["Webkit"],animationDuration:["Webkit"],animationIterationCount:["Webkit"],animationName:["Webkit"],animationPlayState:["Webkit"],animationTimingFunction:["Webkit"],appearance:["Webkit","Moz"],userSelect:["Webkit","Moz","ms"],fontKerning:["Webkit"],textEmphasisPosition:["Webkit"],textEmphasis:["Webkit"],textEmphasisStyle:["Webkit"],textEmphasisColor:["Webkit"],boxDecorationBreak:["Webkit"],clipPath:["Webkit"],maskImage:["Webkit"],maskMode:["Webkit"],maskRepeat:["Webkit"],maskPosition:["Webkit"],maskClip:["Webkit"],maskOrigin:["Webkit"],maskSize:["Webkit"],maskComposite:["Webkit"],mask:["Webkit"],maskBorderSource:["Webkit"],maskBorderMode:["Webkit"],maskBorderSlice:["Webkit"],maskBorderWidth:["Webkit"],maskBorderOutset:["Webkit"],maskBorderRepeat:["Webkit"],maskBorder:["Webkit"],maskType:["Webkit"],textDecorationStyle:["Webkit","Moz"],textDecorationSkip:["Webkit","Moz"],textDecorationLine:["Webkit","Moz"],textDecorationColor:["Webkit","Moz"],filter:["Webkit"],fontFeatureSettings:["Webkit","Moz"],breakAfter:["Webkit","Moz","ms"],breakBefore:["Webkit","Moz","ms"],breakInside:["Webkit","Moz","ms"],columnCount:["Webkit","Moz"],columnFill:["Webkit","Moz"],columnGap:["Webkit","Moz"],columnRule:["Webkit","Moz"],columnRuleColor:["Webkit","Moz"],columnRuleStyle:["Webkit","Moz"],columnRuleWidth:["Webkit","Moz"],columns:["Webkit","Moz"],columnSpan:["Webkit","Moz"],columnWidth:["Webkit","Moz"],flex:["Webkit","ms"],flexBasis:["Webkit"],flexDirection:["Webkit","ms"],flexGrow:["Webkit"],flexFlow:["Webkit","ms"],flexShrink:["Webkit"],flexWrap:["Webkit","ms"],alignContent:["Webkit"],alignItems:["Webkit"],alignSelf:["Webkit"],justifyContent:["Webkit"],order:["Webkit"],transitionDelay:["Webkit"],transitionDuration:["Webkit"],transitionProperty:["Webkit"],transitionTimingFunction:["Webkit"],backdropFilter:["Webkit"],scrollSnapType:["Webkit","ms"],scrollSnapPointsX:["Webkit","ms"],scrollSnapPointsY:["Webkit","ms"],scrollSnapDestination:["Webkit","ms"],scrollSnapCoordinate:["Webkit","ms"],shapeImageThreshold:["Webkit"],shapeImageMargin:["Webkit"],shapeImageOutside:["Webkit"],hyphens:["Webkit","Moz","ms"],flowInto:["Webkit","ms"],flowFrom:["Webkit","ms"],regionFragment:["Webkit","ms"],boxSizing:["Moz"],textAlignLast:["Moz"],tabSize:["Moz"],wrapFlow:["ms"],wrapThrough:["ms"],wrapMargin:["ms"],touchAction:["ms"],gridTemplateColumns:["ms"],gridTemplateRows:["ms"],gridTemplateAreas:["ms"],gridTemplate:["ms"],gridAutoColumns:["ms"],gridAutoRows:["ms"],gridAutoFlow:["ms"],grid:["ms"],gridRowStart:["ms"],gridColumnStart:["ms"],gridRowEnd:["ms"],gridRow:["ms"],gridColumn:["ms"],gridColumnEnd:["ms"],gridColumnGap:["ms"],gridRowGap:["ms"],gridArea:["ms"],gridGap:["ms"],textSizeAdjust:["Webkit","ms"],borderImage:["Webkit"],borderImageOutset:["Webkit"],borderImageRepeat:["Webkit"],borderImageSlice:["Webkit"],borderImageSource:["Webkit"],borderImageWidth:["Webkit"]}}; +},{"inline-style-prefixer/static/plugins/calc":26,"inline-style-prefixer/static/plugins/crossFade":27,"inline-style-prefixer/static/plugins/cursor":28,"inline-style-prefixer/static/plugins/filter":29,"inline-style-prefixer/static/plugins/flex":30,"inline-style-prefixer/static/plugins/imageSet":31,"inline-style-prefixer/static/plugins/flexboxIE":32,"inline-style-prefixer/static/plugins/gradient":33,"inline-style-prefixer/static/plugins/flexboxOld":34,"inline-style-prefixer/static/plugins/position":35,"inline-style-prefixer/static/plugins/sizing":36,"inline-style-prefixer/static/plugins/transition":37}],14:[function(require,module,exports) { +"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n>>0}module.exports=r; +},{}],15:[function(require,module,exports) { +"use strict";function r(r){return r&&r.__esModule?r:{default:r}}function t(r,t){return r+t.charAt(0).toUpperCase()+t.substring(1)}Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return function(r,t){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return function(r,t){var e=[],n=!0,o=!1,i=void 0;try{for(var a,u=r[Symbol.iterator]();!(n=(a=u.next()).done)&&(e.push(a.value),!t||e.length!==t);n=!0);}catch(r){o=!0,i=r}finally{try{!n&&u.return&&u.return()}finally{if(o)throw i}}return e}(r,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=require("string-hash"),o=r(n),i=function(r,t){for(var n=Object.keys(r),o={},i=0;i0&&(e[i]=d)}else{var x=(0,a.default)(l,i,s,e,t);x&&(e[i]=x),(0,u.default)(t,i,e)}}return e}var t=e.prefixMap,l=e.plugins;return r}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=r;var t=require("../utils/prefixProperty"),u=e(t),l=require("../utils/prefixValue"),a=e(l),i=require("../utils/addNewValuesOnly"),f=e(i),s=require("../utils/isObject"),n=e(s);module.exports=exports.default; +},{"../utils/prefixProperty":21,"../utils/prefixValue":22,"../utils/addNewValuesOnly":23,"../utils/isObject":24}],11:[function(require,module,exports) { +"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var r=Object.assign||function(e){for(var r=1;rc){for(var t=0,n=u.length-i;t0&&u(e)};exports.flushToStyleTag=g;var S=function(){return Object.keys(c)};exports.getRenderedClassNames=S;var x=function(e){e.forEach(function(e){c[e]=!0})};exports.addRenderedClassNames=x;var N=function e(t,n){for(var r=0;r1&&t===r&&('"'===t||"'"===t))return['"'+v(e.substr(1,e.length-2))+'"'];var n=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(e);if(n)return y(e.substr(0,n.index)).concat(y(n[1])).concat(y(e.substr(n.index+n[0].length)));var a=e.split(".");if(1===a.length)return['"'+v(e)+'"'];for(var i=[],o=0;o0,"invalid pixel ratio")):n=(a=i).canvas:t=i:Ae.raise("invalid arguments to regl"),t&&("canvas"===t.nodeName.toLowerCase()?n=t:r=t),!a){if(!n){Ae("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var m=function(e,t,r){function n(){var t=window.innerWidth,n=window.innerHeight;if(e!==document.body){var i=e.getBoundingClientRect();t=i.right-i.left,n=i.bottom-i.top}a.width=r*t,a.height=r*n,se(a.style,{width:t+"px",height:n+"px"})}var a=document.createElement("canvas");return se(a.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(a),e===document.body&&(a.style.position="absolute",se(e.style,{margin:0,padding:0})),window.addEventListener("resize",n,!1),n(),{canvas:a,onDestroy:function(){window.removeEventListener("resize",n),e.removeChild(a)}}}(r||document.body,0,s);if(!m)return null;n=m.canvas,d=m.onDestroy}a=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")}(n,o)}return a?{gl:a,canvas:n,container:r,extensions:f,optionalExtensions:u,pixelRatio:s,profile:c,onDone:l,onDestroy:d}:(d(),l("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function S(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||ue(e.data))}function _(e,t){for(var r=Array(e),n=0;n65535)<<4,e>>>=t,r=(e>255)<<3,e>>>=r,t|=r,r=(e>15)<<2,e>>>=r,t|=r,r=(e>3)<<1,e>>>=r,(t|=r)|e>>1}function T(e){var t=function(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}(e),r=Ie[E(t)>>2];return r.length>0?r.pop():new ArrayBuffer(t)}function D(e){Ie[E(e.byteLength)>>2].push(e)}function j(e,t,r,n,a,i){for(var o=i,f=0;f>>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 P(e){return Array.isArray(e)||ue(e)}function R(e){return"[object "+e+"]"}function L(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function I(e){if(!Array.isArray(e))return!1;return!(0===e.length||!P(e[0]))}function M(e){return Object.prototype.toString.call(e)}function W(e){return M(e)===kr}function H(e){if(!e)return!1;var t=M(e);return Er.indexOf(t)>=0||(L(e)||I(e)||S(e))}function G(e){return 0|fe[Object.prototype.toString.call(e)]}function U(e,t){return Me.allocType(e.type===Ft?Yt:e.type,t)}function N(e,t){e.type===Ft?(e.data=B(t),Me.freeType(t)):e.data=t}function q(e,t,r,n,a,i){var o;if(o=void 0!==Dr[e]?Dr[e]:wr[e]*Tr[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 Q(e,t,r,n,a,i,o){function f(){this.internalformat=bt,this.format=bt,this.type=qt,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=0,this.width=0,this.height=0,this.channels=0}function u(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 s(e,n){if("object"==typeof n&&n){if("premultiplyAlpha"in n&&(Ae.type(n.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=n.premultiplyAlpha),"flipY"in n&&(Ae.type(n.flipY,"boolean","invalid texture flip"),e.flipY=n.flipY),"alignment"in n&&(Ae.oneOf(n.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=n.alignment),"colorSpace"in n&&(Ae.parameter(n.colorSpace,R,"invalid colorSpace"),e.colorSpace=R[n.colorSpace]),"type"in n){var a=n.type;Ae(t.oes_texture_float||!("float"===a||"float32"===a),"you must enable the OES_texture_float extension in order to use floating point textures."),Ae(t.oes_texture_half_float||!("half float"===a||"float16"===a),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),Ae(t.webgl_depth_texture||!("uint16"===a||"uint32"===a||"depth stencil"===a),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),Ae.parameter(a,Q,"invalid texture type"),e.type=Q[a]}var i=e.width,o=e.height,f=e.channels,u=!1;"shape"in n?(Ae(Array.isArray(n.shape)&&n.shape.length>=2,"shape must be an array"),i=n.shape[0],o=n.shape[1],3===n.shape.length&&(f=n.shape[2],Ae(f>0&&f<=4,"invalid number of channels"),u=!0),Ae(i>=0&&i<=r.maxTextureSize,"invalid width"),Ae(o>=0&&o<=r.maxTextureSize,"invalid height")):("radius"in n&&(i=o=n.radius,Ae(i>=0&&i<=r.maxTextureSize,"invalid radius")),"width"in n&&(i=n.width,Ae(i>=0&&i<=r.maxTextureSize,"invalid width")),"height"in n&&(o=n.height,Ae(o>=0&&o<=r.maxTextureSize,"invalid height")),"channels"in n&&(f=n.channels,Ae(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 n){var c=n.format;Ae(t.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),Ae.parameter(c,V,"invalid texture format");var l=e.internalformat=V[c];e.format=re[l],c in Q&&("type"in n||(e.type=Q[c])),c in Y&&(e.compressed=!0),s=!0}!u&&s?e.channels=wr[e.format]:u&&!s?e.channels!==xr[e.format]&&(e.format=e.internalformat=xr[e.channels]):s&&u&&Ae(e.channels===wr[e.format],"number of channels inconsistent with specified format")}}function c(t){e.pixelStorei(pr,t.flipY),e.pixelStorei(hr,t.premultiplyAlpha),e.pixelStorei(br,t.colorSpace),e.pixelStorei(mr,t.unpackAlignment)}function l(){f.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function d(e,t){var n=null;if(H(t)?n=t:t&&(Ae.type(t,"object","invalid pixel data type"),s(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),H(t.data)&&(n=t.data)),Ae(!e.compressed||n instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),t.copy){Ae(!n,"can not specify copy and data field for the same texture");var i=a.viewportWidth,o=a.viewportHeight;e.width=e.width||i-e.xOffset,e.height=e.height||o-e.yOffset,e.needsCopy=!0,Ae(e.xOffset>=0&&e.xOffset=0&&e.yOffset0&&e.width<=i&&e.height>0&&e.height<=o,"copy texture read out of bounds")}else if(n){if(ue(n))e.channels=e.channels||4,e.data=n,"type"in t||e.type!==qt||(e.type=G(n));else if(L(n))e.channels=e.channels||4,function(e,t){var r=t.length;switch(e.type){case qt:case Qt:case Vt:case Yt:var n=Me.allocType(e.type,r);n.set(t),e.data=n;break;case Ft:e.data=B(t);break;default:Ae.raise("unsupported texture type, must specify a typed array")}}(e,n),e.alignment=1,e.needsFree=!0;else if(S(n)){var f=n.data;Array.isArray(f)||e.type!==qt||(e.type=G(f));var u,c,l,d,m,p,h=n.shape,b=n.stride;3===h.length?(l=h[2],p=b[2]):(Ae(2===h.length,"invalid ndarray pixel data, must be 2 or 3D"),l=1,p=1),u=h[0],c=h[1],d=b[0],m=b[1],e.alignment=1,e.width=u,e.height=c,e.channels=l,e.format=e.internalformat=xr[l],e.needsFree=!0,function(e,t,r,n,a,i){for(var o=e.width,f=e.height,u=e.channels,s=U(e,o*f*u),c=0,l=0;l=0,"oes_texture_float extension not enabled"):e.type===Ft&&Ae(r.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function m(t,r,a){var i=t.element,o=t.data,f=t.internalformat,u=t.format,s=t.type,l=t.width,d=t.height;c(t),i?e.texImage2D(r,a,u,u,s,i):t.compressed?e.compressedTexImage2D(r,a,f,l,d,0,o):t.needsCopy?(n(),e.copyTexImage2D(r,a,u,t.xOffset,t.yOffset,l,d,0)):e.texImage2D(r,a,u,l,d,0,u,s,o)}function p(t,r,a,i,o){var f=t.element,u=t.data,s=t.internalformat,l=t.format,d=t.type,m=t.width,p=t.height;c(t),f?e.texSubImage2D(r,o,a,i,l,d,f):t.compressed?e.compressedTexSubImage2D(r,o,a,i,s,m,p,u):t.needsCopy?(n(),e.copyTexSubImage2D(r,o,a,i,t.xOffset,t.yOffset,m,p)):e.texSubImage2D(r,o,a,i,m,p,l,d,u)}function h(){return ne.pop()||new l}function b(e){e.needsFree&&Me.freeType(e.data),l.call(e),ne.push(e)}function g(e,t,r){var n=e.images[0]=h();e.mipmask=1,n.width=e.width=t,n.height=e.height=r,n.channels=e.channels=4}function v(e,t){var r=null;if(H(t))u(r=e.images[0]=h(),e),d(r,t),e.mipmask=1;else if(s(e,t),Array.isArray(t.mipmap))for(var n=t.mipmap,a=0;a>=a,r.height>>=a,d(r,n[a]),e.mipmask|=1<=0&&(e.genMipmaps=!0)}if("mag"in t){var a=t.mag;Ae.parameter(a,F),e.magFilter=F[a]}var i=e.wrapS,o=e.wrapT;if("wrap"in t){var f=t.wrap;"string"==typeof f?(Ae.parameter(f,C),i=o=C[f]):Array.isArray(f)&&(Ae.parameter(f[0],C),Ae.parameter(f[1],C),i=C[f[0]],o=C[f[1]])}else{if("wrapS"in t){var u=t.wrapS;Ae.parameter(u,C),i=C[u]}if("wrapT"in t){var s=t.wrapT;Ae.parameter(s,C),o=C[s]}}if(e.wrapS=i,e.wrapT=o,"anisotropic"in t){var c=t.anisotropic;Ae("number"==typeof c&&c>=1&&c<=r.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var l=!1;switch(typeof t.mipmap){case"string":Ae.parameter(t.mipmap,O,"invalid mipmap hint"),e.mipmapHint=O[t.mipmap],e.genMipmaps=!0,l=!0;break;case"boolean":l=e.genMipmaps=t.mipmap;break;case"object":Ae(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,l=!0;break;default:Ae.raise("invalid mipmap type")}!l||"min"in t||(e.minFilter=ar)}}function _(r,n){e.texParameteri(n,tr,r.minFilter),e.texParameteri(n,er,r.magFilter),e.texParameteri(n,Xt,r.wrapS),e.texParameteri(n,$t,r.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(n,dr,r.anisotropic),r.genMipmaps&&(e.hint(ur,r.mipmapHint),e.generateMipmap(n))}function E(t){f.call(this),this.mipmask=0,this.internalformat=bt,this.id=ie++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new k,o.profile&&(this.stats={size:0})}function T(t){e.activeTexture(vr),e.bindTexture(t.target,t.texture)}function D(){var t=ce[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(mt,null)}function j(t){var r=t.texture;Ae(r,"must not double destroy texture");var n=t.unit,a=t.target;n>=0&&(e.activeTexture(vr+n),e.bindTexture(a,null),ce[n]=null),e.deleteTexture(r),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete oe[t.id],i.textureCount--}var O={"don't care":sr,"dont care":sr,nice:lr,fast:cr},C={repeat:Kt,clamp:Jt,mirror:Zt},F={nearest:rr,linear:nr},z=se({mipmap:fr,"nearest mipmap nearest":ar,"linear mipmap nearest":ir,"nearest mipmap linear":or,"linear mipmap linear":fr},F),R={none:0,browser:gr},Q={uint8:qt,rgba4:St,rgb565:Et,"rgb5 a1":_t},V={alpha:gt,luminance:yt,"luminance alpha":xt,rgb:vt,rgba:bt,rgba4:wt,"rgb5 a1":kt,rgb565:At},Y={};t.ext_srgb&&(V.srgb=Ot,V.srgba=Ct),t.oes_texture_float&&(Q.float32=Q.float=Yt),t.oes_texture_half_float&&(Q.float16=Q["half float"]=Ft),t.webgl_depth_texture&&(se(V,{depth:Dt,"depth stencil":jt}),se(Q,{uint16:Qt,uint32:Vt,"depth stencil":Tt})),t.webgl_compressed_texture_s3tc&&se(Y,{"rgb s3tc dxt1":zt,"rgba s3tc dxt1":Bt,"rgba s3tc dxt3":Pt,"rgba s3tc dxt5":Rt}),t.webgl_compressed_texture_atc&&se(Y,{"rgb atc":Lt,"rgba atc explicit alpha":It,"rgba atc interpolated alpha":Mt}),t.webgl_compressed_texture_pvrtc&&se(Y,{"rgb pvrtc 4bppv1":Wt,"rgb pvrtc 2bppv1":Ht,"rgba pvrtc 4bppv1":Gt,"rgba pvrtc 2bppv1":Ut}),t.webgl_compressed_texture_etc1&&(Y["rgb etc1"]=Nt);var X=Array.prototype.slice.call(e.getParameter(dt));Object.keys(Y).forEach(function(e){var t=Y[e];X.indexOf(t)>=0&&(V[e]=t)});var $=Object.keys(V);r.textureFormats=$;var K=[];Object.keys(V).forEach(function(e){var t=V[e];K[t]=e});var J=[];Object.keys(Q).forEach(function(e){var t=Q[e];J[t]=e});var Z=[];Object.keys(F).forEach(function(e){var t=F[e];Z[t]=e});var ee=[];Object.keys(z).forEach(function(e){var t=z[e];ee[t]=e});var te=[];Object.keys(C).forEach(function(e){var t=C[e];te[t]=e});var re=$.reduce(function(e,t){var r=V[t];return r===yt||r===gt||r===yt||r===xt||r===Dt||r===jt?e[r]=r:r===kt||t.indexOf("rgba")>=0?e[r]=bt:e[r]=vt,e},{}),ne=[],ae=[],ie=0,oe={},fe=r.maxTextureUnits,ce=Array(fe).map(function(){return null});return se(E.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(t<0){for(var r=0;r0)continue;n.unit=-1}ce[r]=this,t=r;break}t>=fe&&Ae.raise("insufficient number of texture units"),o.profile&&i.maxTextureUnits>s)-i,c.height=c.height||(f.height>>s)-o,Ae(f.type===c.type&&f.format===c.format&&f.internalformat===c.internalformat,"incompatible format for texture.subimage"),Ae(i>=0&&o>=0&&i+c.width<=f.width&&o+c.height<=f.height,"texture.subimage write out of bounds"),Ae(f.mipmask&1<>u;++u)e.texImage2D(mt,u,f.format,n>>u,i>>u,0,f.format,f.type,null);return D(),o.profile&&(f.stats.size=q(f.internalformat,f.type,n,i,!1,!1)),a},a._reglType="texture2d",a._texture=f,o.profile&&(a.stats=f.stats),a.destroy=function(){f.decRef()},a},createCube:function(t,n,a,f,c,l){function m(e,t,n,a,i,f){var c,l=S.texInfo;for(k.call(l),c=0;c<6;++c)j[c]=x();if("number"!=typeof e&&e)if("object"==typeof e)if(t)v(j[0],e),v(j[1],t),v(j[2],n),v(j[3],a),v(j[4],i),v(j[5],f);else if(A(l,e),s(S,e),"faces"in e){var d=e.faces;for(Ae(Array.isArray(d)&&6===d.length,"cube faces must be a length 6 array"),c=0;c<6;++c)Ae("object"==typeof d[c]&&!!d[c],"invalid input for cube map face"),u(j[c],S),v(j[c],d[c])}else for(c=0;c<6;++c)v(j[c],e);else Ae.raise("invalid arguments to cube map");else{var p=0|e||1;for(c=0;c<6;++c)g(j[c],p,p)}for(u(S,j[0]),l.genMipmaps?S.mipmask=(j[0].width<<1)-1:S.mipmask=j[0].mipmask,Ae.textureCube(S,l,j,r),S.internalformat=j[0].internalformat,m.width=j[0].width,m.height=j[0].height,T(S),c=0;c<6;++c)y(j[c],ht+c);for(_(l,pt),D(),o.profile&&(S.stats.size=q(S.internalformat,S.type,m.width,m.height,l.genMipmaps,!0)),m.format=K[S.internalformat],m.type=J[S.type],m.mag=Z[l.magFilter],m.min=ee[l.minFilter],m.wrapS=te[l.wrapS],m.wrapT=te[l.wrapT],c=0;c<6;++c)w(j[c]);return m}var S=new E(pt);oe[S.id]=S,i.cubeCount++;var j=new Array(6);return m(t,n,a,f,c,l),m.subimage=function(e,t,r,n,a){Ae(!!t,"must specify image data"),Ae("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var i=0|r,o=0|n,f=0|a,s=h();return u(s,S),s.width=0,s.height=0,d(s,t),s.width=s.width||(S.width>>f)-i,s.height=s.height||(S.height>>f)-o,Ae(S.type===s.type&&S.format===s.format&&S.internalformat===s.internalformat,"incompatible format for texture.subimage"),Ae(i>=0&&o>=0&&i+s.width<=S.width&&o+s.height<=S.height,"texture.subimage write out of bounds"),Ae(S.mipmask&1<>a;++a)e.texImage2D(ht+n,a,S.format,r>>a,r>>a,0,S.format,S.type,null);return D(),o.profile&&(S.stats.size=q(S.internalformat,S.type,m.width,m.height,!1,!0)),m}},m._reglType="textureCube",m._texture=S,o.profile&&(m.stats=S.stats),m.destroy=function(){S.decRef()},m},clear:function(){for(var t=0;t>r,t.height>>r,0,t.internalformat,t.type,null);else for(var n=0;n<6;++n)e.texImage2D(ht+n,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);_(t.texInfo,t.target)})}}}function V(e,t,r){return Cr[e]*t*r}function Y(){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=Kr,this.offset=0,this.stride=0,this.divisor=0}function X(e,t,r,n){function a(e,t,r,n){this.name=e,this.id=t,this.location=r,this.info=n}function i(e,t){for(var r=0;r1)for(var h=0;he&&(e=t.stats.uniformsCount)}),e},r.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);Oe(u).forEach(t),u={},Oe(s).forEach(t),s={},l.forEach(function(t){e.deleteProgram(t.program)}),l.length=0,c={},r.shaderCount=0},program:function(e,t,a){Ae.command(e>=0,"missing vertex shader",a),Ae.command(t>=0,"missing fragment shader",a);var i=c[t];i||(i=c[t]={});var o=i[e];return o||(o=new function(e,t){this.id=d++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],n.profile&&(this.stats={uniformsCount:0,attributesCount:0})}(t,e),r.shaderCount++,f(o,a),i[e]=o,l.push(o)),o},restore:function(){u={},s={};for(var e=0;e=0&&u=0&&s0&&c+u<=n.framebufferWidth,"invalid width for read pixels"),Ae(l>0&&l+s<=n.framebufferHeight,"invalid height for read pixels"),r();var m=c*l*4;return d||(f===nn?d=new Uint8Array(m):f===on&&(d=d||new Float32Array(m))),Ae.isTypedArray(d,"data buffer for regl.read() must be a typedarray"),Ae(d.byteLength>=m,"data buffer for regl.read() too small"),e.pixelStorei(an,4),e.readPixels(u,s,c,l,rn,f,d),d}return function(e){return e&&"framebuffer"in e?function(e){var r;return t.setFBO({framebuffer:e.framebuffer},function(){r=o(e)}),r}(e):o(e)}}function K(e){return Array.prototype.slice.call(e)}function J(e){return K(e).join("")}function Z(e){return Array.isArray(e)||ue(e)||S(e)}function ee(e){return e.sort(function(e,t){return e===Gn?-1:t===Gn?1:e=1,n>=2,t)}if(r===hn){var a=e.data;return new te(a.thisDep,a.contextDep,a.propDep,t)}return new te(r===pn,r===mn,r===dn,t)}function ie(e,t,r,n,a,i,o,f,u,s,c,l,d,m,p){function h(e){return e.replace(".","_")}function b(e,t,r){var n=h(e);G.push(e),H[n]=W[n]=!!r,U[n]=t}function g(e,t,r){var n=h(e);G.push(e),Array.isArray(r)?(W[n]=r.slice(),H[n]=r.slice()):W[n]=H[n]=r,N[n]=t}function v(){var e=function(){function e(){var e=[],t=[];return se(function(){e.push.apply(e,K(arguments))},{def:function(){var n="v"+r++;return t.push(n),arguments.length>0&&(e.push(n,"="),e.push.apply(e,K(arguments)),e.push(";")),n},toString:function(){return J([t.length>0?"var "+t+";":"",J(e)])}})}function t(){function t(e,t){n(e,t,"=",r.def(e,t),";")}var r=e(),n=e(),a=r.toString,i=n.toString;return se(function(){r.apply(r,K(arguments))},{def:r.def,entry:r,exit:n,save:t,set:function(e,n,a){t(e,n),r(e,n,"=",a,";")},toString:function(){return a()+i()}})}var r=0,n=[],a=[],i=e(),o={};return{global:i,link:function(e){for(var t=0;t=0,'unknown parameter "'+e+'"',s.commandStr)})}var t=[Nn,qn,Qn,Vn,Yn,$n,Xn,Kn,Un].concat(G);e(d),e(m)});var p=function(e,t){var r=e.static,n=e.dynamic;if(Nn in r){var a=r[Nn];return a?(a=f.getFramebuffer(a),Ae.command(a,"invalid framebuffer object"),ne(function(e,t){var r=e.link(a),n=e.shared;t.set(n.framebuffer,".next",r);var i=n.context;return t.set(i,"."+Jn,r+".width"),t.set(i,"."+Zn,r+".height"),r})):ne(function(e,t){var r=e.shared;t.set(r.framebuffer,".next","null");var n=r.context;return t.set(n,"."+Jn,n+"."+ra),t.set(n,"."+Zn,n+"."+na),"null"})}if(Nn in n){var i=n[Nn];return ae(i,function(e,t){var r=e.invoke(t,i),n=e.shared,a=n.framebuffer,o=t.def(a,".getFramebuffer(",r,")");Ae.optional(function(){e.assert(t,"!"+r+"||"+o,"invalid framebuffer object")}),t.set(a,".next",o);var f=n.context;return t.set(f,"."+Jn,o+"?"+o+".width:"+f+"."+ra),t.set(f,"."+Zn,o+"?"+o+".height:"+f+"."+na),o})}return null}(e),b=function(e,t,r){function n(e){if(e in a){var n=a[e];Ae.commandType(n,"object","invalid "+e,r.commandStr);var o,f,u=!0,s=0|n.x,c=0|n.y;return"width"in n?(o=0|n.width,Ae.command(o>=0,"invalid "+e,r.commandStr)):u=!1,"height"in n?(f=0|n.height,Ae.command(f>=0,"invalid "+e,r.commandStr)):u=!1,new te(!u&&t&&t.thisDep,!u&&t&&t.contextDep,!u&&t&&t.propDep,function(e,t){var r=e.shared.context,a=o;"width"in n||(a=t.def(r,".",Jn,"-",s));var i=f;return"height"in n||(i=t.def(r,".",Zn,"-",c)),[s,c,a,i]})}if(e in i){var l=i[e],d=ae(l,function(t,r){var n=t.invoke(r,l);Ae.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,".",Jn,"-",i,")"),u=r.def('"height" in ',n,"?",n,".height|0:","(",a,".",Zn,"-",o,")");return Ae.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 te(t.thisDep,t.contextDep,t.propDep,function(e,t){var r=e.shared.context;return[0,0,t.def(r,".",Jn),t.def(r,".",Zn)]}):null}var a=e.static,i=e.dynamic,o=n(Gn);if(o){var f=o;o=new te(o.thisDep,o.contextDep,o.propDep,function(e,t){var r=f.append(e,t),n=e.shared.context;return t.set(n,"."+ea,r[2]),t.set(n,"."+ta,r[3]),r})}return{viewport:o,scissor_box:n(Hn)}}(e,p,s),g=function(e,t){function r(e,r){if(e in n){var i=0|n[e];return Ae.command(!r||i>=0,"invalid "+e,t.commandStr),ne(function(e,t){return r&&(e.OFFSET=i),i})}if(e in a){var f=a[e];return ae(f,function(t,n){var a=t.invoke(n,f);return r&&(t.OFFSET=a,Ae.optional(function(){t.assert(n,a+">=0","invalid "+e)})),a})}return r&&o?ne(function(e,t){return e.OFFSET="0",0}):null}var n=e.static,a=e.dynamic,o=function(){if(Vn in n){var e=n[Vn];Z(e)?e=i.getElements(i.create(e,!0)):e&&(e=i.getElements(e),Ae.command(e,"invalid elements",t.commandStr));var r=ne(function(t,r){if(e){var n=t.link(e);return t.ELEMENTS=n,n}return t.ELEMENTS=null,null});return r.value=e,r}if(Vn in a){var o=a[Vn];return ae(o,function(e,t){var r=e.shared,n=r.isBufferArgs,a=r.elements,i=e.invoke(t,o),f=t.def("null"),u=t.def(n,"(",i,")"),s=e.cond(u).then(f,"=",a,".createStream(",i,");").else(f,"=",a,".getElements(",i,");");return Ae.optional(function(){e.assert(s.else,"!"+i+"||"+f,"invalid elements")}),t.entry(s),t.exit(e.cond(u).then(a,".destroyStream(",f,");")),e.ELEMENTS=f,f})}return null}(),f=r($n,!0);return{elements:o,primitive:function(){if(Yn in n){var e=n[Yn];return Ae.commandParameter(e,$e,"invalid primitve",t.commandStr),ne(function(t,r){return $e[e]})}if(Yn in a){var r=a[Yn];return ae(r,function(e,t){var n=e.constants.primTypes,a=e.invoke(t,r);return Ae.optional(function(){e.assert(t,a+" in "+n,"invalid primitive, must be one of "+Object.keys($e))}),t.def(n,"[",a,"]")})}return o?re(o)?o.value?ne(function(e,t){return t.def(e.ELEMENTS,".primType")}):ne(function(){return Pa}):new te(o.thisDep,o.contextDep,o.propDep,function(e,t){var r=e.ELEMENTS;return t.def(r,"?",r,".primType:",Pa)}):null}(),count:function(){if(Xn in n){var e=0|n[Xn];return Ae.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),ne(function(){return e})}if(Xn in a){var r=a[Xn];return ae(r,function(e,t){var n=e.invoke(t,r);return Ae.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")}),n})}if(o){if(re(o)){if(o)return f?new te(f.thisDep,f.contextDep,f.propDep,function(e,t){var r=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return Ae.optional(function(){e.assert(t,r+">=0","invalid vertex offset/element buffer too small")}),r}):ne(function(e,t){return t.def(e.ELEMENTS,".vertCount")});var i=ne(function(){return-1});return Ae.optional(function(){i.MISSING=!0}),i}var u=new te(o.thisDep||f.thisDep,o.contextDep||f.contextDep,o.propDep||f.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 Ae.optional(function(){u.DYNAMIC=!0}),u}return null}(),instances:r(Kn,!1),offset:f}}(e,s),v=function(e,t){var r=e.static,a=e.dynamic,i={};return G.forEach(function(e){function o(t,n){if(e in r){var o=t(r[e]);i[f]=ne(function(){return o})}else if(e in a){var u=a[e];i[f]=ae(u,function(e,t){return n(e,t,e.invoke(t,u))})}}var f=h(e);switch(e){case En:case gn:case bn:case Pn:case wn:case Wn:case On:case Fn:case zn:case Sn:return o(function(r){return Ae.commandType(r,"boolean",e,t.commandStr),r},function(t,r,n){return Ae.optional(function(){t.assert(r,"typeof "+n+'==="boolean"',"invalid flag "+e,t.commandStr)}),n});case kn:return o(function(r){return Ae.commandParameter(r,Ja,"invalid "+e,t.commandStr),Ja[r]},function(t,r,n){var a=t.constants.compareFuncs;return Ae.optional(function(){t.assert(r,n+" in "+a,"invalid "+e+", must be one of "+Object.keys(Ja))}),r.def(a,"[",n,"]")});case An:return o(function(e){return Ae.command(P(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 Ae.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 xn:return o(function(e){Ae.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 Ae.commandParameter(r,$a,f+".srcRGB",t.commandStr),Ae.commandParameter(n,$a,f+".srcAlpha",t.commandStr),Ae.commandParameter(a,$a,f+".dstRGB",t.commandStr),Ae.commandParameter(i,$a,f+".dstAlpha",t.commandStr),Ae.command(-1===Ka.indexOf(r+", "+a),"unallowed blending combination (srcRGB, dstRGB) = ("+r+", "+a+")",t.commandStr),[$a[r],$a[a],$a[n],$a[i]]},function(t,r,n){function a(a,o){var f=r.def('"',a,o,'" in ',n,"?",n,".",a,o,":",n,".",a);return Ae.optional(function(){t.assert(r,f+" in "+i,"invalid "+e+"."+a+o+", must be one of "+Object.keys($a))}),f}var i=t.constants.blendFuncs;Ae.optional(function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid blend func, must be an object")});var o=a("src","RGB"),f=a("dst","RGB");Ae.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(i,"[",o,"]"),s=r.def(i,"[",a("src","Alpha"),"]");return[u,r.def(i,"[",f,"]"),s,r.def(i,"[",a("dst","Alpha"),"]")]});case yn:return o(function(r){return"string"==typeof r?(Ae.commandParameter(r,L,"invalid "+e,t.commandStr),[L[r],L[r]]):"object"==typeof r?(Ae.commandParameter(r.rgb,L,e+".rgb",t.commandStr),Ae.commandParameter(r.alpha,L,e+".alpha",t.commandStr),[L[r.rgb],L[r.alpha]]):void Ae.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 Ae.optional(function(){function r(e,r,n){t.assert(e,n+" in "+a,"invalid "+r+", must be one of "+Object.keys(L))}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 vn:return o(function(e){return Ae.command(P(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),_(4,function(t){return+e[t]})},function(e,t,r){return Ae.optional(function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===4","blend.color must be a 4d array")}),_(4,function(e){return t.def("+",r,"[",e,"]")})});case Rn:return o(function(e){return Ae.commandType(e,"number",f,t.commandStr),0|e},function(e,t,r){return Ae.optional(function(){e.assert(t,"typeof "+r+'==="number"',"invalid stencil.mask")}),t.def(r,"|0")});case Ln:return o(function(r){Ae.commandType(r,"object",f,t.commandStr);var n=r.cmp||"keep",a=r.ref||0,i="mask"in r?r.mask:-1;return Ae.commandParameter(n,Ja,e+".cmp",t.commandStr),Ae.commandType(a,"number",e+".ref",t.commandStr),Ae.commandType(i,"number",e+".mask",t.commandStr),[Ja[n],a,i]},function(e,t,r){var n=e.constants.compareFuncs;return Ae.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]",":",Ua),t.def(r,".ref|0"),t.def('"mask" in ',r,"?",r,".mask|0:-1")]});case In:case Mn:return o(function(r){Ae.commandType(r,"object",f,t.commandStr);var n=r.fail||"keep",a=r.zfail||"keep",i=r.zpass||"keep";return Ae.commandParameter(n,Za,e+".fail",t.commandStr),Ae.commandParameter(a,Za,e+".zfail",t.commandStr),Ae.commandParameter(i,Za,e+".zpass",t.commandStr),[e===Mn?La:Ra,Za[n],Za[a],Za[i]]},function(t,r,n){function a(a){return Ae.optional(function(){t.assert(r,'!("'+a+'" in '+n+")||("+n+"."+a+" in "+i+")","invalid "+e+"."+a+", must be one of "+Object.keys(Za))}),r.def('"',a,'" in ',n,"?",i,"[",n,".",a,"]:",Ua)}var i=t.constants.stencilOps;return Ae.optional(function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)}),[e===Mn?La:Ra,a("fail"),a("zfail"),a("zpass")]});case Cn:return o(function(e){Ae.commandType(e,"object",f,t.commandStr);var r=0|e.factor,n=0|e.units;return Ae.commandType(r,"number",f+".factor",t.commandStr),Ae.commandType(n,"number",f+".units",t.commandStr),[r,n]},function(t,r,n){return Ae.optional(function(){t.assert(r,n+"&&typeof "+n+'==="object"',"invalid "+e)}),[r.def(n,".factor|0"),r.def(n,".units|0")]});case Tn:return o(function(e){var r=0;return"front"===e?r=Ra:"back"===e&&(r=La),Ae.command(!!r,f,t.commandStr),r},function(e,t,r){return Ae.optional(function(){e.assert(t,r+'==="front"||'+r+'==="back"',"invalid cull.face")}),t.def(r,'==="front"?',Ra,":",La)});case jn:return o(function(e){return Ae.command("number"==typeof e&&e>=n.lineWidthDims[0]&&e<=n.lineWidthDims[1],"invalid line width, must positive number between "+n.lineWidthDims[0]+" and "+n.lineWidthDims[1],t.commandStr),e},function(e,t,r){return Ae.optional(function(){e.assert(t,"typeof "+r+'==="number"&&'+r+">="+n.lineWidthDims[0]+"&&"+r+"<="+n.lineWidthDims[1],"invalid line width")}),r});case Dn:return o(function(e){return Ae.commandParameter(e,ti,f,t.commandStr),ti[e]},function(e,t,r){return Ae.optional(function(){e.assert(t,r+'==="cw"||'+r+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),t.def(r+'==="cw"?'+Ia+":"+Ma)});case _n:return o(function(e){return Ae.command(P(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map(function(e){return!!e})},function(e,t,r){return Ae.optional(function(){e.assert(t,e.shared.isArrayLike+"("+r+")&&"+r+".length===4","invalid color.mask")}),_(4,function(e){return"!!"+r+"["+e+"]"})});case Bn:return o(function(e){Ae.command("object"==typeof e&&e,f,t.commandStr);var r="value"in e?e.value:1,n=!!e.invert;return Ae.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 Ae.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,s),y=function(e){function r(e){if(e in a){var r=t.id(a[e]);Ae.optional(function(){c.shader(ei[e],r,Ae.guessCommand())});var n=ne(function(){return r});return n.id=r,n}if(e in i){var o=i[e];return ae(o,function(t,r){var n=t.invoke(r,o),a=r.def(t.shared.strings,".id(",n,")");return Ae.optional(function(){r(t.shared.shader,".shader(",ei[e],",",a,",",t.command,");")}),a})}return null}var n,a=e.static,i=e.dynamic,o=r(Qn),f=r(qn),u=null;return re(o)&&re(f)?(u=c.program(f.id,o.id),n=ne(function(e,t){return e.link(u)})):n=new te(o&&o.thisDep||f&&f.thisDep,o&&o.contextDep||f&&f.contextDep,o&&o.propDep||f&&f.propDep,function(e,t){var r,n=e.shared.shader;r=o?o.append(e,t):t.def(n,".",Qn);var a=n+".program("+(f?f.append(e,t):t.def(n,".",qn))+","+r;return Ae.optional(function(){a+=","+e.command}),t.def(a+")")}),{frag:o,vert:f,progVar:n,program:u}}(e);l(Gn),l(h(Hn));var x=Object.keys(v).length>0,w={framebuffer:p,draw:g,shader:y,state:v,dirty:x};return w.profile=function(e){var t,r=e.static,n=e.dynamic;if(Un in r){var a=!!r[Un];(t=ne(function(e,t){return a})).enable=a}else if(Un in n){var i=n[Un];t=ae(i,function(e,t){return e.invoke(t,i)})}return t}(e),w.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=ne(function(){return i});else if("function"==typeof i){var o=i._reglType;"texture2d"===o||"textureCube"===o?n=ne(function(e){return e.link(i)}):"framebuffer"===o||"framebufferCube"===o?(Ae.command(i.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),n=ne(function(e){return e.link(i.color[0])})):Ae.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else P(i)?n=ne(function(t){return t.global.def("[",_(i.length,function(r){return Ae.command("number"==typeof i[r]||"boolean"==typeof i[r],"invalid uniform "+e,t.commandStr),i[r]}),"]")}):Ae.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]=ae(t,function(e,r){return e.invoke(r,t)})}),a}(o,s),w.attributes=function(e,r){var n=e.static,i=e.dynamic,o={};return Object.keys(n).forEach(function(e){var i=n[e],f=t.id(e),u=new R;if(Z(i))u.state=sn,u.buffer=a.getBuffer(a.create(i,ia,!1,!0)),u.type=0;else{var s=a.getBuffer(i);if(s)u.state=sn,u.buffer=s,u.type=0;else if(Ae.command("object"==typeof i&&i,"invalid data for attribute "+e,r.commandStr),i.constant){var c=i.constant;u.buffer="null",u.state=cn,"number"==typeof c?u.x=c:(Ae.command(P(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,r.commandStr),fn.forEach(function(e,t){t=0,'invalid offset for attribute "'+e+'"',r.commandStr);var d=0|i.stride;Ae.command(d>=0&&d<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',r.commandStr);var m=0|i.size;Ae.command(!("size"in i)||m>0&&m<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',r.commandStr);var p=!!i.normalized,h=0;"type"in i&&(Ae.commandParameter(i.type,He,"invalid type for attribute "+e,r.commandStr),h=He[i.type]);var b=0|i.divisor;"divisor"in i&&(Ae.command(0===b||I,'cannot specify divisor for attribute "'+e+'", instancing not supported',r.commandStr),Ae.command(b>=0,'invalid divisor for attribute "'+e+'"',r.commandStr)),Ae.optional(function(){var t=r.commandStr,n=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach(function(r){Ae.command(n.indexOf(r)>=0,'unknown parameter "'+r+'" for attribute pointer "'+e+'" (valid parameters are '+n+")",t)})}),u.buffer=s,u.state=sn,u.size=m,u.normalized=p,u.type=h||s.dtype,u.offset=l,u.stride=d,u.divisor=b}}o[e]=ne(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(i).forEach(function(e){var t=i[e];o[e]=ae(t,function(r,n){function a(e){n(s[e],"=",i,".",e,"|0;")}var i=r.invoke(n,t),o=r.shared,f=o.isBufferArgs,u=o.buffer;Ae.optional(function(){r.assert(n,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+f+"("+i+")||"+u+".getBuffer("+i+")||"+u+".getBuffer("+i+".buffer)||"+f+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+o.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+e+'"')});var s={isStream:n.def(!1)},c=new R;c.state=sn,Object.keys(c).forEach(function(e){s[e]=n.def(""+c[e])});var l=s.buffer,d=s.type;return n("if(",f,"(",i,")){",s.isStream,"=true;",l,"=",u,".createStream(",ia,",",i,");",d,"=",l,".dtype;","}else{",l,"=",u,".getBuffer(",i,");","if(",l,"){",d,"=",l,".dtype;",'}else if("constant" in ',i,"){",s.state,"=",cn,";","if(typeof "+i+'.constant === "number"){',s[fn[0]],"=",i,".constant;",fn.slice(1).map(function(e){return s[e]}).join("="),"=0;","}else{",fn.map(function(e,t){return s[e]+"="+i+".constant.length>="+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",f,"(",i,".buffer)){",l,"=",u,".createStream(",ia,",",i,".buffer);","}else{",l,"=",u,".getBuffer(",i,".buffer);","}",d,'="type" in ',i,"?",o.glTypes,"[",i,".type]:",l,".dtype;",s.normalized,"=!!",i,".normalized;"),a("size"),a("offset"),a("stride"),a("divisor"),n("}}"),n.exit("if(",s.isStream,"){",u,".destroyStream(",l,");","}"),s})}),o}(r,s),w.context=function(e){var t=e.static,r=e.dynamic,n={};return Object.keys(t).forEach(function(e){var r=t[e];n[e]=ne(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]=ae(t,function(e,r){return e.invoke(r,t)})}),n}(u),w}function x(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];a(n,".",i,"=",o.append(e,t),";")}),t(a)}function w(e,t,r,n){var a,i=e.shared,o=i.gl,f=i.framebuffer;M&&(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(",Ya,",",u,".framebuffer);"),M&&t(a,".drawBuffersWEBGL(",c,"[",u,".colorAttachments.length]);"),t("}else{",o,".bindFramebuffer(",Ya,",null);"),M&&t(a,".drawBuffersWEBGL(",l,");"),t("}",f,".cur=",u,";"),n||t("}")}function k(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");G.forEach(function(t){var n=h(t);if(!(n in r.state)){var c,l;if(n in o){c=o[n],l=i[n];var d=_(W[n].length,function(e){return s.def(c,"[",e,"]")});s(e.cond(d.map(function(e,t){return e+"!=="+l+"["+t+"]"}).join("||")).then(a,".",N[n],"(",d,");",d.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";"))}else{c=s.def(u,".",n);var m=e.cond(c,"!==",f,".",n);s(m),n in U?m(e.cond(c).then(a,".enable(",U[n],");").else(a,".disable(",U[n],");"),f,".",n,"=",c,";"):m(a,".",N[n],"(",c,");",f,".",n,"=",c,";")}}}),0===Object.keys(r.state).length&&s(f,".dirty=false;"),t(s)}function A(e,t,r,n){var a=e.shared,i=e.current,o=a.current,f=a.gl;ee(Object.keys(r)).forEach(function(a){var u=r[a];if(!n||n(u)){var s=u.append(e,t);if(U[a]){var c=U[a];re(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(P(s)){var l=i[a];t(f,".",N[a],"(",s,");",s.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(f,".",N[a],"(",s,");",o,".",a,"=",s,";")}})}function S(e,t){I&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function E(e,t,r,n,a){function i(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function o(e){e(s=t.def(),"=",i(),";"),"string"==typeof a?e(p,".count+=",a,";"):e(p,".count++;"),m&&(n?e(c=t.def(),"=",b,".getNumPendingQueries();"):e(b,".beginQuery(",p,");"))}function f(e){e(p,".cpuTime+=",i(),"-",s,";"),m&&(n?e(b,".pushScopeStats(",c,",",b,".getNumPendingQueries(),",p,");"):e(b,".endQuery();"))}function u(e){var r=t.def(h,".profile");t(h,".profile=",e,";"),t.exit(h,".profile=",r,";")}var s,c,l,d=e.shared,p=e.stats,h=d.current,b=d.timer,g=r.profile;if(g){if(re(g))return void(g.enable?(o(t),f(t.exit),u("true")):u("false"));u(l=g.append(e,t))}else l=t.def(h,".profile");var v=e.block();o(v),t("if(",l,"){",v,"}");var y=e.block();f(y),t.exit("if(",l,"){",y,"}")}function T(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(ri))return;var s=e.scopeAttrib(f);Ae.optional(function(){e.assert(t,s+".state","missing attribute "+f)}),o={},Object.keys(new R).forEach(function(e){o[e]=t.def(s,".",e)})}!function(r,n,a){function o(){t("if(!",c,".buffer){",u,".enableVertexAttribArray(",s,");}");var r,i=a.type;if(r=a.size?t.def(a.size,"||",n):n,t("if(",c,".type!==",i,"||",c,".size!==",r,"||",p.map(function(e){return c+"."+e+"!=="+a[e]}).join("||"),"){",u,".bindBuffer(",ia,",",d,".buffer);",u,".vertexAttribPointer(",[s,r,i,a.normalized,a.stride,a.offset],");",c,".type=",i,";",c,".size=",r,";",p.map(function(e){return c+"."+e+"="+a[e]+";"}).join(""),"}"),I){var o=a.divisor;t("if(",c,".divisor!==",o,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,o],");",c,".divisor=",o,";}")}}function f(){t("if(",c,".buffer){",u,".disableVertexAttribArray(",s,");","}if(",fn.map(function(e,t){return c+"."+e+"!=="+m[t]}).join("||"),"){",u,".vertexAttrib4f(",s,",",m,");",fn.map(function(e,t){return c+"."+e+"="+m[t]+";"}).join(""),"}")}var u=i.gl,s=t.def(r,".location"),c=t.def(i.attributes,"[",s,"]"),l=a.state,d=a.buffer,m=[a.x,a.y,a.z,a.w],p=["buffer","normalized","offset","stride"];l===sn?o():l===cn?f():(t("if(",l,"===",sn,"){"),o(),t("}else{"),f(),t("}"))}(e.link(n),function(e){switch(e){case ya:case Aa:case Ta:return 2;case xa:case Sa:case Da:return 3;case wa:case _a:case ja:return 4;default:return 1}}(n.info.type),o)})}function D(e,r,n,a,i){for(var o,f=e.shared,u=f.gl,s=0;s1?_(x,function(e){return c+"["+e+"]"}):c);r(");")}}function j(e,t,r,n){function a(a){var i=c[a];return i?i.contextDep&&n.contextDynamic||i.propDep?i.append(e,r):i.append(e,t):t.def(s,".",a)}function i(){function e(){r(b,".drawElementsInstancedANGLE(",[d,p,g,m+"<<(("+g+"-"+un+")>>1)",h],");")}function t(){r(b,".drawArraysInstancedANGLE(",[d,m,p,h],");")}l?v?e():(r("if(",l,"){"),e(),r("}else{"),t(),r("}")):t()}function o(){function e(){r(u+".drawElements("+[d,p,g,m+"<<(("+g+"-"+un+")>>1)"]+");")}function t(){r(u+".drawArrays("+[d,m,p]+");")}l?v?e():(r("if(",l,"){"),e(),r("}else{"),t(),r("}")):t()}var f=e.shared,u=f.gl,s=f.draw,c=n.draw,l=function(){var a,i=c.elements,o=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(o=r),a=i.append(e,o)):a=o.def(s,".",Vn),a&&o("if("+a+")"+u+".bindBuffer("+oa+","+a+".buffer.buffer);"),a}(),d=a(Yn),m=a($n),p=function(){var a,i=c.count,o=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(o=r),a=i.append(e,o),Ae.optional(function(){i.MISSING&&e.assert(t,"false","missing vertex count"),i.DYNAMIC&&e.assert(o,a+">=0","missing vertex count")})):(a=o.def(s,".",Xn),Ae.optional(function(){e.assert(o,a+">=0","missing vertex count")})),a}();if("number"==typeof p){if(0===p)return}else r("if(",p,"){"),r.exit("}");var h,b;I&&(h=a(Kn),b=e.instancing);var g=l+".type",v=c.elements&&re(c.elements);I&&("number"!=typeof h||h>=0)?"string"==typeof h?(r("if(",h,">0){"),i(),r("}else if(",h,"<0){"),o(),r("}")):i():o()}function O(e,t,r,n,a){var i=v(),o=i.proc("body",a);return Ae.optional(function(){i.commandStr=t.commandStr,i.command=i.link(t.commandStr)}),I&&(i.instancing=o.def(i.shared.extensions,".angle_instanced_arrays")),e(i,o,r,n),i.compile().body}function C(e,t,r,n){S(e,t),T(e,t,r,n.attributes,function(){return!0}),D(e,t,r,n.uniforms,function(){return!0}),j(e,t,t,r)}function F(e,t,r,n){function a(){return!0}e.batchId="a1",S(e,t),T(e,t,r,n.attributes,a),D(e,t,r,n.uniforms,a),j(e,t,t,r)}function z(e,t,r,n){function a(e){return e.contextDep&&o||e.propDep}function i(e){return!a(e)}S(e,t);var o=r.contextDep,f=t.def(),u=t.def();e.shared.props=u,e.batchId=f;var s=e.scope(),c=e.scope();if(t(s.entry,"for(",f,"=0;",f,"<","a1",";++",f,"){",u,"=","a0","[",f,"];",c,"}",s.exit),r.needsContext&&x(e,c,r.context),r.needsFramebuffer&&w(e,c,r.framebuffer),A(e,c,r.state,a),r.profile&&a(r.profile)&&E(e,c,r,!1,!0),n)T(e,s,r,n.attributes,i),T(e,c,r,n.attributes,a),D(e,s,r,n.uniforms,i),D(e,c,r,n.uniforms,a),j(e,s,c,r);else{var l=e.global.def("{}"),d=r.shader.progVar.append(e,c),m=c.def(d,".id"),p=c.def(l,"[",m,"]");c(e.shared.gl,".useProgram(",d,".program);","if(!",p,"){",p,"=",l,"[",m,"]=",e.link(function(t){return O(F,e,r,t,2)}),"(",d,");}",p,".call(this,a0[",f,"],",f,");")}}function B(e,t,r){var n=t.static[r];if(n&&function(e){if("object"==typeof e&&!P(e)){for(var t=Object.keys(e),r=0;r0&&r(e.shared.current,".dirty=true;")}(o,f),function(e,r){function n(t){var n=r.shader[t];n&&a.set(i.shader,"."+t,n.append(e,a))}var a=e.proc("scope",3);e.batchId="a2";var i=e.shared,o=i.current;x(e,a,r.context),r.framebuffer&&r.framebuffer.append(e,a),ee(Object.keys(r.state)).forEach(function(t){var n=r.state[t].append(e,a);P(n)?n.forEach(function(r,n){a.set(e.next[t],"["+n+"]",r)}):a.set(i.next,"."+t,n)}),E(e,a,r,!0,!0),[Vn,$n,Xn,Kn,Yn].forEach(function(t){var n=r.draw[t];n&&a.set(i.draw,"."+t,""+n.append(e,a))}),Object.keys(r.uniforms).forEach(function(n){a.set(i.uniforms,"["+t.id(n)+"]",r.uniforms[n].append(e,a))}),Object.keys(r.attributes).forEach(function(t){var n=r.attributes[t].append(e,a),i=e.scopeAttrib(t);Object.keys(new R).forEach(function(e){a.set(i,"."+e,n[e])})}),n(qn),n(Qn),Object.keys(r.state).length>0&&(a(o,".dirty=true;"),a.exit(o,".dirty=true;")),a("a1(",e.shared.context,",a0,",e.batchId,");")}(o,f),function(e,t){function r(e){return e.contextDep&&a||e.propDep}var n=e.proc("batch",2);e.batchId="0",S(e,n);var a=!1,i=!0;Object.keys(t.context).forEach(function(e){a=a||t.context[e].propDep}),a||(x(e,n,t.context),i=!1);var o=t.framebuffer,f=!1;o?(o.propDep?a=f=!0:o.contextDep&&a&&(f=!0),f||w(e,n,o)):w(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(a=!0),k(e,n,t),A(e,n,t.state,function(e){return!r(e)}),t.profile&&r(t.profile)||E(e,n,t,!1,"a1"),t.contextDep=a,t.needsContext=i,t.needsFramebuffer=f;var u=t.shader.progVar;if(u.contextDep&&a||u.propDep)z(e,n,t,null);else{var s=u.append(e,n);if(n(e.shared.gl,".useProgram(",s,".program);"),t.shader.program)z(e,n,t,t.shader.program);else{var c=e.global.def("{}"),l=n.def(s,".id"),d=n.def(c,"[",l,"]");n(e.cond(d).then(d,".call(this,a0,a1);").else(d,"=",c,"[",l,"]=",e.link(function(r){return O(z,e,t,r,2)}),"(",s,");",d,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;")}(o,f),o.compile()}}}function oe(e,t){for(var r=0;r=0&&(0|e)===e||t("invalid parameter type, ("+e+")"+n(r)+". must be a nonnegative integer")},oneOf:a,shaderError:function(e,t,n,a,o){if(!e.getShaderParameter(t,e.COMPILE_STATUS)){var f=e.getShaderInfoLog(t),s=a===e.FRAGMENT_SHADER?"fragment":"vertex";p(n,"string",s+" shader source must be a string",o);var c=l(n,o),d=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 u(0|r[1],0|r[2],r[3].trim())):e.length>0&&t.push(new u("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,d),Object.keys(c).forEach(function(e){function t(e,t){n.push(e),a.push(t||"")}var r=c[e];if(r.hasErrors){var n=[""],a=[""];t("file number "+e+": "+r.name+"\n","color:red;text-decoration:underline;font-weight:bold"),r.lines.forEach(function(e){if(e.errors.length>0){t(i(e.number,4)+"| ","background-color:yellow; font-weight:bold"),t(e.line+"\n","color:red; background-color:yellow; font-weight:bold");var r=0;e.errors.forEach(function(n){var a=n.message,o=/^\s*\'(.*)\'\s*\:\s*(.*)$/.exec(a);if(o){var f=o[1];switch(a=o[2],f){case"assign":f="="}r=Math.max(e.line.indexOf(f,r),0)}else r=0;t(i("| ",6)),t(i("^^^",r+3)+"\n","font-weight:bold"),t(i("| ",6)),t(a+"\n","font-weight:bold")}),t(i("| ",6)+"\n")}else t(i(e.number,4)+"| "),t(e.line+"\n","color:red")}),"undefined"!=typeof document&&(a[0]=n.join("%c"))}}),r.raise("Error compiling "+s+" shader, "+c[0].name)}},linkError:function(e,t,n,a,i){if(!e.getProgramParameter(t,e.LINK_STATUS)){e.getProgramInfoLog(t);var o=l(n,i),f='Error linking program with vertex shader, "'+l(a,i)[0].name+'", and fragment shader "'+o[0].name+'"';r.raise(f)}},callSite:c,saveCommandRef:d,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})}d(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?a(e.texture._texture.internalformat,t,"unsupported texture format for attachment"):a(e.renderbuffer._renderbuffer.format,r,"unsupported renderbuffer format for attachment")},guessCommand:s,texture2D:function(e,t,n){var a,i=t.width,o=t.height,f=t.channels;r(i>0&&i<=n.maxTextureSize&&o>0&&o<=n.maxTextureSize,"invalid texture shape"),e.wrapS===le&&e.wrapT===le||r(b(i)&&b(o),"incompatible wrap mode for texture, both width and height must be power of 2"),1===t.mipmask?1!==i&&1!==o&&r(e.minFilter!==me&&e.minFilter!==he&&e.minFilter!==pe&&e.minFilter!==be,"min filter requires mipmap"):(r(b(i)&&b(o),"texture must be a square power of 2 to support mipmapping"),r(t.mipmask===(i<<1)-1,"missing or incomplete mipmap data")),t.type===ge&&(n.extensions.indexOf("oes_texture_float_linear")<0&&r(e.minFilter===de&&e.magFilter===de,"filter not supported, must enable oes_texture_float_linear"),r(!e.genMipmaps,"mipmap generation not supported with float textures"));var u=t.images;for(a=0;a<16;++a)if(u[a]){var s=i>>a,c=o>>a;r(t.mipmask&1<0&&i<=a.maxTextureSize&&o>0&&o<=a.maxTextureSize,"invalid texture shape"),r(i===o,"cube map must be square"),r(t.wrapS===le&&t.wrapT===le,"wrap mode not supported by cube map");for(var u=0;u>l,p=o>>l;r(s.mipmask&1<=2,"invalid renderbuffer shape"),i=0|m[0],o=0|m[1]}else"radius"in d&&(i=o=0|d.radius),"width"in d&&(i=0|d.width),"height"in d&&(o=0|d.height);"format"in d&&(Ae.parameter(d.format,f,"invalid renderbuffer format"),c=f[d.format])}else"number"==typeof t?(i=0|t,o="number"==typeof n?0|n:i):t?Ae.raise("invalid arguments to renderbuffer constructor"):i=o=1;if(Ae(i>0&&o>0&&i<=r.maxRenderbufferSize&&o<=r.maxRenderbufferSize,"invalid renderbuffer size"),i!==l.width||o!==l.height||c!==l.format)return s.width=l.width=i,s.height=l.height=o,l.format=c,e.bindRenderbuffer(jr,l.renderbuffer),e.renderbufferStorage(jr,c,i,o),a.profile&&(l.stats.size=V(l.format,l.width,l.height)),s.format=u[l.format],s}var l=new i(e.createRenderbuffer());return c[l.id]=l,n.renderbufferCount++,s(t,o),s.resize=function(t,n){var i=0|t,o=0|n||i;return i===l.width&&o===l.height?s:(Ae(i>0&&o>0&&i<=r.maxRenderbufferSize&&o<=r.maxRenderbufferSize,"invalid renderbuffer size"),s.width=l.width=i,s.height=l.height=o,e.bindRenderbuffer(jr,l.renderbuffer),e.renderbufferStorage(jr,l.format,i,o),a.profile&&(l.stats.size=V(l.format,l.width,l.height)),s)},s._reglType="renderbuffer",s._renderbuffer=l,a.profile&&(s.stats=l.stats),s.destroy=function(){l.decRef()},s},clear:function(){Oe(c).forEach(o)},restore:function(){Oe(c).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(jr,t.renderbuffer),e.renderbufferStorage(jr,t.format,t.width,t.height)}),e.bindRenderbuffer(jr,null)}}},zr=36160,Br=36161,Pr=3553,Rr=34069,Lr=36064,Ir=36096,Mr=36128,Wr=33306,Hr=36053,Gr=6402,Ur=[6408],Nr=[];Nr[6408]=4;var qr=[];qr[5121]=1,qr[5126]=4,qr[36193]=2;var Qr=33189,Vr=36168,Yr=34041,Xr=[32854,32855,36194,35907,34842,34843,34836],$r={};$r[Hr]="complete",$r[36054]="incomplete attachment",$r[36057]="incomplete dimensions",$r[36055]="incomplete, missing attachment",$r[36061]="unsupported";var Kr=5126,Jr=35632,Zr=35633,en=35718,tn=35721,rn=6408,nn=5121,an=3333,on=5126,fn="xyzw".split(""),un=5121,sn=1,cn=2,ln=0,dn=1,mn=2,pn=3,hn=4,bn="dither",gn="blend.enable",vn="blend.color",yn="blend.equation",xn="blend.func",wn="depth.enable",kn="depth.func",An="depth.range",Sn="depth.mask",_n="colorMask",En="cull.enable",Tn="cull.face",Dn="frontFace",jn="lineWidth",On="polygonOffset.enable",Cn="polygonOffset.offset",Fn="sample.alpha",zn="sample.enable",Bn="sample.coverage",Pn="stencil.enable",Rn="stencil.mask",Ln="stencil.func",In="stencil.opFront",Mn="stencil.opBack",Wn="scissor.enable",Hn="scissor.box",Gn="viewport",Un="profile",Nn="framebuffer",qn="vert",Qn="frag",Vn="elements",Yn="primitive",Xn="count",$n="offset",Kn="instances",Jn=Nn+"Width",Zn=Nn+"Height",ea=Gn+"Width",ta=Gn+"Height",ra="drawingBufferWidth",na="drawingBufferHeight",aa=[xn,yn,Ln,In,Mn,Bn,Gn,Hn,Cn],ia=34962,oa=34963,fa=3553,ua=34067,sa=2884,ca=3042,la=3024,da=2960,ma=2929,pa=3089,ha=32823,ba=32926,ga=32928,va=5126,ya=35664,xa=35665,wa=35666,ka=5124,Aa=35667,Sa=35668,_a=35669,Ea=35670,Ta=35671,Da=35672,ja=35673,Oa=35674,Ca=35675,Fa=35676,za=35678,Ba=35680,Pa=4,Ra=1028,La=1029,Ia=2304,Ma=2305,Wa=32775,Ha=32776,Ga=519,Ua=7680,Na=0,qa=1,Qa=32774,Va=513,Ya=36160,Xa=36064,$a={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},Ka=["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"],Ja={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},Za={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},ei={frag:35632,vert:35633},ti={cw:Ia,ccw:Ma},ri=new te(!1,!1,!1,function(){}),ni=34918,ai=34919,ii=35007,oi=function(e,t){function r(e){o.push(e)}function n(e){u.push(e)}function a(e,t,r){var n=u.pop()||new function(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null};n.startQueryIndex=e,n.endQueryIndex=t,n.sum=0,n.stats=r,s.push(n)}var i=t.ext_disjoint_timer_query;if(!i)return null;var o=[],f=[],u=[],s=[],c=[],l=[];return{beginQuery:function(e){var t=o.pop()||i.createQueryEXT();i.beginQueryEXT(ii,t),f.push(t),a(f.length-1,f.length,e)},endQuery:function(){i.endQueryEXT(ii)},pushScopeStats:a,update:function(){var e,t,a=f.length;if(0!==a){l.length=Math.max(l.length,a+1),c.length=Math.max(c.length,a+1),c[0]=0,l[0]=0;var o=0;for(e=0,t=0;t=0;--e){var r=U[e];r&&r(T,null,0)}p.flush(),w&&w.update()}function r(){!K&&U.length>0&&(K=Te.next(t))}function n(){K&&(Te.cancel(t),K=null)}function a(e){e.preventDefault(),b=!0,n(),N.forEach(function(e){e()})}function i(e){p.getError(),b=!1,g.restore(),P.restore(),j.restore(),R.restore(),L.restore(),I.restore(),w&&w.restore(),M.procs.refresh(),r(),q.forEach(function(e){e()})}function o(e){function t(e){var t={},r={};return Object.keys(e).forEach(function(n){var a=e[n];Ee.isDynamic(a)?r[n]=Ee.unbox(a,n):t[n]=a}),{dynamic:r,static:t}}Ae(!!e,"invalid args to regl({...})"),Ae.type(e,"object","invalid args to regl({...})");var r=t(e.context||{}),n=t(e.uniforms||{}),a=t(e.attributes||{}),i=t(function(e){function t(e){if(e in r){var t=r[e];delete r[e],Object.keys(t).forEach(function(n){r[e+"."+n]=t[n]})}}var r=se({},e);return delete r.uniforms,delete r.attributes,delete r.context,"stencil"in r&&r.stencil.op&&(r.stencil.opBack=r.stencil.opFront=r.stencil.op,delete r.stencil.op),t("blend"),t("depth"),t("cull"),t("stencil"),t("polygonOffset"),t("scissor"),t("sample"),r}(e)),o={gpuTime:0,cpuTime:0,count:0},f=M.compile(i,a,n,r,o),u=f.draw,s=f.batch,c=f.scope,l=[];return se(function(e,t){var r;if(b&&Ae.raise("context lost"),"function"==typeof e)return c.call(this,null,e,0);if("function"==typeof t){if("number"==typeof e){for(r=0;r0)return s.call(this,function(e){for(;l.length=0,"cannot cancel a frame twice"),U[r]=t}}}function s(){var e=H.viewport,t=H.scissor_box;e[0]=e[1]=t[0]=t[1]=0,T.viewportWidth=T.framebufferWidth=T.drawingBufferWidth=e[2]=t[2]=p.drawingBufferWidth,T.viewportHeight=T.framebufferHeight=T.drawingBufferHeight=e[3]=t[3]=p.drawingBufferHeight}function c(){T.tick+=1,T.time=d(),s(),M.procs.poll()}function l(){s(),M.procs.refresh(),w&&w.update()}function d(){return(De()-k)/1e3}var m=A(e);if(!m)return null;var p=m.gl,h=p.getContextAttributes(),b=p.isContextLost(),g=function(e,t){function r(t){Ae.type(t,"string","extension name must be string");var r,a=t.toLowerCase();try{r=n[a]=e.getExtension(a)}catch(e){}return!!r}for(var n={},a=0;a0){var u;if(Array.isArray(t[0])){f=Ne(t);for(var s=1,c=1;c0)if("number"==typeof e[0]){var a=Me.allocType(m.dtype,e.length);F(a,e),d(a,n),Me.freeType(a)}else if(Array.isArray(e[0])||ue(e[0])){r=Ne(e);var i=Ue(e,r,m.dtype);d(i,n),Me.freeType(i)}else Ae.raise("invalid buffer data")}else if(ue(e))d(e,n);else if(S(e)){r=e.shape;var o=e.stride,f=0,u=0,s=0,c=0;1===r.length?(f=r[0],u=1,s=o[0],c=0):2===r.length?(f=r[0],u=r[1],s=o[0],c=o[1]):Ae.raise("invalid shape");var p=Array.isArray(e.data)?m.dtype:C(e.data),h=Me.allocType(p,f*u);z(h,e.data,f,u,s,c,e.offset),d(h,n),Me.freeType(h)}else Ae.raise("invalid data for buffer subdata");return l},r.profile&&(l.stats=m.stats),l.destroy=function(){o(m)},l},createStream:function(e,t){var r=s.pop();return r||(r=new n(e)),r.bind(),i(r,t,Qe,0,1,!1),r},destroyStream:function(e){s.push(e)},clear:function(){Oe(u).forEach(o),s.forEach(o)},getBuffer:function(e){return e&&e._buffer instanceof n?e._buffer:null},restore:function(){Oe(u).forEach(function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)})},_initBuffer:i}}(p,y,m),O=function(e,t,r,n){function a(e){this.id=u++,f[this.id]=this,this.buffer=e,this.primType=Ze,this.vertCount=0,this.type=0}function i(n,a,i,o,f,u,s){if(n.buffer.bind(),a){var c=s;s||ue(a)&&(!S(a)||ue(a.data))||(c=t.oes_element_index_uint?it:nt),r._initBuffer(n.buffer,a,i,c,3)}else e.bufferData(ot,u,i),n.buffer.dtype=l||tt,n.buffer.usage=i,n.buffer.dimension=3,n.buffer.byteLength=u;var l=s;if(!s){switch(n.buffer.dtype){case tt:case et:l=tt;break;case nt:case rt:l=nt;break;case it:case at:l=it;break;default:Ae.raise("unsupported type for element array")}n.buffer.dtype=l}n.type=l,Ae(l!==it||!!t.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var d=f;d<0&&(d=n.buffer.byteLength,l===nt?d>>=1:l===it&&(d>>=2)),n.vertCount=d;var m=o;if(o<0){m=Ze;var p=n.buffer.dimension;1===p&&(m=Ke),2===p&&(m=Je),3===p&&(m=Ze)}n.primType=m}function o(e){n.elementsCount--,Ae(null!==e.buffer,"must not double destroy elements"),delete f[e.id],e.buffer.destroy(),e.buffer=null}var f={},u=0,s={uint8:tt,uint16:nt};t.oes_element_index_uint&&(s.uint32=it),a.prototype.bind=function(){this.buffer.bind()};var c=[];return{create:function(e,t){function f(e){if(e)if("number"==typeof e)u(e),c.primType=Ze,c.vertCount=0|e,c.type=tt;else{var t=null,r=ut,n=-1,a=-1,o=0,l=0;Array.isArray(e)||ue(e)||S(e)?t=e:(Ae.type(e,"object","invalid arguments for elements"),"data"in e&&(t=e.data,Ae(Array.isArray(t)||ue(t)||S(t),"invalid data for element buffer")),"usage"in e&&(Ae.parameter(e.usage,Ge,"invalid element buffer usage"),r=Ge[e.usage]),"primitive"in e&&(Ae.parameter(e.primitive,$e,"invalid element buffer primitive"),n=$e[e.primitive]),"count"in e&&(Ae("number"==typeof e.count&&e.count>=0,"invalid vertex count for elements"),a=0|e.count),"type"in e&&(Ae.parameter(e.type,s,"invalid buffer type"),l=s[e.type]),"length"in e?o=0|e.length:(o=a,l===nt||l===rt?o*=2:l!==it&&l!==at||(o*=4))),i(c,t,r,n,a,o,l)}else u(),c.primType=Ze,c.vertCount=0,c.type=tt;return f}var u=r.create(null,ot,!0),c=new a(u._buffer);return n.elementsCount++,f(e),f._reglType="elements",f._elements=c,f.subdata=function(e,t){return u.subdata(e,t),f},f.destroy=function(){o(c)},f},createStream:function(e){var t=c.pop();return t||(t=new a(r.create(null,ot,!0,!1)._buffer)),i(t,e,ft,-1,-1,0,0),t},destroyStream:function(e){c.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof a?e._elements:null},clear:function(){Oe(f).forEach(o)}}}(p,x,j,y),B=function(e,t,r,n,a){for(var i=r.maxAttributes,o=new Array(i),f=0;f=Rr&&t=2,"invalid shape for framebuffer"),s=F[0],m=F[1]}else"radius"in C&&(s=m=C.radius),"width"in C&&(s=C.width),"height"in C&&(m=C.height);("color"in C||"colors"in C)&&(v=C.color||C.colors,Array.isArray(v)&&Ae(1===v.length||f,"multiple render targets not supported")),v||("colorCount"in C&&(E=0|C.colorCount,Ae(E>0,"invalid color buffer count")),"colorTexture"in C&&(A=!!C.colorTexture,S="rgba4"),"colorType"in C&&(_=C.colorType,A?(Ae(t.oes_texture_float||!("float"===_||"float32"===_),"you must enable OES_texture_float in order to use floating point framebuffer objects"),Ae(t.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"===_?(Ae(t.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),S="rgba16f"):"float"!==_&&"float32"!==_||(Ae(t.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),S="rgba32f"),Ae.oneOf(_,k,"invalid color type")),"colorFormat"in C&&(S=C.colorFormat,x.indexOf(S)>=0?A=!0:w.indexOf(S)>=0?A=!1:A?Ae.oneOf(C.colorFormat,x,"invalid color format for texture"):Ae.oneOf(C.colorFormat,w,"invalid color format for renderbuffer"))),("depthTexture"in C||"depthStencilTexture"in C)&&(O=!(!C.depthTexture&&!C.depthStencilTexture),Ae(!O||t.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in C&&("boolean"==typeof C.depth?p=C.depth:(T=C.depth,b=!1)),"stencil"in C&&("boolean"==typeof C.stencil?b=C.stencil:(D=C.stencil,p=!1)),"depthStencil"in C&&("boolean"==typeof C.depthStencil?p=b=C.depthStencil:(j=C.depthStencil,p=!1,b=!1))}else s=m=1;var z=null,B=null,P=null,R=null;if(Array.isArray(v))z=v.map(c);else if(v)z=[c(v)];else for(z=new Array(E),i=0;i=0||z[i].renderbuffer&&Xr.indexOf(z[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),z[i]&&z[i].texture){var I=Nr[z[i].texture._texture.format]*qr[z[i].texture._texture.type];null===L?L=I:Ae(L===I,"all color attachments much have the same number of bits per pixel.")}return u(B,s,m),Ae(!B||B.texture&&B.texture._texture.format===Gr||B.renderbuffer&&B.renderbuffer._renderbuffer.format===Qr,"invalid depth attachment for framebuffer object"),u(P,s,m),Ae(!P||P.renderbuffer&&P.renderbuffer._renderbuffer.format===Vr,"invalid stencil attachment for framebuffer object"),u(R,s,m),Ae(!R||R.texture&&R.texture._texture.format===Yr||R.renderbuffer&&R.renderbuffer._renderbuffer.format===Yr,"invalid depth-stencil attachment for framebuffer object"),h(o),o.width=s,o.height=m,o.colorAttachments=z,o.depthAttachment=B,o.stencilAttachment=P,o.depthStencilAttachment=R,a.color=z.map(d),a.depth=d(B),a.stencil=d(P),a.depthStencil=d(R),a.width=o.width,a.height=o.height,g(o),a}var o=new p;return i.framebufferCount++,a(e,n),se(a,{resize:function(e,t){Ae(y.next!==o,"can not resize a framebuffer which is currently in use");var r=0|e,n=0|t||r;if(r===o.width&&n===o.height)return a;for(var i=o.colorAttachments,f=0;f=2,"invalid shape for framebuffer"),Ae(p[0]===p[1],"cube framebuffer must be square"),u=p[0]}else"radius"in m&&(u=0|m.radius),"width"in m?(u=0|m.width,"height"in m&&Ae(m.height===u,"must be square")):"height"in m&&(u=0|m.height);("color"in m||"colors"in m)&&(s=m.color||m.colors,Array.isArray(s)&&Ae(1===s.length||o,"multiple render targets not supported")),s||("colorCount"in m&&(d=0|m.colorCount,Ae(d>0,"invalid color buffer count")),"colorType"in m&&(Ae.oneOf(m.colorType,k,"invalid color type"),l=m.colorType),"colorFormat"in m&&(c=m.colorFormat,Ae.oneOf(m.colorFormat,x,"invalid color format for texture"))),"depth"in m&&(f.depth=m.depth),"stencil"in m&&(f.stencil=m.stencil),"depthStencil"in m&&(f.depthStencil=m.depthStencil)}else u=1;var h;if(s)if(Array.isArray(s))for(h=[],r=0;r0&&(f.depth=i[0].depth,f.stencil=i[0].stencil,f.depthStencil=i[0].depthStencil),i[r]?i[r](f):i[r]=v(f)}return se(a,{width:u,height:u,color:h})}var i=Array(6);return a(e),se(a,{faces:i,resize:function(e){var t,n=0|e;if(Ae(n>0&&n<=r.maxCubeMapSize,"invalid radius for cube fbo"),n===a.width)return a;var o=a.color;for(t=0;t=0},read:W,destroy:function(){U.length=0,n(),G&&(G.removeEventListener(li,a),G.removeEventListener(di,i)),P.clear(),I.clear(),L.clear(),R.clear(),O.clear(),j.clear(),w&&w.clear(),V.forEach(function(e){e()})},_gl:p,_refresh:l,poll:function(){c(),w&&w.update()},now:d,stats:y});return m.onDone(null,Z),Z}}); +},{}],2:[function(require,module,exports) { +"use strict";function e(e,t,i,s,n=1){for(;;){if(t-e<=n)return[e,t];const o=(t+e)/2,r=i(o);rs&&(t=o)}}function t(e,t){const i=Math.floor(t/2),s=e.substr(0,i),n=e.substr(e.length-i,i);return s+p+n}function i(e,t){return d.has(t)||d.set(t,e.measureText(t).width),d.get(t)}function s(s,n,o){if(i(s,n)<=o)return n;const[r]=e(0,n.length,e=>i(s,t(n,e)),o);return t(n,r)}Object.defineProperty(exports,"__esModule",{value:!0});const n=require("preact"),o=require("aphrodite"),r=require("regl"),a=require("./math"),h=require("./utils");var c;(c||(c={})).MONOSPACE="Courier, monospace";var l;!function(e){e[e.LABEL=10]="LABEL"}(l||(l={}));class f{constructor(e){this.profile=e,this.layers=[],this.duration=0,this.frameColors=new Map,e.forEachSample(this.appendSample.bind(this)),this.layers=this.layers.map(f.mergeAdjacentFrames),this.selectFrameColors(e)}getDuration(){return this.duration}getLayers(){return this.layers}getFrameColors(){return this.frameColors}appendFrame(e,t,i,s){for(;e>=this.layers.length;)this.layers.push([]);const n={node:t,start:this.duration,end:this.duration+i,parent:s,children:[]};return this.layers[e].push(n),s&&s.children.push(n),n}appendSample(e,t){let i=null;for(let s=0;s0?t[t.length-1]:null;e&&f.shouldMergeFrames(e,i)?(t.pop(),t.push(f.mergeFrames(e,i))):t.push(i)}return t}selectFrameColors(e){function t(e){return(e.file||"").split("/").concat(e.name.split(/\W/))}function i(e,i){const s=t(e),n=t(i),o=Math.min(s.length,n.length);let r=0;for(let e=0;en.join()?a:-a}const s=[];this.profile.forEachFrame(e=>s.push(e)),s.sort(i);const n=[];let o=0;for(let e=0;e{e?(this.canvas=e,this.ctx=this.canvas.getContext("webgl"),this.renderCanvas()):this.canvas=null}),this.overlayCanvasRef=(e=>{e?(this.overlayCanvas=e,this.overlayCtx=this.overlayCanvas.getContext("2d"),this.renderCanvas()):(this.overlayCanvas=null,this.overlayCtx=null)}),this.LOGICAL_VIEW_SPACE_FRAME_HEIGHT=16,this.renderCanvas=h.atMostOnceAFrame(()=>{!this.canvas||this.canvas.getBoundingClientRect().width<2?requestAnimationFrame(()=>this.renderCanvas()):(this.renderer||this.preprocess(this.props.flamechart),this.renderRects(),this.renderLabels())}),this.lastDragPos=null,this.onMouseDown=(e=>{this.lastDragPos=new a.Vec2(e.offsetX,e.offsetY)}),this.onMouseDrag=(e=>{if(!this.lastDragPos)return;const t=new a.Vec2(e.offsetX,e.offsetY);this.pan(this.lastDragPos.minus(t)),this.lastDragPos=t}),this.onMouseMove=(e=>{if(this.lastDragPos)return e.preventDefault(),void this.onMouseDrag(e);this.hoveredLabel=null;const t=new a.Vec2(e.offsetX,e.offsetY),i=this.logicalToPhysicalViewSpace().transformPosition(t),s=this.configSpaceToPhysicalViewSpace().inverseTransformPosition(i);if(s){for(let e of this.labels)if(e.configSpaceBounds.contains(s)){this.hoveredLabel=e;break}this.props.setNodeHover(this.hoveredLabel?this.hoveredLabel.node:null,t),this.renderCanvas()}}),this.onWheel=(e=>{if(e.preventDefault(),e.metaKey||e.ctrlKey){let t=1+e.deltaY/100;e.ctrlKey&&(t=1+e.deltaY/40),this.zoom(new a.Vec2(e.offsetX,e.offsetY),t)}else this.pan(new a.Vec2(e.deltaX,e.deltaY)),this.hoveredLabel=null,this.props.setNodeHover(null,new a.Vec2);this.renderCanvas()}),this.onWindowMouseUp=(e=>{this.lastDragPos=null})}preprocess(e){if(!this.canvas||!this.ctx)return;const t=[],i=[],s=e.getLayers(),n=e.getFrameColors();this.labels=[];for(let e=0;e{this.setState({hoveredNode:e,logicalSpaceMouse:t})}),this.containerRef=(e=>{this.container=e||null}),this.state={hoveredNode:null,logicalSpaceMouse:new a.Vec2}}formatTime(e){const t=this.props.flamechart.getDuration();return`${(e/1e3).toFixed(2)}ms (${(100*e/t).toFixed()}%)`}renderTooltip(){if(!this.container)return null;const{hoveredNode:e,logicalSpaceMouse:t}=this.state;if(!e)return null;const{width:i,height:s}=this.container.getBoundingClientRect(),r={};return t.x+7+v.TOOLTIP_WIDTH_MAX{const s=[],n=[],o=(e,t)=>{function i(e){s.push(e.flatten()),n.push(t)}i(e.topLeft()),i(e.bottomLeft()),i(e.topRight()),i(e.bottomLeft()),i(e.topRight()),i(e.bottomRight())};for(let e=0;et.configSpaceToNDC.flatten(),physicalSize:(e,t)=>t.physicalSize.flatten()},primitive:"triangles",count:n.length})}); +},{"./math":7,"./utils":8,"preact":5,"aphrodite":6,"regl":10}],9:[function(require,module,exports) { +"use strict";function e(e,t,s){return e.has(t)||e.set(t,s),e.get(t)}function t(e){return e[e.length-1]}Object.defineProperty(exports,"__esModule",{value:!0});class s{constructor(){this.selfTime=0,this.totalTime=0}getSelfTime(){return this.selfTime}getTotalTime(){return this.totalTime}addToTotalTime(e){this.totalTime+=e}addToSelfTime(e){this.selfTime+=e}}exports.HasTimings=s;class i extends s{constructor(e){super(),this.key=e.key,this.name=e.name,this.file=e.file,this.line=e.line,this.col=e.col}}exports.Frame=i;class r extends s{constructor(e,t){super(),this.frame=e,this.parent=t,this.children=[]}}exports.CallTreeNode=r;class a{constructor(e){this.frames=new Map,this.calltreeRoots=[],this.samples=[],this.timeDeltas=[],this.events=[],this.duration=e}getDuration(){return this.duration}getEvents(){return this.events}forEachSample(e){const t=new Map;for(let s=0;se(t[0])(r.push({stack:t.split(";").map(e=>({key:e,name:e})),duration:parseInt(o,10)}),e)),r}function r(r){const o=e(r),n=o.reduce((e,r)=>e+r.duration,0),a=new t.Profile(n);for(let e of o)a.appendSample(e.stack,e.duration);return a}Object.defineProperty(exports,"__esModule",{value:!0});const t=require("../profile");exports.importFromBGFlameGraph=r; +},{"../profile":9}],4:[function(require,module,exports) { +"use strict";function e(e){const r=JSON.parse(e),s=r.raw_timestamp_deltas.reduce((e,t)=>e+t,0),o=new t.Profile(s),{frames:a,raw:l,raw_timestamp_deltas:n}=r;let p=0;for(let e=0;e{const t=e.dataTransfer.files.item(0),n=new FileReader;n.addEventListener("loadend",()=>{const e=t.name.endsWith("json")?o.importFromStackprof(n.result):r.importFromBGFlameGraph(n.result),i=new s.Flamechart(e),a=new s.Flamechart(e.sortedAlphabetically());this.setState({profile:e,flamechart:i,sortedFlamechart:a})}),n.readAsText(t),e.preventDefault()}),this.onDragOver=(e=>{e.preventDefault()}),this.onWindowKeyPress=(e=>{"a"==e.key&&this.setState({sortOrder:this.state.sortOrder===n.CHRONO?n.ALPHA:n.CHRONO})}),this.onWindowResize=(()=>{this.forceUpdate()}),this.state={profile:null,flamechart:null,sortedFlamechart:null,sortOrder:n.CHRONO}}componentDidMount(){window.addEventListener("resize",this.onWindowResize),window.addEventListener("keypress",this.onWindowKeyPress)}componentWillUnmount(){window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keypress",this.onWindowKeyPress)}render(){const{flamechart:r,sortedFlamechart:o,sortOrder:i}=this.state,d=i==n.CHRONO?r:o;return e.h("div",{onDrop:this.onDrop,onDragOver:this.onDragOver,className:t.css(a.root)},d&&e.h(s.FlamechartView,{flamechart:d}))}}const a=t.StyleSheet.create({root:{width:"100vw",height:"100vh",overflow:"hidden"}});e.render(e.h(i,null),document.body); +},{"./flamechart":2,"./import/bg-flamegraph":3,"./import/stackprof":4,"preact":5,"aphrodite":6}]},{},[1]) \ No newline at end of file diff --git a/package.json b/package.json index cec82ac..33f81ba 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,14 @@ "description": "", "main": "index.js", "scripts": { - "serve": "budo index.tsx --force-default-index --css reset.css -- -p tsify", - "release": "browserify index.tsx -p tsify | uglifyjs -cm > dist/speedscope.js" + "serve": "parcel dev.html", + "release": "parcel build speedscope.tsx" }, "author": "", "license": "MIT", "devDependencies": { "aphrodite": "^1.2.5", - "browserify": "^14.5.0", - "budo": "^10.0.4", + "parcel-bundler": "^1.2.1", "preact": "^8.2.7", "regl": "^1.3.0", "tsify": "^3.0.4", diff --git a/index.tsx b/speedscope.tsx similarity index 100% rename from index.tsx rename to speedscope.tsx