@turbox3d/shared
Version:
turbox shared internal utility
2 lines • 22.7 kB
JavaScript
/*! For license information please see index.min.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("THREE")):"function"==typeof define&&define.amd?define(["THREE"],e):"object"==typeof exports?exports["@turbox3d/shared"]=e(require("THREE")):t.Shared=e(t.THREE)}(self,(t=>(()=>{var e={207:(t,e,r)=>{var n=r(840)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},791:t=>{function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},840:(t,e,r)=>{var n=r(791).default;function o(){"use strict";t.exports=o=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var e,r={},i=Object.prototype,a=i.hasOwnProperty,u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",f=u.asyncIterator||"@@asyncIterator",s=u.toStringTag||"@@toStringTag";function l(t,e,r,n){return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{l({},"")}catch(e){l=function(t,e,r){return t[e]=r}}function h(t,r,n,o){var i=r&&r.prototype instanceof y?r:y,a=Object.create(i.prototype);return l(a,"_invoke",function(t,r,n){var o=1;return function(i,a){if(3===o)throw Error("Generator is already running");if(4===o){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=E(u,n);if(c){if(c===d)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===o)throw o=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=3;var f=p(t,r,n);if("normal"===f.type){if(o=n.done?4:2,f.arg===d)continue;return{value:f.arg,done:n.done}}"throw"===f.type&&(o=4,n.method="throw",n.arg=f.arg)}}}(t,n,new A(o||[])),!0),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var d={};function y(){}function v(){}function g(){}var b={};l(b,c,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(T([])));w&&w!==i&&a.call(w,c)&&(b=w);var x=g.prototype=y.prototype=Object.create(b);function j(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,i,u,c){var f=p(t[o],t,i);if("throw"!==f.type){var s=f.arg,l=s.value;return l&&"object"==n(l)&&a.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,u,c)}),(function(t){r("throw",t,u,c)})):e.resolve(l).then((function(t){s.value=t,u(s)}),(function(t){return r("throw",t,u,c)}))}c(f.arg)}var o;l(this,"_invoke",(function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}),!0)}function E(t,r){var n=r.method,o=t.i[n];if(o===e)return r.delegate=null,"throw"===n&&t.i.return&&(r.method="return",r.arg=e,E(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=p(o,t.i,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var a=i.arg;return a?a.done?(r[t.r]=a.value,r.next=t.n,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function S(t){this.tryEntries.push(t)}function R(t){var r=t[4]||{};r.type="normal",r.arg=e,t[4]=r}function A(t){this.tryEntries=[[-1]],t.forEach(S,this),this.reset(!0)}function T(t){if(null!=t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(a.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(n(t)+" is not iterable")}return v.prototype=g,l(x,"constructor",g),l(g,"constructor",v),v.displayName=l(g,s,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,l(t,s,"GeneratorFunction")),t.prototype=Object.create(x),t},r.awrap=function(t){return{__await:t}},j(O.prototype),l(O.prototype,f,(function(){return this})),r.AsyncIterator=O,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new O(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(x),l(x,s,"Generator"),l(x,c,(function(){return this})),l(x,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.unshift(n);return function t(){for(;r.length;)if((n=r.pop())in e)return t.value=n,t.done=!1,t;return t.done=!0,t}},r.values=T,A.prototype={constructor:A,reset:function(t){if(this.prev=this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e){a.type="throw",a.arg=t,r.next=e}for(var o=r.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i[4],u=this.prev,c=i[1],f=i[2];if(-1===i[0])return n("end"),!1;if(!c&&!f)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=u){if(u<c)return this.method="next",this.arg=e,n(c),!0;if(u<f)return n(f),!1}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var o=n;break}}o&&("break"===t||"continue"===t)&&o[0]<=e&&e<=o[2]&&(o=null);var i=o?o[4]:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o[2],d):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[2]===t)return this.complete(r[4],r[3]),R(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[0]===t){var n=r[4];if("throw"===n.type){var o=n.arg;R(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={i:T(t),r,n},"next"===this.method&&(this.arg=e),d}},r}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},858:e=>{"use strict";e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{"use strict";n.r(o),n.d(o,{OBFUSCATED_ERROR:()=>pt,Task:()=>l,TaskPriority:()=>C,base64toBlob:()=>ft,batchRemove:()=>R,batchRemoveFromSet:()=>A,bind:()=>B,canObserve:()=>jt,compose:()=>St,convert2UniqueString:()=>k,cropImage:()=>ut,debounce:()=>Et,deduplicate:()=>U,deepMerge:()=>wt,dummy:()=>F,emitter:()=>ht,fail:()=>yt,generateUUID:()=>r,getContextEnv:()=>N,getContextParam:()=>q,getRelativePositionFromEvent:()=>lt,getRenderTargetImageData:()=>tt,getValue:()=>i,hasOwn:()=>I,includes:()=>E,invariant:()=>dt,is:()=>_,isObject:()=>w,isPlainObject:()=>j,isPrimitive:()=>T,isPromise:()=>x,isReserved:()=>d,isSupportProxy:()=>y,isSupportSymbol:()=>g,isSymbol:()=>v,loadImage:()=>nt,loadImageBase64:()=>et,loadImageElement:()=>it,loadJSON:()=>D,mirrorImage:()=>Z,nextTick:()=>L,pointInRect:()=>st,quacksLikeADecorator:()=>xt,remove:()=>S,shallowEqual:()=>M,sortBy:()=>O,stateDecoRegExp:()=>m,throttleInAFrame:()=>J,toObjectTypeString:()=>b,updateQueryStringParameter:()=>G,warn:()=>vt});var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36);function r(){for(var r=0,n=0;n<36;n++)if(8===n||13===n||18===n||23===n)e[n]="-";else if(14===n)e[n]="7";else{r<=2&&(r=33554432+16777216*Math.random()|0);var o=15&r;r>>=4,e[n]=t[19===n?3&o|8:o]}return e.join("")}function i(t,e){return t[e]}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function c(t){var e=function(t){if("object"!=u(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(e)?e:e+""}function f(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function s(t,e,r){return e&&f(t.prototype,e),r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}var l=function(){function t(e,r){a(this,t),this.fn=e,this.priority=r}return s(t,null,[{key:"createTask",value:function(e,r){return new t(e,r)}}])}();function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function p(t,e){if(t){if("string"==typeof t)return h(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(t,e):void 0}}function d(t){var e="".concat(t).charCodeAt(0);return 36===e||95===e}function y(){return"undefined"!=typeof Proxy}function v(t){return"symbol"===u(t)}function g(){return"undefined"!=typeof Symbol}var b=function(t){return Object.prototype.toString.call(t)},m=/^\[object (?:Object|Array|Map|Set|WeakMap|WeakSet)\]$/;function w(t){return null!==t&&"object"===u(t)}function x(t){return t&&"function"==typeof t.then}function j(t){if(null===t||"object"!==u(t))return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function O(t,e){for(var r=t.length,n=0;n<r;n++)for(var o=n+1;o<r;o++){var i=t[n],a=t[o],u=e?e(i):i;(e?e(a):a)<u&&(t[n]=a,t[o]=i)}return t}function E(t,e){return t.indexOf(e)>-1}function S(t,e){var r=t.indexOf(e);r>-1&&t.splice(r,1)}function R(t,e){e.forEach((function(e){var r=t.indexOf(e);r>-1&&t.splice(r,1)}))}function A(t,e){e.forEach((function(e){t.delete(e)}))}function T(t){return null===t||"object"!==u(t)&&"function"!=typeof t}function k(t){return v(t)?t.toString()+r():t.toString()}var U=function(t){return Array.from(new Set(t))},P=Promise.resolve();function L(t){return t?P.then(t):P}var I=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function _(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function B(t,e){return function(r){var n=arguments.length;return n?n>1?t.apply(e,arguments):t.call(e,r):t.call(e)}}function M(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(_(t,e))return!0;if("object"!==u(t)||null===t||"object"!==u(e)||null===e)return!1;var n=[],o=[];if(r&&r.length>0){var i=new Set(r);n=Object.keys(t).filter((function(t){return!i.has(t)})),o=Object.keys(e).filter((function(t){return!i.has(t)}))}else n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(var a=0;a<n.length;a++)if(!e.hasOwnProperty(n[a])||!_(t[n[a]],e[n[a]]))return!1;return!0}var C,F=function(){};function D(t){return new Promise((function(e){var r=new XMLHttpRequest;r.overrideMimeType("application/json"),r.open("GET",t,!0),r.onreadystatechange=function(){4===r.readyState&&200===r.status&&e(JSON.parse(r.responseText||"{}"))},r.send(null)}))}function G(t,e,r){if(!r)return t;var n=new RegExp("([?&])".concat(e,"=.*?(&|$)"),"i"),o=-1!==t.indexOf("?")?"&":"?";return t.match(n)?t.replace(n,"$1".concat(e,"=").concat(r,"$2")):"".concat(t).concat(o).concat(e,"=").concat(r)}function N(){return"undefined"!=typeof window?"browser":"vm"}function q(t){var e,r=N();return"browser"===r&&(e=window[t]),"vm"===r&&(e=n.g[t]),e}!function(t){t[t.UserAction=0]="UserAction",t[t.UpdateState=1]="UpdateState",t[t.RenderReact=2]="RenderReact",t[t.RenderScene=-1]="RenderScene"}(C||(C={}));var H=[],$=!1;function W(){var t=O(H,(function(t){return t.priority}));H=[],t.forEach((function(t){(0,t.fn)()})),$=!1}function J(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:C.UserAction,n=!1;function o(){var r;n=!1,t.apply(void 0,function(t){if(Array.isArray(t))return h(t)}(r=e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||p(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}var i=function(t,e){var r=1e3/e,n=0;return function(){var e=Date.now();if(e-n>=r){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];t.apply(this,i),n=e}}}((function(){for(var t=arguments.length,i=new Array(t),a=0;a<t;a++)i[a]=arguments[a];e=i,n||(n=!0,H.push(l.createTask(o,r)),$||($=!0,L(W)))}),arguments.length>2&&void 0!==arguments[2]?arguments[2]:60);return i}function X(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function Q(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){X(i,n,o,a,u,"next",t)}function u(t){X(i,n,o,a,u,"throw",t)}a(void 0)}))}}var V=n(207),Y=n.n(V),z=n(858);function K(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"turbox";return t.includes(";base64,")||!t?t:G(t,e,"true")}var Z=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,i=new Image;return i.setAttribute("crossOrigin","anonymous"),i.src=t instanceof Blob?URL.createObjectURL(t):K(t),new Promise((function(a){i.onload=function(){t instanceof Blob&&URL.revokeObjectURL(i.src);var u=document.createElement("canvas"),c=u.getContext("2d");u.width=i.width,u.height=i.height,c.translate(-1===e.x?u.width:0,-1===e.y?u.height:0),c.scale(e.x,e.y),c.drawImage(i,0,0,u.width,u.height,0,0,u.width,u.height),r?a("".concat(u.toDataURL(n,o))):u.toBlob((function(t){t&&a(t)}),n,o)}}))},tt=function(t,e,r,n,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"image/png",a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1,u=new z.WebGLRenderTarget(e,r,{minFilter:z.LinearFilter});t.setRenderTarget(u),t.render(n,o);var c=new Uint8Array(e*r*4),f=new Uint8ClampedArray(c.buffer);return t.readRenderTargetPixels(u,0,0,e,r,c),new Promise((function(u){var c=document.createElement("canvas");c.width=e,c.height=r;var s=c.getContext("2d"),l=new ImageData(f,e,r);s.putImageData(l,0,0),t.setRenderTarget(null),t.render(n,o),c.toBlob(function(){var t=Q(Y().mark((function t(e){var r;return Y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=5;break}return t.next=3,Z(e,{x:1,y:-1},!1,i);case 3:r=t.sent,u(r);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),i,a)}))};function et(t){return rt.apply(this,arguments)}function rt(){return rt=Q(Y().mark((function t(e){var r,n,o,i=arguments;return Y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:"image/png",n=i.length>2&&void 0!==i[2]?i[2]:1,(o=new Image).setAttribute("crossOrigin","anonymous"),o.src=e instanceof Blob?URL.createObjectURL(e):K(e),t.abrupt("return",new Promise((function(t){o.onload=function(){e instanceof Blob&&URL.revokeObjectURL(o.src);var i=document.createElement("canvas"),a=i.getContext("2d");i.width=o.width,i.height=o.height,a.drawImage(o,0,0,i.width,i.height,0,0,i.width,i.height);var u="".concat(i.toDataURL(r,n));t({base64:u,width:o.width,height:o.height})}})));case 6:case"end":return t.stop()}}),t)}))),rt.apply(this,arguments)}function nt(t){return ot.apply(this,arguments)}function ot(){return ot=Q(Y().mark((function t(e){var r,n,o,i=arguments;return Y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:"image/png",n=i.length>2&&void 0!==i[2]?i[2]:1,(o=new Image).setAttribute("crossOrigin","anonymous"),o.src=e instanceof Blob?URL.createObjectURL(e):K(e),t.abrupt("return",new Promise((function(t){o.onload=function(){e instanceof Blob&&URL.revokeObjectURL(o.src);var i=document.createElement("canvas"),a=i.getContext("2d");i.width=o.width,i.height=o.height,a.drawImage(o,0,0,i.width,i.height,0,0,i.width,i.height),i.toBlob((function(e){t({blob:e,width:o.width,height:o.height})}),r,n)}})));case 6:case"end":return t.stop()}}),t)}))),ot.apply(this,arguments)}function it(t){return at.apply(this,arguments)}function at(){return(at=Q(Y().mark((function t(e){var r;return Y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(r=new Image).setAttribute("crossOrigin","anonymous"),r.src=e instanceof Blob?URL.createObjectURL(e):K(e),t.abrupt("return",new Promise((function(t){r.onload=function(){e instanceof Blob&&URL.revokeObjectURL(r.src),t({element:r,width:r.width,height:r.height})}})));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ut(t,e){return ct.apply(this,arguments)}function ct(){return ct=Q(Y().mark((function t(e,r){var n,o,i,a=arguments;return Y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.length>2&&void 0!==a[2]?a[2]:"image/png",o=a.length>3&&void 0!==a[3]?a[3]:1,(i=new Image).setAttribute("crossOrigin","anonymous"),e instanceof HTMLImageElement?i.src=e.src:i.src=e instanceof Blob?URL.createObjectURL(e):K(e),t.abrupt("return",new Promise((function(t){i.onload=function(){e instanceof Blob&&URL.revokeObjectURL(i.src);var a=document.createElement("canvas"),u=a.getContext("2d");a.width=r.end.x-r.start.x,a.height=r.end.y-r.start.y,u.drawImage(i,r.start.x,r.start.y,a.width,a.height,0,0,a.width,a.height),a.toBlob((function(e){if(e){var r=URL.createObjectURL(e),n=new Image;n.onload=function(){URL.revokeObjectURL(r),t({blob:e,element:n,width:a.width,height:a.height})},n.src=r}else t({blob:null,width:0,height:0})}),n,o)}})));case 6:case"end":return t.stop()}}),t)}))),ct.apply(this,arguments)}function ft(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:512,r=t.split(";base64,"),n=r[0].split(":")[1],o=window.atob(r[1]),i=[],a=0;a<o.length;a+=e){for(var u=o.slice(a,a+e),c=new Array(u.length),f=0;f<u.length;f++)c[f]=u.charCodeAt(f);var s=new Uint8Array(c);i.push(s)}return new Blob(i,{type:n})}function st(t,e){var r,n,o=(n=2,function(t){if(Array.isArray(t))return t}(r=e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,f=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){f=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(f)throw o}}return u}}(r,n)||p(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1],u=(t.x-i.x)*(t.x-a.x),c=(t.y-i.y)*(t.y-a.y);return u<=0&&c<=0}function lt(t,e){var r={x:t.x-e.x,y:t.y-e.y};if(!(r.x<=0||r.y<=0||r.x>e.width||r.y>e.height))return r}var ht=new(function(){return s((function t(){a(this,t),this.listeners={}}),[{key:"on",value:function(t,e){var r=this.listeners[t]||[];r.push(e),this.listeners[t]=r}},{key:"emit",value:function(t){for(var e=this,r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];var i=this.listeners[t];Array.isArray(i)&&i.forEach((function(t){try{t.apply(e,n)}catch(t){console.error(t)}}))}},{key:"off",value:function(t){this.listeners[t]&&(this.listeners[t]=[])}}])}()),pt="An invariant failed, however the error is obfuscated because this is an production build.";function dt(t,e){if(!t)throw new Error("[turbox]: ".concat(e||pt))}function yt(t){throw dt(!1,t),"X"}function vt(t){console.warn("[turbox]: ".concat(t))}function gt(t){return t&&"object"===u(t)&&"[object RegExp]"!==Object.prototype.toString.call(t)&&"[object Date]"!==Object.prototype.toString.call(t)}function bt(t,e){var r;return e&&!0===e.clone&>(t)?wt((r=t,Array.isArray(r)?[]:{}),t,e):t}function mt(t,e,r){var n=t.slice();return e.forEach((function(e,o){void 0===n[o]?n[o]=bt(e,r):gt(e)?n[o]=wt(t[o],e,r):-1===t.indexOf(e)&&n.push(bt(e,r))})),n}function wt(t,e,r){var n=Array.isArray(e),o=(r||{arrayMerge:mt}).arrayMerge||mt;return n?Array.isArray(t)?o(t,e,r):bt(e,r):function(t,e,r){var n={};return gt(t)&&Object.keys(t).forEach((function(e){n[e]=bt(t[e],r)})),Object.keys(e).forEach((function(o){gt(e[o])&&t[o]?n[o]=wt(t[o],e[o],r):n[o]=bt(e[o],r)})),n}(t,e,r)}function xt(t){return(2===t.length||3===t.length)&&"string"==typeof t[1]}var jt=function(t){return m.test(b(t))},Ot=Date.now;function Et(t){var e,r,n,o,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300,u=!1;if("function"!=typeof t)throw new TypeError("Expected a function");function c(t){var e=t-i;return void 0===i||e>=a||e<0||u}function f(i){return o=void 0,e?(a=e,u=r,e=r=void 0,n=t.apply(u,a)):(e=r=void 0,n);var a,u}function s(){var t=Ot();if(c(t))return f();o=setTimeout(s,function(t){return a-(t-i)}(t))}function l(){var t=Ot(),u=c(t);return e=arguments,r=this,i=t,u&&void 0===o?(o=setTimeout(s,a),n):(void 0===o&&(o=setTimeout(s,a)),n)}return l.cancel=function(){void 0!==o&&clearTimeout(o),e=i=r=o=void 0},l.flush=function(){return void 0===o?n:f(Ot())},l}function St(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce((function(t,e){return function(){return t(e.apply(void 0,arguments))}}))}})(),o})()));