/** * diaporama 2.2.0 * Gaëtan Renaudeau – https://github.com/gre/diaporama */ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Diaporama=e()}}(function(){var e;return function t(e,r,n){function i(a,o){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var f=r[a]={exports:{}};e[a][0].call(f.exports,function(t){var r=e[a][1][t];return i(r?r:t)},f,f.exports,t,e,r,n)}return r[a].exports}for(var s="function"==typeof require&&require,a=0;a=this._slideTimes.length){if(!this._loop||this._feeded)return;t=0}this._slideToTime(this._slideTimes[t],e,!0)}},prev:function(e){var t=this._slideIndexForTime(this._slidingTarget?this._slidingTarget.to:this._currentTime);if(-1!==t){if(t--,0>t){if(!this._loop||this._feeded)return;t=this._slideTimes.length-1}this._slideToTime(this._slideTimes[t],e,!1)}},jump:function(e,t){if("number"!=typeof e)throw new Error("Diaporama#jump requires the slide index number.");if(!(0>e||e>=this._slideTimes.length)){var r=this._slideIndexForTime(this._currentTime);r!==e&&this._slideToTime(this._slideTimes[e],t)}},fitToContainer:function(){var e=this.node,t=e.getBoundingClientRect();this._width=t.width,this._height=t.height,this._requestResize()},feed:function(e,t){var r=this;if(r._feeded)throw new Error("feed can only work once at a time.");t||(t={});var n=t.freeSlideBehind||1/0;return r._feeded=!0,r._feedSubscription=e.subscribe(function(e){var t=r.data,i=r.slide,s=t.timeline.concat(e),a=i-n;if(a>0){for(var o=0,u=0;a>u;u++){var h=s[u];o+=(h.duration||0)+(h.transitionNext&&h.transitionNext.duration||0)}s.splice(0,a),r.currentTime-=o}r.data=l({},t,{timeline:s})},function(e){r.emit("error",e),r._feeded=!1},function(){r._feeded=!1}),r._feedSubscription},_playbackRate:1,_loop:!1,_autoplay:!1,_paused:!0,_width:null,_height:null,_resolution:window.devicePixelRatio||1,_currentTime:0,_duration:0,_backgroundColor:[0,0,0],_timeBuffered:0,_feeded:!1,_curLoop:null,_startLoopId:0,_needResize:null,_needRender:null,_slidingTarget:null,_loadMedia:function(){function e(e){var t=g(e);t in l||(l[t]=e)}function t(){d||(d=1,u.emit("canplay"),u._requestRender())}function r(){p||(p=1,u.emit("canplaythrough"),u._requestRender())}function n(){u.emit("load"),u._requestRender()}function i(){u._requestRender(),u._computeTimeBuffered();var e=u.timeBuffered;if(u.emit("progress",{timeBuffered:e,loaded:c.length,total:Object.keys(l).length}),c.length===Object.keys(l).length)t(),r(),n(),o();else if(!d&&e>0&&t(),d&&!p){var i=u.duration,s=u.playbackRate,a=Date.now()-_;e-4e3>s*a&&.8*c.length/Object.keys(l).length>s*a/i&&r()}}function s(e){g(e)in l&&(c.push(e),i())}function a(e,t){u.emit("error",new Error("Failure to load "+e),t),o()}function o(){f.removeListener("load",s),f.removeListener("error",a),clearInterval(m)}this._stopCurrentDiaporamaLoading&&(this._stopCurrentDiaporamaLoading(),this._stopCurrentDiaporamaLoading=null);var u=this;u._timeBuffered=0;var h=this._rendering,f=h.media,l={},c=[];this._data.timeline.forEach(function(t){if(t.video){var r=u._resolve(t.video,"video");e(r)}else t.image?e({image:t.image}):t.slide2d&&A(t.slide2d.draws,function(t){e({image:t})})});var d,p;if(0===Object.keys(l).length)return void setTimeout(function(){u._computeTimeBuffered(),t(),r(),n()},0);var _=Date.now();setTimeout(i,0);var m=setInterval(i,200);f.on("load",s),f.on("error",a);for(var v in l)f.load(l[v]);this._stopCurrentDiaporamaLoading=o},_loadTransitions:function(){var e=this._rendering.transitions;if(e){var t=this._data.transitions||{};this._data.timeline.forEach(function(r){var n=r.transitionNext&&r.transitionNext.name;if(n&&!e.has(n)){var i=m(n,t);i&&e.set(n,i)}})}},_requestResize:function(){null===this._needResize&&(this._needResize=h(this._handleResize))},_handleResize:function(){null!==this._needResize&&(this._needResize=null,this._resize())},_resize:function(){if(!this._destroyed){var e=this._width,t=this._height,r=this._resolution;this._rendering.resize(e,t,r);for(var n=0;nc;c++){u.push(a);var d=l({},i.timeline[c]),p=d.duration||0,g=d.transitionNext,m=g&&g.duration||0,v=c===s-1?2:c%2;if(d.video||d.image)d.video&&(d.video=this._resolve(d.video,"video")),d.image&&(d.image=this._resolve(d.image,"image")),e=new this._rendering.SegmentKenBurns(_.KENBURNS[v],d,this);else{if(!d.slide2d)throw new E("timeline item can't be understood as a segment.",d);e=new this._rendering.SegmentSlide2d(_.SLIDE2D[v],d)}h.push([new w(a-o,r||c!==s-1?a+p+m:a+p),e]),o=m,a+=p,m&&(f.push({interval:new w(a,a+m),index:c}),a+=m)}for(var y=a-o,T=[],A=0;An;++n)if(ea||s>o)&&(o>a?e+=i:e-=i):r?s>a&&(e+=i):s>o&&(e-=i)}if(this.paused||!t)this._currentTime=e,this._requestRender();else{var u=this._playbackRate;this._slidingTarget={from:n,to:e,startTime:null,duration:t,initialPlaybackRate:e>n==u>0?u:0}}}},renderNow:function(){this._needRender=!0,this._handleRender()},_requestRender:function(){null===this._curLoop&&null===this._needRender&&(this._needRender=h(this._handleRender))},_handleRender:function(){null!==this._needRender&&(this._needRender=null,this._render())},_normalizeTime:function(e){var t=this.duration;return!this._loop||this._feeded?Math.max(0,Math.min(e,t)):t?(e+t)%t:0},_render:function(){if(!this._destroyed){var e=this._rendering;this._handleResize();var t=this._segments;if(0===t.length)return e.render(0,[]),this.emit("render",0,R),R;var r,i,s=this._normalizeTime(this._currentTime),a=this._runningSegments,o=!1,u=[],h=[],f=t.length,l=0;for(r=0;f>r;++r){i=t[r];var c=a.indexOf(i),d=-1!==c;if(i[0].timeInside(s)){if(l++,!d){if(!i[1].ready(e)){o=!0;continue}a.push(i),u.push(i[1])}}else d&&(a.splice(c,1),h.push(i[1]))}for(a.sort(n),r=h.length-1;r>=0;r--){i=h[r];var p=i.leave();p&&this.emit.apply(this,p)}for(r=u.length-1;r>=0;r--){i=u[r];var g=i.enter(e);g&&this.emit.apply(this,g)}(0===s||a.length>0)&&this._rendering.render(s,a)&&(o=!0);var _=l>0?o?x:I:R;return this._currentRenderState=_,this.emit("render",s,_),this._userJump&&(this._userJump=!1,this.emit("seeked",s,_)),_}},_start:function(){var e,t=this,r=++this._startLoopId;this._curLoop=h(function n(i){if(t._startLoopId===r){h(n),e||(e=i,t.emit("play"));var s=i-e;e=i;var o=t._render();if(o===R){if(t._feeded)return;t.loop?t.currentTime=0:t._stop(!0)}else if(o===I){var u=t._slidingTarget;if(null!==u){null===u.startTime&&(u.startTime=i);var f=i-u.startTime,l=a(u.from,u.to,f,u.duration,u.initialPlaybackRate);Math.abs(u.to-l)<10||f>=u.duration?(t._currentTime=u.to,t._slidingTarget=null):t._currentTime=l}else t._currentTime=t._normalizeTime(t._currentTime+s*t._playbackRate)}}})},_stop:function(e){this._startLoopId++,this._slidingTarget&&(this.currentTime=this._slidingTarget.endAt,this._slidingTarget=null),null!==this._curLoop&&(h.cancel(this._curLoop),this._curLoop=null,this.emit("pause"),e&&this.emit("ended"))},_resolve:function(e,t){var r=this.data;if(e="string"==typeof e&&r&&r.resources&&e in r.resources&&r.resources[e]||e,"string"==typeof e){var n={};n[t]=e,e=n}return e},_computeTimeBuffered:function(){if(!this._data)return this._timeBuffered=0;for(var e=this._rendering,t=this._segments,r=t.length,n=[],i=0;r>i;++i){var s=t[i];s[1].ready(e)||n.push(s[0].startT)}return n.length>0?this._timeBuffered=Math.min.apply(Math,n):this._timeBuffered=this.duration}}),Object.defineProperties(o.prototype,{loop:{set:function(e){var t=!!e;this._loop!==t&&(this._loop=t,this._data&&(this._computeTimelineSegments(this._data),this._computeTimeBuffered(),this._requestRender()))},get:function(){return this._loop}},autoplay:{set:function(e){this._autoplay=e},get:function(){return this._autoplay}},data:{set:function(e){var t=this._data;t!==e&&(this._currentRenderState=x,this._data=e,this._computeTimelineSegments(t),this._loadTransitions(),this._loadMedia(),this._requestRender(),this.emit("data",e))},get:function(){return this._data}},resolution:{set:function(e){e!==this._resolution&&(this._resolution=e,this._requestResize())},get:function(){return this._resolution}},width:{set:function(e){e!==this._width&&(this._width=e,this._requestResize())},get:function(){return this._width}},height:{set:function(e){e!==this._height&&(this._height=e,this._requestResize())},get:function(){return this._height}},currentTime:{set:function(e){e!==this._currentTime&&(this._userJump=!0,this._currentTime=this._normalizeTime(e),this._requestRender())},get:function(){return this._currentTime}},playbackRate:{set:function(e){this._playbackRate!==e&&(this._playbackRate=e,this.emit("ratechange",e))},get:function(){return this._playbackRate}},slide:{set:function(e){var t=this._slideIndexForTime(this._currentTime);t!==e&&this.jump(e)},get:function(){return this._slideIndexForTime(this._currentTime)}},paused:{set:function(e){var t=null===this._curLoop;e!==t&&(e?this._stop():this._start())},get:function(){return null===this._curLoop}},duration:{get:function(){var e=this._duration||0;return this._loop&&!this._feeded?e+(this._lastTransitionDuration||0):e},set:function(){throw new Error("Diaporama: duration is a read-only value.")}},slides:{get:function(){var e=this._data;return e&&e.timeline&&e.timeline.length||0},set:function(){throw new Error("Diaporama: slides is a read-only value.")}},renderingMode:{get:function(){return this._renderingMode},set:function(){throw new Error("Diaporama: setting renderingMode afterwards is not supported.")}},backgroundColor:{get:function(){return this._backgroundColor},set:function(){throw new Error("Diaporama: setting backgroundColor afterwards is not supported.")}},currentRenderState:{get:function(){return this._currentRenderState},set:function(){throw new Error("Diaporama: currentRenderState is a read-only value.")}},timeBuffered:{get:function(){return this._timeBuffered},set:function(){throw new Error("Diaporama: timeBuffered is a read-only value.")}}}),o.RENDER_EMPTY=R,o.RENDER_WAITING=x,o.RENDER_PLAYING=I,t.exports=o},{"./Channels":2,"./DiaporamaFormatError":4,"./DiaporamaRenderingCanvas":9,"./DiaporamaRenderingDOM":12,"./MediaLoader":13,"./SegmentTimeline":16,"./TimeInterval":17,"./WebGLDetector":18,"./findTransitionByName":19,"./forEachSlide2dImage":20,"./hashResource":22,"bezier-easing":26,croissant:34,events:31,"object-assign":70,raf:71}],4:[function(e,t,r){function n(e,t){var r=Error.call(this,e);this.name=r.name="DiaporamaFormatError",this.stack=r.stack,this.message=r.message,this.data=t}n.prototype=Object.create(Error.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t.exports=n},{}],5:[function(e,t,r){function n(e,t){this.gl=e,this.shader=i(e,o,u),this.buffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.buffer),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);var r=t.concat([1]);this.background=a(e,s(new Float32Array(r.concat(r).concat(r).concat(r)),[2,2,4]))}var i=e("gl-shader"),s=e("ndarray"),a=e("gl-texture2d"),o=["attribute vec2 position;","varying vec2 uv;","void main() {","gl_Position = vec4(position,0.0,1.0);","uv = 0.5 * (position+1.0);","}"].join(""),u=["precision mediump float;","uniform sampler2D buffer;","varying vec2 uv;","void main() {","gl_FragColor = texture2D(buffer, uv);","}"].join("");n.prototype={dispose:function(){this.gl.deleteBuffer(this.buffer),this.background.dispose(),this.shader.dispose()},renderTexture:function(e){var t=this.gl,r=this.shader;r.bind(),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),r.attributes.position.pointer(),r.uniforms.buffer=e.bind(),t.drawArrays(t.TRIANGLES,0,6)},renderFBO:function(e){this.renderTexture(e.color[0])},renderEmpty:function(){this.renderTexture(this.background)}},t.exports=n},{"gl-shader":44,"gl-texture2d":61,ndarray:67}],6:[function(e,t,r){function n(e,t,r,n){a.call(this,e,t),this.segmentFrom=r,this.segmentTo=n,this._p=0}var i=e("object-assign"),s=e("bezier-easing"),a=e("../SegmentTimeline");n.prototype=i({},a.prototype,{toString:function(){return"SegmentTransition("+this.channel+","+this.segmentFrom.channel+"~>"+this.segmentTo.channel+")"},ready:function(e){return this.segmentFrom.ready(e)&&this.segmentTo.ready(e)&&(!this.data.name||e.transitions.has(this.data.name))},enter:function(e){var t=this.data,r=e.transitions.getOrFade(t.name),n=e.getChannelContext(this.channel);return this.gl=n,this.from=function(){return e.getChannel(this.segmentFrom.channel)},this.to=function(){return e.getChannel(this.segmentTo.channel)},this.uniforms=i({},r.uniforms,t.uniforms||{}),this.duration=t.duration||1e3,this.easing=s.apply(null,t.easing||[0,0,1,1]),this.t=r.t,["transition",this.data,this.segmentFrom.data,this.segmentTo.data]},resize:function(){this.t.render(this._p,this.from(),this.to(),this.uniforms)},leave:function(){return["transitionEnd",this.data,this.segmentFrom.data,this.segmentTo.data]},render:function(e,t){var r=this._p=this.easing(t.interpolate(e));this.t.render(r,this.from(),this.to(),this.uniforms)}}),t.exports=n},{"../SegmentTimeline":16,"bezier-easing":26,"object-assign":70}],7:[function(e,t,r){function n(e,t,r){a.call(this,e,t,r)}var i=e("object-assign"),s=e("gl-texture2d"),a=e("../SegmentKenBurns");n.prototype=i({},a.prototype,{enter:function(e){var t=this.getMediaSize(),r=a.prototype.enter.apply(this,arguments);return this.texture=s(e.gl,[t.width,t.height]),this.texture.minFilter=this.texture.magFilter=e.gl.LINEAR,this.image&&this.texture.setPixels(this.image),r},leave:function(){return this.texture.dispose(),a.prototype.leave.apply(this,arguments)},draw:function(e,t){this.video&&this.texture.setPixels(e),this.kenburns.render(this.texture,t)}}),t.exports=n},{"../SegmentKenBurns":14,"gl-texture2d":61,"object-assign":70}],8:[function(e,t,r){function n(e){this.gl=e,this.ts={},this.set("fade",s)}var i=e("glsl-transition"),s=e("glsl-transition-fade");n.prototype={destroy:function(){for(var e in this.ts)this.ts[e].t.dispose();this.ts=null},has:function(e){return e in this.ts},set:function(e,t){var r=i(this.gl,t.glsl);this.ts[e]={t:r,uniforms:t.uniforms||{}}},get:function(e){return this.ts[e]},getOrFade:function(e){return e&&this.ts[e]||this.ts.fade}},t.exports=n},{"glsl-transition":63,"glsl-transition-fade":62}],9:[function(e,t,r){function n(e,t,r){this.media=e,this._container=t,this.bg=r.concat([1]),this._canvas=null,this._canvases={},this._textures={},this._ctxs={},this._fbos={},this._currentChannel=null;var n=this.shape=[1,1],h=e.getImageResolver(),f=document.createElement("canvas"),l=f.getContext("webgl");l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,!1),this.gl=l,this._post=new u(l,r);var p=a(l,n);this._attachContext(d.TRANSITION,l,p),d.KENBURNS.forEach(function(e){var t=a(l,n),r=new i(l);this._attachContext(e,r,t)},this),d.SLIDE2D.forEach(function(e){var t=document.createElement("canvas"),r=t.getContext("2d");this._canvases[e]=t;var n=o(l,t);n.minFilter=n.magFilter=l.LINEAR,this._textures[e]=n,this._attachContext(e,s(r,h))},this),this._container.appendChild(this._canvas=f),this.transitions=new c(this.getChannelContext(d.TRANSITION))}var i=e("kenburns-webgl"),s=e("slide2d"),a=e("gl-fbo"),o=e("gl-texture2d"),u=e("./Post"),h=e("./SegmentGlslTransition"),f=e("./SegmentKenBurnsWebGL"),l=e("../SegmentSlide2d"),c=e("./StoreTransitions"),d=e("../Channels");n.prototype={SegmentTransition:h,SegmentKenBurns:f,SegmentSlide2d:l,destroy:function(){this.media.destroy(),this.transitions.destroy();for(var e in this._ctxs){var t=this._ctxs[e];t.destroy?t.destroy():t.dispose&&t.dispose()}for(var r in this._fbos)this._fbos[r].dispose();for(var n in this._textures)this._textures[n].dispose();this._post.dispose(),this._fbos=null,this._canvas=null,this._canvases=null,this._ctxs=null,this._post=null,this._currentChannel=null},getSize:function(){var e=this.shape;return{width:e[0],height:e[1]}},resize:function(e,t,r){var n=e*r,i=t*r,s=this.shape=[n,i],a=this._canvas,o=this._container;a.style.width=e+"px",a.style.height=t+"px",a.width=n,a.height=i,o.style.width=e+"px",o.style.height=t+"px";for(var u in this._canvases){var h=this._canvases[u];h.width=n,h.height=i}for(var f in this._fbos)this._fbos[f].shape=s;for(var l in this._textures)this._textures[l].shape=s},getChannel:function(e){var t=this._fbos[e];if(t)return t.color[0];var r=this._canvases[e],n=this._textures[e],i=this.gl;return i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),n.setPixels(r),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),n},getChannelContext:function(e){return this._ctxs[e]},switchChannel:function(e){this._currentChannel=e},_attachContext:function(e,t,r){this._ctxs[e]=t,r&&(this._fbos[e]=r)},preparePostRender:function(){var e=this.gl,t=this.bg,r=this.shape;e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,r[0],r[1]),e.clearColor.apply(e,t),e.clear(e.COLOR_BUFFER_BIT)},render:function(e,t){var r=!1;if(t.length>0){for(var n,i=t.length-1;i>=0;i--){var s=t[i],a=s[1],o=s[0];n=a.channel;var u=this._fbos[a.channel];u&&u.bind(),a.render(e,o)&&(r=!0)}this.preparePostRender(),this._post.renderTexture(this.getChannel(n))}else this.preparePostRender(),this._post.renderEmpty();return r}},t.exports=n},{"../Channels":2,"../SegmentSlide2d":15,"./Post":5,"./SegmentGlslTransition":6,"./SegmentKenBurnsWebGL":7,"./StoreTransitions":8,"gl-fbo":43,"gl-texture2d":61,"kenburns-webgl":66,slide2d:76}],10:[function(e,t,r){function n(e,t,r,n){a.call(this,e,t),this.segmentFrom=r,this.segmentTo=n}var i=e("object-assign"),s=e("bezier-easing"),a=e("../SegmentTimeline");n.prototype=i({},a.prototype,{toString:function(){return"SegmentTransition("+this.channel+","+this.segmentFrom.channel+"~>"+this.segmentTo.channel+")"},ready:function(e){return this.segmentFrom.ready(e)&&this.segmentTo.ready(e)},enter:function(e){var t=this.data,r=e.getChannel(this.segmentFrom.channel),n=e.getChannel(this.segmentTo.channel),i=e.getChannel(this.channel);return r.style.position="absolute",r.style.top=0,r.style.left=0,n.style.position="absolute",n.style.top=0,n.style.left=0,i.appendChild(n),i.appendChild(r),this.container=i,this.from=r,this.to=n,this.duration=t.duration||1e3,this.easing=s.apply(null,t.easing||[0,0,1,1]),["transition",t,this.segmentFrom.data,this.segmentTo.data]},resize:function(){},leave:function(){return this.container.removeChild(this.from),this.container.removeChild(this.to),this.from.style.opacity=1,this.to.style.opacity=1,["transitionEnd",this.data,this.segmentFrom.data,this.segmentTo.data]},render:function(e,t){var r=this.easing(t.interpolate(e));this.from.style.opacity=1-r}}),t.exports=n},{"../SegmentTimeline":16,"bezier-easing":26,"object-assign":70}],11:[function(e,t,r){function n(e,t,r){s.call(this,e,t,r)}var i=e("object-assign"),s=e("../SegmentKenBurns");n.prototype=i({},s.prototype,{enter:function(e){return this.div=e.getChannel(this.channel),this.getSize=e.getSize.bind(e),s.prototype.enter.apply(this,arguments)},draw:function(e,t){this.kenburns.draw(e,t)}}),t.exports=n},{"../SegmentKenBurns":14,"object-assign":70}],12:[function(e,t,r){function n(e,t,r){this.media=e,this._container=t;var n=this._container.style.position;n&&"static"!==n||(this._container.style.position="relative"),this._container.style.backgroundColor="rgb("+r.map(function(e){return~~(255*e)})+")",this._nodes={},this._ctxs={},this.createDOM(),this.resolveImage=e.getImageResolver()}var i=e("kenburns-dom"),s=e("slide2d"),a=e("../Channels"),o=e("./SegmentDomTransition"),u=e("./SegmentKenBurnsDOM"),h=e("../SegmentSlide2d");n.prototype={SegmentTransition:o,SegmentKenBurns:u,SegmentSlide2d:h,destroy:function(){this._setChild(null),this.media.destroy();for(var e in this._ctxs)this._ctxs[e].destroy&&this._ctxs[e].destroy();this._nodes=null,this._ctxs=null},resize:function(e,t,r){this._w=e,this._h=t;var n=e*r,i=t*r;for(var s in this._nodes){var a=this._nodes[s];a.style.width=e+"px",a.style.height=t+"px","CANVAS"===a.nodeName&&(a.width=n,a.height=i)}this._container.style.width=e+"px",this._container.style.height=t+"px"},getSize:function(){return{width:this._w,height:this._h}},getChannel:function(e){return this._nodes[e]},getChannelContext:function(e){return this._ctxs[e]},switchChannel:function(e){e!==this._c&&(this._c=e,this._setChild(this._nodes[e]))},render:function(e,t){var r=!1;if(t.length>0){for(var n=t.length-1;n>=0;n--){var i=t[n],s=i[1],a=i[0];s.render(e,a)&&(r=!0)}this.switchChannel(t[0][1].channel)}else this.switchChannel(null);return r},createDOM:function(){var e=this.resolveImage,t=document.createElement("div");this._attachChannel(a.TRANSITION,t,t),a.KENBURNS.forEach(function(e){var t=document.createElement("div"),r=new i(t);r.getViewport=this.getSize.bind(this),this._attachChannel(e,t,r)},this),a.SLIDE2D.forEach(function(t){var r=document.createElement("canvas"),n=r.getContext("2d");this._attachChannel(t,r,s(n,e))},this)},_attachChannel:function(e,t,r){this._nodes[e]=t,this._ctxs[e]=r},_setChild:function(e){var t=this._container,r=t.children[0];r&&t.removeChild(r),e&&t.appendChild(e)}},t.exports=n},{"../Channels":2,"../SegmentSlide2d":15,"./SegmentDomTransition":10,"./SegmentKenBurnsDOM":11,"kenburns-dom":64,slide2d:76}],13:[function(e,t,r){function n(e,t){this.loader=e,this.resources={},this._loading={},this._threshold=t||3,this._queue=[]}var i=e("object-assign"),s=e("events").EventEmitter,a=e("./hashResource");n.prototype=i({},s.prototype,{destroy:function(){this.removeAllListeners(),this.resources={};for(var e in this._loading)this._loading[e]();this._loading={},this._queue=[],this._imageResolver=function(e){var t=this.get(e);return t&&t.image||null}.bind(this)},has:function(e){return a(e)in this.resources},get:function(e){return this.resources[a(e)]},load:function(e){Object.keys(this._loading).length>=this._threshold?this._queue.push(e):this._load(e)},getImageResolver:function(){return this._imageResolver},_load:function(e){var t=a(e);if(!(t in this._loading)){var r=this;this._take(e,this.loader(e,function(n){r._release(e)&&(r.resources[t]=n,r.emit("load",e,n))},function(t){r.emit("error",e,t)}))}},_take:function(e,t){this._loading[a(e)]=t},_release:function(e){var t=a(e);return t in this._loading?(delete this._loading[t],this._queue.length>0&&this._load(this._queue.shift()),!0):!1}}),t.exports=n},{"./hashResource":22,events:31,"object-assign":70}],14:[function(e,t,r){function n(e,t,r){s.call(this,e,t),this.diaporama=r,this.outOfSync=!1,this.syncing=!1,this.video=null,this.image=null,this.opts=i({position:0,volume:0,playbackRate:1,loop:!1},t),this.onVideoSeeked=this.onVideoSeeked.bind(this),this.onDiaporamaPause=this.onDiaporamaPause.bind(this),this.onDiaporamaPlay=this.onDiaporamaPlay.bind(this),this.onDiaporamaRateChange=this.onDiaporamaRateChange.bind(this),this.onDiaporamaSeeked=this.onDiaporamaSeeked.bind(this),this.resKey=f(t.video||t.image),r[l]||(r[l]={}),r[l][this.resKey]||(this.isFirstInstance=!0,r[l][this.resKey]=!0)}var i=e("object-assign"),s=e("./SegmentTimeline"),a=e("rect-clamp"),o=e("rect-crop"),u=e("rect-mix"),h=e("bezier-easing"),f=e("./hashResource"),l="__skb_fi";n.prototype=i({},s.prototype,{toString:function(){return"SegmentKenBurns("+this.channel+")"},destroy:function(){this.isFirstInstance?delete this.diaporama[l][this.resKey]:this._res&&this._res(),this._res=null},_computeVideoMeta:function(){var e=this.video;this.videoDuration=e.duration,this.videoSize={width:e.videoWidth,height:e.videoHeight}},_setRes:function(e){e.video?(this.video=e.video,this._computeVideoMeta()):e.image&&(this.image=e.image)},_load:function(e){var t=e.media,r=this.data;if(!this._loadHandled){if(this.isFirstInstance){var n=t.get(r.image||r.video);return void(n&&(this._loadHandled=!0,this._setRes(n)))}this._loadHandled=!0,this._res=t.loader(r.video||r.image,this._setRes.bind(this))}},ready:function(e){return this._load(e),this.image||this.video},getMediaSize:function(){return this.image||this.videoSize},enter:function(e){this.outOfSync=!0,this.syncing=!1,this.getSize=e.getSize.bind(e);var t=this.data,r=this.video,n=this.image,i=this.opts,s=this.getMediaSize();r&&(r.loop=i.loop,r.volume=i.volume,r.playbackRate=this.getPlaybackRate(),r.addEventListener("seeked",this.onVideoSeeked),this.diaporama.on("pause",this.onDiaporamaPause),this.diaporama.on("play",this.onDiaporamaPlay),this.diaporama.on("ratechange",this.onDiaporamaRateChange),this.diaporama.on("seeked",this.onDiaporamaSeeked));var a=e.getChannelContext(this.channel);this.kenburns=a;var u=o.largest,f=o.largest;return t.kenburns&&(t.kenburns.from&&(u=o.apply(null,t.kenburns.from)),t.kenburns.to&&(f=o.apply(null,t.kenburns.to))),this.from=u,this.to=f,this.easing=h.apply(null,t.kenburns&&t.kenburns.easing||[0,0,1,1]),this.viewport=[0,0,s.width,s.height],this.computeBounds(),a.runStart&&a.runStart(r||n),["slide",t]},leave:function(){var e=this.video;e&&(e.pause(),e.removeEventListener("seeked",this.onVideoSeeked),this.diaporama.removeListener("pause",this.onDiaporamaPause),this.diaporama.removeListener("play",this.onDiaporamaPlay),this.diaporama.removeListener("ratechange",this.onDiaporamaRateChange),this.diaporama.removeListener("seeked",this.onDiaporamaSeeked));var t=this.kenburns;return t.runEnd&&t.runEnd(),["slideEnd",this.data]},resize:function(){this.computeBounds()},getPlaybackRate:function(){return this.opts.playbackRate*this.diaporama.playbackRate},computeCurrentTime:function(e){var t=this.opts,r=this.getPlaybackRate();return(t.position+e*r)/1e3%this.videoDuration},onDiaporamaRateChange:function(){this.video.playbackRate=this.getPlaybackRate()},onDiaporamaSeeked:function(){this.outOfSync=!0},onDiaporamaPause:function(){this.outOfSync=!0,this.video.pause()},onDiaporamaPlay:function(){this.outOfSync=!0},onVideoSeeked:function(){this.syncing=!1,this.diaporama._requestRender()},setVideoTime:function(e){this.video.currentTime=e},getCurrentTimeDiff:function(e){var t=this.video,r=this.videoDuration,n=Math.abs((e-t.currentTime+r)%r);return n},render:function(e,t){var r=this.easing(t.interpolate(e)),n=this.video,i=this.image;if(n){var s=this.computeCurrentTime(t.relative(e)),o=this.diaporama.paused,h=this.getCurrentTimeDiff(s);o?h>.01&&this.setVideoTime(s):this.syncing||(this.outOfSync?(this.outOfSync=!1,this.syncing=!0,this.startSyncingTime=Date.now(),this.setVideoTime(s),o!==n.paused&&(o?n.pause():n.play())):o!==n.paused&&this.setVideoTime(s))}var f=u(this.fromCropBound,this.toCropBound,r);return f=a(f,this.viewport),this.draw(n||i,f),this.syncing&&Date.now()-this.startSyncingTime>300},cropBound:function(e){var t=e(this.getSize(),this.getMediaSize());return t=a(t,this.viewport)},computeBounds:function(){this.fromCropBound=this.cropBound(this.from),this.toCropBound=this.cropBound(this.to)}}),t.exports=n},{"./SegmentTimeline":16,"./hashResource":22,"bezier-easing":26,"object-assign":70,"rect-clamp":73,"rect-crop":74,"rect-mix":75}],15:[function(e,t,r){function n(e,t){s.call(this,e,t),this.imgs=[],a(t.slide2d.draws,this.imgs.push,this.imgs),this._needRender=!1}var i=e("object-assign"),s=e("./SegmentTimeline"),a=e("./forEachSlide2dImage");n.prototype=i({},s.prototype,{toString:function(){return"SegmentSlide2d("+this.channel+")"},ready:function(e){for(var t=0;t0?r=o:t=o;while(Math.abs(a)>f&&++ua;++a){var o=i(s,e,r);if(0===o)return s;var h=n(s,e,r)-t;s-=h/o}return s}function f(){for(var t=0;c>t;++t)m[t]=n(t*d,e,r)}function l(t){for(var n=0,a=1,u=c-1;a!=u&&m[a]<=t;++a)n+=d;--a;var f=(t-m[a])/(m[a+1]-m[a]),l=n+f*d,p=i(l,e,r);return p>=h?o(t,l):0===p?l:s(t,n,n+d,e,r)}function g(){v=!0,(e!=t||r!=a)&&f()}if(4!==arguments.length)throw new Error("BezierEasing requires 4 arguments.");for(var _=0;4>_;++_)if("number"!=typeof arguments[_]||isNaN(arguments[_])||!isFinite(arguments[_]))throw new Error("BezierEasing arguments should be integers.");if(0>e||e>1||0>r||r>1)throw new Error("BezierEasing x values must be in [0, 1] range.");var m=p?new Float32Array(c):new Array(c),v=!1,y=function(i){return v||g(),e===t&&r===a?i:0===i?0:1===i?1:n(l(i),t,a)};y.getControlPoints=function(){return[{x:e,y:t},{x:r,y:a}]};var b=[e,t,r,a],w="BezierEasing("+b+")";y.toString=function(){return w};var E="cubic-bezier("+b+")";return y.toCSS=function(){return E},y}var o=this,u=4,h=.001,f=1e-7,l=10,c=11,d=1/(c-1),p="Float32Array"in o;return a.css={ease:a(.25,.1,.25,1),linear:a(0,0,1,1),"ease-in":a(.42,0,1,1),"ease-out":a(0,0,.58,1),"ease-in-out":a(.42,0,.58,1)},a})},{}],27:[function(e,t,r){function n(){return i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e){return this instanceof i?(this.length=0,this.parent=void 0,"number"==typeof e?s(this,e):"string"==typeof e?a(this,e,arguments.length>1?arguments[1]:"utf8"):o(this,e)):arguments.length>1?new i(e,arguments[1]):new i(e)}function s(e,t){if(e=d(e,0>t?0:0|p(t)),!i.TYPED_ARRAY_SUPPORT)for(var r=0;t>r;r++)e[r]=0;return e}function a(e,t,r){("string"!=typeof r||""===r)&&(r="utf8");var n=0|_(t,r);return e=d(e,n),e.write(t,r),e}function o(e,t){if(i.isBuffer(t))return u(e,t);if(W(t))return h(e,t);if(null==t)throw new TypeError("must start with number, buffer, array or string");return"undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer?f(e,t):t.length?l(e,t):c(e,t)}function u(e,t){var r=0|p(t.length);return e=d(e,r),t.copy(e,0,0,r),e}function h(e,t){var r=0|p(t.length);e=d(e,r);for(var n=0;r>n;n+=1)e[n]=255&t[n];return e}function f(e,t){var r=0|p(t.length);e=d(e,r);for(var n=0;r>n;n+=1)e[n]=255&t[n];return e}function l(e,t){var r=0|p(t.length);e=d(e,r);for(var n=0;r>n;n+=1)e[n]=255&t[n];return e}function c(e,t){var r,n=0;"Buffer"===t.type&&W(t.data)&&(r=t.data,n=0|p(r.length)),e=d(e,n);for(var i=0;n>i;i+=1)e[i]=255&r[i];return e}function d(e,t){i.TYPED_ARRAY_SUPPORT?e=i._augment(new Uint8Array(t)):(e.length=t,e._isBuffer=!0);var r=0!==t&&t<=i.poolSize>>>1;return r&&(e.parent=K),e}function p(e){if(e>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function g(e,t){if(!(this instanceof g))return new g(e,t);var r=new i(e,t);return delete r.parent,r}function _(e,t){"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return k(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return k(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=!1;if(t=0|t,r=void 0===r||r===1/0?this.length:0|r,e||(e="utf8"),0>t&&(t=0),r>this.length&&(r=this.length),t>=r)return"";for(;;)switch(e){case"hex":return S(this,t,r);case"utf8":case"utf-8":return R(this,t,r);case"ascii":return x(this,t,r);case"binary":return I(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function v(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.length;if(s%2!==0)throw new Error("Invalid hex string");n>s/2&&(n=s/2);for(var a=0;n>a;a++){var o=parseInt(t.substr(2*a,2),16);if(isNaN(o))throw new Error("Invalid hex string");e[r+a]=o}return a}function y(e,t,r,n){return Y(k(t,e.length-r),e,r,n)}function b(e,t,r,n){return Y(V(t),e,r,n)}function w(e,t,r,n){return b(e,t,r,n)}function E(e,t,r,n){return Y(q(t),e,r,n)}function T(e,t,r,n){return Y(z(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?G.fromByteArray(e):G.fromByteArray(e.slice(t,r))}function R(e,t,r){var n="",i="";r=Math.min(e.length,r);for(var s=t;r>s;s++)e[s]<=127?(n+=X(i)+String.fromCharCode(e[s]),i=""):i+="%"+e[s].toString(16);return n+X(i)}function x(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(127&e[i]);return n}function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(e[i]);return n}function S(e,t,r){var n=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var i="",s=t;r>s;s++)i+=M(e[s]);return i}function N(e,t,r){for(var n=e.slice(t,r),i="",s=0;se)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function L(e,t,r,n,s,a){if(!i.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>s||a>t)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range")}function O(e,t,r,n){0>t&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);s>i;i++)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function F(e,t,r,n){0>t&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);s>i;i++)e[r+i]=t>>>8*(n?i:3-i)&255}function U(e,t,r,n,i,s){if(t>i||s>t)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function j(e,t,r,n,i){return i||U(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),H.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,i){return i||U(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),H.write(e,t,r,n,52,8),r+8}function P(e){if(e=C(e).replace(J,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function C(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function M(e){return 16>e?"0"+e.toString(16):e.toString(16)}function k(e,t){t=t||1/0;for(var r,n=e.length,i=null,s=[],a=0;n>a;a++){if(r=e.charCodeAt(a),r>55295&&57344>r){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(56320>r){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&((t-=3)>-1&&s.push(239,191,189),i=null);if(128>r){if((t-=1)<0)break;s.push(r)}else if(2048>r){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(65536>r){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function V(e){for(var t=[],r=0;r>8,i=r%256,s.push(i),s.push(n);return s}function q(e){return G.toByteArray(P(e))}function Y(e,t,r,n){for(var i=0;n>i&&!(i+r>=t.length||i>=e.length);i++)t[i+r]=e[i];return i}function X(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}var G=e("base64-js"),H=e("ieee754"),W=e("is-array");r.Buffer=i,r.SlowBuffer=g,r.INSPECT_MAX_BYTES=50,i.poolSize=8192;var K={};i.TYPED_ARRAY_SUPPORT=function(){function e(){}try{var t=new ArrayBuffer(0),r=new Uint8Array(t);return r.foo=function(){return 42},r.constructor=e,42===r.foo()&&r.constructor===e&&"function"==typeof r.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(n){return!1}}(),i.isBuffer=function(e){return!(null==e||!e._isBuffer)},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,s=0,a=Math.min(r,n);a>s&&e[s]===t[s];)++s;return s!==a&&(r=e[s],n=t[s]),n>r?-1:r>n?1:0},i.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(e,t){if(!W(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new i(0);if(1===e.length)return e[0];var r;if(void 0===t)for(t=0,r=0;r0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},i.prototype.compare=function(e){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:i.compare(this,e)},i.prototype.indexOf=function(e,t){function r(e,t,r){for(var n=-1,i=0;r+i2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(i.isBuffer(e))return r(this,e,t);if("number"==typeof e)return i.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):r(this,[e],t);throw new TypeError("val must be string, number or Buffer")},i.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},i.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},i.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=t,t=0|r,r=i}var s=this.length-t;if((void 0===r||r>s)&&(r=s),e.length>0&&(0>r||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return y(this,e,t,r);case"ascii":return b(this,e,t,r);case"binary":return w(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},i.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),e>t&&(t=e);var n;if(i.TYPED_ARRAY_SUPPORT)n=i._augment(this.subarray(e,t));else{var s=t-e;n=new i(s,void 0);for(var a=0;s>a;a++)n[a]=this[a+e]}return n.length&&(n.parent=this.parent||this),n},i.prototype.readUIntLE=function(e,t,r){e=0|e,t=0|t,r||B(e,t,this.length);for(var n=this[e],i=1,s=0;++s0&&(i*=256);)n+=this[e+--t]*i;return n},i.prototype.readUInt8=function(e,t){return t||B(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return t||B(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return t||B(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,r){e=0|e,t=0|t,r||B(e,t,this.length);for(var n=this[e],i=1,s=0;++s=i&&(n-=Math.pow(2,8*t)),n},i.prototype.readIntBE=function(e,t,r){e=0|e,t=0|t,r||B(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*t)),s},i.prototype.readInt8=function(e,t){return t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){t||B(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(e,t){t||B(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(e,t){return t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return t||B(e,4,this.length),H.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return t||B(e,4,this.length),H.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return t||B(e,8,this.length),H.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return t||B(e,8,this.length),H.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,r,n){e=+e,t=0|t,r=0|r,n||L(this,e,t,r,Math.pow(2,8*r),0);var i=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+i]=e/s&255;return t+r},i.prototype.writeUInt8=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,1,255,0),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e,t+1},i.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},i.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):O(this,e,t,!1),t+2},i.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e):F(this,e,t,!0),t+4},i.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):F(this,e,t,!1),t+4},i.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=0|t,!n){var i=Math.pow(2,8*r-1);L(this,e,t,r,i-1,-i)}var s=0,a=1,o=0>e?1:0;for(this[t]=255&e;++s>0)-o&255;return t+r},i.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=0|t,!n){var i=Math.pow(2,8*r-1);L(this,e,t,r,i-1,-i)}var s=r-1,a=1,o=0>e?1:0;for(this[t+s]=255&e;--s>=0&&(a*=256);)this[t+s]=(e/a>>0)-o&255;return t+r},i.prototype.writeInt8=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,1,127,-128),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=e,t+1},i.prototype.writeInt16LE=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},i.prototype.writeInt16BE=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):O(this,e,t,!1),t+2},i.prototype.writeInt32LE=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,4,2147483647,-2147483648),i.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):F(this,e,t,!0),t+4},i.prototype.writeInt32BE=function(e,t,r){return e=+e,t=0|t,r||L(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):F(this,e,t,!1),t+4},i.prototype.writeFloatLE=function(e,t,r){return j(this,e,t,!0,r)},i.prototype.writeFloatBE=function(e,t,r){return j(this,e,t,!1,r)},i.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},i.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},i.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-ts||!i.TYPED_ARRAY_SUPPORT)for(var a=0;s>a;a++)e[a+t]=this[a+r];else e._set(this.subarray(r,r+s),t);return s},i.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),t>r)throw new RangeError("end < start");if(r!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof e)for(n=t;r>n;n++)this[n]=e;else{var i=k(e.toString()),s=i.length;for(n=t;r>n;n++)this[n]=i[n%s]}return this}},i.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(i.TYPED_ARRAY_SUPPORT)return new i(this).buffer;for(var e=new Uint8Array(this.length),t=0,r=e.length;r>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var Z=i.prototype;i._augment=function(e){return e.constructor=i,e._isBuffer=!0,e._set=e.set,e.get=Z.get,e.set=Z.set,e.write=Z.write,e.toString=Z.toString,e.toLocaleString=Z.toString,e.toJSON=Z.toJSON,e.equals=Z.equals,e.compare=Z.compare,e.indexOf=Z.indexOf,e.copy=Z.copy,e.slice=Z.slice,e.readUIntLE=Z.readUIntLE,e.readUIntBE=Z.readUIntBE,e.readUInt8=Z.readUInt8,e.readUInt16LE=Z.readUInt16LE,e.readUInt16BE=Z.readUInt16BE,e.readUInt32LE=Z.readUInt32LE,e.readUInt32BE=Z.readUInt32BE,e.readIntLE=Z.readIntLE,e.readIntBE=Z.readIntBE,e.readInt8=Z.readInt8,e.readInt16LE=Z.readInt16LE,e.readInt16BE=Z.readInt16BE,e.readInt32LE=Z.readInt32LE,e.readInt32BE=Z.readInt32BE,e.readFloatLE=Z.readFloatLE,e.readFloatBE=Z.readFloatBE,e.readDoubleLE=Z.readDoubleLE,e.readDoubleBE=Z.readDoubleBE,e.writeUInt8=Z.writeUInt8,e.writeUIntLE=Z.writeUIntLE,e.writeUIntBE=Z.writeUIntBE,e.writeUInt16LE=Z.writeUInt16LE,e.writeUInt16BE=Z.writeUInt16BE,e.writeUInt32LE=Z.writeUInt32LE,e.writeUInt32BE=Z.writeUInt32BE,e.writeIntLE=Z.writeIntLE,e.writeIntBE=Z.writeIntBE,e.writeInt8=Z.writeInt8,e.writeInt16LE=Z.writeInt16LE,e.writeInt16BE=Z.writeInt16BE,e.writeInt32LE=Z.writeInt32LE,e.writeInt32BE=Z.writeInt32BE,e.writeFloatLE=Z.writeFloatLE,e.writeFloatBE=Z.writeFloatBE,e.writeDoubleLE=Z.writeDoubleLE,e.writeDoubleBE=Z.writeDoubleBE,e.fill=Z.fill,e.inspect=Z.inspect,e.toArrayBuffer=Z.toArrayBuffer,e};var J=/[^+\/0-9A-z\-]/g},{"base64-js":28,ieee754:29,"is-array":30}],28:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===a||t===l?62:t===o||t===c?63:u>t?-1:u+10>t?t-u+26+26:f+26>t?t-f:h+26>t?t-h+26:void 0}function r(e){function r(e){h[l++]=e}var n,i,a,o,u,h;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=e.length;u="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0,h=new s(3*e.length/4-u),a=u>0?e.length-4:e.length;var l=0;for(n=0,i=0;a>n;n+=4,i+=3)o=t(e.charAt(n))<<18|t(e.charAt(n+1))<<12|t(e.charAt(n+2))<<6|t(e.charAt(n+3)),r((16711680&o)>>16),r((65280&o)>>8),r(255&o);return 2===u?(o=t(e.charAt(n))<<2|t(e.charAt(n+1))>>4,r(255&o)):1===u&&(o=t(e.charAt(n))<<10|t(e.charAt(n+1))<<4|t(e.charAt(n+2))>>2,r(o>>8&255),r(255&o)),h}function i(e){function t(e){return n.charAt(e)}function r(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,s,a,o=e.length%3,u="";for(i=0,a=e.length-o;a>i;i+=3)s=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=r(s);switch(o){case 1:s=e[e.length-1],u+=t(s>>2),u+=t(s<<4&63),u+="==";break;case 2:s=(e[e.length-2]<<8)+e[e.length-1],u+=t(s>>10),u+=t(s>>4&63),u+=t(s<<2&63),u+="="}return u}var s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),o="/".charCodeAt(0),u="0".charCodeAt(0),h="a".charCodeAt(0),f="A".charCodeAt(0),l="-".charCodeAt(0),c="_".charCodeAt(0);e.toByteArray=r,e.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],29:[function(e,t,r){r.read=function(e,t,r,n,i){var s,a,o=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,c=r?-1:1,d=e[t+l];for(l+=c,s=d&(1<<-f)-1,d>>=-f,f+=o;f>0;s=256*s+e[t+l],l+=c,f-=8);for(a=s&(1<<-f)-1,s>>=-f,f+=n;f>0;a=256*a+e[t+l],l+=c,f-=8);if(0===s)s=1-h;else{if(s===u)return a?NaN:(d?-1:1)*(1/0);a+=Math.pow(2,n),s-=h}return(d?-1:1)*a*Math.pow(2,s-n)},r.write=function(e,t,r,n,i,s){var a,o,u,h=8*s-i-1,f=(1<>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),t+=a+l>=1?c/u:c*Math.pow(2,1-l),t*u>=2&&(a++,u/=2),a+l>=f?(o=0,a=f):a+l>=1?(o=(t*u-1)*Math.pow(2,i),a+=l):(o=t*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&o,d+=p,o/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,h-=8);e[r+d-p]|=128*g}},{}],30:[function(e,t,r){var n=Array.isArray,i=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],31:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function s(e){return"number"==typeof e}function a(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!s(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,s,u,h;if(this._events||(this._events={}),"error"===e&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[e],o(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,s=new Array(n-1),u=1;n>u;u++)s[u-1]=arguments[u];r.apply(this,s)}else if(a(r)){for(n=arguments.length,s=new Array(n-1),u=1;n>u;u++)s[u-1]=arguments[u];for(h=r.slice(),n=h.length,u=0;n>u;u++)h[u].apply(this,s)}return!0},n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,a(this._events[e])&&!this._events[e].warned){var r;r=o(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var n=!1;return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,t){var r,n,s,o;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],s=r.length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(r)){for(o=s;o-->0;)if(r[o]===t||r[o].listener&&r[o].listener===t){n=o;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],i(r))this.removeListener(e,r);else for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var r;return r=e._events&&e._events[t]?i(e._events[t])?1:e._events[t].length:0}},{}],32:[function(e,t,r){function n(){if(!o){o=!0;for(var e,t=a.length;t;){e=a,a=[];for(var r=-1;++r=n;++n){for(var i=new Array(r),s=0;n>s;++s)i[s]=e.COLOR_ATTACHMENT0+s;for(var s=n;r>s;++s)i[s]=e.NONE;v[n]=i}}function a(e){switch(e){case p:throw new Error("gl-fbo: Framebuffer unsupported");case g:throw new Error("gl-fbo: Framebuffer incomplete attachment");case _:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case m:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function o(e,t,r,n,i,s){if(!n)return null;var a=d(e,t,r,i,n);return a.magFilter=e.NEAREST,a.minFilter=e.NEAREST,a.mipSamples=1,a.bind(),e.framebufferTexture2D(e.FRAMEBUFFER,s,e.TEXTURE_2D,a.handle,0),a}function u(e,t,r,n,i){var s=e.createRenderbuffer();return e.bindRenderbuffer(e.RENDERBUFFER,s),e.renderbufferStorage(e.RENDERBUFFER,n,t,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,i,e.RENDERBUFFER,s),s}function h(e){var t=n(e.gl),r=e.gl,s=e.handle=r.createFramebuffer(),h=e._shape[0],f=e._shape[1],l=e.color.length,c=e._ext,d=e._useStencil,p=e._useDepth,g=e._colorType;r.bindFramebuffer(r.FRAMEBUFFER,s);for(var _=0;l>_;++_)e.color[_]=o(r,h,f,g,r.RGBA,r.COLOR_ATTACHMENT0+_);0===l?(e._color_rb=u(r,h,f,r.RGBA4,r.COLOR_ATTACHMENT0),c&&c.drawBuffersWEBGL(v[0])):l>1&&c.drawBuffersWEBGL(v[l]);var m=r.getExtension("WEBGL_depth_texture");m?d?e.depth=o(r,h,f,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(e.depth=o(r,h,f,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?e._depth_rb=u(r,h,f,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?e._depth_rb=u(r,h,f,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(e._depth_rb=u(r,h,f,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var y=r.checkFramebufferStatus(r.FRAMEBUFFER);if(y!==r.FRAMEBUFFER_COMPLETE){e._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(e.handle),e.handle=null,e.depth&&(e.depth.dispose(),e.depth=null),e._depth_rb&&(r.deleteRenderbuffer(e._depth_rb),e._depth_rb=null);for(var _=0;_u;++u)this.color[u]=null;this._color_rb=null,this.depth=null,this._depth_rb=null,this._colorType=n,this._useDepth=s,this._useStencil=a;var f=this,l=[0|t,0|r];Object.defineProperties(l,{0:{get:function(){return f._shape[0]},set:function(e){return f.width=e}},1:{get:function(){return f._shape[1]},set:function(e){return f.height=e}}}),this._shapeVector=l,h(this)}function l(e,t,r){if(e._destroyed)throw new Error("gl-fbo: Can't resize destroyed FBO");if(e._shape[0]!==t||e._shape[1]!==r){var s=e.gl,o=s.getParameter(s.MAX_RENDERBUFFER_SIZE);if(0>t||t>o||0>r||r>o)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");e._shape[0]=t,e._shape[1]=r;for(var u=n(s),h=0;ht||t>a||0>r||r>a)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var o=1;if("color"in n){if(o=Math.max(0|n.color,0),0>o)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(o>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(o>e.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+o+" draw buffers")}}var u=e.UNSIGNED_BYTE,h=e.getExtension("OES_texture_float");if(n["float"]&&o>0){if(!h)throw new Error("gl-fbo: Context does not support floating point textures");u=e.FLOAT}else n.preferFloat&&o>0&&h&&(u=e.FLOAT);var l=!0;"depth"in n&&(l=!!n.depth);var c=!1;return"stencil"in n&&(c=!!n.stencil),new f(e,t,r,u,o,l,c,i)}var d=e("gl-texture2d");t.exports=c;var p,g,_,m,v=null,y=f.prototype;Object.defineProperties(y,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(e){if(Array.isArray(e)||(e=[0|e,0|e]),2!==e.length)throw new Error("gl-fbo: Shape vector must be length 2");var t=0|e[0],r=0|e[1];return l(this,t,r),[t,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(e){return e=0|e,l(this,e,this._shape[1]),e},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(e){return e=0|e,l(this,this._shape[0],e),e},enumerable:!1}}),y.bind=function(){if(!this._destroyed){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.handle),e.viewport(0,0,this._shape[0],this._shape[1])}},y.dispose=function(){if(!this._destroyed){this._destroyed=!0;var e=this.gl;e.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(e.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var t=0;t=0){for(var T=0|E.type.charAt(E.type.length-1),A=new Array(T),R=0;T>R;++R)A[R]=b.length,y.push(E.name+"["+R+"]"),"number"==typeof E.location?b.push(E.location+R):Array.isArray(E.location)&&E.location.length===T&&"number"==typeof E.location[R]?b.push(0|E.location[R]):b.push(-1);v.push({name:E.name,type:E.type,locations:A})}else v.push({name:E.name,type:E.type,locations:[b.length]}),y.push(E.name),"number"==typeof E.location?b.push(0|E.location):b.push(-1)}for(var x=0,w=0;w=0;)x+=1;b[w]=x}var I=new Array(r.length);s(),c._relink=s,c.types={uniforms:u(r),attributes:u(n)},c.attributes=o(d,c,v,b),Object.defineProperty(c,"uniforms",a(d,c,r,I))},t.exports=s},{"./lib/create-attributes":45,"./lib/create-uniforms":46,"./lib/reflect":47,"./lib/runtime-reflect":48,"./lib/shader-cache":49}],45:[function(e,t,r){"use strict";function n(e,t,r,n,i,s){this._gl=e,this._wrapper=t,this._index=r,this._locations=n,this._dimension=i,this._constFunc=s}function i(e,t,r,i,s,a,o){for(var u=["gl","v"],h=[],f=0;s>f;++f)u.push("x"+f),h.push("x"+f);u.push("if(x0.length===void 0){return gl.vertexAttrib"+s+"f(v,"+h.join()+")}else{return gl.vertexAttrib"+s+"fv(v,x0)}");var l=Function.apply(null,u),c=new n(e,t,r,i,s,l);Object.defineProperty(a,o,{set:function(t){return e.disableVertexAttribArray(i[r]),l(e,i[r],t),t},get:function(){return c},enumerable:!0})}function s(e,t,r,n,s,a,o){for(var u=new Array(s),h=new Array(s),f=0;s>f;++f)i(e,t,r[f],n,s,u,f),h[f]=u[f];Object.defineProperty(u,"location",{set:function(e){if(Array.isArray)for(var t=0;s>t;++t)h[t].location=e[t];else for(var t=0;s>t;++t)result[t]=h[t].location=e+t;return e},get:function(){for(var e=new Array(s),t=0;s>t;++t)e[t]=n[r[t]];return e},enumerable:!0}),u.pointer=function(t,i,a,o){t=t||e.FLOAT,i=!!i,a=a||s*s,o=o||0;for(var u=0;s>u;++u){var h=n[r[u]];e.vertexAttribPointer(h,s,t,i,a,o+u*s),e.enableVertexAttribArray(h)}};var l=new Array(s),c=e["vertexAttrib"+s+"fv"];Object.defineProperty(a,o,{set:function(t){for(var i=0;s>i;++i){var a=n[r[i]];if(e.disableVertexAttribArray(a),Array.isArray(t[0]))c.call(e,a,t[i]);else{for(var o=0;s>o;++o)l[o]=t[s*i+o];c.call(e,a,l)}}return t},get:function(){return u},enumerable:!0})}function a(e,t,r,n){for(var a={},o=0,u=r.length;u>o;++o){var h=r[o],f=h.name,l=h.type,c=h.locations;switch(l){case"bool":case"int":case"float":i(e,t,c[0],n,1,a,f);break;default:if(l.indexOf("vec")>=0){var d=l.charCodeAt(l.length-1)-48;if(2>d||d>4)throw new Error("gl-shader: Invalid data type for attribute "+f+": "+l);i(e,t,c[0],n,d,a,f)}else{if(!(l.indexOf("mat")>=0))throw new Error("gl-shader: Unknown data type for attribute "+f+": "+l);var d=l.charCodeAt(l.length-1)-48;if(2>d||d>4)throw new Error("gl-shader: Invalid data type for attribute "+f+": "+l);s(e,t,c,n,d,a,f)}}}return a}t.exports=a;var o=n.prototype;o.pointer=function(e,t,r,n){var i=this,s=i._gl,a=i._locations[i._index];s.vertexAttribPointer(a,i._dimension,e||s.FLOAT,!!t,r||0,n||0),s.enableVertexAttribArray(a)},o.set=function(e,t,r,n){return this._constFunc(this._locations[this._index],e,t,r,n)},Object.defineProperty(o,"location",{get:function(){return this._locations[this._index]},set:function(e){return e!==this._locations[this._index]&&(this._locations[this._index]=0|e,this._wrapper.program=null),0|e}})},{}],46:[function(e,t,r){"use strict";function n(e){var t=new Function("y","return function(){return y}");return t(e)}function i(e,t){for(var r=new Array(e),n=0;e>n;++n)r[n]=t;return r}function s(e,t,r,s){function o(r){var n=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return n(e,t,s)}function u(e,t,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+t+"],obj"+e+")";case"float":return"gl.uniform1f(locations["+t+"],obj"+e+")";default:var n=r.indexOf("vec");if(!(n>=0&&1>=n&&r.length===4+n)){if(0===r.indexOf("mat")&&4===r.length){var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+t+"],false,obj"+e+")"}throw new Error("gl-shader: Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new Error("gl-shader: Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+t+"],obj"+e+")";case"v":return"gl.uniform"+i+"fv(locations["+t+"],obj"+e+")";default:throw new Error("gl-shader: Unrecognized data type for vector "+name+": "+r)}}}function h(e,t){if("object"!=typeof t)return[[e,t]];var r=[];for(var n in t){var i=t[n],s=e;s+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,h(s,i)):r.push([s,i])}return r}function f(t){for(var n=["return function updateProperty(obj){"],i=h("",t),a=0;a=0&&1>=t&&e.length===4+t){var r=e.charCodeAt(e.length-1)-48;if(2>r||r>4)throw new Error("gl-shader: Invalid data type");return"b"===e.charAt(0)?i(r,!1):i(r,0)}if(0===e.indexOf("mat")&&4===e.length){var r=e.charCodeAt(e.length-1)-48;if(2>r||r>4)throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+e);return i(r*r,0)}throw new Error("gl-shader: Unknown uniform data type for "+name+": "+e)}}function c(e,t,i){if("object"==typeof i){var a=d(i);Object.defineProperty(e,t,{get:n(a),set:f(i),enumerable:!0,configurable:!1})}else s[i]?Object.defineProperty(e,t,{get:o(i),set:f(i),enumerable:!0,configurable:!1}):e[t]=l(r[i].type)}function d(e){var t;if(Array.isArray(e)){t=new Array(e.length);for(var r=0;r1){u[0]in a||(a[u[0]]=[]),a=a[u[0]];for(var h=1;hs;++s){var a=e.getActiveUniform(t,s);if(a){var o=n(e,a.type);if(a.size>1)for(var u=0;us;++s){var a=e.getActiveAttrib(t,s);a&&i.push({name:a.name,type:n(e,a.type)})}return i}r.uniforms=i,r.attributes=s;var a={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},o=null},{}],49:[function(e,t,r){"use strict";function n(e,t,r,n,i,s,a){this.id=e,this.src=t,this.type=r,this.shader=n,this.count=s,this.programs=[],this.cache=a}function i(e){this.gl=e,this.shaders=[{},{}],this.programs={}}function s(e,t,r){var n=e.createShader(t);if(e.shaderSource(n,r),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){var i=e.getShaderInfoLog(n);throw console.error("gl-shader: Error compiling shader:",i),new Error("gl-shader: Error compiling shader:"+i)}return n}function a(e,t,r,n,i){var s=e.createProgram();e.attachShader(s,t),e.attachShader(s,r);for(var a=0;an;++n){var s=e.programs[r[n]];s&&(delete e.programs[n],t.deleteProgram(s))}t.deleteShader(this.shader),delete e.shaders[this.type===t.FRAGMENT_SHADER|0][this.src]}};var d=i.prototype;d.getShaderReference=function(e,t){var r=this.gl,i=this.shaders[e===r.FRAGMENT_SHADER|0],a=i[t];if(a&&r.isShader(a.shader))a.count+=1;else{var o=s(r,e,t);a=i[t]=new n(c++,t,e,o,[],1,this)}return a},d.getProgram=function(e,t,r,n){var i=[e.id,t.id,r.join(":"),n.join(":")].join("@"),s=this.programs[i];return s&&this.gl.isProgram(s)||(this.programs[i]=s=a(this.gl,e.shader,t.shader,r,n),e.programs.push(i),t.programs.push(i)),s}},{"weakmap-shim":52}],50:[function(e,t,r){function n(){var e={};return function(t){if(("object"!=typeof t||null===t)&&"function"!=typeof t)throw new Error("Weakmap-shim: Key must be object");var r=t.valueOf(e);return r&&r.identity===e?r:i(t,e)}}var i=e("./hidden-store.js");t.exports=n},{"./hidden-store.js":51}],51:[function(e,t,r){function n(e,t){var r={identity:t},n=e.valueOf;return Object.defineProperty(e,"valueOf",{value:function(e){return e!==t?n.apply(this,arguments):r},writable:!0}),r}t.exports=n},{}],52:[function(e,t,r){function n(){var e=i();return{get:function(t,r){var n=e(t);return n.hasOwnProperty("value")?n.value:r},set:function(t,r){e(t).value=r},has:function(t){return"value"in e(t)},"delete":function(t){return delete e(t).value}}}var i=e("./create-store.js");t.exports=n},{"./create-store.js":50}],53:[function(e,t,r){"use strict";function n(e){if(!e)return o;for(var t=0;t>",rrshift:">>>"};!function(){for(var e in u){var t=u[e];r[e]=s({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),r[e+"eq"]=s({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:e+"eq"}),r[e+"s"]=s({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),r[e+"seq"]=s({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:e+"seq"})}}();var h={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var e in h){var t=h[e];r[e]=s({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:e}),r[e+"eq"]=s({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:e+"eq"})}}();var f={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var e in f){var t=f[e];r[e]=s({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),r[e+"s"]=s({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),r[e+"eq"]=s({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:e+"eq"}),r[e+"seq"]=s({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:e+"seq"})}}();var l=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var e=0;ethis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=a({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=a({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=a({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=s({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=s({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=s({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=a({args:["array","array"],pre:o,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":54}],54:[function(e,t,r){"use strict";function n(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function i(e){var t=new n;t.pre=e.pre,t.body=e.body,t.post=e.post;var r=e.args.slice(0);t.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===a)t.scalarArgs.push(i),t.shimArgs.push("scalar"+i);else if("index"===a){if(t.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===a){if(t.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,s(t)}var s=e("./lib/thunk.js");t.exports=i},{"./lib/thunk.js":56}],55:[function(e,t,r){"use strict";function n(e,t,r){var n,i,s=e.length,a=t.arrayArgs.length,o=t.indexArgs.length>0,u=[],h=[],f=0,l=0;for(n=0;s>n;++n)h.push(["i",n,"=0"].join(""));for(i=0;a>i;++i)for(n=0;s>n;++n)l=f,f=e[n],0===n?h.push(["d",i,"s",n,"=t",i,"p",f].join("")):h.push(["d",i,"s",n,"=(t",i,"p",f,"-s",l,"*t",i,"p",l,")"].join(""));for(u.push("var "+h.join(",")),n=s-1;n>=0;--n)f=e[n],u.push(["for(i",n,"=0;i",n,"n;++n){for(l=f,f=e[n],i=0;a>i;++i)u.push(["p",i,"+=d",i,"s",n].join(""));o&&(n>0&&u.push(["index[",l,"]-=s",l].join("")),u.push(["++index[",f,"]"].join(""))),u.push("}")}return u.join("\n")}function i(e,t,r,i){for(var s=t.length,a=r.arrayArgs.length,o=r.blockSize,u=r.indexArgs.length>0,h=[],f=0;a>f;++f)h.push(["var offset",f,"=p",f].join(""));for(var f=e;s>f;++f)h.push(["for(var j"+f+"=SS[",t[f],"]|0;j",f,">0;){"].join("")),h.push(["if(j",f,"<",o,"){"].join("")),h.push(["s",t[f],"=j",f].join("")),h.push(["j",f,"=0"].join("")),h.push(["}else{s",t[f],"=",o].join("")),h.push(["j",f,"-=",o,"}"].join("")),u&&h.push(["index[",t[f],"]=j",f].join(""));for(var f=0;a>f;++f){for(var l=["offset"+f],c=e;s>c;++c)l.push(["j",c,"*t",f,"p",t[c]].join(""));h.push(["p",f,"=(",l.join("+"),")"].join(""))}h.push(n(t,r,i));for(var f=e;s>f;++f)h.push("}");return h.join("\n")}function s(e){for(var t=0,r=e[0].length;r>t;){for(var n=1;n0&&(r=r&&t[n]===t[n-1])}return r?t[0]:t.join("")}function u(e,t){for(var r=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,u=new Array(e.arrayArgs.length),f=new Array(e.arrayArgs.length),l=0;lv;++v)w.push(["s",v,"=SS[",v,"]"].join(""));for(var l=0;lv;++v)w.push(["t",l,"p",v,"=t",l,"[",p[l]+v,"]"].join(""));for(var v=0;v0&&w.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var E=new Array(r),l=0;r>l;++l)E[l]="0";w.push(["index=[",E.join(","),"]"].join(""))}for(var l=0;l3&&b.push(a(e.pre,e,f));var x=a(e.body,e,f),I=s(_);r>I?b.push(i(I,_[0],e,x)):b.push(n(_[0],e,x)),e.post.body.length>3&&b.push(a(e.post,e,f)),e.debug&&console.log("-----Generated cwise routine for ",t,":\n"+b.join("\n")+"\n----------");var S=[e.funcName||"unnamed","_cwise_loop_",u[0].join("s"),"m",I,o(f)].join(""),N=new Function(["function ",S,"(",y.join(","),"){",b.join("\n"),"} return ",S].join(""));return N()}var h=e("uniq");t.exports=u},{uniq:57}],56:[function(e,t,r){"use strict";function n(e){var t=["'use strict'","var CACHED={}"],r=[],n=e.funcName+"_cwise_thunk";t.push(["return function ",n,"(",e.shimArgs.join(","),"){"].join(""));for(var s=[],a=[],o=[["array",e.arrayArgs[0],".shape.slice(",Math.max(0,e.arrayBlockIndices[0]),e.arrayBlockIndices[0]<0?","+e.arrayBlockIndices[0]+")":")"].join("")],u=[],h=[],f=0;f0&&(u.push("array"+e.arrayArgs[0]+".shape.length===array"+l+".shape.length+"+(Math.abs(e.arrayBlockIndices[0])-Math.abs(e.arrayBlockIndices[f]))),h.push("array"+e.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[0])+"]===array"+l+".shape[shapeIndex+"+Math.max(0,e.arrayBlockIndices[f])+"]"))}e.arrayArgs.length>1&&(t.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),t.push("for(var shapeIndex=array"+e.arrayArgs[0]+".shape.length-"+Math.abs(e.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),t.push("if (!("+h.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),t.push("}"));for(var f=0;fa;++a)if(s=i,i=e[a],t(i,s)){if(a===r){r++;continue}e[r++]=i}return e.length=r,e}function i(e){for(var t=1,r=e.length,n=e[0],i=e[0],s=1;r>s;++s,i=n)if(i=n,n=e[s],n!==i){if(s===t){t++;continue}e[t++]=n}return e.length=t,e}function s(e,t,r){return 0===e.length?e:t?(r||e.sort(t),n(e,t)):(r||e.sort(),i(e))}t.exports=s},{}],58:[function(e,t,r){"use strict";"use restrict";function n(e){var t=32;return e&=-e,e&&t--,65535&e&&(t-=16),16711935&e&&(t-=8),252645135&e&&(t-=4),858993459&e&&(t-=2),1431655765&e&&(t-=1),t}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>e)},r.abs=function(e){var t=e>>i-1;return(e^t)-t},r.min=function(e,t){return t^(e^t)&-(t>e)},r.max=function(e,t){return e^(e^t)&-(t>e)},r.isPow2=function(e){return!(e&e-1||!e)},r.log2=function(e){var t,r;return t=(e>65535)<<4,e>>>=t,r=(e>255)<<3,e>>>=r,t|=r,r=(e>15)<<2,e>>>=r,t|=r,r=(e>3)<<1,e>>>=r,t|=r,t|e>>1},r.log10=function(e){return e>=1e9?9:e>=1e8?8:e>=1e7?7:e>=1e6?6:e>=1e5?5:e>=1e4?4:e>=1e3?3:e>=100?2:e>=10?1:0},r.popCount=function(e){return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1},r.prevPow2=function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e-(e>>>1)},r.parity=function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,e&=15,27030>>>e&1};var s=new Array(256);!function(e){for(var t=0;256>t;++t){var r=t,n=t,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;e[t]=n<>>8&255]<<16|s[e>>>16&255]<<8|s[e>>>24&255]},r.interleave2=function(e,t){return e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1},r.deinterleave2=function(e,t){return e=e>>>t&1431655765,e=858993459&(e|e>>>1),e=252645135&(e|e>>>2),e=16711935&(e|e>>>4),e=65535&(e|e>>>16),e<<16>>16},r.interleave3=function(e,t,r){return e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e|=t<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),e|r<<2},r.deinterleave3=function(e,t){return e=e>>>t&1227133513,e=3272356035&(e|e>>>2),e=251719695&(e|e>>>4),e=4278190335&(e|e>>>8),e=1023&(e|e>>>16),e<<22>>22},r.nextCombination=function(e){var t=e|e-1;return t+1|(~t&-~t)-1>>>n(e)+1}},{}],59:[function(e,t,r){"use strict";function n(e,t,r){var i=0|e[r];if(0>=i)return[];var s,a=new Array(i);if(r===e.length-1)for(s=0;i>s;++s)a[s]=t;else for(s=0;i>s;++s)a[s]=n(e,t,r+1);return a}function i(e,t){var r,n;for(r=new Array(e),n=0;e>n;++n)r[n]=t;return r}function s(e,t){switch("undefined"==typeof t&&(t=0),typeof e){case"number":if(e>0)return i(0|e,t);break;case"object":if("number"==typeof e.length)return n(e,t,0)}return[]}t.exports=s},{}],60:[function(e,t,r){(function(t,n){"use strict";function i(e){if(e){var t=e.length||e.byteLength,r=v.log2(t);E[r].push(e)}}function s(e){i(e.buffer)}function a(e){var e=v.nextPow2(e),t=v.log2(e),r=E[t];return r.length>0?r.pop():new ArrayBuffer(e)}function o(e){return new Uint8Array(a(e),0,e)}function u(e){return new Uint16Array(a(2*e),0,e)}function h(e){return new Uint32Array(a(4*e),0,e)}function f(e){return new Int8Array(a(e),0,e)}function l(e){return new Int16Array(a(2*e),0,e)}function c(e){return new Int32Array(a(4*e),0,e)}function d(e){return new Float32Array(a(4*e),0,e)}function p(e){return new Float64Array(a(8*e),0,e)}function g(e){return b?new Uint8ClampedArray(a(e),0,e):o(e)}function _(e){return new DataView(a(e),0,e)}function m(e){e=v.nextPow2(e);var t=v.log2(e),r=T[t];return r.length>0?r.pop():new n(e)}var v=e("bit-twiddle"),y=e("dup");t.__TYPEDARRAY_POOL||(t.__TYPEDARRAY_POOL={UINT8:y([32,0]),UINT16:y([32,0]),UINT32:y([32,0]),INT8:y([32,0]),INT16:y([32,0]),INT32:y([32,0]),FLOAT:y([32,0]),DOUBLE:y([32,0]),DATA:y([32,0]),UINT8C:y([32,0]),BUFFER:y([32,0])});var b="undefined"!=typeof Uint8ClampedArray,w=t.__TYPEDARRAY_POOL;w.UINT8C||(w.UINT8C=y([32,0])),w.BUFFER||(w.BUFFER=y([32,0]));var E=w.DATA,T=w.BUFFER;r.free=function(e){if(n.isBuffer(e))T[v.log2(e.length)].push(e);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(e)&&(e=e.buffer),!e)return;var t=e.length||e.byteLength,r=0|v.log2(t);E[r].push(e)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=s,r.freeArrayBuffer=i,r.freeBuffer=function(e){T[v.log2(e.length)].push(e)},r.malloc=function(e,t){if(void 0===t||"arraybuffer"===t)return a(e);switch(t){case"uint8":return o(e);case"uint16":return u(e);case"uint32":return h(e);case"int8":return f(e);case"int16":return l(e);case"int32":return c(e);case"float":case"float32":return d(e);case"double":case"float64":return p(e);case"uint8_clamped":return g(e);case"buffer":return m(e);case"data":case"dataview":return _(e);default:return null}return null},r.mallocArrayBuffer=a,r.mallocUint8=o,r.mallocUint16=u,r.mallocUint32=h,r.mallocInt8=f,r.mallocInt16=l,r.mallocInt32=c,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=_,r.mallocBuffer=m,r.clearCache=function(){for(var e=0;32>e;++e)w.UINT8[e].length=0,w.UINT16[e].length=0,w.UINT32[e].length=0,w.INT8[e].length=0,w.INT16[e].length=0,w.INT32[e].length=0,w.FLOAT[e].length=0,w.DOUBLE[e].length=0,w.UINT8C[e].length=0,E[e].length=0,T[e].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"bit-twiddle":58,buffer:27,dup:59}],61:[function(e,t,r){"use strict";function n(e){_=[e.LINEAR,e.NEAREST_MIPMAP_LINEAR,e.LINEAR_MIPMAP_NEAREST,e.LINEAR_MIPMAP_NEAREST],m=[e.NEAREST,e.LINEAR,e.NEAREST_MIPMAP_NEAREST,e.NEAREST_MIPMAP_LINEAR,e.LINEAR_MIPMAP_NEAREST,e.LINEAR_MIPMAP_LINEAR],v=[e.REPEAT,e.CLAMP_TO_EDGE,e.MIRRORED_REPEAT]}function i(e,t,r){var n=e.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(0>t||t>i||0>r||r>i)throw new Error("gl-texture2d: Invalid texture size");return e._shape=[t,r],e.bind(),n.texImage2D(n.TEXTURE_2D,0,e.format,t,r,0,e.format,e.type,null),e._mipLevels=[0],e}function s(e,t,r,n,i,s){this.gl=e,this.handle=t,this.format=i,this.type=s,this._shape=[r,n],this._mipLevels=[0],this._magFilter=e.NEAREST,this._minFilter=e.NEAREST,this._wrapS=e.CLAMP_TO_EDGE,this._wrapT=e.CLAMP_TO_EDGE,this._anisoSamples=1;var a=this,o=[this._wrapS,this._wrapT];Object.defineProperties(o,[{get:function(){return a._wrapS},set:function(e){return a.wrapS=e}},{get:function(){return a._wrapT},set:function(e){return a.wrapT=e}}]),this._wrapVector=o;var u=[this._shape[0],this._shape[1]];Object.defineProperties(u,[{get:function(){return a._shape[0]},set:function(e){return a.width=e}},{get:function(){return a._shape[1]},set:function(e){return a.height=e}}]),this._shapeVector=u}function a(e,t){return 3===e.length?1===t[2]&&t[1]===e[0]*e[2]&&t[0]===e[2]:1===t[0]&&t[1]===e[0]}function o(e,t,r,n,i,s,o,u){var h=u.dtype,f=u.shape.slice();if(f.length<2||f.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var l=0,c=0,_=a(f,u.stride.slice());"float32"===h?l=e.FLOAT:"float64"===h?(l=e.FLOAT,_=!1,h="float32"):"uint8"===h?l=e.UNSIGNED_BYTE:(l=e.UNSIGNED_BYTE,_=!1,h="uint8");var m=1;if(2===f.length)c=e.LUMINANCE,f=[f[0],f[1],1],u=d(u.data,f,[u.stride[0],u.stride[1],1],u.offset);else{if(3!==f.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===f[2])c=e.ALPHA;else if(2===f[2])c=e.LUMINANCE_ALPHA;else if(3===f[2])c=e.RGB;else{if(4!==f[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");c=e.RGBA}m=f[2]}if(c!==e.LUMINANCE&&c!==e.ALPHA||i!==e.LUMINANCE&&i!==e.ALPHA||(c=i),c!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var v=u.size,b=o.indexOf(n)<0;if(b&&o.push(n),l===s&&_)0===u.offset&&u.data.length===v?b?e.texImage2D(e.TEXTURE_2D,n,i,f[0],f[1],0,i,s,u.data):e.texSubImage2D(e.TEXTURE_2D,n,t,r,f[0],f[1],i,s,u.data):b?e.texImage2D(e.TEXTURE_2D,n,i,f[0],f[1],0,i,s,u.data.subarray(u.offset,u.offset+v)):e.texSubImage2D(e.TEXTURE_2D,n,t,r,f[0],f[1],i,s,u.data.subarray(u.offset,u.offset+v));else{var w;w=s===e.FLOAT?g.mallocFloat32(v):g.mallocUint8(v);var E=d(w,f,[f[2],f[2]*f[0],1]);l===e.FLOAT&&s===e.UNSIGNED_BYTE?y(E,u):p.assign(E,u),b?e.texImage2D(e.TEXTURE_2D,n,i,f[0],f[1],0,i,s,w.subarray(0,v)):e.texSubImage2D(e.TEXTURE_2D,n,t,r,f[0],f[1],i,s,w.subarray(0,v)),s===e.FLOAT?g.freeFloat32(w):g.freeUint8(w)}}function u(e){var t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}function h(e,t,r,n,i){var a=e.getParameter(e.MAX_TEXTURE_SIZE);if(0>t||t>a||0>r||r>a)throw new Error("gl-texture2d: Invalid texture shape");if(i===e.FLOAT&&!e.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var o=u(e);return e.texImage2D(e.TEXTURE_2D,0,n,t,r,0,n,i,null),new s(e,o,t,r,n,i)}function f(e,t,r,n){var i=u(e);return e.texImage2D(e.TEXTURE_2D,0,r,r,n,t),new s(e,i,0|t.width,0|t.height,r,n)}function l(e,t){var r=t.dtype,n=t.shape.slice(),i=e.getParameter(e.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var o=a(n,t.stride.slice()),h=0;"float32"===r?h=e.FLOAT:"float64"===r?(h=e.FLOAT,o=!1,r="float32"):"uint8"===r?h=e.UNSIGNED_BYTE:(h=e.UNSIGNED_BYTE,o=!1,r="uint8");var f=0;if(2===n.length)f=e.LUMINANCE,n=[n[0],n[1],1],t=d(t.data,n,[t.stride[0],t.stride[1],1],t.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])f=e.ALPHA;else if(2===n[2])f=e.LUMINANCE_ALPHA;else if(3===n[2])f=e.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");f=e.RGBA}}h!==e.FLOAT||e.getExtension("OES_texture_float")||(h=e.UNSIGNED_BYTE,o=!1);var l,c,_=t.size;if(o)l=0===t.offset&&t.data.length===_?t.data:t.data.subarray(t.offset,t.offset+_);else{var m=[n[2],n[2]*n[0],1];c=g.malloc(_,r);var v=d(c,n,m,0);"float32"!==r&&"float64"!==r||h!==e.UNSIGNED_BYTE?p.assign(v,t):y(v,t),l=c.subarray(0,_)}var b=u(e);return e.texImage2D(e.TEXTURE_2D,0,f,n[0],n[1],0,f,h,l),o||g.free(c),new s(e,b,n[0],n[1],f,h)}function c(e){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(_||n(e),"number"==typeof arguments[1])return h(e,arguments[1],arguments[2],arguments[3]||e.RGBA,arguments[4]||e.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return h(e,0|arguments[1][0],0|arguments[1][1],arguments[2]||e.RGBA,arguments[3]||e.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var t=arguments[1];if(t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof ImageData)return f(e,t,arguments[2]||e.RGBA,arguments[3]||e.UNSIGNED_BYTE);if(t.shape&&t.data&&t.stride)return l(e,t)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var d=e("ndarray"),p=e("ndarray-ops"),g=e("typedarray-pool");t.exports=c;var _=null,m=null,v=null,y=function(e,t){p.muls(e,t,255)},b=s.prototype;Object.defineProperties(b,{minFilter:{get:function(){return this._minFilter},set:function(e){this.bind();var t=this.gl;if(this.type===t.FLOAT&&_.indexOf(e)>=0&&(t.getExtension("OES_texture_float_linear")||(e=t.NEAREST)),m.indexOf(e)<0)throw new Error("gl-texture2d: Unknown filter mode "+e);return t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e),this._minFilter=e}},magFilter:{get:function(){return this._magFilter},set:function(e){this.bind();var t=this.gl;if(this.type===t.FLOAT&&_.indexOf(e)>=0&&(t.getExtension("OES_texture_float_linear")||(e=t.NEAREST)),m.indexOf(e)<0)throw new Error("gl-texture2d: Unknown filter mode "+e);return t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,e),this._magFilter=e}},mipSamples:{get:function(){return this._anisoSamples},set:function(e){var t=this._anisoSamples;if(this._anisoSamples=0|Math.max(e,1),t!==this._anisoSamples){var r=gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(e){if(this.bind(),v.indexOf(e)<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,e),this._wrapS=e}},wrapT:{get:function(){return this._wrapT},set:function(e){if(this.bind(),v.indexOf(e)<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,e),this._wrapT=e}},wrap:{get:function(){return this._wrapVector},set:function(e){if(Array.isArray(e)||(e=[e,e]),2!==e.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var t=0;2>t;++t)if(v.indexOf(e[t])<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);this._wrapS=e[0],this._wrapT=e[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),e}},shape:{get:function(){return this._shapeVector},set:function(e){if(Array.isArray(e)){if(2!==e.length)throw new Error("gl-texture2d: Invalid texture shape")}else e=[0|e,0|e];return i(this,0|e[0],0|e[1]),[0|e[0],0|e[1]]}},width:{get:function(){return this._shape[0]},set:function(e){return e=0|e,i(this,e,this._shape[1]),e}},height:{get:function(){return this._shape[1]},set:function(e){return e=0|e,i(this,this._shape[0],e),e}}}),b.bind=function(e){var t=this.gl;return void 0!==e&&t.activeTexture(t.TEXTURE0+(0|e)),t.bindTexture(t.TEXTURE_2D,this.handle),void 0!==e?0|e:t.getParameter(t.ACTIVE_TEXTURE)-t.TEXTURE0},b.dispose=function(){this.gl.deleteTexture(this.handle)},b.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var e=Math.min(this._shape[0],this._shape[1]),t=0;e>0;++t,e>>>=1)this._mipLevels.indexOf(t)<0&&this._mipLevels.push(t)},b.setPixels=function(e,t,r,n){var i=this.gl;if(this.bind(),Array.isArray(t)?(n=r,r=0|t[1],t=0|t[0]):(t=t||0,r=r||0),n=n||0,e instanceof HTMLCanvasElement||e instanceof ImageData||e instanceof HTMLImageElement||e instanceof HTMLVideoElement){var s=this._mipLevels.indexOf(n)<0;s?(i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,this.type,e),this._mipLevels.push(n)):i.texSubImage2D(i.TEXTURE_2D,n,t,r,this.format,this.type,e)}else{if(!(e.shape&&e.stride&&e.data))throw new Error("gl-texture2d: Unsupported data type");if(e.shape.length<2||t+e.shape[1]>this._shape[1]>>>n||r+e.shape[0]>this._shape[0]>>>n||0>t||0>r)throw new Error("gl-texture2d: Texture dimensions are out of bounds");o(i,t,r,n,this.format,this.type,this._mipLevels,e)}}},{ndarray:67,"ndarray-ops":53,"typedarray-pool":60}],62:[function(e,t,r){t.exports={glsl:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 resolution;uniform sampler2D from, to;uniform float progress;void main() {vec2 p = gl_FragCoord.xy / resolution;gl_FragColor = mix(texture2D(from, p), texture2D(to, p), progress);}",uniforms:{},id:"7e61b1f44a391f0c0894",name:"fade",owner:"glslioadmin",html_url:"https://gist.github.com/glslioadmin/7e61b1f44a391f0c0894",created_at:"2014-05-16T00:00:00Z",updated_at:"2014-05-16T00:00:00Z",stars:0}},{}],63:[function(e,t,r){function n(e,t){return this instanceof n?(this.gl=e,this.shader=i(e,s,t),void(this.buffer=e.createBuffer())):new n(e,t)}var i=e("gl-shader"),s="attribute vec2 position; void main() { gl_Position = vec4(2.0*position-1.0, 0.0, 1.0);}";t.exports=n,n.prototype={dispose:function(){this.shader.dispose(),this.gl.deleteBuffer(this.buffer),this.shader=null,this.buffer=null},render:function(e,t,r,n){var i=this.gl,s=this.shader,a=0;s.bind(),this._checkViewport(),s.uniforms.progress=e,s.uniforms.from=t.bind(a++),s.uniforms.to=r.bind(a++);for(var o in n){var u=n[o];u&&u.bind?s.uniforms[o]=u.bind(a++):s.uniforms[o]!==u&&(s.uniforms[o]=u)}i.drawArrays(i.TRIANGLES,0,6)},_checkViewport:function(){var e=this.gl,t=e.canvas,r=t.width,n=t.height;(this._w!==r||this._h!==n)&&(this._syncViewport(r,n),this._w=r,this._h=n)},_syncViewport:function(e,t){var r=this.gl,n=this.shader,i=this.buffer,s=0,a=e,o=0,u=t;n.uniforms.resolution=new Float32Array([e,t]),r.bindBuffer(r.ARRAY_BUFFER,i),n.attributes.position.pointer(),r.bufferData(r.ARRAY_BUFFER,new Float32Array([s,o,a,o,s,u,s,u,a,o,a,u]),r.STATIC_DRAW),r.viewport(s,o,a,u)}}},{"gl-shader":44}],64:[function(e,t,r){function n(e){this.elt=e,"absolute"!==e.style.position&&(e.style.position="relative"),e.style.overflow="hidden"}var i=e("vendor-prefix"),s=i("transform"),a=i("transform-origin");n.prototype={clamped:!0,rgb:[0,0,0],getViewport:function(){return this.elt.getBoundingClientRect()},abort:function(){this.reset()},_transformForRect:function(e){var t=this.getViewport(),r=t.width/e[2],n=[-e[0]+"px",-e[1]+"px"];return"scale("+r+") translate("+n+")"},_reset:function(){this.elt.style.backgroundColor="rgb("+this.rgb.map(function(e){return 255*e})+")",this.elt.innerHTML=""},_setImage:function(e){e!==this.image&&(this._reset(),this.elt.appendChild(e),e.style.position="absolute",e.style.top=0,e.style.left=0,e.style[a]="0% 0%",this.image=e)},_positionImage:function(e){this.image.style[s]=this._transformForRect(e)},runStart:function(e){this._setImage(e)},draw:function(e,t){this._positionImage(t)}},t.exports=n},{"vendor-prefix":65}],65:[function(e,t,r){"use strict";function n(e){return e in f?f[e]:f[e]=i(e)}function i(e){var t,r=e.replace(/-([a-z])/g,function(e,t){return t.toUpperCase()}),n=u.length;if(void 0!==o[r])return r;for(r=s(e);n--;)if(t=u[n]+r,void 0!==o[t])return t;throw new Error("unable to prefix "+e)}function s(e){return e.charAt(0).toUpperCase()+e.slice(1)}function a(e){var t=n(e),r=/([A-Z])/g;return r.test(t)&&(t=(h.test(t)?"-":"")+t.replace(r,"-$1")),t.toLowerCase()}var o=document.createElement("p").style,u="O ms Moz webkit".split(" "),h=/^(o|ms|moz|webkit)/,f={};t.exports=n,t.exports.dash=a},{}],66:[function(e,t,r){function n(e){return this instanceof n?(this.gl=e,this.shader=i(e,"#define GLSLIFY 1\nvarying vec2 uv;\n\nattribute vec2 p;\n\nuniform vec2 imgRes; // image size\nuniform vec2 pos; // bound position\nuniform vec2 dim; // bound size\n\nvoid main() {\n uv = pos/imgRes + ((p * vec2(1.,-1.)+1.)/2.) * (dim/imgRes);\n gl_Position = vec4(p,0.,1.);\n}\n","#define GLSLIFY 1\nprecision highp float;\n\nvarying vec2 uv;\n\nuniform sampler2D img;\nuniform vec3 bg;\n\nvoid main() {\n if(uv.x<0.||uv.x>1.||uv.y<0.||uv.y>1.)\n gl_FragColor = vec4(bg, 1.0);\n else\n gl_FragColor = texture2D(img, uv);\n}\n"),this.buffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.buffer),void e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW)):new n(e)}var i=e("gl-shader");n.prototype={clamped:!0,rgb:[0,0,0],dispose:function(){this.shader.dispose(),this.gl.deleteBuffer(this.buffer),this.gl=null,this.shader=null,this.buffer=null},render:function(e,t){var r=t[0],n=t[1],i=t[2],s=t[3];if(isNaN(r)||isNaN(n)||isNaN(i)||isNaN(s))throw new Error("invalid numbers in bound: "+t);var a=this.gl,o=this.shader;o.bind(),a.bindBuffer(a.ARRAY_BUFFER,this.buffer),o.attributes.p.pointer(),o.uniforms.imgRes=e.shape.slice(0,2),o.uniforms.bg=this.rgb,o.uniforms.img=e.bind(),o.uniforms.pos=[r,n],o.uniforms.dim=[i,s],a.drawArrays(a.TRIANGLES,0,6)},getViewport:function(){return{width:this.gl.drawingBufferWidth,height:this.gl.drawingBufferHeight}}},t.exports=n},{"gl-shader":44}],67:[function(e,t,r){function n(e,t){return e[0]-t[0]}function i(){var e,t=this.stride,r=new Array(t.length);for(e=0;et&&(r="View_Nil"+e);var n="generic"===e;if(-1===t){var s="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",a=new Function(s);return a()}if(0===t){var s="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",a=new Function("TrivialArray",s);return a(l[e][0])}var s=["'use strict'"],o=u(t),h=o.map(function(e){return"i"+e}),f="this.offset+"+o.map(function(e){return"this.stride["+e+"]*i"+e}).join("+"),c=o.map(function(e){return"b"+e}).join(","),d=o.map(function(e){return"c"+e}).join(",");s.push("function "+r+"(a,"+c+","+d+",d){this.data=a","this.shape=["+c+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),s.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+o.map(function(e){return"this.shape["+e+"]"}).join("*"),"}})"),1===t?s.push("proto.order=[0]"):(s.push("Object.defineProperty(proto,'order',{get:"),4>t?(s.push("function "+r+"_order(){"),2===t?s.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===t&&s.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):s.push("ORDER})")),s.push("proto.set=function "+r+"_set("+h.join(",")+",v){"),n?s.push("return this.data.set("+f+",v)}"):s.push("return this.data["+f+"]=v}"),s.push("proto.get=function "+r+"_get("+h.join(",")+"){"),n?s.push("return this.data.get("+f+")}"):s.push("return this.data["+f+"]}"),s.push("proto.index=function "+r+"_index(",h.join(),"){return "+f+"}"),s.push("proto.hi=function "+r+"_hi("+h.join(",")+"){return new "+r+"(this.data,"+o.map(function(e){return["(typeof i",e,"!=='number'||i",e,"<0)?this.shape[",e,"]:i",e,"|0"].join("")}).join(",")+","+o.map(function(e){return"this.stride["+e+"]"}).join(",")+",this.offset)}");var p=o.map(function(e){return"a"+e+"=this.shape["+e+"]"}),g=o.map(function(e){return"c"+e+"=this.stride["+e+"]"});s.push("proto.lo=function "+r+"_lo("+h.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var _=0;t>_;++_)s.push("if(typeof i"+_+"==='number'&&i"+_+">=0){d=i"+_+"|0;b+=c"+_+"*d;a"+_+"-=d}");s.push("return new "+r+"(this.data,"+o.map(function(e){return"a"+e}).join(",")+","+o.map(function(e){return"c"+e}).join(",")+",b)}"),s.push("proto.step=function "+r+"_step("+h.join(",")+"){var "+o.map(function(e){return"a"+e+"=this.shape["+e+"]"}).join(",")+","+o.map(function(e){return"b"+e+"=this.stride["+e+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var _=0;t>_;++_)s.push("if(typeof i"+_+"==='number'){d=i"+_+"|0;if(d<0){c+=b"+_+"*(a"+_+"-1);a"+_+"=ceil(-a"+_+"/d)}else{a"+_+"=ceil(a"+_+"/d)}b"+_+"*=d}");s.push("return new "+r+"(this.data,"+o.map(function(e){return"a"+e}).join(",")+","+o.map(function(e){return"b"+e}).join(",")+",c)}");for(var m=new Array(t),v=new Array(t),_=0;t>_;++_)m[_]="a[i"+_+"]",v[_]="b[i"+_+"]";s.push("proto.transpose=function "+r+"_transpose("+h+"){"+h.map(function(e,t){return e+"=("+e+"===undefined?"+t+":"+e+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+v.join(",")+",this.offset)}"),s.push("proto.pick=function "+r+"_pick("+h+"){var a=[],b=[],c=this.offset");for(var _=0;t>_;++_)s.push("if(typeof i"+_+"==='number'&&i"+_+">=0){c=(c+this.stride["+_+"]*i"+_+")|0}else{a.push(this.shape["+_+"]);b.push(this.stride["+_+"])}");s.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),s.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+o.map(function(e){return"shape["+e+"]"}).join(",")+","+o.map(function(e){return"stride["+e+"]"}).join(",")+",offset)}");var a=new Function("CTOR_LIST","ORDER",s.join("\n"));return a(l[e],i)}function a(e){if(h(e))return"buffer";if(f)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(e)?"array":"generic"}function o(e,t,r,n){if(void 0===e){var i=l.array[0];return i([])}"number"==typeof e&&(e=[e]),void 0===t&&(t=[e.length]);var o=t.length;if(void 0===r){r=new Array(o);for(var u=o-1,h=1;u>=0;--u)r[u]=h,h*=t[u]}if(void 0===n){n=0;for(var u=0;o>u;++u)r[u]<0&&(n-=(t[u]-1)*r[u])}for(var f=a(e),c=l[f];c.length<=o+1;)c.push(s(f,c.length-1));var i=c[o+1];return i(e,t,r,n)}var u=e("iota-array"),h=e("is-buffer"),f="undefined"!=typeof Float64Array,l={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};t.exports=o},{"iota-array":68,"is-buffer":69}],68:[function(e,t,r){"use strict";function n(e){for(var t=new Array(e),r=0;e>r;++r)t[r]=r;return t}t.exports=n},{}],69:[function(e,t,r){t.exports=function(e){return!(null==e||!e.constructor||"function"!=typeof e.constructor.isBuffer||!e.constructor.isBuffer(e))}},{}],70:[function(e,t,r){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}t.exports=Object.assign||function(e,t){for(var r,i,s=n(e),a=1;ai&&(r=i,n=~~(r/a)),n>s&&(n=s,r=~~(n*a)),[t[0]+Math.max(0,Math.min(e[0],i-r)),t[1]+Math.max(0,Math.min(e[1],s-n)),r,n]}},{}],74:[function(e,t,r){function n(e,t){return t||(t=[.5,.5]),function(r,n){var i=r.width/r.height,s=n.width/n.height,a=Math.max(i,s),o=[i/a*n.width*e,s/a*n.height*e];return[n.width*t[0]-o[0]/2,n.height*t[1]-o[1]/2,o[0],o[1]]}}n.largest=n(1),t.exports=n},{}],75:[function(e,t,r){function n(e,t,r){return e*(1-r)+t*r}t.exports=function(e,t,r){for(var i=[],s=0;4>s;++s)i[s]=n(e[s],t[s],r);return i}},{}],76:[function(e,t,r){function n(e,t){var r=Error.call(this,e);this.name=r.name="UnsupportedDrawOperation",this.stack=r.stack,this.message=r.message,this.path=t}function i(e){if(e in this._imgs)return this._imgs[e];var t=new window.Image;return t.crossOrigin=!0,t.src=e,this._imgs[e]=t,t.onload=this.flush.bind(this),t}function s(e,t){return this instanceof s?(this.ctx=e,this._imgs={},void(this.resolveImage=t?function(e){var r=t(e);return"string"==typeof r?i.call(this,r):r}:i)):new s(e,t)}var a=e("draw-image-normalized"),o=e("rect-crop"),u={background:"#000",size:[1e3,1e3],draws:[]};n.prototype=Object.create(Error.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),s.defaultResolveImage=i,s.defaults=u,s.prototype={destroy:function(){this._item=null,this._imgs=null,this.ctx=null},getSize:function(e){return e.size||u.size},getRectangle:function(e){var t=this.getSize(e),r=t[0],n=t[1];return o.largest({width:r,height:n},this.ctx.canvas)},flush:function(){this._item&&this.render(this._item)},render:function(e,t){this._item=e;var r=this.ctx,n=r.canvas,i=n.width,s=n.height,a=e.background||u.size,o=this.getSize(e),h=this.getRectangle(e),f=o[0],l=o[1];r.save(),r.fillStyle=a,r.fillRect(0,0,i,s),r.translate(Math.round(h[0]),Math.round(h[1])),r.scale(h[2]/f,h[3]/l),this._renderRec(e.draws||u.draws,[],t||function(){}),r.restore()},_renderRec:function(e,t,r){for(var n=this.ctx,i=e.length,s=0;i>s;++s){var a=e[s],o=t.concat([s]);if(a instanceof Array){var u=a[0];"object"==typeof u?(n.save(),this._renderRec(a,o,r),n.restore()):this._renderOp(u,a.slice(1),o)}else for(var h in a)n[h]=a[h];r(o,a)}},_renderOp:function(e,t,r){var i=this.ctx;if("string"!=typeof e)throw new n("must be a string operation: "+e,r);switch(e){case"drawImage":var s="string"==typeof t[0]?this.resolveImage(t[0]):s;a.apply(null,[i,s].concat(t.slice(1)));break;case"fillText":case"strokeText":var o=t[0],u=o.split("\n"),h=u.length,f=t[1],l=t[2];if(1===h||t.length<4)i[e].call(i,o,f,l);else for(var c=t[3],d=0;h>d;++d)i[e].call(i,u[d],f,l+d*c);break;default:var p=i[e];if("function"!=typeof p)throw new n(e,r);p.apply(i,t)}}},t.exports=s},{"draw-image-normalized":77,"rect-crop":74}],77:[function(e,t,r){t.exports=function(e,t,r,n,i,s,a,o,u,h){if(arguments.length<=6&&(a=r,o=n,u=i,h=s,r=0,n=0,i=t.width,s=t.height),arguments.length<=4&&(u=i,h=s),0>r&&(a-=r*u/i,u+=r*u/i,i+=r,r=0),0>n&&(o-=n*h/s,h+=n*h/s,s+=n,n=0),r+i>t.width){var f=r+i-t.width;u*=(i-f)/i,i=t.width}if(n+s>t.height){var l=n+s-t.height;h*=(s-l)/s,s=t.height}0>=i||0>=s||0>=u||0>=h||e.drawImage.apply(e,[t,r,n,i,s,a,o,u,h])}},{}],78:[function(e,t,r){!function(){"use strict";function e(t){t.permitHostObjects___&&t.permitHostObjects___(e)}function r(e){return!(e.substr(0,d.length)==d&&"___"===e.substr(e.length-3))}function n(e){if(e!==Object(e))throw new TypeError("Not an object: "+e);var t=e[p];if(t&&t.key===e)return t;if(!c(e))return void 0;t={key:e};try{return l(e,p,{value:t,writable:!1,enumerable:!1,configurable:!1}),t}catch(r){return void 0}}function i(e){return e.prototype=null,Object.freeze(e)}function s(){v||"undefined"==typeof console||(v=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}if("undefined"==typeof ses||!ses.ok||ses.ok()){"undefined"!=typeof ses&&(ses.weakMapPermitHostObjects=e);var a=!1;if("function"==typeof WeakMap){var o=WeakMap;if("undefined"!=typeof navigator&&/Firefox/.test(navigator.userAgent));else{var u=new o,h=Object.freeze({});if(u.set(h,1),1===u.get(h))return void(t.exports=WeakMap);a=!0}}var f=(Object.prototype.hasOwnProperty,Object.getOwnPropertyNames),l=Object.defineProperty,c=Object.isExtensible,d="weakmap:",p=d+"ident:"+Math.random()+"___";if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof ArrayBuffer&&"function"==typeof Uint8Array){var g=new ArrayBuffer(25),_=new Uint8Array(g);crypto.getRandomValues(_),p=d+"rand:"+Array.prototype.map.call(_,function(e){return(e%36).toString(36)}).join("")+"___"}if(l(Object,"getOwnPropertyNames",{value:function(e){return f(e).filter(r)}}),"getPropertyNames"in Object){var m=Object.getPropertyNames;l(Object,"getPropertyNames",{value:function(e){return m(e).filter(r)}})}!function(){var e=Object.freeze;l(Object,"freeze",{value:function(t){return n(t),e(t)}});var t=Object.seal;l(Object,"seal",{value:function(e){return n(e),t(e)}});var r=Object.preventExtensions;l(Object,"preventExtensions",{value:function(e){return n(e),r(e)}})}();var v=!1,y=0,b=function(){function e(e,t){var r,i=n(e);return i?h in i?i[h]:t:(r=o.indexOf(e),r>=0?u[r]:t)}function t(e){var t=n(e);return t?h in t:o.indexOf(e)>=0}function r(e,t){var r,i=n(e);return i?i[h]=t:(r=o.indexOf(e),r>=0?u[r]=t:(r=o.length,u[r]=t,o[r]=e)),this}function a(e){var t,r,i=n(e);return i?h in i&&delete i[h]:(t=o.indexOf(e),0>t?!1:(r=o.length-1,o[t]=void 0,u[t]=u[r],o[t]=o[r],o.length=r,u.length=r,!0))}this instanceof b||s();var o=[],u=[],h=y++;return Object.create(b.prototype,{get___:{value:i(e)},has___:{value:i(t)},set___:{value:i(r)},delete___:{value:i(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function(e,t){return this.get___(e,t)},writable:!0,configurable:!0},has:{value:function(e){return this.has___(e)},writable:!0,configurable:!0},set:{value:function(e,t){return this.set___(e,t)},writable:!0,configurable:!0},"delete":{value:function(e){return this.delete___(e)},writable:!0,configurable:!0}}),"function"==typeof o?!function(){function r(){function t(e,t){return f?h.has(e)?h.get(e):f.get___(e,t):h.get(e,t)}function r(e){return h.has(e)||(f?f.has___(e):!1)}function n(e){var t=!!h["delete"](e);return f?f.delete___(e)||t:t}this instanceof b||s();var u,h=new o,f=void 0,l=!1;return u=a?function(e,t){return h.set(e,t),h.has(e)||(f||(f=new b),f.set(e,t)),this}:function(e,t){if(l)try{h.set(e,t)}catch(r){f||(f=new b),f.set___(e,t)}else h.set(e,t);return this},Object.create(b.prototype,{get___:{value:i(t)},has___:{value:i(r)},set___:{value:i(u)},delete___:{value:i(n)},permitHostObjects___:{value:i(function(t){if(t!==e)throw new Error("bogus call to permitHostObjects___");l=!0})}})}a&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=b.prototype,t.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),t.exports=b)}}()},{}],79:[function(e,t,r){"use strict";function n(e){return e.replace(/^[A-Z]+_/,"")}function i(e){var t=a.get(e);if(t)return t;for(var r={},i=e.getSupportedExtensions(),s=0;s