!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["webgl-rendering-debugger"]=e():t["webgl-rendering-debugger"]=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var o,r=(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(Error),s=function(){function t(){this._count=0}return Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),t.prototype.resetCount=function(){this._count=0},t.prototype.getInvokingTasks=function(){var t=this;return{drawElements:[function(e,n,o,r){t._count++}],drawArrays:[function(e,n,o){t._count++}]}},t}(),c=function(){function t(){this._count=0}return Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),t.prototype.resetCount=function(){this._count=0},t.prototype.getInvokingTasks=function(){var t=this;return{drawElements:[function(e,n,o,r){t._count+=n}],drawArrays:[function(e,n,o){t._count+=o}]}},t}(),u=Object.freeze({DRAW_CALLS:s.name,POLYGON:c.name});n.d(e,"default",function(){return a}),n.d(e,"DrawCall",function(){return s}),n.d(e,"Polygon",function(){return c}),n.d(e,"WebGLRenderingDebuggerError",function(){return i});var a=function(){function t(t){this.context=t,this.inspectors={},this.preservations={},this.invokations={},this.invokationsInspectorKeyCache={}}return t.createInspector=function(t){switch(t){case u.DRAW_CALLS:return new s;case u.POLYGON:return new c;default:return null}},t.prototype.getAttachedInstpector=function(t){return this.inspectors[t]},t.prototype.attach=function(e){if(this.inspectors.hasOwnProperty(e))throw new i;var n=t.createInspector(e);if(null!==n){this.inspectors[e]=n;for(var o=this.inspectors[e].getInvokingTasks(),r=Object.keys(o),s=0;s<r.length;s++){var c=r[s];this.attachInspector(c,e,o[c])}}},t.prototype.attachInspector=function(t,e,n){this.invokations.hasOwnProperty(t)||(this.invokations[t]={},this.invokationsInspectorKeyCache[t]=[]),this.invokations[t][e]=n,this.invokationsInspectorKeyCache[t].push(e),this.preservations.hasOwnProperty(t)||this.replaceContextMethod(t)},t.prototype.detach=function(t){for(var e=Object.keys(this.invokations),n=0;n<e.length;n++){var o=e[n];this.detachInspector(o,t),this.restorePropertyIfNeeded(o)}delete this.inspectors[t]},t.prototype.detachInspector=function(t,e){if(this.invokations[t].hasOwnProperty(e)){delete this.invokations[t][e];var n=this.invokationsInspectorKeyCache[t].indexOf(e);n>=0&&this.invokationsInspectorKeyCache[t].splice(n,1)}},t.prototype.restorePropertyIfNeeded=function(t){Object.keys(this.invokations[t]).length>0||(this.context[t]=this.preservations[t],delete this.invokations[t],delete this.invokationsInspectorKeyCache[t],delete this.preservations[t])},t.prototype.replaceContextMethod=function(t){var e=this;this.preservations[t]=this.context[t],this.context[t]=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];for(var r,i=e.invokationsInspectorKeyCache[t],s=0;s<i.length;s++)for(var c=e.invokations[t][i[s]],u=0;u<c.length;u++)c[u].apply(c,n);(r=e.preservations[t]).call.apply(r,[e.context].concat(n))}},t.Inspectors=u,t}()}])});