@sketch-hq/sketch-web-renderer 5.2.2 → 5.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";function e(e,t,r,n){return new(r||(r=Promise))((function(s,o){function a(e){try{i(n.next(e))}catch(e){o(e)}}function u(e){try{i(n.throw(e))}catch(e){o(e)}}function i(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}i((n=n.apply(e,t||[])).next())}))}function t(e,t){var r,n,s,o,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(i){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(s=2&u[0]?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(s=a.trys,(s=s.length>0&&s[s.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!s||u[1]>s[0]&&u[1]<s[3])){a.label=u[1];break}if(6===u[0]&&a.label<s[1]){a.label=s[1],s=u;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(u);break}s[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,i])}}}new(function(){function r(){var e=this;this.requests={},this.handleMessage=function(t){switch(t.data.type){case"fetch":e.fetch(t.data.url);break;case"abort":e.abort(t.data.url)}},self.onmessage=this.handleMessage}return r.prototype.fetch=function(r){return e(this,void 0,void 0,(function(){var e,n,s,o,a;return t(this,(function(t){switch(t.label){case 0:if(this.requests[r])return[2];e=new AbortController,n=fetch(r,{signal:e.signal}),this.requests[r]={promise:n,abortController:e},t.label=1;case 1:return t.trys.push([1,4,,5]),[4,n];case 2:if(!(s=t.sent()).ok)throw{statusCode:s.status,statusText:s.statusText};return[4,s.arrayBuffer()];case 3:return o=t.sent(),self.postMessage({type:"success",url:r,buffer:o},[o]),delete this.requests[r],[3,5];case 4:return a=t.sent(),self.postMessage({type:"error",url:r,error:a}),delete this.requests[r],[3,5];case 5:return[2]}}))}))},r.prototype.abort=function(e){var t=this.requests[e];t&&t.abortController.abort()},r}());
1
+ "use strict";function e(e,t,r,n){return new(r||(r=Promise))((function(s,o){function a(e){try{i(n.next(e))}catch(e){o(e)}}function u(e){try{i(n.throw(e))}catch(e){o(e)}}function i(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}i((n=n.apply(e,t||[])).next())}))}function t(e,t){var r,n,s,o,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(i){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(s=2&u[0]?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(s=a.trys,(s=s.length>0&&s[s.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!s||u[1]>s[0]&&u[1]<s[3])){a.label=u[1];break}if(6===u[0]&&a.label<s[1]){a.label=s[1],s=u;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(u);break}s[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,i])}}}new(function(){function r(){var e=this;this.requests={},this.handleMessage=function(t){switch(t.data.type){case"fetch":e.fetch(t.data.url);break;case"abort":e.abort(t.data.url)}},self.onmessage=this.handleMessage}return r.prototype.fetch=function(r){return e(this,void 0,void 0,(function(){var e,n,s,o,a;return t(this,(function(t){switch(t.label){case 0:if(this.requests[r])return[2];e=new AbortController,n=fetch(r,{signal:e.signal}),this.requests[r]={promise:n,abortController:e,aborted:!1},t.label=1;case 1:return t.trys.push([1,4,,5]),[4,n];case 2:if(!(s=t.sent()).ok)throw{statusCode:s.status,statusText:s.statusText};return[4,s.arrayBuffer()];case 3:return o=t.sent(),self.postMessage({type:"success",url:r,buffer:o},[o]),delete this.requests[r],[3,5];case 4:return a=t.sent(),this.requests[r].aborted||self.postMessage({type:"error",url:r,error:a}),delete this.requests[r],[3,5];case 5:return[2]}}))}))},r.prototype.abort=function(e){var t=this.requests[e];t&&(t.abortController.abort(),t.aborted=!0)},r}());
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import e,{createContext as t,useContext as n,useRef as o,useReducer as r,useCallback as i,useMemo as a,useEffect as s,useState as u}from"react";var c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var d=function(){return d=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},d.apply(this,arguments)};function h(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}function v(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function p(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function f(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}const g=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function m(e){return e.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const y="undefined"==typeof window,C=(()=>{if(y)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,o=/(iphone|ipod|ipad)/i.test(e),r="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:r,isMobile:/android/i.test(e)||o||r,isSafari12:/Version\/12.+Safari/.test(e)}})();const w=[],b=[];function P(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let o=e.length,r=t.length;for(;o>0&&e.charCodeAt(~-o)===t.charCodeAt(~-r);)o--,r--;let i,a=0;for(;a<o&&e.charCodeAt(a)===t.charCodeAt(a);)a++;if(o-=a,r-=a,0===o)return r;let s,u,c=0,l=0,d=0;for(;l<o;)b[l]=e.charCodeAt(a+l),w[l]=++l;for(;d<r;)for(i=t.charCodeAt(a+d),s=d++,c=d,l=0;l<o;l++)u=i===b[l]?s:s+1,s=w[l],c=w[l]=s>c?u>c?c+1:u:u>s?s+1:u;return c}function E(e){return null!=e}class M extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const R=({mobileTiers:e=[0,15,30,60],desktopTiers:t=[0,15,30,60],override:n={},glContext:o,failIfMajorPerformanceCaveat:r=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@4.0.47/dist/benchmarks"}={})=>f(void 0,void 0,void 0,(function*(){const a={};if(y)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==C?void 0:C.isIpad),isMobile:u=!!(null==C?void 0:C.isMobile),screenSize:c=window.screen,loadBenchmarks:l=(e=>f(void 0,void 0,void 0,(function*(){const t=yield fetch(`${i}/${e}`).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<4)throw new M("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:d}=n;const h=(e,t,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:u,tier:e,type:t});let v,p="";if(d)d=m(d),v=[d];else{const e=o||function(e,t=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:t,powerPreference:"high-performance",stencil:!1};e&&delete n.powerPreference;const o=window.document.createElement("canvas"),r=o.getContext("webgl",n)||o.getContext("experimental-webgl",n);return null!=r?r:void 0}(null==C?void 0:C.isSafari12,r);if(!e)return h(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(d=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");p=d,d=m(d),v=function(e,t,n){return"apple gpu"===t?function(e,t,n){if(!n)return[t];const o=function(e){const t=e.createShader(35633),n=e.createShader(35632),o=e.createProgram();if(!(n&&t&&o))return;e.shaderSource(t,"\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n "),e.shaderSource(n,"\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n "),e.compileShader(t),e.compileShader(n),e.attachShader(o,t),e.attachShader(o,n),e.linkProgram(o),e.detachShader(o,t),e.detachShader(o,n),e.deleteShader(t),e.deleteShader(n),e.useProgram(o);const r=e.createBuffer();e.bindBuffer(34962,r),e.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const i=e.getAttribLocation(o,"aPosition");e.vertexAttribPointer(i,3,5126,!1,0,0),e.enableVertexAttribArray(i),e.clearColor(1,1,1,1),e.clear(16384),e.viewport(0,0,1,1),e.drawArrays(4,0,3);const a=new Uint8Array(4);return e.readPixels(0,0,1,1,6408,5121,a),e.deleteProgram(o),e.deleteBuffer(r),a.join("")}(e),r="801621810",i="8016218135",a="80162181161",s=(null==C?void 0:C.isIpad)?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["m1",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15]];let u;return"80162181255"===o?u=s.filter((([,,e])=>e>=14)):(u=s.filter((([,e])=>e===o)),u.length||(u=s)),u.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,d,u)}const w=(yield Promise.all(v.map((function(e){var t;return f(this,void 0,void 0,(function*(){const n=(e=>{const t=u?["adreno","apple","mali-t","mali","nvidia","powervr"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const o=`${u?"m":"d"}-${n}${s?"-ipad":""}.json`,r=a[o]=null!==(t=a[o])&&void 0!==t?t:l(o);let i;try{i=yield r}catch(n){if(n instanceof M)throw n;return}const d=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let h=i.filter((([,e])=>e===d));h.length||(h=i.filter((([t])=>t.includes(e))));const v=h.length;if(0===v)return;let p,[f,,,g]=v>1?h.map((t=>[t,P(e,t[0])])).sort((([,e],[,t])=>e-t))[0][0]:h[0],m=Number.MAX_VALUE;const{devicePixelRatio:y}=window,C=c.width*y*c.height*y;for(const e of g){const[t,n]=e,o=t*n,r=Math.abs(C-o);r<m&&(m=r,p=e)}if(!p)return;const[,,w,b]=p;return[m,w,f,b]}))})))).filter(E).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!w.length){const e=g.find((e=>d.includes(e)));return e?h(0,"BLOCKLISTED",e):h(1,"FALLBACK",`${d} (${p})`)}const[,b,R,L]=w[0];if(-1===b)return h(0,"BLOCKLISTED",R,b,L);const W=u?e:t;let x=0;for(let e=0;e<W.length;e++)b>=W[e]&&(x=e);return h(x,"BENCHMARK",R,b,L)}));var L,W=function(e){function t(n,o,r){var i=this.constructor,a=e.call(this,"(".concat(n,") ").concat(o))||this;return a.code=n,a.cause=r,a.name=t.name,Object.setPrototypeOf(a,i.prototype),a}return l(t,e),t}(Error);!function(e){e.debug="debug",e.release="release"}(L||(L={}));var x=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,o;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(o=this.listeners[e])||void 0===o||o.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.forwardEvent=function(e,t){this.on(t,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];e.emit.apply(e,p([t],n,!1))}))},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this.listeners[e];(null==o?void 0:o.size)&&o.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e.prototype.detachAllListeners=function(){this.listeners={}},e}(),I=function(){function e(){this.removeListenerCallbacks=[]}return e.prototype.add=function(e,t,n,o){e.addEventListener(t,n,o);var r=function(){e.removeEventListener(t,n,o)};return this.removeListenerCallbacks.push(r),r},e.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(e){return e()}))},e}(),S={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1},D=function(e){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(e)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},T=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,F=function(e){if(void 0===e&&(e=window.navigator.userAgent),e.includes("Chrome/")||e.includes("Chromium/")||e.includes("Opera/")||e.includes("Firefox/"))return null;var t=e.match(T);if(!t)return null;var n=t[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(t[4])||0,minor:parseInt(t[5])||0,patch:parseInt(t[6])||0}}};function k(e,t){var n;function o(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){e.apply(void 0,o)}),t)}return o.cancel=function(){n&&clearTimeout(n)},o}function A(e){var t,n,o,r,i,a=null!==(n=null===(t=e.touches)||void 0===t?void 0:t[0])&&void 0!==n?n:null===(o=e.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(r=null==a?void 0:a.clientX)&&void 0!==r?r:e.clientX,y:null!==(i=null==a?void 0:a.clientY)&&void 0!==i?i:e.clientY}}function U(e,t,n){return Math.max(t,Math.min(n,e))}function B(){return F()&&!S.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function G(e){for(var t=e.size(),n=[],o=0;o<t;++o){var r=e.get(o);if(null==r)throw Error("Error converting embind vector to array");n.push(r)}return n}function Z(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function z(e){var t=e;return Object.keys(t).forEach((function(e){void 0===t[e]&&delete t[e]})),t}function O(e){return Z()?{onTouchEnd:e}:{onClick:e}}var _=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},n.handleGestureStart=function(e){e.preventDefault(),n.state.lastGestureScale=e.scale},n.handleGestureChange=function(e){e.preventDefault();var t=e.scale/n.state.lastGestureScale;n.state.lastGestureScale=e.scale;var o=n.getCorrectPointerPosition(e);n.emitZoomEvent(t,o)},n.handleGestureEnd=function(e){e.preventDefault()},n.handleTouchStart=function(e){e.preventDefault(),n.handleTouchPinchToZoomStart(e),n.emit("pointerdown",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleMouseDown=function(e){e.ctrlKey||(e.preventDefault(),n.emit("pointerdown",{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0}))},n.handleTouchMove=function(e){n.handleTouchPinchToZoomChange(e),n.emit("pointermove",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleMouseMove=function(e){n.updateMousePosition(e)},n.handleGlobalTouchMove=function(e){n.emit("globalpointermove",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleGlobalMouseMove=function(e){n.updateGlobalMousePosition(e)},n.handleTouchPinchToZoomStart=function(e){var t;!e.touches||(null===(t=e.touches)||void 0===t?void 0:t.length)<2||(n.state.pinchToZoomLastDistance=n.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]))},n.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var o=n.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]),r=n.getCorrectPointerPosition(e),i=1+.004*(o-n.state.pinchToZoomLastDistance);n.state.pinchToZoomLastDistance=o,n.emitZoomEvent(i,r)}},n.handleTouchEnd=function(e){var t=n.getCorrectPointerPosition(e);n.emit("pointerup",{position:t,type:"touch",button:0,touchesCount:e.touches.length})},n.handleMouseUp=function(e){n.emit("pointerup",{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},n.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!n.state.isCtrlPressed,o=e.metaKey||t||n.state.isCtrlPressed;if(n.updateMousePosition(e),n.updateGlobalMousePosition(e),o){var r=t?-1:1,i=n.getCorrectPointerPosition(e),a=1+.005*e.deltaY*r;n.emitZoomEvent(a,i)}else n.emit("wheel",{x:-e.deltaX,y:-e.deltaY},{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},n.target=t,n.targetBounds=t.getBoundingClientRect(),n.addListeners(),n}return l(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},t.prototype.addKeyboardEventListeners=function(){var e=this;this.listenersCollector.add(document,"keydown",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(t){t.ctrlKey&&(e.state.isCtrlPressed=!1)}))},t.prototype.addMouseEventListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handleMouseDown),this.listenersCollector.add(this.target,"mousemove",this.handleMouseMove),this.listenersCollector.add(document,"mousemove",this.handleGlobalMouseMove),this.listenersCollector.add(document,"mouseup",this.handleMouseUp),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel)},t.prototype.addTouchEventListeners=function(){this.listenersCollector.add(this.target,"touchstart",this.handleTouchStart),this.listenersCollector.add(document,"touchmove",this.handleGlobalTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(this.target,"touchmove",this.handleTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(document,"touchcancel",this.handleTouchEnd),this.listenersCollector.add(document,"touchend",this.handleTouchEnd)},t.prototype.addSafariGesturesEventListeners=function(){Z()||(this.listenersCollector.add(this.target,"gesturestart",this.handleGestureStart,{capture:!0}),this.listenersCollector.add(this.target,"gesturechange",this.handleGestureChange,{capture:!0}),this.listenersCollector.add(this.target,"gestureend",this.handleGestureEnd,{capture:!0}))},t.prototype.clampPointerToTargetBounds=function(e){return{x:U(e.x-this.targetBounds.x,0,this.target.clientWidth),y:U(e.y-this.targetBounds.y,0,this.target.clientHeight)}},t.prototype.getCorrectPointerPosition=function(e){var t,n={x:0,y:0};if((null===(t=e.touches)||void 0===t?void 0:t.length)>1){var o=e,r=o.touches[0],i=o.touches[1];n={x:(r.clientX+i.clientX)/2,y:(r.clientY+i.clientY)/2}}else n=A(e);return this.clampPointerToTargetBounds(n)},t.prototype.updateMousePosition=function(e){this.emit("pointermove",{type:"mouse",position:this.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},t.prototype.updateGlobalMousePosition=function(e){this.emit("globalpointermove",{type:"mouse",position:this.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},t.prototype.calculateDistanceBetweenTouches=function(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)},t.prototype.emitZoomEvent=function(e,t){this.emit("pinchToZoom",e,t)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(x),N=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.handleKeyUp=function(e){n.emit("keyUp",e.code)},n.target=t,n.addListeners(),n}return l(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(x),j=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now()}return e.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(t," ms")}var n=(e/1e3).toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(n," s")},e}();function K(e){setTimeout((function(){e()}),0)}var Y=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l(t,e),t.prototype.logDebug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,p(["log","debug"],e,!1))},t.prototype.logWarning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,p(["log","warn"],e,!1))},t.prototype.logError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,p(["log","error"],e,!1))},t}(x)),$=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.size={width:0,height:0},n.pixelRatio=1,n.handleCanvasResizeObserver=function(e){n.resizeCanvas(e[0].contentRect)},n.resizeCanvas=function(e){var t=e.width,o=e.height;window.requestAnimationFrame((function(){n.setSize(t,o),n.emit("resize",t,o,n.getDevicePixelRatio())}))},n.getCanvasCenterPoint=function(){var e=n.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},n.container=t.container,n.canvas=t.canvas,n.canvasResizeObserver=new ResizeObserver(n.handleCanvasResizeObserver),n.canvasResizeObserver.observe(n.container),n.listenersCollector.add(window,"orientationchange",n.handleDeviceOrientationChange),n.setSize(n.container.clientWidth,n.container.clientHeight),n}return l(t,e),t.prototype.setSize=function(e,t){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(e,"px"),this.canvas.style.height="".concat(t,"px"),this.size.width=e*this.pixelRatio,this.size.height=t*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},t.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},t.prototype.getDevicePixelRatio=function(){return U(window.devicePixelRatio,1,2)},t.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},t.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},t}(x),H=function(){function e(e){this.settings=e}return e.prototype.isReleaseMode=function(){return this.settings.mode===L.release},e.prototype.init=function(){return h(this,void 0,void 0,(function(){var e,t,n,o,r,i=this;return v(this,(function(a){switch(a.label){case 0:return[4,this.importModule()];case 1:e=a.sent(),t=e.default,a.label=2;case 2:return a.trys.push([2,4,,5]),n=this,[4,t({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:B(),bridge:this.settings.jsBridge,locateFile:function(e){return i.settings.locateFile.replace("{file}",e)}})];case 3:return n.instance=a.sent(),[3,5];case 4:throw o=a.sent(),new W("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerType.Unset,mouse:this.instance.PRUserPointerType.Mouse,touch:this.instance.PRUserPointerType.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorType.Auto.value]="auto",r[this.instance.PRCursorType.Default.value]="default",r[this.instance.PRCursorType.Pointer.value]="pointer",r[this.instance.PRCursorType.Grab.value]="grab",r[this.instance.PRCursorType.Grabbing.value]="grabbing",r),[2]}}))}))},e.prototype.makeWebGLContext=function(e,t){void 0===t&&(t={});var n=d({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},t),o=this.instance.GL.createContext(e,n);if(!o)throw new W("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");return o},e.prototype.destroyWebGLContext=function(e){var t,n=null===(t=this.instance)||void 0===t?void 0:t.GL.getContext(e);if(n){var o=n.GLctx.getExtension("WEBGL_lose_context");if(o)return o.loseContext(),!0}},e.prototype.importModule=function(){return this.isReleaseMode()?import("./module-release-bd90bea3.js"):import("./module-debug-7ee9ba03.js")},e.prototype.mapToCSSCursor=function(e){return this.prCursorTypeToCSSCursorMap[e.value]},e.prototype.mapToPRPointerType=function(e){var t;return null!==(t=this.pointerTypeToWASMMap[e])&&void 0!==t?t:this.instance.PRUserPointerType.Unset},e.prototype.mapPointerInfo=function(e){return d(d({},e),{type:this.mapToPRPointerType(e.type)})},e}(),X=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"INIT"},n.handleCanvasResize=function(e,t,o){var r;null===(r=n.pageCanvasWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&(null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(e.x,e.y,n.wasmModule.mapPointerInfo(t)))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(e)))},n.settings=d(d({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1,panBoundariesPadding:0},z(t)),{featureFlags:d(d({},S),t.featureFlags)}),n.gestureManager=new _(n.settings.container),n.canvasManager=new $({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new H({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return l(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,R()];case 1:return e=t.sent(),this.deviceInfo=d(d({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:this.traceFirstPaint=new j("FirstPaint"),this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),t.label=1;case 1:return t.trys.push([1,5,,6]),[4,this.initWasmModule()];case 2:return t.sent(),[4,this.initCanvasRendererWasm()];case 3:return t.sent(),[4,this.setFile(this.settings.filePath)];case 4:return t.sent(),[3,6];case 5:return e=t.sent(),[2,this.fail(e instanceof W?e:new W("ERROR","Unexpected exception initializing the web renderer",e))];case 6:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.setInitialCameraState=function(){var e,t,n,o=void 0!==this.settings.initialZoom,r=void 0!==this.settings.initialPan;o||r?(o&&this.setZoom(this.settings.initialZoom||1),r&&this.setPan((null===(e=this.settings.initialPan)||void 0===e?void 0:e.x)||0,(null===(t=this.settings.initialPan)||void 0===t?void 0:t.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport)):this.zoomToFit()},t.prototype.startRendering=function(){var e;this.traceInitialRender=new j("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.pageCanvasWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){Y.logDebug("[C++] ".concat(e))},logWarning:function(e){Y.logWarning("[C++] ".concat(e))},logError:function(e){Y.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t):e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t]:(Y.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:(Y.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(){var t=e.getPan();e.emit("cameraPanChange",(null==t?void 0:t.x)||0,(null==t?void 0:t.y)||0)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},onPlayStateChange:function(){},fetch:this.handleJSBridgeFetch.bind(this)}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){if(t.data.url===e){switch(t.data.type){case"success":o.exec(new Uint8Array(t.data.buffer),200,"");break;case"error":o.exec(new Uint8Array(0),t.data.statusCode,t.data.statusText)}n.fetchWorker.removeEventListener("message",r)}};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.initWasmModule=function(){var e;return h(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=new j("WasmModuleDownload"),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()];case 1:return n.sent(),Y.logDebug(t.printMeasurement()),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.initCanvasRendererWasm=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){try{if(!this.wasmModule)throw Error("WASM module not initialized");e=B(),Y.logDebug("Using WebGL ".concat(e)),this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:e}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.pageCanvasWasm=new this.wasmModule.instance.CanvasRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(e){throw new W("WASM_ERROR","An error occurred while trying to create the wasm object.",e)}return this.userEventsCollectorWasm=this.pageCanvasWasm.getUserEventsCollector(),this.pageCanvasWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.pageCanvasWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.pageCanvasWasm.setPanBoundariesPadding(this.settings.panBoundariesPadding),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.pageCanvasWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.generateDocumentPNG=function(){var e;return h(this,void 0,void 0,(function(){return v(this,(function(t){return[2,null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.generateDocumentPNG()]}))}))},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(Y.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),Y.logDebug(this.traceFirstPaint.printMeasurement()),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;(null===(e=this.wasmModule)||void 0===e?void 0:e.destroyWebGLContext(this.webglCtxHandle))||Y.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.scaleDocumentToFit()},t.prototype.setFile=function(e){return h(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=t.pageCanvasWasm)||void 0===r||r.setFile(e,(function(e,o,r){t.setStatus({type:"FILE_READY"});var i="".concat(e,"-v").concat("5.2.2");t.emit("fileReady",t.getDocument(),i,o,r),n()}),(function(){return o(new W("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:"".concat(e.toString()).concat(e.cause?"\nWrapped Error: ".concat(e.cause.toString()):"")}),Y.logError(e),e.cause&&Y.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(Y.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getDocument=function(){if(!this.pageCanvasWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var e=this.pageCanvasWasm.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:d(d({},e),{artboards:G(e.artboards)})}}return this.cachedDocumentInfo.document},t.prototype.getArtboardAtPosition=function(e,t){if(this.pageCanvasWasm){var n=this.getDocument();if(n){for(var o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(e-o.x)/r,a=(t-o.y)/r,s=0,u=n.artboards;s<u.length;s++){var c=u[s],l=c.bounds.x+c.bounds.width,d=c.bounds.y+c.bounds.height;if(i>=c.bounds.x&&a>=c.bounds.y&&i<=l&&a<=d)return c.objectId}return null}}},t.prototype.getPanAtPosition=function(e,t){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),r=e/o,i=t/o;return{x:n.x-r,y:n.y-i}},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,o=null!=t?t:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(e,o.x,o.y)},t.prototype.getPan=function(){var e,t,n=this.getDocument().bounds,o=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getPan(),r=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom();return o&&r?{x:o.x/r+n.x,y:o.y/r+n.y}:{x:0,y:0}},t.prototype.getZoom=function(){var e;return(null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom())||0},t.prototype.setPan=function(e,t,n){var o;void 0===n&&(n=!1);var r=e,i=t,a=this.getDocument().bounds,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);r+=this.canvasManager.size.width/u,i+=this.canvasManager.size.height/u}var c=(r-a.x)*s,l=(i-a.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(c,l)},t.prototype.dispose=function(){var e,t,n;try{this.detachAllListeners(),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(e=this.pageCanvasWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.pageCanvasWasm)||void 0===t||t.delete(),null===(n=this.renderTarget)||void 0===n||n.delete(),this.fetchWorker.terminate(),this.pageCanvasWasm=void 0,this.wasmModule=void 0}catch(e){this.fail(new W("ERROR","Unexpected exception while disposing the wasm object",e))}},t}(x),V=t(void 0),J=t(void 0),q=t(void 0),Q=t(void 0),ee=t(void 0),te=t(void 0),ne=t("auto"),oe=t(void 0),re=function(){var e=n(oe);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},ie=function(e,t){switch(t.type){case"on-status":return d(d({},e),{status:t.status});case"on-file-ready":return d(d({},e),{document:t.document});case"on-zoom":return d(d({},e),{zoom:t.zoom});case"on-pan":return d(d({},e),{pan:t.pan});case"dispose":return d(d({},e),{status:null,zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return d(d({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return d(d({},e),{isCameraZooming:!1});case"on-camera-move-start":return d(d({},e),{isCameraMoving:!0});case"on-camera-move-end":return d(d({},e),{isCameraMoving:!1});case"on-cursor-change":return d(d({},e),{cursor:t.cursor});default:return e}},ae=function(t){var n=o(null),s=o(null),u=r(ie,{pan:null,zoom:null,status:null,document:null,isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),c=u[0],l=c.status,h=c.document,v=c.zoom,p=c.pan,f=c.isCameraZooming,g=c.isCameraMoving,m=c.cursor,y=u[1],C=i((function(e){return y({type:"on-zoom",zoom:e})}),[]),w=i((function(e,t){return y({type:"on-pan",pan:{x:e,y:t}})}),[]),b=i((function(e){y({type:"on-status",status:e})}),[]),P=i((function(e){y({type:"on-file-ready",document:e})}),[]),E=i((function(){return y({type:"on-camera-zoom-start"})}),[]),M=i((function(){return y({type:"on-camera-zoom-end"})}),[]),R=i((function(){return y({type:"on-camera-move-start"})}),[]),L=i((function(){return y({type:"on-camera-move-end"})}),[]),W=i((function(e){return y({type:"on-cursor-change",cursor:e})}),[]),x=i((function(){var e=n.current;e&&(Y.logDebug("Provider dispose"),e.off("status",b),e.off("fileReady",P),e.off("cameraZoomChange",C),e.off("cameraPanChange",w),e.off("cameraZoomStart",E),e.off("cameraZoomEnd",M),e.off("cameraMoveStart",R),e.off("cameraMoveEnd",L),e.off("cursorChange",W),e.dispose(),n.current=null,y({type:"dispose"}))}),[b,P,w,C,E,M,R,L,W]),I=i((function(e,t,o){if(""!==e&&t&&o&&s.current){Y.logDebug("Provider init");var r=new X(d(d({},s.current),{filePath:e,container:o,canvas:t}));r.on("status",b),r.on("fileReady",P),r.on("cameraZoomChange",C),r.on("cameraPanChange",w),r.on("cameraZoomStart",E),r.on("cameraZoomEnd",M),r.on("cameraMoveStart",R),r.on("cameraMoveEnd",L),r.on("cursorChange",W),n.current=r}}),[b,P,C,w,E,M,R,L,W]),S=i((function(e){var t;Y.logDebug("Provider setSettings",e),e.backgroundColor&&(null===(t=n.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),s.current=e}),[]),D=i((function(){return n.current}),[]),T=a((function(){return{dispose:x,init:I,setSettings:S,getInstance:D,dispatch:y}}),[x,I,S,D]);return e.createElement(oe.Provider,{value:T},e.createElement(V.Provider,{value:l},e.createElement(J.Provider,{value:h},e.createElement(q.Provider,{value:v},e.createElement(te.Provider,{value:p},e.createElement(Q.Provider,{value:f},e.createElement(ee.Provider,{value:g},e.createElement(ne.Provider,{value:m},t.children))))))))},se=function(){var e=n(V);if(void 0===e)throw Error("useStatus must be used within a provider");return e},ue=function(){var e=n(J);if(void 0===e)throw Error("useDocument must be used within a provider");return e},ce=function(){var e=n(q);if(void 0===e)throw Error("useZoom must be used within a provider");return e},le=function(){var e=n(te);if(void 0===e)throw Error("usePan must be used within a provider");return e},de=function(){var e=n(ne);if(void 0===e)throw Error("useCursor must be used within a provider");return e},he=function(){var e=n(Q);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},ve=function(){var e=n(ee);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},pe=function(){var e=(0,re().getInstance)();return i((function(t){null==e||e.setZoom(t)}),[e])},fe=function(){var e=pe(),t=ce();return i((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},ge=function(){var e=pe(),t=ce();return i((function(){"number"==typeof t&&e(t/2)}),[e,t])},me=function(){var e=(0,re().getInstance)();return i((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},ye=function(){var e=(0,re().getInstance)();return i((function(){null==e||e.zoomToFit()}),[e])},Ce=function(){var e=(0,re().getInstance)();return i((function(){null==e||e.looseWebGLContext()}),[e])},we=function(){var e=(0,re().getInstance)();return i((function(){return h(void 0,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,null==e?void 0:e.generateDocumentPNG()];case 1:return[2,t.sent()]}}))}))}),[e])},be=function(){var e=(0,re().getInstance)();return i((function(t,n){return h(void 0,void 0,void 0,(function(){return v(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Pe=function(){var e=(0,re().getInstance)();return i((function(t,n){return h(void 0,void 0,void 0,(function(){return v(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Ee=function(){var e=(0,re().getInstance)();return i((function(t){null==e||e.setIsCameraLocked(t)}),[e])},Me=function(e,t){var n=(0,re().getInstance)();s((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function Re(e){var t=o(e);t.current=e;var n=i((function(e){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];t.current.apply(t,p([e],n,!1))}),[]);s((function(){return Y.on("log",n),function(){Y.off("log",n)}}),[])}var Le={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},We={position:"absolute",top:0,left:0},xe=function(t){var n=t.filePath,r=t.locateFile,c=t.imagesURLFormat,l=t.imagesURLMap,h=t.fragmentsURLFormat,v=t.fragmentsURLMap,p=t.backgroundColor,f=t.mode,g=t.showTilesBorders,m=t.minimumZoomLevel,y=t.maximumZoomLevel,C=t.preserveDrawingBuffer,w=t.panBoundariesPadding,b=t.initialPan,P=t.initialZoom,E=t.children,M=t.containerProps,R=void 0===M?{}:M,L=t.canvasProps,W=void 0===L?{}:L,x=t.featureFlags,I=void 0===x?{}:x,S=o(null),D=o(null),T=u(!1),F=T[0],k=T[1],A=i((function(){return k(!0)}),[]),U=re(),B=U.dispose,G=U.init,Z=U.setSettings,z=de(),O=se();Me("allImagesReady",A),s((function(){return Y.logDebug("WebRenderer mounted"),function(){return Y.logDebug("WebRenderer unmounted")}}),[]),s((function(){Z({locateFile:r,imagesURLFormat:c,imagesURLMap:l,fragmentsURLFormat:h,fragmentsURLMap:v,backgroundColor:p,mode:f,showTilesBorders:g,minimumZoomLevel:m,maximumZoomLevel:y,preserveDrawingBuffer:C,panBoundariesPadding:w,initialPan:b,initialZoom:P,featureFlags:I})}),[Z,r,c,l,h,v,p,f,g,m,y,C,w,b,P,I]),s((function(){if(n)return G(n,S.current,D.current),function(){B()}}),[B,G,n]);var _=a((function(){var e;return null!==(e=t.cursor)&&void 0!==e?e:z}),[t.cursor,z]),N=a((function(){return d(d({},Le),{cursor:_})}),[_]);return e.createElement("div",d({},R,{ref:D,style:N}),n&&e.createElement("canvas",d({},W,{key:n,ref:S,"data-sketchweb-all-images-ready":F,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==O?void 0:O.type.toLowerCase())||"null"),style:We})),"READY"===(null==O?void 0:O.type)&&E)},Ie=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"INIT"},n.handleCanvasResize=function(e,t,o){var r;null===(r=n.playerWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&n.userEventsCollectorWasm.dispatchWheelEvent(e.x,e.y,null===(o=n.wasmModule)||void 0===o?void 0:o.mapPointerInfo(t))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerDownEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerUpEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.restartPrototype=function(e){var t;null===(t=n.playerWasm)||void 0===t||t.restartPrototype(e)},n.goBack=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goBack()},n.goForwards=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goForwards()},n.settings=d(d({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1},z(t)),{featureFlags:d(d({},S),t.featureFlags)}),n.gestureManager=new _(n.settings.container),n.canvasManager=new $({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new H({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.settings.manualInitialization||n.init(),n}return l(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,R()];case 1:return e=t.sent(),this.deviceInfo=d(d({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:this.traceFirstPaint=new j("FirstPaint"),this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),t.label=1;case 1:return t.trys.push([1,6,,7]),[4,this.initWasmModule()];case 2:return t.sent(),[4,this.initPlayerWasm()];case 3:return t.sent(),[4,this.setFile(this.settings.filePath)];case 4:return t.sent(),[4,this.preloadImages()];case 5:return t.sent(),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof W?e:new W("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initWasmModule=function(){var e;return h(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=new j("WasmModuleDownload"),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()];case 1:return n.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.setInitialCameraState=function(){this.zoomToFit()},t.prototype.preloadImages=function(){var e=this;return new Promise((function(t){var n;null===(n=e.playerWasm)||void 0===n||n.preloadImages((function(){t()}))}))},t.prototype.startRendering=function(){var e;this.traceInitialRender=new j("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.playerWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){Y.logDebug("[C++] ".concat(e))},logWarning:function(e){Y.logWarning("[C++] ".concat(e))},logError:function(e){Y.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t):e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t]:(Y.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(){return""},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(t,n){e.emit("cameraPanChange",t,n)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},onPlayStateChange:function(t,n,o){e.emit("playStateChange",{screenArtboardId:t,canGoBack:n,canGoForwards:o})}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n,o=new j("ImagesDownload");null===(n=e.playerWasm)||void 0===n||n.downloadImages((function(){o.printMeasurement(),e.emit("metric",o.measure()),Y.logDebug("Images downloaded"),t()}))}))},t.prototype.initPlayerWasm=function(){return h(this,void 0,void 0,(function(){return v(this,(function(e){try{if(!this.wasmModule)throw Error("WASM module not initialized");this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:B()}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.playerWasm=new this.wasmModule.instance.PrototypeRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID)}catch(e){throw new W("WASM_ERROR","An error occurred while trying to create the WebRendererWasm object.",e)}return this.userEventsCollectorWasm=this.playerWasm.getUserEventsCollector(),this.playerWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.playerWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.playerWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.playerWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}),this.downloadImages())},t.prototype.looseWebGLContext=function(){var e;null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(){var e;null===(e=this.playerWasm)||void 0===e||e.scaleDocumentToFit()},t.prototype.setFile=function(e){return h(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=t.playerWasm)||void 0===r||r.setFile(e,(function(e,o,r){t.setStatus({type:"FILE_READY"});var i="".concat(e,"-v").concat("5.2.2");t.emit("fileReady",t.getDocument(),i,o,r),n()}),(function(){return o(new W("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:"".concat(e.toString()).concat(e.cause?"\nWrapped Error: ".concat(e.cause.toString()):"")}),Y.logError(e),e.cause&&Y.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(Y.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getStatus=function(){return this.status},t.prototype.getDocument=function(){var e;if(!this.playerWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var t=null===(e=this.playerWasm)||void 0===e?void 0:e.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:d(d({},t),{artboards:G(t.artboards)})}}return this.cachedDocumentInfo.document},t.prototype.dispose=function(){var e,t;try{this.detachAllListeners(),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(e=this.playerWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.playerWasm)||void 0===t||t.delete(),this.renderTarget.delete(),this.playerWasm=void 0,this.wasmModule=void 0}catch(e){this.fail(new W("ERROR","Unexpected exception while disposing the WebRendererWasm object",e))}},t}(x),Se=t(void 0),De=t("auto"),Te=t(void 0),Fe=t(void 0),ke=function(){var e=n(Fe);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},Ae=function(e,t){switch(t.type){case"on-status":return d(d({},e),{status:t.status});case"dispose":return d(d({},e),{status:null,cursor:"auto"});case"on-cursor-change":return d(d({},e),{cursor:t.cursor});case"on-play-state-change":return d(d({},e),{playState:d(d({},e.playState),t.playState)});default:return e}},Ue=function(t){var n=o(null),s=o(null),u=r(Ae,{status:null,cursor:"auto",playState:{screenArtboardId:"",canGoBack:!0,canGoForwards:!0}}),c=u[0],l=c.status,h=c.cursor,v=c.playState,p=u[1],f=i((function(e){p({type:"on-status",status:e})}),[]),g=i((function(e){return p({type:"on-cursor-change",cursor:e})}),[]),m=i((function(e){return p({type:"on-play-state-change",playState:e})}),[]),y=i((function(){var e=n.current;e&&(Y.logDebug("Provider dispose"),e.off("status",f),e.off("cursorChange",g),e.off("playStateChange",m),e.dispose(),n.current=null,p({type:"dispose"}))}),[f,g,m]),C=i((function(e,t,o){if(""!==e&&t&&o&&s.current){Y.logDebug("Provider init");var r=new Ie(d(d({},s.current),{filePath:e,container:o,canvas:t}));r.on("status",f),r.on("cursorChange",g),r.on("playStateChange",m),n.current=r}}),[f,g,m]),w=i((function(e){var t;Y.logDebug("Provider setSettings",e),e.backgroundColor&&(null===(t=n.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),s.current=e}),[]),b=i((function(){return n.current}),[]),P=a((function(){return{dispose:y,init:C,setSettings:w,getInstance:b,dispatch:p}}),[y,C,w,b]);return e.createElement(Fe.Provider,{value:P},e.createElement(Se.Provider,{value:l},e.createElement(De.Provider,{value:h},e.createElement(Te.Provider,{value:v},t.children))))},Be=function(){var e=(0,ke().getInstance)();return i((function(t){null==e||e.restartPrototype(t)}),[e])},Ge=function(){var e=(0,ke().getInstance)();return i((function(){null==e||e.goBack()}),[e])},Ze=function(){var e=(0,ke().getInstance)();return i((function(){null==e||e.goForwards()}),[e])},ze=function(){var e=n(Se);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},Oe=function(){var e=n(De);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},_e=function(){var e=n(Te);if(void 0===e)throw Error("usePrototypePlayState must be used within a provider");return e},Ne=function(e,t){var n=(0,ke().getInstance)();s((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},je={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Ke={position:"absolute",top:0,left:0},Ye=function(t){var n=t.filePath,r=t.locateFile,i=t.imagesURLFormat,u=t.imagesURLMap,c=t.backgroundColor,l=t.mode,h=t.showTilesBorders,v=t.minimumZoomLevel,p=t.maximumZoomLevel,f=t.preserveDrawingBuffer,g=t.children,m=t.containerProps,y=void 0===m?{}:m,C=t.canvasProps,w=void 0===C?{}:C,b=t.featureFlags,P=void 0===b?{}:b,E=t.startArtboardUUID,M=o(null),R=o(null),L=ke(),W=L.dispose,x=L.init,I=L.setSettings,S=Oe(),D=ze();s((function(){I({locateFile:r,imagesURLFormat:i,imagesURLMap:u,backgroundColor:c,mode:l,showTilesBorders:h,minimumZoomLevel:v,maximumZoomLevel:p,preserveDrawingBuffer:f,featureFlags:P,startArtboardUUID:E})}),[I,r,i,u,c,l,h,v,p,f,P,E]),s((function(){if(n)return x(n,M.current,R.current),function(){W()}}),[W,x,n]);var T=a((function(){return d(d({},je),{cursor:S})}),[S]);return e.createElement("div",d({},y,{ref:R,style:T}),n&&e.createElement("canvas",d({},w,{key:n,ref:M,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==D?void 0:D.type.toLowerCase())||"null"),style:Ke})),"READY"===(null==D?void 0:D.type)&&g)};export{ee as CameraMoveContext,Q as CameraZoomingContext,X as CanvasRenderer,ae as CanvasRendererProvider,xe as CanvasRendererReact,ne as CursorContext,S as DefaultFeatureFlags,J as DocumentContext,x as EventEmitter,_ as GestureManager,N as KeyboardManager,I as ListenersCollector,te as PanContext,j as Performance,Ie as PrototypeRenderer,Ue as PrototypeRendererProvider,Ye as PrototypeRendererReact,V as StatusContext,W as WebRendererError,L as WebRendererMode,q as ZoomContext,U as clamp,G as convertEmbindVectorToArray,k as debounce,A as extractPointer,B as getSupportedWebGLVersion,D as getiOSVersion,Z as isTouchDevice,Y as logger,K as nextTick,F as parseSafariUserAgent,ie as reducer,z as removeUndefinedKeys,O as touchableClick,de as useCursor,ge as useDecrementZoom,ue as useDocument,Me as useEvent,we as useGenerateDocumentPNG,be as useGetArtboardAtPosititon,Pe as useGetPanAtPosition,Ge as useGoBack,Ze as useGoForwards,fe as useIncrementZoom,ve as useIsCameraMoving,he as useIsCameraZooming,Ee as useLockCamera,Re as useLogEvent,Ce as useLooseWebGLContext,le as usePan,Oe as usePrototypeCursor,Ne as usePrototypeEvent,_e as usePrototypePlayState,ze as usePrototypeStatus,Be as useRestartPrototype,me as useSetPan,pe as useSetZoom,se as useStatus,ce as useZoom,ye as useZoomToFit};
1
+ import e,{createContext as t,useContext as n,useRef as o,useReducer as r,useCallback as i,useMemo as a,useEffect as s,useState as u}from"react";var c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var d=function(){return d=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},d.apply(this,arguments)};function h(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}function v(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function p(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function f(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}const g=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function m(e){return e.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const y="undefined"==typeof window,C=(()=>{if(y)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,o=/(iphone|ipod|ipad)/i.test(e),r="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:r,isMobile:/android/i.test(e)||o||r,isSafari12:/Version\/12.+Safari/.test(e)}})();const w=[],b=[];function P(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let o=e.length,r=t.length;for(;o>0&&e.charCodeAt(~-o)===t.charCodeAt(~-r);)o--,r--;let i,a=0;for(;a<o&&e.charCodeAt(a)===t.charCodeAt(a);)a++;if(o-=a,r-=a,0===o)return r;let s,u,c=0,l=0,d=0;for(;l<o;)b[l]=e.charCodeAt(a+l),w[l]=++l;for(;d<r;)for(i=t.charCodeAt(a+d),s=d++,c=d,l=0;l<o;l++)u=i===b[l]?s:s+1,s=w[l],c=w[l]=s>c?u>c?c+1:u:u>s?s+1:u;return c}function E(e){return null!=e}class M extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const R=({mobileTiers:e=[0,15,30,60],desktopTiers:t=[0,15,30,60],override:n={},glContext:o,failIfMajorPerformanceCaveat:r=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@4.0.47/dist/benchmarks"}={})=>f(void 0,void 0,void 0,(function*(){const a={};if(y)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==C?void 0:C.isIpad),isMobile:u=!!(null==C?void 0:C.isMobile),screenSize:c=window.screen,loadBenchmarks:l=(e=>f(void 0,void 0,void 0,(function*(){const t=yield fetch(`${i}/${e}`).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<4)throw new M("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:d}=n;const h=(e,t,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:u,tier:e,type:t});let v,p="";if(d)d=m(d),v=[d];else{const e=o||function(e,t=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:t,powerPreference:"high-performance",stencil:!1};e&&delete n.powerPreference;const o=window.document.createElement("canvas"),r=o.getContext("webgl",n)||o.getContext("experimental-webgl",n);return null!=r?r:void 0}(null==C?void 0:C.isSafari12,r);if(!e)return h(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(d=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");p=d,d=m(d),v=function(e,t,n){return"apple gpu"===t?function(e,t,n){if(!n)return[t];const o=function(e){const t=e.createShader(35633),n=e.createShader(35632),o=e.createProgram();if(!(n&&t&&o))return;e.shaderSource(t,"\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n "),e.shaderSource(n,"\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n "),e.compileShader(t),e.compileShader(n),e.attachShader(o,t),e.attachShader(o,n),e.linkProgram(o),e.detachShader(o,t),e.detachShader(o,n),e.deleteShader(t),e.deleteShader(n),e.useProgram(o);const r=e.createBuffer();e.bindBuffer(34962,r),e.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const i=e.getAttribLocation(o,"aPosition");e.vertexAttribPointer(i,3,5126,!1,0,0),e.enableVertexAttribArray(i),e.clearColor(1,1,1,1),e.clear(16384),e.viewport(0,0,1,1),e.drawArrays(4,0,3);const a=new Uint8Array(4);return e.readPixels(0,0,1,1,6408,5121,a),e.deleteProgram(o),e.deleteBuffer(r),a.join("")}(e),r="801621810",i="8016218135",a="80162181161",s=(null==C?void 0:C.isIpad)?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["m1",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15]];let u;return"80162181255"===o?u=s.filter((([,,e])=>e>=14)):(u=s.filter((([,e])=>e===o)),u.length||(u=s)),u.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,d,u)}const w=(yield Promise.all(v.map((function(e){var t;return f(this,void 0,void 0,(function*(){const n=(e=>{const t=u?["adreno","apple","mali-t","mali","nvidia","powervr"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const o=`${u?"m":"d"}-${n}${s?"-ipad":""}.json`,r=a[o]=null!==(t=a[o])&&void 0!==t?t:l(o);let i;try{i=yield r}catch(n){if(n instanceof M)throw n;return}const d=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let h=i.filter((([,e])=>e===d));h.length||(h=i.filter((([t])=>t.includes(e))));const v=h.length;if(0===v)return;let p,[f,,,g]=v>1?h.map((t=>[t,P(e,t[0])])).sort((([,e],[,t])=>e-t))[0][0]:h[0],m=Number.MAX_VALUE;const{devicePixelRatio:y}=window,C=c.width*y*c.height*y;for(const e of g){const[t,n]=e,o=t*n,r=Math.abs(C-o);r<m&&(m=r,p=e)}if(!p)return;const[,,w,b]=p;return[m,w,f,b]}))})))).filter(E).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!w.length){const e=g.find((e=>d.includes(e)));return e?h(0,"BLOCKLISTED",e):h(1,"FALLBACK",`${d} (${p})`)}const[,b,R,L]=w[0];if(-1===b)return h(0,"BLOCKLISTED",R,b,L);const W=u?e:t;let x=0;for(let e=0;e<W.length;e++)b>=W[e]&&(x=e);return h(x,"BENCHMARK",R,b,L)}));var L,W=function(e){function t(n,o,r){var i=this.constructor,a=e.call(this,"(".concat(n,") ").concat(o))||this;return a.code=n,a.cause=r,a.name=t.name,Object.setPrototypeOf(a,i.prototype),a}return l(t,e),t}(Error);!function(e){e.debug="debug",e.release="release"}(L||(L={}));var x=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,o;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(o=this.listeners[e])||void 0===o||o.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.forwardEvent=function(e,t){this.on(t,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];e.emit.apply(e,p([t],n,!1))}))},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this.listeners[e];(null==o?void 0:o.size)&&o.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e.prototype.detachAllListeners=function(){this.listeners={}},e}(),I=function(){function e(){this.removeListenerCallbacks=[]}return e.prototype.add=function(e,t,n,o){e.addEventListener(t,n,o);var r=function(){e.removeEventListener(t,n,o)};return this.removeListenerCallbacks.push(r),r},e.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(e){return e()}))},e}(),S={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1},D=function(e){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(e)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},T=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,F=function(e){if(void 0===e&&(e=window.navigator.userAgent),e.includes("Chrome/")||e.includes("Chromium/")||e.includes("Opera/")||e.includes("Firefox/"))return null;var t=e.match(T);if(!t)return null;var n=t[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(t[4])||0,minor:parseInt(t[5])||0,patch:parseInt(t[6])||0}}};function k(e,t){var n;function o(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){e.apply(void 0,o)}),t)}return o.cancel=function(){n&&clearTimeout(n)},o}function A(e){var t,n,o,r,i,a=null!==(n=null===(t=e.touches)||void 0===t?void 0:t[0])&&void 0!==n?n:null===(o=e.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(r=null==a?void 0:a.clientX)&&void 0!==r?r:e.clientX,y:null!==(i=null==a?void 0:a.clientY)&&void 0!==i?i:e.clientY}}function U(e,t,n){return Math.max(t,Math.min(n,e))}function B(){return F()&&!S.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function G(e){for(var t=e.size(),n=[],o=0;o<t;++o){var r=e.get(o);if(null==r)throw Error("Error converting embind vector to array");n.push(r)}return n}function Z(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function z(e){var t=e;return Object.keys(t).forEach((function(e){void 0===t[e]&&delete t[e]})),t}function O(e){return Z()?{onTouchEnd:e}:{onClick:e}}var _=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},n.handleGestureStart=function(e){e.preventDefault(),n.state.lastGestureScale=e.scale},n.handleGestureChange=function(e){e.preventDefault();var t=e.scale/n.state.lastGestureScale;n.state.lastGestureScale=e.scale;var o=n.getCorrectPointerPosition(e);n.emitZoomEvent(t,o)},n.handleGestureEnd=function(e){e.preventDefault()},n.handleTouchStart=function(e){e.preventDefault(),n.handleTouchPinchToZoomStart(e),n.emit("pointerdown",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleMouseDown=function(e){e.ctrlKey||(e.preventDefault(),n.emit("pointerdown",{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0}))},n.handleTouchMove=function(e){n.handleTouchPinchToZoomChange(e),n.emit("pointermove",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleMouseMove=function(e){n.updateMousePosition(e)},n.handleGlobalTouchMove=function(e){n.emit("globalpointermove",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleGlobalMouseMove=function(e){n.updateGlobalMousePosition(e)},n.handleTouchPinchToZoomStart=function(e){var t;!e.touches||(null===(t=e.touches)||void 0===t?void 0:t.length)<2||(n.state.pinchToZoomLastDistance=n.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]))},n.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var o=n.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]),r=n.getCorrectPointerPosition(e),i=1+.004*(o-n.state.pinchToZoomLastDistance);n.state.pinchToZoomLastDistance=o,n.emitZoomEvent(i,r)}},n.handleTouchEnd=function(e){var t=n.getCorrectPointerPosition(e);n.emit("pointerup",{position:t,type:"touch",button:0,touchesCount:e.touches.length})},n.handleMouseUp=function(e){n.emit("pointerup",{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},n.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!n.state.isCtrlPressed,o=e.metaKey||t||n.state.isCtrlPressed;if(n.updateMousePosition(e),n.updateGlobalMousePosition(e),o){var r=t?-1:1,i=n.getCorrectPointerPosition(e),a=1+.005*e.deltaY*r;n.emitZoomEvent(a,i)}else n.emit("wheel",{x:-e.deltaX,y:-e.deltaY},{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},n.target=t,n.targetBounds=t.getBoundingClientRect(),n.addListeners(),n}return l(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},t.prototype.addKeyboardEventListeners=function(){var e=this;this.listenersCollector.add(document,"keydown",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(t){t.ctrlKey&&(e.state.isCtrlPressed=!1)}))},t.prototype.addMouseEventListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handleMouseDown),this.listenersCollector.add(this.target,"mousemove",this.handleMouseMove),this.listenersCollector.add(document,"mousemove",this.handleGlobalMouseMove),this.listenersCollector.add(document,"mouseup",this.handleMouseUp),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel)},t.prototype.addTouchEventListeners=function(){this.listenersCollector.add(this.target,"touchstart",this.handleTouchStart),this.listenersCollector.add(document,"touchmove",this.handleGlobalTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(this.target,"touchmove",this.handleTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(document,"touchcancel",this.handleTouchEnd),this.listenersCollector.add(document,"touchend",this.handleTouchEnd)},t.prototype.addSafariGesturesEventListeners=function(){Z()||(this.listenersCollector.add(this.target,"gesturestart",this.handleGestureStart,{capture:!0}),this.listenersCollector.add(this.target,"gesturechange",this.handleGestureChange,{capture:!0}),this.listenersCollector.add(this.target,"gestureend",this.handleGestureEnd,{capture:!0}))},t.prototype.clampPointerToTargetBounds=function(e){return{x:U(e.x-this.targetBounds.x,0,this.target.clientWidth),y:U(e.y-this.targetBounds.y,0,this.target.clientHeight)}},t.prototype.getCorrectPointerPosition=function(e){var t,n={x:0,y:0};if((null===(t=e.touches)||void 0===t?void 0:t.length)>1){var o=e,r=o.touches[0],i=o.touches[1];n={x:(r.clientX+i.clientX)/2,y:(r.clientY+i.clientY)/2}}else n=A(e);return this.clampPointerToTargetBounds(n)},t.prototype.updateMousePosition=function(e){this.emit("pointermove",{type:"mouse",position:this.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},t.prototype.updateGlobalMousePosition=function(e){this.emit("globalpointermove",{type:"mouse",position:this.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},t.prototype.calculateDistanceBetweenTouches=function(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)},t.prototype.emitZoomEvent=function(e,t){this.emit("pinchToZoom",e,t)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(x),N=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.handleKeyUp=function(e){n.emit("keyUp",e.code)},n.target=t,n.addListeners(),n}return l(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(x),j=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now()}return e.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(t," ms")}var n=(e/1e3).toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(n," s")},e}();function K(e){setTimeout((function(){e()}),0)}var Y=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l(t,e),t.prototype.logDebug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,p(["log","debug"],e,!1))},t.prototype.logWarning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,p(["log","warn"],e,!1))},t.prototype.logError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,p(["log","error"],e,!1))},t}(x)),$=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.size={width:0,height:0},n.pixelRatio=1,n.handleCanvasResizeObserver=function(e){n.resizeCanvas(e[0].contentRect)},n.resizeCanvas=function(e){var t=e.width,o=e.height;window.requestAnimationFrame((function(){n.setSize(t,o),n.emit("resize",t,o,n.getDevicePixelRatio())}))},n.getCanvasCenterPoint=function(){var e=n.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},n.container=t.container,n.canvas=t.canvas,n.canvasResizeObserver=new ResizeObserver(n.handleCanvasResizeObserver),n.canvasResizeObserver.observe(n.container),n.listenersCollector.add(window,"orientationchange",n.handleDeviceOrientationChange),n.setSize(n.container.clientWidth,n.container.clientHeight),n}return l(t,e),t.prototype.setSize=function(e,t){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(e,"px"),this.canvas.style.height="".concat(t,"px"),this.size.width=e*this.pixelRatio,this.size.height=t*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},t.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},t.prototype.getDevicePixelRatio=function(){return U(window.devicePixelRatio,1,2)},t.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},t.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},t}(x),H=function(){function e(e){this.settings=e}return e.prototype.isReleaseMode=function(){return this.settings.mode===L.release},e.prototype.init=function(){return h(this,void 0,void 0,(function(){var e,t,n,o,r,i=this;return v(this,(function(a){switch(a.label){case 0:return[4,this.importModule()];case 1:e=a.sent(),t=e.default,a.label=2;case 2:return a.trys.push([2,4,,5]),n=this,[4,t({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:B(),bridge:this.settings.jsBridge,locateFile:function(e){return i.settings.locateFile.replace("{file}",e)}})];case 3:return n.instance=a.sent(),[3,5];case 4:throw o=a.sent(),new W("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerType.Unset,mouse:this.instance.PRUserPointerType.Mouse,touch:this.instance.PRUserPointerType.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorType.Auto.value]="auto",r[this.instance.PRCursorType.Default.value]="default",r[this.instance.PRCursorType.Pointer.value]="pointer",r[this.instance.PRCursorType.Grab.value]="grab",r[this.instance.PRCursorType.Grabbing.value]="grabbing",r),[2]}}))}))},e.prototype.makeWebGLContext=function(e,t){void 0===t&&(t={});var n=d({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},t),o=this.instance.GL.createContext(e,n);if(!o)throw new W("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");return o},e.prototype.destroyWebGLContext=function(e){var t,n=null===(t=this.instance)||void 0===t?void 0:t.GL.getContext(e);if(n){var o=n.GLctx.getExtension("WEBGL_lose_context");if(o)return o.loseContext(),!0}},e.prototype.importModule=function(){return this.isReleaseMode()?import("./module-release-bd90bea3.js"):import("./module-debug-7ee9ba03.js")},e.prototype.mapToCSSCursor=function(e){return this.prCursorTypeToCSSCursorMap[e.value]},e.prototype.mapToPRPointerType=function(e){var t;return null!==(t=this.pointerTypeToWASMMap[e])&&void 0!==t?t:this.instance.PRUserPointerType.Unset},e.prototype.mapPointerInfo=function(e){return d(d({},e),{type:this.mapToPRPointerType(e.type)})},e}(),X=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"INIT"},n.handleCanvasResize=function(e,t,o){var r;null===(r=n.pageCanvasWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&(null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(e.x,e.y,n.wasmModule.mapPointerInfo(t)))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(e)))},n.settings=d(d({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1,panBoundariesPadding:0},z(t)),{featureFlags:d(d({},S),t.featureFlags)}),n.gestureManager=new _(n.settings.container),n.canvasManager=new $({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new H({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return l(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,R()];case 1:return e=t.sent(),this.deviceInfo=d(d({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:this.traceFirstPaint=new j("FirstPaint"),this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),t.label=1;case 1:return t.trys.push([1,5,,6]),[4,this.initWasmModule()];case 2:return t.sent(),[4,this.initCanvasRendererWasm()];case 3:return t.sent(),[4,this.setFile(this.settings.filePath)];case 4:return t.sent(),[3,6];case 5:return e=t.sent(),[2,this.fail(e instanceof W?e:new W("ERROR","Unexpected exception initializing the web renderer",e))];case 6:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.setInitialCameraState=function(){var e,t,n,o=void 0!==this.settings.initialZoom,r=void 0!==this.settings.initialPan;o||r?(o&&this.setZoom(this.settings.initialZoom||1),r&&this.setPan((null===(e=this.settings.initialPan)||void 0===e?void 0:e.x)||0,(null===(t=this.settings.initialPan)||void 0===t?void 0:t.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport)):this.zoomToFit()},t.prototype.startRendering=function(){var e;this.traceInitialRender=new j("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.pageCanvasWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){Y.logDebug("[C++] ".concat(e))},logWarning:function(e){Y.logWarning("[C++] ".concat(e))},logError:function(e){Y.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t):e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t]:(Y.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:(Y.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(){var t=e.getPan();e.emit("cameraPanChange",(null==t?void 0:t.x)||0,(null==t?void 0:t.y)||0)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},onPlayStateChange:function(){},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this)}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){var i,a,s,u;if(t.data.url===e){switch(t.data.type){case"success":o.exec(new Uint8Array(t.data.buffer),200,"");break;case"error":Y.logError("Error while fetching ".concat(e),t.data.error),o.exec(new Uint8Array(0),null!==(a=null===(i=t.data.error)||void 0===i?void 0:i.statusCode)&&void 0!==a?a:500,null!==(u=null===(s=t.data.error)||void 0===s?void 0:s.statusText)&&void 0!==u?u:"Unknown error")}n.fetchWorker.removeEventListener("message",r)}};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initWasmModule=function(){var e;return h(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=new j("WasmModuleDownload"),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()];case 1:return n.sent(),Y.logDebug(t.printMeasurement()),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.initCanvasRendererWasm=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){try{if(!this.wasmModule)throw Error("WASM module not initialized");e=B(),Y.logDebug("Using WebGL ".concat(e)),this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:e}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.pageCanvasWasm=new this.wasmModule.instance.CanvasRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(e){throw new W("WASM_ERROR","An error occurred while trying to create the wasm object.",e)}return this.userEventsCollectorWasm=this.pageCanvasWasm.getUserEventsCollector(),this.pageCanvasWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.pageCanvasWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.pageCanvasWasm.setPanBoundariesPadding(this.settings.panBoundariesPadding),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.pageCanvasWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.generateDocumentPNG=function(){var e;return h(this,void 0,void 0,(function(){return v(this,(function(t){return[2,null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.generateDocumentPNG()]}))}))},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(Y.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),Y.logDebug(this.traceFirstPaint.printMeasurement()),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;(null===(e=this.wasmModule)||void 0===e?void 0:e.destroyWebGLContext(this.webglCtxHandle))||Y.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.scaleDocumentToFit()},t.prototype.setFile=function(e){return h(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=t.pageCanvasWasm)||void 0===r||r.setFile(e,(function(e,o,r){t.setStatus({type:"FILE_READY"});var i="".concat(e,"-v").concat("5.2.4");t.emit("fileReady",t.getDocument(),i,o,r),n()}),(function(){return o(new W("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:"".concat(e.toString()).concat(e.cause?"\nWrapped Error: ".concat(e.cause.toString()):"")}),Y.logError(e),e.cause&&Y.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(Y.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getDocument=function(){if(!this.pageCanvasWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var e=this.pageCanvasWasm.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:d(d({},e),{artboards:G(e.artboards)})}}return this.cachedDocumentInfo.document},t.prototype.getArtboardAtPosition=function(e,t){if(this.pageCanvasWasm){var n=this.getDocument();if(n){for(var o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(e-o.x)/r,a=(t-o.y)/r,s=0,u=n.artboards;s<u.length;s++){var c=u[s],l=c.bounds.x+c.bounds.width,d=c.bounds.y+c.bounds.height;if(i>=c.bounds.x&&a>=c.bounds.y&&i<=l&&a<=d)return c.objectId}return null}}},t.prototype.getPanAtPosition=function(e,t){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),r=e/o,i=t/o;return{x:n.x-r,y:n.y-i}},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,o=null!=t?t:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(e,o.x,o.y)},t.prototype.getPan=function(){var e,t,n=this.getDocument().bounds,o=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getPan(),r=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom();return o&&r?{x:o.x/r+n.x,y:o.y/r+n.y}:{x:0,y:0}},t.prototype.getZoom=function(){var e;return(null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom())||0},t.prototype.setPan=function(e,t,n){var o;void 0===n&&(n=!1);var r=e,i=t,a=this.getDocument().bounds,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);r+=this.canvasManager.size.width/u,i+=this.canvasManager.size.height/u}var c=(r-a.x)*s,l=(i-a.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(c,l)},t.prototype.dispose=function(){var e,t,n;try{this.detachAllListeners(),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(e=this.pageCanvasWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.pageCanvasWasm)||void 0===t||t.delete(),null===(n=this.renderTarget)||void 0===n||n.delete(),this.fetchWorker.terminate(),this.pageCanvasWasm=void 0,this.wasmModule=void 0}catch(e){this.fail(new W("ERROR","Unexpected exception while disposing the wasm object",e))}},t}(x),V=t(void 0),J=t(void 0),q=t(void 0),Q=t(void 0),ee=t(void 0),te=t(void 0),ne=t("auto"),oe=t(void 0),re=function(){var e=n(oe);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},ie=function(e,t){switch(t.type){case"on-status":return d(d({},e),{status:t.status});case"on-file-ready":return d(d({},e),{document:t.document});case"on-zoom":return d(d({},e),{zoom:t.zoom});case"on-pan":return d(d({},e),{pan:t.pan});case"dispose":return d(d({},e),{status:null,zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return d(d({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return d(d({},e),{isCameraZooming:!1});case"on-camera-move-start":return d(d({},e),{isCameraMoving:!0});case"on-camera-move-end":return d(d({},e),{isCameraMoving:!1});case"on-cursor-change":return d(d({},e),{cursor:t.cursor});default:return e}},ae=function(t){var n=o(null),s=o(null),u=r(ie,{pan:null,zoom:null,status:null,document:null,isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),c=u[0],l=c.status,h=c.document,v=c.zoom,p=c.pan,f=c.isCameraZooming,g=c.isCameraMoving,m=c.cursor,y=u[1],C=i((function(e){return y({type:"on-zoom",zoom:e})}),[]),w=i((function(e,t){return y({type:"on-pan",pan:{x:e,y:t}})}),[]),b=i((function(e){y({type:"on-status",status:e})}),[]),P=i((function(e){y({type:"on-file-ready",document:e})}),[]),E=i((function(){return y({type:"on-camera-zoom-start"})}),[]),M=i((function(){return y({type:"on-camera-zoom-end"})}),[]),R=i((function(){return y({type:"on-camera-move-start"})}),[]),L=i((function(){return y({type:"on-camera-move-end"})}),[]),W=i((function(e){return y({type:"on-cursor-change",cursor:e})}),[]),x=i((function(){var e=n.current;e&&(Y.logDebug("Provider dispose"),e.off("status",b),e.off("fileReady",P),e.off("cameraZoomChange",C),e.off("cameraPanChange",w),e.off("cameraZoomStart",E),e.off("cameraZoomEnd",M),e.off("cameraMoveStart",R),e.off("cameraMoveEnd",L),e.off("cursorChange",W),e.dispose(),n.current=null,y({type:"dispose"}))}),[b,P,w,C,E,M,R,L,W]),I=i((function(e,t,o){if(""!==e&&t&&o&&s.current){Y.logDebug("Provider init");var r=new X(d(d({},s.current),{filePath:e,container:o,canvas:t}));r.on("status",b),r.on("fileReady",P),r.on("cameraZoomChange",C),r.on("cameraPanChange",w),r.on("cameraZoomStart",E),r.on("cameraZoomEnd",M),r.on("cameraMoveStart",R),r.on("cameraMoveEnd",L),r.on("cursorChange",W),n.current=r}}),[b,P,C,w,E,M,R,L,W]),S=i((function(e){var t;Y.logDebug("Provider setSettings",e),e.backgroundColor&&(null===(t=n.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),s.current=e}),[]),D=i((function(){return n.current}),[]),T=a((function(){return{dispose:x,init:I,setSettings:S,getInstance:D,dispatch:y}}),[x,I,S,D]);return e.createElement(oe.Provider,{value:T},e.createElement(V.Provider,{value:l},e.createElement(J.Provider,{value:h},e.createElement(q.Provider,{value:v},e.createElement(te.Provider,{value:p},e.createElement(Q.Provider,{value:f},e.createElement(ee.Provider,{value:g},e.createElement(ne.Provider,{value:m},t.children))))))))},se=function(){var e=n(V);if(void 0===e)throw Error("useStatus must be used within a provider");return e},ue=function(){var e=n(J);if(void 0===e)throw Error("useDocument must be used within a provider");return e},ce=function(){var e=n(q);if(void 0===e)throw Error("useZoom must be used within a provider");return e},le=function(){var e=n(te);if(void 0===e)throw Error("usePan must be used within a provider");return e},de=function(){var e=n(ne);if(void 0===e)throw Error("useCursor must be used within a provider");return e},he=function(){var e=n(Q);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},ve=function(){var e=n(ee);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},pe=function(){var e=(0,re().getInstance)();return i((function(t){null==e||e.setZoom(t)}),[e])},fe=function(){var e=pe(),t=ce();return i((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},ge=function(){var e=pe(),t=ce();return i((function(){"number"==typeof t&&e(t/2)}),[e,t])},me=function(){var e=(0,re().getInstance)();return i((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},ye=function(){var e=(0,re().getInstance)();return i((function(){null==e||e.zoomToFit()}),[e])},Ce=function(){var e=(0,re().getInstance)();return i((function(){null==e||e.looseWebGLContext()}),[e])},we=function(){var e=(0,re().getInstance)();return i((function(){return h(void 0,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,null==e?void 0:e.generateDocumentPNG()];case 1:return[2,t.sent()]}}))}))}),[e])},be=function(){var e=(0,re().getInstance)();return i((function(t,n){return h(void 0,void 0,void 0,(function(){return v(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Pe=function(){var e=(0,re().getInstance)();return i((function(t,n){return h(void 0,void 0,void 0,(function(){return v(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Ee=function(){var e=(0,re().getInstance)();return i((function(t){null==e||e.setIsCameraLocked(t)}),[e])},Me=function(e,t){var n=(0,re().getInstance)();s((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function Re(e){var t=o(e);t.current=e;var n=i((function(e){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];t.current.apply(t,p([e],n,!1))}),[]);s((function(){return Y.on("log",n),function(){Y.off("log",n)}}),[])}var Le={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},We={position:"absolute",top:0,left:0},xe=function(t){var n=t.filePath,r=t.locateFile,c=t.imagesURLFormat,l=t.imagesURLMap,h=t.fragmentsURLFormat,v=t.fragmentsURLMap,p=t.backgroundColor,f=t.mode,g=t.showTilesBorders,m=t.minimumZoomLevel,y=t.maximumZoomLevel,C=t.preserveDrawingBuffer,w=t.panBoundariesPadding,b=t.initialPan,P=t.initialZoom,E=t.children,M=t.containerProps,R=void 0===M?{}:M,L=t.canvasProps,W=void 0===L?{}:L,x=t.featureFlags,I=void 0===x?{}:x,S=o(null),D=o(null),T=u(!1),F=T[0],k=T[1],A=i((function(){return k(!0)}),[]),U=re(),B=U.dispose,G=U.init,Z=U.setSettings,z=de(),O=se();Me("allImagesReady",A),s((function(){return Y.logDebug("WebRenderer mounted"),function(){return Y.logDebug("WebRenderer unmounted")}}),[]),s((function(){Z({locateFile:r,imagesURLFormat:c,imagesURLMap:l,fragmentsURLFormat:h,fragmentsURLMap:v,backgroundColor:p,mode:f,showTilesBorders:g,minimumZoomLevel:m,maximumZoomLevel:y,preserveDrawingBuffer:C,panBoundariesPadding:w,initialPan:b,initialZoom:P,featureFlags:I})}),[Z,r,c,l,h,v,p,f,g,m,y,C,w,b,P,I]),s((function(){if(n)return G(n,S.current,D.current),function(){B()}}),[B,G,n]);var _=a((function(){var e;return null!==(e=t.cursor)&&void 0!==e?e:z}),[t.cursor,z]),N=a((function(){return d(d({},Le),{cursor:_})}),[_]);return e.createElement("div",d({},R,{ref:D,style:N}),n&&e.createElement("canvas",d({},W,{key:n,ref:S,"data-sketchweb-all-images-ready":F,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==O?void 0:O.type.toLowerCase())||"null"),style:We})),"READY"===(null==O?void 0:O.type)&&E)},Ie=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"INIT"},n.handleCanvasResize=function(e,t,o){var r;null===(r=n.playerWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&n.userEventsCollectorWasm.dispatchWheelEvent(e.x,e.y,null===(o=n.wasmModule)||void 0===o?void 0:o.mapPointerInfo(t))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerDownEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerUpEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.restartPrototype=function(e){var t;null===(t=n.playerWasm)||void 0===t||t.restartPrototype(e)},n.goBack=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goBack()},n.goForwards=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goForwards()},n.settings=d(d({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1},z(t)),{featureFlags:d(d({},S),t.featureFlags)}),n.gestureManager=new _(n.settings.container),n.canvasManager=new $({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new H({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.settings.manualInitialization||n.init(),n}return l(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:return[4,R()];case 1:return e=t.sent(),this.deviceInfo=d(d({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){return h(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:this.traceFirstPaint=new j("FirstPaint"),this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),t.label=1;case 1:return t.trys.push([1,6,,7]),[4,this.initWasmModule()];case 2:return t.sent(),[4,this.initPlayerWasm()];case 3:return t.sent(),[4,this.setFile(this.settings.filePath)];case 4:return t.sent(),[4,this.preloadImages()];case 5:return t.sent(),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof W?e:new W("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initWasmModule=function(){var e;return h(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return t=new j("WasmModuleDownload"),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()];case 1:return n.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.setInitialCameraState=function(){this.zoomToFit()},t.prototype.preloadImages=function(){var e=this;return new Promise((function(t){var n;null===(n=e.playerWasm)||void 0===n||n.preloadImages((function(){t()}))}))},t.prototype.startRendering=function(){var e;this.traceInitialRender=new j("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.playerWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){Y.logDebug("[C++] ".concat(e))},logWarning:function(e){Y.logWarning("[C++] ".concat(e))},logError:function(e){Y.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t):e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t]:(Y.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(){return""},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(t,n){e.emit("cameraPanChange",t,n)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},onPlayStateChange:function(t,n,o){e.emit("playStateChange",{screenArtboardId:t,canGoBack:n,canGoForwards:o})}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n,o=new j("ImagesDownload");null===(n=e.playerWasm)||void 0===n||n.downloadImages((function(){o.printMeasurement(),e.emit("metric",o.measure()),Y.logDebug("Images downloaded"),t()}))}))},t.prototype.initPlayerWasm=function(){return h(this,void 0,void 0,(function(){return v(this,(function(e){try{if(!this.wasmModule)throw Error("WASM module not initialized");this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:B()}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.playerWasm=new this.wasmModule.instance.PrototypeRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID)}catch(e){throw new W("WASM_ERROR","An error occurred while trying to create the WebRendererWasm object.",e)}return this.userEventsCollectorWasm=this.playerWasm.getUserEventsCollector(),this.playerWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.playerWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.playerWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.playerWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}),this.downloadImages())},t.prototype.looseWebGLContext=function(){var e;null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(){var e;null===(e=this.playerWasm)||void 0===e||e.scaleDocumentToFit()},t.prototype.setFile=function(e){return h(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=t.playerWasm)||void 0===r||r.setFile(e,(function(e,o,r){t.setStatus({type:"FILE_READY"});var i="".concat(e,"-v").concat("5.2.4");t.emit("fileReady",t.getDocument(),i,o,r),n()}),(function(){return o(new W("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:"".concat(e.toString()).concat(e.cause?"\nWrapped Error: ".concat(e.cause.toString()):"")}),Y.logError(e),e.cause&&Y.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(Y.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getStatus=function(){return this.status},t.prototype.getDocument=function(){var e;if(!this.playerWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var t=null===(e=this.playerWasm)||void 0===e?void 0:e.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:d(d({},t),{artboards:G(t.artboards)})}}return this.cachedDocumentInfo.document},t.prototype.dispose=function(){var e,t;try{this.detachAllListeners(),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(e=this.playerWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.playerWasm)||void 0===t||t.delete(),this.renderTarget.delete(),this.playerWasm=void 0,this.wasmModule=void 0}catch(e){this.fail(new W("ERROR","Unexpected exception while disposing the WebRendererWasm object",e))}},t}(x),Se=t(void 0),De=t("auto"),Te=t(void 0),Fe=t(void 0),ke=function(){var e=n(Fe);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},Ae=function(e,t){switch(t.type){case"on-status":return d(d({},e),{status:t.status});case"dispose":return d(d({},e),{status:null,cursor:"auto"});case"on-cursor-change":return d(d({},e),{cursor:t.cursor});case"on-play-state-change":return d(d({},e),{playState:d(d({},e.playState),t.playState)});default:return e}},Ue=function(t){var n=o(null),s=o(null),u=r(Ae,{status:null,cursor:"auto",playState:{screenArtboardId:"",canGoBack:!0,canGoForwards:!0}}),c=u[0],l=c.status,h=c.cursor,v=c.playState,p=u[1],f=i((function(e){p({type:"on-status",status:e})}),[]),g=i((function(e){return p({type:"on-cursor-change",cursor:e})}),[]),m=i((function(e){return p({type:"on-play-state-change",playState:e})}),[]),y=i((function(){var e=n.current;e&&(Y.logDebug("Provider dispose"),e.off("status",f),e.off("cursorChange",g),e.off("playStateChange",m),e.dispose(),n.current=null,p({type:"dispose"}))}),[f,g,m]),C=i((function(e,t,o){if(""!==e&&t&&o&&s.current){Y.logDebug("Provider init");var r=new Ie(d(d({},s.current),{filePath:e,container:o,canvas:t}));r.on("status",f),r.on("cursorChange",g),r.on("playStateChange",m),n.current=r}}),[f,g,m]),w=i((function(e){var t;Y.logDebug("Provider setSettings",e),e.backgroundColor&&(null===(t=n.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),s.current=e}),[]),b=i((function(){return n.current}),[]),P=a((function(){return{dispose:y,init:C,setSettings:w,getInstance:b,dispatch:p}}),[y,C,w,b]);return e.createElement(Fe.Provider,{value:P},e.createElement(Se.Provider,{value:l},e.createElement(De.Provider,{value:h},e.createElement(Te.Provider,{value:v},t.children))))},Be=function(){var e=(0,ke().getInstance)();return i((function(t){null==e||e.restartPrototype(t)}),[e])},Ge=function(){var e=(0,ke().getInstance)();return i((function(){null==e||e.goBack()}),[e])},Ze=function(){var e=(0,ke().getInstance)();return i((function(){null==e||e.goForwards()}),[e])},ze=function(){var e=n(Se);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},Oe=function(){var e=n(De);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},_e=function(){var e=n(Te);if(void 0===e)throw Error("usePrototypePlayState must be used within a provider");return e},Ne=function(e,t){var n=(0,ke().getInstance)();s((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},je={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Ke={position:"absolute",top:0,left:0},Ye=function(t){var n=t.filePath,r=t.locateFile,i=t.imagesURLFormat,u=t.imagesURLMap,c=t.backgroundColor,l=t.mode,h=t.showTilesBorders,v=t.minimumZoomLevel,p=t.maximumZoomLevel,f=t.preserveDrawingBuffer,g=t.children,m=t.containerProps,y=void 0===m?{}:m,C=t.canvasProps,w=void 0===C?{}:C,b=t.featureFlags,P=void 0===b?{}:b,E=t.startArtboardUUID,M=o(null),R=o(null),L=ke(),W=L.dispose,x=L.init,I=L.setSettings,S=Oe(),D=ze();s((function(){I({locateFile:r,imagesURLFormat:i,imagesURLMap:u,backgroundColor:c,mode:l,showTilesBorders:h,minimumZoomLevel:v,maximumZoomLevel:p,preserveDrawingBuffer:f,featureFlags:P,startArtboardUUID:E})}),[I,r,i,u,c,l,h,v,p,f,P,E]),s((function(){if(n)return x(n,M.current,R.current),function(){W()}}),[W,x,n]);var T=a((function(){return d(d({},je),{cursor:S})}),[S]);return e.createElement("div",d({},y,{ref:R,style:T}),n&&e.createElement("canvas",d({},w,{key:n,ref:M,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==D?void 0:D.type.toLowerCase())||"null"),style:Ke})),"READY"===(null==D?void 0:D.type)&&g)};export{ee as CameraMoveContext,Q as CameraZoomingContext,X as CanvasRenderer,ae as CanvasRendererProvider,xe as CanvasRendererReact,ne as CursorContext,S as DefaultFeatureFlags,J as DocumentContext,x as EventEmitter,_ as GestureManager,N as KeyboardManager,I as ListenersCollector,te as PanContext,j as Performance,Ie as PrototypeRenderer,Ue as PrototypeRendererProvider,Ye as PrototypeRendererReact,V as StatusContext,W as WebRendererError,L as WebRendererMode,q as ZoomContext,U as clamp,G as convertEmbindVectorToArray,k as debounce,A as extractPointer,B as getSupportedWebGLVersion,D as getiOSVersion,Z as isTouchDevice,Y as logger,K as nextTick,F as parseSafariUserAgent,ie as reducer,z as removeUndefinedKeys,O as touchableClick,de as useCursor,ge as useDecrementZoom,ue as useDocument,Me as useEvent,we as useGenerateDocumentPNG,be as useGetArtboardAtPosititon,Pe as useGetPanAtPosition,Ge as useGoBack,Ze as useGoForwards,fe as useIncrementZoom,ve as useIsCameraMoving,he as useIsCameraZooming,Ee as useLockCamera,Re as useLogEvent,Ce as useLooseWebGLContext,le as usePan,Oe as usePrototypeCursor,Ne as usePrototypeEvent,_e as usePrototypePlayState,ze as usePrototypeStatus,Be as useRestartPrototype,me as useSetPan,pe as useSetZoom,se as useStatus,ce as useZoom,ye as useZoomToFit};
Binary file
Binary file
@@ -52,6 +52,7 @@ export declare class CanvasRenderer extends EventEmitter<WebRendererEvents> {
52
52
  startRendering(): void;
53
53
  private createJSBridge;
54
54
  private handleJSBridgeFetch;
55
+ handleJSBridgeAbortFetch(url: string): void;
55
56
  private initWasmModule;
56
57
  private initCanvasRendererWasm;
57
58
  setIsCameraLocked(isLocked: boolean): void;
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasRenderer.d.ts","sourceRoot":"","sources":["../../../src/ts/canvas-renderer/CanvasRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAMjB,WAAW,EAGX,mBAAmB,EACnB,KAAK,EAEN,MAAM,U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are type PendingRequest = {
6
6
  promise: Promise<Response>;
7
7
  abortController: AbortController;
8
+ aborted: boolean;
8
9
  };
9
10
  //# sourceMappingURL=FetchWorker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FetchWorker.d.ts","sourceRoot":"","sources":["../../../src/ts/fetch-worker/FetchWorker.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,oBAAY,cAAc,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC1B,eAAe,EAAE,eAAe,CAAA;CACjC,CAAA"}
1
+ {"version":3,"file":"FetchWorker.d.ts","sourceRoot":"","sources":["../../../src/ts/fetch-worker/FetchWorker.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,oBAAY,cAAc,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC1B,eAAe,EAAE,eAAe,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA"}
@@ -28,5 +28,6 @@ export interface JSBridge {
28
28
  onCursorChange: (cursor: PRCursorType) => void;
29
29
  onPlayStateChange: (screenArtboardId: string, canGoBack: boolean, canGoForward: boolean) => void;
30
30
  fetch?: (url: string, callback: JSBridgeFetchCallback) => void;
31
+ abortFetch?: (url: string) => void;
31
32
  }
32
33
  //# sourceMappingURL=JSBridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"JSBridge.d.ts","sourceRoot":"","sources":["../../../../src/ts/types/wasm/JSBridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD,oBAAY,qBAAqB,GAAG,cAAc,CAChD;IAAc,UAAU;IAAmB,MAAM;IAAmB,MAAM;CAAC,EAC3E,IAAI,CACL,CAAA;AAED,MAAM,WAAW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O,KAClB,IAAI,CAAA;IACT,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,KAAK,IAAI,CAAA;IAC9D,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sketch-hq/sketch-web-renderer",
3
- "version": "5.2.2",
3
+ "version": "5.2.4",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Sketch Web Renderer",
6
6
  "repository": "git@github.com:sketch-hq/web-renderer",
@@ -50,7 +50,7 @@
50
50
  "@rollup/plugin-replace": "5.0.1",
51
51
  "@rollup/plugin-terser": "0.1.0",
52
52
  "@rollup/plugin-typescript": "9.0.2",
53
- "@sketch-hq/sketch-file-format-marina": "5.2.2",
53
+ "@sketch-hq/sketch-file-format-marina": "5.2.4",
54
54
  "@sketch-hq/sketch-presentation-file-format": "0.11.1",
55
55
  "@types/jest": "29.2.2",
56
56
  "@types/node": "18.11.9",