-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.js
2 lines (2 loc) · 162 KB
/
output.js
1
2
!function(){return 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){return i(t[o][1][e]||e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}}()({1:[function(e,t,n){t.exports=function(e){"string"==typeof e&&(e=[e]);for(var t=[].slice.call(arguments,1),n=[],r=0;r<e.length-1;r++)n.push(e[r],t[r]||"");return n.push(e[r]),n.join("")}},{}],2:[function(e,t,n){const r=e("canvas-sketch"),i=e("canvas-sketch-util/shader"),a=e("glslify")(["\n precision highp float;\n#define GLSLIFY 1\n\n\n uniform float time;\n varying vec2 vUv;\n\n //\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : ijm\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec3 mod289_0(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289_0(vec4 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute_0(vec4 x) {\n return mod289_0(((x*34.0)+1.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise_0(vec3 v)\n {\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n// First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n// Other corners\n vec3 g_0 = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g_0;\n vec3 i1 = min( g_0.xyz, l.zxy );\n vec3 i2 = max( g_0.xyz, l.zxy );\n\n // x0 = x0 - 0.0 + 0.0 * C.xxx;\n // x1 = x0 - i1 + 1.0 * C.xxx;\n // x2 = x0 - i2 + 2.0 * C.xxx;\n // x3 = x0 - 1.0 + 3.0 * C.xxx;\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n// Permutations\n i = mod289_0(i);\n vec4 p = permute_0( permute_0( permute_0(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n// Gradients: 7x7 points over a square, mapped onto an octahedron.\n// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n//Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n// Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n }\n\n //\n// Description : Array and textureless GLSL 2D simplex noise function.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : ijm\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec3 mod289_1(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec2 mod289_1(vec2 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec3 permute_1(vec3 x) {\n return mod289_1(((x*34.0)+1.0)*x);\n}\n\nfloat snoise_1(vec2 v)\n {\n const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439); // 1.0 / 41.0\n// First corner\n vec2 i = floor(v + dot(v, C.yy) );\n vec2 x0 = v - i + dot(i, C.xx);\n\n// Other corners\n vec2 i1;\n //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0\n //i1.y = 1.0 - i1.x;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n // x0 = x0 - 0.0 + 0.0 * C.xx ;\n // x1 = x0 - i1 + 1.0 * C.xx ;\n // x2 = x0 - 1.0 + 2.0 * C.xx ;\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n\n// Permutations\n i = mod289_1(i); // Avoid truncation effects in permutation\n vec3 p = permute_1( permute_1( i.y + vec3(0.0, i1.y, 1.0 ))\n + i.x + vec3(0.0, i1.x, 1.0 ));\n\n vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);\n m = m*m ;\n m = m*m ;\n\n// Gradients: 41 points uniformly over a line, mapped onto a diamond.\n// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)\n\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n\n// Normalise gradients implicitly by scaling m\n// Approximation of: m *= inversesqrt( a0*a0 + h*h );\n m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );\n\n// Compute final noise value at P\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n\n vec3 c1 = vec3(124.0, 245.0, 190.0) / vec3(255.0);\n vec3 c2 = vec3(40., 151., 155.) / vec3(255.0);\n vec3 c3 = vec3(250., 184., 104.) / vec3(255.0);\n\n void main () {\n vec3 color = 0.5 + 0.5 * cos(time + vUv.xyx + vec3(0.0, 2.0, 4.0));\n gl_FragColor = vec4(c1, 1.0);\n }\n"]);r(({gl:e})=>i({gl:e,frag:a,uniforms:{time:({time:e})=>e}}),{context:"webgl",animate:!0})},{"canvas-sketch":4,"canvas-sketch-util/shader":3,glslify:1}],3:[function(e,t,n){var r=e("regl"),i=e("primitive-quad"),a=e("parse-color"),o=e("defined");function s(e){return e&&!Array.isArray(e)&&"object"==typeof e}t.exports=function(e){if(!(e=e||{}).gl)throw new Error('Must specify { context: "webgl" } in sketch settings, or a WebGL-enabled canvas');var t=e.gl,n={gl:t};void 0!==e.extensions&&(n.extensions=e.extensions);void 0!==e.optionalExtensions&&(n.optionalExtensions=e.optionalExtensions);void 0!==e.profile&&(n.profile=e.profile);void 0!==e.onDone&&(n.onDone=e.onDone);var f,u=r(n),c=i(),l=new Map,p=e.uniforms||{},d=Object.assign({},p);Object.keys(p).forEach(function(e){var t=p[e];d[e]="function"==typeof t?function(e,n,r){var i=t.call(p,n,r);if(s(i))if(l.has(t)){var a=l.get(t);a(i),i=a}else{var o=u.texture(i);l.set(t,o),i=o}return i}:s(t)?u.texture(t):t});try{f=u({scissor:!!e.scissor&&{enable:!0,box:{x:u.prop("scissorX"),y:u.prop("scissorY"),width:u.prop("scissorWidth"),height:u.prop("scissorHeight")}},uniforms:d,frag:e.frag||["precision highp float;","","void main () {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);","}"].join("\n"),vert:e.vert||["precision highp float;","attribute vec3 position;","varying vec2 vUv;","","void main () {"," gl_Position = vec4(position.xyz, 1.0);"," vUv = gl_Position.xy * 0.5 + 0.5;","}"].join("\n"),blend:!1!==e.blend?{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1}}:void 0,attributes:{position:c.positions},elements:c.cells})}catch(e){b(e)}var m=o(e.clearColor,"black");if("string"==typeof m){var h=a(m);if(!h.rgb)throw new Error('Error parsing { clearColor } color string "'+m+'"');m=h.rgb.slice(0,3).map(function(e){return e/255})}else if(m&&(!Array.isArray(m)||m.length<3))throw new Error("Error with { clearColor } option, must be a string or [ r, g, b ] float array");var v=o(e.clearAlpha,1),g=!!m&&m.concat([v||0]);return{render:function(e){u.poll(),g&&u.clear({color:g,depth:1,stencil:0}),y(e),t.flush()},regl:u,drawQuad:y,unload:function(){l.clear(),u.destroy()}};function y(e){if(e=e||{},f)try{f(e)}catch(t){b(t)&&null==e&&console.warn('Warning: shader.render() is not called with any "props" parameter')}}function b(e){if(/^\(regl\)/.test(e.message))return!0;throw e}}},{defined:8,"parse-color":9,"primitive-quad":10,regl:11}],4:[function(e,t,n){(function(r){(function(){!function(r,i){"object"==typeof n&&void 0!==t?t.exports=i(e("convert-length")):"function"==typeof define&&define.amd?define(["convert-length"],i):r.canvasSketch=i(null)}(this,function(e){e=e&&e.hasOwnProperty("default")?e.default:e;var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;var a=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,r){for(var a,o,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),f=1;f<arguments.length;f++){for(var u in a=Object(arguments[f]))n.call(a,u)&&(s[u]=a[u]);if(t){o=t(a);for(var c=0;c<o.length;c++)i.call(a,o[c])&&(s[o[c]]=a[o[c]])}}return s},o="undefined"!=typeof window?window:void 0!==r?r:"undefined"!=typeof self?self:{};function s(e,t){return e(t={exports:{}},t.exports),t.exports}var f=o.performance&&o.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date},u=function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then};var c=function(e){return!(!e||"object"!=typeof e)&&("object"==typeof window&&"object"==typeof window.Node?e instanceof window.Node:"number"==typeof e.nodeType&&"string"==typeof e.nodeName)};function l(){return"undefined"!=typeof window&&window["canvas-sketch-cli"]}function p(){for(var e=arguments,t=0;t<arguments.length;t++)if(null!=e[t])return e[t]}function d(){return"undefined"!=typeof document}var m,h=s(function(e,t){function n(e){var t=[];for(var n in e)t.push(n);return t}(e.exports="function"==typeof Object.keys?Object.keys:n).shim=n}),v=s(function(e,t){var n="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();function r(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function i(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}(t=e.exports=n?r:i).supported=r,t.unsupported=i}),g=s(function(e){var t=Array.prototype.slice,n=e.exports=function(e,a,o){return o||(o={}),e===a||(e instanceof Date&&a instanceof Date?e.getTime()===a.getTime():!e||!a||"object"!=typeof e&&"object"!=typeof a?o.strict?e===a:e==a:function(e,a,o){var s,f;if(r(e)||r(a))return!1;if(e.prototype!==a.prototype)return!1;if(v(e))return!!v(a)&&(e=t.call(e),a=t.call(a),n(e,a,o));if(i(e)){if(!i(a))return!1;if(e.length!==a.length)return!1;for(s=0;s<e.length;s++)if(e[s]!==a[s])return!1;return!0}try{var u=h(e),c=h(a)}catch(e){return!1}if(u.length!=c.length)return!1;for(u.sort(),c.sort(),s=u.length-1;s>=0;s--)if(u[s]!=c[s])return!1;for(s=u.length-1;s>=0;s--)if(!n(e[f=u[s]],a[f],o))return!1;return typeof e==typeof a}(e,a,o))};function r(e){return null==e}function i(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&!(e.length>0&&"number"!=typeof e[0]))}}),y=s(function(e,t){!function(t){var n,r,i,a=(n=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|"[^"]*"|'[^']*'/g,r=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,i=/[^-+\dA-Z]/g,function(e,t,s,f){if(1!==arguments.length||"string"!==(null===(u=e)?"null":void 0===u?"undefined":"object"!=typeof u?typeof u:Array.isArray(u)?"array":{}.toString.call(u).slice(8,-1).toLowerCase())||/\d/.test(e)||(t=e,e=void 0),(e=e||new Date)instanceof Date||(e=new Date(e)),isNaN(e))throw TypeError("Invalid date");var u,c=(t=String(a.masks[t]||t||a.masks.default)).slice(0,4);"UTC:"!==c&&"GMT:"!==c||(t=t.slice(4),s=!0,"GMT:"===c&&(f=!0));var l=s?"getUTC":"get",p=e[l+"Date"](),d=e[l+"Day"](),m=e[l+"Month"](),h=e[l+"FullYear"](),v=e[l+"Hours"](),g=e[l+"Minutes"](),y=e[l+"Seconds"](),b=e[l+"Milliseconds"](),x=s?0:e.getTimezoneOffset(),w=function(e){var t=new Date(e.getFullYear(),e.getMonth(),e.getDate());t.setDate(t.getDate()-(t.getDay()+6)%7+3);var n=new Date(t.getFullYear(),0,4);n.setDate(n.getDate()-(n.getDay()+6)%7+3);var r=t.getTimezoneOffset()-n.getTimezoneOffset();return t.setHours(t.getHours()-r),1+Math.floor((t-n)/6048e5)}(e),k=function(e){var t=e.getDay();return 0===t&&(t=7),t}(e),_={d:p,dd:o(p),ddd:a.i18n.dayNames[d],dddd:a.i18n.dayNames[d+7],m:m+1,mm:o(m+1),mmm:a.i18n.monthNames[m],mmmm:a.i18n.monthNames[m+12],yy:String(h).slice(2),yyyy:h,h:v%12||12,hh:o(v%12||12),H:v,HH:o(v),M:g,MM:o(g),s:y,ss:o(y),l:o(b,3),L:o(Math.round(b/10)),t:v<12?a.i18n.timeNames[0]:a.i18n.timeNames[1],tt:v<12?a.i18n.timeNames[2]:a.i18n.timeNames[3],T:v<12?a.i18n.timeNames[4]:a.i18n.timeNames[5],TT:v<12?a.i18n.timeNames[6]:a.i18n.timeNames[7],Z:f?"GMT":s?"UTC":(String(e).match(r)||[""]).pop().replace(i,""),o:(x>0?"-":"+")+o(100*Math.floor(Math.abs(x)/60)+Math.abs(x)%60,4),S:["th","st","nd","rd"][p%10>3?0:(p%100-p%10!=10)*p%10],W:w,N:k};return t.replace(n,function(e){return e in _?_[e]:e.slice(1,e.length-1)})});function o(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e}a.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:sso",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",expiresHeaderFormat:"ddd, dd mmm yyyy HH:MM:ss Z"},a.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"],timeNames:["a","p","am","pm","A","P","AM","PM"]},e.exports=a}()}),b="",x=function(e,t){if("string"!=typeof e)throw new TypeError("expected a string");if(1===t)return e;if(2===t)return e+e;var n=e.length*t;if(m!==e||void 0===m)m=e,b="";else if(b.length>=n)return b.substr(0,n);for(;n>b.length&&t>1;)1&t&&(b+=e),t>>=1,e+=e;return b=(b+=e).substr(0,n)};var w,k=function(e,t,n){return e=e.toString(),void 0===t?e:(n=0===n?"0":n?n.toString():" ",x(n,t-e.length)+e)},_=function(){},A={extension:"",prefix:"",suffix:""},S=["image/png","image/jpeg","image/webp"];function E(e,t){return void 0===t&&(t={}),new Promise(function(n,r){t=a({},A,t);var i=j(Object.assign({},t,{frame:void 0})),o=e?"streamStart":"streamEnd",s=l();return s&&s.output&&"function"==typeof s[o]?s[o](a({},t,{filename:i})).then(function(e){return n(e)}):n({filename:i,client:!1})})}function T(e,t){return void 0===t&&(t={}),function(e){return new Promise(function(t){var n=e.indexOf(",");if(-1!==n){for(var r=e.slice(n+1),i=window.atob(r),a=e.slice(0,n),o=/data:([^;]+)/.exec(a),s=(o?o[1]:"")||void 0,f=new ArrayBuffer(i.length),u=new Uint8Array(f),c=0;c<i.length;c++)u[c]=i.charCodeAt(c);t(new window.Blob([f],{type:s}))}else t(new window.Blob)})}(e).then(function(e){return O(e,t)})}function O(e,t){return void 0===t&&(t={}),new Promise(function(n){var r=(t=a({},A,t)).filename,i=l();if(i&&"function"==typeof i.saveBlob&&i.output)return i.saveBlob(e,a({},t,{filename:r})).then(function(e){return n(e)});w||((w=document.createElement("a")).style.visibility="hidden",w.target="_blank"),w.download=r,w.href=window.URL.createObjectURL(e),document.body.appendChild(w),w.onclick=function(){w.onclick=_,setTimeout(function(){window.URL.revokeObjectURL(e),w.parentElement&&w.parentElement.removeChild(w),w.removeAttribute("href"),n({filename:r,client:!1})})},w.click()})}function j(e){if(void 0===e&&(e={}),"function"==typeof(e=a({},e)).file)return e.file(e);if(e.file)return e.file;var t,n=null,r="";("string"==typeof e.extension&&(r=e.extension),"number"==typeof e.frame)&&(t="number"==typeof e.totalFrames?e.totalFrames:Math.max(1e3,e.frame),n=k(String(e.frame),String(t).length,"0"));var i=isFinite(e.totalLayers)&&isFinite(e.layer)&&e.totalLayers>1?""+e.layer:"";return null!=n?[i,n].filter(Boolean).join("-")+r:[e.prefix,e.name||e.timeStamp,i,e.hash,e.suffix].filter(Boolean).join("-")+r}var C={dimension:"dimensions",animated:"animate",animating:"animate",unit:"units",P5:"p5",pixellated:"pixelated",looping:"loop",pixelPerInch:"pixels"},D=["dimensions","units","pixelsPerInch","orientation","scaleToFit","scaleToView","bleed","pixelRatio","exportPixelRatio","maxPixelRatio","scaleContext","resizeCanvas","styleCanvas","canvas","context","attributes","parent","file","name","prefix","suffix","animate","playing","loop","duration","totalFrames","fps","playbackRate","timeScale","frame","time","flush","pixelated","hotkeys","p5","id","scaleToFitPadding","data","params","encoding","encodingQuality"],z=function(e){Object.keys(e).forEach(function(e){e in C?console.warn('[canvas-sketch] Could not recognize the setting "'+e+'", did you mean "'+C[e]+'"?'):D.includes(e)||console.warn('[canvas-sketch] Could not recognize the setting "'+e+'"')})};var M=[["postcard",101.6,152.4],["poster-small",280,430],["poster",460,610],["poster-large",610,910],["business-card",50.8,88.9],["2r",64,89],["3r",89,127],["4r",102,152],["5r",127,178],["6r",152,203],["8r",203,254],["10r",254,305],["11r",279,356],["12r",305,381],["a0",841,1189],["a1",594,841],["a2",420,594],["a3",297,420],["a4",210,297],["a5",148,210],["a6",105,148],["a7",74,105],["a8",52,74],["a9",37,52],["a10",26,37],["2a0",1189,1682],["4a0",1682,2378],["b0",1e3,1414],["b1",707,1e3],["b1+",720,1020],["b2",500,707],["b2+",520,720],["b3",353,500],["b4",250,353],["b5",176,250],["b6",125,176],["b7",88,125],["b8",62,88],["b9",44,62],["b10",31,44],["b11",22,32],["b12",16,22],["c0",917,1297],["c1",648,917],["c2",458,648],["c3",324,458],["c4",229,324],["c5",162,229],["c6",114,162],["c7",81,114],["c8",57,81],["c9",40,57],["c10",28,40],["c11",22,32],["c12",16,22],["half-letter",5.5,8.5,"in"],["letter",8.5,11,"in"],["legal",8.5,14,"in"],["junior-legal",5,8,"in"],["ledger",11,17,"in"],["tabloid",11,17,"in"],["ansi-a",8.5,11,"in"],["ansi-b",11,17,"in"],["ansi-c",17,22,"in"],["ansi-d",22,34,"in"],["ansi-e",34,44,"in"],["arch-a",9,12,"in"],["arch-b",12,18,"in"],["arch-c",18,24,"in"],["arch-d",24,36,"in"],["arch-e",36,48,"in"],["arch-e1",30,42,"in"],["arch-e2",26,38,"in"],["arch-e3",27,39,"in"]].reduce(function(e,t){var n={units:t[3]||"mm",dimensions:[t[1],t[2]]};return e[t[0]]=n,e[t[0].replace(/-/g," ")]=n,e},{});function F(t,n,r,i){return void 0===n&&(n="px"),void 0===r&&(r="px"),void 0===i&&(i=72),e(t,n,r,{pixelsPerInch:i,precision:4,roundPixel:!0})}function P(e,t){var n,r,i,a,o,s,f=d(),u=t.dimensions,c=function(e){return!(!e.dimensions||"string"!=typeof e.dimensions&&!(Array.isArray(e.dimensions)&&e.dimensions.length>=2))}(t),l=e.exporting,m=!!c&&!1!==t.scaleToFit,h=!(!l&&c)||t.scaleToView;f||(m=h=!1);var v,g,y=t.units,b="number"==typeof t.pixelsPerInch&&isFinite(t.pixelsPerInch)?t.pixelsPerInch:72,x=p(t.bleed,0),w=f?window.devicePixelRatio:1,k=h?w:1;"number"==typeof t.pixelRatio&&isFinite(t.pixelRatio)?g=p(t.exportPixelRatio,v=t.pixelRatio):c?(v=k,g=p(t.exportPixelRatio,1)):g=p(t.exportPixelRatio,v=w),"number"==typeof t.maxPixelRatio&&isFinite(t.maxPixelRatio)&&(v=Math.min(t.maxPixelRatio,v)),l&&(v=g);var _,A,S=function(e,t){if(!d())return[300,150];var n=t.parent||window;if(n===window||n===document||n===document.body)return[window.innerWidth,window.innerHeight];var r=n.getBoundingClientRect();return[r.width,r.height]}(0,t),E=S[0],T=S[1];if(c){var O=function(e,t,n){if(void 0===t&&(t="px"),void 0===n&&(n=72),"string"==typeof e){var r=e.toLowerCase();if(!(r in M))throw new Error('The dimension preset "'+e+'" is not supported or could not be found; try using a4, a3, postcard, letter, etc.');var i=M[r];return i.dimensions.map(function(e){return F(e,i.units,t,n)})}return e}(u,y,b),j=Math.max(O[0],O[1]),C=Math.min(O[0],O[1]);if(t.orientation){var D="landscape"===t.orientation;n=D?j:C,r=D?C:j}else n=O[0],r=O[1];_=n,A=r,n+=2*x,r+=2*x}else _=n=E,A=r=T;var z=n,P=r;if(c&&y&&(z=F(n,y,"px",b),P=F(r,y,"px",b)),i=Math.round(z),a=Math.round(P),m&&!l&&c){var R=n/r,L=E/T,B=p(t.scaleToFitPadding,40),I=Math.round(E-2*B),V=Math.round(T-2*B);(i>I||a>V)&&(L>R?(a=V,i=Math.round(a*R)):(i=I,a=Math.round(i/R)))}return{bleed:x,pixelRatio:v,width:n,height:r,dimensions:[n,r],units:y||"px",scaleX:(o=h?Math.round(v*i):Math.round(v*z))/n,scaleY:(s=h?Math.round(v*a):Math.round(v*P))/r,viewportWidth:h?Math.round(i):Math.round(z),viewportHeight:h?Math.round(a):Math.round(P),canvasWidth:o,canvasHeight:s,trimWidth:_,trimHeight:A,styleWidth:i,styleHeight:a}}var R=function(e,t){if("string"!=typeof e)throw new TypeError("must specify type string");if(t=t||{},"undefined"==typeof document&&!t.canvas)return null;var n=t.canvas||document.createElement("canvas");"number"==typeof t.width&&(n.width=t.width);"number"==typeof t.height&&(n.height=t.height);var r,i=t;try{var a=[e];0===e.indexOf("webgl")&&a.push("experimental-"+e);for(var o=0;o<a.length;o++)if(r=n.getContext(a[o],i))return r}catch(e){r=null}return r||null};function L(e){var t,n;void 0===e&&(e={});var r=!1;if(!1!==e.canvas){if(!(t=e.context)||"string"==typeof t){var i=e.canvas;i||(i=function(){if(!d())throw new Error("It appears you are runing from Node.js or a non-browser environment. Try passing in an existing { canvas } interface instead.");return document.createElement("canvas")}(),r=!0);var o=t||"2d";if("function"!=typeof i.getContext)throw new Error("The specified { canvas } element does not have a getContext() function, maybe it is not a <canvas> tag?");if(!(t=R(o,a({},e.attributes,{canvas:i}))))throw new Error("Failed at canvas.getContext('"+o+"') - the browser may not support this context, or a different context may already be in use with this canvas.")}if(n=t.canvas,e.canvas&&n!==e.canvas)throw new Error("The { canvas } and { context } settings must point to the same underlying canvas element");e.pixelated&&(t.imageSmoothingEnabled=!1,t.mozImageSmoothingEnabled=!1,t.oImageSmoothingEnabled=!1,t.webkitImageSmoothingEnabled=!1,t.msImageSmoothingEnabled=!1,n.style["image-rendering"]="pixelated")}return{canvas:n,context:t,ownsCanvas:r}}var B=function(){var e=this;this._settings={},this._props={},this._sketch=void 0,this._raf=null,this._lastRedrawResult=void 0,this._isP5Resizing=!1,this._keyboardShortcuts=function(e){void 0===e&&(e={});var t=function(t){if(e.enabled()){var n=l();83!==t.keyCode||t.altKey||!t.metaKey&&!t.ctrlKey?32===t.keyCode?e.togglePlay(t):n&&!t.altKey&&75===t.keyCode&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e.commit(t)):(t.preventDefault(),e.save(t))}};return{attach:function(){window.addEventListener("keydown",t)},detach:function(){window.removeEventListener("keydown",t)}}}({enabled:function(){return!1!==e.settings.hotkeys},save:function(t){t.shiftKey?e.props.recording?(e.endRecord(),e.run()):e.record():e.props.recording||e.exportFrame()},togglePlay:function(){e.props.playing?e.pause():e.play()},commit:function(t){e.exportFrame({commit:!0})}}),this._animateHandler=function(){return e.animate()},this._resizeHandler=function(){e.resize()&&e.render()}},I={sketch:{configurable:!0},settings:{configurable:!0},props:{configurable:!0}};I.sketch.get=function(){return this._sketch},I.settings.get=function(){return this._settings},I.props.get=function(){return this._props},B.prototype._computePlayhead=function(e,t){return"number"==typeof t&&isFinite(t)?e/t:0},B.prototype._computeFrame=function(e,t,n,r){return isFinite(n)&&n>1?Math.floor(e*(n-1)):Math.floor(r*t)},B.prototype._computeCurrentFrame=function(){return this._computeFrame(this.props.playhead,this.props.time,this.props.totalFrames,this.props.fps)},B.prototype._getSizeProps=function(){var e=this.props;return{width:e.width,height:e.height,pixelRatio:e.pixelRatio,canvasWidth:e.canvasWidth,canvasHeight:e.canvasHeight,viewportWidth:e.viewportWidth,viewportHeight:e.viewportHeight}},B.prototype.run=function(){if(!this.sketch)throw new Error("should wait until sketch is loaded before trying to play()");return!1!==this.settings.playing&&this.play(),"function"==typeof this.sketch.dispose&&console.warn("In canvas-sketch@0.0.23 the dispose() event has been renamed to unload()"),this.props.started||(this._signalBegin(),this.props.started=!0),this.tick(),this.render(),this},B.prototype.play=function(){var e=this.settings.animate;"animation"in this.settings&&(e=!0,console.warn("[canvas-sketch] { animation } has been renamed to { animate }")),e&&(d()?this.props.playing||(this.props.started||(this._signalBegin(),this.props.started=!0),this.props.playing=!0,null!=this._raf&&window.cancelAnimationFrame(this._raf),this._lastTime=f(),this._raf=window.requestAnimationFrame(this._animateHandler)):console.error("[canvas-sketch] WARN: Using { animate } in Node.js is not yet supported"))},B.prototype.pause=function(){this.props.recording&&this.endRecord(),this.props.playing=!1,null!=this._raf&&d()&&window.cancelAnimationFrame(this._raf)},B.prototype.togglePlay=function(){this.props.playing?this.pause():this.play()},B.prototype.stop=function(){this.pause(),this.props.frame=0,this.props.playhead=0,this.props.time=0,this.props.deltaTime=0,this.props.started=!1,this.render()},B.prototype.record=function(){var e=this;if(!this.props.recording)if(d()){this.stop(),this.props.playing=!0,this.props.recording=!0;var t=this._createExportOptions({sequence:!0}),n=1/this.props.fps;null!=this._raf&&window.cancelAnimationFrame(this._raf);var r,i=function(){return e.props.recording?(e.props.deltaTime=n,e.tick(),e.exportFrame(t).then(function(){e.props.recording&&(e.props.deltaTime=0,e.props.frame++,e.props.frame<e.props.totalFrames?(e.props.time+=n,e.props.playhead=e._computePlayhead(e.props.time,e.props.duration),e._raf=window.requestAnimationFrame(i)):(console.log("Finished recording"),e._signalEnd(),e.endRecord(),e.stop(),e.run()))})):Promise.resolve()};this.props.started||(this._signalBegin(),this.props.started=!0),(r=t,void 0===r&&(r={}),E(!0,r)).catch(function(e){console.error(e)}).then(function(t){e._raf=window.requestAnimationFrame(i)})}else console.error("[canvas-sketch] WARN: Recording from Node.js is not yet supported")},B.prototype._signalBegin=function(){var e=this;this.sketch&&"function"==typeof this.sketch.begin&&this._wrapContextScale(function(t){return e.sketch.begin(t)})},B.prototype._signalEnd=function(){var e=this;this.sketch&&"function"==typeof this.sketch.end&&this._wrapContextScale(function(t){return e.sketch.end(t)})},B.prototype.endRecord=function(){var e;null!=this._raf&&d()&&window.cancelAnimationFrame(this._raf),this.props.recording=!1,this.props.deltaTime=0,this.props.playing=!1,(void 0===e&&(e={}),E(!1,e)).catch(function(e){console.error(e)})},B.prototype._createExportOptions=function(e){return void 0===e&&(e={}),{sequence:e.sequence,save:e.save,fps:this.props.fps,frame:e.sequence?this.props.frame:void 0,file:this.settings.file,name:this.settings.name,prefix:this.settings.prefix,suffix:this.settings.suffix,encoding:this.settings.encoding,encodingQuality:this.settings.encodingQuality,timeStamp:e.timeStamp||y(new Date,"yyyy.mm.dd-HH.MM.ss"),totalFrames:isFinite(this.props.totalFrames)?Math.max(100,this.props.totalFrames):1e3}},B.prototype.exportFrame=function(e){var t=this;if(void 0===e&&(e={}),!this.sketch)return Promise.all([]);"function"==typeof this.sketch.preExport&&this.sketch.preExport();var n=this._createExportOptions(e),r=l(),i=Promise.resolve();if(r&&e.commit&&"function"==typeof r.commit){var o=a({},n),s=r.commit(o);i=u(s)?s:Promise.resolve(s)}return i.then(function(e){return t._doExportFrame(a({},n,{hash:e||""}))}).then(function(e){return 1===e.length?e[0]:e})},B.prototype._doExportFrame=function(e){var t=this;void 0===e&&(e={}),this._props.exporting=!0,this.resize();var n=this.render();return void 0===n&&(n=[this.props.canvas]),n=(n=[].concat(n).filter(Boolean)).map(function(t){var n,r="object"==typeof t&&t&&("data"in t||"dataURL"in t),i=r?t.data:t,o=r?a({},t,{data:i}):{data:i};if(c(n=i)&&/canvas/i.test(n.nodeName)&&"function"==typeof n.getContext){var s=function(e,t){void 0===t&&(t={});var n=t.encoding||"image/png";if(!S.includes(n))throw new Error("Invalid canvas encoding "+n);var r=(n.split("/")[1]||"").replace(/jpeg/i,"jpg");return r&&(r=("."+r).toLowerCase()),{extension:r,type:n,dataURL:e.toDataURL(n,t.encodingQuality)}}(i,{encoding:o.encoding||e.encoding,encodingQuality:p(o.encodingQuality,e.encodingQuality,.95)});return Object.assign(o,{dataURL:s.dataURL,extension:s.extension,type:s.type})}return o}),this._props.exporting=!1,this.resize(),this.render(),Promise.all(n.map(function(t,n,r){var i=a({extension:"",prefix:"",suffix:""},e,t,{layer:n,totalLayers:r.length}),o=!1!==e.save&&t.save;for(var s in i.save=!1!==o,i.filename=j(i),delete i.encoding,delete i.encodingQuality,i)void 0===i[s]&&delete i[s];var f=Promise.resolve({});if(i.save){var u=i.data;if(i.dataURL)f=T(i.dataURL,i);else f=function(e,t){void 0===t&&(t={});var n=Array.isArray(e)?e:[e];return O(new window.Blob(n,{type:t.type||""}),t)}(u,i)}return f.then(function(e){return Object.assign({},i,e)})})).then(function(n){var r=n.filter(function(e){return e.save});if(r.length>0){var i,a=r.find(function(e){return e.outputName}),o=r.some(function(e){return e.client}),s=r.some(function(e){return e.stream});i=r.length>1?r.length:a?a.outputName+"/"+r[0].filename:""+r[0].filename;var f="";if(e.sequence)f=isFinite(t.props.totalFrames)?" (frame "+(e.frame+1)+" / "+t.props.totalFrames+")":" (frame "+e.frame+")";else r.length>1&&(f=" files");console.log("%c["+(o?"canvas-sketch-cli":"canvas-sketch")+"]%c "+(s?"Streaming into":"Exported")+" %c"+i+"%c"+f,"color: #8e8e8e;","color: initial;","font-weight: bold;","font-weight: initial;")}return"function"==typeof t.sketch.postExport&&t.sketch.postExport(),n})},B.prototype._wrapContextScale=function(e){this._preRender(),e(this.props),this._postRender()},B.prototype._preRender=function(){var e=this.props;this.props.gl||!e.context||e.p5?e.p5&&e.p5.scale(e.scaleX/e.pixelRatio,e.scaleY/e.pixelRatio):(e.context.save(),!1!==this.settings.scaleContext&&e.context.scale(e.scaleX,e.scaleY))},B.prototype._postRender=function(){var e=this.props;this.props.gl||!e.context||e.p5||e.context.restore(),e.gl&&!1!==this.settings.flush&&!e.p5&&e.gl.flush()},B.prototype.tick=function(){this.sketch&&"function"==typeof this.sketch.tick&&(this._preRender(),this.sketch.tick(this.props),this._postRender())},B.prototype.render=function(){return this.props.p5?(this._lastRedrawResult=void 0,this.props.p5.redraw(),this._lastRedrawResult):this.submitDrawCall()},B.prototype.submitDrawCall=function(){if(this.sketch){var e,t=this.props;return this._preRender(),"function"==typeof this.sketch?e=this.sketch(t):"function"==typeof this.sketch.render&&(e=this.sketch.render(t)),this._postRender(),e}},B.prototype.update=function(e){var t=this;void 0===e&&(e={});var n=["animate"];Object.keys(e).forEach(function(e){if(n.indexOf(e)>=0)throw new Error("Sorry, the { "+e+" } option is not yet supported with update().")});var r=this._settings.canvas,i=this._settings.context;for(var a in e){var o=e[a];void 0!==o&&(t._settings[a]=o)}var s=Object.assign({},this._settings,e);if("time"in e&&"frame"in e)throw new Error("You should specify { time } or { frame } but not both");if("time"in e?delete s.frame:"frame"in e&&delete s.time,"duration"in e&&"totalFrames"in e)throw new Error("You should specify { duration } or { totalFrames } but not both");"duration"in e?delete s.totalFrames:"totalFrames"in e&&delete s.duration,"data"in e&&(this._props.data=e.data);var f=this.getTimeProps(s);if(Object.assign(this._props,f),r!==this._settings.canvas||i!==this._settings.context){var u=L(this._settings),c=u.context;this.props.canvas=u.canvas,this.props.context=c,this._setupGLKey(),this._appendCanvasIfNeeded()}return e.p5&&"function"!=typeof e.p5&&(this.props.p5=e.p5,this.props.p5.draw=function(){t._isP5Resizing||(t._lastRedrawResult=t.submitDrawCall())}),"playing"in e&&(e.playing?this.play():this.pause()),z(this._settings),this.resize(),this.render(),this.props},B.prototype.resize=function(){var e=this._getSizeProps(),t=this.settings,n=this.props,r=P(n,t);Object.assign(this._props,r);var i=this.props,a=i.pixelRatio,o=i.canvasWidth,s=i.canvasHeight,f=i.styleWidth,u=i.styleHeight,c=this.props.canvas;c&&!1!==t.resizeCanvas&&(n.p5?c.width===o&&c.height===s||(this._isP5Resizing=!0,n.p5.pixelDensity(a),n.p5.resizeCanvas(o/a,s/a,!1),this._isP5Resizing=!1):(c.width!==o&&(c.width=o),c.height!==s&&(c.height=s)),d()&&!1!==t.styleCanvas&&(c.style.width=f+"px",c.style.height=u+"px"));var l=this._getSizeProps(),p=!g(e,l);return p&&this._sizeChanged(),p},B.prototype._sizeChanged=function(){this.sketch&&"function"==typeof this.sketch.resize&&this.sketch.resize(this.props)},B.prototype.animate=function(){if(this.props.playing)if(d()){this._raf=window.requestAnimationFrame(this._animateHandler);var e=f(),t=1e3/this.props.fps,n=e-this._lastTime,r=this.props.duration,i="number"==typeof r&&isFinite(r),a=!0,o=this.settings.playbackRate;"fixed"===o?n=t:"throttle"===o?n>t?this._lastTime=e-=n%t:a=!1:this._lastTime=e;var s=n/1e3,u=this.props.time+s*this.props.timeScale;u<0&&i&&(u=r+u);var c=!1,l=!1;if(i&&u>=r&&(!1!==this.settings.loop?(a=!0,u%=r,l=!0):(a=!1,u=r,c=!0),this._signalEnd()),a){this.props.deltaTime=s,this.props.time=u,this.props.playhead=this._computePlayhead(u,r);var p=this.props.frame;this.props.frame=this._computeCurrentFrame(),l&&this._signalBegin(),p!==this.props.frame&&this.tick(),this.render(),this.props.deltaTime=0}c&&this.pause()}else console.error("[canvas-sketch] WARN: Animation in Node.js is not yet supported")},B.prototype.dispatch=function(e){if("function"!=typeof e)throw new Error("must pass function into dispatch()");e(this.props),this.render()},B.prototype.mount=function(){this._appendCanvasIfNeeded()},B.prototype.unmount=function(){d()&&(window.removeEventListener("resize",this._resizeHandler),this._keyboardShortcuts.detach()),this.props.canvas.parentElement&&this.props.canvas.parentElement.removeChild(this.props.canvas)},B.prototype._appendCanvasIfNeeded=function(){d()&&(!1!==this.settings.parent&&this.props.canvas&&!this.props.canvas.parentElement&&(this.settings.parent||document.body).appendChild(this.props.canvas))},B.prototype._setupGLKey=function(){var e;this.props.context&&("function"==typeof(e=this.props.context).clear&&"function"==typeof e.clearColor&&"function"==typeof e.bufferData?this._props.gl=this.props.context:delete this._props.gl)},B.prototype.getTimeProps=function(e){void 0===e&&(e={});var t=e.duration,n=e.totalFrames,r=p(e.timeScale,1),i=p(e.fps,24),a="number"==typeof t&&isFinite(t),o="number"==typeof n&&isFinite(n),s=a?Math.floor(i*t):void 0,f=o?n/i:void 0;if(a&&o&&s!==n)throw new Error("You should specify either duration or totalFrames, but not both. Or, they must match exactly.");void 0===e.dimensions&&void 0!==e.units&&console.warn("You've specified a { units } setting but no { dimension }, so the units will be ignored."),n=p(n,s,Infinity),t=p(t,f,Infinity);var u=e.time,c=e.frame,l="number"==typeof u&&isFinite(u),d="number"==typeof c&&isFinite(c),m=0,h=0,v=0;if(l&&d)throw new Error("You should specify either start frame or time, but not both.");return l?(v=this._computePlayhead(m=u,t),h=this._computeFrame(v,m,n,i)):d&&(v=this._computePlayhead(m=(h=c)/i,t)),{playhead:v,time:m,frame:h,duration:t,totalFrames:n,fps:i,timeScale:r}},B.prototype.setup=function(e){var t=this;if(void 0===e&&(e={}),this.sketch)throw new Error("Multiple setup() calls not yet supported.");this._settings=Object.assign({},e,this._settings),z(this._settings);var n=L(this._settings),r=n.context,i=n.canvas,a=this.getTimeProps(this._settings);this._props=Object.assign({},a,{canvas:i,context:r,deltaTime:0,started:!1,exporting:!1,playing:!1,recording:!1,settings:this.settings,data:this.settings.data,render:function(){return t.render()},togglePlay:function(){return t.togglePlay()},dispatch:function(e){return t.dispatch(e)},tick:function(){return t.tick()},resize:function(){return t.resize()},update:function(e){return t.update(e)},exportFrame:function(e){return t.exportFrame(e)},record:function(){return t.record()},play:function(){return t.play()},pause:function(){return t.pause()},stop:function(){return t.stop()}}),this._setupGLKey(),this.resize()},B.prototype.loadAndRun=function(e,t){var n=this;return this.load(e,t).then(function(){return n.run(),n})},B.prototype.unload=function(){var e=this;this.pause(),this.sketch&&("function"==typeof this.sketch.unload&&this._wrapContextScale(function(t){return e.sketch.unload(t)}),this._sketch=null)},B.prototype.destroy=function(){this.unload(),this.unmount()},B.prototype.load=function(e,t){var n=this;if("function"!=typeof e)throw new Error("The function must take in a function as the first parameter. Example:\n canvasSketcher(() => { ... }, settings)");this.sketch&&this.unload(),void 0!==t&&this.update(t),this._preRender();var r=Promise.resolve();if(this.settings.p5){if(!d())throw new Error("[canvas-sketch] ERROR: Using p5.js in Node.js is not supported");r=new Promise(function(e){var t,r=n.settings.p5;r.p5&&(t=r.preload,r=r.p5);var i=function(r){t&&(r.preload=function(){return t(r)}),r.setup=function(){var t=n.props,i="webgl"===n.settings.context,a=i?r.WEBGL:r.P2D;r.noLoop(),r.pixelDensity(t.pixelRatio),r.createCanvas(t.viewportWidth,t.viewportHeight,a),i&&n.settings.attributes&&r.setAttributes(n.settings.attributes),n.update({p5:r,canvas:r.canvas,context:r._renderer.drawingContext}),e()}};if("function"==typeof r)new r(i);else{if("function"!=typeof window.createCanvas)throw new Error("{ p5 } setting is passed but can't find p5.js in global (window) scope. Maybe you did not create it globally?\nnew p5(); // <-- attaches to global scope");i(window)}})}return r.then(function(){var t=e(n.props);return u(t)||(t=Promise.resolve(t)),t}).then(function(e){return e||(e={}),n._sketch=e,d()&&(n._keyboardShortcuts.attach(),window.addEventListener("resize",n._resizeHandler)),n._postRender(),n._sizeChanged(),n}).catch(function(e){throw console.warn("Could not start sketch, the async loading function rejected with an error:\n Error: "+e.message),e})},Object.defineProperties(B.prototype,I);var V="hot-id-cache",N=[];function H(e,t){if(void 0===t&&(t={}),t.p5){if(t.canvas||t.context&&"string"!=typeof t.context)throw new Error('In { p5 } mode, you can\'t pass your own canvas or context, unless the context is a "webgl" or "2d" string');t=Object.assign({},t,{canvas:!1,context:"string"==typeof t.context&&t.context})}var n,r,i=(n=l())&&n.hot;i&&(r=p(t.id,"$__DEFAULT_CANVAS_SKETCH_ID__$"));var a=i&&"string"==typeof r;a&&N.includes(r)&&(console.warn("Warning: You have multiple calls to canvasSketch() in --hot mode. You must pass unique { id } strings in settings to enable hot reload across multiple sketches. ",r),a=!1);var o=Promise.resolve();if(a){N.push(r);var s=function(e){var t=l();if(t)return t[V]=t[V]||{},t[V][e]}(r);if(s){var f=function(){var e,n=(e=s.manager,t.animate?{time:e.props.time}:void 0);return s.manager.destroy(),n};o=s.load.then(f).catch(f)}}return o.then(function(n){var i,o,s,f,u=new B;return e?(t=Object.assign({},t,n),u.setup(t),u.mount(),i=u.loadAndRun(e)):i=Promise.resolve(u),a&&(o=r,s={load:i,manager:u},(f=l())&&(f[V]=f[V]||{},f[V][o]=s)),i})}return H.canvasSketch=H,H.PaperSizes=M,H})}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"convert-length":7}],5:[function(e,t,n){function i(e){var t,n,r=e[0]/255,i=e[1]/255,a=e[2]/255,o=Math.min(r,i,a),s=Math.max(r,i,a),f=s-o;return s==o?t=0:r==s?t=(i-a)/f:i==s?t=2+(a-r)/f:a==s&&(t=4+(r-i)/f),(t=Math.min(60*t,360))<0&&(t+=360),n=(o+s)/2,[t,100*(s==o?0:n<=.5?f/(s+o):f/(2-s-o)),100*n]}function a(e){var t,n,r=e[0],i=e[1],a=e[2],o=Math.min(r,i,a),s=Math.max(r,i,a),f=s-o;return n=0==s?0:f/s*1e3/10,s==o?t=0:r==s?t=(i-a)/f:i==s?t=2+(a-r)/f:a==s&&(t=4+(r-i)/f),(t=Math.min(60*t,360))<0&&(t+=360),[t,n,s/255*1e3/10]}function o(e){var t=e[0],n=e[1],r=e[2];return[i(e)[0],100*(1/255*Math.min(t,Math.min(n,r))),100*(r=1-1/255*Math.max(t,Math.max(n,r)))]}function s(e){var t,n=e[0]/255,r=e[1]/255,i=e[2]/255;return[100*((1-n-(t=Math.min(1-n,1-r,1-i)))/(1-t)||0),100*((1-r-t)/(1-t)||0),100*((1-i-t)/(1-t)||0),100*t]}function f(e){return S[JSON.stringify(e)]}function u(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255;return[100*(.4124*(t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*t+.7152*n+.0722*r),100*(.0193*t+.1192*n+.9505*r)]}function c(e){var t=u(e),n=t[0],r=t[1],i=t[2];return r/=100,i/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]}function l(e){var t,n,r,i,a,o=e[0]/360,s=e[1]/100,f=e[2]/100;if(0==s)return[a=255*f,a,a];t=2*f-(n=f<.5?f*(1+s):f+s-f*s),i=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,i[u]=255*(a=6*r<1?t+6*(n-t)*r:2*r<1?n:3*r<2?t+(n-t)*(2/3-r)*6:t);return i}function p(e){var t=e[0]/60,n=e[1]/100,r=e[2]/100,i=Math.floor(t)%6,a=t-Math.floor(t),o=255*r*(1-n),s=255*r*(1-n*a),f=255*r*(1-n*(1-a));r*=255;switch(i){case 0:return[r,f,o];case 1:return[s,r,o];case 2:return[o,r,f];case 3:return[o,s,r];case 4:return[f,o,r];case 5:return[r,o,s]}}function d(e){var t,n,i,a,o=e[0]/360,s=e[1]/100,f=e[2]/100,u=s+f;switch(u>1&&(s/=u,f/=u),i=6*o-(t=Math.floor(6*o)),0!=(1&t)&&(i=1-i),a=s+i*((n=1-f)-s),t){default:case 6:case 0:r=n,g=a,b=s;break;case 1:r=a,g=n,b=s;break;case 2:r=s,g=n,b=a;break;case 3:r=s,g=a,b=n;break;case 4:r=a,g=s,b=n;break;case 5:r=n,g=s,b=a}return[255*r,255*g,255*b]}function m(e){var t=e[1]/100,n=e[2]/100,r=e[3]/100;return[255*(1-Math.min(1,e[0]/100*(1-r)+r)),255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r))]}function h(e){var t,n,r,i=e[0]/100,a=e[1]/100,o=e[2]/100;return n=-.9689*i+1.8758*a+.0415*o,r=.0557*i+-.204*a+1.057*o,t=(t=3.2406*i+-1.5372*a+-.4986*o)>.0031308?1.055*Math.pow(t,1/2.4)-.055:t*=12.92,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n*=12.92,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r*=12.92,[255*(t=Math.min(Math.max(0,t),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]}function v(e){var t=e[0],n=e[1],r=e[2];return n/=100,r/=108.883,t=(t/=95.047)>.008856?Math.pow(t,1/3):7.787*t+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(t-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]}function y(e){var t,n,r,i,a=e[0],o=e[1],s=e[2];return a<=8?i=(n=100*a/903.3)/100*7.787+16/116:(n=100*Math.pow((a+16)/116,3),i=Math.pow(n/100,1/3)),[t=t/95.047<=.008856?t=95.047*(o/500+i-16/116)/7.787:95.047*Math.pow(o/500+i,3),n,r=r/108.883<=.008859?r=108.883*(i-s/200-16/116)/7.787:108.883*Math.pow(i-s/200,3)]}function x(e){var t,n=e[0],r=e[1],i=e[2];return(t=360*Math.atan2(i,r)/2/Math.PI)<0&&(t+=360),[n,Math.sqrt(r*r+i*i),t]}function w(e){return h(y(e))}function k(e){var t,n=e[1];return t=e[2]/360*2*Math.PI,[e[0],n*Math.cos(t),n*Math.sin(t)]}function _(e){return A[e]}t.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:o,rgb2cmyk:s,rgb2keyword:f,rgb2xyz:u,rgb2lab:c,rgb2lch:function(e){return x(c(e))},hsl2rgb:l,hsl2hsv:function(e){var t=e[0],n=e[1]/100,r=e[2]/100;if(0===r)return[0,0,0];return[t,100*(2*(n*=(r*=2)<=1?r:2-r)/(r+n)),100*((r+n)/2)]},hsl2hwb:function(e){return o(l(e))},hsl2cmyk:function(e){return s(l(e))},hsl2keyword:function(e){return f(l(e))},hsv2rgb:p,hsv2hsl:function(e){var t,n,r=e[1]/100,i=e[2]/100;return t=r*i,[e[0],100*(t=(t/=(n=(2-r)*i)<=1?n:2-n)||0),100*(n/=2)]},hsv2hwb:function(e){return o(p(e))},hsv2cmyk:function(e){return s(p(e))},hsv2keyword:function(e){return f(p(e))},hwb2rgb:d,hwb2hsl:function(e){return i(d(e))},hwb2hsv:function(e){return a(d(e))},hwb2cmyk:function(e){return s(d(e))},hwb2keyword:function(e){return f(d(e))},cmyk2rgb:m,cmyk2hsl:function(e){return i(m(e))},cmyk2hsv:function(e){return a(m(e))},cmyk2hwb:function(e){return o(m(e))},cmyk2keyword:function(e){return f(m(e))},keyword2rgb:_,keyword2hsl:function(e){return i(_(e))},keyword2hsv:function(e){return a(_(e))},keyword2hwb:function(e){return o(_(e))},keyword2cmyk:function(e){return s(_(e))},keyword2lab:function(e){return c(_(e))},keyword2xyz:function(e){return u(_(e))},xyz2rgb:h,xyz2lab:v,xyz2lch:function(e){return x(v(e))},lab2xyz:y,lab2rgb:w,lab2lch:x,lch2lab:k,lch2xyz:function(e){return y(k(e))},lch2rgb:function(e){return w(k(e))}};var A={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},S={};for(var E in A)S[JSON.stringify(A[E])]=E},{}],6:[function(e,t,n){var r=e("./conversions"),i=function(){return new u};for(var a in r){i[a+"Raw"]=function(e){return function(t){return"number"==typeof t&&(t=Array.prototype.slice.call(arguments)),r[e](t)}}(a);var o=/(\w+)2(\w+)/.exec(a),s=o[1],f=o[2];(i[s]=i[s]||{})[f]=i[a]=function(e){return function(t){"number"==typeof t&&(t=Array.prototype.slice.call(arguments));var n=r[e](t);if("string"==typeof n||void 0===n)return n;for(var i=0;i<n.length;i++)n[i]=Math.round(n[i]);return n}}(a)}var u=function(){this.convs={}};u.prototype.routeSpace=function(e,t){var n=t[0];return void 0===n?this.getValues(e):("number"==typeof n&&(n=Array.prototype.slice.call(t)),this.setValues(e,n))},u.prototype.setValues=function(e,t){return this.space=e,this.convs={},this.convs[e]=t,this},u.prototype.getValues=function(e){var t=this.convs[e];if(!t){var n=this.space;t=i[n][e](this.convs[n]),this.convs[e]=t}return t},["rgb","hsl","hsv","cmyk","keyword"].forEach(function(e){u.prototype[e]=function(t){return this.routeSpace(e,arguments)}}),t.exports=i},{"./conversions":5}],7:[function(e,t,n){var r=e("defined"),i=["mm","cm","m","pc","pt","in","ft","px"],a={m:{system:"metric",factor:1},cm:{system:"metric",factor:.01},mm:{system:"metric",factor:.001},pt:{system:"imperial",factor:1/72},pc:{system:"imperial",factor:1/6},in:{system:"imperial",factor:1},ft:{system:"imperial",factor:12}};const o={metric:{unit:"m",ratio:1/.0254},imperial:{unit:"in",ratio:.0254}};t.exports=function(e,t,n,s){if("number"!=typeof e||!isFinite(e))throw new Error("Value must be a finite number");if(!t||!n)throw new Error("Must specify from and to units");var f=r((s=s||{}).pixelsPerInch,96),u=s.precision,c=!1!==s.roundPixel;if(t=t.toLowerCase(),n=n.toLowerCase(),-1===i.indexOf(t))throw new Error('Invalid from unit "'+t+'", must be one of: '+i.join(", "));if(-1===i.indexOf(n))throw new Error('Invalid from unit "'+n+'", must be one of: '+i.join(", "));if(t===n)return e;var l=1,p=1,d=!1;"px"===t&&(p=1/f,t="in"),"px"===n&&(d=!0,l=f,n="in");var m=a[t],h=a[n],v=e*m.factor*p;m.system!==h.system&&(v*=o[m.system].ratio);var g=v/h.factor*l;return d&&c?g=Math.round(g):"number"==typeof u&&isFinite(u)&&(g=function(e,t){return Number(Math.round(e+"e"+t)+"e-"+t)}(g,u)),g},t.exports.units=i},{defined:8}],8:[function(e,t,n){t.exports=function(){for(var e=0;e<arguments.length;e++)if(void 0!==arguments[e])return arguments[e]}},{}],9:[function(e,t,n){var r=e("color-convert");t.exports=function(e){var t,n,i,a;if(t=/^((?:rgb|hs[lv]|cmyk|xyz|lab)a?)\s*\(([^\)]*)\)/.exec(e)){var o=t[1],s="cmyk"===(f=o.replace(/a$/,""))?4:3;n=r[f],i=t[2].replace(/^\s+|\s+$/g,"").split(/\s*,\s*/).map(function(e,t){return/%$/.test(e)&&t===s?parseFloat(e)/100:(/%$/.test(e),parseFloat(e))}),o===f&&i.push(1),a=void 0===i[s]?1:i[s],i=i.slice(0,s),n[f]=function(){return i}}else if(/^#[A-Fa-f0-9]+$/.test(e)){var f=e.replace(/^#/,"");n=r.rgb,i=(i=f.split(3===(s=f.length)?/(.)/:/(..)/)).filter(Boolean).map(function(e){return 3===s?parseInt(e+e,16):parseInt(e,16)}),a=1,n.rgb=function(){return i},i[0]||(i[0]=0),i[1]||(i[1]=0),i[2]||(i[2]=0)}else(n=r.keyword).keyword=function(){return e},i=e,a=1;var u={rgb:void 0,hsl:void 0,hsv:void 0,cmyk:void 0,keyword:void 0,hex:void 0};try{u.rgb=n.rgb(i)}catch(e){}try{u.hsl=n.hsl(i)}catch(e){}try{u.hsv=n.hsv(i)}catch(e){}try{u.cmyk=n.cmyk(i)}catch(e){}try{u.keyword=n.keyword(i)}catch(e){}return u.rgb&&(u.hex="#"+u.rgb.map(function(e){var t=e.toString(16);return 1===t.length?"0"+t:t}).join("")),u.rgb&&(u.rgba=u.rgb.concat(a)),u.hsl&&(u.hsla=u.hsl.concat(a)),u.hsv&&(u.hsva=u.hsv.concat(a)),u.cmyk&&(u.cmyka=u.cmyk.concat(a)),u}},{"color-convert":6}],10:[function(e,t,n){t.exports=function(e){e=void 0!==e?e:1,Array.isArray(e)||(e=[e,e]);var t=[[-e[0],-e[1],0],[e[0],-e[1],0],[e[0],e[1],0],[-e[0],e[1],0]],n=[0,0,-1],r=[n.slice(),n.slice(),n.slice(),n.slice()];return{positions:t,cells:[[0,1,2],[2,3,0]],uvs:[[0,0],[1,0],[1,1],[0,1]],normals:r}}},{}],11:[function(e,t,n){var r,i;r=this,i=function(){"use strict";var e=function(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof Uint8ClampedArray},t=function(e,t){for(var n=Object.keys(t),r=0;r<n.length;++r)e[n[r]]=t[n[r]];return e},n="\n";function r(e){var t=new Error("(regl) "+e);throw console.error(t),t}function i(e,t){e||r(t)}function a(e){return e?": "+e:""}function o(e,t){switch(t){case"number":return"number"==typeof e;case"object":return"object"==typeof e;case"string":return"string"==typeof e;case"boolean":return"boolean"==typeof e;case"function":return"function"==typeof e;case"undefined":return void 0===e;case"symbol":return"symbol"==typeof e}}function s(e,t,n){t.indexOf(e)<0&&r("invalid value"+a(n)+". must be one of: "+t)}var f=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function u(e,t){for(e+="";e.length<t;)e=" "+e;return e}function c(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function l(e,t){this.number=e,this.line=t,this.errors=[]}function p(e,t,n){this.file=e,this.line=t,this.message=n}function d(){var e=new Error,t=(e.stack||e).toString(),n=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(t);if(n)return n[1];var r=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(t);return r?r[1]:"unknown"}function m(){var e=new Error,t=(e.stack||e).toString(),n=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(t);if(n)return n[1];var r=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(t);return r?r[1]:"unknown"}function h(e,t){var n,r=e.split("\n"),i=1,a=0,o={unknown:new c,0:new c};o.unknown.name=o[0].name=t||d(),o.unknown.lines.push(new l(0,""));for(var s=0;s<r.length;++s){var f=r[s],u=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(f);if(u)switch(u[1]){case"line":var p=/(\d+)(\s+\d+)?/.exec(u[2]);p&&(i=0|p[1],p[2]&&((a=0|p[2])in o||(o[a]=new c)));break;case"define":var m=/SHADER_NAME(_B64)?\s+(.*)$/.exec(u[2]);m&&(o[a].name=m[1]?(n=m[2],"undefined"!=typeof atob?atob(n):"base64:"+n):m[2])}o[a].lines.push(new l(i++,f))}return Object.keys(o).forEach(function(e){var t=o[e];t.lines.forEach(function(e){t.index[e.number]=e})}),o}function v(e){e._commandRef=d()}function g(e,t){var n=m();r(e+" in command "+(t||d())+("unknown"===n?"":" called from "+n))}function y(e,t,n,r){o(e,t)||g("invalid parameter type"+a(n)+". expected "+t+", got "+typeof e,r||d())}var b=33071,x=9728,w=9984,k=9985,_=9986,A=9987,S=5126,E=32819,T=32820,O=33635,j=34042,C={};function D(e,t){return e===T||e===E||e===O?2:e===j?4:C[e]*t}function z(e){return!(e&e-1||!e)}C[5120]=C[5121]=1,C[5122]=C[5123]=C[36193]=C[O]=C[E]=C[T]=2,C[5124]=C[5125]=C[S]=C[j]=4;var M=t(i,{optional:function(e){e()},raise:r,commandRaise:g,command:function(e,t,n){e||g(t,n||d())},parameter:function(e,t,n){e in t||r("unknown parameter ("+e+")"+a(n)+". possible values: "+Object.keys(t).join())},commandParameter:function(e,t,n,r){e in t||g("unknown parameter ("+e+")"+a(n)+". possible values: "+Object.keys(t).join(),r||d())},constructor:function(e){Object.keys(e).forEach(function(e){f.indexOf(e)<0&&r('invalid regl constructor argument "'+e+'". must be one of '+f)})},type:function(e,t,n){o(e,t)||r("invalid parameter type"+a(n)+". expected "+t+", got "+typeof e)},commandType:y,isTypedArray:function(t,n){e(t)||r("invalid parameter type"+a(n)+". must be a typed array")},nni:function(e,t){e>=0&&(0|e)===e||r("invalid parameter type, ("+e+")"+a(t)+". must be a nonnegative integer")},oneOf:s,shaderError:function(e,t,r,a,o){if(!e.getShaderParameter(t,e.COMPILE_STATUS)){var s=e.getShaderInfoLog(t),f=a===e.FRAGMENT_SHADER?"fragment":"vertex";y(r,"string",f+" shader source must be a string",o);var c=h(r,o),l=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 p(0|n[1],0|n[2],n[3].trim())):e.length>0&&t.push(new p("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,l),Object.keys(c).forEach(function(e){var t=c[e];if(t.hasErrors){var r=[""],i=[""];a("file number "+e+": "+t.name+"\n","color:red;text-decoration:underline;font-weight:bold"),t.lines.forEach(function(e){if(e.errors.length>0){a(u(e.number,4)+"| ","background-color:yellow; font-weight:bold"),a(e.line+n,"color:red; background-color:yellow; font-weight:bold");var t=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="="}t=Math.max(e.line.indexOf(s,t),0)}else t=0;a(u("| ",6)),a(u("^^^",t+3)+n,"font-weight:bold"),a(u("| ",6)),a(i+n,"font-weight:bold")}),a(u("| ",6)+n)}else a(u(e.number,4)+"| "),a(e.line+n,"color:red")}),"undefined"==typeof document||window.chrome?console.log(r.join("")):(i[0]=r.join("%c"),console.log.apply(console,i))}function a(e,t){r.push(e),i.push(t||"")}}),i.raise("Error compiling "+f+" shader, "+c[0].name)}},linkError:function(e,t,r,a,o){if(!e.getProgramParameter(t,e.LINK_STATUS)){var s=e.getProgramInfoLog(t),f=h(r,o),u='Error linking program with vertex shader, "'+h(a,o)[0].name+'", and fragment shader "'+f[0].name+'"';"undefined"!=typeof document?console.log("%c"+u+n+"%c"+s,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(u+n+s),i.raise(u)}},callSite:m,saveCommandRef:v,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})}v(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?s(e.texture._texture.internalformat,t,"unsupported texture format for attachment"):s(e.renderbuffer._renderbuffer.format,n,"unsupported renderbuffer format for attachment")},guessCommand:d,texture2D:function(e,t,n){var r,a=t.width,o=t.height,s=t.channels;i(a>0&&a<=n.maxTextureSize&&o>0&&o<=n.maxTextureSize,"invalid texture shape"),e.wrapS===b&&e.wrapT===b||i(z(a)&&z(o),"incompatible wrap mode for texture, both width and height must be power of 2"),1===t.mipmask?1!==a&&1!==o&&i(e.minFilter!==w&&e.minFilter!==_&&e.minFilter!==k&&e.minFilter!==A,"min filter requires mipmap"):(i(z(a)&&z(o),"texture must be a square power of 2 to support mipmapping"),i(t.mipmask===(a<<1)-1,"missing or incomplete mipmap data")),t.type===S&&(n.extensions.indexOf("oes_texture_float_linear")<0&&i(e.minFilter===x&&e.magFilter===x,"filter not supported, must enable oes_texture_float_linear"),i(!e.genMipmaps,"mipmap generation not supported with float textures"));var f=t.images;for(r=0;r<16;++r)if(f[r]){var u=a>>r,c=o>>r;i(t.mipmask&1<<r,"missing mipmap data");var l=f[r];if(i(l.width===u&&l.height===c,"invalid shape for mip images"),i(l.format===t.format&&l.internalformat===t.internalformat&&l.type===t.type,"incompatible type for mip image"),l.compressed);else if(l.data){var p=Math.ceil(D(l.type,s)*u/l.unpackAlignment)*l.unpackAlignment;i(l.data.byteLength===p*c,"invalid data for image, buffer size is inconsistent with image format")}}else e.genMipmaps||i(0==(t.mipmask&1<<r),"extra mipmap data");t.compressed&&i(!e.genMipmaps,"mipmap generation for compressed images not supported")},textureCube:function(e,t,n,r){var a=e.width,o=e.height,s=e.channels;i(a>0&&a<=r.maxTextureSize&&o>0&&o<=r.maxTextureSize,"invalid texture shape"),i(a===o,"cube map must be square"),i(t.wrapS===b&&t.wrapT===b,"wrap mode not supported by cube map");for(var f=0;f<n.length;++f){var u=n[f];i(u.width===a&&u.height===o,"inconsistent cube map face shape"),t.genMipmaps&&(i(!u.compressed,"can not generate mipmap for compressed textures"),i(1===u.mipmask,"can not specify mipmaps and generate mipmaps"));for(var c=u.images,l=0;l<16;++l){var p=c[l];if(p){var d=a>>l,m=o>>l;i(u.mipmask&1<<l,"missing mipmap data"),i(p.width===d&&p.height===m,"invalid shape for mip images"),i(p.format===e.format&&p.internalformat===e.internalformat&&p.type===e.type,"incompatible type for mip image"),p.compressed||p.data&&i(p.data.byteLength===d*m*Math.max(D(p.type,s),p.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format")}}}}}),F=0,P=0;function R(e,t){this.id=F++,this.type=e,this.data=t}function L(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function B(e){return"["+function e(t){if(0===t.length)return[];var n=t.charAt(0),r=t.charAt(t.length-1);if(t.length>1&&n===r&&('"'===n||"'"===n))return['"'+L(t.substr(1,t.length-2))+'"'];var i=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t);if(i)return e(t.substr(0,i.index)).concat(e(i[1])).concat(e(t.substr(i.index+i[0].length)));var a=t.split(".");if(1===a.length)return['"'+L(t)+'"'];for(var o=[],s=0;s<a.length;++s)o=o.concat(e(a[s]));return o}(e).join("][")+"]"}var I={DynamicVariable:R,define:function(e,t){return new R(e,B(t+""))},isDynamic:function(e){return"function"==typeof e&&!e._reglType||e instanceof R},unbox:function(e,t){return"function"==typeof e?new R(P,e):e},accessor:B},V={next:"function"==typeof requestAnimationFrame?function(e){return requestAnimationFrame(e)}:function(e){return setTimeout(e,16)},cancel:"function"==typeof cancelAnimationFrame?function(e){return cancelAnimationFrame(e)}:clearTimeout},N="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date};function H(e){return"string"==typeof e?e.split():(M(Array.isArray(e),"invalid extension array"),e)}function U(e){return"string"==typeof e?(M("undefined"!=typeof document,"not supported outside of DOM"),document.querySelector(e)):e}function q(e){var n,r,i,a,o,s=e||{},f={},u=[],c=[],l="undefined"==typeof window?1:window.devicePixelRatio,p=!1,d=function(e){e&&M.raise(e)},m=function(){};if("string"==typeof s?(M("undefined"!=typeof document,"selector queries only supported in DOM enviroments"),n=document.querySelector(s),M(n,"invalid query string for element")):"object"==typeof s?"string"==typeof(o=s).nodeName&&"function"==typeof o.appendChild&&"function"==typeof o.getBoundingClientRect?n=s:!function(e){return"function"==typeof e.drawArrays||"function"==typeof e.drawElements}(s)?(M.constructor(s),"gl"in s?a=s.gl:"canvas"in s?i=U(s.canvas):"container"in s&&(r=U(s.container)),"attributes"in s&&M.type(f=s.attributes,"object","invalid context attributes"),"extensions"in s&&(u=H(s.extensions)),"optionalExtensions"in s&&(c=H(s.optionalExtensions)),"onDone"in s&&(M.type(s.onDone,"function","invalid or missing onDone callback"),d=s.onDone),"profile"in s&&(p=!!s.profile),"pixelRatio"in s&&M((l=+s.pixelRatio)>0,"invalid pixel ratio")):i=(a=s).canvas:M.raise("invalid arguments to regl"),n&&("canvas"===n.nodeName.toLowerCase()?i=n:r=n),!a){if(!i){M("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var h=function(e,n,r){var i,a=document.createElement("canvas");function o(){var n=window.innerWidth,i=window.innerHeight;if(e!==document.body){var o=e.getBoundingClientRect();n=o.right-o.left,i=o.bottom-o.top}a.width=r*n,a.height=r*i,t(a.style,{width:n+"px",height:i+"px"})}return t(a.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(a),e===document.body&&(a.style.position="absolute",t(e.style,{margin:0,padding:0})),e!==document.body&&"function"==typeof ResizeObserver?(i=new ResizeObserver(function(){setTimeout(o)})).observe(e):window.addEventListener("resize",o,!1),o(),{canvas:a,onDestroy:function(){i?i.disconnect():window.removeEventListener("resize",o),e.removeChild(a)}}}(r||document.body,0,l);if(!h)return null;i=h.canvas,m=h.onDestroy}void 0===f.premultipliedAlpha&&(f.premultipliedAlpha=!0),a=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")}(i,f)}return a?{gl:a,canvas:i,container:r,extensions:u,optionalExtensions:c,pixelRatio:l,profile:p,onDone:d,onDestroy:m}:(m(),d("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function W(e,t){for(var n=Array(e),r=0;r<e;++r)n[r]=t(r);return n}var G=5120,Q=5121,Y=5122,K=5123,$=5124,X=5125,J=5126;function Z(e){var t,n;return t=(e>65535)<<4,t|=n=((e>>>=t)>255)<<3,t|=n=((e>>>=n)>15)<<2,(t|=n=((e>>>=n)>3)<<1)|(e>>>=n)>>1}function ee(){var e=W(8,function(){return[]});function t(t){var n=function(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}(t),r=e[Z(n)>>2];return r.length>0?r.pop():new ArrayBuffer(n)}function n(t){e[Z(t.byteLength)>>2].push(t)}return{alloc:t,free:n,allocType:function(e,n){var r=null;switch(e){case G:r=new Int8Array(t(n),0,n);break;case Q:r=new Uint8Array(t(n),0,n);break;case Y:r=new Int16Array(t(2*n),0,n);break;case K:r=new Uint16Array(t(2*n),0,n);break;case $:r=new Int32Array(t(4*n),0,n);break;case X:r=new Uint32Array(t(4*n),0,n);break;case J:r=new Float32Array(t(4*n),0,n);break;default:return null}return r.length!==n?r.subarray(0,n):r},freeType:function(e){n(e.buffer)}}}var te=ee();te.zero=ee();var ne=function(e,t){var n=1;t.ext_texture_filter_anisotropic&&(n=e.getParameter(34047));var r=1,i=1;t.webgl_draw_buffers&&(r=e.getParameter(34852),i=e.getParameter(36063));var a=!!t.oes_texture_float;if(a){var o=e.createTexture();e.bindTexture(3553,o),e.texImage2D(3553,0,6408,1,1,0,6408,5126,null);var s=e.createFramebuffer();if(e.bindFramebuffer(36160,s),e.framebufferTexture2D(36160,36064,3553,o,0),e.bindTexture(3553,null),36053!==e.checkFramebufferStatus(36160))a=!1;else{e.viewport(0,0,1,1),e.clearColor(1,0,0,1),e.clear(16384);var f=te.allocType(5126,4);e.readPixels(0,0,1,1,6408,5126,f),e.getError()?a=!1:(e.deleteFramebuffer(s),e.deleteTexture(o),a=1===f[0]),te.freeType(f)}}var u=!0;if(!("undefined"!=typeof navigator&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent)))){var c=e.createTexture(),l=te.allocType(5121,36);e.activeTexture(33984),e.bindTexture(34067,c),e.texImage2D(34069,0,6408,3,3,0,6408,5121,l),te.freeType(l),e.bindTexture(34067,null),e.deleteTexture(c),u=!e.getError()}return{colorBits:[e.getParameter(3410),e.getParameter(3411),e.getParameter(3412),e.getParameter(3413)],depthBits:e.getParameter(3414),stencilBits:e.getParameter(3415),subpixelBits:e.getParameter(3408),extensions:Object.keys(t).filter(function(e){return!!t[e]}),maxAnisotropic:n,maxDrawbuffers:r,maxColorAttachments:i,pointSizeDims:e.getParameter(33901),lineWidthDims:e.getParameter(33902),maxViewportDims:e.getParameter(3386),maxCombinedTextureUnits:e.getParameter(35661),maxCubeMapSize:e.getParameter(34076),maxRenderbufferSize:e.getParameter(34024),maxTextureUnits:e.getParameter(34930),maxTextureSize:e.getParameter(3379),maxAttributes:e.getParameter(34921),maxVertexUniforms:e.getParameter(36347),maxVertexTextureUnits:e.getParameter(35660),maxVaryingVectors:e.getParameter(36348),maxFragmentUniforms:e.getParameter(36349),glsl:e.getParameter(35724),renderer:e.getParameter(7937),vendor:e.getParameter(7936),version:e.getParameter(7938),readFloat:a,npotTextureCube:u}};function re(t){return!!t&&"object"==typeof t&&Array.isArray(t.shape)&&Array.isArray(t.stride)&&"number"==typeof t.offset&&t.shape.length===t.stride.length&&(Array.isArray(t.data)||e(t.data))}var ie=function(e){return Object.keys(e).map(function(t){return e[t]})},ae={shape:function(e){for(var t=[],n=e;n.length;n=n[0])t.push(n.length);return t},flatten:function(e,t,n,r){var i=1;if(t.length)for(var a=0;a<t.length;++a)i*=t[a];else i=0;var o=r||te.allocType(n,i);switch(t.length){case 0:break;case 1:!function(e,t,n){for(var r=0;r<t;++r)n[r]=e[r]}(e,t[0],o);break;case 2:!function(e,t,n,r){for(var i=0,a=0;a<t;++a)for(var o=e[a],s=0;s<n;++s)r[i++]=o[s]}(e,t[0],t[1],o);break;case 3:oe(e,t[0],t[1],t[2],o,0);break;default:!function e(t,n,r,i,a){var o=1;for(var s=r+1;s<n.length;++s)o*=n[s];var f=n[r];if(n.length-r==4){var u=n[r+1],c=n[r+2],l=n[r+3];for(s=0;s<f;++s)oe(t[s],u,c,l,i,a),a+=o}else for(s=0;s<f;++s)e(t[s],n,r+1,i,a),a+=o}(e,t,0,o,0)}return o}};function oe(e,t,n,r,i,a){for(var o=a,s=0;s<t;++s)for(var f=e[s],u=0;u<n;++u)for(var c=f[u],l=0;l<r;++l)i[o++]=c[l]}var se={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},fe={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},ue={dynamic:35048,stream:35040,static:35044},ce=ae.flatten,le=ae.shape,pe=35044,de=35040,me=5121,he=5126,ve=[];function ge(e){return 0|se[Object.prototype.toString.call(e)]}function ye(e,t){for(var n=0;n<t.length;++n)e[n]=t[n]}function be(e,t,n,r,i,a,o){for(var s=0,f=0;f<n;++f)for(var u=0;u<r;++u)e[s++]=t[i*f+a*u+o]}ve[5120]=1,ve[5122]=2,ve[5124]=4,ve[5121]=1,ve[5123]=2,ve[5125]=4,ve[5126]=4;var xe={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},we=0,ke=1,_e=4,Ae=5120,Se=5121,Ee=5122,Te=5123,Oe=5124,je=5125,Ce=34963,De=35040,ze=35044,Me=new Float32Array(1),Fe=new Uint32Array(Me.buffer),Pe=5123;function Re(e){for(var t=te.allocType(Pe,e.length),n=0;n<e.length;++n)if(isNaN(e[n]))t[n]=65535;else if(Infinity===e[n])t[n]=31744;else if(-Infinity===e[n])t[n]=64512;else{Me[0]=e[n];var r=Fe[0],i=r>>>31<<15,a=(r<<1>>>24)-127,o=r>>13&1023;if(a<-24)t[n]=i;else if(a<-14){t[n]=i+(o+1024>>-14-a)}else t[n]=a>15?i+31744:i+(a+15<<10)+o}return t}function Le(t){return Array.isArray(t)||e(t)}var Be=function(e){return!(e&e-1||!e)},Ie=34467,Ve=3553,Ne=34067,He=34069,Ue=6408,qe=6406,We=6407,Ge=6409,Qe=6410,Ye=32854,Ke=32855,$e=36194,Xe=32819,Je=32820,Ze=33635,et=34042,tt=6402,nt=34041,rt=35904,it=35906,at=36193,ot=33776,st=33777,ft=33778,ut=33779,ct=35986,lt=35987,pt=34798,dt=35840,mt=35841,ht=35842,vt=35843,gt=36196,yt=5121,bt=5123,xt=5125,wt=5126,kt=10242,_t=10243,At=10497,St=33071,Et=33648,Tt=10240,Ot=10241,jt=9728,Ct=9729,Dt=9984,zt=9985,Mt=9986,Ft=9987,Pt=33170,Rt=4352,Lt=4353,Bt=4354,It=34046,Vt=3317,Nt=37440,Ht=37441,Ut=37443,qt=37444,Wt=33984,Gt=[Dt,Mt,zt,Ft],Qt=[0,Ge,Qe,We,Ue],Yt={};function Kt(e){return"[object "+e+"]"}Yt[Ge]=Yt[qe]=Yt[tt]=1,Yt[nt]=Yt[Qe]=2,Yt[We]=Yt[rt]=3,Yt[Ue]=Yt[it]=4;var $t=Kt("HTMLCanvasElement"),Xt=Kt("OffscreenCanvas"),Jt=Kt("CanvasRenderingContext2D"),Zt=Kt("ImageBitmap"),en=Kt("HTMLImageElement"),tn=Kt("HTMLVideoElement"),nn=Object.keys(se).concat([$t,Xt,Jt,Zt,en,tn]),rn=[];rn[yt]=1,rn[wt]=4,rn[at]=2,rn[bt]=2,rn[xt]=4;var an=[];function on(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function sn(e){return!!Array.isArray(e)&&!(0===e.length||!Le(e[0]))}function fn(e){return Object.prototype.toString.call(e)}function un(e){return fn(e)===$t}function cn(e){return fn(e)===Xt}function ln(e){if(!e)return!1;var t=fn(e);return nn.indexOf(t)>=0||(on(e)||sn(e)||re(e))}function pn(e){return 0|se[Object.prototype.toString.call(e)]}function dn(e,t){return te.allocType(e.type===at?wt:e.type,t)}function mn(e,t){e.type===at?(e.data=Re(t),te.freeType(t)):e.data=t}function hn(e,t,n,r,i,a){var o;if(o=void 0!==an[e]?an[e]:Yt[e]*rn[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 vn(n,r,i,a,o,s,f){var u={"don't care":Rt,"dont care":Rt,nice:Bt,fast:Lt},c={repeat:At,clamp:St,mirror:Et},l={nearest:jt,linear:Ct},p=t({mipmap:Ft,"nearest mipmap nearest":Dt,"linear mipmap nearest":zt,"nearest mipmap linear":Mt,"linear mipmap linear":Ft},l),d={none:0,browser:qt},m={uint8:yt,rgba4:Xe,rgb565:Ze,"rgb5 a1":Je},h={alpha:qe,luminance:Ge,"luminance alpha":Qe,rgb:We,rgba:Ue,rgba4:Ye,"rgb5 a1":Ke,rgb565:$e},v={};r.ext_srgb&&(h.srgb=rt,h.srgba=it),r.oes_texture_float&&(m.float32=m.float=wt),r.oes_texture_half_float&&(m.float16=m["half float"]=at),r.webgl_depth_texture&&(t(h,{depth:tt,"depth stencil":nt}),t(m,{uint16:bt,uint32:xt,"depth stencil":et})),r.webgl_compressed_texture_s3tc&&t(v,{"rgb s3tc dxt1":ot,"rgba s3tc dxt1":st,"rgba s3tc dxt3":ft,"rgba s3tc dxt5":ut}),r.webgl_compressed_texture_atc&&t(v,{"rgb atc":ct,"rgba atc explicit alpha":lt,"rgba atc interpolated alpha":pt}),r.webgl_compressed_texture_pvrtc&&t(v,{"rgb pvrtc 4bppv1":dt,"rgb pvrtc 2bppv1":mt,"rgba pvrtc 4bppv1":ht,"rgba pvrtc 2bppv1":vt}),r.webgl_compressed_texture_etc1&&(v["rgb etc1"]=gt);var g=Array.prototype.slice.call(n.getParameter(Ie));Object.keys(v).forEach(function(e){var t=v[e];g.indexOf(t)>=0&&(h[e]=t)});var y=Object.keys(h);i.textureFormats=y;var b=[];Object.keys(h).forEach(function(e){b[h[e]]=e});var x=[];Object.keys(m).forEach(function(e){x[m[e]]=e});var w=[];Object.keys(l).forEach(function(e){w[l[e]]=e});var k=[];Object.keys(p).forEach(function(e){k[p[e]]=e});var _=[];Object.keys(c).forEach(function(e){_[c[e]]=e});var A=y.reduce(function(e,t){var n=h[t];return e[n]=n===Ge||n===qe||n===Ge||n===Qe||n===tt||n===nt||r.ext_srgb&&(n===rt||n===it)?n:n===Ke||t.indexOf("rgba")>=0?Ue:We,e},{});function S(){this.internalformat=Ue,this.format=Ue,this.type=yt,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=qt,this.width=0,this.height=0,this.channels=0}function E(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 T(e,t){if("object"==typeof t&&t){if("premultiplyAlpha"in t&&(M.type(t.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(M.type(t.flipY,"boolean","invalid texture flip"),e.flipY=t.flipY),"alignment"in t&&(M.oneOf(t.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=t.alignment),"colorSpace"in t&&(M.parameter(t.colorSpace,d,"invalid colorSpace"),e.colorSpace=d[t.colorSpace]),"type"in t){var n=t.type;M(r.oes_texture_float||!("float"===n||"float32"===n),"you must enable the OES_texture_float extension in order to use floating point textures."),M(r.oes_texture_half_float||!("half float"===n||"float16"===n),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),M(r.webgl_depth_texture||!("uint16"===n||"uint32"===n||"depth stencil"===n),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),M.parameter(n,m,"invalid texture type"),e.type=m[n]}var a=e.width,o=e.height,s=e.channels,f=!1;"shape"in t?(M(Array.isArray(t.shape)&&t.shape.length>=2,"shape must be an array"),a=t.shape[0],o=t.shape[1],3===t.shape.length&&(M((s=t.shape[2])>0&&s<=4,"invalid number of channels"),f=!0),M(a>=0&&a<=i.maxTextureSize,"invalid width"),M(o>=0&&o<=i.maxTextureSize,"invalid height")):("radius"in t&&(a=o=t.radius,M(a>=0&&a<=i.maxTextureSize,"invalid radius")),"width"in t&&M((a=t.width)>=0&&a<=i.maxTextureSize,"invalid width"),"height"in t&&M((o=t.height)>=0&&o<=i.maxTextureSize,"invalid height"),"channels"in t&&(M((s=t.channels)>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 t){var c=t.format;M(r.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),M.parameter(c,h,"invalid texture format");var l=e.internalformat=h[c];e.format=A[l],c in m&&("type"in t||(e.type=m[c])),c in v&&(e.compressed=!0),u=!0}!f&&u?e.channels=Yt[e.format]:f&&!u?e.channels!==Qt[e.format]&&(e.format=e.internalformat=Qt[e.channels]):u&&f&&M(e.channels===Yt[e.format],"number of channels inconsistent with specified format")}}function O(e){n.pixelStorei(Nt,e.flipY),n.pixelStorei(Ht,e.premultiplyAlpha),n.pixelStorei(Ut,e.colorSpace),n.pixelStorei(Vt,e.unpackAlignment)}function j(){S.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function C(t,n){var r=null;if(ln(n)?r=n:n&&(M.type(n,"object","invalid pixel data type"),T(t,n),"x"in n&&(t.xOffset=0|n.x),"y"in n&&(t.yOffset=0|n.y),ln(n.data)&&(r=n.data)),M(!t.compressed||r instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),n.copy){M(!r,"can not specify copy and data field for the same texture");var a=o.viewportWidth,s=o.viewportHeight;t.width=t.width||a-t.xOffset,t.height=t.height||s-t.yOffset,t.needsCopy=!0,M(t.xOffset>=0&&t.xOffset<a&&t.yOffset>=0&&t.yOffset<s&&t.width>0&&t.width<=a&&t.height>0&&t.height<=s,"copy texture read out of bounds")}else if(r){if(e(r))t.channels=t.channels||4,t.data=r,"type"in n||t.type!==yt||(t.type=pn(r));else if(on(r))t.channels=t.channels||4,function(e,t){var n=t.length;switch(e.type){case yt:case bt:case xt:case wt:var r=te.allocType(e.type,n);r.set(t),e.data=r;break;case at:e.data=Re(t);break;default:M.raise("unsupported texture type, must specify a typed array")}}(t,r),t.alignment=1,t.needsFree=!0;else if(re(r)){var f=r.data;Array.isArray(f)||t.type!==yt||(t.type=pn(f));var u,c,l,p,d,m,h=r.shape,v=r.stride;3===h.length?(l=h[2],m=v[2]):(M(2===h.length,"invalid ndarray pixel data, must be 2 or 3D"),l=1,m=1),u=h[0],c=h[1],p=v[0],d=v[1],t.alignment=1,t.width=u,t.height=c,t.channels=l,t.format=t.internalformat=Qt[l],t.needsFree=!0,function(e,t,n,r,i,a){for(var o=e.width,s=e.height,f=e.channels,u=dn(e,o*s*f),c=0,l=0;l<s;++l)for(var p=0;p<o;++p)for(var d=0;d<f;++d)u[c++]=t[n*p+r*l+i*d+a];mn(e,u)}(t,f,p,d,m,r.offset)}else if(un(r)||cn(r)||fn(r)===Jt)t.element=un(r)||cn(r)?r:r.canvas,t.width=t.element.width,t.height=t.element.height,t.channels=4;else if(function(e){return fn(e)===Zt}(r))t.element=r,t.width=r.width,t.height=r.height,t.channels=4;else if(function(e){return fn(e)===en}(r))t.element=r,t.width=r.naturalWidth,t.height=r.naturalHeight,t.channels=4;else if(function(e){return fn(e)===tn}(r))t.element=r,t.width=r.videoWidth,t.height=r.videoHeight,t.channels=4;else if(sn(r)){var g=t.width||r[0].length,y=t.height||r.length,b=t.channels;b=Le(r[0][0])?b||r[0][0].length:b||1;for(var x=ae.shape(r),w=1,k=0;k<x.length;++k)w*=x[k];var _=dn(t,w);ae.flatten(r,x,"",_),mn(t,_),t.alignment=1,t.width=g,t.height=y,t.channels=b,t.format=t.internalformat=Qt[b],t.needsFree=!0}}else t.width=t.width||1,t.height=t.height||1,t.channels=t.channels||4;t.type===wt?M(i.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):t.type===at&&M(i.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function D(e,t,r){var i=e.element,o=e.data,s=e.internalformat,f=e.format,u=e.type,c=e.width,l=e.height;O(e),i?n.texImage2D(t,r,f,f,u,i):e.compressed?n.compressedTexImage2D(t,r,s,c,l,0,o):e.needsCopy?(a(),n.copyTexImage2D(t,r,f,e.xOffset,e.yOffset,c,l,0)):n.texImage2D(t,r,f,c,l,0,f,u,o||null)}function z(e,t,r,i,o){var s=e.element,f=e.data,u=e.internalformat,c=e.format,l=e.type,p=e.width,d=e.height;O(e),s?n.texSubImage2D(t,o,r,i,c,l,s):e.compressed?n.compressedTexSubImage2D(t,o,r,i,u,p,d,f):e.needsCopy?(a(),n.copyTexSubImage2D(t,o,r,i,e.xOffset,e.yOffset,p,d)):n.texSubImage2D(t,o,r,i,p,d,c,l,f)}var F=[];function P(){return F.pop()||new j}function R(e){e.needsFree&&te.freeType(e.data),j.call(e),F.push(e)}function L(){S.call(this),this.genMipmaps=!1,this.mipmapHint=Rt,this.mipmask=0,this.images=Array(16)}function B(e,t,n){var r=e.images[0]=P();e.mipmask=1,r.width=e.width=t,r.height=e.height=n,r.channels=e.channels=4}function I(e,t){var n=null;if(ln(t))E(n=e.images[0]=P(),e),C(n,t),e.mipmask=1;else if(T(e,t),Array.isArray(t.mipmap))for(var r=t.mipmap,i=0;i<r.length;++i)E(n=e.images[i]=P(),e),n.width>>=i,n.height>>=i,C(n,r[i]),e.mipmask|=1<<i;else E(n=e.images[0]=P(),e),C(n,t),e.mipmask=1;E(e,e.images[0]),!e.compressed||e.internalformat!==ot&&e.internalformat!==st&&e.internalformat!==ft&&e.internalformat!==ut||M(e.width%4==0&&e.height%4==0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function V(e,t){for(var n=e.images,r=0;r<n.length;++r){if(!n[r])return;D(n[r],t,r)}}var N=[];function H(){var e=N.pop()||new L;S.call(e),e.mipmask=0;for(var t=0;t<16;++t)e.images[t]=null;return e}function U(e){for(var t=e.images,n=0;n<t.length;++n)t[n]&&R(t[n]),t[n]=null;N.push(e)}function q(){this.minFilter=jt,this.magFilter=jt,this.wrapS=St,this.wrapT=St,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=Rt}function W(e,t){if("min"in t){var n=t.min;M.parameter(n,p),e.minFilter=p[n],Gt.indexOf(e.minFilter)>=0&&!("faces"in t)&&(e.genMipmaps=!0)}if("mag"in t){var r=t.mag;M.parameter(r,l),e.magFilter=l[r]}var a=e.wrapS,o=e.wrapT;if("wrap"in t){var s=t.wrap;"string"==typeof s?(M.parameter(s,c),a=o=c[s]):Array.isArray(s)&&(M.parameter(s[0],c),M.parameter(s[1],c),a=c[s[0]],o=c[s[1]])}else{if("wrapS"in t){var f=t.wrapS;M.parameter(f,c),a=c[f]}if("wrapT"in t){var d=t.wrapT;M.parameter(d,c),o=c[d]}}if(e.wrapS=a,e.wrapT=o,"anisotropic"in t){var m=t.anisotropic;M("number"==typeof m&&m>=1&&m<=i.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var h=!1;switch(typeof t.mipmap){case"string":M.parameter(t.mipmap,u,"invalid mipmap hint"),e.mipmapHint=u[t.mipmap],e.genMipmaps=!0,h=!0;break;case"boolean":h=e.genMipmaps=t.mipmap;break;case"object":M(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,h=!0;break;default:M.raise("invalid mipmap type")}!h||"min"in t||(e.minFilter=Dt)}}function G(e,t){n.texParameteri(t,Ot,e.minFilter),n.texParameteri(t,Tt,e.magFilter),n.texParameteri(t,kt,e.wrapS),n.texParameteri(t,_t,e.wrapT),r.ext_texture_filter_anisotropic&&n.texParameteri(t,It,e.anisotropic),e.genMipmaps&&(n.hint(Pt,e.mipmapHint),n.generateMipmap(t))}var Q=0,Y={},K=i.maxTextureUnits,$=Array(K).map(function(){return null});function X(e){S.call(this),this.mipmask=0,this.internalformat=Ue,this.id=Q++,this.refCount=1,this.target=e,this.texture=n.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new q,f.profile&&(this.stats={size:0})}function J(e){n.activeTexture(Wt),n.bindTexture(e.target,e.texture)}function Z(){var e=$[0];e?n.bindTexture(e.target,e.texture):n.bindTexture(Ve,null)}function ee(e){var t=e.texture;M(t,"must not double destroy texture");var r=e.unit,i=e.target;r>=0&&(n.activeTexture(Wt+r),n.bindTexture(i,null),$[r]=null),n.deleteTexture(t),e.texture=null,e.params=null,e.pixels=null,e.refCount=0,delete Y[e.id],s.textureCount--}return t(X.prototype,{bind:function(){this.bindCount+=1;var e=this.unit;if(e<0){for(var t=0;t<K;++t){var r=$[t];if(r){if(r.bindCount>0)continue;r.unit=-1}$[t]=this,e=t;break}e>=K&&M.raise("insufficient number of texture units"),f.profile&&s.maxTextureUnits<e+1&&(s.maxTextureUnits=e+1),this.unit=e,n.activeTexture(Wt+e),n.bindTexture(this.target,this.texture)}return e},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&ee(this)}}),f.profile&&(s.getTotalTextureSize=function(){var e=0;return Object.keys(Y).forEach(function(t){e+=Y[t].stats.size}),e}),{create2D:function(e,t){var r=new X(Ve);function a(e,t){var n=r.texInfo;q.call(n);var o=H();return"number"==typeof e?B(o,0|e,"number"==typeof t?0|t:0|e):e?(M.type(e,"object","invalid arguments to regl.texture"),W(n,e),I(o,e)):B(o,1,1),n.genMipmaps&&(o.mipmask=(o.width<<1)-1),r.mipmask=o.mipmask,E(r,o),M.texture2D(n,o,i),r.internalformat=o.internalformat,a.width=o.width,a.height=o.height,J(r),V(o,Ve),G(n,Ve),Z(),U(o),f.profile&&(r.stats.size=hn(r.internalformat,r.type,o.width,o.height,n.genMipmaps,!1)),a.format=b[r.internalformat],a.type=x[r.type],a.mag=w[n.magFilter],a.min=k[n.minFilter],a.wrapS=_[n.wrapS],a.wrapT=_[n.wrapT],a}return Y[r.id]=r,s.textureCount++,a(e,t),a.subimage=function(e,t,n,i){M(!!e,"must specify image data");var o=0|t,s=0|n,f=0|i,u=P();return E(u,r),u.width=0,u.height=0,C(u,e),u.width=u.width||(r.width>>f)-o,u.height=u.height||(r.height>>f)-s,M(r.type===u.type&&r.format===u.format&&r.internalformat===u.internalformat,"incompatible format for texture.subimage"),M(o>=0&&s>=0&&o+u.width<=r.width&&s+u.height<=r.height,"texture.subimage write out of bounds"),M(r.mipmask&1<<f,"missing mipmap data"),M(u.data||u.element||u.needsCopy,"missing image data"),J(r),z(u,Ve,o,s,f),Z(),R(u),a},a.resize=function(e,t){var i=0|e,o=0|t||i;if(i===r.width&&o===r.height)return a;a.width=r.width=i,a.height=r.height=o,J(r);for(var s=0;r.mipmask>>s;++s){var u=i>>s,c=o>>s;if(!u||!c)break;n.texImage2D(Ve,s,r.format,u,c,0,r.format,r.type,null)}return Z(),f.profile&&(r.stats.size=hn(r.internalformat,r.type,i,o,!1,!1)),a},a._reglType="texture2d",a._texture=r,f.profile&&(a.stats=r.stats),a.destroy=function(){r.decRef()},a},createCube:function(e,t,r,a,o,u){var c=new X(Ne);Y[c.id]=c,s.cubeCount++;var l=new Array(6);function p(e,t,n,r,a,o){var s,u=c.texInfo;for(q.call(u),s=0;s<6;++s)l[s]=H();if("number"!=typeof e&&e)if("object"==typeof e)if(t)I(l[0],e),I(l[1],t),I(l[2],n),I(l[3],r),I(l[4],a),I(l[5],o);else if(W(u,e),T(c,e),"faces"in e){var d=e.faces;for(M(Array.isArray(d)&&6===d.length,"cube faces must be a length 6 array"),s=0;s<6;++s)M("object"==typeof d[s]&&!!d[s],"invalid input for cube map face"),E(l[s],c),I(l[s],d[s])}else for(s=0;s<6;++s)I(l[s],e);else M.raise("invalid arguments to cube map");else{var m=0|e||1;for(s=0;s<6;++s)B(l[s],m,m)}for(E(c,l[0]),i.npotTextureCube||M(Be(c.width)&&Be(c.height),"your browser does not support non power or two texture dimensions"),c.mipmask=u.genMipmaps?(l[0].width<<1)-1:l[0].mipmask,M.textureCube(c,u,l,i),c.internalformat=l[0].internalformat,p.width=l[0].width,p.height=l[0].height,J(c),s=0;s<6;++s)V(l[s],He+s);for(G(u,Ne),Z(),f.profile&&(c.stats.size=hn(c.internalformat,c.type,p.width,p.height,u.genMipmaps,!0)),p.format=b[c.internalformat],p.type=x[c.type],p.mag=w[u.magFilter],p.min=k[u.minFilter],p.wrapS=_[u.wrapS],p.wrapT=_[u.wrapT],s=0;s<6;++s)U(l[s]);return p}return p(e,t,r,a,o,u),p.subimage=function(e,t,n,r,i){M(!!t,"must specify image data"),M("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var a=0|n,o=0|r,s=0|i,f=P();return E(f,c),f.width=0,f.height=0,C(f,t),f.width=f.width||(c.width>>s)-a,f.height=f.height||(c.height>>s)-o,M(c.type===f.type&&c.format===f.format&&c.internalformat===f.internalformat,"incompatible format for texture.subimage"),M(a>=0&&o>=0&&a+f.width<=c.width&&o+f.height<=c.height,"texture.subimage write out of bounds"),M(c.mipmask&1<<s,"missing mipmap data"),M(f.data||f.element||f.needsCopy,"missing image data"),J(c),z(f,He+e,a,o,s),Z(),R(f),p},p.resize=function(e){var t=0|e;if(t!==c.width){p.width=c.width=t,p.height=c.height=t,J(c);for(var r=0;r<6;++r)for(var i=0;c.mipmask>>i;++i)n.texImage2D(He+r,i,c.format,t>>i,t>>i,0,c.format,c.type,null);return Z(),f.profile&&(c.stats.size=hn(c.internalformat,c.type,p.width,p.height,!1,!0)),p}},p._reglType="textureCube",p._texture=c,f.profile&&(p.stats=c.stats),p.destroy=function(){c.decRef()},p},clear:function(){for(var e=0;e<K;++e)n.activeTexture(Wt+e),n.bindTexture(Ve,null),$[e]=null;ie(Y).forEach(ee),s.cubeCount=0,s.textureCount=0},getTexture:function(e){return null},restore:function(){for(var e=0;e<K;++e){var t=$[e];t&&(t.bindCount=0,t.unit=-1,$[e]=null)}ie(Y).forEach(function(e){e.texture=n.createTexture(),n.bindTexture(e.target,e.texture);for(var t=0;t<32;++t)if(0!=(e.mipmask&1<<t))if(e.target===Ve)n.texImage2D(Ve,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);else for(var r=0;r<6;++r)n.texImage2D(He+r,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);G(e.texInfo,e.target)})}}}an[Ye]=2,an[Ke]=2,an[$e]=2,an[nt]=4,an[ot]=.5,an[st]=.5,an[ft]=1,an[ut]=1,an[ct]=.5,an[lt]=1,an[pt]=1,an[dt]=.5,an[mt]=.25,an[ht]=.5,an[vt]=.25,an[gt]=.5;var gn=36161,yn=32854,bn=[];function xn(e,t,n){return bn[e]*t*n}bn[yn]=2,bn[32855]=2,bn[36194]=2,bn[33189]=2,bn[36168]=1,bn[34041]=4,bn[35907]=4,bn[34836]=16,bn[34842]=8,bn[34843]=6;var wn=function(e,t,n,r,i){var a={rgba4:yn,rgb565:36194,"rgb5 a1":32855,depth:33189,stencil:36168,"depth stencil":34041};t.ext_srgb&&(a.srgba=35907),t.ext_color_buffer_half_float&&(a.rgba16f=34842,a.rgb16f=34843),t.webgl_color_buffer_float&&(a.rgba32f=34836);var o=[];Object.keys(a).forEach(function(e){o[a[e]]=e});var s=0,f={};function u(e){this.id=s++,this.refCount=1,this.renderbuffer=e,this.format=yn,this.width=0,this.height=0,i.profile&&(this.stats={size:0})}function c(t){var n=t.renderbuffer;M(n,"must not double destroy renderbuffer"),e.bindRenderbuffer(gn,null),e.deleteRenderbuffer(n),t.renderbuffer=null,t.refCount=0,delete f[t.id],r.renderbufferCount--}return u.prototype.decRef=function(){--this.refCount<=0&&c(this)},i.profile&&(r.getTotalRenderbufferSize=function(){var e=0;return Object.keys(f).forEach(function(t){e+=f[t].stats.size}),e}),{create:function(t,s){var c=new u(e.createRenderbuffer());function l(t,r){var s=0,f=0,u=yn;if("object"==typeof t&&t){var p=t;if("shape"in p){var d=p.shape;M(Array.isArray(d)&&d.length>=2,"invalid renderbuffer shape"),s=0|d[0],f=0|d[1]}else"radius"in p&&(s=f=0|p.radius),"width"in p&&(s=0|p.width),"height"in p&&(f=0|p.height);"format"in p&&(M.parameter(p.format,a,"invalid renderbuffer format"),u=a[p.format])}else"number"==typeof t?(s=0|t,f="number"==typeof r?0|r:s):t?M.raise("invalid arguments to renderbuffer constructor"):s=f=1;if(M(s>0&&f>0&&s<=n.maxRenderbufferSize&&f<=n.maxRenderbufferSize,"invalid renderbuffer size"),s!==c.width||f!==c.height||u!==c.format)return l.width=c.width=s,l.height=c.height=f,c.format=u,e.bindRenderbuffer(gn,c.renderbuffer),e.renderbufferStorage(gn,u,s,f),M(0===e.getError(),"invalid render buffer format"),i.profile&&(c.stats.size=xn(c.format,c.width,c.height)),l.format=o[c.format],l}return f[c.id]=c,r.renderbufferCount++,l(t,s),l.resize=function(t,r){var a=0|t,o=0|r||a;return a===c.width&&o===c.height?l:(M(a>0&&o>0&&a<=n.maxRenderbufferSize&&o<=n.maxRenderbufferSize,"invalid renderbuffer size"),l.width=c.width=a,l.height=c.height=o,e.bindRenderbuffer(gn,c.renderbuffer),e.renderbufferStorage(gn,c.format,a,o),M(0===e.getError(),"invalid render buffer format"),i.profile&&(c.stats.size=xn(c.format,c.width,c.height)),l)},l._reglType="renderbuffer",l._renderbuffer=c,i.profile&&(l.stats=c.stats),l.destroy=function(){c.decRef()},l},clear:function(){ie(f).forEach(c)},restore:function(){ie(f).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(gn,t.renderbuffer),e.renderbufferStorage(gn,t.format,t.width,t.height)}),e.bindRenderbuffer(gn,null)}}},kn=36160,_n=36161,An=3553,Sn=34069,En=36064,Tn=36096,On=36128,jn=33306,Cn=36053,Dn=6402,zn=[6407,6408],Mn=[];Mn[6408]=4,Mn[6407]=3;var Fn=[];Fn[5121]=1,Fn[5126]=4,Fn[36193]=2;var Pn=33189,Rn=36168,Ln=34041,Bn=[32854,32855,36194,35907,34842,34843,34836],In={};In[Cn]="complete",In[36054]="incomplete attachment",In[36057]="incomplete dimensions",In[36055]="incomplete, missing attachment",In[36061]="unsupported";var Vn=5126,Nn=34962;function Hn(){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=Vn,this.offset=0,this.stride=0,this.divisor=0}var Un=35632,qn=35633,Wn=35718,Gn=35721,Qn=6408,Yn=5121,Kn=3333,$n=5126;function Xn(t,n,r,i,a,o,s){function f(f){var u;null===n.next?(M(a.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),u=Yn):(M(null!==n.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),u=n.next.colorAttachments[0].texture._texture.type,o.oes_texture_float?(M(u===Yn||u===$n,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),u===$n&&M(s.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):M(u===Yn,"Reading from a framebuffer is only allowed for the type 'uint8'"));var c=0,l=0,p=i.framebufferWidth,d=i.framebufferHeight,m=null;e(f)?m=f:f&&(M.type(f,"object","invalid arguments to regl.read()"),l=0|f.y,M((c=0|f.x)>=0&&c<i.framebufferWidth,"invalid x offset for regl.read"),M(l>=0&&l<i.framebufferHeight,"invalid y offset for regl.read"),p=0|(f.width||i.framebufferWidth-c),d=0|(f.height||i.framebufferHeight-l),m=f.data||null),m&&(u===Yn?M(m instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):u===$n&&M(m instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),M(p>0&&p+c<=i.framebufferWidth,"invalid width for read pixels"),M(d>0&&d+l<=i.framebufferHeight,"invalid height for read pixels"),r();var h=p*d*4;return m||(u===Yn?m=new Uint8Array(h):u===$n&&(m=m||new Float32Array(h))),M.isTypedArray(m,"data buffer for regl.read() must be a typedarray"),M(m.byteLength>=h,"data buffer for regl.read() too small"),t.pixelStorei(Kn,4),t.readPixels(c,l,p,d,Qn,u,m),m}return function(e){return e&&"framebuffer"in e?function(e){var t;return n.setFBO({framebuffer:e.framebuffer},function(){t=f(e)}),t}(e):f(e)}}function Jn(e){return Array.prototype.slice.call(e)}function Zn(e){return Jn(e).join("")}var er="xyzw".split(""),tr=5121,nr=1,rr=2,ir=0,ar=1,or=2,sr=3,fr=4,ur="dither",cr="blend.enable",lr="blend.color",pr="blend.equation",dr="blend.func",mr="depth.enable",hr="depth.func",vr="depth.range",gr="depth.mask",yr="colorMask",br="cull.enable",xr="cull.face",wr="frontFace",kr="lineWidth",_r="polygonOffset.enable",Ar="polygonOffset.offset",Sr="sample.alpha",Er="sample.enable",Tr="sample.coverage",Or="stencil.enable",jr="stencil.mask",Cr="stencil.func",Dr="stencil.opFront",zr="stencil.opBack",Mr="scissor.enable",Fr="scissor.box",Pr="viewport",Rr="profile",Lr="framebuffer",Br="vert",Ir="frag",Vr="elements",Nr="primitive",Hr="count",Ur="offset",qr="instances",Wr="vao",Gr=Lr+"Width",Qr=Lr+"Height",Yr=Pr+"Width",Kr=Pr+"Height",$r="drawingBufferWidth",Xr="drawingBufferHeight",Jr=[dr,pr,Cr,Dr,zr,Tr,Pr,Fr,Ar],Zr=34962,ei=34963,ti=3553,ni=34067,ri=2884,ii=3042,ai=3024,oi=2960,si=2929,fi=3089,ui=32823,ci=32926,li=32928,pi=5126,di=35664,mi=35665,hi=35666,vi=5124,gi=35667,yi=35668,bi=35669,xi=35670,wi=35671,ki=35672,_i=35673,Ai=35674,Si=35675,Ei=35676,Ti=35678,Oi=35680,ji=4,Ci=1028,Di=1029,zi=2304,Mi=2305,Fi=32775,Pi=32776,Ri=519,Li=7680,Bi=0,Ii=1,Vi=32774,Ni=513,Hi=36160,Ui=36064,qi={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},Wi=["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"],Gi={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},Qi={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Yi={frag:35632,vert:35633},Ki={cw:zi,ccw:Mi};function $i(t){return Array.isArray(t)||e(t)||re(t)}function Xi(e){return e.sort(function(e,t){return e===Pr?-1:t===Pr?1:e<t?-1:1})}function Ji(e,t,n,r){this.thisDep=e,this.contextDep=t,this.propDep=n,this.append=r}function Zi(e){return e&&!(e.thisDep||e.contextDep||e.propDep)}function ea(e){return new Ji(!1,!1,!1,e)}function ta(e,t){var n=e.type;if(n===ir){var r=e.data.length;return new Ji(!0,r>=1,r>=2,t)}if(n===fr){var i=e.data;return new Ji(i.thisDep,i.contextDep,i.propDep,t)}return new Ji(n===sr,n===or,n===ar,t)}var na=new Ji(!1,!1,!1,function(){});function ra(e,n,r,i,a,o,s,f,u,c,l,p,d,m,h){var v=c.Record,g={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&(g.min=Fi,g.max=Pi);var y=r.angle_instanced_arrays,b=r.webgl_draw_buffers,x={dirty:!0,profile:h.profile},w={},k=[],_={},A={};function S(e){return e.replace(".","_")}function E(e,t,n){var r=S(e);k.push(e),w[r]=x[r]=!!n,_[r]=t}function T(e,t,n){var r=S(e);k.push(e),Array.isArray(n)?(x[r]=n.slice(),w[r]=n.slice()):x[r]=w[r]=n,A[r]=t}E(ur,ai),E(cr,ii),T(lr,"blendColor",[0,0,0,0]),T(pr,"blendEquationSeparate",[Vi,Vi]),T(dr,"blendFuncSeparate",[Ii,Bi,Ii,Bi]),E(mr,si,!0),T(hr,"depthFunc",Ni),T(vr,"depthRange",[0,1]),T(gr,"depthMask",!0),T(yr,yr,[!0,!0,!0,!0]),E(br,ri),T(xr,"cullFace",Di),T(wr,wr,Mi),T(kr,kr,1),E(_r,ui),T(Ar,"polygonOffset",[0,0]),E(Sr,ci),E(Er,li),T(Tr,"sampleCoverage",[1,!1]),E(Or,oi),T(jr,"stencilMask",-1),T(Cr,"stencilFunc",[Ri,0,-1]),T(Dr,"stencilOpSeparate",[Ci,Li,Li,Li]),T(zr,"stencilOpSeparate",[Di,Li,Li,Li]),E(Mr,fi),T(Fr,"scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),T(Pr,Pr,[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var O={gl:e,context:d,strings:n,next:w,current:x,draw:p,elements:o,buffer:a,shader:l,attributes:c.state,vao:c,uniforms:u,framebuffer:f,extensions:r,timer:m,isBufferArgs:$i},j={primTypes:xe,compareFuncs:Gi,blendFuncs:qi,blendEquations:g,stencilOps:Qi,glTypes:fe,orientationType:Ki};M.optional(function(){O.isArrayLike=Le}),b&&(j.backBuffer=[Di],j.drawBuffer=W(i.maxDrawbuffers,function(e){return 0===e?[0]:W(e,function(e){return Ui+e})}));var C=0;function D(){var e=function(){var e=0,n=[],r=[];function i(){var n=[],r=[];return t(function(){n.push.apply(n,Jn(arguments))},{def:function(){var t="v"+e++;return r.push(t),arguments.length>0&&(n.push(t,"="),n.push.apply(n,Jn(arguments)),n.push(";")),t},toString:function(){return Zn([r.length>0?"var "+r.join(",")+";":"",Zn(n)])}})}function a(){var e=i(),n=i(),r=e.toString,a=n.toString;function o(t,r){n(t,r,"=",e.def(t,r),";")}return t(function(){e.apply(e,Jn(arguments))},{def:e.def,entry:e,exit:n,save:o,set:function(t,n,r){o(t,n),e(t,n,"=",r,";")},toString:function(){return r()+a()}})}var o=i(),s={};return{global:o,link:function(t){for(var i=0;i<r.length;++i)if(r[i]===t)return n[i];var a="g"+e++;return n.push(a),r.push(t),a},block:i,proc:function(e,n){var r=[];function i(){var e="a"+r.length;return r.push(e),e}n=n||0;for(var o=0;o<n;++o)i();var f=a(),u=f.toString;return s[e]=t(f,{arg:i,toString:function(){return Zn(["function(",r.join(),"){",u(),"}"])}})},scope:a,cond:function(){var e=Zn(arguments),n=a(),r=a(),i=n.toString,o=r.toString;return t(n,{then:function(){return n.apply(n,Jn(arguments)),this},else:function(){return r.apply(r,Jn(arguments)),this},toString:function(){var t=o();return t&&(t="else{"+t+"}"),Zn(["if(",e,"){",i(),"}",t])}})},compile:function(){var e=['"use strict";',o,"return {"];Object.keys(s).forEach(function(t){e.push('"',t,'":',s[t].toString(),",")}),e.push("}");var t=Zn(e).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,n.concat(t)).apply(null,r)}}}(),r=e.link,i=e.global;e.id=C++,e.batchId="0";var a=r(O),o=e.shared={props:"a0"};Object.keys(O).forEach(function(e){o[e]=i.def(a,".",e)}),M.optional(function(){e.CHECK=r(M),e.commandStr=M.guessCommand(),e.command=r(e.commandStr),e.assert=function(e,t,n){e("if(!(",t,"))",this.CHECK,".commandRaise(",r(n),",",this.command,");")},j.invalidBlendCombinations=Wi});var s=e.next={},f=e.current={};Object.keys(A).forEach(function(e){Array.isArray(x[e])&&(s[e]=i.def(o.next,".",e),f[e]=i.def(o.current,".",e))});var u=e.constants={};Object.keys(j).forEach(function(e){u[e]=i.def(JSON.stringify(j[e]))}),e.invoke=function(t,n){switch(n.type){case ir:var i=["this",o.context,o.props,e.batchId];return t.def(r(n.data),".call(",i.slice(0,Math.max(n.data.length+1,4)),")");case ar:return t.def(o.props,n.data);case or:return t.def(o.context,n.data);case sr:return t.def("this",n.data);case fr:return n.data.append(e,t),n.data.ref}},e.attribCache={};var l={};return e.scopeAttrib=function(e){var t=n.id(e);if(t in l)return l[t];var i=c.scope[t];return i||(i=c.scope[t]=new v),l[t]=r(i)},e}function z(e,t,s,u,p){var d=e.static,m=e.dynamic;M.optional(function(){var e=[Lr,Br,Ir,Vr,Nr,Ur,Hr,qr,Rr,Wr].concat(k);function t(t){Object.keys(t).forEach(function(t){M.command(e.indexOf(t)>=0,'unknown parameter "'+t+'"',p.commandStr)})}t(d),t(m)});var h=function(e,t){var n=e.static;if("string"==typeof n[Ir]&&"string"==typeof n[Br]){if(Object.keys(t.dynamic).length>0)return null;var r=t.static,i=Object.keys(r);if(i.length>0&&"number"==typeof r[i[0]]){for(var a=[],o=0;o<i.length;++o)M("number"==typeof r[i[o]],"must specify all vertex attribute locations when using vaos"),a.push([0|r[i[o]],i[o]]);return a}}return null}(e,t),b=function(e,t){var n=e.static,r=e.dynamic;if(Lr in n){var i=n[Lr];return i?(i=f.getFramebuffer(i),M.command(i,"invalid framebuffer object"),ea(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,"."+Gr,n+".width"),t.set(a,"."+Qr,n+".height"),n})):ea(function(e,t){var n=e.shared;t.set(n.framebuffer,".next","null");var r=n.context;return t.set(r,"."+Gr,r+"."+$r),t.set(r,"."+Qr,r+"."+Xr),"null"})}if(Lr in r){var a=r[Lr];return ta(a,function(e,t){var n=e.invoke(t,a),r=e.shared,i=r.framebuffer,o=t.def(i,".getFramebuffer(",n,")");M.optional(function(){e.assert(t,"!"+n+"||"+o,"invalid framebuffer object")}),t.set(i,".next",o);var s=r.context;return t.set(s,"."+Gr,o+"?"+o+".width:"+s+"."+$r),t.set(s,"."+Qr,o+"?"+o+".height:"+s+"."+Xr),o})}return null}(e),x=function(e,t,n){var r=e.static,i=e.dynamic;function a(e){if(e in r){var a=r[e];M.commandType(a,"object","invalid "+e,n.commandStr);var o,s,f=!0,u=0|a.x,c=0|a.y;return"width"in a?M.command((o=0|a.width)>=0,"invalid "+e,n.commandStr):f=!1,"height"in a?M.command((s=0|a.height)>=0,"invalid "+e,n.commandStr):f=!1,new Ji(!f&&t&&t.thisDep,!f&&t&&t.contextDep,!f&&t&&t.propDep,function(e,t){var n=e.shared.context,r=o;"width"in a||(r=t.def(n,".",Gr,"-",u));var i=s;return"height"in a||(i=t.def(n,".",Qr,"-",c)),[u,c,r,i]})}if(e in i){var l=i[e],p=ta(l,function(t,n){var r=t.invoke(n,l);M.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,".",Gr,"-",a,")"),f=n.def('"height" in ',r,"?",r,".height|0:","(",i,".",Qr,"-",o,")");return M.optional(function(){t.assert(n,s+">=0&&"+f+">=0","invalid "+e)}),[a,o,s,f]});return t&&(p.thisDep=p.thisDep||t.thisDep,p.contextDep=p.contextDep||t.contextDep,p.propDep=p.propDep||t.propDep),p}return t?new Ji(t.thisDep,t.contextDep,t.propDep,function(e,t){var n=e.shared.context;return[0,0,t.def(n,".",Gr),t.def(n,".",Qr)]}):null}var o=a(Pr);if(o){var s=o;o=new Ji(o.thisDep,o.contextDep,o.propDep,function(e,t){var n=s.append(e,t),r=e.shared.context;return t.set(r,"."+Yr,n[2]),t.set(r,"."+Kr,n[3]),n})}return{viewport:o,scissor_box:a(Fr)}}(e,b,p),w=function(e,t){var n=e.static,r=e.dynamic,i=function(){if(Vr in n){var e=n[Vr];$i(e)?e=o.getElements(o.create(e,!0)):e&&(e=o.getElements(e),M.command(e,"invalid elements",t.commandStr));var i=ea(function(t,n){if(e){var r=t.link(e);return t.ELEMENTS=r,r}return t.ELEMENTS=null,null});return i.value=e,i}if(Vr in r){var a=r[Vr];return ta(a,function(e,t){var n=e.shared,r=n.isBufferArgs,i=n.elements,o=e.invoke(t,a),s=t.def("null"),f=t.def(r,"(",o,")"),u=e.cond(f).then(s,"=",i,".createStream(",o,");").else(s,"=",i,".getElements(",o,");");return M.optional(function(){e.assert(u.else,"!"+o+"||"+s,"invalid elements")}),t.entry(u),t.exit(e.cond(f).then(i,".destroyStream(",s,");")),e.ELEMENTS=s,s})}return null}();function a(e,a){if(e in n){var o=0|n[e];return M.command(!a||o>=0,"invalid "+e,t.commandStr),ea(function(e,t){return a&&(e.OFFSET=o),o})}if(e in r){var s=r[e];return ta(s,function(t,n){var r=t.invoke(n,s);return a&&(t.OFFSET=r,M.optional(function(){t.assert(n,r+">=0","invalid "+e)})),r})}return a&&i?ea(function(e,t){return e.OFFSET="0",0}):null}var s=a(Ur,!0);return{elements:i,primitive:function(){if(Nr in n){var e=n[Nr];return M.commandParameter(e,xe,"invalid primitve",t.commandStr),ea(function(t,n){return xe[e]})}if(Nr in r){var a=r[Nr];return ta(a,function(e,t){var n=e.constants.primTypes,r=e.invoke(t,a);return M.optional(function(){e.assert(t,r+" in "+n,"invalid primitive, must be one of "+Object.keys(xe))}),t.def(n,"[",r,"]")})}return i?Zi(i)?ea(i.value?function(e,t){return t.def(e.ELEMENTS,".primType")}:function(){return ji}):new Ji(i.thisDep,i.contextDep,i.propDep,function(e,t){var n=e.ELEMENTS;return t.def(n,"?",n,".primType:",ji)}):null}(),count:function(){if(Hr in n){var e=0|n[Hr];return M.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),ea(function(){return e})}if(Hr in r){var a=r[Hr];return ta(a,function(e,t){var n=e.invoke(t,a);return M.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")}),n})}if(i){if(Zi(i)){if(i)return s?new Ji(s.thisDep,s.contextDep,s.propDep,function(e,t){var n=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return M.optional(function(){e.assert(t,n+">=0","invalid vertex offset/element buffer too small")}),n}):ea(function(e,t){return t.def(e.ELEMENTS,".vertCount")});var o=ea(function(){return-1});return M.optional(function(){o.MISSING=!0}),o}var f=new Ji(i.thisDep||s.thisDep,i.contextDep||s.contextDep,i.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 M.optional(function(){f.DYNAMIC=!0}),f}return null}(),instances:a(qr,!1),offset:s}}(e,p),_=function(e,t){var n=e.static,r=e.dynamic,a={};return k.forEach(function(e){var o=S(e);function s(t,i){if(e in n){var s=t(n[e]);a[o]=ea(function(){return s})}else if(e in r){var f=r[e];a[o]=ta(f,function(e,t){return i(e,t,e.invoke(t,f))})}}switch(e){case br:case cr:case ur:case Or:case mr:case Mr:case _r:case Sr:case Er:case gr:return s(function(n){return M.commandType(n,"boolean",e,t.commandStr),n},function(t,n,r){return M.optional(function(){t.assert(n,"typeof "+r+'==="boolean"',"invalid flag "+e,t.commandStr)}),r});case hr:return s(function(n){return M.commandParameter(n,Gi,"invalid "+e,t.commandStr),Gi[n]},function(t,n,r){var i=t.constants.compareFuncs;return M.optional(function(){t.assert(n,r+" in "+i,"invalid "+e+", must be one of "+Object.keys(Gi))}),n.def(i,"[",r,"]")});case vr:return s(function(e){return M.command(Le(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 M.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 dr:return s(function(e){M.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 M.commandParameter(n,qi,o+".srcRGB",t.commandStr),M.commandParameter(r,qi,o+".srcAlpha",t.commandStr),M.commandParameter(i,qi,o+".dstRGB",t.commandStr),M.commandParameter(a,qi,o+".dstAlpha",t.commandStr),M.command(-1===Wi.indexOf(n+", "+i),"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+i+")",t.commandStr),[qi[n],qi[i],qi[r],qi[a]]},function(t,n,r){var i=t.constants.blendFuncs;function a(a,o){var s=n.def('"',a,o,'" in ',r,"?",r,".",a,o,":",r,".",a);return M.optional(function(){t.assert(n,s+" in "+i,"invalid "+e+"."+a+o+", must be one of "+Object.keys(qi))}),s}M.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid blend func, must be an object")});var o=a("src","RGB"),s=a("dst","RGB");M.optional(function(){t.assert(n,t.constants.invalidBlendCombinations+".indexOf("+o+'+", "+'+s+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var f=n.def(i,"[",o,"]"),u=n.def(i,"[",a("src","Alpha"),"]");return[f,n.def(i,"[",s,"]"),u,n.def(i,"[",a("dst","Alpha"),"]")]});case pr:return s(function(n){return"string"==typeof n?(M.commandParameter(n,g,"invalid "+e,t.commandStr),[g[n],g[n]]):"object"==typeof n?(M.commandParameter(n.rgb,g,e+".rgb",t.commandStr),M.commandParameter(n.alpha,g,e+".alpha",t.commandStr),[g[n.rgb],g[n.alpha]]):void M.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 M.optional(function(){function n(e,n,r){t.assert(e,r+" in "+i,"invalid "+n+", must be one of "+Object.keys(g))}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 lr:return s(function(e){return M.command(Le(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),W(4,function(t){return+e[t]})},function(e,t,n){return M.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","blend.color must be a 4d array")}),W(4,function(e){return t.def("+",n,"[",e,"]")})});case jr:return s(function(e){return M.commandType(e,"number",o,t.commandStr),0|e},function(e,t,n){return M.optional(function(){e.assert(t,"typeof "+n+'==="number"',"invalid stencil.mask")}),t.def(n,"|0")});case Cr:return s(function(n){M.commandType(n,"object",o,t.commandStr);var r=n.cmp||"keep",i=n.ref||0,a="mask"in n?n.mask:-1;return M.commandParameter(r,Gi,e+".cmp",t.commandStr),M.commandType(i,"number",e+".ref",t.commandStr),M.commandType(a,"number",e+".mask",t.commandStr),[Gi[r],i,a]},function(e,t,n){var r=e.constants.compareFuncs;return M.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]",":",Li),t.def(n,".ref|0"),t.def('"mask" in ',n,"?",n,".mask|0:-1")]});case Dr:case zr:return s(function(n){M.commandType(n,"object",o,t.commandStr);var r=n.fail||"keep",i=n.zfail||"keep",a=n.zpass||"keep";return M.commandParameter(r,Qi,e+".fail",t.commandStr),M.commandParameter(i,Qi,e+".zfail",t.commandStr),M.commandParameter(a,Qi,e+".zpass",t.commandStr),[e===zr?Di:Ci,Qi[r],Qi[i],Qi[a]]},function(t,n,r){var i=t.constants.stencilOps;function a(a){return M.optional(function(){t.assert(n,'!("'+a+'" in '+r+")||("+r+"."+a+" in "+i+")","invalid "+e+"."+a+", must be one of "+Object.keys(Qi))}),n.def('"',a,'" in ',r,"?",i,"[",r,".",a,"]:",Li)}return M.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[e===zr?Di:Ci,a("fail"),a("zfail"),a("zpass")]});case Ar:return s(function(e){M.commandType(e,"object",o,t.commandStr);var n=0|e.factor,r=0|e.units;return M.commandType(n,"number",o+".factor",t.commandStr),M.commandType(r,"number",o+".units",t.commandStr),[n,r]},function(t,n,r){return M.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[n.def(r,".factor|0"),n.def(r,".units|0")]});case xr:return s(function(e){var n=0;return"front"===e?n=Ci:"back"===e&&(n=Di),M.command(!!n,o,t.commandStr),n},function(e,t,n){return M.optional(function(){e.assert(t,n+'==="front"||'+n+'==="back"',"invalid cull.face")}),t.def(n,'==="front"?',Ci,":",Di)});case kr:return s(function(e){return M.command("number"==typeof e&&e>=i.lineWidthDims[0]&&e<=i.lineWidthDims[1],"invalid line width, must be a positive number between "+i.lineWidthDims[0]+" and "+i.lineWidthDims[1],t.commandStr),e},function(e,t,n){return M.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">="+i.lineWidthDims[0]+"&&"+n+"<="+i.lineWidthDims[1],"invalid line width")}),n});case wr:return s(function(e){return M.commandParameter(e,Ki,o,t.commandStr),Ki[e]},function(e,t,n){return M.optional(function(){e.assert(t,n+'==="cw"||'+n+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),t.def(n+'==="cw"?'+zi+":"+Mi)});case yr:return s(function(e){return M.command(Le(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map(function(e){return!!e})},function(e,t,n){return M.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","invalid color.mask")}),W(4,function(e){return"!!"+n+"["+e+"]"})});case Tr:return s(function(e){M.command("object"==typeof e&&e,o,t.commandStr);var n="value"in e?e.value:1,r=!!e.invert;return M.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 M.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,p),A=function(e,t,r){var i=e.static,a=e.dynamic;function o(e){if(e in i){var t=n.id(i[e]);M.optional(function(){l.shader(Yi[e],t,M.guessCommand())});var r=ea(function(){return t});return r.id=t,r}if(e in a){var o=a[e];return ta(o,function(t,n){var r=t.invoke(n,o),i=n.def(t.shared.strings,".id(",r,")");return M.optional(function(){n(t.shared.shader,".shader(",Yi[e],",",i,",",t.command,");")}),i})}return null}var s,f=o(Ir),u=o(Br),c=null;return Zi(f)&&Zi(u)?(c=l.program(u.id,f.id,null,r),s=ea(function(e,t){return e.link(c)})):s=new Ji(f&&f.thisDep||u&&u.thisDep,f&&f.contextDep||u&&u.contextDep,f&&f.propDep||u&&u.propDep,function(e,t){var n,r=e.shared.shader;n=f?f.append(e,t):t.def(r,".",Ir);var i=r+".program("+(u?u.append(e,t):t.def(r,".",Br))+","+n;return M.optional(function(){i+=","+e.command}),t.def(i+")")}),{frag:f,vert:u,progVar:s,program:c}}(e,0,h);function E(e){var t=x[e];t&&(_[e]=t)}E(Pr),E(S(Fr));var T=Object.keys(_).length>0,O={framebuffer:b,draw:w,shader:A,state:_,dirty:T,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(O.profile=function(e){var t,n=e.static,r=e.dynamic;if(Rr in n){var i=!!n[Rr];(t=ea(function(e,t){return i})).enable=i}else if(Rr in r){var a=r[Rr];t=ta(a,function(e,t){return e.invoke(t,a)})}return t}(e),O.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=ea(function(){return a});else if("function"==typeof a){var o=a._reglType;"texture2d"===o||"textureCube"===o?r=ea(function(e){return e.link(a)}):"framebuffer"===o||"framebufferCube"===o?(M.command(a.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),r=ea(function(e){return e.link(a.color[0])})):M.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else Le(a)?r=ea(function(t){return t.global.def("[",W(a.length,function(n){return M.command("number"==typeof a[n]||"boolean"==typeof a[n],"invalid uniform "+e,t.commandStr),a[n]}),"]")}):M.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]=ta(t,function(e,n){return e.invoke(n,t)})}),i}(s,p),O.drawVAO=O.scopeVAO=function(e,t){var n=e.static,r=e.dynamic;if(Wr in n){var i=n[Wr];return null!==i&&null===c.getVAO(i)&&(i=c.createVAO(i)),ea(function(e){return e.link(c.getVAO(i))})}if(Wr in r){var a=r[Wr];return ta(a,function(e,t){var n=e.invoke(t,a);return t.def(e.shared.vao+".getVAO("+n+")")})}return null}(e),!O.drawVAO&&A.program&&!h&&r.angle_instanced_arrays){var j=!0,C=A.program.attributes.map(function(e){var n=t.static[e];return j=j&&!!n,n});if(j&&C.length>0){var D=c.getVAO(c.createVAO(C));O.drawVAO=new Ji(null,null,null,function(e,t){return e.link(D)}),O.useVAO=!0}}return h?O.useVAO=!0:O.attributes=function(e,t){var r=e.static,i=e.dynamic,o={};return Object.keys(r).forEach(function(e){var i=r[e],s=n.id(e),f=new v;if($i(i))f.state=nr,f.buffer=a.getBuffer(a.create(i,Zr,!1,!0)),f.type=0;else{var u=a.getBuffer(i);if(u)f.state=nr,f.buffer=u,f.type=0;else if(M.command("object"==typeof i&&i,"invalid data for attribute "+e,t.commandStr),"constant"in i){var c=i.constant;f.buffer="null",f.state=rr,"number"==typeof c?f.x=c:(M.command(Le(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,t.commandStr),er.forEach(function(e,t){t<c.length&&(f[e]=c[t])}))}else{u=$i(i.buffer)?a.getBuffer(a.create(i.buffer,Zr,!1,!0)):a.getBuffer(i.buffer),M.command(!!u,'missing buffer for attribute "'+e+'"',t.commandStr);var l=0|i.offset;M.command(l>=0,'invalid offset for attribute "'+e+'"',t.commandStr);var p=0|i.stride;M.command(p>=0&&p<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',t.commandStr);var d=0|i.size;M.command(!("size"in i)||d>0&&d<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',t.commandStr);var m=!!i.normalized,h=0;"type"in i&&(M.commandParameter(i.type,fe,"invalid type for attribute "+e,t.commandStr),h=fe[i.type]);var g=0|i.divisor;"divisor"in i&&(M.command(0===g||y,'cannot specify divisor for attribute "'+e+'", instancing not supported',t.commandStr),M.command(g>=0,'invalid divisor for attribute "'+e+'"',t.commandStr)),M.optional(function(){var n=t.commandStr,r=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach(function(t){M.command(r.indexOf(t)>=0,'unknown parameter "'+t+'" for attribute pointer "'+e+'" (valid parameters are '+r+")",n)})}),f.buffer=u,f.state=nr,f.size=d,f.normalized=m,f.type=h||u.dtype,f.offset=l,f.stride=p,f.divisor=g}}o[e]=ea(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(i).forEach(function(e){var t=i[e];o[e]=ta(t,function(n,r){var i=n.invoke(r,t),a=n.shared,o=n.constants,s=a.isBufferArgs,f=a.buffer;M.optional(function(){n.assert(r,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+s+"("+i+")||"+f+".getBuffer("+i+")||"+f+".getBuffer("+i+".buffer)||"+s+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+a.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+e+'"')});var u={isStream:r.def(!1)},c=new v;c.state=nr,Object.keys(c).forEach(function(e){u[e]=r.def(""+c[e])});var l=u.buffer,p=u.type;function d(e){r(u[e],"=",i,".",e,"|0;")}return r("if(",s,"(",i,")){",u.isStream,"=true;",l,"=",f,".createStream(",Zr,",",i,");",p,"=",l,".dtype;","}else{",l,"=",f,".getBuffer(",i,");","if(",l,"){",p,"=",l,".dtype;",'}else if("constant" in ',i,"){",u.state,"=",rr,";","if(typeof "+i+'.constant === "number"){',u[er[0]],"=",i,".constant;",er.slice(1).map(function(e){return u[e]}).join("="),"=0;","}else{",er.map(function(e,t){return u[e]+"="+i+".constant.length>"+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",s,"(",i,".buffer)){",l,"=",f,".createStream(",Zr,",",i,".buffer);","}else{",l,"=",f,".getBuffer(",i,".buffer);","}",p,'="type" in ',i,"?",o.glTypes,"[",i,".type]:",l,".dtype;",u.normalized,"=!!",i,".normalized;"),d("size"),d("offset"),d("stride"),d("divisor"),r("}}"),r.exit("if(",u.isStream,"){",f,".destroyStream(",l,");","}"),u})}),o}(t,p),O.context=function(e){var t=e.static,n=e.dynamic,r={};return Object.keys(t).forEach(function(e){var n=t[e];r[e]=ea(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]=ta(t,function(e,n){return e.invoke(n,t)})}),r}(u),O}function F(e,t,n){var r=e.shared.context,i=e.scope();Object.keys(n).forEach(function(a){t.save(r,"."+a),i(r,".",a,"=",n[a].append(e,t),";")}),t(i)}function P(e,t,n,r){var i,a=e.shared,o=a.gl,s=a.framebuffer;b&&(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(",Hi,",",f,".framebuffer);"),b&&t(i,".drawBuffersWEBGL(",c,"[",f,".colorAttachments.length]);"),t("}else{",o,".bindFramebuffer(",Hi,",null);"),b&&t(i,".drawBuffersWEBGL(",l,");"),t("}",s,".cur=",f,";"),r||t("}")}function R(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");k.forEach(function(t){var r,c,l=S(t);if(!(l in n.state))if(l in o){r=o[l],c=a[l];var p=W(x[l].length,function(e){return u.def(r,"[",e,"]")});u(e.cond(p.map(function(e,t){return e+"!=="+c+"["+t+"]"}).join("||")).then(i,".",A[l],"(",p,");",p.map(function(e,t){return c+"["+t+"]="+e}).join(";"),";"))}else{r=u.def(f,".",l);var d=e.cond(r,"!==",s,".",l);u(d),l in _?d(e.cond(r).then(i,".enable(",_[l],");").else(i,".disable(",_[l],");"),s,".",l,"=",r,";"):d(i,".",A[l],"(",r,");",s,".",l,"=",r,";")}}),0===Object.keys(n.state).length&&u(s,".dirty=false;"),t(u)}function L(e,t,n,r){var i=e.shared,a=e.current,o=i.current,s=i.gl;Xi(Object.keys(n)).forEach(function(i){var f=n[i];if(!r||r(f)){var u=f.append(e,t);if(_[i]){var c=_[i];Zi(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(Le(u)){var l=a[i];t(s,".",A[i],"(",u,");",u.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(s,".",A[i],"(",u,");",o,".",i,"=",u,";")}})}function B(e,t){y&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function V(e,t,n,r,i){var a,o,s,f=e.shared,u=e.stats,c=f.current,l=f.timer,p=n.profile;function d(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function h(e){e(a=t.def(),"=",d(),";"),"string"==typeof i?e(u,".count+=",i,";"):e(u,".count++;"),m&&(r?e(o=t.def(),"=",l,".getNumPendingQueries();"):e(l,".beginQuery(",u,");"))}function v(e){e(u,".cpuTime+=",d(),"-",a,";"),m&&(r?e(l,".pushScopeStats(",o,",",l,".getNumPendingQueries(),",u,");"):e(l,".endQuery();"))}function g(e){var n=t.def(c,".profile");t(c,".profile=",e,";"),t.exit(c,".profile=",n,";")}if(p){if(Zi(p))return void(p.enable?(h(t),v(t.exit),g("true")):g("false"));g(s=p.append(e,t))}else s=t.def(c,".profile");var y=e.block();h(y),t("if(",s,"){",y,"}");var b=e.block();v(b),t.exit("if(",s,"){",b,"}")}function N(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);M.optional(function(){e.assert(t,u+".state","missing attribute "+s)}),o={},Object.keys(new v).forEach(function(e){o[e]=t.def(u,".",e)})}!function(n,r,i){var o=a.gl,s=t.def(n,".location"),f=t.def(a.attributes,"[",s,"]"),u=i.state,c=i.buffer,l=[i.x,i.y,i.z,i.w],p=["buffer","normalized","offset","stride"];function d(){t("if(!",f,".buffer){",o,".enableVertexAttribArray(",s,");}");var n,a=i.type;if(n=i.size?t.def(i.size,"||",r):r,t("if(",f,".type!==",a,"||",f,".size!==",n,"||",p.map(function(e){return f+"."+e+"!=="+i[e]}).join("||"),"){",o,".bindBuffer(",Zr,",",c,".buffer);",o,".vertexAttribPointer(",[s,n,a,i.normalized,i.stride,i.offset],");",f,".type=",a,";",f,".size=",n,";",p.map(function(e){return f+"."+e+"="+i[e]+";"}).join(""),"}"),y){var u=i.divisor;t("if(",f,".divisor!==",u,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,u],");",f,".divisor=",u,";}")}}function m(){t("if(",f,".buffer){",o,".disableVertexAttribArray(",s,");",f,".buffer=null;","}if(",er.map(function(e,t){return f+"."+e+"!=="+l[t]}).join("||"),"){",o,".vertexAttrib4f(",s,",",l,");",er.map(function(e,t){return f+"."+e+"="+l[t]+";"}).join(""),"}")}u===nr?d():u===rr?m():(t("if(",u,"===",nr,"){"),d(),t("}else{"),m(),t("}"))}(e.link(r),function(e){switch(e){case di:case gi:case wi:return 2;case mi:case yi:case ki:return 3;case hi:case bi:case _i:return 4;default:return 1}}(r.info.type),o)})}function H(e,t,r,i,a){for(var o,s=e.shared,f=s.gl,u=0;u<i.length;++u){var c,l=i[u],p=l.name,d=l.info.type,m=r.uniforms[p],h=e.link(l)+".location";if(m){if(!a(m))continue;if(Zi(m)){var v=m.value;if(M.command(null!=v,'missing uniform "'+p+'"',e.commandStr),d===Ti||d===Oi){M.command("function"==typeof v&&(d===Ti&&("texture2d"===v._reglType||"framebuffer"===v._reglType)||d===Oi&&("textureCube"===v._reglType||"framebufferCube"===v._reglType)),"invalid texture for uniform "+p,e.commandStr);var g=e.link(v._texture||v.color[0]._texture);t(f,".uniform1i(",h,",",g+".bind());"),t.exit(g,".unbind();")}else if(d===Ai||d===Si||d===Ei){M.optional(function(){M.command(Le(v),"invalid matrix for uniform "+p,e.commandStr),M.command(d===Ai&&4===v.length||d===Si&&9===v.length||d===Ei&&16===v.length,"invalid length for matrix uniform "+p,e.commandStr)});var y=e.global.def("new Float32Array(["+Array.prototype.slice.call(v)+"])"),b=2;d===Si?b=3:d===Ei&&(b=4),t(f,".uniformMatrix",b,"fv(",h,",false,",y,");")}else{switch(d){case pi:M.commandType(v,"number","uniform "+p,e.commandStr),o="1f";break;case di:M.command(Le(v)&&2===v.length,"uniform "+p,e.commandStr),o="2f";break;case mi:M.command(Le(v)&&3===v.length,"uniform "+p,e.commandStr),o="3f";break;case hi:M.command(Le(v)&&4===v.length,"uniform "+p,e.commandStr),o="4f";break;case xi:M.commandType(v,"boolean","uniform "+p,e.commandStr),o="1i";break;case vi:M.commandType(v,"number","uniform "+p,e.commandStr),o="1i";break;case wi:case gi:M.command(Le(v)&&2===v.length,"uniform "+p,e.commandStr),o="2i";break;case ki:case yi:M.command(Le(v)&&3===v.length,"uniform "+p,e.commandStr),o="3i";break;case _i:case bi:M.command(Le(v)&&4===v.length,"uniform "+p,e.commandStr),o="4i"}t(f,".uniform",o,"(",h,",",Le(v)?Array.prototype.slice.call(v):v,");")}continue}c=m.append(e,t)}else{if(!a(na))continue;c=t.def(s.uniforms,"[",n.id(p),"]")}d===Ti?t("if(",c,"&&",c,'._reglType==="framebuffer"){',c,"=",c,".color[0];","}"):d===Oi&&t("if(",c,"&&",c,'._reglType==="framebufferCube"){',c,"=",c,".color[0];","}"),M.optional(function(){function n(n,r){e.assert(t,n,'bad data or missing for uniform "'+p+'". '+r)}function r(e){n("typeof "+c+'==="'+e+'"',"invalid type, expected "+e)}function i(e,t){n(s.isArrayLike+"("+c+")&&"+c+".length==="+e,"invalid vector, should have length "+e)}function a(e){n("typeof "+c+'==="function"&&'+c+'._reglType==="texture'+(e===ti?"2d":"Cube")+'"',"invalid texture type")}switch(d){case vi:r("number");break;case gi:i(2);break;case yi:i(3);break;case bi:i(4);break;case pi:r("number");break;case di:i(2);break;case mi:i(3);break;case hi:i(4);break;case xi:r("boolean");break;case wi:i(2);break;case ki:i(3);break;case _i:case Ai:i(4);break;case Si:i(9);break;case Ei:i(16);break;case Ti:a(ti);break;case Oi:a(ni)}});var x=1;switch(d){case Ti:case Oi:var w=t.def(c,"._texture");t(f,".uniform1i(",h,",",w,".bind());"),t.exit(w,".unbind();");continue;case vi:case xi:o="1i";break;case gi:case wi:o="2i",x=2;break;case yi:case ki:o="3i",x=3;break;case bi:case _i:o="4i",x=4;break;case pi:o="1f";break;case di:o="2f",x=2;break;case mi:o="3f",x=3;break;case hi:o="4f",x=4;break;case Ai:o="Matrix2fv";break;case Si:o="Matrix3fv";break;case Ei:o="Matrix4fv"}if(t(f,".uniform",o,"(",h,","),"M"===o.charAt(0)){var k=Math.pow(d-Ai+2,2),_=e.global.def("new Float32Array(",k,")");t("false,(Array.isArray(",c,")||",c," instanceof Float32Array)?",c,":(",W(k,function(e){return _+"["+e+"]="+c+"["+e+"]"}),",",_,")")}else t(x>1?W(x,function(e){return c+"["+e+"]"}):c);t(");")}}function U(e,t,n,r){var i=e.shared,a=i.gl,o=i.draw,s=r.draw;var f=function(){var i,f=s.elements,u=t;return f?((f.contextDep&&r.contextDynamic||f.propDep)&&(u=n),i=f.append(e,u)):i=u.def(o,".",Vr),i&&u("if("+i+")"+a+".bindBuffer("+ei+","+i+".buffer.buffer);"),i}();function u(i){var a=s[i];return a?a.append(e,a.contextDep&&r.contextDynamic||a.propDep?n:t):t.def(o,".",i)}var c,l,p=u(Nr),d=u(Ur),m=function(){var i,a=s.count,f=t;return a?((a.contextDep&&r.contextDynamic||a.propDep)&&(f=n),i=a.append(e,f),M.optional(function(){a.MISSING&&e.assert(t,"false","missing vertex count"),a.DYNAMIC&&e.assert(f,i+">=0","missing vertex count")})):(i=f.def(o,".",Hr),M.optional(function(){e.assert(f,i+">=0","missing vertex count")})),i}();if("number"==typeof m){if(0===m)return}else n("if(",m,"){"),n.exit("}");y&&(c=u(qr),l=e.instancing);var h=f+".type",v=s.elements&&Zi(s.elements);function g(){function e(){n(l,".drawElementsInstancedANGLE(",[p,m,h,d+"<<(("+h+"-"+tr+")>>1)",c],");")}function t(){n(l,".drawArraysInstancedANGLE(",[p,d,m,c],");")}f?v?e():(n("if(",f,"){"),e(),n("}else{"),t(),n("}")):t()}function b(){function e(){n(a+".drawElements("+[p,m,h,d+"<<(("+h+"-"+tr+")>>1)"]+");")}function t(){n(a+".drawArrays("+[p,d,m]+");")}f?v?e():(n("if(",f,"){"),e(),n("}else{"),t(),n("}")):t()}y&&("number"!=typeof c||c>=0)?"string"==typeof c?(n("if(",c,">0){"),g(),n("}else if(",c,"<0){"),b(),n("}")):g():b()}function q(e,t,n,r,i){var a=D(),o=a.proc("body",i);return M.optional(function(){a.commandStr=t.commandStr,a.command=a.link(t.commandStr)}),y&&(a.instancing=o.def(a.shared.extensions,".angle_instanced_arrays")),e(a,o,n,r),a.compile().body}function G(e,t,n,r){B(e,t),n.useVAO?n.drawVAO?t(e.shared.vao,".setVAO(",n.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),N(e,t,n,r.attributes,function(){return!0})),H(e,t,n,r.uniforms,function(){return!0}),U(e,t,t,n)}function Q(e,t,n,r){function i(){return!0}e.batchId="a1",B(e,t),N(e,t,n,r.attributes,i),H(e,t,n,r.uniforms,i),U(e,t,t,n)}function Y(e,t,n,r){B(e,t);var i=n.contextDep,a=t.def(),o=t.def();e.shared.props=o,e.batchId=a;var s=e.scope(),f=e.scope();function u(e){return e.contextDep&&i||e.propDep}function c(e){return!u(e)}if(t(s.entry,"for(",a,"=0;",a,"<","a1",";++",a,"){",o,"=","a0","[",a,"];",f,"}",s.exit),n.needsContext&&F(e,f,n.context),n.needsFramebuffer&&P(e,f,n.framebuffer),L(e,f,n.state,u),n.profile&&u(n.profile)&&V(e,f,n,!1,!0),r)n.useVAO?n.drawVAO?u(n.drawVAO)?f(e.shared.vao,".setVAO(",n.drawVAO.append(e,f),");"):s(e.shared.vao,".setVAO(",n.drawVAO.append(e,s),");"):s(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(s(e.shared.vao,".setVAO(null);"),N(e,s,n,r.attributes,c),N(e,f,n,r.attributes,u)),H(e,s,n,r.uniforms,c),H(e,f,n,r.uniforms,u),U(e,s,f,n);else{var l=e.global.def("{}"),p=n.shader.progVar.append(e,f),d=f.def(p,".id"),m=f.def(l,"[",d,"]");f(e.shared.gl,".useProgram(",p,".program);","if(!",m,"){",m,"=",l,"[",d,"]=",e.link(function(t){return q(Q,e,n,t,2)}),"(",p,");}",m,".call(this,a0[",a,"],",a,");")}}function K(e,t,n){var r=t.static[n];if(r&&function(e){if("object"==typeof e&&!Le(e)){for(var t=Object.keys(e),n=0;n<t.length;++n)if(I.isDynamic(e[t[n]]))return!0;return!1}}(r)){var i=e.global,a=Object.keys(r),o=!1,s=!1,f=!1,u=e.global.def("{}");a.forEach(function(t){var n=r[t];if(I.isDynamic(n)){"function"==typeof n&&(n=r[t]=I.unbox(n));var a=ta(n,null);o=o||a.thisDep,f=f||a.propDep,s=s||a.contextDep}else{switch(i(u,".",t,"="),typeof n){case"number":i(n);break;case"string":i('"',n,'"');break;case"object":Array.isArray(n)&&i("[",n.join(),"]");break;default:i(e.link(n))}i(";")}}),t.dynamic[n]=new I.DynamicVariable(fr,{thisDep:o,contextDep:s,propDep:f,ref:u,append:function(e,t){a.forEach(function(n){var i=r[n];if(I.isDynamic(i)){var a=e.invoke(t,i);t(u,".",n,"=",a,";")}})}}),delete t.static[n]}}return{next:w,current:x,procs:function(){var e=D(),t=e.proc("poll"),n=e.proc("refresh"),a=e.block();t(a),n(a);var o,s=e.shared,f=s.gl,u=s.next,c=s.current;a(c,".dirty=false;"),P(e,t),P(e,n,null,!0),y&&(o=e.link(y)),r.oes_vertex_array_object&&n(e.link(r.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var l=0;l<i.maxAttributes;++l){var p=n.def(s.attributes,"[",l,"]"),d=e.cond(p,".buffer");d.then(f,".enableVertexAttribArray(",l,");",f,".bindBuffer(",Zr,",",p,".buffer.buffer);",f,".vertexAttribPointer(",l,",",p,".size,",p,".type,",p,".normalized,",p,".stride,",p,".offset);").else(f,".disableVertexAttribArray(",l,");",f,".vertexAttrib4f(",l,",",p,".x,",p,".y,",p,".z,",p,".w);",p,".buffer=null;"),n(d),y&&n(o,".vertexAttribDivisorANGLE(",l,",",p,".divisor);")}return n(e.shared.vao,".currentVAO=null;",e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"),Object.keys(_).forEach(function(r){var i=_[r],o=a.def(u,".",r),s=e.block();s("if(",o,"){",f,".enable(",i,")}else{",f,".disable(",i,")}",c,".",r,"=",o,";"),n(s),t("if(",o,"!==",c,".",r,"){",s,"}")}),Object.keys(A).forEach(function(r){var i,o,s=A[r],l=x[r],p=e.block();if(p(f,".",s,"("),Le(l)){var d=l.length;i=e.global.def(u,".",r),o=e.global.def(c,".",r),p(W(d,function(e){return i+"["+e+"]"}),");",W(d,function(e){return o+"["+e+"]="+i+"["+e+"];"}).join("")),t("if(",W(d,function(e){return i+"["+e+"]!=="+o+"["+e+"]"}).join("||"),"){",p,"}")}else i=a.def(u,".",r),o=a.def(c,".",r),p(i,");",c,".",r,"=",i,";"),t("if(",i,"!==",o,"){",p,"}");n(p)}),e.compile()}(),compile:function(e,t,r,i,a){var o=D();o.stats=o.link(a),Object.keys(t.static).forEach(function(e){K(o,t,e)}),Jr.forEach(function(t){K(o,e,t)});var s=z(e,t,r,i,o);return function(e,t){var n=e.proc("draw",1);B(e,n),F(e,n,t.context),P(e,n,t.framebuffer),R(e,n,t),L(e,n,t.state),V(e,n,t,!1,!0);var r=t.shader.progVar.append(e,n);if(n(e.shared.gl,".useProgram(",r,".program);"),t.shader.program)G(e,n,t,t.shader.program);else{n(e.shared.vao,".setVAO(null);");var i=e.global.def("{}"),a=n.def(r,".id"),o=n.def(i,"[",a,"]");n(e.cond(o).then(o,".call(this,a0);").else(o,"=",i,"[",a,"]=",e.link(function(n){return q(G,e,t,n,1)}),"(",r,");",o,".call(this,a0);"))}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;")}(o,s),function(e,t){var r=e.proc("scope",3);e.batchId="a2";var i=e.shared,a=i.current;function o(n){var a=t.shader[n];a&&r.set(i.shader,"."+n,a.append(e,r))}F(e,r,t.context),t.framebuffer&&t.framebuffer.append(e,r),Xi(Object.keys(t.state)).forEach(function(n){var a=t.state[n].append(e,r);Le(a)?a.forEach(function(t,i){r.set(e.next[n],"["+i+"]",t)}):r.set(i.next,"."+n,a)}),V(e,r,t,!0,!0),[Vr,Ur,Hr,qr,Nr].forEach(function(n){var a=t.draw[n];a&&r.set(i.draw,"."+n,""+a.append(e,r))}),Object.keys(t.uniforms).forEach(function(a){r.set(i.uniforms,"["+n.id(a)+"]",t.uniforms[a].append(e,r))}),Object.keys(t.attributes).forEach(function(n){var i=t.attributes[n].append(e,r),a=e.scopeAttrib(n);Object.keys(new v).forEach(function(e){r.set(a,"."+e,i[e])})}),t.scopeVAO&&r.set(i.vao,".targetVAO",t.scopeVAO.append(e,r)),o(Br),o(Ir),Object.keys(t.state).length>0&&(r(a,".dirty=true;"),r.exit(a,".dirty=true;")),r("a1(",e.shared.context,",a0,",e.batchId,");")}(o,s),function(e,t){var n=e.proc("batch",2);e.batchId="0",B(e,n);var r=!1,i=!0;Object.keys(t.context).forEach(function(e){r=r||t.context[e].propDep}),r||(F(e,n,t.context),i=!1);var a=t.framebuffer,o=!1;function s(e){return e.contextDep&&r||e.propDep}a?(a.propDep?r=o=!0:a.contextDep&&r&&(o=!0),o||P(e,n,a)):P(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(r=!0),R(e,n,t),L(e,n,t.state,function(e){return!s(e)}),t.profile&&s(t.profile)||V(e,n,t,!1,"a1"),t.contextDep=r,t.needsContext=i,t.needsFramebuffer=o;var f=t.shader.progVar;if(f.contextDep&&r||f.propDep)Y(e,n,t,null);else{var u=f.append(e,n);if(n(e.shared.gl,".useProgram(",u,".program);"),t.shader.program)Y(e,n,t,t.shader.program);else{n(e.shared.vao,".setVAO(null);");var c=e.global.def("{}"),l=n.def(u,".id"),p=n.def(c,"[",l,"]");n(e.cond(p).then(p,".call(this,a0,a1);").else(p,"=",c,"[",l,"]=",e.link(function(n){return q(Y,e,t,n,2)}),"(",u,");",p,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;")}(o,s),o.compile()}}}var ia=34918,aa=34919,oa=35007,sa=function(e,t){if(!t.ext_disjoint_timer_query)return null;var n=[];function r(e){n.push(e)}var i=[];function a(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var o=[];function s(e){o.push(e)}var f=[];function u(e,t,n){var r=o.pop()||new a;r.startQueryIndex=e,r.endQueryIndex=t,r.sum=0,r.stats=n,f.push(r)}var c=[],l=[];return{beginQuery:function(e){var r=n.pop()||t.ext_disjoint_timer_query.createQueryEXT();t.ext_disjoint_timer_query.beginQueryEXT(oa,r),i.push(r),u(i.length-1,i.length,e)},endQuery:function(){t.ext_disjoint_timer_query.endQueryEXT(oa)},pushScopeStats:u,update:function(){var e,n,a=i.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,n=0;n<i.length;++n){var u=i[n];t.ext_disjoint_timer_query.getQueryObjectEXT(u,aa)?(o+=t.ext_disjoint_timer_query.getQueryObjectEXT(u,ia),r(u)):i[e++]=u,c[n+1]=o,l[n+1]=e}for(i.length=e,e=0,n=0;n<f.length;++n){var p=f[n],d=p.startQueryIndex,m=p.endQueryIndex;p.sum+=c[m]-c[d];var h=l[d],v=l[m];v===h?(p.stats.gpuTime+=p.sum/1e6,s(p)):(p.startQueryIndex=h,p.endQueryIndex=v,f[e++]=p)}f.length=e}},getNumPendingQueries:function(){return i.length},clear:function(){n.push.apply(n,i);for(var e=0;e<n.length;e++)t.ext_disjoint_timer_query.deleteQueryEXT(n[e]);i.length=0,n.length=0},restore:function(){i.length=0,n.length=0}}},fa=16384,ua=256,ca=1024,la=34962,pa="webglcontextlost",da="webglcontextrestored",ma=1,ha=2,va=3;function ga(e,t){for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1}return function(n){var r=q(n);if(!r)return null;var i=r.gl,a=i.getContextAttributes(),o=i.isContextLost(),s=function(e,t){var n={};function r(t){M.type(t,"string","extension name must be string");var r,i=t.toLowerCase();try{r=n[i]=e.getExtension(i)}catch(e){}return!!r}for(var i=0;i<t.extensions.length;++i){var a=t.extensions[i];if(!r(a))return t.onDestroy(),t.onDone('"'+a+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return t.optionalExtensions.forEach(r),{extensions:n,restore:function(){Object.keys(n).forEach(function(e){if(n[e]&&!r(e))throw new Error("(regl): error restoring extension "+e)})}}}(i,r);if(!s)return null;var f,u,c=(f={"":0},u=[""],{id:function(e){var t=f[e];return t||(t=f[e]=u.length,u.push(e),t)},str:function(e){return u[e]}}),l={vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},p=s.extensions,d=sa(i,p),m=N(),h=i.drawingBufferWidth,v=i.drawingBufferHeight,g={tick:0,time:0,viewportWidth:h,viewportHeight:v,framebufferWidth:h,framebufferHeight:v,drawingBufferWidth:h,drawingBufferHeight:v,pixelRatio:r.pixelRatio},y=ne(i,p),b=function(t,n,r,i){var a=0,o={};function s(e){this.id=a++,this.buffer=t.createBuffer(),this.type=e,this.usage=pe,this.byteLength=0,this.dimension=1,this.dtype=me,this.persistentData=null,r.profile&&(this.stats={size:0})}s.prototype.bind=function(){t.bindBuffer(this.type,this.buffer)},s.prototype.destroy=function(){l(this)};var f=[];function u(e,n,r){e.byteLength=n.byteLength,t.bufferData(e.type,n,r)}function c(t,n,r,i,a,o){var s,f;if(t.usage=r,Array.isArray(n)){if(t.dtype=i||he,n.length>0)if(Array.isArray(n[0])){s=le(n);for(var c=1,l=1;l<s.length;++l)c*=s[l];t.dimension=c,u(t,f=ce(n,s,t.dtype),r),o?t.persistentData=f:te.freeType(f)}else if("number"==typeof n[0]){t.dimension=a;var p=te.allocType(t.dtype,n.length);ye(p,n),u(t,p,r),o?t.persistentData=p:te.freeType(p)}else e(n[0])?(t.dimension=n[0].length,t.dtype=i||ge(n[0])||he,u(t,f=ce(n,[n.length,n[0].length],t.dtype),r),o?t.persistentData=f:te.freeType(f)):M.raise("invalid buffer data")}else if(e(n))t.dtype=i||ge(n),t.dimension=a,u(t,n,r),o&&(t.persistentData=new Uint8Array(new Uint8Array(n.buffer)));else if(re(n)){var d=n.stride,m=n.offset,h=0,v=0,g=0,y=0;1===(s=n.shape).length?(h=s[0],v=1,g=d[0],y=0):2===s.length?(h=s[0],v=s[1],g=d[0],y=d[1]):M.raise("invalid shape"),t.dtype=i||ge(n.data)||he,t.dimension=v;var b=te.allocType(t.dtype,h*v);be(b,n.data,h,v,g,y,m),u(t,b,r),o?t.persistentData=b:te.freeType(b)}else n instanceof ArrayBuffer?(t.dtype=me,t.dimension=a,u(t,n,r),o&&(t.persistentData=new Uint8Array(new Uint8Array(n)))):M.raise("invalid buffer data")}function l(e){n.bufferCount--,i(e);var r=e.buffer;M(r,"buffer must not be deleted already"),t.deleteBuffer(r),e.buffer=null,delete o[e.id]}return r.profile&&(n.getTotalBufferSize=function(){var e=0;return Object.keys(o).forEach(function(t){e+=o[t].stats.size}),e}),{create:function(i,a,f,u){n.bufferCount++;var p=new s(a);function d(n){var i=pe,a=null,o=0,s=0,f=1;return Array.isArray(n)||e(n)||re(n)||n instanceof ArrayBuffer?a=n:"number"==typeof n?o=0|n:n&&(M.type(n,"object","buffer arguments must be an object, a number or an array"),"data"in n&&(M(null===a||Array.isArray(a)||e(a)||re(a),"invalid data for buffer"),a=n.data),"usage"in n&&(M.parameter(n.usage,ue,"invalid buffer usage"),i=ue[n.usage]),"type"in n&&(M.parameter(n.type,fe,"invalid buffer type"),s=fe[n.type]),"dimension"in n&&(M.type(n.dimension,"number","invalid dimension"),f=0|n.dimension),"length"in n&&(M.nni(o,"buffer length must be a nonnegative integer"),o=0|n.length)),p.bind(),a?c(p,a,i,s,f,u):(o&&t.bufferData(p.type,o,i),p.dtype=s||me,p.usage=i,p.dimension=f,p.byteLength=o),r.profile&&(p.stats.size=p.byteLength*ve[p.dtype]),d}function m(e,n){M(n+e.byteLength<=p.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+e.byteLength+" starting from offset "+n+" to a buffer of size "+p.byteLength),t.bufferSubData(p.type,n,e)}return o[p.id]=p,f||d(i),d._reglType="buffer",d._buffer=p,d.subdata=function(t,n){var r,i=0|(n||0);if(p.bind(),e(t)||t instanceof ArrayBuffer)m(t,i);else if(Array.isArray(t)){if(t.length>0)if("number"==typeof t[0]){var a=te.allocType(p.dtype,t.length);ye(a,t),m(a,i),te.freeType(a)}else if(Array.isArray(t[0])||e(t[0])){r=le(t);var o=ce(t,r,p.dtype);m(o,i),te.freeType(o)}else M.raise("invalid buffer data")}else if(re(t)){var s=t.stride,f=0,u=0,c=0,l=0;1===(r=t.shape).length?(f=r[0],u=1,c=s[0],l=0):2===r.length?(f=r[0],u=r[1],c=s[0],l=s[1]):M.raise("invalid shape");var h=Array.isArray(t.data)?p.dtype:ge(t.data),v=te.allocType(h,f*u);be(v,t.data,f,u,c,l,t.offset),m(v,i),te.freeType(v)}else M.raise("invalid data for buffer subdata");return d},r.profile&&(d.stats=p.stats),d.destroy=function(){l(p)},d},createStream:function(e,t){var n=f.pop();return n||(n=new s(e)),n.bind(),c(n,t,de,0,1,!1),n},destroyStream:function(e){f.push(e)},clear:function(){ie(o).forEach(l),f.forEach(l)},getBuffer:function(e){return e&&e._buffer instanceof s?e._buffer:null},restore:function(){ie(o).forEach(function(e){e.buffer=t.createBuffer(),t.bindBuffer(e.type,e.buffer),t.bufferData(e.type,e.persistentData||e.byteLength,e.usage)})},_initBuffer:c}}(i,l,r,function(e){return x.destroyBuffer(e)}),x=function(t,n,r,i,a){for(var o=r.maxAttributes,s=new Array(o),f=0;f<o;++f)s[f]=new Hn;var u=0,c={},l={Record:Hn,scope:{},state:s,currentVAO:null,targetVAO:null,restore:p()?function(){p()&&ie(c).forEach(function(e){e.refresh()})}:function(){},createVAO:function(t){var r=new m;function s(t){M(Array.isArray(t),"arguments to vertex array constructor must be an array"),M(t.length<o,"too many attributes"),M(t.length>0,"must specify at least one attribute");for(var i=0;i<r.buffers.length;++i)r.buffers[i].destroy();r.buffers.length=0;var f=r.attributes;f.length=t.length;for(var u=0;u<t.length;++u){var c=t[u],l=f[u]=new Hn;if(Array.isArray(c)||e(c)||re(c)){var p=a.create(c,Nn,!1,!0);l.buffer=a.getBuffer(p),l.size=0|l.buffer.dimension,l.normalized=!1,l.type=l.buffer.dtype,l.offset=0,l.stride=0,l.divisor=0,l.state=1,r.buffers.push(p)}else a.getBuffer(c)?(l.buffer=a.getBuffer(c),l.size=0|l.buffer.dimension,l.normalized=!1,l.type=l.buffer.dtype,l.offset=0,l.stride=0,l.divisor=0,l.state=1):a.getBuffer(c.buffer)?(l.buffer=a.getBuffer(c.buffer),l.size=0|(+c.size||l.buffer.dimension),l.normalized=!!c.normalized||!1,"type"in c?(M.parameter(c.type,fe,"invalid buffer type"),l.type=fe[c.type]):l.type=l.buffer.dtype,l.offset=0|(c.offset||0),l.stride=0|(c.stride||0),l.divisor=0|(c.divisor||0),l.state=1,M(l.size>=1&&l.size<=4,"size must be between 1 and 4"),M(l.offset>=0,"invalid offset"),M(l.stride>=0&&l.stride<=255,"stride must be between 0 and 255"),M(l.divisor>=0,"divisor must be positive"),M(!l.divisor||!!n.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in c?(M(u>0,"first attribute must not be a constant"),l.x=+c.x||0,l.y=+c.y||0,l.z=+c.z||0,l.w=+c.w||0,l.state=2):M(!1,"invalid attribute spec for location "+u)}return r.refresh(),s}return i.vaoCount+=1,s.destroy=function(){r.destroy()},s._vao=r,s._reglType="vao",s(t)},getVAO:function(e){return"function"==typeof e&&e._vao?e._vao:null},destroyBuffer:function(e){for(var n=0;n<s.length;++n){var r=s[n];r.buffer===e&&(t.disableVertexAttribArray(n),r.buffer=null)}},setVAO:p()?function(e){if(e!==l.currentVAO){var t=p();t.bindVertexArrayOES(e?e.vao:null),l.currentVAO=e}}:function(e){if(e!==l.currentVAO){if(e)e.bindAttrs();else for(var n=d(),r=0;r<s.length;++r){var i=s[r];i.buffer?(t.enableVertexAttribArray(r),t.vertexAttribPointer(r,i.size,i.type,i.normalized,i.stride,i.offfset),n&&n.vertexAttribDivisorANGLE(r,i.divisor)):(t.disableVertexAttribArray(r),t.vertexAttrib4f(r,i.x,i.y,i.z,i.w))}l.currentVAO=e}},clear:p()?function(){ie(c).forEach(function(e){e.destroy()})}:function(){}};function p(){return n.oes_vertex_array_object}function d(){return n.angle_instanced_arrays}function m(){this.id=++u,this.attributes=[];var e=p();this.vao=e?e.createVertexArrayOES():null,c[this.id]=this,this.buffers=[]}return m.prototype.bindAttrs=function(){for(var e=d(),n=this.attributes,r=0;r<n.length;++r){var i=n[r];i.buffer?(t.enableVertexAttribArray(r),t.bindBuffer(Nn,i.buffer.buffer),t.vertexAttribPointer(r,i.size,i.type,i.normalized,i.stride,i.offset),e&&e.vertexAttribDivisorANGLE(r,i.divisor)):(t.disableVertexAttribArray(r),t.vertexAttrib4f(r,i.x,i.y,i.z,i.w))}for(var a=n.length;a<o;++a)t.disableVertexAttribArray(a)},m.prototype.refresh=function(){var e=p();e&&(e.bindVertexArrayOES(this.vao),this.bindAttrs(),l.currentVAO=this)},m.prototype.destroy=function(){if(this.vao){var e=p();this===l.currentVAO&&(l.currentVAO=null,e.bindVertexArrayOES(null)),e.deleteVertexArrayOES(this.vao),this.vao=null}c[this.id]&&(delete c[this.id],i.vaoCount-=1)},l}(i,p,y,l,b),w=function(t,n,r,i){var a={},o=0,s={uint8:Se,uint16:Te};function f(e){this.id=o++,a[this.id]=this,this.buffer=e,this.primType=_e,this.vertCount=0,this.type=0}n.oes_element_index_uint&&(s.uint32=je),f.prototype.bind=function(){this.buffer.bind()};var u=[];function c(i,a,o,s,f,u,c){var l;if(i.buffer.bind(),a){var p=c;c||e(a)&&(!re(a)||e(a.data))||(p=n.oes_element_index_uint?je:Te),r._initBuffer(i.buffer,a,o,p,3)}else t.bufferData(Ce,u,o),i.buffer.dtype=l||Se,i.buffer.usage=o,i.buffer.dimension=3,i.buffer.byteLength=u;if(l=c,!c){switch(i.buffer.dtype){case Se:case Ae:l=Se;break;case Te:case Ee:l=Te;break;case je:case Oe:l=je;break;default:M.raise("unsupported type for element array")}i.buffer.dtype=l}i.type=l,M(l!==je||!!n.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var d=f;d<0&&(d=i.buffer.byteLength,l===Te?d>>=1:l===je&&(d>>=2)),i.vertCount=d;var m=s;if(s<0){m=_e;var h=i.buffer.dimension;1===h&&(m=we),2===h&&(m=ke),3===h&&(m=_e)}i.primType=m}function l(e){i.elementsCount--,M(null!==e.buffer,"must not double destroy elements"),delete a[e.id],e.buffer.destroy(),e.buffer=null}return{create:function(t,n){var a=r.create(null,Ce,!0),o=new f(a._buffer);function u(t){if(t)if("number"==typeof t)a(t),o.primType=_e,o.vertCount=0|t,o.type=Se;else{var n=null,r=ze,i=-1,f=-1,l=0,p=0;Array.isArray(t)||e(t)||re(t)?n=t:(M.type(t,"object","invalid arguments for elements"),"data"in t&&(n=t.data,M(Array.isArray(n)||e(n)||re(n),"invalid data for element buffer")),"usage"in t&&(M.parameter(t.usage,ue,"invalid element buffer usage"),r=ue[t.usage]),"primitive"in t&&(M.parameter(t.primitive,xe,"invalid element buffer primitive"),i=xe[t.primitive]),"count"in t&&(M("number"==typeof t.count&&t.count>=0,"invalid vertex count for elements"),f=0|t.count),"type"in t&&(M.parameter(t.type,s,"invalid buffer type"),p=s[t.type]),"length"in t?l=0|t.length:(l=f,p===Te||p===Ee?l*=2:p!==je&&p!==Oe||(l*=4))),c(o,n,r,i,f,l,p)}else a(),o.primType=_e,o.vertCount=0,o.type=Se;return u}return i.elementsCount++,u(t),u._reglType="elements",u._elements=o,u.subdata=function(e,t){return a.subdata(e,t),u},u.destroy=function(){l(o)},u},createStream:function(e){var t=u.pop();return t||(t=new f(r.create(null,Ce,!0,!1)._buffer)),c(t,e,De,-1,-1,0,0),t},destroyStream:function(e){u.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof f?e._elements:null},clear:function(){ie(a).forEach(l)}}}(i,p,b,l),k=function(e,t,n,r){var i={},a={};function o(e,t,n,r){this.name=e,this.id=t,this.location=n,this.info=r}function s(e,t){for(var n=0;n<e.length;++n)if(e[n].id===t.id)return void(e[n].location=t.location);e.push(t)}function f(n,r,o){var s=n===Un?i:a,f=s[r];if(!f){var u=t.str(r);f=e.createShader(n),e.shaderSource(f,u),e.compileShader(f),M.shaderError(e,f,u,n,o),s[r]=f}return f}var u={},c=[],l=0;function p(e,t){this.id=l++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],r.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function d(n,i,a){var u,c,l=f(Un,n.fragId),p=f(qn,n.vertId),d=n.program=e.createProgram();if(e.attachShader(d,l),e.attachShader(d,p),a)for(u=0;u<a.length;++u){var m=a[u];e.bindAttribLocation(d,m[0],m[1])}e.linkProgram(d),M.linkError(e,d,t.str(n.fragId),t.str(n.vertId),i);var h=e.getProgramParameter(d,Wn);r.profile&&(n.stats.uniformsCount=h);var v=n.uniforms;for(u=0;u<h;++u)if(c=e.getActiveUniform(d,u))if(c.size>1)for(var g=0;g<c.size;++g){var y=c.name.replace("[0]","["+g+"]");s(v,new o(y,t.id(y),e.getUniformLocation(d,y),c))}else s(v,new o(c.name,t.id(c.name),e.getUniformLocation(d,c.name),c));var b=e.getProgramParameter(d,Gn);r.profile&&(n.stats.attributesCount=b);var x=n.attributes;for(u=0;u<b;++u)(c=e.getActiveAttrib(d,u))&&s(x,new o(c.name,t.id(c.name),e.getAttribLocation(d,c.name),c))}return r.profile&&(n.getMaxUniformsCount=function(){var e=0;return c.forEach(function(t){t.stats.uniformsCount>e&&(e=t.stats.uniformsCount)}),e},n.getMaxAttributesCount=function(){var e=0;return c.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);ie(i).forEach(t),i={},ie(a).forEach(t),a={},c.forEach(function(t){e.deleteProgram(t.program)}),c.length=0,u={},n.shaderCount=0},program:function(e,t,r,i){M.command(e>=0,"missing vertex shader",r),M.command(t>=0,"missing fragment shader",r);var a=u[t];a||(a=u[t]={});var o=a[e];if(o&&!i)return o;var s=new p(t,e);return n.shaderCount++,d(s,r,i),o||(a[e]=s),c.push(s),s},restore:function(){i={},a={};for(var e=0;e<c.length;++e)d(c[e],null,c[e].attributes.map(function(e){return[e.location,e.name]}))},shader:f,frag:-1,vert:-1}}(i,c,l,r),_=vn(i,p,y,function(){E.procs.poll()},g,l,r),A=wn(i,p,y,l,r),S=function(e,n,r,i,a,o){var s={cur:null,next:null,dirty:!1,setFBO:null},f=["rgba"],u=["rgba4","rgb565","rgb5 a1"];n.ext_srgb&&u.push("srgba"),n.ext_color_buffer_half_float&&u.push("rgba16f","rgb16f"),n.webgl_color_buffer_float&&u.push("rgba32f");var c=["uint8"];function l(e,t,n){this.target=e,this.texture=t,this.renderbuffer=n;var r=0,i=0;t?(r=t.width,i=t.height):n&&(r=n.width,i=n.height),this.width=r,this.height=i}function p(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function d(e,t,n){if(e)if(e.texture){var r=e.texture._texture,i=Math.max(1,r.width),a=Math.max(1,r.height);M(i===t&&a===n,"inconsistent width/height for supplied texture"),r.refCount+=1}else{var o=e.renderbuffer._renderbuffer;M(o.width===t&&o.height===n,"inconsistent width/height for renderbuffer"),o.refCount+=1}}function m(t,n){n&&(n.texture?e.framebufferTexture2D(kn,t,n.target,n.texture._texture.texture,0):e.framebufferRenderbuffer(kn,t,_n,n.renderbuffer._renderbuffer.renderbuffer))}function h(e){var t=An,n=null,r=null,i=e;"object"==typeof e&&(i=e.data,"target"in e&&(t=0|e.target)),M.type(i,"function","invalid attachment data");var a=i._reglType;return"texture2d"===a?(n=i,M(t===An)):"textureCube"===a?(n=i,M(t>=Sn&&t<Sn+6,"invalid cube map target")):"renderbuffer"===a?(r=i,t=_n):M.raise("invalid regl object for attachment"),new l(t,n,r)}function v(e,t,n,r,o){if(n){var s=i.create2D({width:e,height:t,format:r,type:o});return s._texture.refCount=0,new l(An,s,null)}var f=a.create({width:e,height:t,format:r});return f._renderbuffer.refCount=0,new l(_n,null,f)}function g(e){return e&&(e.texture||e.renderbuffer)}function y(e,t,n){e&&(e.texture?e.texture.resize(t,n):e.renderbuffer&&e.renderbuffer.resize(t,n),e.width=t,e.height=n)}n.oes_texture_half_float&&c.push("half float","float16"),n.oes_texture_float&&c.push("float","float32");var b=0,x={};function w(){this.id=b++,x[this.id]=this,this.framebuffer=e.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function k(e){e.colorAttachments.forEach(p),p(e.depthAttachment),p(e.stencilAttachment),p(e.depthStencilAttachment)}function _(t){var n=t.framebuffer;M(n,"must not double destroy framebuffer"),e.deleteFramebuffer(n),t.framebuffer=null,o.framebufferCount--,delete x[t.id]}function A(t){var n;e.bindFramebuffer(kn,t.framebuffer);var i=t.colorAttachments;for(n=0;n<i.length;++n)m(En+n,i[n]);for(n=i.length;n<r.maxColorAttachments;++n)e.framebufferTexture2D(kn,En+n,An,null,0);e.framebufferTexture2D(kn,jn,An,null,0),e.framebufferTexture2D(kn,Tn,An,null,0),e.framebufferTexture2D(kn,On,An,null,0),m(Tn,t.depthAttachment),m(On,t.stencilAttachment),m(jn,t.depthStencilAttachment);var a=e.checkFramebufferStatus(kn);e.isContextLost()||a===Cn||M.raise("framebuffer configuration not supported, status = "+In[a]),e.bindFramebuffer(kn,s.next?s.next.framebuffer:null),s.cur=s.next,e.getError()}function S(e,i){var a=new w;function l(e,t){var i;M(s.next!==a,"can not update framebuffer which is currently in use");var o=0,p=0,m=!0,y=!0,b=null,x=!0,w="rgba",_="uint8",S=1,E=null,T=null,O=null,j=!1;if("number"==typeof e)o=0|e,p=0|t||o;else if(e){M.type(e,"object","invalid arguments for framebuffer");var C=e;if("shape"in C){var D=C.shape;M(Array.isArray(D)&&D.length>=2,"invalid shape for framebuffer"),o=D[0],p=D[1]}else"radius"in C&&(o=p=C.radius),"width"in C&&(o=C.width),"height"in C&&(p=C.height);("color"in C||"colors"in C)&&(b=C.color||C.colors,Array.isArray(b)&&M(1===b.length||n.webgl_draw_buffers,"multiple render targets not supported")),b||("colorCount"in C&&M((S=0|C.colorCount)>0,"invalid color buffer count"),"colorTexture"in C&&(x=!!C.colorTexture,w="rgba4"),"colorType"in C&&(_=C.colorType,x?(M(n.oes_texture_float||!("float"===_||"float32"===_),"you must enable OES_texture_float in order to use floating point framebuffer objects"),M(n.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"===_?(M(n.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),w="rgba16f"):"float"!==_&&"float32"!==_||(M(n.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),w="rgba32f"),M.oneOf(_,c,"invalid color type")),"colorFormat"in C&&(f.indexOf(w=C.colorFormat)>=0?x=!0:u.indexOf(w)>=0?x=!1:x?M.oneOf(C.colorFormat,f,"invalid color format for texture"):M.oneOf(C.colorFormat,u,"invalid color format for renderbuffer"))),("depthTexture"in C||"depthStencilTexture"in C)&&M(!(j=!(!C.depthTexture&&!C.depthStencilTexture))||n.webgl_depth_texture,"webgl_depth_texture extension not supported"),"depth"in C&&("boolean"==typeof C.depth?m=C.depth:(E=C.depth,y=!1)),"stencil"in C&&("boolean"==typeof C.stencil?y=C.stencil:(T=C.stencil,m=!1)),"depthStencil"in C&&("boolean"==typeof C.depthStencil?m=y=C.depthStencil:(O=C.depthStencil,m=!1,y=!1))}else o=p=1;var z=null,F=null,P=null,R=null;if(Array.isArray(b))z=b.map(h);else if(b)z=[h(b)];else for(z=new Array(S),i=0;i<S;++i)z[i]=v(o,p,x,w,_);M(n.webgl_draw_buffers||z.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),M(z.length<=r.maxColorAttachments,"too many color attachments, not supported"),o=o||z[0].width,p=p||z[0].height,E?F=h(E):m&&!y&&(F=v(o,p,j,"depth","uint32")),T?P=h(T):y&&!m&&(P=v(o,p,!1,"stencil","uint8")),O?R=h(O):!E&&!T&&y&&m&&(R=v(o,p,j,"depth stencil","depth stencil")),M(!!E+!!T+!!O<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var L=null;for(i=0;i<z.length;++i)if(d(z[i],o,p),M(!z[i]||z[i].texture&&zn.indexOf(z[i].texture._texture.format)>=0||z[i].renderbuffer&&Bn.indexOf(z[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),z[i]&&z[i].texture){var B=Mn[z[i].texture._texture.format]*Fn[z[i].texture._texture.type];null===L?L=B:M(L===B,"all color attachments much have the same number of bits per pixel.")}return d(F,o,p),M(!F||F.texture&&F.texture._texture.format===Dn||F.renderbuffer&&F.renderbuffer._renderbuffer.format===Pn,"invalid depth attachment for framebuffer object"),d(P,o,p),M(!P||P.renderbuffer&&P.renderbuffer._renderbuffer.format===Rn,"invalid stencil attachment for framebuffer object"),d(R,o,p),M(!R||R.texture&&R.texture._texture.format===Ln||R.renderbuffer&&R.renderbuffer._renderbuffer.format===Ln,"invalid depth-stencil attachment for framebuffer object"),k(a),a.width=o,a.height=p,a.colorAttachments=z,a.depthAttachment=F,a.stencilAttachment=P,a.depthStencilAttachment=R,l.color=z.map(g),l.depth=g(F),l.stencil=g(P),l.depthStencil=g(R),l.width=a.width,l.height=a.height,A(a),l}return o.framebufferCount++,l(e,i),t(l,{resize:function(e,t){M(s.next!==a,"can not resize a framebuffer which is currently in use");var n=Math.max(0|e,1),r=Math.max(0|t||n,1);if(n===a.width&&r===a.height)return l;for(var i=a.colorAttachments,o=0;o<i.length;++o)y(i[o],n,r);return y(a.depthAttachment,n,r),y(a.stencilAttachment,n,r),y(a.depthStencilAttachment,n,r),a.width=l.width=n,a.height=l.height=r,A(a),l},_reglType:"framebuffer",_framebuffer:a,destroy:function(){_(a),k(a)},use:function(e){s.setFBO({framebuffer:l},e)}})}return t(s,{getFramebuffer:function(e){if("function"==typeof e&&"framebuffer"===e._reglType){var t=e._framebuffer;if(t instanceof w)return t}return null},create:S,createCube:function(e){var a=Array(6);function o(e){var r;M(a.indexOf(s.next)<0,"can not update framebuffer which is currently in use");var u,l={color:null},p=0,d=null,m="rgba",h="uint8",v=1;if("number"==typeof e)p=0|e;else if(e){M.type(e,"object","invalid arguments for framebuffer");var g=e;if("shape"in g){var y=g.shape;M(Array.isArray(y)&&y.length>=2,"invalid shape for framebuffer"),M(y[0]===y[1],"cube framebuffer must be square"),p=y[0]}else"radius"in g&&(p=0|g.radius),"width"in g?(p=0|g.width,"height"in g&&M(g.height===p,"must be square")):"height"in g&&(p=0|g.height);("color"in g||"colors"in g)&&(d=g.color||g.colors,Array.isArray(d)&&M(1===d.length||n.webgl_draw_buffers,"multiple render targets not supported")),d||("colorCount"in g&&M((v=0|g.colorCount)>0,"invalid color buffer count"),"colorType"in g&&(M.oneOf(g.colorType,c,"invalid color type"),h=g.colorType),"colorFormat"in g&&(m=g.colorFormat,M.oneOf(g.colorFormat,f,"invalid color format for texture"))),"depth"in g&&(l.depth=g.depth),"stencil"in g&&(l.stencil=g.stencil),"depthStencil"in g&&(l.depthStencil=g.depthStencil)}else p=1;if(d)if(Array.isArray(d))for(u=[],r=0;r<d.length;++r)u[r]=d[r];else u=[d];else{u=Array(v);var b={radius:p,format:m,type:h};for(r=0;r<v;++r)u[r]=i.createCube(b)}for(l.color=Array(u.length),r=0;r<u.length;++r){var x=u[r];M("function"==typeof x&&"textureCube"===x._reglType,"invalid cube map"),M(x.width===(p=p||x.width)&&x.height===p,"invalid cube map shape"),l.color[r]={target:Sn,data:u[r]}}for(r=0;r<6;++r){for(var w=0;w<u.length;++w)l.color[w].target=Sn+r;r>0&&(l.depth=a[0].depth,l.stencil=a[0].stencil,l.depthStencil=a[0].depthStencil),a[r]?a[r](l):a[r]=S(l)}return t(o,{width:p,height:p,color:u})}return o(e),t(o,{faces:a,resize:function(e){var t,n=0|e;if(M(n>0&&n<=r.maxCubeMapSize,"invalid radius for cube fbo"),n===o.width)return o;var i=o.color;for(t=0;t<i.length;++t)i[t].resize(n);for(t=0;t<6;++t)a[t].resize(n);return o.width=o.height=n,o},_reglType:"framebufferCube",destroy:function(){a.forEach(function(e){e.destroy()})}})},clear:function(){ie(x).forEach(_)},restore:function(){s.cur=null,s.next=null,s.dirty=!0,ie(x).forEach(function(t){t.framebuffer=e.createFramebuffer(),A(t)})}})}(i,p,y,_,A,l),E=ra(i,c,p,y,b,w,0,S,{},x,k,{elements:null,primitive:4,count:-1,offset:0,instances:-1},g,d,r),T=Xn(i,S,E.procs.poll,g,a,p,y),O=E.next,j=i.canvas,C=[],D=[],z=[],F=[r.onDestroy],P=null;function R(){if(0===C.length)return d&&d.update(),void(P=null);P=V.next(R),$();for(var e=C.length-1;e>=0;--e){var t=C[e];t&&t(g,null,0)}i.flush(),d&&d.update()}function L(){!P&&C.length>0&&(P=V.next(R))}function B(){P&&(V.cancel(R),P=null)}function H(e){e.preventDefault(),o=!0,B(),D.forEach(function(e){e()})}function U(e){i.getError(),o=!1,s.restore(),k.restore(),b.restore(),_.restore(),A.restore(),S.restore(),x.restore(),d&&d.restore(),E.procs.refresh(),L(),z.forEach(function(e){e()})}function W(e){function n(e){var t={},n={};return Object.keys(e).forEach(function(r){var i=e[r];I.isDynamic(i)?n[r]=I.unbox(i,r):t[r]=i}),{dynamic:n,static:t}}M(!!e,"invalid args to regl({...})"),M.type(e,"object","invalid args to regl({...})");var r=n(e.context||{}),i=n(e.uniforms||{}),a=n(e.attributes||{}),s=n(function(e){var n=t({},e);function r(e){if(e in n){var t=n[e];delete n[e],Object.keys(t).forEach(function(r){n[e+"."+r]=t[r]})}}return delete n.uniforms,delete n.attributes,delete n.context,delete n.vao,"stencil"in n&&n.stencil.op&&(n.stencil.opBack=n.stencil.opFront=n.stencil.op,delete n.stencil.op),r("blend"),r("depth"),r("cull"),r("stencil"),r("polygonOffset"),r("scissor"),r("sample"),"vao"in e&&(n.vao=e.vao),n}(e)),f={gpuTime:0,cpuTime:0,count:0},u=E.compile(s,a,i,r,f),c=u.draw,l=u.batch,p=u.scope,d=[];return t(function(e,t){var n;if(o&&M.raise("context lost"),"function"==typeof e)return p.call(this,null,e,0);if("function"==typeof t)if("number"==typeof e)for(n=0;n<e;++n)p.call(this,null,t,n);else{if(!Array.isArray(e))return p.call(this,e,t,0);for(n=0;n<e.length;++n)p.call(this,e[n],t,n)}else if("number"==typeof e){if(e>0)return l.call(this,function(e){for(;d.length<e;)d.push(null);return d}(0|e),0|e)}else{if(!Array.isArray(e))return c.call(this,e);if(e.length)return l.call(this,e,e.length)}},{stats:f})}j&&(j.addEventListener(pa,H,!1),j.addEventListener(da,U,!1));var G=S.setFBO=W({framebuffer:I.define.call(null,ma,"framebuffer")});function Q(e,t){var n=0;E.procs.poll();var r=t.color;r&&(i.clearColor(+r[0]||0,+r[1]||0,+r[2]||0,+r[3]||0),n|=fa),"depth"in t&&(i.clearDepth(+t.depth),n|=ua),"stencil"in t&&(i.clearStencil(0|t.stencil),n|=ca),M(!!n,"called regl.clear with no buffer specified"),i.clear(n)}function Y(e){return M.type(e,"function","regl.frame() callback must be a function"),C.push(e),L(),{cancel:function(){var t=ga(C,e);M(t>=0,"cannot cancel a frame twice"),C[t]=function e(){var t=ga(C,e);C[t]=C[C.length-1],C.length-=1,C.length<=0&&B()}}}}function K(){var e=O.viewport,t=O.scissor_box;e[0]=e[1]=t[0]=t[1]=0,g.viewportWidth=g.framebufferWidth=g.drawingBufferWidth=e[2]=t[2]=i.drawingBufferWidth,g.viewportHeight=g.framebufferHeight=g.drawingBufferHeight=e[3]=t[3]=i.drawingBufferHeight}function $(){g.tick+=1,g.time=J(),K(),E.procs.poll()}function X(){K(),E.procs.refresh(),d&&d.update()}function J(){return(N()-m)/1e3}X();var Z=t(W,{clear:function(e){if(M("object"==typeof e&&e,"regl.clear() takes an object as input"),"framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var n=0;n<6;++n)G(t({framebuffer:e.framebuffer.faces[n]},e),Q);else G(e,Q);else Q(0,e)},prop:I.define.bind(null,ma),context:I.define.bind(null,ha),this:I.define.bind(null,va),draw:W({}),buffer:function(e){return b.create(e,la,!1,!1)},elements:function(e){return w.create(e,!1)},texture:_.create2D,cube:_.createCube,renderbuffer:A.create,framebuffer:S.create,framebufferCube:S.createCube,vao:x.createVAO,attributes:a,frame:Y,on:function(e,t){var n;switch(M.type(t,"function","listener callback must be a function"),e){case"frame":return Y(t);case"lost":n=D;break;case"restore":n=z;break;case"destroy":n=F;break;default:M.raise("invalid event, must be one of frame,lost,restore,destroy")}return n.push(t),{cancel:function(){for(var e=0;e<n.length;++e)if(n[e]===t)return n[e]=n[n.length-1],void n.pop()}}},limits:y,hasExtension:function(e){return y.extensions.indexOf(e.toLowerCase())>=0},read:T,destroy:function(){C.length=0,B(),j&&(j.removeEventListener(pa,H),j.removeEventListener(da,U)),k.clear(),S.clear(),A.clear(),_.clear(),w.clear(),b.clear(),x.clear(),d&&d.clear(),F.forEach(function(e){e()})},_gl:i,_refresh:X,poll:function(){$(),d&&d.update()},now:J,stats:l});return r.onDone(null,Z),Z}},"object"==typeof n&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):r.createREGL=i()},{}],12:[function(e,t,n){(function(e){(function(){e.CANVAS_SKETCH_DEFAULT_STORAGE_KEY=window.location.href}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2,12]);
//# sourceMappingURL=output.js.map