@sketch-hq/sketch-web-renderer 3.2.1 → 3.2.3

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.
Files changed (59) hide show
  1. package/dist/cpp/out/Debug/module-debug.d.ts +6 -0
  2. package/dist/cpp/out/Debug/module-debug.d.ts.map +1 -0
  3. package/dist/cpp/out/Release/module-release.d.ts +6 -0
  4. package/dist/cpp/out/Release/module-release.d.ts.map +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/module-debug.wasm +0 -0
  7. package/dist/module-release.wasm +0 -0
  8. package/dist/static/js/web-renderer-49953fc2d5b916489af2.chunk.js +1 -0
  9. package/dist/static/js/web-renderer-8cf7e3dad04db65cf1e1.chunk.js +1 -0
  10. package/dist/static/js/web-renderer-aabfc7a6fc6164757d08.chunk.js +1 -0
  11. package/dist/ts/Manager.d.ts +21 -11
  12. package/dist/ts/Manager.d.ts.map +1 -1
  13. package/dist/ts/SketchWeb.d.ts +26 -16
  14. package/dist/ts/SketchWeb.d.ts.map +1 -1
  15. package/dist/ts/react/SketchWebProvider.d.ts +6 -2
  16. package/dist/ts/react/SketchWebProvider.d.ts.map +1 -1
  17. package/dist/ts/react/SketchWebReact.d.ts +3 -2
  18. package/dist/ts/react/SketchWebReact.d.ts.map +1 -1
  19. package/dist/ts/react/contexts.d.ts +4 -20
  20. package/dist/ts/react/contexts.d.ts.map +1 -1
  21. package/dist/ts/react/hooks/actions.d.ts +4 -1
  22. package/dist/ts/react/hooks/actions.d.ts.map +1 -1
  23. package/dist/ts/react/hooks/state.d.ts +2 -20
  24. package/dist/ts/react/hooks/state.d.ts.map +1 -1
  25. package/dist/ts/react/hooks/useEvent.d.ts +1 -1
  26. package/dist/ts/react/hooks/useEvent.d.ts.map +1 -1
  27. package/dist/ts/react/internal.d.ts.map +1 -1
  28. package/dist/ts/react/reducer.d.ts.map +1 -1
  29. package/dist/ts/react/types.d.ts +4 -15
  30. package/dist/ts/react/types.d.ts.map +1 -1
  31. package/dist/ts/types/CSSCursor.d.ts +12 -0
  32. package/dist/ts/types/CSSCursor.d.ts.map +1 -0
  33. package/dist/ts/types/Error.d.ts +2 -2
  34. package/dist/ts/types/Error.d.ts.map +1 -1
  35. package/dist/ts/types/Events.d.ts +8 -4
  36. package/dist/ts/types/Events.d.ts.map +1 -1
  37. package/dist/ts/types/JSBridge.d.ts +8 -0
  38. package/dist/ts/types/JSBridge.d.ts.map +1 -1
  39. package/dist/ts/types/PointerInfo.d.ts +11 -0
  40. package/dist/ts/types/PointerInfo.d.ts.map +1 -0
  41. package/dist/ts/types/WASM.d.ts +70 -38
  42. package/dist/ts/types/WASM.d.ts.map +1 -1
  43. package/dist/ts/utils/GestureManager/GestureManager.d.ts +23 -43
  44. package/dist/ts/utils/GestureManager/GestureManager.d.ts.map +1 -1
  45. package/dist/ts/utils/misc.d.ts +0 -1
  46. package/dist/ts/utils/misc.d.ts.map +1 -1
  47. package/package.json +27 -26
  48. package/CHANGELOG.md +0 -552
  49. package/dist/static/js/web-renderer-17fd55cdb979ed59dbc9.chunk.js +0 -1
  50. package/dist/static/js/web-renderer-b584c7152f956c9cbea5.chunk.js +0 -1
  51. package/dist/static/js/web-renderer-bc8f1d99872a3ed28cf9.chunk.js +0 -1
  52. package/dist/ts/utils/CameraMoveTracker/CameraMoveTracker.d.ts +0 -48
  53. package/dist/ts/utils/CameraMoveTracker/CameraMoveTracker.d.ts.map +0 -1
  54. package/dist/ts/utils/CameraMoveTracker/CameraMoveTracker.test.d.ts +0 -2
  55. package/dist/ts/utils/CameraMoveTracker/CameraMoveTracker.test.d.ts.map +0 -1
  56. package/dist/ts/utils/CameraMoveTracker/index.d.ts +0 -2
  57. package/dist/ts/utils/CameraMoveTracker/index.d.ts.map +0 -1
  58. package/dist/ts/utils/GestureManager/GestureManager.test.d.ts +0 -2
  59. package/dist/ts/utils/GestureManager/GestureManager.test.d.ts.map +0 -1
@@ -0,0 +1,6 @@
1
+ export = SketchWebWasmFactory;
2
+ declare function SketchWebWasmFactory(SketchWebWasmFactory: any, ...args: any[]): any;
3
+ declare namespace SketchWebWasmFactory {
4
+ export { SketchWebWasmFactory };
5
+ }
6
+ //# sourceMappingURL=module-debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-debug.d.ts","sourceRoot":"","sources":["../../../../src/cpp/out/Debug/module-debug.js"],"names":[],"mappings":";AAKA,sFA4tOC"}
@@ -0,0 +1,6 @@
1
+ export = SketchWebWasmFactory;
2
+ declare function SketchWebWasmFactory(SketchWebWasmFactory: any): any;
3
+ declare namespace SketchWebWasmFactory {
4
+ export { SketchWebWasmFactory };
5
+ }
6
+ //# sourceMappingURL=module-release.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-release.d.ts","sourceRoot":"","sources":["../../../../src/cpp/out/Release/module-release.js"],"names":[],"mappings":";AAKA,sEAOC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(require("react")):t(e.react);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,(function(e){return(()=>{var t,n,o,r,i={975:(e,t,n)=>{"use strict";function o(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())}))}n.d(t,{M:()=>f});const r=["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 i(e){return e.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"")}const a="undefined"==typeof window,s=(()=>{if(a)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)}})(),u=[],c=[];function l(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,l,d=0,h=0,f=0;for(;h<o;)c[h]=e.charCodeAt(a+h),u[h]=++h;for(;f<r;)for(i=t.charCodeAt(a+f),s=f++,d=f,h=0;h<o;h++)l=i===c[h]?s:s+1,s=u[h],d=u[h]=s>d?l>d?d+1:l:l>s?s+1:l;return d}function d(e){return null!=e}class h extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const f=({mobileTiers:e=[0,15,30,60],desktopTiers:t=[0,15,30,60],override:n={},glContext:u,failIfMajorPerformanceCaveat:c=!1,benchmarksURL:f="https://unpkg.com/detect-gpu@4.0.37/dist/benchmarks"}={})=>o(void 0,void 0,void 0,(function*(){const v={};if(a)return{tier:0,type:"SSR"};const{isIpad:m=!!(null==s?void 0:s.isIpad),isMobile:p=!!(null==s?void 0:s.isMobile),screenSize:g=window.screen,loadBenchmarks:b=(e=>o(void 0,void 0,void 0,(function*(){const t=yield fetch(`${f}/${e}`).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<4)throw new h("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:y}=n;const w=(e,t,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:p,tier:e,type:t});let C,k="";if(y)y=i(y),C=[y];else{const e=u||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==s?void 0:s.isSafari12,c);if(!e)return w(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(y=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!y)return w(1,"FALLBACK");k=y,y=i(y),C=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",u=(null==s?void 0:s.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 c;return"80162181255"===o?c=u.filter((([,,e])=>e>=14)):(c=u.filter((([,e])=>e===o)),c.length||(c=u)),c.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,y,p)}const P=(yield Promise.all(C.map((function(e){var t;return o(this,void 0,void 0,(function*(){const n=(e=>{const t=p?["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=`${p?"m":"d"}-${n}${m?"-ipad":""}.json`,r=v[o]=null!==(t=v[o])&&void 0!==t?t:b(o);let i;try{i=yield r}catch(n){if(n instanceof h)throw n;return}const a=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 s=i.filter((([,e])=>e===a));s.length||(s=i.filter((([t])=>t.includes(e))));const u=s.length;if(0===u)return;let c,[d,,,f]=u>1?s.map((t=>[t,l(e,t[0])])).sort((([,e],[,t])=>e-t))[0][0]:s[0],y=Number.MAX_VALUE;const{devicePixelRatio:w}=window,C=g.width*w*g.height*w;for(const e of f){const[t,n]=e,o=t*n,r=Math.abs(C-o);r<y&&(y=r,c=e)}if(!c)return;const[,,k,P]=c;return[y,k,d,P]}))})))).filter(d).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!P.length){const e=r.find((e=>y.includes(e)));return e?w(0,"BLOCKLISTED",e):w(1,"FALLBACK",`${y} (${k})`)}const[,E,W,M]=P[0];if(-1===E)return w(0,"BLOCKLISTED",W,E,M);const S=p?e:t;let x=0;for(let e=0;e<S.length;e++)E>=S[e]&&(x=e);return w(x,"BENCHMARK",W,E,M)}))},519:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});const o={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1}},946:(e,t,n)=>{"use strict";n.d(t,{d:()=>B});var o,r=n(354),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}(),a=n(388),s=function(){function e(e,t){var n=this;this.cameraMoveState={status:"inactive"},this.endInteractionDebounced=(0,a.Ds)((function(){"inactive"!==n.cameraMoveState.status&&("moving"===n.cameraMoveState.status&&n.onCameraMoveEnd(),n.setCameraMoveStatus("inactive"))}),100),this.onCameraMoveStart=e,this.onCameraMoveEnd=t}return e.prototype.dispose=function(){this.endInteractionDebounced.cancel(),this.cameraMoveState={status:"inactive"}},e.prototype.handleCameraMoveEvent=function(){var e;this.endInteractionDebounced(),"inactive"===this.cameraMoveState.status&&this.setCameraMoveStatus("uncertain"),"uncertain"===this.cameraMoveState.status&&(e=this.cameraMoveState,Date.now()-e.interactionStartTimestamp>=20)&&(this.onCameraMoveStart(),this.setCameraMoveStatus("moving"))},e.prototype.setCameraMoveStatus=function(e){this.cameraMoveState="uncertain"===e?{status:"uncertain",interactionStartTimestamp:Date.now()}:{status:e}},e}(),u=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),c=function(){return(c=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}).apply(this,arguments)},l=function(e){function t(t,n){var o=e.call(this)||this;return o.listenersCollector=new i,o.state={panning:!1,zooming:!1,pinchToZoomLastDistance:0,lastPan:{x:0,y:0},zoomCenter:{x:0,y:0},lastGestureScale:1,mouse:{x:0,y:0},isCameraLocked:!1,isWaitingForSecondClick:!1,lastMouseClickPosition:{x:0,y:0}},o.handleGestureStart=function(e){e.preventDefault(),o.state.isCameraLocked||(o.state.lastGestureScale=e.scale,o.emitZoomStartEvent())},o.handleGestureChange=function(e){if(e.preventDefault(),!o.state.isCameraLocked){o.state.zoomCenter=o.getCorrectPointerPosition(e);var t=e.scale/o.state.lastGestureScale;o.state.lastGestureScale=e.scale,o.emitZoomEvent(t,o.state.zoomCenter,!1),o.cameraMoveTracker.handleCameraMoveEvent()}},o.handleGestureEnd=function(e){e.preventDefault(),o.emitZoomEndEvent()},o.handlePointerDown=function(e){(e instanceof MouseEvent&&0===e.button||(0,a.z6)(e))&&(e.preventDefault(),o.updateMousePosition(e),o.handlePanStart(),o.handleTouchPinchToZoomStart(e),o.emit("mousedown"))},o.handlePanStart=function(){o.state.panning=!0,o.state.lastPan.x=o.state.mouse.x,o.state.lastPan.y=o.state.mouse.y},o.handleTouchPinchToZoomStart=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){o.emitZoomStartEvent();var n=e.touches[0],r=e.touches[1];o.state.pinchToZoomLastDistance=Math.hypot(n.clientX-r.clientX,n.clientY-r.clientY)}},o.handlePointerMove=function(e){(0,a.z6)(e)&&o.handleTouchPinchToZoomChange(e),o.state.panning||o.updateMousePosition(e)},o.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var n=e.touches[0],r=e.touches[1],i=Math.hypot(n.clientX-r.clientX,n.clientY-r.clientY),a=o.clampPointerToTargetBounds({x:(n.clientX+r.clientX)/2,y:(n.clientY+r.clientY)/2}),s=i/Math.max(o.state.pinchToZoomLastDistance,1);o.state.pinchToZoomLastDistance=i,o.emitZoomEvent(s,a,!1)}},o.handlePanMove=function(e){if(o.state.panning&&!o.state.isCameraLocked){var t=o.getCorrectPointerPosition(e),n=o.state.lastPan.x-t.x,r=o.state.lastPan.y-t.y;o.state.lastPan.x=t.x,o.state.lastPan.y=t.y,o.emit("panChange",-n,-r),o.cameraMoveTracker.handleCameraMoveEvent()}},o.handleDoubleClick=function(e){if(!("undefined"!=typeof TouchEvent&&e instanceof TouchEvent&&e.touches.length>0)){var t=o.getCorrectPointerPosition(e),n=Math.hypot(o.state.lastMouseClickPosition.x-t.x,o.state.lastMouseClickPosition.y-t.y)>("undefined"!=typeof TouchEvent&&e instanceof TouchEvent?15:0);if(!o.state.isWaitingForSecondClick||n)return o.state.isWaitingForSecondClick=!0,o.state.lastMouseClickPosition=o.getCorrectPointerPosition(e),void o.resetDoubleClick();o.state.isWaitingForSecondClick=!1,o.emit("doubleClick")}},o.resetDoubleClick=(0,a.Ds)((function(){o.state.isWaitingForSecondClick=!1}),500),o.handlePanEnd=function(){o.state.panning=!1},o.handlePointerUp=function(e){var t;o.handleTouchPinchToZoomEnd(e),(null===(t=e.touches)||void 0===t?void 0:t.length)>1||o.emit("mouseup")},o.handleTouchPinchToZoomEnd=function(e){var t;(null===(t=e.touches)||void 0===t?void 0:t.length)>2||o.emitZoomEndEvent()},o.handleMouseWheel=function(e){if(e.preventDefault(),!o.state.isCameraLocked){var t=e.metaKey||e.ctrlKey;if(o.updateMousePosition(e),t){var n=e.ctrlKey?-1:1;o.state.zoomCenter=o.getCorrectPointerPosition(e);var r=1+.01*e.deltaY*n;o.emitZoomEvent(r,o.state.zoomCenter)}else o.emit("panChange",-e.deltaX,-e.deltaY);o.cameraMoveTracker.handleCameraMoveEvent()}},o.emitZoomEndEvent=(0,a.Ds)((function(){o.state.zooming&&(o.state.zooming=!1,o.emit("zoomEnd"))}),90),o.handleCameraMoveStart=function(){o.emit("cameraMoveStart")},o.handleCameraMoveEnd=function(){o.emit("cameraMoveEnd")},o.target=t,o.settings=n,o.targetBounds=t.getBoundingClientRect(),o.addListeners(),o.cameraMoveTracker=new s(o.handleCameraMoveStart,o.handleCameraMoveEnd),o}return u(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addSafariGesturesEventListeners()},t.prototype.addMouseEventListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handlePointerDown),this.listenersCollector.add(this.target,"mousemove",this.handlePointerMove),this.listenersCollector.add(document,"mousemove",this.handlePanMove),this.listenersCollector.add(this.target,"mouseup",this.handlePointerUp),this.listenersCollector.add(document,"mouseup",this.handlePanEnd),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel),this.listenersCollector.add(this.target,"mouseup",this.handleDoubleClick)},t.prototype.addTouchEventListeners=function(){this.listenersCollector.add(this.target,"touchstart",this.handlePointerDown),this.listenersCollector.add(document,"touchmove",this.handlePanMove,{passive:!0}),this.listenersCollector.add(this.target,"touchmove",this.handlePointerMove,{passive:!0}),this.listenersCollector.add(this.target,"touchend",this.handlePointerUp),this.listenersCollector.add(this.target,"touchcancel",this.handlePointerUp),this.listenersCollector.add(document,"touchend",this.handlePanEnd),this.listenersCollector.add(this.target,"touchend",this.handleDoubleClick)},t.prototype.addSafariGesturesEventListeners=function(){(0,a.b1)()||(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:(0,a.uZ)(e.x-this.targetBounds.x,0,this.target.clientWidth),y:(0,a.uZ)(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=(0,a.MP)(e);return this.clampPointerToTargetBounds(n)},t.prototype.updateMousePosition=function(e){this.state.mouse=this.getCorrectPointerPosition(e),this.emit("mousemove",this.state.mouse.x,this.state.mouse.y)},t.prototype.emitZoomEvent=function(e,t,n){void 0===n&&(n=!0),n&&this.emitZoomStartEvent(),this.emit("zoomChange",e,t),n&&this.emitZoomEndEvent()},t.prototype.emitZoomStartEvent=function(){this.state.zooming||(this.state.zooming=!0,this.emit("zoomStart"))},t.prototype.getMouse=function(){return c({},this.state.mouse)},t.prototype.setMouse=function(e,t){this.state.mouse.x=e,this.state.mouse.y=t,this.emit("mousemove",this.state.mouse.x,this.state.mouse.y)},t.prototype.setIsCameraLocked=function(e){this.state.isCameraLocked=e},t.prototype.getMinZoomLevel=function(){return this.settings.minimumZoomLevel},t.prototype.getMaxZoomLevel=function(){return this.settings.maximumZoomLevel},t.prototype.dispose=function(){this.listenersCollector.dispose(),this.cameraMoveTracker.dispose()},t}(r.v),d=n(475),h=n(419);const f=Symbol("Comlink.proxy"),v=Symbol("Comlink.endpoint"),m=Symbol("Comlink.releaseProxy"),p=Symbol("Comlink.thrown"),g=e=>"object"==typeof e&&null!==e||"function"==typeof e,b=new Map([["proxy",{canHandle:e=>g(e)&&e[f],serialize(e){const{port1:t,port2:n}=new MessageChannel;return y(e,t),[n,[n]]},deserialize:e=>(e.start(),C(e))}],["throw",{canHandle:e=>g(e)&&p in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function y(e,t=self){t.addEventListener("message",(function n(o){if(!o||!o.data)return;const{id:r,type:i,path:a}=Object.assign({path:[]},o.data),s=(o.data.argumentList||[]).map(L);let u;try{const t=a.slice(0,-1).reduce(((e,t)=>e[t]),e),n=a.reduce(((e,t)=>e[t]),e);switch(i){case"GET":u=n;break;case"SET":t[a.slice(-1)[0]]=L(o.data.value),u=!0;break;case"APPLY":u=n.apply(t,s);break;case"CONSTRUCT":u=S(new n(...s));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;y(e,n),u=M(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(e){u={value:e,[p]:0}}Promise.resolve(u).catch((e=>({value:e,[p]:0}))).then((e=>{const[o,a]=x(e);t.postMessage(Object.assign(Object.assign({},o),{id:r}),a),"RELEASE"===i&&(t.removeEventListener("message",n),w(t))}))})),t.start&&t.start()}function w(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function C(e,t){return P(e,[],t)}function k(e){if(e)throw new Error("Proxy has been released and is not useable")}function P(e,t=[],n=function(){}){let o=!1;const r=new Proxy(n,{get(n,i){if(k(o),i===m)return()=>D(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{w(e),o=!0}));if("then"===i){if(0===t.length)return{then:()=>r};const n=D(e,{type:"GET",path:t.map((e=>e.toString()))}).then(L);return n.then.bind(n)}return P(e,[...t,i])},set(n,r,i){k(o);const[a,s]=x(i);return D(e,{type:"SET",path:[...t,r].map((e=>e.toString())),value:a},s).then(L)},apply(n,r,i){k(o);const a=t[t.length-1];if(a===v)return D(e,{type:"ENDPOINT"}).then(L);if("bind"===a)return P(e,t.slice(0,-1));const[s,u]=E(i);return D(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:s},u).then(L)},construct(n,r){k(o);const[i,a]=E(r);return D(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:i},a).then(L)}});return r}function E(e){const t=e.map(x);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const W=new WeakMap;function M(e,t){return W.set(e,t),e}function S(e){return Object.assign(e,{[f]:!0})}function x(e){for(const[t,n]of b)if(n.canHandle(e)){const[o,r]=n.serialize(e);return[{type:"HANDLER",name:t,value:o},r]}return[{type:"RAW",value:e},W.get(e)||[]]}function L(e){switch(e.type){case"HANDLER":return b.get(e.name).deserialize(e.value);case"RAW":return e.value}}function D(e,t,n){return new Promise((o=>{const r=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===r&&(e.removeEventListener("message",t),o(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:r},t),n)}))}var Z,R=n(849),T=n(519),O=n(332),z=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),A=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 z(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(r.v),_=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),I=function(){return(I=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}).apply(this,arguments)},F=function(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())}))},G=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},j=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o};!function(e){e[e.browser=0]="browser",e[e.worker=1]="worker"}(Z||(Z={}));var B=function(e){function t(t){var n,o=e.call(this)||this;o.listenersCollector=new i,o.handleZoomStart=function(){o.emit("zoomStart")},o.handleZoomEnd=function(){o.emit("zoomEnd")},o.handleCameraMoveStart=function(){var e;null===(e=o.sketchWeb)||void 0===e||e.setIsCameraMoving(!0)},o.handleCameraMoveEnd=function(){var e;null===(e=o.sketchWeb)||void 0===e||e.setIsCameraMoving(!1)},o.handleMouseChange=function(e,t){var n;null===(n=o.sketchWeb)||void 0===n||n.setMouse(e,t)},o.handlePanChange=function(e,t){return F(o,void 0,void 0,(function(){var n;return G(this,(function(o){return null===(n=this.sketchWeb)||void 0===n||n.addPan(e,t),this.emitPanEvent(),[2]}))}))},o.handleZoomChange=function(e,t){return F(o,void 0,void 0,(function(){var n;return G(this,(function(o){return null===(n=this.sketchWeb)||void 0===n||n.addZoom(e,t),this.emitZoomEvent(),this.emitPanEvent(),[2]}))}))},o.handleCanvasResizeObserver=function(e){o.resizeCanvas(e[0].contentRect)},o.resizeCanvas=function(e){var t=e.width,n=e.height;window.requestAnimationFrame((function(){var e;o.setCanvasSize(t,n),o.gestureManager.updateTargetBounds(),null===(e=o.sketchWeb)||void 0===e||e.setSize(t,n,o.getDevicePixelRatio())}))};var r=null!==(n=t.featureFlags)&&void 0!==n?n:{};return o.featureFlags=I(I({},T.Z),r),o.settings=t,o.canvas=t.canvas,o.gestureManager=new l(o.settings.container,{minimumZoomLevel:t.minimumZoomLevel,maximumZoomLevel:t.maximumZoomLevel}),o.keyboardManager=new A(document.body),R.Z.active=t.mode===O.p.debug,o.init(),o}return _(t,e),t.prototype.init=function(){var e;return F(this,void 0,void 0,(function(){var t,n,o;return G(this,(function(r){switch(r.label){case 0:return this.setCanvasSize(this.settings.container.clientWidth,this.settings.container.clientHeight),[4,this.initSketchWeb()];case 1:return r.sent(),[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getStatus()];case 2:return"FILE_READY"!==(null==(t=r.sent())?void 0:t.type)?[2]:(n=void 0!==this.settings.initialZoom,o=void 0!==this.settings.initialPan,n||o?n?[4,this.setZoom(this.settings.initialZoom)]:[3,4]:[3,7]);case 3:r.sent(),r.label=4;case 4:return o?[4,this.setPan(this.settings.initialPan.x,this.settings.initialPan.y,this.settings.initialPan.centerPointInViewport)]:[3,6];case 5:r.sent(),r.label=6;case 6:return[3,9];case 7:return[4,this.zoomToFit()];case 8:r.sent(),r.label=9;case 9:return this.sketchWeb.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initSketchWeb=function(){return F(this,void 0,void 0,(function(){var e,t,o,r,i;return G(this,(function(a){switch(a.label){case 0:return e=this.featureFlags.offscreenCanvas&&"function"==typeof this.canvas.transferControlToOffscreen,t=I(I({},this.settings),{size:{width:this.canvas.width,height:this.canvas.height},pixelRatio:this.getDevicePixelRatio(),featureFlags:this.featureFlags}),e?(this.environment=Z.worker,R.Z.debug("Using offscreen canvas"),this.offscreenCanvas=this.canvas.transferControlToOffscreen(),this.worker=new Worker(new URL(n.p+n.u(667),n.b),{type:void 0}),o=C(this.worker),r=this,[4,new o(M(I(I({},t),{canvas:this.offscreenCanvas}),[this.offscreenCanvas]))]):[3,2];case 1:return r.sketchWeb=a.sent(),[3,3];case 2:this.environment=Z.browser,R.Z.debug("Using normal canvas"),this.sketchWeb=new d.U(t),a.label=3;case 3:return(i=this.sketchWeb).on("status",this.forwardEvent("status")),i.on("fileReady",this.forwardEvent("fileReady")),i.on("metric",this.forwardEvent("metric")),i.on("warnings",this.forwardEvent("warnings")),i.on("allImagesReady",this.forwardEvent("allImagesReady")),i.on("deviceInfo",this.forwardEvent("deviceInfo")),[4,this.sketchWeb.init()];case 4:return a.sent(),[2]}}))}))},t.prototype.forwardEvent=function(e){var t=this,n=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];t.emit.apply(t,j([e],n))};return this.environment===Z.worker?S(n):n},t.prototype.isRunningInsideWorker=function(){return this.environment===Z.worker},t.prototype.looseWebGLContext=function(){var e;null===(e=this.sketchWeb)||void 0===e||e.looseWebGLContext()},t.prototype.addListeners=function(){this.canvasResizeObserver=new ResizeObserver(this.handleCanvasResizeObserver),this.canvasResizeObserver.observe(this.settings.container),this.listenersCollector.add(window,"orientationchange",this.handleDeviceOrientationChange),this.gestureManager.on("panChange",this.handlePanChange),this.gestureManager.on("mousemove",this.handleMouseChange),this.gestureManager.on("zoomChange",this.handleZoomChange),this.gestureManager.on("zoomStart",this.handleZoomStart),this.gestureManager.on("zoomEnd",this.handleZoomEnd),this.gestureManager.on("cameraMoveStart",this.handleCameraMoveStart),this.gestureManager.on("cameraMoveEnd",this.handleCameraMoveEnd)},t.prototype.emitPanEvent=function(){var e;return F(this,void 0,void 0,(function(){var t;return G(this,(function(n){switch(n.label){case 0:return[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getPan()];case 1:return(t=n.sent())?(this.emit("pan",t.x,t.y),[2]):[2]}}))}))},t.prototype.emitZoomEvent=function(){var e;return F(this,void 0,void 0,(function(){var t;return G(this,(function(n){switch(n.label){case 0:return[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getZoom()];case 1:return void 0===(t=n.sent())||this.emit("zoom",t),[2]}}))}))},t.prototype.getDevicePixelRatio=function(){return(0,h.uZ)(window.devicePixelRatio,1,2)},t.prototype.setCanvasSize=function(e,t){this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this.canvas.width=e*this.getDevicePixelRatio(),this.canvas.height=t*this.getDevicePixelRatio()},t.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.settings.container.clientWidth,height:this.settings.container.clientHeight})},t.prototype.setBackgroundColor=function(e){var t;null===(t=this.sketchWeb)||void 0===t||t.setBackgroundColor(e)},t.prototype.zoomToFit=function(){return F(this,void 0,void 0,(function(){return G(this,(function(e){switch(e.label){case 0:return[4,this.sketchWeb.scaleDocumentToFit()];case 1:return e.sent(),this.emitZoomEvent(),this.emitPanEvent(),[2]}}))}))},t.prototype.getStatus=function(){var e;return F(this,void 0,void 0,(function(){return G(this,(function(t){return[2,null===(e=this.sketchWeb)||void 0===e?void 0:e.getStatus()]}))}))},t.prototype.generateDocumentPNG=function(){var e;return F(this,void 0,void 0,(function(){return G(this,(function(t){return[2,null===(e=this.sketchWeb)||void 0===e?void 0:e.generateDocumentPNG()]}))}))},t.prototype.getDocument=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getDocument()},t.prototype.getArtboardAtPosition=function(e,t){var n;return F(this,void 0,void 0,(function(){return G(this,(function(o){switch(o.label){case 0:return[4,null===(n=this.sketchWeb)||void 0===n?void 0:n.getArtboardAtPosition(e,t)];case 1:return[2,o.sent()||null]}}))}))},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWeb)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.setPan=function(e,t,n){var o;return F(this,void 0,void 0,(function(){return G(this,(function(r){switch(r.label){case 0:return[4,null===(o=this.sketchWeb)||void 0===o?void 0:o.setPan(e,t,Boolean(n))];case 1:return r.sent(),this.emitPanEvent(),[2]}}))}))},t.prototype.setZoom=function(e,t){var n;return F(this,void 0,void 0,(function(){var o;return G(this,(function(r){return o=null!=t?t:this.getCanvasCenterPoint(),null===(n=this.sketchWeb)||void 0===n||n.setZoom(e,o),this.emitZoomEvent(),this.emitPanEvent(),[2]}))}))},t.prototype.getCanvasCenterPoint=function(){var e=this.canvas.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getZoom()},t.prototype.getPan=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getPan()},t.prototype.dispose=function(){var e,t,n,o;return F(this,void 0,void 0,(function(){return G(this,(function(r){switch(r.label){case 0:return this.gestureManager.dispose(),this.keyboardManager.dispose(),this.listenersCollector.dispose(),null===(e=this.canvasResizeObserver)||void 0===e||e.disconnect(),this.isRunningInsideWorker()?[4,null===(t=this.sketchWeb)||void 0===t?void 0:t.dispose()]:[3,2];case 1:return r.sent(),null===(n=this.worker)||void 0===n||n.terminate(),[3,3];case 2:null===(o=this.sketchWeb)||void 0===o||o.dispose(),r.label=3;case 3:return[2]}}))}))},t}(r.v)},475:(e,t,n)=>{"use strict";n.d(t,{U:()=>p});var o,r=n(419),i=n(519),a=n(354),s=n(108),u=n(849),c=n(758),l=n(332),d=n(975),h=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=function(){return(f=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}).apply(this,arguments)},v=function(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())}))},m=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},p=(globalThis.indexedDB,function(e){function t(t){var n=t.canvas,o=t.locateFile,a=t.filePath,c=t.imagesURLFormat,d=t.imagesURLMap,h=t.backgroundColor,v=void 0===h?{r:1,g:1,b:1,a:1}:h,m=t.size,p=t.pixelRatio,g=t.mode,b=t.showTilesBorders,y=void 0!==b&&b,w=t.minimumZoomLevel,C=t.maximumZoomLevel,k=t.preserveDrawingBuffer,P=void 0!==k&&k,E=t.panBoundariesPadding,W=void 0===E?40:E,M=t.featureFlags,S=void 0===M?{}:M,x=e.call(this)||this;return x.status={type:"INIT"},x.isZooming=!1,x.handleWebGLContextLost=function(){x.setStatus({type:"WEBGL_CONTEXT_LOST"})},x.debouncedFullDraw=(0,r.Ds)((function(){return x.draw(!0)}),60),x.notifyZoomDidEndDebounced=(0,r.Ds)((function(){var e;x.isZooming&&(x.isZooming=!1,null===(e=x.sketchWebWasm)||void 0===e||e.setIsZooming(!1),x.delayedDraw())}),80),x.canvas=n,x.locateFile=o,x.filePath=a,x.imagesURLFormat=c,x.imagesURLMap=d,x.backgroundColor=v,x.size=m,x.pixelRatio=p,x.mode=g,x.showTilesBorders=y,x.currentWebGLVersion=(0,r.wX)(),x.zoomLevels={min:w,max:C},x.preserveDrawingBuffer=P,x.panBoundariesPadding=W,x.featureFlags=f(f({},i.Z),S),u.Z.active=g===l.p.debug,x.traceFirstPaint=new s.S("FirstPaint"),x}return h(t,e),t.prototype.collectAndEmitDeviceInfo=function(){return v(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:return[4,(0,d.M)()];case 1:return e=t.sent(),this.deviceInfo=f(f({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){return v(this,void 0,void 0,(function(){var e;return m(this,(function(t){switch(t.label){case 0:this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),t.label=1;case 1:return t.trys.push([1,5,,6]),[4,this.initSketchWebWasm()];case 2:return t.sent(),[4,this.setFile(this.filePath)];case 3:return t.sent(),[4,this.preloadImages()];case 4:return t.sent(),[3,6];case 5:return e=t.sent(),[2,this.fail(e instanceof c.k?e:new c.k("ERROR","Unexpected exception initializing the web renderer",e))];case 6:return[2]}}))}))},t.prototype.preloadImages=function(){var e=this;return new Promise((function(t){var n;null===(n=e.sketchWebWasm)||void 0===n||n.preloadImages((function(){t()}))}))},t.prototype.startRendering=function(){this.traceInitialRender=new s.S("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),this.draw(!0,!1),this.sketchWebWasm.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){u.Z.debug("[C++] "+e)},logWarning:function(e){u.Z.warning("[C++] "+e)},logError:function(e){u.Z.error("[C++] "+e)},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.imagesURLFormat?e.imagesURLFormat.replace(":imageId",t):e.imagesURLMap&&e.imagesURLMap[t]?e.imagesURLMap[t]:(u.Z.warning("Not able to resolve the url for the image with UUID: "+t),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n,o=new s.S("ImagesDownload");null===(n=e.sketchWebWasm)||void 0===n||n.downloadImages((function(){o.printMeasurement(),e.emit("metric",o.measure()),u.Z.debug("Images downloaded"),t()}))}))},t.prototype.initSketchWebWasm=function(){return v(this,void 0,void 0,(function(){var e,t,o,r,i,a,d,h=this;return m(this,(function(f){switch(f.label){case 0:return e=new s.S("WasmModuleDownload"),this.mode!==l.p.debug?[3,2]:[4,n.e(706).then(n.t.bind(n,706,23))];case 1:return t=f.sent(),[3,4];case 2:return[4,n.e(610).then(n.t.bind(n,610,23))];case 3:t=f.sent(),f.label=4;case 4:o=t.default,f.label=5;case 5:return f.trys.push([5,7,,8]),r=this,[4,o({FeatureFlags:this.featureFlags,currentWebGLVersion:this.currentWebGLVersion,locateFile:function(e){return h.locateFile.replace("{file}",e)},bridge:this.createJSBridge()})];case 6:return r.wasmModule=f.sent(),[3,8];case 7:throw i=f.sent(),new c.k("WASM_ERROR","An error occurred while trying to create the wasm module.",i);case 8:if(e.printMeasurement(),this.emit("metric",e.measure()),a={majorVersion:this.currentWebGLVersion,antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:this.preserveDrawingBuffer},u.Z.debug("Using WebGL "+a.majorVersion),!(d=this.wasmModule.GL.createContext(this.canvas,a)))throw new c.k("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");this.webglCtxHandle=d;try{this.sketchWebWasm=this.wasmModule.SketchWeb.MakeGL(this.webglCtxHandle,this.canvas.width,this.size.height,this.pixelRatio,{showTilesBorders:this.showTilesBorders})}catch(e){throw new c.k("WASM_ERROR","An error occurred while trying to create the SketchWebWasm object.",e)}return this.sketchWebWasm.setBackgroundColor(this.backgroundColor.r,this.backgroundColor.g,this.backgroundColor.b,this.backgroundColor.a),this.sketchWebWasm.setZoomLevels(this.zoomLevels.min,this.zoomLevels.max),this.sketchWebWasm.setPanBoundariesPadding(this.panBoundariesPadding),this.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost),[2]}}))}))},t.prototype.setBackgroundColor=function(e){var t;e.r===this.backgroundColor.r&&e.g===this.backgroundColor.g&&e.b===this.backgroundColor.b&&e.a===this.backgroundColor.a||(null===(t=this.sketchWebWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.backgroundColor=e,this.delayedDraw())},t.prototype.generateDocumentPNG=function(){return v(this,void 0,void 0,(function(){return m(this,(function(e){switch(e.label){case 0:return[4,this.downloadImages()];case 1:return e.sent(),[2,this.sketchWebWasm.generateDocumentPNG()]}}))}))},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=this.wasmModule.GL.getContext(this.webglCtxHandle);if(e){var t=e.GLctx.getExtension("WEBGL_lose_context");t?t.loseContext():console.warn("Unable to retrieve WEBGL_lose_context extension")}else console.warn("Unable to loose context. WebGL rendering context not found")},t.prototype.scaleDocumentToFit=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.scaleDocumentToFit(),this.delayedDraw()},t.prototype.setFile=function(e){return v(this,void 0,void 0,(function(){var t=this;return m(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){t.sketchWebWasm.setFile(e,(function(e,o,r,i){if(void 0===i&&(i=[]),i.length){u.Z.debug("Parser warnings: "+i);var a=i.map((function(e){return{key:e}}));t.emit("warnings",a)}t.setStatus({type:"FILE_READY"}),t.emit("fileReady",t.getDocument(),e,o,r),n()}),(function(){return o(new c.k("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.delayedDraw=function(){if(!this.featureFlags.delayedDraw)return this.draw(!0);this.draw(),this.debouncedFullDraw()},t.prototype.draw=function(e,t){var n;void 0===e&&(e=!1),void 0===t&&(t=!1),null===(n=this.sketchWebWasm)||void 0===n||n.setNeedsUpdate(e,t)},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:e.toString()+(e.cause?"\nWrapped Error: "+e.cause.toString():"")}),u.Z.error(e),e.cause&&u.Z.error(e.cause)},t.prototype.setPixelRatio=function(e){this.pixelRatio=e,this.setSize(this.size.width*this.pixelRatio,this.size.height*this.pixelRatio,this.pixelRatio),this.delayedDraw()},t.prototype.setSize=function(e,t,n){var o;this.size.width=e*n,this.size.height=t*n,this.canvas.width=e*n,this.canvas.height=t*n,null===(o=this.sketchWebWasm)||void 0===o||o.resize(e,t,n)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(u.Z.debug("Status transition "+this.status.type+" => "+e.type+"}"),this.status=e,this.emit("status",e))},t.prototype.getDocument=function(){if(!this.sketchWebWasm)return null;if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.filePath){var e=this.sketchWebWasm.getPRFile();this.cachedDocumentInfo={filePath:this.filePath,document:f(f({},e),{artboards:(0,r.gi)(e.artboards)})}}return this.cachedDocumentInfo.document},t.prototype.getArtboardAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getArtboardAtPosition(e,t)},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,o;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(o=this.sketchWebWasm)||void 0===o||o.setZoom(e),this.delayedDraw()},t.prototype.addZoom=function(e,t){var n,o;this.notifyZoomDidStart(),null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(o=this.sketchWebWasm)||void 0===o||o.addZoom(e),this.notifyZoomDidEndDebounced(),this.delayedDraw()},t.prototype.notifyZoomDidStart=function(){var e;this.isZooming||(this.isZooming=!0,null===(e=this.sketchWebWasm)||void 0===e||e.setIsZooming(!0))},t.prototype.setPan=function(e,t,n){var o;void 0===n&&(n=!1),null===(o=this.sketchWebWasm)||void 0===o||o.setPan(e,t,n),this.delayedDraw()},t.prototype.addPan=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.addPan(e,t),this.delayedDraw()},t.prototype.getPan=function(){if(this.sketchWebWasm)return this.sketchWebWasm.getPan()},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWebWasm)||void 0===e?void 0:e.getZoom()},t.prototype.setMouse=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.setMouse(e,t)},t.prototype.setIsCameraMoving=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.setIsCameraMoving(e)},t.prototype.dispose=function(){var e,t;try{null===(e=this.sketchWebWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.sketchWebWasm)||void 0===t||t.delete(),this.looseWebGLContext(),this.sketchWebWasm=null,this.wasmModule=null}catch(e){this.fail(new c.k("ERROR","Unexpected exception while disposing the SketchWebWasm object",e))}},t}(a.v))},536:(e,t,n)=>{"use strict";n.d(t,{z0:()=>V,oW:()=>B,jr:()=>P,tm:()=>D,ky:()=>w,zX:()=>I,ex:()=>O,Jw:()=>z,m_:()=>A,Yy:()=>L,d6:()=>W,aP:()=>E,EY:()=>_,pt:()=>T,od:()=>k,ph:()=>Z,lt:()=>x,$z:()=>y,BO:()=>C,us:()=>R});var o,r=n(297),i=n.n(r),a=n(332),s=n(849),u=(0,r.createContext)(void 0),c=function(){var e=(0,r.useContext)(u);if(void 0===e)throw Error("useSketchWebInternalContext must be used within a SketchWebProvider");return e},l=(n(419),function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o}),d=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.Z.debug.apply(s.Z,l(["SketchWebReact"],e))},h=(0,r.createContext)(void 0),f=(0,r.createContext)(void 0),v=(0,r.createContext)(void 0),m=(0,r.createContext)(void 0),p=(0,r.createContext)(void 0),g=(0,r.createContext)(void 0),b=(0,r.createContext)(void 0),y=function(){var e=(0,r.useContext)(h);if(void 0===e)throw Error("useStatus must be used within a SketchWebProvider");return e},w=function(){var e=(0,r.useContext)(f);if(void 0===e)throw Error("useDocument must be used within a SketchWebProvider");return e},C=function(){var e=(0,r.useContext)(v);if(void 0===e)throw Error("useZoom must be used within a SketchWebProvider");return e},k=function(){var e=(0,r.useContext)(g);if(void 0===e)throw Error("usePan must be used within a SketchWebProvider");return e},P=function(){var e=(0,r.useContext)(b);if(void 0===e)throw Error("useCursor must be used within a SketchWebProvider");return e},E=function(){var e=(0,r.useContext)(m);if(void 0===status)throw Error("useIsCameraZooming must be used within a SketchWebProvider");return e},W=function(){var e=(0,r.useContext)(p);if(void 0===status)throw Error("useIsCameraMoving must be used within a SketchWebProvider");return e},M=function(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())}))},S=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},x=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t){d("setZoom",t),null==e||e.setZoom(t)}),[e])},L=function(){var e=x(),t=C();return(0,r.useCallback)((function(){var n;d("incrementZoom"),"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},D=function(){var e=x(),t=C();return(0,r.useCallback)((function(){d("decrementZoom"),"number"==typeof t&&e(t/2)}),[e,t])},Z=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;d("setPan",n,o,"centerPointInViewport",r),null==e||e.setPan(n,o,r)}),[e])},R=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(){d("zoomToFit"),null==e||e.zoomToFit()}),[e])},T=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(){d("looseWebGLContext"),null==e||e.looseWebGLContext()}),[e])},O=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(){return M(void 0,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return d("generateDocumentPNG"),[4,null==e?void 0:e.generateDocumentPNG()];case 1:return[2,t.sent()]}}))}))}),[e])},z=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t,n){return M(void 0,void 0,void 0,(function(){return S(this,(function(o){switch(o.label){case 0:return d("getArtboardAtPosition",t,n),[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},A=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t,n){return M(void 0,void 0,void 0,(function(){return S(this,(function(o){switch(o.label){case 0:return d("getPanAtPosition",t,n),[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},_=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t){d("setIsCameraLocked",t),null==e||e.gestureManager.setIsCameraLocked(t)}),[e])},I=function(e,t){var n=(0,c().getManager)();(0,r.useEffect)((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},F=function(){return(F=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}).apply(this,arguments)},G={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},j={position:"absolute",top:0,left:0},B=function(e){s.Z.active=e.mode===a.p.debug;var t=e.filePath,n=e.locateFile,o=e.imagesURLFormat,u=e.imagesURLMap,l=e.backgroundColor,d=e.mode,h=e.showTilesBorders,f=e.minimumZoomLevel,v=e.maximumZoomLevel,m=e.preserveDrawingBuffer,p=e.panBoundariesPadding,g=e.initialPan,b=e.initialZoom,w=e.children,C=e.containerProps,k=void 0===C?{}:C,E=e.canvasProps,W=void 0===E?{}:E,M=e.featureFlags,S=void 0===M?{}:M,x=(0,r.useRef)(null),L=(0,r.useRef)(null),D=(0,r.useState)(!1),Z=D[0],R=D[1],T=(0,r.useCallback)((function(){return R(!0)}),[]),O=c(),z=O.dispose,A=O.init,_=O.setSettings,B=P(),U=y();I("allImagesReady",T),(0,r.useEffect)((function(){_({locateFile:n,imagesURLFormat:o,imagesURLMap:u,backgroundColor:l,mode:d,showTilesBorders:h,minimumZoomLevel:f,maximumZoomLevel:v,preserveDrawingBuffer:m,panBoundariesPadding:p,initialPan:g,initialZoom:b,featureFlags:S})}),[_,n,o,u,l,d,h,f,v,m,p,g,b,S]),(0,r.useEffect)((function(){if(t)return A(t,x.current,L.current),function(){z()}}),[z,A,t]);var N=(0,r.useMemo)((function(){var t;return null!==(t=e.cursor)&&void 0!==t?t:B}),[e.cursor,B]),X=(0,r.useMemo)((function(){return F(F({},G),{cursor:N})}),[N]);return i().createElement("div",F({},k,{ref:L,style:X}),t&&i().createElement("canvas",F({},W,{key:t,ref:x,"data-sketchweb-all-images-ready":Z,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-"+((null==U?void 0:U.type.toLowerCase())||"null"),style:j})),"READY"===(null==U?void 0:U.type)&&w)},U=n(946);!function(e){e.Draggable="grab",e.Dragging="grabbing",e.Hover="pointer",e.Default="auto"}(o||(o={}));var N=function(){return(N=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}).apply(this,arguments)},X=function(e,t){switch(d('dispatched: "'+t.type+'"',t),t.type){case"on-status":return N(N({},e),{status:t.status});case"on-file-ready":return N(N({},e),{document:t.document});case"on-zoom":return N(N({},e),{zoom:t.zoom});case"on-pan":return N(N({},e),{pan:t.pan});case"dispose":return N(N({},e),{status:null,zoom:null,pan:null,cursor:o.Default});case"post-init":return N(N({},e),{status:t.status,zoom:t.zoom});case"on-camera-zoom-start":return N(N({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return N(N({},e),{isCameraZooming:!1});case"on-camera-move-start":return N(N({},e),{cursor:e.isMouseDown?o.Dragging:o.Draggable,isCameraMoving:!0});case"on-camera-move-end":return N(N({},e),{isCameraMoving:!1});case"on-mouse-down":return N(N({},e),{cursor:o.Dragging,isMouseDown:!0});case"on-mouse-up":return N(N({},e),{cursor:o.Draggable,isMouseDown:!1});default:return e}},Y=function(){return(Y=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}).apply(this,arguments)},V=function(e){var t=e.children,n=(0,r.useRef)(null),a=(0,r.useRef)(null),s=(0,r.useReducer)(X,{pan:null,zoom:null,status:null,document:null,isCameraZooming:!1,isCameraMoving:!1,cursor:o.Default,isMouseDown:!1}),c=s[0],l=c.status,y=c.document,w=c.zoom,C=c.pan,k=c.isCameraZooming,P=c.isCameraMoving,E=c.cursor,W=s[1],M=(0,r.useCallback)((function(e){return W({type:"on-zoom",zoom:e})}),[]),S=(0,r.useCallback)((function(e,t){return W({type:"on-pan",pan:{x:e,y:t}})}),[]),x=(0,r.useCallback)((function(e){W({type:"on-status",status:e})}),[]),L=(0,r.useCallback)((function(e){W({type:"on-file-ready",document:e})}),[]),D=(0,r.useCallback)((function(){return W({type:"on-mouse-down"})}),[]),Z=(0,r.useCallback)((function(){return W({type:"on-mouse-up"})}),[]),R=(0,r.useCallback)((function(){return W({type:"on-camera-zoom-start"})}),[]),T=(0,r.useCallback)((function(){return W({type:"on-camera-zoom-end"})}),[]),O=(0,r.useCallback)((function(){return W({type:"on-camera-move-start"})}),[]),z=(0,r.useCallback)((function(){return W({type:"on-camera-move-end"})}),[]),A=(0,r.useCallback)((function(){var e=n.current;e&&(d("dispose"),e.off("status",x),e.off("fileReady",L),e.off("zoom",M),e.off("pan",S),e.gestureManager.off("mousedown",D),e.gestureManager.off("mouseup",Z),e.gestureManager.off("zoomStart",R),e.gestureManager.off("zoomEnd",T),e.gestureManager.off("cameraMoveStart",O),e.gestureManager.off("cameraMoveEnd",z),e.dispose(),n.current=null,W({type:"dispose"}))}),[x,L,S,M,Z,D,R,T,O,z]),_=(0,r.useCallback)((function(e,t,o){if(""!==e&&t&&o&&a.current){d("init");var r=new U.d(Y(Y({},a.current),{filePath:e,container:o,canvas:t}));r.on("status",x),r.on("fileReady",L),r.on("zoom",M),r.on("pan",S),r.gestureManager.on("mousedown",D),r.gestureManager.on("mouseup",Z),r.gestureManager.on("zoomStart",R),r.gestureManager.on("zoomEnd",T),r.gestureManager.on("cameraMoveStart",O),r.gestureManager.on("cameraMoveEnd",z),i=void 0,s=void 0,c=function(){var e,t;return function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(n){switch(n.label){case 0:return e=W,t={type:"post-init"},[4,r.getZoom()];case 1:return t.zoom=n.sent()||null,[4,r.getStatus()];case 2:return t.status=n.sent()||null,[4,r.getPan()];case 3:return e.apply(void 0,[(t.pan=n.sent()||null,t)]),[2]}}))},new((u=void 0)||(u=Promise))((function(e,t){function n(e){try{r(c.next(e))}catch(e){t(e)}}function o(e){try{r(c.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):(r=t.value,r instanceof u?r:new u((function(e){e(r)}))).then(n,o)}r((c=c.apply(i,s||[])).next())})),n.current=r}var i,s,u,c}),[x,L,M,S,D,Z,R,T,O,z]),I=(0,r.useCallback)((function(e){var t;d("setSettings",e),e.backgroundColor&&(null===(t=n.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),a.current=e}),[]),F=(0,r.useCallback)((function(){return n.current}),[]),G=(0,r.useMemo)((function(){return{dispose:A,init:_,setSettings:I,getManager:F,dispatch:W}}),[A,_,I,F]);return i().createElement(u.Provider,{value:G},i().createElement(h.Provider,{value:l},i().createElement(f.Provider,{value:y},i().createElement(v.Provider,{value:w},i().createElement(g.Provider,{value:C},i().createElement(m.Provider,{value:k},i().createElement(p.Provider,{value:P},i().createElement(b.Provider,{value:E},t))))))))}},758:(e,t,n)=>{"use strict";n.d(t,{k:()=>i});var o,r=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=function(e){function t(n,o,r){var i=this.constructor,a=e.call(this,"("+n+") "+o)||this;return a.code=n,a.cause=r,a.name=t.name,Object.setPrototypeOf(a,i.prototype),a}return r(t,e),t}(Error)},18:()=>{},689:()=>{},332:(e,t,n)=>{"use strict";var o;n.d(t,{p:()=>o}),function(e){e.debug="debug",e.release="release"}(o||(o={}))},119:()=>{},650:()=>{},312:()=>{},552:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var o=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.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}()},354:(e,t,n)=>{"use strict";n.d(t,{v:()=>o.v});var o=n(552)},849:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var o=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o};const r=new(function(){function e(){this.active=!0}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.debug.apply(console,o(["[SketchWeb] [Debug]"],e))},e.prototype.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.warn.apply(console,o(["[SketchWeb] [Warn]"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,o(["[SketchWeb] [Error]"],e))},e}())},108:(e,t,n)=>{"use strict";n.d(t,{S:()=>r});var o=n(849),r=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now(),o.Z.debug("[Performance] Start: "+this.label)}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);o.Z.debug("[Performance] End: "+this.label+" -> "+t+" ms")}else{var n=(e/1e3).toFixed(2);o.Z.debug("[Performance] End: "+this.label+" -> "+n+" s")}},e}()},419:(e,t,n)=>{"use strict";n.d(t,{uZ:()=>o.uZ,gi:()=>o.gi,Ds:()=>o.Ds,wX:()=>o.wX});var o=n(388)},388:(e,t,n)=>{"use strict";n.d(t,{Ds:()=>i,MP:()=>a,uZ:()=>s,wX:()=>u,gi:()=>c,b1:()=>l,z6:()=>d});var o=n(519),r=n(66);function i(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,s,u;return{x:null!==(r=null!==(t=e.pageX)&&void 0!==t?t:null===(o=null===(n=e.touches)||void 0===n?void 0:n[0])||void 0===o?void 0:o.pageX)&&void 0!==r?r:e.clientX,y:null!==(u=null!==(i=e.pageY)&&void 0!==i?i:null===(s=null===(a=e.touches)||void 0===a?void 0:a[0])||void 0===s?void 0:s.pageY)&&void 0!==u?u:e.clientY}}function s(e,t,n){return Math.max(t,Math.min(n,e))}function u(){return(0,r.t)()&&!o.Z.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function c(e){for(var t=e.size(),n=[],o=0;o<t;++o){var r=e.get(o);n.push(r)}return n}function l(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function d(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent||void 0!==e.touches||void 0!==e.targetTouches||void 0!==e.changedTouches}},66:(e,t,n)=>{"use strict";n.d(t,{t:()=>r});var o=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,r=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(o);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}}}},297:t=>{"use strict";t.exports=e}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.m=i,s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,o){if(1&o&&(e=this(e)),8&o)return e;if("object"==typeof e&&e){if(4&o&&e.__esModule)return e;if(16&o&&"function"==typeof e.then)return e}var r=Object.create(null);s.r(r);var i={};t=t||[null,n({}),n([]),n(n)];for(var a=2&o&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((t=>i[t]=()=>e[t]));return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,n)=>(s.f[n](e,t),t)),[])),s.u=e=>"static/js/web-renderer-"+{610:"17fd55cdb979ed59dbc9",667:"bc8f1d99872a3ed28cf9",706:"b584c7152f956c9cbea5"}[e]+".chunk.js",s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},r="@sketch-hq/sketch-web-renderer:",s.l=(e,t,n,i)=>{if(o[e])o[e].push(t);else{var a,u;if(void 0!==n)for(var c=document.getElementsByTagName("script"),l=0;l<c.length;l++){var d=c[l];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==r+n){a=d;break}}a||(u=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",r+n),a.src=e),o[e]=[t];var h=(t,n)=>{a.onerror=a.onload=null,clearTimeout(f);var r=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((e=>e(n))),t)return t(n)},f=setTimeout(h.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=h.bind(null,a.onerror),a.onload=h.bind(null,a.onload),u&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.p="/",(()=>{s.b=document.baseURI||self.location.href;var e={826:0};s.f.j=(t,n)=>{var o=s.o(e,t)?e[t]:void 0;if(0!==o)if(o)n.push(o[2]);else{var r=new Promise(((n,r)=>o=e[t]=[n,r]));n.push(o[2]=r);var i=s.p+s.u(t),a=new Error;s.l(i,(n=>{if(s.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var r=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,o[1](a)}}),"chunk-"+t,t)}};var t=(t,n)=>{var o,r,[i,a,u]=n,c=0;if(i.some((t=>0!==e[t]))){for(o in a)s.o(a,o)&&(s.m[o]=a[o]);u&&u(s)}for(t&&t(n);c<i.length;c++)r=i[c],s.o(e,r)&&e[r]&&e[r][0](),e[i[c]]=0},n=self.webpackChunk_sketch_hq_sketch_web_renderer=self.webpackChunk_sketch_hq_sketch_web_renderer||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var u={};return(()=>{"use strict";s.r(u),s.d(u,{default:()=>v,DefaultFeatureFlags:()=>m,SketchWeb:()=>n.U,SketchWebMode:()=>a.p,SketchWebError:()=>l.k,SketchWebProvider:()=>f.z0,SketchWebReact:()=>f.oW,useCursor:()=>f.jr,useDecrementZoom:()=>f.tm,useDocument:()=>f.ky,useEvent:()=>f.zX,useGenerateDocumentPNG:()=>f.ex,useGetArtboardAtPosititon:()=>f.Jw,useGetPanAtPosition:()=>f.m_,useIncrementZoom:()=>f.Yy,useIsCameraMoving:()=>f.d6,useIsCameraZooming:()=>f.aP,useLockCamera:()=>f.EY,useLooseWebGLContext:()=>f.pt,usePan:()=>f.od,useSetPan:()=>f.ph,useSetZoom:()=>f.lt,useStatus:()=>f.$z,useZoom:()=>f.BO,useZoomToFit:()=>f.us});var e=s(946),t=s(519),n=s(475),o=s(18),r={};for(const e in o)["default","DefaultFeatureFlags","SketchWeb"].indexOf(e)<0&&(r[e]=()=>o[e]);s.d(u,r);var i=s(119);r={};for(const e in i)["default","DefaultFeatureFlags","SketchWeb"].indexOf(e)<0&&(r[e]=()=>i[e]);s.d(u,r);var a=s(332),c=s(312);r={};for(const e in c)["default","DefaultFeatureFlags","SketchWeb","SketchWebMode"].indexOf(e)<0&&(r[e]=()=>c[e]);s.d(u,r);var l=s(758),d=s(689);r={};for(const e in d)["default","DefaultFeatureFlags","SketchWeb","SketchWebMode","SketchWebError"].indexOf(e)<0&&(r[e]=()=>d[e]);s.d(u,r);var h=s(650);r={};for(const e in h)["default","DefaultFeatureFlags","SketchWeb","SketchWebMode","SketchWebError"].indexOf(e)<0&&(r[e]=()=>h[e]);s.d(u,r);var f=s(536);const v=e.d;var m=t.Z})(),u})()}));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(require("react")):t(e.react);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,(e=>(()=>{"use strict";var t,n,o,r,i={156:t=>{t.exports=e}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.m=i,s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,o){if(1&o&&(e=this(e)),8&o)return e;if("object"==typeof e&&e){if(4&o&&e.__esModule)return e;if(16&o&&"function"==typeof e.then)return e}var r=Object.create(null);s.r(r);var i={};t=t||[null,n({}),n([]),n(n)];for(var a=2&o&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((t=>i[t]=()=>e[t]));return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,n)=>(s.f[n](e,t),t)),[])),s.u=e=>"static/js/web-renderer-"+{610:"8cf7e3dad04db65cf1e1",667:"aabfc7a6fc6164757d08",706:"49953fc2d5b916489af2"}[e]+".chunk.js",s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},r="@sketch-hq/sketch-web-renderer:",s.l=(e,t,n,i)=>{if(o[e])o[e].push(t);else{var a,c;if(void 0!==n)for(var u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var h=u[l];if(h.getAttribute("src")==e||h.getAttribute("data-webpack")==r+n){a=h;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",r+n),a.src=e),o[e]=[t];var d=(t,n)=>{a.onerror=a.onload=null,clearTimeout(f);var r=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((e=>e(n))),t)return t(n)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),c&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.p="/",(()=>{s.b=document.baseURI||self.location.href;var e={826:0};s.f.j=(t,n)=>{var o=s.o(e,t)?e[t]:void 0;if(0!==o)if(o)n.push(o[2]);else{var r=new Promise(((n,r)=>o=e[t]=[n,r]));n.push(o[2]=r);var i=s.p+s.u(t),a=new Error;s.l(i,(n=>{if(s.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var r=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,o[1](a)}}),"chunk-"+t,t)}};var t=(t,n)=>{var o,r,[i,a,c]=n,u=0;if(i.some((t=>0!==e[t]))){for(o in a)s.o(a,o)&&(s.m[o]=a[o]);c&&c(s)}for(t&&t(n);u<i.length;u++)r=i[u],s.o(e,r)&&e[r]&&e[r][0](),e[r]=0},n=self.webpackChunk_sketch_hq_sketch_web_renderer=self.webpackChunk_sketch_hq_sketch_web_renderer||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var c={};return(()=>{s.r(c),s.d(c,{DefaultFeatureFlags:()=>$e,SketchWeb:()=>A,SketchWebError:()=>m,SketchWebMode:()=>f,SketchWebProvider:()=>Ke,SketchWebReact:()=>ze,default:()=>Ye,useCursor:()=>ke,useDecrementZoom:()=>Te,useDocument:()=>we,useEvent:()=>Ge,useGenerateDocumentPNG:()=>De,useGetArtboardAtPosititon:()=>Ie,useGetPanAtPosition:()=>_e,useIncrementZoom:()=>Le,useIsCameraMoving:()=>We,useIsCameraZooming:()=>Ee,useLockCamera:()=>Ze,useLooseWebGLContext:()=>Oe,usePan:()=>Pe,useSetPan:()=>Re,useSetZoom:()=>Se,useStatus:()=>ye,useZoom:()=>Ce,useZoomToFit:()=>Ae});var e=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.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}(),t=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}();const n={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1};var o=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/;function r(e,t,n){return Math.max(t,Math.min(n,e))}function i(e){for(var t=e.size(),n=[],o=0;o<t;++o){var r=e.get(o);n.push(r)}return n}var a,u=(a=function(e,t){return a=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])},a(e,t)},function(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}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),l=function(e){function n(n,o){var r=e.call(this)||this;return r.listenersCollector=new t,r.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},r.handleGestureStart=function(e){e.preventDefault(),r.state.lastGestureScale=e.scale},r.handleGestureChange=function(e){e.preventDefault();var t=e.scale/r.state.lastGestureScale;r.state.lastGestureScale=e.scale;var n=r.getCorrectPointerPosition(e);r.emitZoomEvent(t,n)},r.handleGestureEnd=function(e){e.preventDefault()},r.handleTouchStart=function(e){e.preventDefault(),r.handleTouchPinchToZoomStart(e),r.emit("pointerdown",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleMouseDown=function(e){e.ctrlKey||(e.preventDefault(),r.emit("pointerdown",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0}))},r.handleTouchMove=function(e){r.handleTouchPinchToZoomChange(e),r.emit("pointermove",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleMouseMove=function(e){r.updateMousePosition(e)},r.handleGlobalTouchMove=function(e){r.emit("globalpointermove",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleGlobalMouseMove=function(e){r.updateGlobalMousePosition(e)},r.handleTouchPinchToZoomStart=function(e){var t;!e.touches||(null===(t=e.touches)||void 0===t?void 0:t.length)<2||(r.state.pinchToZoomLastDistance=r.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]))},r.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var n=r.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]),o=r.getCorrectPointerPosition(e),i=1+.004*(n-r.state.pinchToZoomLastDistance);r.state.pinchToZoomLastDistance=n,r.emitZoomEvent(i,o)}},r.handleTouchEnd=function(e){var t=e.touches.length<1?{x:0,y:0}:r.getCorrectPointerPosition(e);r.emit("pointerup",{position:t,type:"touch",button:0,touchesCount:e.touches.length})},r.handleMouseUp=function(e){r.emit("pointerup",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!r.state.isCtrlPressed,n=e.metaKey||t||r.state.isCtrlPressed;if(r.updateMousePosition(e),r.updateGlobalMousePosition(e),n){var o=t?-1:1,i=r.getCorrectPointerPosition(e),a=1+.005*e.deltaY*o;r.emitZoomEvent(a,i)}else r.emit("wheel",{x:-e.deltaX,y:-e.deltaY},{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.target=n,r.settings=o,r.targetBounds=n.getBoundingClientRect(),r.addListeners(),r}return u(n,e),n.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},n.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},n.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)}))},n.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)},n.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)},n.prototype.addSafariGesturesEventListeners=function(){"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0||(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}))},n.prototype.clampPointerToTargetBounds=function(e){return{x:r(e.x-this.targetBounds.x,0,this.target.clientWidth),y:r(e.y-this.targetBounds.y,0,this.target.clientHeight)}},n.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=function(e){var t,n,o,r,i,a;return{x:null!==(o=null===(n=null===(t=e.touches)||void 0===t?void 0:t[0])||void 0===n?void 0:n.clientX)&&void 0!==o?o:e.clientX,y:null!==(a=null===(i=null===(r=e.touches)||void 0===r?void 0:r[0])||void 0===i?void 0:i.clientY)&&void 0!==a?a:e.clientY}}(e);return this.clampPointerToTargetBounds(n)},n.prototype.updateMousePosition=function(e){this.emit("pointermove",{type:"mouse",position:this.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},n.prototype.updateGlobalMousePosition=function(e){this.emit("globalpointermove",{type:"mouse",position:this.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},n.prototype.calculateDistanceBetweenTouches=function(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)},n.prototype.emitZoomEvent=function(e,t){this.emit("pinchToZoom",e,t)},n.prototype.dispose=function(){this.listenersCollector.dispose()},n}(e),h=function(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))};const d=new(function(){function e(){this.active=!0}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.debug.apply(console,h(["[SketchWeb] [Debug]"],e,!1))},e.prototype.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.warn.apply(console,h(["[SketchWeb] [Warn]"],e,!1))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,h(["[SketchWeb] [Error]"],e,!1))},e}());var f,p=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now(),d.debug("[Performance] Start: ".concat(this.label))}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);d.debug("[Performance] End: ".concat(this.label," -> ").concat(t," ms"))}else{var n=(e/1e3).toFixed(2);d.debug("[Performance] End: ".concat(this.label," -> ").concat(n," s"))}},e}(),v=function(){var e=function(t,n){return e=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])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),m=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 v(t,e),t}(Error);function g(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))}!function(e){e.debug="debug",e.release="release"}(f||(f={}));const b=["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 y(e){return e.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const w="undefined"==typeof window,C=(()=>{if(w)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)}})(),P=[],k=[];function E(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,c,u=0,l=0,h=0;for(;l<o;)k[l]=e.charCodeAt(a+l),P[l]=++l;for(;h<r;)for(i=t.charCodeAt(a+h),s=h++,u=h,l=0;l<o;l++)c=i===k[l]?s:s+1,s=P[l],u=P[l]=s>u?c>u?u+1:c:c>s?s+1:c;return u}function W(e){return null!=e}class x extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const M=({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"}={})=>g(void 0,void 0,void 0,(function*(){const a={};if(w)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==C?void 0:C.isIpad),isMobile:c=!!(null==C?void 0:C.isMobile),screenSize:u=window.screen,loadBenchmarks:l=(e=>g(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 x("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:h}=n;const d=(e,t,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:c,tier:e,type:t});let f,p="";if(h)h=y(h),f=[h];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 d(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(h=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!h)return d(1,"FALLBACK");p=h,h=y(h),f=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 c;return"80162181255"===o?c=s.filter((([,,e])=>e>=14)):(c=s.filter((([,e])=>e===o)),c.length||(c=s)),c.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,h,c)}const v=(yield Promise.all(f.map((function(e){var t;return g(this,void 0,void 0,(function*(){const n=(e=>{const t=c?["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=`${c?"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 x)throw n;return}const h=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 d=i.filter((([,e])=>e===h));d.length||(d=i.filter((([t])=>t.includes(e))));const f=d.length;if(0===f)return;let p,[v,,,m]=f>1?d.map((t=>[t,E(e,t[0])])).sort((([,e],[,t])=>e-t))[0][0]:d[0],g=Number.MAX_VALUE;const{devicePixelRatio:b}=window,y=u.width*b*u.height*b;for(const e of m){const[t,n]=e,o=t*n,r=Math.abs(y-o);r<g&&(g=r,p=e)}if(!p)return;const[,,w,C]=p;return[g,w,v,C]}))})))).filter(W).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!v.length){const e=b.find((e=>h.includes(e)));return e?d(0,"BLOCKLISTED",e):d(1,"FALLBACK",`${h} (${p})`)}const[,m,P,k]=v[0];if(-1===m)return d(0,"BLOCKLISTED",P,m,k);const M=c?e:t;let S=0;for(let e=0;e<M.length;e++)m>=M[e]&&(S=e);return d(S,"BENCHMARK",P,m,k)}));var S=function(){var e=function(t,n){return e=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])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),L=function(){return L=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},L.apply(this,arguments)},T=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},R=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},A=(globalThis.indexedDB,function(e){function t(t){var r=t.canvas,i=t.locateFile,a=t.filePath,s=t.imagesURLFormat,c=t.imagesURLMap,u=t.backgroundColor,l=void 0===u?{r:1,g:1,b:1,a:1}:u,h=t.size,v=t.pixelRatio,m=t.mode,g=t.showTilesBorders,b=void 0!==g&&g,y=t.minimumZoomLevel,w=t.maximumZoomLevel,C=t.preserveDrawingBuffer,P=void 0!==C&&C,k=t.panBoundariesPadding,E=void 0===k?40:k,W=t.featureFlags,x=void 0===W?{}:W,M=e.call(this)||this;return M.status={type:"INIT"},M.handleWebGLContextLost=function(){M.setStatus({type:"WEBGL_CONTEXT_LOST"})},M.canvas=r,M.locateFile=i,M.filePath=a,M.imagesURLFormat=s,M.imagesURLMap=c,M.backgroundColor=l,M.size=h,M.pixelRatio=v,M.mode=m,M.showTilesBorders=b,M.currentWebGLVersion=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(o);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}}}()&&!n.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1,M.zoomLevels={min:y,max:w},M.preserveDrawingBuffer=P,M.panBoundariesPadding=E,M.featureFlags=L(L({},n),x),d.active=m===f.debug,M.traceFirstPaint=new p("FirstPaint"),M}return S(t,e),t.prototype.collectAndEmitDeviceInfo=function(){return T(this,void 0,void 0,(function(){var e;return R(this,(function(t){switch(t.label){case 0:return[4,M()];case 1:return e=t.sent(),this.deviceInfo=L(L({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){var e,t;return T(this,void 0,void 0,(function(){var n,o;return R(this,(function(r){switch(r.label){case 0:this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,this.initSketchWebWasm()];case 2:return r.sent(),[4,this.setFile(this.filePath)];case 3:return r.sent(),[4,this.preloadImages()];case 4:return r.sent(),[3,6];case 5:return n=r.sent(),[2,this.fail(n instanceof m?n:new m("ERROR","Unexpected exception initializing the web renderer",n))];case 6:return this.mode===f.debug&&((o=window).sketchWeb=this.sketchWebWasm,o.PRFindCriteria=null===(e=this.wasmModule)||void 0===e?void 0:e.PRFindCriteria,o.PRTimingFunction=null===(t=this.wasmModule)||void 0===t?void 0:t.PRTimingFunction),[2]}}))}))},t.prototype.preloadImages=function(){var e=this;return new Promise((function(t){var n;null===(n=e.sketchWebWasm)||void 0===n||n.preloadImages((function(){t()}))}))},t.prototype.startRendering=function(){this.traceInitialRender=new p("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),this.sketchWebWasm.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){d.debug("[C++] ".concat(e))},logWarning:function(e){d.warning("[C++] ".concat(e))},logError:function(e){d.error("[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.imagesURLFormat?e.imagesURLFormat.replace(":imageId",t):e.imagesURLMap&&e.imagesURLMap[t]?e.imagesURLMap[t]:(d.warning("Not able to resolve the url for the image 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",t.x,t.y)},onCursorChange:function(t){var n=e.prCursorTypeToCSSCursorMap[t.value];n?e.emit("cursorChange",n):d.warning("Unknown cursor type ".concat(t.value))}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n,o=new p("ImagesDownload");null===(n=e.sketchWebWasm)||void 0===n||n.downloadImages((function(){o.printMeasurement(),e.emit("metric",o.measure()),d.debug("Images downloaded"),t()}))}))},t.prototype.initSketchWebWasm=function(){return T(this,void 0,void 0,(function(){var e,t,n,o,r,i,a,c,u=this;return R(this,(function(l){switch(l.label){case 0:return e=new p("WasmModuleDownload"),this.mode!==f.debug?[3,2]:[4,s.e(706).then(s.t.bind(s,706,23))];case 1:return t=l.sent(),[3,4];case 2:return[4,s.e(610).then(s.t.bind(s,610,23))];case 3:t=l.sent(),l.label=4;case 4:n=t.default,l.label=5;case 5:return l.trys.push([5,7,,8]),o=this,[4,n({FeatureFlags:this.featureFlags,currentWebGLVersion:this.currentWebGLVersion,locateFile:function(e){return u.locateFile.replace("{file}",e)},bridge:this.createJSBridge()})];case 6:return o.wasmModule=l.sent(),[3,8];case 7:throw r=l.sent(),new m("WASM_ERROR","An error occurred while trying to create the wasm module.",r);case 8:if(this.pointerTypeToWASMMap={unset:this.wasmModule.PRUserPointerType.Unset,mouse:this.wasmModule.PRUserPointerType.Mouse,touch:this.wasmModule.PRUserPointerType.Touch},this.prCursorTypeToCSSCursorMap=((c={})[this.wasmModule.PRCursorType.Auto.value]="auto",c[this.wasmModule.PRCursorType.Default.value]="default",c[this.wasmModule.PRCursorType.Pointer.value]="pointer",c[this.wasmModule.PRCursorType.Grab.value]="grab",c[this.wasmModule.PRCursorType.Grabbing.value]="grabbing",c),e.printMeasurement(),this.emit("metric",e.measure()),i={majorVersion:this.currentWebGLVersion,antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:this.preserveDrawingBuffer},d.debug("Using WebGL ".concat(i.majorVersion)),!(a=this.wasmModule.GL.createContext(this.canvas,i)))throw new m("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");this.webglCtxHandle=a;try{this.sketchWebWasm=this.wasmModule.SketchWeb.MakeGL(this.webglCtxHandle,this.canvas.width,this.size.height,this.pixelRatio,{showTilesBorders:this.showTilesBorders})}catch(e){throw new m("WASM_ERROR","An error occurred while trying to create the SketchWebWasm object.",e)}return this.userEventsCollectorWasm=this.sketchWebWasm.getUserEventsCollector(),this.sketchWebWasm.setBackgroundColor(this.backgroundColor.r,this.backgroundColor.g,this.backgroundColor.b,this.backgroundColor.a),this.sketchWebWasm.setZoomLevels(this.zoomLevels.min,this.zoomLevels.max),this.sketchWebWasm.setPanBoundariesPadding(this.panBoundariesPadding),this.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost),[2]}}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.backgroundColor.r&&e.g===this.backgroundColor.g&&e.b===this.backgroundColor.b&&e.a===this.backgroundColor.a||(null===(t=this.sketchWebWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.backgroundColor=e)},t.prototype.generateDocumentPNG=function(){return T(this,void 0,void 0,(function(){return R(this,(function(e){switch(e.label){case 0:return[4,this.downloadImages()];case 1:return e.sent(),[2,this.sketchWebWasm.generateDocumentPNG()]}}))}))},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=this.wasmModule.GL.getContext(this.webglCtxHandle);if(e){var t=e.GLctx.getExtension("WEBGL_lose_context");t?t.loseContext():console.warn("Unable to retrieve WEBGL_lose_context extension")}else console.warn("Unable to loose context. WebGL rendering context not found")},t.prototype.scaleDocumentToFit=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.scaleDocumentToFit()},t.prototype.setFile=function(e){return T(this,void 0,void 0,(function(){var t=this;return R(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){t.sketchWebWasm.setFile(e,(function(e,o,r,i){if(void 0===i&&(i=[]),i.length){d.debug("Parser warnings: ".concat(i));var a=i.map((function(e){return{key:e}}));t.emit("warnings",a)}t.setStatus({type:"FILE_READY"}),t.emit("fileReady",t.getDocument(),e,o,r),n()}),(function(){return o(new m("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()):"")}),d.error(e),e.cause&&d.error(e.cause)},t.prototype.setSize=function(e,t,n){var o;this.size.width=e*n,this.size.height=t*n,this.canvas.width=e*n,this.canvas.height=t*n,null===(o=this.sketchWebWasm)||void 0===o||o.resize(e,t,n)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(d.debug("Status transition ".concat(this.status.type," => ").concat(e.type,"}")),this.status=e,this.emit("status",e))},t.prototype.getDocument=function(){if(!this.sketchWebWasm)return null;if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.filePath){var e=this.sketchWebWasm.getPRFile();this.cachedDocumentInfo={filePath:this.filePath,document:L(L({},e),{artboards:i(e.artboards)})}}return this.cachedDocumentInfo.document},t.prototype.getArtboardAtPosition=function(e,t){if(this.sketchWebWasm){var n=this.getDocument();if(n){for(var o=this.sketchWebWasm.getPan(),r=this.sketchWebWasm.getZoom(),i=(e-o.x)/r,a=(t-o.y)/r,s=0,c=n.artboards;s<c.length;s++){var u=c[s],l=u.bounds.x+u.bounds.width,h=u.bounds.y+u.bounds.height;if(i>=u.bounds.x&&a>=u.bounds.y&&i<=l&&a<=h)return u.objectId}return null}}},t.prototype.getPanAtPosition=function(e,t){if(this.sketchWebWasm){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;null===(n=this.sketchWebWasm)||void 0===n||n.setZoom(e,t.x,t.y)},t.prototype.getPan=function(){if(this.sketchWebWasm){var e=this.getDocument();if(e){var t=e.bounds,n=this.sketchWebWasm.getPan(),o=this.sketchWebWasm.getZoom();return{x:n.x/o+t.x,y:n.y/o+t.y}}}},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWebWasm)||void 0===e?void 0:e.getZoom()},t.prototype.handlePinchToZoomEvent=function(e,t){var n;null===(n=this.userEventsCollectorWasm)||void 0===n||n.dispatchPinchToZoomEvent(e,t.x,t.y)},t.prototype.pointerInfoToWASM=function(e){var t,n;return this.pointerTypeToWASMMap||d.warning("An user event was triggered, but the WASM module is not available."),L(L({},e),{type:null!==(n=null===(t=this.pointerTypeToWASMMap)||void 0===t?void 0:t[e.type])&&void 0!==n?n:this.wasmModule.PRUserPointerType.Unset})},t.prototype.setPan=function(e,t,n){if(void 0===n&&(n=!1),this.sketchWebWasm){var o=e,r=t,i=this.getDocument().bounds,a=this.sketchWebWasm.getZoom();if(n){var s=Math.max(2*a*this.pixelRatio,Number.EPSILON);o+=this.size.width/s,r+=this.size.height/s}var c=(o-i.x)*a,u=(r-i.y)*a;this.sketchWebWasm.setPan(c,u)}},t.prototype.handleWheelEvent=function(e,t){var n;null===(n=this.userEventsCollectorWasm)||void 0===n||n.dispatchWheelEvent(e.x,e.y,this.pointerInfoToWASM(t))},t.prototype.handlePointerDownEvent=function(e){var t;null===(t=this.userEventsCollectorWasm)||void 0===t||t.dispatchPointerDownEvent(this.pointerInfoToWASM(e))},t.prototype.handlePointerMoveEvent=function(e){var t;null===(t=this.userEventsCollectorWasm)||void 0===t||t.dispatchPointerMoveEvent(this.pointerInfoToWASM(e))},t.prototype.setGlobalPointerPosition=function(e){var t;null===(t=this.userEventsCollectorWasm)||void 0===t||t.dispatchGlobalPointerMoveEvent(this.pointerInfoToWASM(e))},t.prototype.handlePointerUpEvent=function(e){var t;null===(t=this.userEventsCollectorWasm)||void 0===t||t.dispatchPointerUpEvent(this.pointerInfoToWASM(e))},t.prototype.dispose=function(){var e,t;try{null===(e=this.sketchWebWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.sketchWebWasm)||void 0===t||t.delete(),this.looseWebGLContext(),this.userEventsCollectorWasm=null,this.sketchWebWasm=null,this.wasmModule=null}catch(e){this.fail(new m("ERROR","Unexpected exception while disposing the SketchWebWasm object",e))}},t}(e));const O=Symbol("Comlink.proxy"),D=Symbol("Comlink.endpoint"),I=Symbol("Comlink.releaseProxy"),_=Symbol("Comlink.thrown"),Z=e=>"object"==typeof e&&null!==e||"function"==typeof e,G=new Map([["proxy",{canHandle:e=>Z(e)&&e[O],serialize(e){const{port1:t,port2:n}=new MessageChannel;return j(e,t),[n,[n]]},deserialize:e=>(e.start(),B(e))}],["throw",{canHandle:e=>Z(e)&&_ in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function j(e,t=self){t.addEventListener("message",(function n(o){if(!o||!o.data)return;const{id:r,type:i,path:a}=Object.assign({path:[]},o.data),s=(o.data.argumentList||[]).map(H);let c;try{const t=a.slice(0,-1).reduce(((e,t)=>e[t]),e),n=a.reduce(((e,t)=>e[t]),e);switch(i){case"GET":c=n;break;case"SET":t[a.slice(-1)[0]]=H(o.data.value),c=!0;break;case"APPLY":c=n.apply(t,s);break;case"CONSTRUCT":c=Y(new n(...s));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;j(e,n),c=K(t,[t])}break;case"RELEASE":c=void 0;break;default:return}}catch(e){c={value:e,[_]:0}}Promise.resolve(c).catch((e=>({value:e,[_]:0}))).then((e=>{const[o,a]=$(e);t.postMessage(Object.assign(Object.assign({},o),{id:r}),a),"RELEASE"===i&&(t.removeEventListener("message",n),F(t))}))})),t.start&&t.start()}function F(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function B(e,t){return U(e,[],t)}function z(e){if(e)throw new Error("Proxy has been released and is not useable")}function U(e,t=[],n=function(){}){let o=!1;const r=new Proxy(n,{get(n,i){if(z(o),i===I)return()=>X(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{F(e),o=!0}));if("then"===i){if(0===t.length)return{then:()=>r};const n=X(e,{type:"GET",path:t.map((e=>e.toString()))}).then(H);return n.then.bind(n)}return U(e,[...t,i])},set(n,r,i){z(o);const[a,s]=$(i);return X(e,{type:"SET",path:[...t,r].map((e=>e.toString())),value:a},s).then(H)},apply(n,r,i){z(o);const a=t[t.length-1];if(a===D)return X(e,{type:"ENDPOINT"}).then(H);if("bind"===a)return U(e,t.slice(0,-1));const[s,c]=N(i);return X(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:s},c).then(H)},construct(n,r){z(o);const[i,a]=N(r);return X(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:i},a).then(H)}});return r}function N(e){const t=e.map($);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const V=new WeakMap;function K(e,t){return V.set(e,t),e}function Y(e){return Object.assign(e,{[O]:!0})}function $(e){for(const[t,n]of G)if(n.canHandle(e)){const[o,r]=n.serialize(e);return[{type:"HANDLER",name:t,value:o},r]}return[{type:"RAW",value:e},V.get(e)||[]]}function H(e){switch(e.type){case"HANDLER":return G.get(e.name).deserialize(e.value);case"RAW":return e.value}}function X(e,t,n){return new Promise((o=>{const r=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===r&&(e.removeEventListener("message",t),o(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:r},t),n)}))}var q,J=function(){var e=function(t,n){return e=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])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),Q=function(e){function n(n){var o=e.call(this)||this;return o.listenersCollector=new t,o.handleKeyUp=function(e){o.emit("keyUp",e.code)},o.target=n,o.addListeners(),o}return J(n,e),n.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},n.prototype.dispose=function(){this.listenersCollector.dispose()},n}(e),ee=function(){var e=function(t,n){return e=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])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),te=function(){return te=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},te.apply(this,arguments)},ne=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},oe=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},re=function(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(e){e[e.browser=0]="browser",e[e.worker=1]="worker"}(q||(q={}));var ie=function(e){function o(o){var r,i=this;(i=e.call(this)||this).listenersCollector=new t,i.handlePointerDownEvent=function(e){var t;null===(t=i.sketchWeb)||void 0===t||t.handlePointerDownEvent(e)},i.handlePointerMoveEvent=function(e){var t;null===(t=i.sketchWeb)||void 0===t||t.handlePointerMoveEvent(e)},i.handleGlobalPointerMoveEvent=function(e){var t;null===(t=i.sketchWeb)||void 0===t||t.setGlobalPointerPosition(e)},i.handlePointerUpEvent=function(e){var t;null===(t=i.sketchWeb)||void 0===t||t.handlePointerUpEvent(e)},i.handleWheelEvent=function(e,t){return ne(i,void 0,void 0,(function(){var n;return oe(this,(function(o){return null===(n=this.sketchWeb)||void 0===n||n.handleWheelEvent(e,t),[2]}))}))},i.handlePinchToZoomEvent=function(e,t){return ne(i,void 0,void 0,(function(){var n;return oe(this,(function(o){return null===(n=this.sketchWeb)||void 0===n||n.handlePinchToZoomEvent(e,t),[2]}))}))},i.handleCanvasResizeObserver=function(e){i.resizeCanvas(e[0].contentRect)},i.resizeCanvas=function(e){var t=e.width,n=e.height;window.requestAnimationFrame((function(){var e;i.setCanvasSize(t,n),i.gestureManager.updateTargetBounds(),null===(e=i.sketchWeb)||void 0===e||e.setSize(t,n,i.getDevicePixelRatio())}))};var a=null!==(r=o.featureFlags)&&void 0!==r?r:{};return i.featureFlags=te(te({},n),a),i.settings=o,i.canvas=o.canvas,i.gestureManager=new l(i.settings.container,{minimumZoomLevel:o.minimumZoomLevel,maximumZoomLevel:o.maximumZoomLevel}),i.keyboardManager=new Q(document.body),d.active=o.mode===f.debug,i.init(),i}return ee(o,e),o.prototype.init=function(){var e;return ne(this,void 0,void 0,(function(){var t,n,o;return oe(this,(function(r){switch(r.label){case 0:return this.setCanvasSize(this.settings.container.clientWidth,this.settings.container.clientHeight),[4,this.initSketchWeb()];case 1:return r.sent(),[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getStatus()];case 2:return"FILE_READY"!==(null==(t=r.sent())?void 0:t.type)?[2]:(n=void 0!==this.settings.initialZoom,o=void 0!==this.settings.initialPan,n||o?n?[4,this.setZoom(this.settings.initialZoom)]:[3,4]:[3,7]);case 3:r.sent(),r.label=4;case 4:return o?[4,this.setPan(this.settings.initialPan.x,this.settings.initialPan.y,this.settings.initialPan.centerPointInViewport)]:[3,6];case 5:r.sent(),r.label=6;case 6:return[3,9];case 7:return[4,this.zoomToFit()];case 8:r.sent(),r.label=9;case 9:return this.sketchWeb.startRendering(),this.addListeners(),[2]}}))}))},o.prototype.initSketchWeb=function(){return ne(this,void 0,void 0,(function(){var e,t,n,o,r;return oe(this,(function(i){switch(i.label){case 0:return e=this.featureFlags.offscreenCanvas&&"function"==typeof this.canvas.transferControlToOffscreen,t=te(te({},this.settings),{size:{width:this.canvas.width,height:this.canvas.height},pixelRatio:this.getDevicePixelRatio(),featureFlags:this.featureFlags}),e?(this.environment=q.worker,d.debug("Using offscreen canvas"),this.offscreenCanvas=this.canvas.transferControlToOffscreen(),this.worker=new Worker(new URL(s.p+s.u(667),s.b),{type:void 0}),n=B(this.worker),o=this,[4,new n(K(te(te({},t),{canvas:this.offscreenCanvas}),[this.offscreenCanvas]))]):[3,2];case 1:return o.sketchWeb=i.sent(),[3,3];case 2:this.environment=q.browser,d.debug("Using normal canvas"),this.sketchWeb=new A(t),i.label=3;case 3:return(r=this.sketchWeb).on("status",this.forwardEvent("status")),r.on("fileReady",this.forwardEvent("fileReady")),r.on("metric",this.forwardEvent("metric")),r.on("warnings",this.forwardEvent("warnings")),r.on("allImagesReady",this.forwardEvent("allImagesReady")),r.on("deviceInfo",this.forwardEvent("deviceInfo")),r.on("cameraMoveStart",this.forwardEvent("cameraMoveStart")),r.on("cameraMoveEnd",this.forwardEvent("cameraMoveEnd")),r.on("cameraZoomStart",this.forwardEvent("cameraZoomStart")),r.on("cameraZoomEnd",this.forwardEvent("cameraZoomEnd")),r.on("cameraZoomChange",this.forwardEvent("cameraZoomChange")),r.on("cameraPanChange",this.forwardEvent("cameraPanChange")),r.on("cursorChange",this.forwardEvent("cursorChange")),[4,this.sketchWeb.init()];case 4:return i.sent(),[2]}}))}))},o.prototype.forwardEvent=function(e){var t=this,n=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];t.emit.apply(t,re([e],n,!1))};return this.environment===q.worker?Y(n):n},o.prototype.isRunningInsideWorker=function(){return this.environment===q.worker},o.prototype.looseWebGLContext=function(){var e;null===(e=this.sketchWeb)||void 0===e||e.looseWebGLContext()},o.prototype.addListeners=function(){this.canvasResizeObserver=new ResizeObserver(this.handleCanvasResizeObserver),this.canvasResizeObserver.observe(this.settings.container),this.listenersCollector.add(window,"orientationchange",this.handleDeviceOrientationChange),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)},o.prototype.getDevicePixelRatio=function(){return r(window.devicePixelRatio,1,2)},o.prototype.setCanvasSize=function(e,t){this.canvas.style.width="".concat(e,"px"),this.canvas.style.height="".concat(t,"px"),this.canvas.width=e*this.getDevicePixelRatio(),this.canvas.height=t*this.getDevicePixelRatio()},o.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.settings.container.clientWidth,height:this.settings.container.clientHeight})},o.prototype.setBackgroundColor=function(e){var t;null===(t=this.sketchWeb)||void 0===t||t.setBackgroundColor(e)},o.prototype.zoomToFit=function(){return ne(this,void 0,void 0,(function(){return oe(this,(function(e){switch(e.label){case 0:return[4,this.sketchWeb.scaleDocumentToFit()];case 1:return e.sent(),[2]}}))}))},o.prototype.getStatus=function(){var e;return ne(this,void 0,void 0,(function(){return oe(this,(function(t){return[2,null===(e=this.sketchWeb)||void 0===e?void 0:e.getStatus()]}))}))},o.prototype.generateDocumentPNG=function(){var e;return ne(this,void 0,void 0,(function(){return oe(this,(function(t){return[2,null===(e=this.sketchWeb)||void 0===e?void 0:e.generateDocumentPNG()]}))}))},o.prototype.getDocument=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getDocument()},o.prototype.getArtboardAtPosition=function(e,t){var n;return ne(this,void 0,void 0,(function(){return oe(this,(function(o){switch(o.label){case 0:return[4,null===(n=this.sketchWeb)||void 0===n?void 0:n.getArtboardAtPosition(e,t)];case 1:return[2,o.sent()||null]}}))}))},o.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWeb)||void 0===n?void 0:n.getPanAtPosition(e,t)},o.prototype.setPan=function(e,t,n){var o;return ne(this,void 0,void 0,(function(){return oe(this,(function(r){switch(r.label){case 0:return[4,null===(o=this.sketchWeb)||void 0===o?void 0:o.setPan(e,t,Boolean(n))];case 1:return r.sent(),[2]}}))}))},o.prototype.setZoom=function(e,t){var n;return ne(this,void 0,void 0,(function(){var o;return oe(this,(function(r){return o=null!=t?t:this.getCanvasCenterPoint(),null===(n=this.sketchWeb)||void 0===n||n.setZoom(e,o),[2]}))}))},o.prototype.getCanvasCenterPoint=function(){var e=this.canvas.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},o.prototype.getZoom=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getZoom()},o.prototype.getPan=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getPan()},o.prototype.setIsCameraLocked=function(e){var t;null===(t=this.sketchWeb)||void 0===t||t.setIsCameraLocked(e)},o.prototype.dispose=function(){var e,t,n,o;return ne(this,void 0,void 0,(function(){return oe(this,(function(r){switch(r.label){case 0:return this.gestureManager.dispose(),this.keyboardManager.dispose(),this.listenersCollector.dispose(),null===(e=this.canvasResizeObserver)||void 0===e||e.disconnect(),this.isRunningInsideWorker()?[4,null===(t=this.sketchWeb)||void 0===t?void 0:t.dispose()]:[3,2];case 1:return r.sent(),null===(n=this.worker)||void 0===n||n.terminate(),[3,3];case 2:null===(o=this.sketchWeb)||void 0===o||o.dispose(),r.label=3;case 3:return[2]}}))}))},o}(e),ae=s(156),se=s.n(ae),ce=(0,ae.createContext)(void 0),ue=function(){var e=(0,ae.useContext)(ce);if(void 0===e)throw Error("useSketchWebInternalContext must be used within a SketchWebProvider");return e},le=function(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))},he=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d.debug.apply(d,le(["SketchWebReact"],e,!1))},de=(0,ae.createContext)(void 0),fe=(0,ae.createContext)(void 0),pe=(0,ae.createContext)(void 0),ve=(0,ae.createContext)(void 0),me=(0,ae.createContext)(void 0),ge=(0,ae.createContext)(void 0),be=(0,ae.createContext)("auto"),ye=function(){var e=(0,ae.useContext)(de);if(void 0===e)throw Error("useStatus must be used within a SketchWebProvider");return e},we=function(){var e=(0,ae.useContext)(fe);if(void 0===e)throw Error("useDocument must be used within a SketchWebProvider");return e},Ce=function(){var e=(0,ae.useContext)(pe);if(void 0===e)throw Error("useZoom must be used within a SketchWebProvider");return e},Pe=function(){var e=(0,ae.useContext)(ge);if(void 0===e)throw Error("usePan must be used within a SketchWebProvider");return e},ke=function(){var e=(0,ae.useContext)(be);if(void 0===e)throw Error("useCursor must be used within a SketchWebProvider");return e},Ee=function(){var e=(0,ae.useContext)(ve);if(void 0===status)throw Error("useIsCameraZooming must be used within a SketchWebProvider");return e},We=function(){var e=(0,ae.useContext)(me);if(void 0===status)throw Error("useIsCameraMoving must be used within a SketchWebProvider");return e},xe=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},Me=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Se=function(){var e=(0,ue().getManager)();return(0,ae.useCallback)((function(t){he("setZoom",t),null==e||e.setZoom(t)}),[e])},Le=function(){var e=Se(),t=Ce();return(0,ae.useCallback)((function(){var n;he("incrementZoom"),"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},Te=function(){var e=Se(),t=Ce();return(0,ae.useCallback)((function(){he("decrementZoom"),"number"==typeof t&&e(t/2)}),[e,t])},Re=function(){var e=(0,ue().getManager)();return(0,ae.useCallback)((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;he("setPan",n,o,"centerPointInViewport",r),null==e||e.setPan(n,o,r)}),[e])},Ae=function(){var e=(0,ue().getManager)();return(0,ae.useCallback)((function(){he("zoomToFit"),null==e||e.zoomToFit()}),[e])},Oe=function(){var e=(0,ue().getManager)();return(0,ae.useCallback)((function(){he("looseWebGLContext"),null==e||e.looseWebGLContext()}),[e])},De=function(){var e=(0,ue().getManager)();return(0,ae.useCallback)((function(){return xe(void 0,void 0,void 0,(function(){return Me(this,(function(t){switch(t.label){case 0:return he("generateDocumentPNG"),[4,null==e?void 0:e.generateDocumentPNG()];case 1:return[2,t.sent()]}}))}))}),[e])},Ie=function(){var e=(0,ue().getManager)();return(0,ae.useCallback)((function(t,n){return xe(void 0,void 0,void 0,(function(){return Me(this,(function(o){switch(o.label){case 0:return he("getArtboardAtPosition",t,n),[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},_e=function(){var e=(0,ue().getManager)();return(0,ae.useCallback)((function(t,n){return xe(void 0,void 0,void 0,(function(){return Me(this,(function(o){switch(o.label){case 0:return he("getPanAtPosition",t,n),[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Ze=function(){var e=(0,ue().getManager)();return(0,ae.useCallback)((function(t){he("setIsCameraLocked",t),null==e||e.setIsCameraLocked(t)}),[e])},Ge=function(e,t){var n=(0,ue().getManager)();(0,ae.useEffect)((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},je=function(){return je=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},je.apply(this,arguments)},Fe={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Be={position:"absolute",top:0,left:0},ze=function(e){d.active=e.mode===f.debug;var t=e.filePath,n=e.locateFile,o=e.imagesURLFormat,r=e.imagesURLMap,i=e.backgroundColor,a=e.mode,s=e.showTilesBorders,c=e.minimumZoomLevel,u=e.maximumZoomLevel,l=e.preserveDrawingBuffer,h=e.panBoundariesPadding,p=e.initialPan,v=e.initialZoom,m=e.children,g=e.containerProps,b=void 0===g?{}:g,y=e.canvasProps,w=void 0===y?{}:y,C=e.featureFlags,P=void 0===C?{}:C,k=(0,ae.useRef)(null),E=(0,ae.useRef)(null),W=(0,ae.useState)(!1),x=W[0],M=W[1],S=(0,ae.useCallback)((function(){return M(!0)}),[]),L=ue(),T=L.dispose,R=L.init,A=L.setSettings,O=ke(),D=ye();Ge("allImagesReady",S),(0,ae.useEffect)((function(){A({locateFile:n,imagesURLFormat:o,imagesURLMap:r,backgroundColor:i,mode:a,showTilesBorders:s,minimumZoomLevel:c,maximumZoomLevel:u,preserveDrawingBuffer:l,panBoundariesPadding:h,initialPan:p,initialZoom:v,featureFlags:P})}),[A,n,o,r,i,a,s,c,u,l,h,p,v,P]),(0,ae.useEffect)((function(){if(t)return R(t,k.current,E.current),function(){T()}}),[T,R,t]);var I=(0,ae.useMemo)((function(){var t;return null!==(t=e.cursor)&&void 0!==t?t:O}),[e.cursor,O]),_=(0,ae.useMemo)((function(){return je(je({},Fe),{cursor:I})}),[I]);return se().createElement("div",je({},b,{ref:E,style:_}),t&&se().createElement("canvas",je({},w,{key:t,ref:k,"data-sketchweb-all-images-ready":x,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==D?void 0:D.type.toLowerCase())||"null"),style:Be})),"READY"===(null==D?void 0:D.type)&&m)},Ue=function(){return Ue=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},Ue.apply(this,arguments)},Ne=function(e,t){switch(t.type){case"on-status":return Ue(Ue({},e),{status:t.status});case"on-file-ready":return Ue(Ue({},e),{document:t.document});case"on-zoom":return Ue(Ue({},e),{zoom:t.zoom});case"on-pan":return Ue(Ue({},e),{pan:t.pan});case"dispose":return Ue(Ue({},e),{status:null,zoom:null,pan:null,cursor:"auto"});case"post-init":return Ue(Ue({},e),{status:t.status,zoom:t.zoom});case"on-camera-zoom-start":return Ue(Ue({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return Ue(Ue({},e),{isCameraZooming:!1});case"on-camera-move-start":return Ue(Ue({},e),{isCameraMoving:!0});case"on-camera-move-end":return Ue(Ue({},e),{isCameraMoving:!1});case"on-cursor-change":return Ue(Ue({},e),{cursor:t.cursor});default:return e}},Ve=function(){return Ve=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},Ve.apply(this,arguments)},Ke=function(e){var t=(0,ae.useRef)(null),n=(0,ae.useRef)(null),o=(0,ae.useReducer)(Ne,{pan:null,zoom:null,status:null,document:null,isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),r=o[0],i=r.status,a=r.document,s=r.zoom,c=r.pan,u=r.isCameraZooming,l=r.isCameraMoving,h=r.cursor,d=o[1],f=(0,ae.useCallback)((function(e){return d({type:"on-zoom",zoom:e})}),[]),p=(0,ae.useCallback)((function(e,t){return d({type:"on-pan",pan:{x:e,y:t}})}),[]),v=(0,ae.useCallback)((function(e){d({type:"on-status",status:e})}),[]),m=(0,ae.useCallback)((function(e){d({type:"on-file-ready",document:e})}),[]),g=(0,ae.useCallback)((function(){return d({type:"on-camera-zoom-start"})}),[]),b=(0,ae.useCallback)((function(){return d({type:"on-camera-zoom-end"})}),[]),y=(0,ae.useCallback)((function(){return d({type:"on-camera-move-start"})}),[]),w=(0,ae.useCallback)((function(){return d({type:"on-camera-move-end"})}),[]),C=(0,ae.useCallback)((function(e){return d({type:"on-cursor-change",cursor:e})}),[]),P=(0,ae.useCallback)((function(){var e=t.current;e&&(he("dispose"),e.off("status",v),e.off("fileReady",m),e.off("cameraZoomChange",f),e.off("cameraPanChange",p),e.off("cameraZoomStart",g),e.off("cameraZoomEnd",b),e.off("cameraMoveStart",y),e.off("cameraMoveEnd",w),e.off("cursorChange",C),e.dispose(),t.current=null,d({type:"dispose"}))}),[v,m,p,f,g,b,y,w,C]),k=(0,ae.useCallback)((function(e,o,r){if(""!==e&&o&&r&&n.current){he("init");var i=new ie(Ve(Ve({},n.current),{filePath:e,container:r,canvas:o}));i.on("status",v),i.on("fileReady",m),i.on("cameraZoomChange",f),i.on("cameraPanChange",p),i.on("cameraZoomStart",g),i.on("cameraZoomEnd",b),i.on("cameraMoveStart",y),i.on("cameraMoveEnd",w),i.on("cursorChange",C),a=void 0,s=void 0,u=function(){var e,t;return function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(n){switch(n.label){case 0:return e=d,t={type:"post-init"},[4,i.getZoom()];case 1:return t.zoom=n.sent()||null,[4,i.getStatus()];case 2:return t.status=n.sent()||null,[4,i.getPan()];case 3:return e.apply(void 0,[(t.pan=n.sent()||null,t)]),[2]}}))},new((c=void 0)||(c=Promise))((function(e,t){function n(e){try{r(u.next(e))}catch(e){t(e)}}function o(e){try{r(u.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):(r=t.value,r instanceof c?r:new c((function(e){e(r)}))).then(n,o)}r((u=u.apply(a,s||[])).next())})),t.current=i}var a,s,c,u}),[v,m,f,p,g,b,y,w,C]),E=(0,ae.useCallback)((function(e){var o;he("setSettings",e),e.backgroundColor&&(null===(o=t.current)||void 0===o||o.setBackgroundColor(e.backgroundColor)),n.current=e}),[]),W=(0,ae.useCallback)((function(){return t.current}),[]),x=(0,ae.useMemo)((function(){return{dispose:P,init:k,setSettings:E,getManager:W,dispatch:d}}),[P,k,E,W]);return se().createElement(ce.Provider,{value:x},se().createElement(de.Provider,{value:i},se().createElement(fe.Provider,{value:a},se().createElement(pe.Provider,{value:s},se().createElement(ge.Provider,{value:c},se().createElement(ve.Provider,{value:u},se().createElement(me.Provider,{value:l},se().createElement(be.Provider,{value:h},e.children))))))))};const Ye=ie;var $e=n})(),c})()));
Binary file
Binary file