@sketch-hq/sketch-web-renderer 15.17.0 → 15.18.0
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.
- package/out/web-renderer/index.js +1 -1
- package/out/web-renderer/ts/canvas-renderer/ComparisonController.d.ts +4 -2
- package/out/web-renderer/ts/canvas-renderer/ComparisonController.d.ts.map +1 -1
- package/out/web-renderer/wasm/Debug/web-renderer-debug.wasm +2 -2
- package/out/web-renderer/wasm/Release/web-renderer-release.wasm +0 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{useRef as t,useLayoutEffect as n,useCallback as o,createContext as r,useContext as i,useReducer as a,useMemo as s,useEffect as u,useState as l}from"react";var c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var h=function(){return h=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},h.apply(this,arguments)};function p(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}function f(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function g(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))}var v={linear:function(e){return e},easeIn:function(e){return e*e*e},easeOut:function(e){return 1-Math.pow(1-e,3)},easeInEaseOut:function(e){return e<.5?4*Math.pow(e,3):1-Math.pow(-2*e+2,3)/2}},m=function(){function e(){this.frame=null}return Object.defineProperty(e.prototype,"isAnimating",{get:function(){return null!==this.frame},enumerable:!1,configurable:!0}),e.prototype.cancel=function(){null!==this.frame&&(cancelAnimationFrame(this.frame),this.frame=null)},e.prototype.run=function(e,t,n){var o,r=this;this.cancel();var i=h(h({},t),e),a=i.duration,s=i.easing,u=null!==(o=v[s])&&void 0!==o?o:v[t.easing],l=e.onComplete;if(a<=0||"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n(1),void(null==l||l());var c=performance.now(),d=function(e){var t=Math.min(1,(e-c)/a);n(u(t)),t<1?r.frame=requestAnimationFrame(d):(r.frame=null,n(1),null==l||l())};this.frame=requestAnimationFrame(d)},e}(),y={duration:200,easing:"easeOut"},b={duration:500,easing:"easeInEaseOut"},w=function(e,t,n){return e+(t-e)*n},C=function(){function e(e){this.apply=e,this.animator=new m}return Object.defineProperty(e.prototype,"isAnimating",{get:function(){return this.animator.isAnimating},enumerable:!1,configurable:!0}),e.prototype.cancel=function(){this.animator.cancel()},e.prototype.animate=function(e,t,n){var o,r=this;if(void 0===n&&(n={}),!(e.zoom>0&&t.zoom>0))return this.animator.cancel(),this.apply(t),void(null===(o=n.onComplete)||void 0===o||o.call(n));var i=t.zoom/e.zoom;this.animator.run(n,b,(function(n){return r.apply({zoom:e.zoom*Math.pow(i,n),pan:{x:w(e.pan.x,t.pan.x,n),y:w(e.pan.y,t.pan.y,n)}})}))},e}();function P(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}const S=["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 E(e){return e.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const R="undefined"==typeof window,M=(()=>{if(R)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)}})();class L extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const x=[],F=[];function W(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let o=e.length,r=t.length;for(;o>0&&e.charCodeAt(~-o)===t.charCodeAt(~-r);)o--,r--;let i,a=0;for(;a<o&&e.charCodeAt(a)===t.charCodeAt(a);)a++;if(o-=a,r-=a,0===o)return r;let s,u,l=0,c=0,d=0;for(;c<o;)F[c]=e.charCodeAt(a+c),x[c]=++c;for(;d<r;)for(i=t.charCodeAt(a+d),s=d++,l=d,c=0;c<o;c++)u=i===F[c]?s:s+1,s=x[c],l=x[c]=s>l?u>l?l+1:u:u>s?s+1:u;return l}function I(e){return null!=e}const A=({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@5.0.25/dist/benchmarks"}={})=>P(void 0,void 0,void 0,(function*(){const a={};if(R)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==M?void 0:M.isIpad),isMobile:u=!!(null==M?void 0:M.isMobile),screenSize:l=window.screen,loadBenchmarks:c=(e=>P(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 L("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:d}=n;const h=(e,t,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:u,tier:e,type:t});let p,f="";if(d)d=E(d),p=[d];else{const e=o||function(e,t=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:t,powerPreference:"high-performance",stencil:!1};e&&delete n.powerPreference;const o=window.document.createElement("canvas"),r=o.getContext("webgl",n)||o.getContext("experimental-webgl",n);return null!=r?r:void 0}(null==M?void 0:M.isSafari12,r);if(!e)return h(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(d=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");f=d,d=E(d),p=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==M?void 0:M.isIpad)?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["m1",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15]];let u;return"80162181255"===o?u=s.filter((([,,e])=>e>=14)):(u=s.filter((([,e])=>e===o)),u.length||(u=s)),u.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,d,u)}const g=(yield Promise.all(p.map((function(e){var t;return P(this,void 0,void 0,(function*(){const n=(e=>{const t=u?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const o=`${u?"m":"d"}-${n}${s?"-ipad":""}.json`,r=a[o]=null!==(t=a[o])&&void 0!==t?t:c(o);let i;try{i=yield r}catch(n){if(n instanceof L)throw n;return}const d=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let h=i.filter((([,e])=>e===d));h.length||(h=i.filter((([t])=>t.includes(e))));const p=h.length;if(0===p)return;const f=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let g,[v,,,,m]=p>1?h.map((e=>[e,W(f,e[2])])).sort((([,e],[,t])=>e-t))[0][0]:h[0],y=Number.MAX_VALUE;const{devicePixelRatio:b}=window,w=l.width*b*l.height*b;for(const e of m){const[t,n]=e,o=t*n,r=Math.abs(w-o);r<y&&(y=r,g=e)}if(!g)return;const[,,C,P]=g;return[y,C,v,P]}))})))).filter(I).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!g.length){const e=S.find((e=>d.includes(e)));return e?h(0,"BLOCKLISTED",e):h(1,"FALLBACK",`${d} (${f})`)}const[,v,m,y]=g[0];if(-1===v)return h(0,"BLOCKLISTED",m,v,y);const b=u?e:t;let w=0;for(let e=0;e<b.length;e++)v>=b[e]&&(w=e);return h(w,"BENCHMARK",m,v,y)}));function T(e){return"displayP3"===e?"display-p3":"srgb"}var U,k,D=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 d(t,e),t}(Error);function G(e){return void 0!==e}!function(e){e.debug="debug",e.release="release"}(U||(U={})),function(e){e.Fit="Fit",e.FillWidth="FillWidth",e.ActualSize="ActualSize"}(k||(k={}));var B=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,o;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(o=this.listeners[e])||void 0===o||o.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.forwardEvent=function(e,t){this.on(t,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];e.emit.apply(e,g([t],n,!1))}))},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this.listeners[e];(null==o?void 0:o.size)&&o.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e.prototype.detachAllListeners=function(){this.listeners={}},e}(),z=function(){function e(e){void 0===e&&(e=!1),this.removeListenerCallbacks=[],this.disabled=e}return e.prototype.add=function(e,t,n,o){var r=this,i=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];r.disabled||n.apply(void 0,e)};e.addEventListener(t,i,o);var a=function(){e.removeEventListener(t,i,o)};return this.removeListenerCallbacks.push(a),a},e.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(e){return e()}))},e.prototype.setDisabled=function(e){this.disabled=e},e}(),O={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1,canvasLayersEvents:!1},Z=function(e){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(e)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},N=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,H=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(N);if(!t)return null;var n=t[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(t[4])||0,minor:parseInt(t[5])||0,patch:parseInt(t[6])||0}}};function j(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 _(e){var t,n,o,r,i,a=null!==(n=null===(t=e.touches)||void 0===t?void 0:t[0])&&void 0!==n?n:null===(o=e.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(r=null==a?void 0:a.clientX)&&void 0!==r?r:e.clientX,y:null!==(i=null==a?void 0:a.clientY)&&void 0!==i?i:e.clientY}}function V(e,t,n){return Math.max(t,Math.min(n,e))}function q(e){return Boolean(window.chrome)&&e.gpu&&/amd\sradeon\s(pro|rx)\s5\d\d\d/gi.test(e.gpu)||H()&&!O.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function J(e){if(!e)return[];for(var t=[],n=0;n<e.size();n++)t.push(e.get(n));return t}function K(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function Y(e){var t=h({},e);return Object.keys(t).forEach((function(e){void 0===t[e]&&delete t[e]})),t}function $(e){return K()?{onTouchEnd:e}:{onClick:e}}function X(){return"function"==typeof crypto.randomUUID?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(16))).map((function(e){return e.toString(16).padStart(2,"0")})).join("")}var Q=function(e){return 0===(null==e?void 0:e.$$.count.value)?null:e},ee=function(e){function t(t,n,o){void 0===n&&(n=!1),void 0===o&&(o=!1);var r=e.call(this)||this;return 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.updateMousePosition=function(e){r.emit("pointermove",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.updateGlobalMousePosition=function(e){r.emit("globalpointermove",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},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=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.debouncedUpdateMousePosition=j(r.updateMousePosition,40),r.debouncedUpdateGlobalMousePosition=j(r.updateGlobalMousePosition,40),r.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!r.state.isCtrlPressed,n=e.metaKey||t||r.state.isCtrlPressed;if(r.debouncedUpdateMousePosition(e),r.debouncedUpdateGlobalMousePosition(e),n){var o=t||r.invertedWheelZoom?-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=t,r.invertedWheelZoom=n,r.targetBounds=t.getBoundingClientRect(),r.listenersCollector=new z(o),r.addListeners(),r.targetResizeObserver=new ResizeObserver(r.updateTargetBounds.bind(r)),r.targetResizeObserver.observe(r.target),r}return d(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},t.prototype.addKeyboardEventListeners=function(){var e=this;this.listenersCollector.add(document,"keydown",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(t){t.ctrlKey&&(e.state.isCtrlPressed=!1)}))},t.prototype.addMouseEventListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handleMouseDown),this.listenersCollector.add(this.target,"mousemove",this.handleMouseMove),this.listenersCollector.add(document,"mousemove",this.handleGlobalMouseMove),this.listenersCollector.add(document,"mouseup",this.handleMouseUp),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel)},t.prototype.addTouchEventListeners=function(){this.listenersCollector.add(this.target,"touchstart",this.handleTouchStart),this.listenersCollector.add(document,"touchmove",this.handleGlobalTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(this.target,"touchmove",this.handleTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(document,"touchcancel",this.handleTouchEnd),this.listenersCollector.add(document,"touchend",this.handleTouchEnd)},t.prototype.addSafariGesturesEventListeners=function(){K()||(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:e.x-this.targetBounds.x,y:e.y-this.targetBounds.y}},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=_(e);return this.clampPointerToTargetBounds(n)},t.prototype.calculateDistanceBetweenTouches=function(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)},t.prototype.emitZoomEvent=function(e,t){this.emit("pinchToZoom",e,t)},t.prototype.dispose=function(){this.listenersCollector.dispose(),this.targetResizeObserver.disconnect()},t.prototype.setDisable=function(e){this.listenersCollector.setDisabled(e)},t.prototype.setInvertedWheelZoom=function(e){this.invertedWheelZoom=e},t}(B),te=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new z,n.handleKeyUp=function(e){n.emit("keyUp",e.code)},n.target=t,n.addListeners(),n}return d(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(B),ne=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now()}return e.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(t," ms")}var n=(e/1e3).toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(n," s")},e}();function oe(e){setTimeout((function(){e()}),0)}var re=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.prototype.logDebug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,g(["log","debug"],e,!1))},t.prototype.logWarning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,g(["log","warn"],e,!1))},t.prototype.logError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,g(["log","error"],e,!1))},t}(B)),ie=function(e,r){var i=t(e);i.current=e;var a=t((function(){}));return n((function(){var e=j((function(){i.current()}),r);return a.current=e,function(){e.cancel()}}),[r]),o((function(){return a.current()}),[])},ae=function(e){function t(t){var n,o=this;return(o=e.call(this)||this).listenersCollector=new z,o.size={width:0,height:0},o.pixelRatio=1,o.maxPixelRatio=2,o.handleCanvasResizeObserver=function(e){o.resizeCanvas(e[0].contentRect)},o.resizeCanvas=function(e){var t=e.width,n=e.height;window.requestAnimationFrame((function(){o.setSize(t,n),o.emit("resize",t,n,o.getDevicePixelRatio())}))},o.getCanvasCenterPoint=function(){var e=o.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},o.container=t.container,o.canvas=t.canvas,o.maxPixelRatio=null!==(n=t.maxPixelRatio)&&void 0!==n?n:o.maxPixelRatio,o.canvasResizeObserver=new ResizeObserver(o.handleCanvasResizeObserver),o.canvasResizeObserver.observe(o.container),o.listenersCollector.add(window,"orientationchange",o.handleDeviceOrientationChange),o.setSize(o.container.clientWidth,o.container.clientHeight),o}return d(t,e),t.prototype.setSize=function(e,t){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(e,"px"),this.canvas.style.height="".concat(t,"px"),this.size.width=e*this.pixelRatio,this.size.height=t*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},t.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},t.prototype.getDevicePixelRatio=function(){return V(window.devicePixelRatio,1,this.maxPixelRatio)},t.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},t.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},t}(B),se=function(){function e(e){this.settings=e}return e.prototype.isReleaseMode=function(){return this.settings.mode===U.release},e.prototype.init=function(){return p(this,void 0,void 0,(function(){var e,t,n,o,r,i=this;return f(this,(function(a){switch(a.label){case 0:return[4,this.importModule()];case 1:e=a.sent(),t=e.default,a.label=2;case 2:return a.trys.push([2,4,,5]),n=this,[4,t({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:this.settings.webglVersion,bridge:this.settings.jsBridge,locateFile:function(e){return i.settings.locateFile.replace("{file}",e)}})];case 3:return n.instance=a.sent(),[3,5];case 4:throw o=a.sent(),new D("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerTypeEnum.Unset,mouse:this.instance.PRUserPointerTypeEnum.Mouse,touch:this.instance.PRUserPointerTypeEnum.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorTypeEnum.Auto.value]="auto",r[this.instance.PRCursorTypeEnum.Default.value]="default",r[this.instance.PRCursorTypeEnum.Pointer.value]="pointer",r[this.instance.PRCursorTypeEnum.Grab.value]="grab",r[this.instance.PRCursorTypeEnum.Grabbing.value]="grabbing",r),this.prototypeResizeModeToWASMMap={Fit:this.instance.PrototypeResizeModeWasmEnum.Fit,FillWidth:this.instance.PrototypeResizeModeWasmEnum.FillWidth,ActualSize:this.instance.PrototypeResizeModeWasmEnum.ActualSize},[2]}}))}))},e.prototype.makeWebGLContext=function(e,t,n){var o;void 0===t&&(t={}),void 0===n&&(n="srgb");var r=h({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},t),i=this.instance.GL.createContext(e,r);if(!i)throw new D("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");var a=null===(o=this.instance.GL.getContext(i))||void 0===o?void 0:o.GLctx;return a&&(a.getExtension("WEBGL_debug_renderer_info"),"srgb"!==n&&"drawingBufferColorSpace"in a&&(a.drawingBufferColorSpace=n)),i},e.prototype.createWebGLTextureFromImage=function(e,t){var n=this.instance.GL,o=n.getContext(t);if(!o)throw new Error("Unable to retrieve emscripten WebGL context from handle");var r=o.GLctx;if(!r)throw new Error("WebGL context is null");var i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);var a=n.getNewId(n.textures);return n.textures[a]=i,r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.bindTexture(r.TEXTURE_2D,null),a},e.prototype.destroyWebGLContext=function(e){var t;re.logDebug("Destroying WebGL context");var n=null===(t=this.instance)||void 0===t?void 0:t.GL.getContext(e);if(n){this.instance.GL.deleteContext(e);var o=n.GLctx.getExtension("WEBGL_lose_context");if(o)return o.loseContext(),re.logDebug("WebGL destroyed"),!0;re.logError("WEBGL_lose_context not available. Not possible to destroy WebGL context manually.")}else re.logError("WebGL context not found while trying to destroy it")},e.prototype.importModule=function(){return this.isReleaseMode()?import("./web-renderer-release-e6a9b58b.js"):import("./web-renderer-debug-042d411e.js")},e.prototype.mapToCSSCursor=function(e){return this.prCursorTypeToCSSCursorMap[e.value]},e.prototype.mapToPRPointerType=function(e){var t;return null!==(t=this.pointerTypeToWASMMap[e])&&void 0!==t?t:this.instance.PRUserPointerTypeEnum.Unset},e.prototype.mapPointerInfo=function(e){return h(h({},e),{type:this.mapToPRPointerType(e.type)})},e.prototype.mapResizeMode=function(e){return this.prototypeResizeModeToWASMMap[e]},e}();function ue(e){return new Promise((function(t,n){var o=new Image;o.onload=function(){t(o)},o.onerror=function(e){n(e)},o.src=e}))}var le=function(){function e(e,t,n){this.canvas=e,this.container=t,this.filePath=n,this.locateFile="/{file}",this.imagesURLFormat="",this.imagesURLMap={},this.fragmentsURLFormat="",this.fragmentsURLMap={},this.backgroundColor={r:1,g:1,b:1,a:1},this.colorSpace="sRGB",this.mode=U.release,this.showTilesBorders=!1,this.minimumZoomLevel=.01,this.maximumZoomLevel=5,this.preserveDrawingBuffer=!1,this.featureFlags=O,this.manualInitialization=!1,this.panBoundariesPadding=0,this.selectedArtboard=null,this.onlyShowFrameIds=[],this.focusedFrameIds=[],this.unfocusedOpacity=1,this.initialZoom=null,this.initialPan=null,this.showArtboardsDecorations=!0,this.invertedWheelZoom=!1}return e.FromSettings=function(t){return Object.assign(new e(t.canvas,t.container,t.filePath),Object.fromEntries(Object.entries(t).filter((function(e){return void 0!==e[1]}))))},e}(),ce={png:"image/png",jpg:"image/jpeg",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",raster:"binary/octet-stream"},de=function(){function e(e,t){var n=this;this.pendingExports=new Map,this._crashed=!1,this.handleError=function(){n._crashed=!0,n.pendingExports.forEach((function(e){e.reject("Export worker crashed")})),n.pendingExports.clear(),n.worker.terminate()},this.handleMessage=function(e){if("result"===e.data.type||"error"===e.data.type){var t=n.pendingExports.get(e.data.requestId);if(t)if(n.pendingExports.delete(e.data.requestId),"error"!==e.data.type){var o=new Blob([e.data.buffer],{type:ce[t.exportFormat]});t.resolve({blob:o,width:e.data.width,height:e.data.height,bytesPerPixel:e.data.bytesPerPixel})}else t.reject(e.data.message)}},this.worker=new Worker(e),this.ready=new Promise((function(e,t){var o=function(r){"ready"===r.data.type?(n.worker.removeEventListener("message",o),e()):"init-error"===r.data.type&&(n.worker.removeEventListener("message",o),t(new Error(r.data.message)))};n.worker.addEventListener("message",o)})),this.worker.addEventListener("message",this.handleMessage),this.worker.addEventListener("error",this.handleError);var o=t.offscreen;this.postMessage(h({type:"init"},t),[o])}return Object.defineProperty(e.prototype,"hasCrashed",{get:function(){return this._crashed},enumerable:!1,configurable:!0}),e.prototype.postMessage=function(e,t){this.worker.postMessage(e,null!=t?t:[])},e.prototype.exportNode=function(e,t,n,o,r){var i=this,a=X();return new Promise((function(s,u){var l=function(){i.pendingExports.delete(a)&&(i.postMessage({type:"cancelExport",requestId:a}),u(null==r?void 0:r.reason))},c=function(e){null==r||r.removeEventListener("abort",l),e()};i.pendingExports.set(a,{resolve:function(e){return c((function(){return s(e)}))},reject:function(e){return c((function(){return u(e)}))},exportFormat:n}),null==r||r.addEventListener("abort",l,{once:!0}),i.postMessage({type:"exportNode",requestId:a,layerPathHash:e,format:t,backingScale:o})}))},e.prototype.dispose=function(){this.pendingExports.forEach((function(e){e.reject("ExportWorkerClient disposed")})),this.pendingExports.clear(),this.postMessage({type:"dispose"}),this.worker.terminate()},e}();function he(e){var t=new Map;return e.forEach((function(e){var n=e.uuid,o=e.x,r=e.y,i=e.width,a=e.height;n&&t.set(n,{uuid:n,x:o,y:r,width:i,height:a})})),t}var pe,fe,ge,ve,me,ye,be,we,Ce,Pe,Se,Ee,Re,Me,Le,xe,Fe,We,Ie,Ae,Te,Ue,ke,De,Ge,Be,ze,Oe,Ze,Ne,He=function(){function e(e){this.host=e,this.held=null,this.split=null,this.splitApplied=!1,this.appliedSource=null,this.generation=0,this.hasFile=!1}return e.prototype.set=function(e){return!this.host.isDisposed()&&(this.hasFile?this.apply(e):(this.held=e,!0))},e.prototype.clear=function(){this.held=null,this.forgetSplit(),this.appliedSource=null,this.generation++,this.host.endComparison()},e.prototype.fileLoaded=function(){this.hasFile=!0,this.held&&this.apply(this.held)},e.prototype.dispose=function(){this.held=null,this.forgetSplit(),this.generation++},e.prototype.setSplit=function(e,t){var n=this.host.getComparison();return this.split=e,this.onSplitRefused=t,n?(this.splitApplied=n.setSplit(e),this.splitApplied||(this.split=null),this.splitApplied):(this.splitApplied=!1,!0)},e.prototype.setSplitFraction=function(e){var t;this.split&&(this.split=h(h({},this.split),{fraction:e})),null===(t=this.host.getComparison())||void 0===t||t.setSplitFraction(e)},e.prototype.clearSplit=function(){var e;this.forgetSplit(),null===(e=this.host.getComparison())||void 0===e||e.clearSplit()},e.prototype.getBounds=function(){var e,t;return null!==(t=null===(e=this.host.getComparison())||void 0===e?void 0:e.getPlacedBounds())&&void 0!==t?t:[]},e.prototype.apply=function(e){var t,n=e.source,o=e.patches;if(this.held=null,n===this.appliedSource)return null===(t=this.host.getComparison())||void 0===t||t.setPatches(o),this.applySplitIfNeeded(),!0;var r=this.host.startComparison();if(!r)return!1;var i=++this.generation;return r.setSource({file:n.file,fragments:n.fragments})?(this.splitApplied=!1,this.appliedSource=n,r.setPatches(o),this.applySplitIfNeeded(),this.handOver(n.images,i),!0):(this.appliedSource=null,!1)},e.prototype.applySplitIfNeeded=function(){var e;if(this.split&&!this.splitApplied){var t=this.host.getComparison();t&&(this.splitApplied=t.setSplit(this.split),this.splitApplied||(this.split=null,null===(e=this.onSplitRefused)||void 0===e||e.call(this),this.onSplitRefused=void 0))}},e.prototype.forgetSplit=function(){this.split=null,this.splitApplied=!1,this.onSplitRefused=void 0},e.prototype.handOver=function(e,t){return p(this,void 0,void 0,(function(){var n=this;return f(this,(function(o){switch(o.label){case 0:return[4,Promise.all(e.map((function(e){return p(n,void 0,void 0,(function(){var n,o,r;return f(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.host.decode(e)];case 1:return n=i.sent(),[3,3];case 2:return i.sent(),[2];case 3:return o=this.host.getComparison(),t!==this.generation||this.host.isDisposed()||!o?[2]:((r=this.host.createTexture(n))&&o.insertImage(e.id,r.texture,r.width,r.height),[2])}}))}))})))];case 1:return o.sent(),[2]}}))}))},e}();!function(e){e[e.Absent=0]="Absent",e[e.Boolean=1]="Boolean",e[e.Number=2]="Number",e[e.Text=3]="Text"}(pe||(pe={})),function(e){e[e.Added=0]="Added",e[e.Removed=1]="Removed",e[e.Modified=2]="Modified"}(fe||(fe={})),function(e){e[e.None=0]="None",e[e.Frame=1]="Frame",e[e.Section=2]="Section"}(ge||(ge={})),function(e){e[e.None=0]="None",e[e.Scale=1]="Scale",e[e.Width=2]="Width",e[e.Height=3]="Height"}(ve||(ve={})),function(e){e[e.None=0]="None",e[e.PNG=1]="PNG",e[e.JPG=2]="JPG",e[e.TIFF=3]="TIFF",e[e.WEBP=4]="WEBP",e[e.PDF=5]="PDF",e[e.EPS=6]="EPS",e[e.SVG=7]="SVG",e[e.HEIC=8]="HEIC"}(me||(me={})),function(e){e[e.Color=0]="Color",e[e.Gradient=1]="Gradient",e[e.Pattern=2]="Pattern"}(ye||(ye={})),function(e){e[e.Fit=0]="Fit",e[e.Fill=1]="Fill",e[e.Stretch=2]="Stretch",e[e.Tile=3]="Tile"}(be||(be={})),function(e){e[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.Angular=2]="Angular"}(we||(we={})),function(e){e[e.Rgb=0]="Rgb",e[e.Oklab=1]="Oklab",e[e.Oklch=2]="Oklch"}(Ce||(Ce={})),function(e){e[e.Center=0]="Center",e[e.Inside=1]="Inside",e[e.Outside=2]="Outside"}(Pe||(Pe={})),function(e){e[e.Butt=0]="Butt",e[e.Round=1]="Round",e[e.Square=2]="Square"}(Se||(Se={})),function(e){e[e.Miter=0]="Miter",e[e.Round=1]="Round",e[e.Bevel=2]="Bevel"}(Ee||(Ee={})),function(e){e[e.Motion=0]="Motion",e[e.Zoom=1]="Zoom",e[e.Background=2]="Background",e[e.Gaussian=3]="Gaussian"}(Re||(Re={})),function(e){e[e.Normal=0]="Normal",e[e.DestAtop=1]="DestAtop",e[e.Clear=2]="Clear",e[e.Source=3]="Source",e[e.Darken=4]="Darken",e[e.Multiply=5]="Multiply",e[e.ColorBurn=6]="ColorBurn",e[e.Lighten=7]="Lighten",e[e.Screen=8]="Screen",e[e.ColorDodge=9]="ColorDodge",e[e.Overlay=10]="Overlay",e[e.SoftLight=11]="SoftLight",e[e.HardLight=12]="HardLight",e[e.Difference=13]="Difference",e[e.Exclusion=14]="Exclusion",e[e.Hue=15]="Hue",e[e.Saturation=16]="Saturation",e[e.Color=17]="Color",e[e.Luminosity=18]="Luminosity",e[e.PlusLighter=19]="PlusLighter",e[e.PlusDarker=20]="PlusDarker"}(Me||(Me={})),function(e){e[e.Artboard=0]="Artboard",e[e.SymbolMaster=1]="SymbolMaster",e[e.SymbolInstance=2]="SymbolInstance",e[e.Hotspot=3]="Hotspot",e[e.Bitmap=4]="Bitmap",e[e.Group=5]="Group",e[e.Oval=6]="Oval",e[e.Polygon=7]="Polygon",e[e.Rectangle=8]="Rectangle",e[e.ShapeGroup=9]="ShapeGroup",e[e.ShapePath=10]="ShapePath",e[e.Star=11]="Star",e[e.Text=12]="Text",e[e.Triangle=13]="Triangle",e[e.Slice=14]="Slice",e[e.Section=15]="Section"}(Le||(Le={})),function(e){e[e.Angled=2]="Angled",e[e.InsideArc=4]="InsideArc",e[e.InsideSquare=3]="InsideSquare",e[e.Rounded=0]="Rounded",e[e.Smooth=1]="Smooth"}(xe||(xe={})),function(e){e[e.Lowercase=2]="Lowercase",e[e.None=0]="None",e[e.Uppercase=1]="Uppercase"}(Fe||(Fe={})),function(e){e[e.Center=1]="Center",e[e.Justified=3]="Justified",e[e.Left=0]="Left",e[e.Right=2]="Right"}(We||(We={})),function(e){e[e.Top=0]="Top",e[e.Middle=1]="Middle",e[e.Bottom=2]="Bottom"}(Ie||(Ie={})),function(e){e[e.LineThrough=2]="LineThrough",e[e.Underline=1]="Underline",e[e.None=0]="None"}(Ae||(Ae={})),function(e){e[e.Fixed=0]="Fixed",e[e.Fill=1]="Fill",e[e.Fit=2]="Fit",e[e.Relative=3]="Relative"}(Te||(Te={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical"}(Ue||(Ue={})),function(e){e[e.Start=0]="Start",e[e.Center=1]="Center",e[e.End=2]="End",e[e.SpaceBetween=3]="SpaceBetween",e[e.SpaceAround=4]="SpaceAround",e[e.SpaceEvenly=5]="SpaceEvenly"}(ke||(ke={})),function(e){e[e.None=0]="None",e[e.Start=1]="Start",e[e.Center=2]="Center",e[e.End=3]="End",e[e.Stretch=4]="Stretch"}(De||(De={})),function(e){e[e.FirstOnTop=0]="FirstOnTop",e[e.LastOnTop=1]="LastOnTop"}(Ge||(Ge={})),function(e){e[e.Unset=0]="Unset",e[e.Mouse=1]="Mouse",e[e.Touch=2]="Touch"}(Be||(Be={})),function(e){e[e.Auto=0]="Auto",e[e.Default=1]="Default",e[e.Pointer=2]="Pointer",e[e.Grab=3]="Grab",e[e.Grabbing=4]="Grabbing"}(ze||(ze={})),function(e){e[e.PNG=0]="PNG",e[e.JPG=1]="JPG",e[e.WEBP=2]="WEBP",e[e.PDF=4]="PDF",e[e.SVG=3]="SVG",e[e.RASTER=5]="RASTER"}(Oe||(Oe={})),function(e){e[e.Screen=0]="Screen",e[e.Overlay=1]="Overlay"}(Ze||(Ze={})),function(e){e[e.Fit=0]="Fit",e[e.FillWidth=1]="FillWidth",e[e.ActualSize=2]="ActualSize"}(Ne||(Ne={}));var je=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"IDLE"},n.appliedOnlyShowFrameIds=[],n.comparison=new He({getComparison:function(){var e;return null===(e=n.pageCanvasWasm)||void 0===e?void 0:e.getComparison()},startComparison:function(){var e;return null===(e=n.pageCanvasWasm)||void 0===e?void 0:e.startComparison()},endComparison:function(){var e;return null===(e=n.pageCanvasWasm)||void 0===e?void 0:e.endComparison()},isDisposed:function(){return n.disposed},decode:function(e){var t=e.bytes,o=e.type;return p(n,void 0,void 0,(function(){var e;return f(this,(function(n){switch(n.label){case 0:e=URL.createObjectURL(new Blob([t],{type:o})),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,ue(e)];case 2:return[2,n.sent()];case 3:return URL.revokeObjectURL(e),[7];case 4:return[2]}}))}))},createTexture:function(e){return n.wasmModule?{texture:n.wasmModule.createWebGLTextureFromImage(e,n.webglCtxHandle),width:e.width,height:e.height}:void 0}}),n.disposed=!1,n.cameraAnimator=new C((function(e){return n.applyCameraState(e)})),n.dimAnimator=new m,n.appliedUnfocusedOpacity=1,n.handleCanvasResize=function(e,t,o){var r;null===(r=n.pageCanvasWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;n.cameraAnimator.cancel(),null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.cameraAnimator.cancel(),n.wasmModule&&(null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(e.x,e.y,n.wasmModule.mapPointerInfo(t)))},n.handlePointerDownEvent=function(e){var t;n.cameraAnimator.cancel(),n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(e)))},n.settings=le.FromSettings(t),re.logDebug("CanvasRenderer JS constructed with settings:",n.settings),n.gestureManager=new ee(n.settings.container,n.settings.invertedWheelZoom),n.canvasManager=new ae({container:n.settings.container,canvas:n.settings.canvas}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return d(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,A()];case 1:return e=t.sent(),this.deviceInfo=h(h({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.detectWebGLVersion=function(){this.webglVersion=q(this.deviceInfo),re.logDebug("Using WebGL ".concat(this.webglVersion))},t.prototype.init=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this.traceFirstPaint=new ne("FirstPaint"),this.setStatus({type:"INITIALIZING"}),[4,this.collectAndEmitDeviceInfo()];case 1:t.sent(),this.detectWebGLVersion(),t.label=2;case 2:return t.trys.push([2,6,,7]),[4,this.initWasmModule()];case 3:return t.sent(),[4,this.initCanvasRendererWasm()];case 4:return t.sent(),[4,this.setFile(this.settings.filePath)];case 5:return t.sent(),this.comparison.fileLoaded(),this.settings.selectedArtboard&&this.selectArtboard(this.settings.selectedArtboard),this.settings.onlyShowFrameIds.length>0&&this.setOnlyShowFrames(this.settings.onlyShowFrameIds),this.settings.focusedFrameIds.length>0&&this.settings.unfocusedOpacity<1&&this.setUnfocusedOpacity(this.settings.focusedFrameIds,this.settings.unfocusedOpacity),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof D?e:new D("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.setInitialCameraState=function(){var e,t,n,o=null!==this.settings.initialZoom,r=null!==this.settings.initialPan;if(o||r)o&&this.setZoom(this.settings.initialZoom||1),r&&this.setPan((null===(e=this.settings.initialPan)||void 0===e?void 0:e.x)||0,(null===(t=this.settings.initialPan)||void 0===t?void 0:t.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport);else{var i=this.findFocusedNodeIdentifier();void 0!==i?this.zoomToFitNode(i):this.zoomToFit()}},t.prototype.findFocusedNodeIdentifier=function(){var e,t,n=this.settings,o=n.focusedFrameIds,r=n.unfocusedOpacity;if(!(1!==o.length||r>=1)){var i=o[0];return null===(t=null===(e=g(g([],this.getPRFileAllFrames(),!0),this.getPRFileSections(),!0).find((function(e){return e.objectId===i})))||void 0===e?void 0:e.getNode())||void 0===t?void 0:t.getIdentifier()}},t.prototype.startRendering=function(){var e;this.traceInitialRender=new ne("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.pageCanvasWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){re.logDebug("[C++] ".concat(e))},logWarning:function(e){re.logWarning("[C++] ".concat(e))},logError:function(e){re.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t,n){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t].replace(":format",n):e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t).replace(":format",n):(re.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):(re.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(){var t=e.getPan();e.emit("cameraPanChange",(null==t?void 0:t.x)||0,(null==t?void 0:t.y)||0)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onLayerClick:function(t){e.emit("layerClick",t)},onLayerMouseHoverChange:function(t){e.emit("layerMouseHoverChange",t)},onSceneChange:function(){e.emit("sceneChange")},onComparePatchesChange:function(){e.emit("comparePatchesChange")},onFragmentLoad:function(t){e.emit("fragmentLoad",t)}}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l,c,d,h;return f(this,(function(p){switch(p.label){case 0:if(!this.wasmModule)return[2];if(this.disposed)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(t.data.contentType)?(i=new Blob([t.data.buffer]),[4,ue(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),this.wasmModule?(s=this.wasmModule.createWebGLTextureFromImage(a,this.webglCtxHandle),n.buffer=new Uint8Array(0),n.isWebGLTexture=!0,n.emscriptenWebGLTextureHandle=s,n.width=a.width,n.height=a.height,[3,4]):[2];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return re.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(l=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==l?l:500,statusText:null!==(d=null===(c=t.data.error)||void 0===c?void 0:c.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=t.data.contentType)&&void 0!==h?h:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:0,width:0,height:0}),[3,7];case 6:return[3,7];case 7:return this.fetchWorker.removeEventListener("message",r),[2]}}))}))};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initWasmModule=function(){var e;return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new ne("WasmModuleDownload"),this.wasmModule=new se({mode:this.settings.mode,locateFile:this.settings.locateFile,jsBridge:this.createJSBridge(),featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion}),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),re.logDebug(t.printMeasurement()),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.initCanvasRendererWasm=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){if(this.disposed)return[2];try{if(!this.wasmModule)throw Error("WASM module not initialized");this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:this.webglVersion},T(this.settings.colorSpace)),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.pageCanvasWasm=new this.wasmModule.instance.CanvasRendererWasm(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(e){throw new D("WASM_ERROR","An error occurred while trying to create the wasm object.",e)}if(!this.pageCanvasWasm)return[2];if(!(e=this.pageCanvasWasm.getUserEventsCollector()))throw new D("WASM_ERROR","An error occurred while trying to create the user events collector");return this.userEventsCollectorWasm=e,this.pageCanvasWasm.setShowArtboardsDecorations(this.settings.showArtboardsDecorations),this.pageCanvasWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.pageCanvasWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.pageCanvasWasm.setPanBoundariesPadding(this.settings.panBoundariesPadding),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setAssetSources=function(e){var t=e.imagesURLFormat,n=e.imagesURLMap,o=e.fragmentsURLFormat,r=e.fragmentsURLMap;this.settings.imagesURLFormat=null!=t?t:"",this.settings.imagesURLMap=null!=n?n:{},this.settings.fragmentsURLFormat=null!=o?o:"",this.settings.fragmentsURLMap=null!=r?r:{}},t.prototype.setComparison=function(e){return this.comparison.set(e)},t.prototype.clearComparison=function(){this.comparison.clear()},t.prototype.setSplit=function(e,t){return this.comparison.setSplit(e,t)},t.prototype.setSplitFraction=function(e){this.comparison.setSplitFraction(e)},t.prototype.clearSplit=function(){this.comparison.clearSplit()},t.prototype.getComparePatchBounds=function(){return this.comparison.getBounds()},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.pageCanvasWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(re.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),re.logDebug(this.traceFirstPaint.printMeasurement()),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;(null===(e=this.wasmModule)||void 0===e?void 0:e.destroyWebGLContext(this.webglCtxHandle))||re.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(e){if(this.pageCanvasWasm)if(this.cameraAnimator.cancel(),e){var t=this.getCameraState();this.pageCanvasWasm.scaleDocumentToFit();var n=this.getCameraState();this.applyCameraState(t),this.cameraAnimator.animate(t,n,e)}else this.pageCanvasWasm.scaleDocumentToFit()},t.prototype.getCameraState=function(){return{pan:this.getPan(),zoom:this.getZoom()}},t.prototype.applyCameraState=function(e){var t=e.pan,n=e.zoom;this.applyZoom(n),this.applyPan(t.x,t.y)},t.prototype.moveCameraTo=function(e,t){this.pageCanvasWasm&&(this.cameraAnimator.cancel(),t?this.cameraAnimator.animate(this.getCameraState(),e,t):this.applyCameraState(e))},t.prototype.cancelCameraAnimation=function(){this.cameraAnimator.cancel()},t.prototype.zoomToFitNode=function(e,t,n,o){if(void 0===t&&(t=.82),void 0===n&&(n=!1),this.pageCanvasWasm)if(this.cameraAnimator.cancel(),o){var r=this.getCameraState();this.pageCanvasWasm.scaleNodeToFit(e,t,n);var i=this.getCameraState();this.applyCameraState(r),this.cameraAnimator.animate(r,i,o)}else this.pageCanvasWasm.scaleNodeToFit(e,t,n)},t.prototype.zoomToFitRect=function(e,t,n,o){var r=this;if(void 0===t&&(t=.82),void 0===n&&(n=!1),this.pageCanvasWasm){this.cameraAnimator.cancel();var i=function(){var o;return null===(o=r.pageCanvasWasm)||void 0===o?void 0:o.scaleRectToFit(e.x,e.y,e.width,e.height,t,n)};if(o){var a=this.getCameraState();i();var s=this.getCameraState();this.applyCameraState(a),this.cameraAnimator.animate(a,s,o)}else i()}},t.prototype.loadAllFragments=function(){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.loadAllFragments()},t.prototype.setFile=function(e){return p(this,void 0,void 0,(function(){var t=this;return f(this,(function(n){return this.disposed?[2]:(this.setStatus({type:"LOADING_FILE"}),this.appliedOnlyShowFrameIds=[],[2,new Promise((function(n,o){var r;null===(r=t.pageCanvasWasm)||void 0===r||r.setFile(e,(function(e,o,r){t.setStatus({type:"FILE_READY"});var i="".concat(e,"-v").concat("15.17.0");t.emit("fileReady",i,o,r),n()}),(function(){return o(new D("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()):"")}),re.logError(e),e.cause&&re.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(re.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getPRFileCachedData=function(){var e;if(!this.pageCanvasWasm)return null;if((null===(e=this.prFileHandle)||void 0===e?void 0:e.filePath)!==this.settings.filePath){var t=this.pageCanvasWasm.getPRFile();this.prFileHandle={handle:t,filePath:this.settings.filePath,artboards:J(t.getFrames()),allFrames:J(t.getAllFrames()),sections:J(t.getSections())}}return this.prFileHandle},t.prototype.getPRFile=function(){var e;return null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.handle},t.prototype.releasePRFileHandle=function(){var e,t;null===(t=null===(e=this.prFileHandle)||void 0===e?void 0:e.handle)||void 0===t||t.delete(),this.prFileHandle=void 0},t.prototype.getRootNodeExtent=function(){var e,t,n;return null!==(n=null===(t=null===(e=this.getPRFile())||void 0===e?void 0:e.getRootNode())||void 0===t?void 0:t.getAbsoluteExtent())&&void 0!==n?n:null},t.prototype.getSceneRootNode=function(){var e,t;return null!==(t=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getSceneRootNode())&&void 0!==t?t:null},t.prototype.getPRFileArtboards=function(){var e,t;return null!==(t=null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.artboards)&&void 0!==t?t:[]},t.prototype.getPRFileAllFrames=function(){var e,t;return null!==(t=null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.allFrames)&&void 0!==t?t:[]},t.prototype.getPRFileSections=function(){var e,t;return null!==(t=null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.sections)&&void 0!==t?t:[]},t.prototype.getArtboardAtPosition=function(e,t){if(!this.pageCanvasWasm)return null;for(var n=this.getPRFileAllFrames(),o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(e-o.x)/r,a=(t-o.y)/r,s=0,u=n;s<u.length;s++){var l=u[s],c=l.bounds.x+l.bounds.width,d=l.bounds.y+l.bounds.height;if(i>=l.bounds.x&&a>=l.bounds.y&&i<=c&&a<=d)return l.getNode()}return null},t.prototype.mapRelativePositionToCameraPosition=function(e,t){var n;return null===(n=this.pageCanvasWasm)||void 0===n?void 0:n.mapRelativePositionToCameraPosition(e,t)},t.prototype.getNodeAtPosition=function(e,t){return this.pageCanvasWasm?this.pageCanvasWasm.getNodeAtPosition(e,t):null},t.prototype.getPanAtPosition=function(e,t){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),r=e/o,i=t/o;return{x:n.x-r,y:n.y-i}},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){this.cameraAnimator.cancel(),this.applyZoom(e,t)},t.prototype.applyZoom=function(e,t){var n,o=null!=t?t:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(e,o.x,o.y)},t.prototype.getPan=function(){var e,t,n=this.getRootNodeExtent();if(!n)return{x:0,y:0};var o=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getPan(),r=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom();return o&&r?{x:o.x/r+n.x,y:o.y/r+n.y}:{x:0,y:0}},t.prototype.getZoom=function(){var e;return(null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom())||0},t.prototype.setPan=function(e,t,n){void 0===n&&(n=!1),this.cameraAnimator.cancel(),this.applyPan(e,t,n)},t.prototype.applyPan=function(e,t,n){var o;void 0===n&&(n=!1);var r=this.getRootNodeExtent();if(r){var i=e,a=t,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);i+=this.canvasManager.size.width/u,a+=this.canvasManager.size.height/u}var l=(i-r.x)*s,c=(a-r.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(l,c)}},t.prototype.selectArtboard=function(e){var t;this.pageCanvasWasm&&(this.settings.selectedArtboard=e,null===(t=this.pageCanvasWasm)||void 0===t||t.selectArtboard(null!=e?e:""))},t.prototype.setUnfocusedOpacity=function(e,t,n){var o,r,i,a=this,s=Array.from(new Set(e)),u=this.settings.unfocusedOpacity===t&&this.settings.focusedFrameIds.length===s.length&&this.settings.focusedFrameIds.every((function(e){return s.includes(e)}));if(this.settings.focusedFrameIds=s,this.settings.unfocusedOpacity=t,this.pageCanvasWasm)if(!u||this.dimAnimator.isAnimating){this.dimAnimator.cancel();var l=function(e){var t;a.appliedUnfocusedOpacity=e,null===(t=a.pageCanvasWasm)||void 0===t||t.setUnfocusedOpacity(s,e)},c=this.appliedUnfocusedOpacity;if(this.emit("unfocusedChange",{frameIds:s,opacity:t}),!n||c===t)return l(t),void(null===(i=null==n?void 0:n.onComplete)||void 0===i||i.call(n));this.dimAnimator.run(n,y,(function(e){return l(c+(t-c)*e)}))}else null===(r=null==n?void 0:n.onComplete)||void 0===r||r.call(n);else null===(o=null==n?void 0:n.onComplete)||void 0===o||o.call(n)},t.prototype.getUnfocusedOpacity=function(){return this.appliedUnfocusedOpacity},t.prototype.getFocusedFrameIds=function(){return this.settings.focusedFrameIds},t.prototype.setOnlyShowFrames=function(e){var t=Array.from(new Set(e)),n=this.appliedOnlyShowFrameIds.length===t.length&&this.appliedOnlyShowFrameIds.every((function(e){return t.includes(e)}));this.settings.onlyShowFrameIds=t,this.pageCanvasWasm&&(n||(this.pageCanvasWasm.setOnlyShowFrames(t),this.appliedOnlyShowFrameIds=t,this.emit("onlyShowFramesChange",t)))},t.prototype.getOnlyShowFrameIds=function(){return this.settings.onlyShowFrameIds},t.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.initExportWorker=function(){var e=new OffscreenCanvas(4096,4096);this.exportWorkerClient=new de(this.settings.locateFile.replace("{file}","export-worker.js"),{offscreen:e,locateFile:this.settings.locateFile,mode:this.settings.mode,featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion,fileURL:this.settings.filePath,imagesURLFormat:this.settings.imagesURLFormat,imagesURLMap:this.settings.imagesURLMap,fragmentsURLFormat:this.settings.fragmentsURLFormat,fragmentsURLMap:this.settings.fragmentsURLMap})},t.prototype.exportNode=function(e,t,n){var o,r;return p(this,void 0,void 0,(function(){var i,a,s,u,l,c;return f(this,(function(d){switch(d.label){case 0:if(this.disposed)throw new Error("CanvasRenderer has been disposed.");if(null==n?void 0:n.aborted)throw n.reason;if(i=t.format.toUpperCase(),void 0===(a=Oe[i]))throw new Error("Unsupported export format: ".concat(t.format));return this.exportWorkerClient&&!this.exportWorkerClient.hasCrashed||this.initExportWorker(),[4,(s=this.exportWorkerClient).ready];case 1:if(d.sent(),null==n?void 0:n.aborted)throw n.reason;if(!(u=null===(r=null===(o=this.pageCanvasWasm)||void 0===o?void 0:o.getPRFile())||void 0===r?void 0:r.findByIdentifier(e)))throw new Error("Node with identifier ".concat(e," not found"));if("string"!=typeof(l=u.getLayerPathHash())||""===l)throw new Error("Node with identifier ".concat(e," has empty layerPathHash"));d.label=2;case 2:return d.trys.push([2,4,,5]),[4,s.exportNode(l,a,t.format,t.backingScale,n)];case 3:return[2,d.sent()];case 4:throw c=d.sent(),s.hasCrashed&&(this.exportWorkerClient=void 0),c;case 5:return[2]}}))}))},t.prototype.dispose=function(){var e,t,n,o,r;try{this.cameraAnimator.cancel(),this.dimAnimator.cancel(),this.disposeFetchWorker(),this.disposed=!0,this.comparison.dispose(),this.detachAllListeners(),this.releasePRFileHandle(),null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.pageCanvasWasm)||void 0===t||t.stopRenderLoop(),null===(n=this.pageCanvasWasm)||void 0===n||n.delete(),null===(o=this.renderTarget)||void 0===o||o.delete(),this.pageCanvasWasm=void 0,this.wasmModule=void 0,null===(r=this.exportWorkerClient)||void 0===r||r.dispose(),this.exportWorkerClient=void 0}catch(e){this.fail(new D("ERROR","Unexpected exception while disposing the wasm object",e))}},t}(B),_e=r(void 0),Ve=r(void 0),qe=r(void 0),Je=r(void 0),Ke=r(void 0),Ye=r("auto"),$e=r(void 0),Xe=function(){var e=i($e);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},Qe=function(e,t){switch(t.type){case"on-status":return h(h({},e),{status:t.status});case"on-zoom":return h(h({},e),{zoom:t.zoom});case"on-pan":return h(h({},e),{pan:t.pan});case"dispose":return h(h({},e),{status:{type:"DISPOSED"},zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return h(h({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return h(h({},e),{isCameraZooming:!1});case"on-camera-move-start":return h(h({},e),{isCameraMoving:!0});case"on-camera-move-end":return h(h({},e),{isCameraMoving:!1});case"on-cursor-change":return h(h({},e),{cursor:t.cursor});default:return e}},et=function(n){var r=t(null),i=t(null),u=a(Qe,{pan:null,zoom:null,status:{type:"IDLE"},isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),l=u[0],c=l.status,d=l.zoom,p=l.pan,f=l.isCameraZooming,g=l.isCameraMoving,v=l.cursor,m=u[1],y=o((function(e){return m({type:"on-zoom",zoom:e})}),[]),b=o((function(e,t){return m({type:"on-pan",pan:{x:e,y:t}})}),[]),w=o((function(e){m({type:"on-status",status:e})}),[]),C=o((function(){return m({type:"on-camera-zoom-start"})}),[]),P=o((function(){return m({type:"on-camera-zoom-end"})}),[]),S=o((function(){return m({type:"on-camera-move-start"})}),[]),E=o((function(){return m({type:"on-camera-move-end"})}),[]),R=o((function(e){return m({type:"on-cursor-change",cursor:e})}),[]),M=o((function(){if(r.current){var e=r.current.getPan();m({type:"on-pan",pan:e})}}),[]),L=o((function(){var e=r.current;e&&(re.logDebug("Provider dispose"),e.off("status",w),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.off("cameraZoomStart",C),e.off("cameraZoomEnd",P),e.off("cameraMoveStart",S),e.off("cameraMoveEnd",E),e.off("cursorChange",R),e.off("sceneChange",M),e.dispose(),r.current=null,m({type:"dispose"}))}),[w,b,y,C,P,S,E,R,M]),x=o((function(e,t,n){if(""!==e&&t&&n&&i.current){re.logDebug("Provider init");var o=new je(h(h({},i.current),{filePath:e,container:n,canvas:t,manualInitialization:!0}));o.on("status",w),o.on("cameraZoomChange",y),o.on("cameraPanChange",b),o.on("cameraZoomStart",C),o.on("cameraZoomEnd",P),o.on("cameraMoveStart",S),o.on("cameraMoveEnd",E),o.on("cursorChange",R),o.on("sceneChange",M),r.current=o,o.init()}}),[w,y,b,C,P,S,E,R,M]),F=o((function(e){var t,n,o,a;re.logDebug("Provider setSettings"),e.backgroundColor&&(null===(t=r.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),null===(n=r.current)||void 0===n||n.gestureManager.setInvertedWheelZoom(e.invertedWheelZoom||!1),null===(o=r.current)||void 0===o||o.selectArtboard(e.selectedArtboard||null),null===(a=r.current)||void 0===a||a.setAssetSources({imagesURLFormat:e.imagesURLFormat,imagesURLMap:e.imagesURLMap,fragmentsURLFormat:e.fragmentsURLFormat,fragmentsURLMap:e.fragmentsURLMap}),i.current=e}),[]),W=o((function(){return r.current}),[]),I=s((function(){return{dispose:L,init:x,setSettings:F,getInstance:W,dispatch:m}}),[L,x,F,W]);return e.createElement($e.Provider,{value:I},e.createElement(_e.Provider,{value:c},e.createElement(Ve.Provider,{value:d},e.createElement(Ke.Provider,{value:p},e.createElement(qe.Provider,{value:f},e.createElement(Je.Provider,{value:g},e.createElement(Ye.Provider,{value:v},n.children)))))))},tt=function(e,t){var n=(0,Xe().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},nt=function(){var e=i(_e);if(void 0===e)throw Error("useStatus must be used within a provider");return e},ot=function(){var e=i(Ve);if(void 0===e)throw Error("useZoom must be used within a provider");return e},rt=function(){var e=i(Ke);if(void 0===e)throw Error("usePan must be used within a provider");return e},it=function(){var e=i(Ye);if(void 0===e)throw Error("useCursor must be used within a provider");return e},at=function(){var e=i(qe);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},st=function(){var e=i(Je);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},ut=function(){var e=(0,Xe().getInstance)(),t=nt();return s((function(){return e&&"READY"===t.type?e.getPRFile():null}),[e,t])},lt=function(){var e=(0,Xe().getInstance)(),t=nt();return s((function(){return e&&"READY"===t.type?e.getPRFileArtboards():null}),[e,t])},ct=function(){var e=(0,Xe().getInstance)(),t=nt();return s((function(){return e&&"READY"===t.type?e.getPRFileAllFrames():null}),[e,t])},dt=function(){var e=(0,Xe().getInstance)(),t=nt();return s((function(){return e&&"READY"===t.type?e.getPRFileSections():null}),[e,t])},ht=function(){var e=(0,Xe().getInstance)(),n=nt(),r=l(0),i=r[0],a=r[1],u=t(null),c=o((function(){var t,n,o=null!==(n=null===(t=null==e?void 0:e.getSceneRootNode())||void 0===t?void 0:t.getIdentifier())&&void 0!==n?n:null;o!==u.current&&(u.current=o,a((function(e){return e+1})))}),[e]);return tt("sceneChange",c),s((function(){return e&&"READY"===n.type?e.getSceneRootNode():null}),[e,n,i])},pt=function(){var e,t,n,o,r=ut(),i=l(null),a=i[0],c=i[1],d=ie((function(){c((function(e){var t,n,o,i=null!==(o=null===(n=null===(t=Q(r))||void 0===t?void 0:t.getRootNode())||void 0===n?void 0:n.getAbsoluteExtent())&&void 0!==o?o:null;return(null==e?void 0:e.width)===(null==i?void 0:i.width)&&(null==e?void 0:e.height)===(null==i?void 0:i.height)&&(null==e?void 0:e.x)===(null==i?void 0:i.x)&&(null==e?void 0:e.y)===(null==i?void 0:i.y)?e:i}))}),16);tt("sceneChange",d),u((function(){d()}),[d]);var h=null!==(e=null==a?void 0:a.x)&&void 0!==e?e:0,p=null!==(t=null==a?void 0:a.y)&&void 0!==t?t:0,f=null!==(n=null==a?void 0:a.width)&&void 0!==n?n:0,g=null!==(o=null==a?void 0:a.height)&&void 0!==o?o:0;return s((function(){return{x:h,y:p,width:f,height:g}}),[h,p,f,g])},ft=function(){var e=(0,Xe().getInstance)();return o((function(t){null==e||e.setZoom(t)}),[e])},gt=function(){var e=ft(),t=ot();return o((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},vt=function(){var e=ft(),t=ot();return o((function(){"number"==typeof t&&e(t/2)}),[e,t])},mt=function(){var e=(0,Xe().getInstance)();return o((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},yt=function(){var e=(0,Xe().getInstance)();return o((function(){null==e||e.zoomToFit()}),[e])},bt=function(){var e=(0,Xe().getInstance)();return o((function(t,n,o){null==e||e.zoomToFitNode(t,n,o)}),[e])},wt=function(){var e=(0,Xe().getInstance)();return o((function(t,n,o,r){null==e||e.zoomToFitRect(t,n,o,r)}),[e])},Ct=function(){var e=(0,Xe().getInstance)();return o((function(){null==e||e.looseWebGLContext()}),[e])},Pt=function(){var e=(0,Xe().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return f(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},St=function(){var e=(0,Xe().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return f(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getNodeAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Et=function(){var e=(0,Xe().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return f(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Rt=function(){var e=(0,Xe().getInstance)();return o((function(t){null==e||e.setIsCameraLocked(t)}),[e])},Mt=function(){var e=(0,Xe().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},Lt=function(e){return!0===e?{}:!1===e||void 0===e?void 0:e},xt=function(){var e=(0,Xe().getInstance)(),n=ct(),r=dt(),i=l(null),a=i[0],s=i[1],c=t({artboards:n,sections:r});c.current={artboards:n,sections:r};var d=o((function(){var t,n,o=null!==(t=null==e?void 0:e.getFocusedFrameIds())&&void 0!==t?t:[];if(1===o.length)return o[0];var r=null!==(n=null==e?void 0:e.getOnlyShowFrameIds())&&void 0!==n?n:[];return 1===r.length?r[0]:null}),[e]),p=o((function(){s(d())}),[d]);u(p,[p]),tt("onlyShowFramesChange",p),tt("unfocusedChange",p);var f=o((function(t,n){var o;void 0===n&&(n={});var r=Lt(n.animate),i=n.dim,a=void 0!==i,u=null===t?[]:[t],l=(null!==(o=null==e?void 0:e.getFocusedFrameIds())&&void 0!==o?o:[]).length>0,p=null===t||a===l;if(t!==d()||!p){s(t),a?null==e||e.setOnlyShowFrames([]):null==e||e.setUnfocusedOpacity([],1);var f=function(o){var i,a,s=function(){var e;null==o||o(),null===(e=null==r?void 0:r.onComplete)||void 0===e||e.call(r)};if(n.camera&&null!==t)return null==e||e.moveCameraTo(n.camera,r&&h(h({},r),{onComplete:s})),void(r||s());if(null===t)return null==e||e.zoomToFit(r&&h(h({},r),{onComplete:s})),void(r||s());var u=c.current,l=u.artboards,d=u.sections,p=null===(a=null===(i=g(g([],null!=l?l:[],!0),null!=d?d:[],!0).find((function(e){return e.objectId===t})))||void 0===i?void 0:i.getNode())||void 0===a?void 0:a.getIdentifier();void 0!==p?(null==e||e.zoomToFitNode(p,void 0,void 0,r&&h(h({},r),{onComplete:s})),r||s()):s()};if(a)return null==e||e.setUnfocusedOpacity(u,null===t?1:i,r&&{onComplete:function(){return f()}}),void(r||f());var v=function(){return null==e?void 0:e.setOnlyShowFrames(u)};r||v(),f(r?v:void 0)}}),[e,d]);return[a,f]},Ft=xt,Wt=function(){var e=(0,Xe().getInstance)(),n=ut(),r=t(null);return u((function(){return function(){var e;null===(e=r.current)||void 0===e||e.abort()}}),[]),o((function(t,o){var i;return e&&n?(null===(i=r.current)||void 0===i||i.abort(),r.current=new AbortController,e.exportNode(t,o,r.current.signal)):Promise.reject("WebRenderer instance not ready")}),[e,n])},It=function(){var e=(0,Xe().getInstance)();return o((function(t,n,o){void 0===o&&(o={}),null==e||e.setUnfocusedOpacity(t,n,Lt(o.animate))}),[e])},At=function(){var e=Xe().getInstance,t=o((function(t){var n,o;return null!==(o=null===(n=e())||void 0===n?void 0:n.setComparison(t))&&void 0!==o&&o}),[e]),n=o((function(){var t;return null===(t=e())||void 0===t?void 0:t.clearComparison()}),[e]),r=o((function(){var t,n;return he(null!==(n=null===(t=e())||void 0===t?void 0:t.getComparePatchBounds())&&void 0!==n?n:[])}),[e]);return s((function(){return{set:t,clear:n,getBounds:r}}),[t,n,r])},Tt=function(){var e=Xe().getInstance,t=o((function(t,n){var o,r;return null!==(r=null===(o=e())||void 0===o?void 0:o.setSplit(t,n))&&void 0!==r&&r}),[e]),n=o((function(t){var n;return null===(n=e())||void 0===n?void 0:n.setSplitFraction(t)}),[e]),r=o((function(){var t;return null===(t=e())||void 0===t?void 0:t.clearSplit()}),[e]);return s((function(){return{set:t,setFraction:n,clear:r}}),[t,n,r])},Ut=function(){var e=Xe().getInstance,t=o((function(){var t,n;return he(null!==(n=null===(t=e())||void 0===t?void 0:t.getComparePatchBounds())&&void 0!==n?n:[])}),[e]),n=l(t),r=n[0],i=n[1],a=o((function(){var e=t();i((function(t){return function(e,t){if(e.size!==t.size)return!1;var n=!0;return e.forEach((function(e,o){var r=t.get(o);r&&e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height||(n=!1)})),n}(t,e)?t:e}))}),[t]),s=e();return u(a,[a,s]),tt("comparePatchesChange",a),r};function kt(e){var n=t(e);n.current=e;var r=o((function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];n.current.apply(n,g([e],t,!1))}),[]);u((function(){return re.on("log",r),function(){re.off("log",r)}}),[r])}var Dt,Gt=function(){var e=Xe().getInstance;return o((function(){var t=e();t&&t.loadAllFragments()}),[e])},Bt={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},zt={position:"absolute",top:0,left:0},Ot=function(n){var r=n.filePath,i=n.locateFile,a=n.imagesURLFormat,c=n.imagesURLMap,d=n.fragmentsURLFormat,p=n.fragmentsURLMap,f=n.backgroundColor,g=n.mode,v=n.showTilesBorders,m=n.minimumZoomLevel,y=n.maximumZoomLevel,b=n.preserveDrawingBuffer,w=n.panBoundariesPadding,C=n.initialPan,P=n.initialZoom,S=n.children,E=n.containerProps,R=n.canvasProps,M=n.featureFlags,L=n.rootEntityUUID,x=n.selectedArtboard,F=n.showArtboardsDecorations,W=n.invertedWheelZoom,I=n.colorSpace,A=null!=L?L:x,T=t(null),U=t(null),k=l(!1),D=k[0],G=k[1],B=o((function(){return G(!0)}),[]),z=Xe(),O=z.dispose,Z=z.init,N=z.setSettings,H=it(),j=nt(),_=t(!1);tt("allImagesReady",B),u((function(){_.current||null==x||null!=L||(_.current=!0,re.logWarning("CanvasRendererReact: the `selectedArtboard` prop is deprecated, use `rootEntityUUID` instead."))}),[x,L]),u((function(){return re.logDebug("CanvasRenderer mounted"),function(){return re.logDebug("CanvasRenderer unmounted")}}),[]),u((function(){N({locateFile:i,imagesURLFormat:a,imagesURLMap:c,fragmentsURLFormat:d,fragmentsURLMap:p,backgroundColor:f,mode:g,showTilesBorders:v,minimumZoomLevel:m,maximumZoomLevel:y,preserveDrawingBuffer:b,panBoundariesPadding:w,initialPan:C,initialZoom:P,featureFlags:M,selectedArtboard:A,showArtboardsDecorations:F,invertedWheelZoom:W,colorSpace:I})}),[N,i,a,c,d,p,f,g,v,m,y,b,w,C,P,M,A,F,W,I]),u((function(){if(r)return Z(r,T.current,U.current),function(){O()}}),[O,Z,r]);var V=s((function(){var e;return null!==(e=n.cursor)&&void 0!==e?e:H}),[n.cursor,H]),q=s((function(){return h(h({},Bt),{cursor:V})}),[V]);return e.createElement("div",h({},E,{ref:U,style:q}),r&&e.createElement("canvas",h({},R,{key:r,ref:T,"data-sketchweb-all-images-ready":D,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==j?void 0:j.type.toLowerCase())||"null"),style:zt})),"READY"===(null==j?void 0:j.type)&&S)};function Zt(e){var t=J(e);return e.delete(),t}function Nt(e){switch(e.kind.value){case pe.Boolean:return e.boolean;case pe.Number:return e.number;case pe.Text:return e.text;default:return null}}var Ht=((Dt={})[fe.Added]="added",Dt[fe.Removed]="removed",Dt[fe.Modified]="modified",Dt),jt=function(e){var t;return null!==(t=Ht[e.value])&&void 0!==t?t:"modified"};function _t(e){return Zt(e).map((function(e){return{property:e.property,before:Nt(e.before),after:Nt(e.after)}}))}function Vt(e){var t=function(e){return{x:e.x,y:e.y}};return{topLeft:t(e.topLeft),topRight:t(e.topRight),bottomRight:t(e.bottomRight),bottomLeft:t(e.bottomLeft)}}function qt(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}var Jt=function(e){return""===e?null:e};function Kt(e){return Zt(e).filter((function(e){return void 0!==e}))}function Yt(e){return Zt(e).map((function(e){return{id:e.uuid,format:e.format}}))}function $t(e){return{entities:Zt(e.entities).map((function(e){return{kind:jt(e.kind),entityKind:e.entityKind.value===ge.Section?"section":"frame",uuid:e.uuid,layerPathHash:e.layerPathHash,beforeFragmentIds:Kt(e.beforeFragmentIds),afterFragmentIds:Kt(e.afterFragmentIds),beforeImages:Yt(e.beforeImages),afterImages:Yt(e.afterImages),parentEntityUUID:Jt(e.parentEntityUUID),name:e.name,changes:_t(e.changes),layerChangeCount:e.layerChangeCount,drawsImage:e.drawsImage,beforeExtent:qt(e.beforeExtent),afterExtent:qt(e.afterExtent),quadAfter:Vt(e.quadAfter),quadBefore:Vt(e.quadBefore)}})),layers:Zt(e.layers).map((function(e){return{kind:jt(e.kind),layerPathHash:e.layerPathHash,uuid:e.uuid,name:e.name,type:e.type<0?null:e.type,entityUUID:Jt(e.entityUUID),parentLayerPathHash:Jt(e.parentLayerPathHash),drawsImage:e.drawsImage,changes:_t(e.changes),beforeExtent:qt(e.beforeExtent),afterExtent:qt(e.afterExtent),quadAfter:Vt(e.quadAfter),quadBefore:Vt(e.quadBefore)}})),beforeNodeCount:e.beforeNodeCount,afterNodeCount:e.afterNodeCount,isPartial:e.isPartial}}var Xt=function(){function e(e){var t=e.locateFile,n=e.mode,o=void 0===n?U.release:n,r=this;this.pending=new Map,this.handleError=function(){r.rejectAll("Comparison worker crashed"),r.worker.terminate()},this.handleMessage=function(e){var t=r.pending.get(e.data.requestId);t&&(r.pending.delete(e.data.requestId),"error"!==e.data.type?t.keep?e.data.source?t.resolve({differences:e.data.differences,source:e.data.source}):t.reject(new Error("Comparison worker did not keep the ".concat(t.keep," version"))):t.resolve(e.data.differences):t.reject(new Error(e.data.message)))},this.worker=new Worker(t.replace("{file}","comparison-worker.js")),this.worker.addEventListener("message",this.handleMessage),this.worker.addEventListener("error",this.handleError),this.postMessage({type:"init",locateFile:t,mode:o})}return e.prototype.postMessage=function(e){this.worker.postMessage(e)},e.prototype.rejectAll=function(e){this.pending.forEach((function(t){return(0,t.reject)(new Error(e))})),this.pending.clear()},e.prototype.compare=function(e,t,n){var o=this,r=(void 0===n?{}:n).keep,i=X();return new Promise((function(n,a){o.pending.set(i,{keep:r,resolve:n,reject:a}),o.postMessage({type:"compare",requestId:i,before:e,after:t,keep:r})}))},e.prototype.dispose=function(){this.rejectAll("Comparison worker disposed"),this.worker.terminate()},e}(),Qt=function(){function e(e,t,n,o){this.prototypeStructure=e,this.startArtboardUUID=t,this.canvas=n,this.container=o,this.locateFile="/{file}",this.imagesURLFormat="",this.imagesURLMap={},this.fragmentsURLFormat="",this.fragmentsURLMap={},this.backgroundColor={r:0,g:0,b:0,a:1},this.mode=U.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=O,this.manualInitialization=!1,this.highlightHotspots=!0,this.resizeMode=k.Fit,this.assetsManagerLimits={maxDepthForBackgroundRequests:1,maxArtboardsForBackgroundRequests:5,maxInitialLoadingDepth:2,maxInitialArtboardToLoad:10},this.disableInteraction=!1}return e.FromSettings=function(t){return Object.assign(new e(t.prototypeStructure,t.startArtboardUUID,t.canvas,t.container),Object.fromEntries(Object.entries(t).filter((function(e){return void 0!==e[1]}))))},e}(),en=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"IDLE"},n.disposed=!1,n.handleCanvasResize=function(e,t,o){var r;null===(r=n.playerWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&n.userEventsCollectorWasm.dispatchWheelEvent(e.x,e.y,null===(o=n.wasmModule)||void 0===o?void 0:o.mapPointerInfo(t))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerDownEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerUpEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.restartPrototype=function(e){var t;null===(t=n.playerWasm)||void 0===t||t.restartPrototype(e)},n.navigateToFirstFlow=function(){var e;null===(e=n.playerWasm)||void 0===e||e.navigateToFirstFlow()},n.goBack=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goBack()},n.goForwards=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goForwards()},n.setResizeMode=function(e){var t;if(n.wasmModule){var o=n.wasmModule.mapResizeMode(e);null===(t=n.playerWasm)||void 0===t||t.setResizeMode(o)}},n.getScreen=function(e){var t;void 0===e&&(e=!0);var o=null===(t=n.playerWasm)||void 0===t?void 0:t.getJSScreen(e);return o?{layers:J(o.layers)}:{layers:[]}},n.settings=Qt.FromSettings(t),re.logDebug("PrototypeRenderer JS constructed with settings:",n.settings),n.gestureManager=new ee(n.settings.container,!1,n.settings.disableInteraction),n.canvasManager=new ae({container:n.settings.container,canvas:n.settings.canvas,maxPixelRatio:3}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return d(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,A()];case 1:return e=t.sent(),this.deviceInfo=h(h({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.detectWebGLVersion=function(){this.webglVersion=q(this.deviceInfo),re.logDebug("Using WebGL ".concat(this.webglVersion))},t.prototype.init=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this.traceFirstPaint=new ne("FirstPaint"),this.setStatus({type:"INITIALIZING"}),[4,this.collectAndEmitDeviceInfo()];case 1:t.sent(),this.detectWebGLVersion(),t.label=2;case 2:return t.trys.push([2,6,,7]),[4,this.initWasmModule()];case 3:return t.sent(),[4,this.initPlayerWasm()];case 4:return t.sent(),[4,this.startDownload()];case 5:return t.sent(),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof D?e:new D("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initWasmModule=function(){var e;return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new ne("WasmModuleDownload"),this.wasmModule=new se({mode:this.settings.mode,locateFile:this.settings.locateFile,jsBridge:this.createJSBridge(),featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion}),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.startDownload=function(){var e=this;return this.setStatus({type:"LOADING_FILE"}),new Promise((function(t){var n;null===(n=e.playerWasm)||void 0===n||n.startDownload((function(){t()}))}))},t.prototype.startRendering=function(){var e;this.traceInitialRender=new ne("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.playerWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){re.logDebug("[C++] ".concat(e))},logWarning:function(e){re.logWarning("[C++] ".concat(e))},logError:function(e){re.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t,n){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t].replace(":format",n):e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t).replace(":format",n):(re.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):(re.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(t,n){e.emit("cameraPanChange",t,n)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},onPrototypeStateWillChange:function(t,n,o){e.emit("prototypeStateWillChange",{currentArtboardId:t,canGoBack:n,canGoForwards:o})},onPrototypeStateChange:function(t,n,o){e.emit("prototypeStateChange",{currentArtboardId:t,canGoBack:n,canGoForwards:o})},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onPrototypeUnhandledPointerUp:function(){e.emit("prototypeUnhandledPointerUp")},onSceneChange:function(){e.emit("sceneChange")}}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l,c,d,h;return f(this,(function(p){switch(p.label){case 0:if(this.disposed||!this.wasmModule)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(t.data.contentType)?(i=new Blob([t.data.buffer]),[4,ue(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),this.wasmModule?(s=this.wasmModule.createWebGLTextureFromImage(a,this.webglCtxHandle),n.buffer=new Uint8Array(0),n.isWebGLTexture=!0,n.emscriptenWebGLTextureHandle=s,n.width=a.width,n.height=a.height,[3,4]):[2];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return re.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(l=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==l?l:500,statusText:null!==(d=null===(c=t.data.error)||void 0===c?void 0:c.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=t.data.contentType)&&void 0!==h?h:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0}),[3,7];case 6:return[3,7];case 7:return this.fetchWorker.removeEventListener("message",r),[2]}}))}))};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initPlayerWasm=function(){var e,t;return p(this,void 0,void 0,(function(){var n,o,r,i,a,s,u,l,c,d,p,g,v,m,y,b,w,C,P,S,E;return f(this,(function(f){try{if(!this.wasmModule)throw Error("WASM module not initialized");for(this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:this.webglVersion}),n=this.wasmModule.instance,o=n.RenderTarget,r=n.PrototypeRendererWasm,i=n.PrototypeStructureArtboardVector,a=n.PrototypeStructureFlowVector,s=n.PrototypeStructureAssetVector,u=n.PrototypeStructureFlowTypeEnum,this.renderTarget=o.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),l={artboards:new i},c={Overlay:u.Overlay,Screen:u.Screen},d=0,p=this.settings.prototypeStructure.artboards;d<p.length;d++){for(g=p[d],v=new a,m=0,y=null!==(e=g.flows)&&void 0!==e?e:[];m<y.length;m++)b=y[m],v.push_back(h(h({},b),{type:c[b.type]}));for(w=new s,C=0,P=null!==(t=g.assets)&&void 0!==t?t:[];C<P.length;C++)S=P[C],w.push_back(S);l.artboards.push_back(h(h({},g),{flows:v,assets:w}))}this.playerWasm=new r(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID,l,this.settings.highlightHotspots,this.settings.assetsManagerLimits)}catch(e){throw new D("WASM_ERROR","An error occurred while trying to create the PrototypeRenderer WASM object.",e)}if(!(E=this.playerWasm.getUserEventsCollector()))throw new D("WASM_ERROR","An error occurred while trying to create the user events collector");return this.userEventsCollectorWasm=E,this.playerWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.playerWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.setResizeMode(this.settings.resizeMode),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.playerWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.playerWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},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()):"")}),re.logError(e),e.cause&&re.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(re.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getStatus=function(){return this.status},t.prototype.getArtboardAtPosition=function(e,t){var n=this.playerWasm;if(!n)return null;for(var o=n.getJSScreen(!1),r=n.getPan(),i=n.getZoom(),a=(e-r.x)/i,s=(t-r.y)/i,u=o.layers.size()-1;u>=0;u-=1){var l=o.layers.get(u);if(l&&"artboard"===l.type){var c=l.bounds.x+l.bounds.width,d=l.bounds.y+l.bounds.height;if(a>=l.bounds.x&&s>=l.bounds.y&&a<=c&&s<=d)return l.getNode()}}return null},t.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.dispose=function(){var e,t,n;try{this.disposeFetchWorker(),this.detachAllListeners(),null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.playerWasm)||void 0===t||t.stopRenderLoop(),null===(n=this.playerWasm)||void 0===n||n.delete(),this.renderTarget.delete(),this.playerWasm=void 0,this.wasmModule=void 0,this.disposed=!0}catch(e){this.fail(new D("ERROR","Unexpected exception while disposing the WebRendererWasm object",e))}},t.prototype.mapRelativePositionToCameraPosition=function(e,t){var n=this.playerWasm;return n?n.mapRelativePositionToCameraPosition(e,t):null},t.prototype.updateHighlightHotspotsSetting=function(e){var t=this.playerWasm;if(!t)return null;t.updateHighlightHotspotsSetting(e)},t}(B),tn=r(void 0),nn=r("auto"),on=r(void 0),rn=r(void 0),an=r(void 0),sn=r(void 0),un=function(){var e=i(sn);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},ln=function(e,t){switch(t.type){case"on-status":return h(h({},e),{status:t.status});case"dispose":return h(h({},e),{status:{type:"DISPOSED"},cursor:"auto"});case"on-cursor-change":return h(h({},e),{cursor:t.cursor});case"on-prototype-state-will-change":return h(h({},e),{prototypeState:h(h({},e.prototypeState),{isChanging:!0})});case"on-prototype-state-change":return h(h({},e),{prototypeState:h(h(h({},e.prototypeState),t.prototypeState),{isChanging:!1})});case"on-zoom":return h(h({},e),{zoom:t.zoom});case"on-pan":return h(h({},e),{pan:{x:t.pan.x,y:t.pan.y}});default:return e}},cn=function(n){var r=t(null),i=t(null),u=a(ln,{status:{type:"IDLE"},cursor:"auto",prototypeState:{currentArtboardId:"",canGoBack:!1,canGoForwards:!1,isChanging:!1},zoom:1,pan:{x:0,y:0}}),l=u[0],c=l.status,d=l.cursor,p=l.prototypeState,f=l.zoom,g=l.pan,v=u[1],m=o((function(e){v({type:"on-status",status:e})}),[]),y=o((function(e){return v({type:"on-zoom",zoom:e})}),[]),b=o((function(e,t){return v({type:"on-pan",pan:{x:e,y:t}})}),[]),w=o((function(e){return v({type:"on-cursor-change",cursor:e})}),[]),C=o((function(){return v({type:"on-prototype-state-will-change"})}),[]),P=o((function(e){return v({type:"on-prototype-state-change",prototypeState:e})}),[]),S=o((function(){var e=r.current;e&&(re.logDebug("Provider dispose"),e.off("status",m),e.off("cursorChange",w),e.off("prototypeStateWillChange",C),e.off("prototypeStateChange",P),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.dispose(),r.current=null,v({type:"dispose"}))}),[m,w,C,P,b,y]),E=o((function(e,t){if(e&&t&&i.current){re.logDebug("Provider init");var n=new en(h(h({},i.current),{container:t,canvas:e,manualInitialization:!0}));n.on("status",m),n.on("cursorChange",w),n.on("prototypeStateWillChange",C),n.on("prototypeStateChange",P),n.on("cameraZoomChange",y),n.on("cameraPanChange",b),r.current=n,n.init()}}),[m,w,C,P,b,y]),R=o((function(e){var t,n,o,a,s,u,l,c;re.logDebug("Provider setSettings"),e.backgroundColor&&e.backgroundColor!=(null===(t=i.current)||void 0===t?void 0:t.backgroundColor)&&(null===(n=r.current)||void 0===n||n.setBackgroundColor(e.backgroundColor)),(null===(o=i.current)||void 0===o?void 0:o.resizeMode)!=e.resizeMode&&(null===(a=r.current)||void 0===a||a.setResizeMode(e.resizeMode||k.Fit)),void 0!==e.highlightHotspots&&(null===(s=i.current)||void 0===s?void 0:s.highlightHotspots)!==e.highlightHotspots&&(null===(u=r.current)||void 0===u||u.updateHighlightHotspotsSetting(e.highlightHotspots)),e.disableInteraction!==(null===(l=i.current)||void 0===l?void 0:l.disableInteraction)&&(null===(c=r.current)||void 0===c||c.gestureManager.setDisable(e.disableInteraction||!1)),i.current=e}),[]),M=o((function(){return r.current}),[]),L=s((function(){return{dispose:S,init:E,setSettings:R,getInstance:M,dispatch:v}}),[S,E,R,M]);return e.createElement(sn.Provider,{value:L},e.createElement(tn.Provider,{value:c},e.createElement(nn.Provider,{value:d},e.createElement(on.Provider,{value:p},e.createElement(rn.Provider,{value:f},e.createElement(an.Provider,{value:g},n.children))))))},dn=function(){var e=(0,un().getInstance)();return o((function(t){null==e||e.restartPrototype(t)}),[e])},hn=function(){var e=(0,un().getInstance)();return o((function(){null==e||e.navigateToFirstFlow()}),[e])},pn=function(){var e=(0,un().getInstance)();return o((function(){null==e||e.goBack()}),[e])},fn=function(){var e=(0,un().getInstance)();return o((function(){null==e||e.goForwards()}),[e])},gn=function(){var e=(0,un().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return f(this,(function(o){return[2,null==e?void 0:e.getArtboardAtPosition(t,n)]}))}))}),[e])},vn=function(){var e=(0,un().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},mn=function(){var e=i(tn);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},yn=function(){var e=i(nn);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},bn=function(){var e=i(on);if(void 0===e)throw Error("usePrototypeState must be used within a provider");return e},wn=function(){var e=i(rn);if(void 0===e)throw Error("usePrototypeZoom must be used within a provider");return e},Cn=function(){var e=i(an);if(void 0===e)throw Error("usePrototypePan must be used within a provider");return e},Pn=function(e,t){var n=(0,un().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function Sn(){var e=(0,un().getInstance)();return o((function(t){return void 0===t&&(t=!0),null==e?void 0:e.getScreen(t)}),[e])}var En={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Rn={position:"absolute",top:0,left:0},Mn=function(n){var o=n.locateFile,r=n.imagesURLFormat,i=n.imagesURLMap,a=n.backgroundColor,l=n.mode,c=n.showTilesBorders,d=n.minimumZoomLevel,p=n.maximumZoomLevel,f=n.preserveDrawingBuffer,g=n.children,v=n.containerProps,m=n.canvasProps,y=n.featureFlags,b=n.startArtboardUUID,w=n.prototypeStructure,C=n.fragmentsURLFormat,P=n.fragmentsURLMap,S=n.highlightHotspots,E=n.resizeMode,R=n.assetsManagerLimits,M=n.cursor,L=n.disableInteraction,x=t(null),F=t(null),W=un(),I=W.dispose,A=W.init,T=W.setSettings,U=mn(),k=yn(),D=("function"==typeof M?M(k):M)||k;u((function(){return re.logDebug("PrototypeRenderer mounted"),function(){return re.logDebug("PrototypeRenderer unmounted")}}),[]),u((function(){T({locateFile:o,imagesURLFormat:r,imagesURLMap:i,backgroundColor:a,mode:l,showTilesBorders:c,minimumZoomLevel:d,maximumZoomLevel:p,preserveDrawingBuffer:f,featureFlags:y,startArtboardUUID:b,prototypeStructure:w,fragmentsURLFormat:C,fragmentsURLMap:P,highlightHotspots:S,resizeMode:E,assetsManagerLimits:R,disableInteraction:L})}),[T,o,r,i,a,l,c,d,p,f,y,b,S,E,C,P,w,R,L]),u((function(){return A(x.current,F.current),function(){I()}}),[I,A]);var G=s((function(){return h(h({},En),{cursor:D})}),[D]);return e.createElement("div",h({},v,{ref:F,style:G}),e.createElement("canvas",h({},m,{ref:x,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==U?void 0:U.type.toLowerCase())||"null"),style:Rn})),"READY"===(null==U?void 0:U.type)&&g)},Ln={position:"absolute",inset:0,pointerEvents:"none"};function xn(t){var n=t.visualize,r=void 0!==n&&n,i=Sn(),a=l((function(){return i()||null})),u=a[0],c=a[1],d=o((function(){c(i()||null)}),[i]);Pn("sceneChange",d);var p=s((function(){return h(h({},Ln),{opacity:r?1:0})}),[r]);return u?e.createElement("div",{style:p},u.layers.map((function(t,n){return e.createElement(Fn,{key:"".concat(n,"/").concat(t.id),bounds:t.bounds,id:t.id,name:t.name,type:t.type})}))):null}function Fn(t){var n=t.bounds,o=t.name,r=t.id,i=t.type,a=wn(),u=Cn()||{x:0,y:0},l=u.x,c=u.y,d=s((function(){return h({position:"absolute",left:l/window.devicePixelRatio+n.x*a,top:c/window.devicePixelRatio+n.y*a,width:n.width*a,height:n.height*a,backgroundColor:"rgba(0, 255, 255, 0.2)",border:"2px dotted white"},"hotspot"===i?{cursor:"pointer",pointerEvents:"auto"}:{})}),[n.x,n.y,n.width,n.height,l,c,a,i]);return e.createElement("div",{style:d,"data-testid":"".concat(i,"-").concat(Wn(o),"-").concat(r),"data-entity-name":o,"data-entity-id":r,"data-entity-bounds-x":n.x,"data-entity-bounds-y":n.x,"data-entity-bounds-width":n.width,"data-entity-bounds-height":n.height})}function Wn(e){var t,n;return null!==(n=null===(t=e.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))||void 0===t?void 0:t.join("-").toLowerCase())&&void 0!==n?n:""}export{C as CameraAnimator,Je as CameraMoveContext,qe as CameraZoomingContext,je as CanvasRenderer,et as CanvasRendererProvider,Ot as CanvasRendererReact,fe as ComparisonChangeKind,ge as ComparisonEntityKind,pe as ComparisonValueKind,Xt as ComparisonWorkerClient,Ye as CursorContext,b as DEFAULT_CAMERA_ANIMATION,O as DefaultFeatureFlags,B as EventEmitter,ee as GestureManager,te as KeyboardManager,z as ListenersCollector,ze as PRCursorType,Te as PRLayerSizingBehaviour,Me as PRMarinaBlendMode,me as PRMarinaExportFormatType,Re as PRMarinaLayerBlurType,Pe as PRMarinaLayerBorderPosition,xe as PRMarinaLayerCornerStyle,ye as PRMarinaLayerFillType,Ce as PRMarinaLayerGradientColorInterpolation,we as PRMarinaLayerGradientType,We as PRMarinaLayerHorizontalTextAlignment,be as PRMarinaLayerImageFillType,Se as PRMarinaLayerLineCap,Ee as PRMarinaLayerLineJoin,Ae as PRMarinaLayerTextDecoration,Fe as PRMarinaLayerTextTransform,Le as PRMarinaLayerType,Ie as PRMarinaLayerVerticalTextAlignment,ve as PRMarinaVisibleScaleType,Oe as PRNodeExportFormat,De as PRStackCrossAxisAlignment,Ue as PRStackDirection,ke as PRStackMainAxisAlignment,Ge as PRStackingOrder,Be as PRUserPointerType,Ke as PanContext,ne as Performance,en as PrototypeRenderer,cn as PrototypeRendererProvider,Mn as PrototypeRendererReact,k as PrototypeResizeMode,Ne as PrototypeResizeModeWasm,Ze as PrototypeStructureFlowType,xn as PrototypeTestOverlay,_e as StatusContext,D as WebRendererError,U as WebRendererMode,Ve as ZoomContext,V as clamp,J as convertEmbindVectorToArray,j as debounce,_ as extractPointer,X as generateUUID,q as getSupportedWebGLVersion,Z as getiOSVersion,G as isDefinedPresentationManifestFrame,K as isTouchDevice,re as logger,oe as nextTick,H as parseSafariUserAgent,Qe as reducer,Y as removeUndefinedKeys,Q as safePtrAccess,$t as toDifferences,T as toDrawingBufferColorSpace,$ as touchableClick,Ut as useComparePatchBounds,At as useComparison,it as useCursor,ie as useDebounceFunction,vt as useDecrementZoom,tt as useEvent,Wt as useExportNode,Pt as useGetArtboardAtPosition,St as useGetNodeAtPosition,Et as useGetPanAtPosition,Sn as useGetScreen,pn as useGoBack,fn as useGoForwards,It as useHighlightEntities,gt as useIncrementZoom,st as useIsCameraMoving,at as useIsCameraZooming,Gt as useLoadAllFragments,Rt as useLockCamera,kt as useLogEvent,Ct as useLooseWebGLContext,Mt as useMapRelativePositionToCameraPosition,hn as useNavigateToFirstFlow,ut as usePRFile,ct as usePRFileAllFrames,lt as usePRFileArtboards,dt as usePRFileSections,rt as usePan,yn as usePrototypeCursor,Pn as usePrototypeEvent,gn as usePrototypeGetArtboardAtPosition,vn as usePrototypeMapRelativePositionToCameraPosition,Cn as usePrototypePan,bn as usePrototypeState,mn as usePrototypeStatus,wn as usePrototypeZoom,dn as useRestartPrototype,pt as useRootNodeAbsoluteExtent,ht as useSceneRootNode,mt as useSetPan,ft as useSetZoom,xt as useShowSingleEntity,Ft as useShowSingleFrame,Tt as useSplitView,nt as useStatus,ot as useZoom,yt as useZoomToFit,bt as useZoomToFitNode,wt as useZoomToFitRect};
|
|
1
|
+
import e,{useRef as t,useLayoutEffect as n,useCallback as o,createContext as r,useContext as i,useReducer as a,useMemo as s,useEffect as u,useState as l}from"react";var c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var h=function(){return h=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},h.apply(this,arguments)};function p(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}function f(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function g(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))}var v={linear:function(e){return e},easeIn:function(e){return e*e*e},easeOut:function(e){return 1-Math.pow(1-e,3)},easeInEaseOut:function(e){return e<.5?4*Math.pow(e,3):1-Math.pow(-2*e+2,3)/2}},m=function(){function e(){this.frame=null}return Object.defineProperty(e.prototype,"isAnimating",{get:function(){return null!==this.frame},enumerable:!1,configurable:!0}),e.prototype.cancel=function(){null!==this.frame&&(cancelAnimationFrame(this.frame),this.frame=null)},e.prototype.run=function(e,t,n){var o,r=this;this.cancel();var i=h(h({},t),e),a=i.duration,s=i.easing,u=null!==(o=v[s])&&void 0!==o?o:v[t.easing],l=e.onComplete;if(a<=0||"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n(1),void(null==l||l());var c=performance.now(),d=function(e){var t=Math.min(1,(e-c)/a);n(u(t)),t<1?r.frame=requestAnimationFrame(d):(r.frame=null,n(1),null==l||l())};this.frame=requestAnimationFrame(d)},e}(),y={duration:200,easing:"easeOut"},b={duration:500,easing:"easeInEaseOut"},w=function(e,t,n){return e+(t-e)*n},C=function(){function e(e){this.apply=e,this.animator=new m}return Object.defineProperty(e.prototype,"isAnimating",{get:function(){return this.animator.isAnimating},enumerable:!1,configurable:!0}),e.prototype.cancel=function(){this.animator.cancel()},e.prototype.animate=function(e,t,n){var o,r=this;if(void 0===n&&(n={}),!(e.zoom>0&&t.zoom>0))return this.animator.cancel(),this.apply(t),void(null===(o=n.onComplete)||void 0===o||o.call(n));var i=t.zoom/e.zoom;this.animator.run(n,b,(function(n){return r.apply({zoom:e.zoom*Math.pow(i,n),pan:{x:w(e.pan.x,t.pan.x,n),y:w(e.pan.y,t.pan.y,n)}})}))},e}();function P(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}const S=["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 E(e){return e.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const R="undefined"==typeof window,M=(()=>{if(R)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)}})();class L extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const x=[],F=[];function W(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let o=e.length,r=t.length;for(;o>0&&e.charCodeAt(~-o)===t.charCodeAt(~-r);)o--,r--;let i,a=0;for(;a<o&&e.charCodeAt(a)===t.charCodeAt(a);)a++;if(o-=a,r-=a,0===o)return r;let s,u,l=0,c=0,d=0;for(;c<o;)F[c]=e.charCodeAt(a+c),x[c]=++c;for(;d<r;)for(i=t.charCodeAt(a+d),s=d++,l=d,c=0;c<o;c++)u=i===F[c]?s:s+1,s=x[c],l=x[c]=s>l?u>l?l+1:u:u>s?s+1:u;return l}function I(e){return null!=e}const A=({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@5.0.25/dist/benchmarks"}={})=>P(void 0,void 0,void 0,(function*(){const a={};if(R)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==M?void 0:M.isIpad),isMobile:u=!!(null==M?void 0:M.isMobile),screenSize:l=window.screen,loadBenchmarks:c=(e=>P(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 L("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:d}=n;const h=(e,t,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:u,tier:e,type:t});let p,f="";if(d)d=E(d),p=[d];else{const e=o||function(e,t=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:t,powerPreference:"high-performance",stencil:!1};e&&delete n.powerPreference;const o=window.document.createElement("canvas"),r=o.getContext("webgl",n)||o.getContext("experimental-webgl",n);return null!=r?r:void 0}(null==M?void 0:M.isSafari12,r);if(!e)return h(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(d=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");f=d,d=E(d),p=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==M?void 0:M.isIpad)?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["m1",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15]];let u;return"80162181255"===o?u=s.filter((([,,e])=>e>=14)):(u=s.filter((([,e])=>e===o)),u.length||(u=s)),u.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,d,u)}const g=(yield Promise.all(p.map((function(e){var t;return P(this,void 0,void 0,(function*(){const n=(e=>{const t=u?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const o=`${u?"m":"d"}-${n}${s?"-ipad":""}.json`,r=a[o]=null!==(t=a[o])&&void 0!==t?t:c(o);let i;try{i=yield r}catch(n){if(n instanceof L)throw n;return}const d=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let h=i.filter((([,e])=>e===d));h.length||(h=i.filter((([t])=>t.includes(e))));const p=h.length;if(0===p)return;const f=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let g,[v,,,,m]=p>1?h.map((e=>[e,W(f,e[2])])).sort((([,e],[,t])=>e-t))[0][0]:h[0],y=Number.MAX_VALUE;const{devicePixelRatio:b}=window,w=l.width*b*l.height*b;for(const e of m){const[t,n]=e,o=t*n,r=Math.abs(w-o);r<y&&(y=r,g=e)}if(!g)return;const[,,C,P]=g;return[y,C,v,P]}))})))).filter(I).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!g.length){const e=S.find((e=>d.includes(e)));return e?h(0,"BLOCKLISTED",e):h(1,"FALLBACK",`${d} (${f})`)}const[,v,m,y]=g[0];if(-1===v)return h(0,"BLOCKLISTED",m,v,y);const b=u?e:t;let w=0;for(let e=0;e<b.length;e++)v>=b[e]&&(w=e);return h(w,"BENCHMARK",m,v,y)}));function T(e){return"displayP3"===e?"display-p3":"srgb"}var U,k,D=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 d(t,e),t}(Error);function G(e){return void 0!==e}!function(e){e.debug="debug",e.release="release"}(U||(U={})),function(e){e.Fit="Fit",e.FillWidth="FillWidth",e.ActualSize="ActualSize"}(k||(k={}));var B=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,o;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(o=this.listeners[e])||void 0===o||o.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.forwardEvent=function(e,t){this.on(t,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];e.emit.apply(e,g([t],n,!1))}))},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this.listeners[e];(null==o?void 0:o.size)&&o.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e.prototype.detachAllListeners=function(){this.listeners={}},e}(),z=function(){function e(e){void 0===e&&(e=!1),this.removeListenerCallbacks=[],this.disabled=e}return e.prototype.add=function(e,t,n,o){var r=this,i=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];r.disabled||n.apply(void 0,e)};e.addEventListener(t,i,o);var a=function(){e.removeEventListener(t,i,o)};return this.removeListenerCallbacks.push(a),a},e.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(e){return e()}))},e.prototype.setDisabled=function(e){this.disabled=e},e}(),O={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1,canvasLayersEvents:!1},Z=function(e){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(e)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},N=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,H=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(N);if(!t)return null;var n=t[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(t[4])||0,minor:parseInt(t[5])||0,patch:parseInt(t[6])||0}}};function j(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 _(e){var t,n,o,r,i,a=null!==(n=null===(t=e.touches)||void 0===t?void 0:t[0])&&void 0!==n?n:null===(o=e.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(r=null==a?void 0:a.clientX)&&void 0!==r?r:e.clientX,y:null!==(i=null==a?void 0:a.clientY)&&void 0!==i?i:e.clientY}}function V(e,t,n){return Math.max(t,Math.min(n,e))}function q(e){return Boolean(window.chrome)&&e.gpu&&/amd\sradeon\s(pro|rx)\s5\d\d\d/gi.test(e.gpu)||H()&&!O.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function J(e){if(!e)return[];for(var t=[],n=0;n<e.size();n++)t.push(e.get(n));return t}function K(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function Y(e){var t=h({},e);return Object.keys(t).forEach((function(e){void 0===t[e]&&delete t[e]})),t}function $(e){return K()?{onTouchEnd:e}:{onClick:e}}function X(){return"function"==typeof crypto.randomUUID?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(16))).map((function(e){return e.toString(16).padStart(2,"0")})).join("")}var Q=function(e){return 0===(null==e?void 0:e.$$.count.value)?null:e},ee=function(e){function t(t,n,o){void 0===n&&(n=!1),void 0===o&&(o=!1);var r=e.call(this)||this;return 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.updateMousePosition=function(e){r.emit("pointermove",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.updateGlobalMousePosition=function(e){r.emit("globalpointermove",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},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=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.debouncedUpdateMousePosition=j(r.updateMousePosition,40),r.debouncedUpdateGlobalMousePosition=j(r.updateGlobalMousePosition,40),r.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!r.state.isCtrlPressed,n=e.metaKey||t||r.state.isCtrlPressed;if(r.debouncedUpdateMousePosition(e),r.debouncedUpdateGlobalMousePosition(e),n){var o=t||r.invertedWheelZoom?-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=t,r.invertedWheelZoom=n,r.targetBounds=t.getBoundingClientRect(),r.listenersCollector=new z(o),r.addListeners(),r.targetResizeObserver=new ResizeObserver(r.updateTargetBounds.bind(r)),r.targetResizeObserver.observe(r.target),r}return d(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},t.prototype.addKeyboardEventListeners=function(){var e=this;this.listenersCollector.add(document,"keydown",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(t){t.ctrlKey&&(e.state.isCtrlPressed=!1)}))},t.prototype.addMouseEventListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handleMouseDown),this.listenersCollector.add(this.target,"mousemove",this.handleMouseMove),this.listenersCollector.add(document,"mousemove",this.handleGlobalMouseMove),this.listenersCollector.add(document,"mouseup",this.handleMouseUp),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel)},t.prototype.addTouchEventListeners=function(){this.listenersCollector.add(this.target,"touchstart",this.handleTouchStart),this.listenersCollector.add(document,"touchmove",this.handleGlobalTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(this.target,"touchmove",this.handleTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(document,"touchcancel",this.handleTouchEnd),this.listenersCollector.add(document,"touchend",this.handleTouchEnd)},t.prototype.addSafariGesturesEventListeners=function(){K()||(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:e.x-this.targetBounds.x,y:e.y-this.targetBounds.y}},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=_(e);return this.clampPointerToTargetBounds(n)},t.prototype.calculateDistanceBetweenTouches=function(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)},t.prototype.emitZoomEvent=function(e,t){this.emit("pinchToZoom",e,t)},t.prototype.dispose=function(){this.listenersCollector.dispose(),this.targetResizeObserver.disconnect()},t.prototype.setDisable=function(e){this.listenersCollector.setDisabled(e)},t.prototype.setInvertedWheelZoom=function(e){this.invertedWheelZoom=e},t}(B),te=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new z,n.handleKeyUp=function(e){n.emit("keyUp",e.code)},n.target=t,n.addListeners(),n}return d(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(B),ne=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now()}return e.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(t," ms")}var n=(e/1e3).toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(n," s")},e}();function oe(e){setTimeout((function(){e()}),0)}var re=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.prototype.logDebug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,g(["log","debug"],e,!1))},t.prototype.logWarning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,g(["log","warn"],e,!1))},t.prototype.logError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,g(["log","error"],e,!1))},t}(B)),ie=function(e,r){var i=t(e);i.current=e;var a=t((function(){}));return n((function(){var e=j((function(){i.current()}),r);return a.current=e,function(){e.cancel()}}),[r]),o((function(){return a.current()}),[])},ae=function(e){function t(t){var n,o=this;return(o=e.call(this)||this).listenersCollector=new z,o.size={width:0,height:0},o.pixelRatio=1,o.maxPixelRatio=2,o.handleCanvasResizeObserver=function(e){o.resizeCanvas(e[0].contentRect)},o.resizeCanvas=function(e){var t=e.width,n=e.height;window.requestAnimationFrame((function(){o.setSize(t,n),o.emit("resize",t,n,o.getDevicePixelRatio())}))},o.getCanvasCenterPoint=function(){var e=o.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},o.container=t.container,o.canvas=t.canvas,o.maxPixelRatio=null!==(n=t.maxPixelRatio)&&void 0!==n?n:o.maxPixelRatio,o.canvasResizeObserver=new ResizeObserver(o.handleCanvasResizeObserver),o.canvasResizeObserver.observe(o.container),o.listenersCollector.add(window,"orientationchange",o.handleDeviceOrientationChange),o.setSize(o.container.clientWidth,o.container.clientHeight),o}return d(t,e),t.prototype.setSize=function(e,t){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(e,"px"),this.canvas.style.height="".concat(t,"px"),this.size.width=e*this.pixelRatio,this.size.height=t*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},t.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},t.prototype.getDevicePixelRatio=function(){return V(window.devicePixelRatio,1,this.maxPixelRatio)},t.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},t.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},t}(B),se=function(){function e(e){this.settings=e}return e.prototype.isReleaseMode=function(){return this.settings.mode===U.release},e.prototype.init=function(){return p(this,void 0,void 0,(function(){var e,t,n,o,r,i=this;return f(this,(function(a){switch(a.label){case 0:return[4,this.importModule()];case 1:e=a.sent(),t=e.default,a.label=2;case 2:return a.trys.push([2,4,,5]),n=this,[4,t({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:this.settings.webglVersion,bridge:this.settings.jsBridge,locateFile:function(e){return i.settings.locateFile.replace("{file}",e)}})];case 3:return n.instance=a.sent(),[3,5];case 4:throw o=a.sent(),new D("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerTypeEnum.Unset,mouse:this.instance.PRUserPointerTypeEnum.Mouse,touch:this.instance.PRUserPointerTypeEnum.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorTypeEnum.Auto.value]="auto",r[this.instance.PRCursorTypeEnum.Default.value]="default",r[this.instance.PRCursorTypeEnum.Pointer.value]="pointer",r[this.instance.PRCursorTypeEnum.Grab.value]="grab",r[this.instance.PRCursorTypeEnum.Grabbing.value]="grabbing",r),this.prototypeResizeModeToWASMMap={Fit:this.instance.PrototypeResizeModeWasmEnum.Fit,FillWidth:this.instance.PrototypeResizeModeWasmEnum.FillWidth,ActualSize:this.instance.PrototypeResizeModeWasmEnum.ActualSize},[2]}}))}))},e.prototype.makeWebGLContext=function(e,t,n){var o;void 0===t&&(t={}),void 0===n&&(n="srgb");var r=h({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},t),i=this.instance.GL.createContext(e,r);if(!i)throw new D("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");var a=null===(o=this.instance.GL.getContext(i))||void 0===o?void 0:o.GLctx;return a&&(a.getExtension("WEBGL_debug_renderer_info"),"srgb"!==n&&"drawingBufferColorSpace"in a&&(a.drawingBufferColorSpace=n)),i},e.prototype.createWebGLTextureFromImage=function(e,t){var n=this.instance.GL,o=n.getContext(t);if(!o)throw new Error("Unable to retrieve emscripten WebGL context from handle");var r=o.GLctx;if(!r)throw new Error("WebGL context is null");var i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);var a=n.getNewId(n.textures);return n.textures[a]=i,r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.bindTexture(r.TEXTURE_2D,null),a},e.prototype.destroyWebGLContext=function(e){var t;re.logDebug("Destroying WebGL context");var n=null===(t=this.instance)||void 0===t?void 0:t.GL.getContext(e);if(n){this.instance.GL.deleteContext(e);var o=n.GLctx.getExtension("WEBGL_lose_context");if(o)return o.loseContext(),re.logDebug("WebGL destroyed"),!0;re.logError("WEBGL_lose_context not available. Not possible to destroy WebGL context manually.")}else re.logError("WebGL context not found while trying to destroy it")},e.prototype.importModule=function(){return this.isReleaseMode()?import("./web-renderer-release-e6a9b58b.js"):import("./web-renderer-debug-042d411e.js")},e.prototype.mapToCSSCursor=function(e){return this.prCursorTypeToCSSCursorMap[e.value]},e.prototype.mapToPRPointerType=function(e){var t;return null!==(t=this.pointerTypeToWASMMap[e])&&void 0!==t?t:this.instance.PRUserPointerTypeEnum.Unset},e.prototype.mapPointerInfo=function(e){return h(h({},e),{type:this.mapToPRPointerType(e.type)})},e.prototype.mapResizeMode=function(e){return this.prototypeResizeModeToWASMMap[e]},e}();function ue(e){return new Promise((function(t,n){var o=new Image;o.onload=function(){t(o)},o.onerror=function(e){n(e)},o.src=e}))}var le=function(){function e(e,t,n){this.canvas=e,this.container=t,this.filePath=n,this.locateFile="/{file}",this.imagesURLFormat="",this.imagesURLMap={},this.fragmentsURLFormat="",this.fragmentsURLMap={},this.backgroundColor={r:1,g:1,b:1,a:1},this.colorSpace="sRGB",this.mode=U.release,this.showTilesBorders=!1,this.minimumZoomLevel=.01,this.maximumZoomLevel=5,this.preserveDrawingBuffer=!1,this.featureFlags=O,this.manualInitialization=!1,this.panBoundariesPadding=0,this.selectedArtboard=null,this.onlyShowFrameIds=[],this.focusedFrameIds=[],this.unfocusedOpacity=1,this.initialZoom=null,this.initialPan=null,this.showArtboardsDecorations=!0,this.invertedWheelZoom=!1}return e.FromSettings=function(t){return Object.assign(new e(t.canvas,t.container,t.filePath),Object.fromEntries(Object.entries(t).filter((function(e){return void 0!==e[1]}))))},e}(),ce={png:"image/png",jpg:"image/jpeg",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",raster:"binary/octet-stream"},de=function(){function e(e,t){var n=this;this.pendingExports=new Map,this._crashed=!1,this.handleError=function(){n._crashed=!0,n.pendingExports.forEach((function(e){e.reject("Export worker crashed")})),n.pendingExports.clear(),n.worker.terminate()},this.handleMessage=function(e){if("result"===e.data.type||"error"===e.data.type){var t=n.pendingExports.get(e.data.requestId);if(t)if(n.pendingExports.delete(e.data.requestId),"error"!==e.data.type){var o=new Blob([e.data.buffer],{type:ce[t.exportFormat]});t.resolve({blob:o,width:e.data.width,height:e.data.height,bytesPerPixel:e.data.bytesPerPixel})}else t.reject(e.data.message)}},this.worker=new Worker(e),this.ready=new Promise((function(e,t){var o=function(r){"ready"===r.data.type?(n.worker.removeEventListener("message",o),e()):"init-error"===r.data.type&&(n.worker.removeEventListener("message",o),t(new Error(r.data.message)))};n.worker.addEventListener("message",o)})),this.worker.addEventListener("message",this.handleMessage),this.worker.addEventListener("error",this.handleError);var o=t.offscreen;this.postMessage(h({type:"init"},t),[o])}return Object.defineProperty(e.prototype,"hasCrashed",{get:function(){return this._crashed},enumerable:!1,configurable:!0}),e.prototype.postMessage=function(e,t){this.worker.postMessage(e,null!=t?t:[])},e.prototype.exportNode=function(e,t,n,o,r){var i=this,a=X();return new Promise((function(s,u){var l=function(){i.pendingExports.delete(a)&&(i.postMessage({type:"cancelExport",requestId:a}),u(null==r?void 0:r.reason))},c=function(e){null==r||r.removeEventListener("abort",l),e()};i.pendingExports.set(a,{resolve:function(e){return c((function(){return s(e)}))},reject:function(e){return c((function(){return u(e)}))},exportFormat:n}),null==r||r.addEventListener("abort",l,{once:!0}),i.postMessage({type:"exportNode",requestId:a,layerPathHash:e,format:t,backingScale:o})}))},e.prototype.dispose=function(){this.pendingExports.forEach((function(e){e.reject("ExportWorkerClient disposed")})),this.pendingExports.clear(),this.postMessage({type:"dispose"}),this.worker.terminate()},e}();function he(e){var t=new Map;return e.forEach((function(e){var n=e.uuid,o=e.x,r=e.y,i=e.width,a=e.height;n&&t.set(n,{uuid:n,x:o,y:r,width:i,height:a})})),t}var pe,fe,ge,ve,me,ye,be,we,Ce,Pe,Se,Ee,Re,Me,Le,xe,Fe,We,Ie,Ae,Te,Ue,ke,De,Ge,Be,ze,Oe,Ze,Ne,He=function(){function e(e){this.host=e,this.held=null,this.split=null,this.splitApplied=!1,this.appliedSource=null,this.generation=0,this.hasFile=!1}return e.prototype.set=function(e){return!this.host.isDisposed()&&(this.hasFile?this.apply(e):(this.held=e,!0))},e.prototype.clear=function(){this.held=null,this.forgetSplit(),this.appliedSource=null,this.generation++,this.host.endComparison()},e.prototype.fileLoaded=function(){this.hasFile=!0,this.held&&this.apply(this.held)},e.prototype.dispose=function(){this.held=null,this.forgetSplit(),this.generation++},e.prototype.setSplit=function(e,t){var n=this.host.getComparison();return this.split=e,this.onSplitRefused=t,n?(this.splitApplied=n.setSplit(e),this.splitApplied||(this.split=null),this.splitApplied):(this.splitApplied=!1,!0)},e.prototype.setSplitFraction=function(e){var t;this.split&&(this.split=h(h({},this.split),{fraction:e})),null===(t=this.host.getComparison())||void 0===t||t.setSplitFraction(e)},e.prototype.clearSplit=function(){var e;this.forgetSplit(),null===(e=this.host.getComparison())||void 0===e||e.clearSplit()},e.prototype.getBounds=function(){var e,t;return null!==(t=null===(e=this.host.getComparison())||void 0===e?void 0:e.getPlacedBounds())&&void 0!==t?t:[]},e.prototype.apply=function(e){var t,n=e.source,o=e.patches;if(this.held=null,n===this.appliedSource)return null===(t=this.host.getComparison())||void 0===t||t.setPatches(o),this.applySplitIfNeeded(),!0;var r=this.host.startComparison();if(!r)return!1;var i=++this.generation;return r.setSource({file:n.file,fragments:n.fragments})?(this.splitApplied=!1,this.appliedSource=n,r.setPatches(o),this.applySplitIfNeeded(),this.handOver(n.images,i),!0):(this.appliedSource=null,!1)},e.prototype.applySplitIfNeeded=function(){var e;if(this.split&&!this.splitApplied){var t=this.host.getComparison();t&&(this.splitApplied=t.setSplit(this.split),this.splitApplied||(this.split=null,null===(e=this.onSplitRefused)||void 0===e||e.call(this),this.onSplitRefused=void 0))}},e.prototype.forgetSplit=function(){this.split=null,this.splitApplied=!1,this.onSplitRefused=void 0},e.prototype.handOver=function(e,t){return p(this,void 0,void 0,(function(){var n=this;return f(this,(function(o){switch(o.label){case 0:return[4,Promise.all(e.map((function(e){return p(n,void 0,void 0,(function(){var n,o,r;return f(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.host.decode(e)];case 1:return n=i.sent(),[3,3];case 2:return i.sent(),[2];case 3:return o=this.host.getComparison(),t!==this.generation||this.host.isDisposed()||!o?[2]:((r=this.host.createTexture(n))&&o.insertImage(e.id,r.texture,r.width,r.height),[2])}}))}))})))];case 1:return o.sent(),[2]}}))}))},e}();!function(e){e[e.Absent=0]="Absent",e[e.Boolean=1]="Boolean",e[e.Number=2]="Number",e[e.Text=3]="Text"}(pe||(pe={})),function(e){e[e.Added=0]="Added",e[e.Removed=1]="Removed",e[e.Modified=2]="Modified"}(fe||(fe={})),function(e){e[e.None=0]="None",e[e.Frame=1]="Frame",e[e.Section=2]="Section"}(ge||(ge={})),function(e){e[e.None=0]="None",e[e.Scale=1]="Scale",e[e.Width=2]="Width",e[e.Height=3]="Height"}(ve||(ve={})),function(e){e[e.None=0]="None",e[e.PNG=1]="PNG",e[e.JPG=2]="JPG",e[e.TIFF=3]="TIFF",e[e.WEBP=4]="WEBP",e[e.PDF=5]="PDF",e[e.EPS=6]="EPS",e[e.SVG=7]="SVG",e[e.HEIC=8]="HEIC"}(me||(me={})),function(e){e[e.Color=0]="Color",e[e.Gradient=1]="Gradient",e[e.Pattern=2]="Pattern"}(ye||(ye={})),function(e){e[e.Fit=0]="Fit",e[e.Fill=1]="Fill",e[e.Stretch=2]="Stretch",e[e.Tile=3]="Tile"}(be||(be={})),function(e){e[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.Angular=2]="Angular"}(we||(we={})),function(e){e[e.Rgb=0]="Rgb",e[e.Oklab=1]="Oklab",e[e.Oklch=2]="Oklch"}(Ce||(Ce={})),function(e){e[e.Center=0]="Center",e[e.Inside=1]="Inside",e[e.Outside=2]="Outside"}(Pe||(Pe={})),function(e){e[e.Butt=0]="Butt",e[e.Round=1]="Round",e[e.Square=2]="Square"}(Se||(Se={})),function(e){e[e.Miter=0]="Miter",e[e.Round=1]="Round",e[e.Bevel=2]="Bevel"}(Ee||(Ee={})),function(e){e[e.Motion=0]="Motion",e[e.Zoom=1]="Zoom",e[e.Background=2]="Background",e[e.Gaussian=3]="Gaussian"}(Re||(Re={})),function(e){e[e.Normal=0]="Normal",e[e.DestAtop=1]="DestAtop",e[e.Clear=2]="Clear",e[e.Source=3]="Source",e[e.Darken=4]="Darken",e[e.Multiply=5]="Multiply",e[e.ColorBurn=6]="ColorBurn",e[e.Lighten=7]="Lighten",e[e.Screen=8]="Screen",e[e.ColorDodge=9]="ColorDodge",e[e.Overlay=10]="Overlay",e[e.SoftLight=11]="SoftLight",e[e.HardLight=12]="HardLight",e[e.Difference=13]="Difference",e[e.Exclusion=14]="Exclusion",e[e.Hue=15]="Hue",e[e.Saturation=16]="Saturation",e[e.Color=17]="Color",e[e.Luminosity=18]="Luminosity",e[e.PlusLighter=19]="PlusLighter",e[e.PlusDarker=20]="PlusDarker"}(Me||(Me={})),function(e){e[e.Artboard=0]="Artboard",e[e.SymbolMaster=1]="SymbolMaster",e[e.SymbolInstance=2]="SymbolInstance",e[e.Hotspot=3]="Hotspot",e[e.Bitmap=4]="Bitmap",e[e.Group=5]="Group",e[e.Oval=6]="Oval",e[e.Polygon=7]="Polygon",e[e.Rectangle=8]="Rectangle",e[e.ShapeGroup=9]="ShapeGroup",e[e.ShapePath=10]="ShapePath",e[e.Star=11]="Star",e[e.Text=12]="Text",e[e.Triangle=13]="Triangle",e[e.Slice=14]="Slice",e[e.Section=15]="Section"}(Le||(Le={})),function(e){e[e.Angled=2]="Angled",e[e.InsideArc=4]="InsideArc",e[e.InsideSquare=3]="InsideSquare",e[e.Rounded=0]="Rounded",e[e.Smooth=1]="Smooth"}(xe||(xe={})),function(e){e[e.Lowercase=2]="Lowercase",e[e.None=0]="None",e[e.Uppercase=1]="Uppercase"}(Fe||(Fe={})),function(e){e[e.Center=1]="Center",e[e.Justified=3]="Justified",e[e.Left=0]="Left",e[e.Right=2]="Right"}(We||(We={})),function(e){e[e.Top=0]="Top",e[e.Middle=1]="Middle",e[e.Bottom=2]="Bottom"}(Ie||(Ie={})),function(e){e[e.LineThrough=2]="LineThrough",e[e.Underline=1]="Underline",e[e.None=0]="None"}(Ae||(Ae={})),function(e){e[e.Fixed=0]="Fixed",e[e.Fill=1]="Fill",e[e.Fit=2]="Fit",e[e.Relative=3]="Relative"}(Te||(Te={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical"}(Ue||(Ue={})),function(e){e[e.Start=0]="Start",e[e.Center=1]="Center",e[e.End=2]="End",e[e.SpaceBetween=3]="SpaceBetween",e[e.SpaceAround=4]="SpaceAround",e[e.SpaceEvenly=5]="SpaceEvenly"}(ke||(ke={})),function(e){e[e.None=0]="None",e[e.Start=1]="Start",e[e.Center=2]="Center",e[e.End=3]="End",e[e.Stretch=4]="Stretch"}(De||(De={})),function(e){e[e.FirstOnTop=0]="FirstOnTop",e[e.LastOnTop=1]="LastOnTop"}(Ge||(Ge={})),function(e){e[e.Unset=0]="Unset",e[e.Mouse=1]="Mouse",e[e.Touch=2]="Touch"}(Be||(Be={})),function(e){e[e.Auto=0]="Auto",e[e.Default=1]="Default",e[e.Pointer=2]="Pointer",e[e.Grab=3]="Grab",e[e.Grabbing=4]="Grabbing"}(ze||(ze={})),function(e){e[e.PNG=0]="PNG",e[e.JPG=1]="JPG",e[e.WEBP=2]="WEBP",e[e.PDF=4]="PDF",e[e.SVG=3]="SVG",e[e.RASTER=5]="RASTER"}(Oe||(Oe={})),function(e){e[e.Screen=0]="Screen",e[e.Overlay=1]="Overlay"}(Ze||(Ze={})),function(e){e[e.Fit=0]="Fit",e[e.FillWidth=1]="FillWidth",e[e.ActualSize=2]="ActualSize"}(Ne||(Ne={}));var je=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"IDLE"},n.appliedOnlyShowFrameIds=[],n.comparison=new He({getComparison:function(){var e;return null===(e=n.pageCanvasWasm)||void 0===e?void 0:e.getComparison()},startComparison:function(){var e;return null===(e=n.pageCanvasWasm)||void 0===e?void 0:e.startComparison()},endComparison:function(){var e;return null===(e=n.pageCanvasWasm)||void 0===e?void 0:e.endComparison()},isDisposed:function(){return n.disposed},decode:function(e){var t=e.bytes,o=e.type;return p(n,void 0,void 0,(function(){var e;return f(this,(function(n){switch(n.label){case 0:e=URL.createObjectURL(new Blob([t],{type:o})),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,ue(e)];case 2:return[2,n.sent()];case 3:return URL.revokeObjectURL(e),[7];case 4:return[2]}}))}))},createTexture:function(e){return n.wasmModule?{texture:n.wasmModule.createWebGLTextureFromImage(e,n.webglCtxHandle),width:e.width,height:e.height}:void 0}}),n.disposed=!1,n.cameraAnimator=new C((function(e){return n.applyCameraState(e)})),n.dimAnimator=new m,n.appliedUnfocusedOpacity=1,n.handleCanvasResize=function(e,t,o){var r;null===(r=n.pageCanvasWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;n.cameraAnimator.cancel(),null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.cameraAnimator.cancel(),n.wasmModule&&(null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(e.x,e.y,n.wasmModule.mapPointerInfo(t)))},n.handlePointerDownEvent=function(e){var t;n.cameraAnimator.cancel(),n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(e)))},n.settings=le.FromSettings(t),re.logDebug("CanvasRenderer JS constructed with settings:",n.settings),n.gestureManager=new ee(n.settings.container,n.settings.invertedWheelZoom),n.canvasManager=new ae({container:n.settings.container,canvas:n.settings.canvas}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return d(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,A()];case 1:return e=t.sent(),this.deviceInfo=h(h({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.detectWebGLVersion=function(){this.webglVersion=q(this.deviceInfo),re.logDebug("Using WebGL ".concat(this.webglVersion))},t.prototype.init=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this.traceFirstPaint=new ne("FirstPaint"),this.setStatus({type:"INITIALIZING"}),[4,this.collectAndEmitDeviceInfo()];case 1:t.sent(),this.detectWebGLVersion(),t.label=2;case 2:return t.trys.push([2,6,,7]),[4,this.initWasmModule()];case 3:return t.sent(),[4,this.initCanvasRendererWasm()];case 4:return t.sent(),[4,this.setFile(this.settings.filePath)];case 5:return t.sent(),this.comparison.fileLoaded(),this.settings.selectedArtboard&&this.selectArtboard(this.settings.selectedArtboard),this.settings.onlyShowFrameIds.length>0&&this.setOnlyShowFrames(this.settings.onlyShowFrameIds),this.settings.focusedFrameIds.length>0&&this.settings.unfocusedOpacity<1&&this.setUnfocusedOpacity(this.settings.focusedFrameIds,this.settings.unfocusedOpacity),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof D?e:new D("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.setInitialCameraState=function(){var e,t,n,o=null!==this.settings.initialZoom,r=null!==this.settings.initialPan;if(o||r)o&&this.setZoom(this.settings.initialZoom||1),r&&this.setPan((null===(e=this.settings.initialPan)||void 0===e?void 0:e.x)||0,(null===(t=this.settings.initialPan)||void 0===t?void 0:t.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport);else{var i=this.findFocusedNodeIdentifier();void 0!==i?this.zoomToFitNode(i):this.zoomToFit()}},t.prototype.findFocusedNodeIdentifier=function(){var e,t,n=this.settings,o=n.focusedFrameIds,r=n.unfocusedOpacity;if(!(1!==o.length||r>=1)){var i=o[0];return null===(t=null===(e=g(g([],this.getPRFileAllFrames(),!0),this.getPRFileSections(),!0).find((function(e){return e.objectId===i})))||void 0===e?void 0:e.getNode())||void 0===t?void 0:t.getIdentifier()}},t.prototype.startRendering=function(){var e;this.traceInitialRender=new ne("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.pageCanvasWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){re.logDebug("[C++] ".concat(e))},logWarning:function(e){re.logWarning("[C++] ".concat(e))},logError:function(e){re.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t,n){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t].replace(":format",n):e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t).replace(":format",n):(re.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):(re.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(){var t=e.getPan();e.emit("cameraPanChange",(null==t?void 0:t.x)||0,(null==t?void 0:t.y)||0)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onLayerClick:function(t){e.emit("layerClick",t)},onLayerMouseHoverChange:function(t){e.emit("layerMouseHoverChange",t)},onSceneChange:function(){e.emit("sceneChange")},onComparePatchesChange:function(){e.emit("comparePatchesChange")},onFragmentLoad:function(t){e.emit("fragmentLoad",t)}}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l,c,d,h;return f(this,(function(p){switch(p.label){case 0:if(!this.wasmModule)return[2];if(this.disposed)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(t.data.contentType)?(i=new Blob([t.data.buffer]),[4,ue(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),this.wasmModule?(s=this.wasmModule.createWebGLTextureFromImage(a,this.webglCtxHandle),n.buffer=new Uint8Array(0),n.isWebGLTexture=!0,n.emscriptenWebGLTextureHandle=s,n.width=a.width,n.height=a.height,[3,4]):[2];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return re.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(l=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==l?l:500,statusText:null!==(d=null===(c=t.data.error)||void 0===c?void 0:c.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=t.data.contentType)&&void 0!==h?h:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:0,width:0,height:0}),[3,7];case 6:return[3,7];case 7:return this.fetchWorker.removeEventListener("message",r),[2]}}))}))};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initWasmModule=function(){var e;return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new ne("WasmModuleDownload"),this.wasmModule=new se({mode:this.settings.mode,locateFile:this.settings.locateFile,jsBridge:this.createJSBridge(),featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion}),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),re.logDebug(t.printMeasurement()),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.initCanvasRendererWasm=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){if(this.disposed)return[2];try{if(!this.wasmModule)throw Error("WASM module not initialized");this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:this.webglVersion},T(this.settings.colorSpace)),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.pageCanvasWasm=new this.wasmModule.instance.CanvasRendererWasm(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(e){throw new D("WASM_ERROR","An error occurred while trying to create the wasm object.",e)}if(!this.pageCanvasWasm)return[2];if(!(e=this.pageCanvasWasm.getUserEventsCollector()))throw new D("WASM_ERROR","An error occurred while trying to create the user events collector");return this.userEventsCollectorWasm=e,this.pageCanvasWasm.setShowArtboardsDecorations(this.settings.showArtboardsDecorations),this.pageCanvasWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.pageCanvasWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.pageCanvasWasm.setPanBoundariesPadding(this.settings.panBoundariesPadding),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setAssetSources=function(e){var t=e.imagesURLFormat,n=e.imagesURLMap,o=e.fragmentsURLFormat,r=e.fragmentsURLMap;this.settings.imagesURLFormat=null!=t?t:"",this.settings.imagesURLMap=null!=n?n:{},this.settings.fragmentsURLFormat=null!=o?o:"",this.settings.fragmentsURLMap=null!=r?r:{}},t.prototype.setComparison=function(e){return this.comparison.set(e)},t.prototype.clearComparison=function(){this.comparison.clear()},t.prototype.setSplit=function(e,t){return this.comparison.setSplit(e,t)},t.prototype.setSplitFraction=function(e){this.comparison.setSplitFraction(e)},t.prototype.clearSplit=function(){this.comparison.clearSplit()},t.prototype.getComparePatchBounds=function(){return this.comparison.getBounds()},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.pageCanvasWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(re.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),re.logDebug(this.traceFirstPaint.printMeasurement()),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;(null===(e=this.wasmModule)||void 0===e?void 0:e.destroyWebGLContext(this.webglCtxHandle))||re.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(e){if(this.pageCanvasWasm)if(this.cameraAnimator.cancel(),e){var t=this.getCameraState();this.pageCanvasWasm.scaleDocumentToFit();var n=this.getCameraState();this.applyCameraState(t),this.cameraAnimator.animate(t,n,e)}else this.pageCanvasWasm.scaleDocumentToFit()},t.prototype.getCameraState=function(){return{pan:this.getPan(),zoom:this.getZoom()}},t.prototype.applyCameraState=function(e){var t=e.pan,n=e.zoom;this.applyZoom(n),this.applyPan(t.x,t.y)},t.prototype.moveCameraTo=function(e,t){this.pageCanvasWasm&&(this.cameraAnimator.cancel(),t?this.cameraAnimator.animate(this.getCameraState(),e,t):this.applyCameraState(e))},t.prototype.cancelCameraAnimation=function(){this.cameraAnimator.cancel()},t.prototype.zoomToFitNode=function(e,t,n,o){if(void 0===t&&(t=.82),void 0===n&&(n=!1),this.pageCanvasWasm)if(this.cameraAnimator.cancel(),o){var r=this.getCameraState();this.pageCanvasWasm.scaleNodeToFit(e,t,n);var i=this.getCameraState();this.applyCameraState(r),this.cameraAnimator.animate(r,i,o)}else this.pageCanvasWasm.scaleNodeToFit(e,t,n)},t.prototype.zoomToFitRect=function(e,t,n,o){var r=this;if(void 0===t&&(t=.82),void 0===n&&(n=!1),this.pageCanvasWasm){this.cameraAnimator.cancel();var i=function(){var o;return null===(o=r.pageCanvasWasm)||void 0===o?void 0:o.scaleRectToFit(e.x,e.y,e.width,e.height,t,n)};if(o){var a=this.getCameraState();i();var s=this.getCameraState();this.applyCameraState(a),this.cameraAnimator.animate(a,s,o)}else i()}},t.prototype.loadAllFragments=function(){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.loadAllFragments()},t.prototype.setFile=function(e){return p(this,void 0,void 0,(function(){var t=this;return f(this,(function(n){return this.disposed?[2]:(this.setStatus({type:"LOADING_FILE"}),this.appliedOnlyShowFrameIds=[],[2,new Promise((function(n,o){var r;null===(r=t.pageCanvasWasm)||void 0===r||r.setFile(e,(function(e,o,r){t.setStatus({type:"FILE_READY"});var i="".concat(e,"-v").concat("15.18.0");t.emit("fileReady",i,o,r),n()}),(function(){return o(new D("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()):"")}),re.logError(e),e.cause&&re.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(re.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getPRFileCachedData=function(){var e;if(!this.pageCanvasWasm)return null;if((null===(e=this.prFileHandle)||void 0===e?void 0:e.filePath)!==this.settings.filePath){var t=this.pageCanvasWasm.getPRFile();this.prFileHandle={handle:t,filePath:this.settings.filePath,artboards:J(t.getFrames()),allFrames:J(t.getAllFrames()),sections:J(t.getSections())}}return this.prFileHandle},t.prototype.getPRFile=function(){var e;return null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.handle},t.prototype.releasePRFileHandle=function(){var e,t;null===(t=null===(e=this.prFileHandle)||void 0===e?void 0:e.handle)||void 0===t||t.delete(),this.prFileHandle=void 0},t.prototype.getRootNodeExtent=function(){var e,t,n;return null!==(n=null===(t=null===(e=this.getPRFile())||void 0===e?void 0:e.getRootNode())||void 0===t?void 0:t.getAbsoluteExtent())&&void 0!==n?n:null},t.prototype.getSceneRootNode=function(){var e,t;return null!==(t=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getSceneRootNode())&&void 0!==t?t:null},t.prototype.getPRFileArtboards=function(){var e,t;return null!==(t=null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.artboards)&&void 0!==t?t:[]},t.prototype.getPRFileAllFrames=function(){var e,t;return null!==(t=null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.allFrames)&&void 0!==t?t:[]},t.prototype.getPRFileSections=function(){var e,t;return null!==(t=null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.sections)&&void 0!==t?t:[]},t.prototype.getArtboardAtPosition=function(e,t){if(!this.pageCanvasWasm)return null;for(var n=this.getPRFileAllFrames(),o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(e-o.x)/r,a=(t-o.y)/r,s=0,u=n;s<u.length;s++){var l=u[s],c=l.bounds.x+l.bounds.width,d=l.bounds.y+l.bounds.height;if(i>=l.bounds.x&&a>=l.bounds.y&&i<=c&&a<=d)return l.getNode()}return null},t.prototype.mapRelativePositionToCameraPosition=function(e,t){var n;return null===(n=this.pageCanvasWasm)||void 0===n?void 0:n.mapRelativePositionToCameraPosition(e,t)},t.prototype.getNodeAtPosition=function(e,t){return this.pageCanvasWasm?this.pageCanvasWasm.getNodeAtPosition(e,t):null},t.prototype.getPanAtPosition=function(e,t){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),r=e/o,i=t/o;return{x:n.x-r,y:n.y-i}},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){this.cameraAnimator.cancel(),this.applyZoom(e,t)},t.prototype.applyZoom=function(e,t){var n,o=null!=t?t:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(e,o.x,o.y)},t.prototype.getPan=function(){var e,t,n=this.getRootNodeExtent();if(!n)return{x:0,y:0};var o=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getPan(),r=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom();return o&&r?{x:o.x/r+n.x,y:o.y/r+n.y}:{x:0,y:0}},t.prototype.getZoom=function(){var e;return(null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom())||0},t.prototype.setPan=function(e,t,n){void 0===n&&(n=!1),this.cameraAnimator.cancel(),this.applyPan(e,t,n)},t.prototype.applyPan=function(e,t,n){var o;void 0===n&&(n=!1);var r=this.getRootNodeExtent();if(r){var i=e,a=t,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);i+=this.canvasManager.size.width/u,a+=this.canvasManager.size.height/u}var l=(i-r.x)*s,c=(a-r.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(l,c)}},t.prototype.selectArtboard=function(e){var t;this.pageCanvasWasm&&(this.settings.selectedArtboard=e,null===(t=this.pageCanvasWasm)||void 0===t||t.selectArtboard(null!=e?e:""))},t.prototype.setUnfocusedOpacity=function(e,t,n){var o,r,i,a=this,s=Array.from(new Set(e)),u=this.settings.unfocusedOpacity===t&&this.settings.focusedFrameIds.length===s.length&&this.settings.focusedFrameIds.every((function(e){return s.includes(e)}));if(this.settings.focusedFrameIds=s,this.settings.unfocusedOpacity=t,this.pageCanvasWasm)if(!u||this.dimAnimator.isAnimating){this.dimAnimator.cancel();var l=function(e){var t;a.appliedUnfocusedOpacity=e,null===(t=a.pageCanvasWasm)||void 0===t||t.setUnfocusedOpacity(s,e)},c=this.appliedUnfocusedOpacity;if(this.emit("unfocusedChange",{frameIds:s,opacity:t}),!n||c===t)return l(t),void(null===(i=null==n?void 0:n.onComplete)||void 0===i||i.call(n));this.dimAnimator.run(n,y,(function(e){return l(c+(t-c)*e)}))}else null===(r=null==n?void 0:n.onComplete)||void 0===r||r.call(n);else null===(o=null==n?void 0:n.onComplete)||void 0===o||o.call(n)},t.prototype.getUnfocusedOpacity=function(){return this.appliedUnfocusedOpacity},t.prototype.getFocusedFrameIds=function(){return this.settings.focusedFrameIds},t.prototype.setOnlyShowFrames=function(e){var t=Array.from(new Set(e)),n=this.appliedOnlyShowFrameIds.length===t.length&&this.appliedOnlyShowFrameIds.every((function(e){return t.includes(e)}));this.settings.onlyShowFrameIds=t,this.pageCanvasWasm&&(n||(this.pageCanvasWasm.setOnlyShowFrames(t),this.appliedOnlyShowFrameIds=t,this.emit("onlyShowFramesChange",t)))},t.prototype.getOnlyShowFrameIds=function(){return this.settings.onlyShowFrameIds},t.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.initExportWorker=function(){var e=new OffscreenCanvas(4096,4096);this.exportWorkerClient=new de(this.settings.locateFile.replace("{file}","export-worker.js"),{offscreen:e,locateFile:this.settings.locateFile,mode:this.settings.mode,featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion,fileURL:this.settings.filePath,imagesURLFormat:this.settings.imagesURLFormat,imagesURLMap:this.settings.imagesURLMap,fragmentsURLFormat:this.settings.fragmentsURLFormat,fragmentsURLMap:this.settings.fragmentsURLMap})},t.prototype.exportNode=function(e,t,n){var o,r;return p(this,void 0,void 0,(function(){var i,a,s,u,l,c;return f(this,(function(d){switch(d.label){case 0:if(this.disposed)throw new Error("CanvasRenderer has been disposed.");if(null==n?void 0:n.aborted)throw n.reason;if(i=t.format.toUpperCase(),void 0===(a=Oe[i]))throw new Error("Unsupported export format: ".concat(t.format));return this.exportWorkerClient&&!this.exportWorkerClient.hasCrashed||this.initExportWorker(),[4,(s=this.exportWorkerClient).ready];case 1:if(d.sent(),null==n?void 0:n.aborted)throw n.reason;if(!(u=null===(r=null===(o=this.pageCanvasWasm)||void 0===o?void 0:o.getPRFile())||void 0===r?void 0:r.findByIdentifier(e)))throw new Error("Node with identifier ".concat(e," not found"));if("string"!=typeof(l=u.getLayerPathHash())||""===l)throw new Error("Node with identifier ".concat(e," has empty layerPathHash"));d.label=2;case 2:return d.trys.push([2,4,,5]),[4,s.exportNode(l,a,t.format,t.backingScale,n)];case 3:return[2,d.sent()];case 4:throw c=d.sent(),s.hasCrashed&&(this.exportWorkerClient=void 0),c;case 5:return[2]}}))}))},t.prototype.dispose=function(){var e,t,n,o,r;try{this.cameraAnimator.cancel(),this.dimAnimator.cancel(),this.disposeFetchWorker(),this.disposed=!0,this.comparison.dispose(),this.detachAllListeners(),this.releasePRFileHandle(),null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.pageCanvasWasm)||void 0===t||t.stopRenderLoop(),null===(n=this.pageCanvasWasm)||void 0===n||n.delete(),null===(o=this.renderTarget)||void 0===o||o.delete(),this.pageCanvasWasm=void 0,this.wasmModule=void 0,null===(r=this.exportWorkerClient)||void 0===r||r.dispose(),this.exportWorkerClient=void 0}catch(e){this.fail(new D("ERROR","Unexpected exception while disposing the wasm object",e))}},t}(B),_e=r(void 0),Ve=r(void 0),qe=r(void 0),Je=r(void 0),Ke=r(void 0),Ye=r("auto"),$e=r(void 0),Xe=function(){var e=i($e);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},Qe=function(e,t){switch(t.type){case"on-status":return h(h({},e),{status:t.status});case"on-zoom":return h(h({},e),{zoom:t.zoom});case"on-pan":return h(h({},e),{pan:t.pan});case"dispose":return h(h({},e),{status:{type:"DISPOSED"},zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return h(h({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return h(h({},e),{isCameraZooming:!1});case"on-camera-move-start":return h(h({},e),{isCameraMoving:!0});case"on-camera-move-end":return h(h({},e),{isCameraMoving:!1});case"on-cursor-change":return h(h({},e),{cursor:t.cursor});default:return e}},et=function(n){var r=t(null),i=t(null),u=a(Qe,{pan:null,zoom:null,status:{type:"IDLE"},isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),l=u[0],c=l.status,d=l.zoom,p=l.pan,f=l.isCameraZooming,g=l.isCameraMoving,v=l.cursor,m=u[1],y=o((function(e){return m({type:"on-zoom",zoom:e})}),[]),b=o((function(e,t){return m({type:"on-pan",pan:{x:e,y:t}})}),[]),w=o((function(e){m({type:"on-status",status:e})}),[]),C=o((function(){return m({type:"on-camera-zoom-start"})}),[]),P=o((function(){return m({type:"on-camera-zoom-end"})}),[]),S=o((function(){return m({type:"on-camera-move-start"})}),[]),E=o((function(){return m({type:"on-camera-move-end"})}),[]),R=o((function(e){return m({type:"on-cursor-change",cursor:e})}),[]),M=o((function(){if(r.current){var e=r.current.getPan();m({type:"on-pan",pan:e})}}),[]),L=o((function(){var e=r.current;e&&(re.logDebug("Provider dispose"),e.off("status",w),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.off("cameraZoomStart",C),e.off("cameraZoomEnd",P),e.off("cameraMoveStart",S),e.off("cameraMoveEnd",E),e.off("cursorChange",R),e.off("sceneChange",M),e.dispose(),r.current=null,m({type:"dispose"}))}),[w,b,y,C,P,S,E,R,M]),x=o((function(e,t,n){if(""!==e&&t&&n&&i.current){re.logDebug("Provider init");var o=new je(h(h({},i.current),{filePath:e,container:n,canvas:t,manualInitialization:!0}));o.on("status",w),o.on("cameraZoomChange",y),o.on("cameraPanChange",b),o.on("cameraZoomStart",C),o.on("cameraZoomEnd",P),o.on("cameraMoveStart",S),o.on("cameraMoveEnd",E),o.on("cursorChange",R),o.on("sceneChange",M),r.current=o,o.init()}}),[w,y,b,C,P,S,E,R,M]),F=o((function(e){var t,n,o,a;re.logDebug("Provider setSettings"),e.backgroundColor&&(null===(t=r.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),null===(n=r.current)||void 0===n||n.gestureManager.setInvertedWheelZoom(e.invertedWheelZoom||!1),null===(o=r.current)||void 0===o||o.selectArtboard(e.selectedArtboard||null),null===(a=r.current)||void 0===a||a.setAssetSources({imagesURLFormat:e.imagesURLFormat,imagesURLMap:e.imagesURLMap,fragmentsURLFormat:e.fragmentsURLFormat,fragmentsURLMap:e.fragmentsURLMap}),i.current=e}),[]),W=o((function(){return r.current}),[]),I=s((function(){return{dispose:L,init:x,setSettings:F,getInstance:W,dispatch:m}}),[L,x,F,W]);return e.createElement($e.Provider,{value:I},e.createElement(_e.Provider,{value:c},e.createElement(Ve.Provider,{value:d},e.createElement(Ke.Provider,{value:p},e.createElement(qe.Provider,{value:f},e.createElement(Je.Provider,{value:g},e.createElement(Ye.Provider,{value:v},n.children)))))))},tt=function(e,t){var n=(0,Xe().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},nt=function(){var e=i(_e);if(void 0===e)throw Error("useStatus must be used within a provider");return e},ot=function(){var e=i(Ve);if(void 0===e)throw Error("useZoom must be used within a provider");return e},rt=function(){var e=i(Ke);if(void 0===e)throw Error("usePan must be used within a provider");return e},it=function(){var e=i(Ye);if(void 0===e)throw Error("useCursor must be used within a provider");return e},at=function(){var e=i(qe);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},st=function(){var e=i(Je);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},ut=function(){var e=(0,Xe().getInstance)(),t=nt();return s((function(){return e&&"READY"===t.type?e.getPRFile():null}),[e,t])},lt=function(){var e=(0,Xe().getInstance)(),t=nt();return s((function(){return e&&"READY"===t.type?e.getPRFileArtboards():null}),[e,t])},ct=function(){var e=(0,Xe().getInstance)(),t=nt();return s((function(){return e&&"READY"===t.type?e.getPRFileAllFrames():null}),[e,t])},dt=function(){var e=(0,Xe().getInstance)(),t=nt();return s((function(){return e&&"READY"===t.type?e.getPRFileSections():null}),[e,t])},ht=function(){var e=(0,Xe().getInstance)(),n=nt(),r=l(0),i=r[0],a=r[1],u=t(null),c=o((function(){var t,n,o=null!==(n=null===(t=null==e?void 0:e.getSceneRootNode())||void 0===t?void 0:t.getIdentifier())&&void 0!==n?n:null;o!==u.current&&(u.current=o,a((function(e){return e+1})))}),[e]);return tt("sceneChange",c),s((function(){return e&&"READY"===n.type?e.getSceneRootNode():null}),[e,n,i])},pt=function(){var e,t,n,o,r=ut(),i=l(null),a=i[0],c=i[1],d=ie((function(){c((function(e){var t,n,o,i=null!==(o=null===(n=null===(t=Q(r))||void 0===t?void 0:t.getRootNode())||void 0===n?void 0:n.getAbsoluteExtent())&&void 0!==o?o:null;return(null==e?void 0:e.width)===(null==i?void 0:i.width)&&(null==e?void 0:e.height)===(null==i?void 0:i.height)&&(null==e?void 0:e.x)===(null==i?void 0:i.x)&&(null==e?void 0:e.y)===(null==i?void 0:i.y)?e:i}))}),16);tt("sceneChange",d),u((function(){d()}),[d]);var h=null!==(e=null==a?void 0:a.x)&&void 0!==e?e:0,p=null!==(t=null==a?void 0:a.y)&&void 0!==t?t:0,f=null!==(n=null==a?void 0:a.width)&&void 0!==n?n:0,g=null!==(o=null==a?void 0:a.height)&&void 0!==o?o:0;return s((function(){return{x:h,y:p,width:f,height:g}}),[h,p,f,g])},ft=function(){var e=(0,Xe().getInstance)();return o((function(t){null==e||e.setZoom(t)}),[e])},gt=function(){var e=ft(),t=ot();return o((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},vt=function(){var e=ft(),t=ot();return o((function(){"number"==typeof t&&e(t/2)}),[e,t])},mt=function(){var e=(0,Xe().getInstance)();return o((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},yt=function(){var e=(0,Xe().getInstance)();return o((function(){null==e||e.zoomToFit()}),[e])},bt=function(){var e=(0,Xe().getInstance)();return o((function(t,n,o){null==e||e.zoomToFitNode(t,n,o)}),[e])},wt=function(){var e=(0,Xe().getInstance)();return o((function(t,n,o,r){null==e||e.zoomToFitRect(t,n,o,r)}),[e])},Ct=function(){var e=(0,Xe().getInstance)();return o((function(){null==e||e.looseWebGLContext()}),[e])},Pt=function(){var e=(0,Xe().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return f(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},St=function(){var e=(0,Xe().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return f(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getNodeAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Et=function(){var e=(0,Xe().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return f(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Rt=function(){var e=(0,Xe().getInstance)();return o((function(t){null==e||e.setIsCameraLocked(t)}),[e])},Mt=function(){var e=(0,Xe().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},Lt=function(e){return!0===e?{}:!1===e||void 0===e?void 0:e},xt=function(){var e=(0,Xe().getInstance)(),n=ct(),r=dt(),i=l(null),a=i[0],s=i[1],c=t({artboards:n,sections:r});c.current={artboards:n,sections:r};var d=o((function(){var t,n,o=null!==(t=null==e?void 0:e.getFocusedFrameIds())&&void 0!==t?t:[];if(1===o.length)return o[0];var r=null!==(n=null==e?void 0:e.getOnlyShowFrameIds())&&void 0!==n?n:[];return 1===r.length?r[0]:null}),[e]),p=o((function(){s(d())}),[d]);u(p,[p]),tt("onlyShowFramesChange",p),tt("unfocusedChange",p);var f=o((function(t,n){var o;void 0===n&&(n={});var r=Lt(n.animate),i=n.dim,a=void 0!==i,u=null===t?[]:[t],l=(null!==(o=null==e?void 0:e.getFocusedFrameIds())&&void 0!==o?o:[]).length>0,p=null===t||a===l;if(t!==d()||!p){s(t),a?null==e||e.setOnlyShowFrames([]):null==e||e.setUnfocusedOpacity([],1);var f=function(o){var i,a,s=function(){var e;null==o||o(),null===(e=null==r?void 0:r.onComplete)||void 0===e||e.call(r)};if(n.camera&&null!==t)return null==e||e.moveCameraTo(n.camera,r&&h(h({},r),{onComplete:s})),void(r||s());if(null===t)return null==e||e.zoomToFit(r&&h(h({},r),{onComplete:s})),void(r||s());var u=c.current,l=u.artboards,d=u.sections,p=null===(a=null===(i=g(g([],null!=l?l:[],!0),null!=d?d:[],!0).find((function(e){return e.objectId===t})))||void 0===i?void 0:i.getNode())||void 0===a?void 0:a.getIdentifier();void 0!==p?(null==e||e.zoomToFitNode(p,void 0,void 0,r&&h(h({},r),{onComplete:s})),r||s()):s()};if(a)return null==e||e.setUnfocusedOpacity(u,null===t?1:i,r&&{onComplete:function(){return f()}}),void(r||f());var v=function(){return null==e?void 0:e.setOnlyShowFrames(u)};r||v(),f(r?v:void 0)}}),[e,d]);return[a,f]},Ft=xt,Wt=function(){var e=(0,Xe().getInstance)(),n=ut(),r=t(null);return u((function(){return function(){var e;null===(e=r.current)||void 0===e||e.abort()}}),[]),o((function(t,o){var i;return e&&n?(null===(i=r.current)||void 0===i||i.abort(),r.current=new AbortController,e.exportNode(t,o,r.current.signal)):Promise.reject("WebRenderer instance not ready")}),[e,n])},It=function(){var e=(0,Xe().getInstance)();return o((function(t,n,o){void 0===o&&(o={}),null==e||e.setUnfocusedOpacity(t,n,Lt(o.animate))}),[e])},At=function(){var e=Xe().getInstance,t=o((function(t){var n,o;return null!==(o=null===(n=e())||void 0===n?void 0:n.setComparison(t))&&void 0!==o&&o}),[e]),n=o((function(){var t;return null===(t=e())||void 0===t?void 0:t.clearComparison()}),[e]),r=o((function(){var t,n;return he(null!==(n=null===(t=e())||void 0===t?void 0:t.getComparePatchBounds())&&void 0!==n?n:[])}),[e]);return s((function(){return{set:t,clear:n,getBounds:r}}),[t,n,r])},Tt=function(){var e=Xe().getInstance,t=o((function(t,n){var o,r;return null!==(r=null===(o=e())||void 0===o?void 0:o.setSplit(t,n))&&void 0!==r&&r}),[e]),n=o((function(t){var n;return null===(n=e())||void 0===n?void 0:n.setSplitFraction(t)}),[e]),r=o((function(){var t;return null===(t=e())||void 0===t?void 0:t.clearSplit()}),[e]);return s((function(){return{set:t,setFraction:n,clear:r}}),[t,n,r])},Ut=function(){var e=Xe().getInstance,t=o((function(){var t,n;return he(null!==(n=null===(t=e())||void 0===t?void 0:t.getComparePatchBounds())&&void 0!==n?n:[])}),[e]),n=l(t),r=n[0],i=n[1],a=o((function(){var e=t();i((function(t){return function(e,t){if(e.size!==t.size)return!1;var n=!0;return e.forEach((function(e,o){var r=t.get(o);r&&e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height||(n=!1)})),n}(t,e)?t:e}))}),[t]),s=e();return u(a,[a,s]),tt("comparePatchesChange",a),r};function kt(e){var n=t(e);n.current=e;var r=o((function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];n.current.apply(n,g([e],t,!1))}),[]);u((function(){return re.on("log",r),function(){re.off("log",r)}}),[r])}var Dt,Gt=function(){var e=Xe().getInstance;return o((function(){var t=e();t&&t.loadAllFragments()}),[e])},Bt={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},zt={position:"absolute",top:0,left:0},Ot=function(n){var r=n.filePath,i=n.locateFile,a=n.imagesURLFormat,c=n.imagesURLMap,d=n.fragmentsURLFormat,p=n.fragmentsURLMap,f=n.backgroundColor,g=n.mode,v=n.showTilesBorders,m=n.minimumZoomLevel,y=n.maximumZoomLevel,b=n.preserveDrawingBuffer,w=n.panBoundariesPadding,C=n.initialPan,P=n.initialZoom,S=n.children,E=n.containerProps,R=n.canvasProps,M=n.featureFlags,L=n.rootEntityUUID,x=n.selectedArtboard,F=n.showArtboardsDecorations,W=n.invertedWheelZoom,I=n.colorSpace,A=null!=L?L:x,T=t(null),U=t(null),k=l(!1),D=k[0],G=k[1],B=o((function(){return G(!0)}),[]),z=Xe(),O=z.dispose,Z=z.init,N=z.setSettings,H=it(),j=nt(),_=t(!1);tt("allImagesReady",B),u((function(){_.current||null==x||null!=L||(_.current=!0,re.logWarning("CanvasRendererReact: the `selectedArtboard` prop is deprecated, use `rootEntityUUID` instead."))}),[x,L]),u((function(){return re.logDebug("CanvasRenderer mounted"),function(){return re.logDebug("CanvasRenderer unmounted")}}),[]),u((function(){N({locateFile:i,imagesURLFormat:a,imagesURLMap:c,fragmentsURLFormat:d,fragmentsURLMap:p,backgroundColor:f,mode:g,showTilesBorders:v,minimumZoomLevel:m,maximumZoomLevel:y,preserveDrawingBuffer:b,panBoundariesPadding:w,initialPan:C,initialZoom:P,featureFlags:M,selectedArtboard:A,showArtboardsDecorations:F,invertedWheelZoom:W,colorSpace:I})}),[N,i,a,c,d,p,f,g,v,m,y,b,w,C,P,M,A,F,W,I]),u((function(){if(r)return Z(r,T.current,U.current),function(){O()}}),[O,Z,r]);var V=s((function(){var e;return null!==(e=n.cursor)&&void 0!==e?e:H}),[n.cursor,H]),q=s((function(){return h(h({},Bt),{cursor:V})}),[V]);return e.createElement("div",h({},E,{ref:U,style:q}),r&&e.createElement("canvas",h({},R,{key:r,ref:T,"data-sketchweb-all-images-ready":D,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==j?void 0:j.type.toLowerCase())||"null"),style:zt})),"READY"===(null==j?void 0:j.type)&&S)};function Zt(e){var t=J(e);return e.delete(),t}function Nt(e){switch(e.kind.value){case pe.Boolean:return e.boolean;case pe.Number:return e.number;case pe.Text:return e.text;default:return null}}var Ht=((Dt={})[fe.Added]="added",Dt[fe.Removed]="removed",Dt[fe.Modified]="modified",Dt),jt=function(e){var t;return null!==(t=Ht[e.value])&&void 0!==t?t:"modified"};function _t(e){return Zt(e).map((function(e){return{property:e.property,before:Nt(e.before),after:Nt(e.after)}}))}function Vt(e){var t=function(e){return{x:e.x,y:e.y}};return{topLeft:t(e.topLeft),topRight:t(e.topRight),bottomRight:t(e.bottomRight),bottomLeft:t(e.bottomLeft)}}function qt(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}var Jt=function(e){return""===e?null:e};function Kt(e){return Zt(e).filter((function(e){return void 0!==e}))}function Yt(e){return Zt(e).map((function(e){return{id:e.uuid,format:e.format}}))}function $t(e){return{entities:Zt(e.entities).map((function(e){return{kind:jt(e.kind),entityKind:e.entityKind.value===ge.Section?"section":"frame",uuid:e.uuid,layerPathHash:e.layerPathHash,beforeFragmentIds:Kt(e.beforeFragmentIds),afterFragmentIds:Kt(e.afterFragmentIds),beforeImages:Yt(e.beforeImages),afterImages:Yt(e.afterImages),parentEntityUUID:Jt(e.parentEntityUUID),name:e.name,changes:_t(e.changes),layerChangeCount:e.layerChangeCount,drawsImage:e.drawsImage,beforeExtent:qt(e.beforeExtent),afterExtent:qt(e.afterExtent),quadAfter:Vt(e.quadAfter),quadBefore:Vt(e.quadBefore)}})),layers:Zt(e.layers).map((function(e){return{kind:jt(e.kind),layerPathHash:e.layerPathHash,uuid:e.uuid,name:e.name,type:e.type<0?null:e.type,entityUUID:Jt(e.entityUUID),parentLayerPathHash:Jt(e.parentLayerPathHash),drawsImage:e.drawsImage,changes:_t(e.changes),beforeExtent:qt(e.beforeExtent),afterExtent:qt(e.afterExtent),quadAfter:Vt(e.quadAfter),quadBefore:Vt(e.quadBefore)}})),beforeNodeCount:e.beforeNodeCount,afterNodeCount:e.afterNodeCount,isPartial:e.isPartial}}var Xt=function(){function e(e){var t=e.locateFile,n=e.mode,o=void 0===n?U.release:n,r=this;this.pending=new Map,this.handleError=function(){r.rejectAll("Comparison worker crashed"),r.worker.terminate()},this.handleMessage=function(e){var t=r.pending.get(e.data.requestId);t&&(r.pending.delete(e.data.requestId),"error"!==e.data.type?t.keep?e.data.source?t.resolve({differences:e.data.differences,source:e.data.source}):t.reject(new Error("Comparison worker did not keep the ".concat(t.keep," version"))):t.resolve(e.data.differences):t.reject(new Error(e.data.message)))},this.worker=new Worker(t.replace("{file}","comparison-worker.js")),this.worker.addEventListener("message",this.handleMessage),this.worker.addEventListener("error",this.handleError),this.postMessage({type:"init",locateFile:t,mode:o})}return e.prototype.postMessage=function(e){this.worker.postMessage(e)},e.prototype.rejectAll=function(e){this.pending.forEach((function(t){return(0,t.reject)(new Error(e))})),this.pending.clear()},e.prototype.compare=function(e,t,n){var o=this,r=(void 0===n?{}:n).keep,i=X();return new Promise((function(n,a){o.pending.set(i,{keep:r,resolve:n,reject:a}),o.postMessage({type:"compare",requestId:i,before:e,after:t,keep:r})}))},e.prototype.dispose=function(){this.rejectAll("Comparison worker disposed"),this.worker.terminate()},e}(),Qt=function(){function e(e,t,n,o){this.prototypeStructure=e,this.startArtboardUUID=t,this.canvas=n,this.container=o,this.locateFile="/{file}",this.imagesURLFormat="",this.imagesURLMap={},this.fragmentsURLFormat="",this.fragmentsURLMap={},this.backgroundColor={r:0,g:0,b:0,a:1},this.mode=U.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=O,this.manualInitialization=!1,this.highlightHotspots=!0,this.resizeMode=k.Fit,this.assetsManagerLimits={maxDepthForBackgroundRequests:1,maxArtboardsForBackgroundRequests:5,maxInitialLoadingDepth:2,maxInitialArtboardToLoad:10},this.disableInteraction=!1}return e.FromSettings=function(t){return Object.assign(new e(t.prototypeStructure,t.startArtboardUUID,t.canvas,t.container),Object.fromEntries(Object.entries(t).filter((function(e){return void 0!==e[1]}))))},e}(),en=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"IDLE"},n.disposed=!1,n.handleCanvasResize=function(e,t,o){var r;null===(r=n.playerWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&n.userEventsCollectorWasm.dispatchWheelEvent(e.x,e.y,null===(o=n.wasmModule)||void 0===o?void 0:o.mapPointerInfo(t))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerDownEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerUpEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.restartPrototype=function(e){var t;null===(t=n.playerWasm)||void 0===t||t.restartPrototype(e)},n.navigateToFirstFlow=function(){var e;null===(e=n.playerWasm)||void 0===e||e.navigateToFirstFlow()},n.goBack=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goBack()},n.goForwards=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goForwards()},n.setResizeMode=function(e){var t;if(n.wasmModule){var o=n.wasmModule.mapResizeMode(e);null===(t=n.playerWasm)||void 0===t||t.setResizeMode(o)}},n.getScreen=function(e){var t;void 0===e&&(e=!0);var o=null===(t=n.playerWasm)||void 0===t?void 0:t.getJSScreen(e);return o?{layers:J(o.layers)}:{layers:[]}},n.settings=Qt.FromSettings(t),re.logDebug("PrototypeRenderer JS constructed with settings:",n.settings),n.gestureManager=new ee(n.settings.container,!1,n.settings.disableInteraction),n.canvasManager=new ae({container:n.settings.container,canvas:n.settings.canvas,maxPixelRatio:3}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return d(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,A()];case 1:return e=t.sent(),this.deviceInfo=h(h({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.detectWebGLVersion=function(){this.webglVersion=q(this.deviceInfo),re.logDebug("Using WebGL ".concat(this.webglVersion))},t.prototype.init=function(){return p(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return this.traceFirstPaint=new ne("FirstPaint"),this.setStatus({type:"INITIALIZING"}),[4,this.collectAndEmitDeviceInfo()];case 1:t.sent(),this.detectWebGLVersion(),t.label=2;case 2:return t.trys.push([2,6,,7]),[4,this.initWasmModule()];case 3:return t.sent(),[4,this.initPlayerWasm()];case 4:return t.sent(),[4,this.startDownload()];case 5:return t.sent(),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof D?e:new D("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initWasmModule=function(){var e;return p(this,void 0,void 0,(function(){var t;return f(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new ne("WasmModuleDownload"),this.wasmModule=new se({mode:this.settings.mode,locateFile:this.settings.locateFile,jsBridge:this.createJSBridge(),featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion}),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.startDownload=function(){var e=this;return this.setStatus({type:"LOADING_FILE"}),new Promise((function(t){var n;null===(n=e.playerWasm)||void 0===n||n.startDownload((function(){t()}))}))},t.prototype.startRendering=function(){var e;this.traceInitialRender=new ne("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.playerWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){re.logDebug("[C++] ".concat(e))},logWarning:function(e){re.logWarning("[C++] ".concat(e))},logError:function(e){re.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t,n){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t].replace(":format",n):e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t).replace(":format",n):(re.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):(re.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(t,n){e.emit("cameraPanChange",t,n)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},onPrototypeStateWillChange:function(t,n,o){e.emit("prototypeStateWillChange",{currentArtboardId:t,canGoBack:n,canGoForwards:o})},onPrototypeStateChange:function(t,n,o){e.emit("prototypeStateChange",{currentArtboardId:t,canGoBack:n,canGoForwards:o})},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onPrototypeUnhandledPointerUp:function(){e.emit("prototypeUnhandledPointerUp")},onSceneChange:function(){e.emit("sceneChange")}}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l,c,d,h;return f(this,(function(p){switch(p.label){case 0:if(this.disposed||!this.wasmModule)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(t.data.contentType)?(i=new Blob([t.data.buffer]),[4,ue(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),this.wasmModule?(s=this.wasmModule.createWebGLTextureFromImage(a,this.webglCtxHandle),n.buffer=new Uint8Array(0),n.isWebGLTexture=!0,n.emscriptenWebGLTextureHandle=s,n.width=a.width,n.height=a.height,[3,4]):[2];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return re.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(l=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==l?l:500,statusText:null!==(d=null===(c=t.data.error)||void 0===c?void 0:c.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=t.data.contentType)&&void 0!==h?h:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0}),[3,7];case 6:return[3,7];case 7:return this.fetchWorker.removeEventListener("message",r),[2]}}))}))};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initPlayerWasm=function(){var e,t;return p(this,void 0,void 0,(function(){var n,o,r,i,a,s,u,l,c,d,p,g,v,m,y,b,w,C,P,S,E;return f(this,(function(f){try{if(!this.wasmModule)throw Error("WASM module not initialized");for(this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:this.webglVersion}),n=this.wasmModule.instance,o=n.RenderTarget,r=n.PrototypeRendererWasm,i=n.PrototypeStructureArtboardVector,a=n.PrototypeStructureFlowVector,s=n.PrototypeStructureAssetVector,u=n.PrototypeStructureFlowTypeEnum,this.renderTarget=o.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),l={artboards:new i},c={Overlay:u.Overlay,Screen:u.Screen},d=0,p=this.settings.prototypeStructure.artboards;d<p.length;d++){for(g=p[d],v=new a,m=0,y=null!==(e=g.flows)&&void 0!==e?e:[];m<y.length;m++)b=y[m],v.push_back(h(h({},b),{type:c[b.type]}));for(w=new s,C=0,P=null!==(t=g.assets)&&void 0!==t?t:[];C<P.length;C++)S=P[C],w.push_back(S);l.artboards.push_back(h(h({},g),{flows:v,assets:w}))}this.playerWasm=new r(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID,l,this.settings.highlightHotspots,this.settings.assetsManagerLimits)}catch(e){throw new D("WASM_ERROR","An error occurred while trying to create the PrototypeRenderer WASM object.",e)}if(!(E=this.playerWasm.getUserEventsCollector()))throw new D("WASM_ERROR","An error occurred while trying to create the user events collector");return this.userEventsCollectorWasm=E,this.playerWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.playerWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.setResizeMode(this.settings.resizeMode),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.playerWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.playerWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},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()):"")}),re.logError(e),e.cause&&re.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(re.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getStatus=function(){return this.status},t.prototype.getArtboardAtPosition=function(e,t){var n=this.playerWasm;if(!n)return null;for(var o=n.getJSScreen(!1),r=n.getPan(),i=n.getZoom(),a=(e-r.x)/i,s=(t-r.y)/i,u=o.layers.size()-1;u>=0;u-=1){var l=o.layers.get(u);if(l&&"artboard"===l.type){var c=l.bounds.x+l.bounds.width,d=l.bounds.y+l.bounds.height;if(a>=l.bounds.x&&s>=l.bounds.y&&a<=c&&s<=d)return l.getNode()}}return null},t.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.dispose=function(){var e,t,n;try{this.disposeFetchWorker(),this.detachAllListeners(),null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.playerWasm)||void 0===t||t.stopRenderLoop(),null===(n=this.playerWasm)||void 0===n||n.delete(),this.renderTarget.delete(),this.playerWasm=void 0,this.wasmModule=void 0,this.disposed=!0}catch(e){this.fail(new D("ERROR","Unexpected exception while disposing the WebRendererWasm object",e))}},t.prototype.mapRelativePositionToCameraPosition=function(e,t){var n=this.playerWasm;return n?n.mapRelativePositionToCameraPosition(e,t):null},t.prototype.updateHighlightHotspotsSetting=function(e){var t=this.playerWasm;if(!t)return null;t.updateHighlightHotspotsSetting(e)},t}(B),tn=r(void 0),nn=r("auto"),on=r(void 0),rn=r(void 0),an=r(void 0),sn=r(void 0),un=function(){var e=i(sn);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},ln=function(e,t){switch(t.type){case"on-status":return h(h({},e),{status:t.status});case"dispose":return h(h({},e),{status:{type:"DISPOSED"},cursor:"auto"});case"on-cursor-change":return h(h({},e),{cursor:t.cursor});case"on-prototype-state-will-change":return h(h({},e),{prototypeState:h(h({},e.prototypeState),{isChanging:!0})});case"on-prototype-state-change":return h(h({},e),{prototypeState:h(h(h({},e.prototypeState),t.prototypeState),{isChanging:!1})});case"on-zoom":return h(h({},e),{zoom:t.zoom});case"on-pan":return h(h({},e),{pan:{x:t.pan.x,y:t.pan.y}});default:return e}},cn=function(n){var r=t(null),i=t(null),u=a(ln,{status:{type:"IDLE"},cursor:"auto",prototypeState:{currentArtboardId:"",canGoBack:!1,canGoForwards:!1,isChanging:!1},zoom:1,pan:{x:0,y:0}}),l=u[0],c=l.status,d=l.cursor,p=l.prototypeState,f=l.zoom,g=l.pan,v=u[1],m=o((function(e){v({type:"on-status",status:e})}),[]),y=o((function(e){return v({type:"on-zoom",zoom:e})}),[]),b=o((function(e,t){return v({type:"on-pan",pan:{x:e,y:t}})}),[]),w=o((function(e){return v({type:"on-cursor-change",cursor:e})}),[]),C=o((function(){return v({type:"on-prototype-state-will-change"})}),[]),P=o((function(e){return v({type:"on-prototype-state-change",prototypeState:e})}),[]),S=o((function(){var e=r.current;e&&(re.logDebug("Provider dispose"),e.off("status",m),e.off("cursorChange",w),e.off("prototypeStateWillChange",C),e.off("prototypeStateChange",P),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.dispose(),r.current=null,v({type:"dispose"}))}),[m,w,C,P,b,y]),E=o((function(e,t){if(e&&t&&i.current){re.logDebug("Provider init");var n=new en(h(h({},i.current),{container:t,canvas:e,manualInitialization:!0}));n.on("status",m),n.on("cursorChange",w),n.on("prototypeStateWillChange",C),n.on("prototypeStateChange",P),n.on("cameraZoomChange",y),n.on("cameraPanChange",b),r.current=n,n.init()}}),[m,w,C,P,b,y]),R=o((function(e){var t,n,o,a,s,u,l,c;re.logDebug("Provider setSettings"),e.backgroundColor&&e.backgroundColor!=(null===(t=i.current)||void 0===t?void 0:t.backgroundColor)&&(null===(n=r.current)||void 0===n||n.setBackgroundColor(e.backgroundColor)),(null===(o=i.current)||void 0===o?void 0:o.resizeMode)!=e.resizeMode&&(null===(a=r.current)||void 0===a||a.setResizeMode(e.resizeMode||k.Fit)),void 0!==e.highlightHotspots&&(null===(s=i.current)||void 0===s?void 0:s.highlightHotspots)!==e.highlightHotspots&&(null===(u=r.current)||void 0===u||u.updateHighlightHotspotsSetting(e.highlightHotspots)),e.disableInteraction!==(null===(l=i.current)||void 0===l?void 0:l.disableInteraction)&&(null===(c=r.current)||void 0===c||c.gestureManager.setDisable(e.disableInteraction||!1)),i.current=e}),[]),M=o((function(){return r.current}),[]),L=s((function(){return{dispose:S,init:E,setSettings:R,getInstance:M,dispatch:v}}),[S,E,R,M]);return e.createElement(sn.Provider,{value:L},e.createElement(tn.Provider,{value:c},e.createElement(nn.Provider,{value:d},e.createElement(on.Provider,{value:p},e.createElement(rn.Provider,{value:f},e.createElement(an.Provider,{value:g},n.children))))))},dn=function(){var e=(0,un().getInstance)();return o((function(t){null==e||e.restartPrototype(t)}),[e])},hn=function(){var e=(0,un().getInstance)();return o((function(){null==e||e.navigateToFirstFlow()}),[e])},pn=function(){var e=(0,un().getInstance)();return o((function(){null==e||e.goBack()}),[e])},fn=function(){var e=(0,un().getInstance)();return o((function(){null==e||e.goForwards()}),[e])},gn=function(){var e=(0,un().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return f(this,(function(o){return[2,null==e?void 0:e.getArtboardAtPosition(t,n)]}))}))}),[e])},vn=function(){var e=(0,un().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},mn=function(){var e=i(tn);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},yn=function(){var e=i(nn);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},bn=function(){var e=i(on);if(void 0===e)throw Error("usePrototypeState must be used within a provider");return e},wn=function(){var e=i(rn);if(void 0===e)throw Error("usePrototypeZoom must be used within a provider");return e},Cn=function(){var e=i(an);if(void 0===e)throw Error("usePrototypePan must be used within a provider");return e},Pn=function(e,t){var n=(0,un().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function Sn(){var e=(0,un().getInstance)();return o((function(t){return void 0===t&&(t=!0),null==e?void 0:e.getScreen(t)}),[e])}var En={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Rn={position:"absolute",top:0,left:0},Mn=function(n){var o=n.locateFile,r=n.imagesURLFormat,i=n.imagesURLMap,a=n.backgroundColor,l=n.mode,c=n.showTilesBorders,d=n.minimumZoomLevel,p=n.maximumZoomLevel,f=n.preserveDrawingBuffer,g=n.children,v=n.containerProps,m=n.canvasProps,y=n.featureFlags,b=n.startArtboardUUID,w=n.prototypeStructure,C=n.fragmentsURLFormat,P=n.fragmentsURLMap,S=n.highlightHotspots,E=n.resizeMode,R=n.assetsManagerLimits,M=n.cursor,L=n.disableInteraction,x=t(null),F=t(null),W=un(),I=W.dispose,A=W.init,T=W.setSettings,U=mn(),k=yn(),D=("function"==typeof M?M(k):M)||k;u((function(){return re.logDebug("PrototypeRenderer mounted"),function(){return re.logDebug("PrototypeRenderer unmounted")}}),[]),u((function(){T({locateFile:o,imagesURLFormat:r,imagesURLMap:i,backgroundColor:a,mode:l,showTilesBorders:c,minimumZoomLevel:d,maximumZoomLevel:p,preserveDrawingBuffer:f,featureFlags:y,startArtboardUUID:b,prototypeStructure:w,fragmentsURLFormat:C,fragmentsURLMap:P,highlightHotspots:S,resizeMode:E,assetsManagerLimits:R,disableInteraction:L})}),[T,o,r,i,a,l,c,d,p,f,y,b,S,E,C,P,w,R,L]),u((function(){return A(x.current,F.current),function(){I()}}),[I,A]);var G=s((function(){return h(h({},En),{cursor:D})}),[D]);return e.createElement("div",h({},v,{ref:F,style:G}),e.createElement("canvas",h({},m,{ref:x,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==U?void 0:U.type.toLowerCase())||"null"),style:Rn})),"READY"===(null==U?void 0:U.type)&&g)},Ln={position:"absolute",inset:0,pointerEvents:"none"};function xn(t){var n=t.visualize,r=void 0!==n&&n,i=Sn(),a=l((function(){return i()||null})),u=a[0],c=a[1],d=o((function(){c(i()||null)}),[i]);Pn("sceneChange",d);var p=s((function(){return h(h({},Ln),{opacity:r?1:0})}),[r]);return u?e.createElement("div",{style:p},u.layers.map((function(t,n){return e.createElement(Fn,{key:"".concat(n,"/").concat(t.id),bounds:t.bounds,id:t.id,name:t.name,type:t.type})}))):null}function Fn(t){var n=t.bounds,o=t.name,r=t.id,i=t.type,a=wn(),u=Cn()||{x:0,y:0},l=u.x,c=u.y,d=s((function(){return h({position:"absolute",left:l/window.devicePixelRatio+n.x*a,top:c/window.devicePixelRatio+n.y*a,width:n.width*a,height:n.height*a,backgroundColor:"rgba(0, 255, 255, 0.2)",border:"2px dotted white"},"hotspot"===i?{cursor:"pointer",pointerEvents:"auto"}:{})}),[n.x,n.y,n.width,n.height,l,c,a,i]);return e.createElement("div",{style:d,"data-testid":"".concat(i,"-").concat(Wn(o),"-").concat(r),"data-entity-name":o,"data-entity-id":r,"data-entity-bounds-x":n.x,"data-entity-bounds-y":n.x,"data-entity-bounds-width":n.width,"data-entity-bounds-height":n.height})}function Wn(e){var t,n;return null!==(n=null===(t=e.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))||void 0===t?void 0:t.join("-").toLowerCase())&&void 0!==n?n:""}export{C as CameraAnimator,Je as CameraMoveContext,qe as CameraZoomingContext,je as CanvasRenderer,et as CanvasRendererProvider,Ot as CanvasRendererReact,fe as ComparisonChangeKind,ge as ComparisonEntityKind,pe as ComparisonValueKind,Xt as ComparisonWorkerClient,Ye as CursorContext,b as DEFAULT_CAMERA_ANIMATION,O as DefaultFeatureFlags,B as EventEmitter,ee as GestureManager,te as KeyboardManager,z as ListenersCollector,ze as PRCursorType,Te as PRLayerSizingBehaviour,Me as PRMarinaBlendMode,me as PRMarinaExportFormatType,Re as PRMarinaLayerBlurType,Pe as PRMarinaLayerBorderPosition,xe as PRMarinaLayerCornerStyle,ye as PRMarinaLayerFillType,Ce as PRMarinaLayerGradientColorInterpolation,we as PRMarinaLayerGradientType,We as PRMarinaLayerHorizontalTextAlignment,be as PRMarinaLayerImageFillType,Se as PRMarinaLayerLineCap,Ee as PRMarinaLayerLineJoin,Ae as PRMarinaLayerTextDecoration,Fe as PRMarinaLayerTextTransform,Le as PRMarinaLayerType,Ie as PRMarinaLayerVerticalTextAlignment,ve as PRMarinaVisibleScaleType,Oe as PRNodeExportFormat,De as PRStackCrossAxisAlignment,Ue as PRStackDirection,ke as PRStackMainAxisAlignment,Ge as PRStackingOrder,Be as PRUserPointerType,Ke as PanContext,ne as Performance,en as PrototypeRenderer,cn as PrototypeRendererProvider,Mn as PrototypeRendererReact,k as PrototypeResizeMode,Ne as PrototypeResizeModeWasm,Ze as PrototypeStructureFlowType,xn as PrototypeTestOverlay,_e as StatusContext,D as WebRendererError,U as WebRendererMode,Ve as ZoomContext,V as clamp,J as convertEmbindVectorToArray,j as debounce,_ as extractPointer,X as generateUUID,q as getSupportedWebGLVersion,Z as getiOSVersion,G as isDefinedPresentationManifestFrame,K as isTouchDevice,re as logger,oe as nextTick,H as parseSafariUserAgent,Qe as reducer,Y as removeUndefinedKeys,Q as safePtrAccess,$t as toDifferences,T as toDrawingBufferColorSpace,$ as touchableClick,Ut as useComparePatchBounds,At as useComparison,it as useCursor,ie as useDebounceFunction,vt as useDecrementZoom,tt as useEvent,Wt as useExportNode,Pt as useGetArtboardAtPosition,St as useGetNodeAtPosition,Et as useGetPanAtPosition,Sn as useGetScreen,pn as useGoBack,fn as useGoForwards,It as useHighlightEntities,gt as useIncrementZoom,st as useIsCameraMoving,at as useIsCameraZooming,Gt as useLoadAllFragments,Rt as useLockCamera,kt as useLogEvent,Ct as useLooseWebGLContext,Mt as useMapRelativePositionToCameraPosition,hn as useNavigateToFirstFlow,ut as usePRFile,ct as usePRFileAllFrames,lt as usePRFileArtboards,dt as usePRFileSections,rt as usePan,yn as usePrototypeCursor,Pn as usePrototypeEvent,gn as usePrototypeGetArtboardAtPosition,vn as usePrototypeMapRelativePositionToCameraPosition,Cn as usePrototypePan,bn as usePrototypeState,mn as usePrototypeStatus,wn as usePrototypeZoom,dn as useRestartPrototype,pt as useRootNodeAbsoluteExtent,ht as useSceneRootNode,mt as useSetPan,ft as useSetZoom,xt as useShowSingleEntity,Ft as useShowSingleFrame,Tt as useSplitView,nt as useStatus,ot as useZoom,yt as useZoomToFit,bt as useZoomToFitNode,wt as useZoomToFitRect};
|
|
@@ -4,10 +4,12 @@ import type { KeptPicture, KeptVersion } from '../comparison-worker/ComparisonWo
|
|
|
4
4
|
*
|
|
5
5
|
* - `insert` adds an entity the page has not got, by uuid, over the page at its old place;
|
|
6
6
|
* - `replace` draws the other version of something the page does have in its place, in the page
|
|
7
|
-
* pass - so it sits under what covers it, inside its masks and under its parents' effects
|
|
7
|
+
* pass - so it sits under what covers it, inside its masks and under its parents' effects;
|
|
8
|
+
* - `overlay` draws it over the page instead, as a ghost in its own colours, so both versions
|
|
9
|
+
* are on screen at once - and so outside the masks, clips and effects a `replace` sits inside.
|
|
8
10
|
*/
|
|
9
11
|
export interface ComparisonPatch {
|
|
10
|
-
kind: 'insert' | 'replace';
|
|
12
|
+
kind: 'insert' | 'replace' | 'overlay';
|
|
11
13
|
/** The node's uuid. */
|
|
12
14
|
id: string;
|
|
13
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComparisonController.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/ComparisonController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACZ,MAAM,kDAAkD,CAAA;AACzD
|
|
1
|
+
{"version":3,"file":"ComparisonController.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/ComparisonController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACZ,MAAM,kDAAkD,CAAA;AACzD;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;IACtC,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAA;IACV;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAC/B,kGAAkG;IAClG,MAAM,EAAE,WAAW,CAAA;IACnB,sCAAsC;IACtC,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B;AAED,iGAAiG;AACjG,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAA;IACd,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,mDAAmD;AACnD,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,OAAO,CAAA;IACnE,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,CAAA;IAC5C,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7E,eAAe,IAAI,OAAO,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAA;IACzC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACxC,UAAU,IAAI,IAAI,CAAA;CACnB;AAED,0DAA0D;AAC1D,MAAM,WAAW,wBAAwB,CAAC,OAAO;IAC/C,8DAA8D;IAC9D,aAAa,IAAI,cAAc,GAAG,IAAI,GAAG,SAAS,CAAA;IAClD,eAAe,IAAI,cAAc,GAAG,IAAI,GAAG,SAAS,CAAA;IACpD,aAAa,IAAI,IAAI,CAAA;IACrB,UAAU,IAAI,OAAO,CAAA;IACrB,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9C,2FAA2F;IAC3F,aAAa,CACX,OAAO,EAAE,OAAO,GACf;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;CAClE;AAED,0CAA0C;AAC1C,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,kBAAkB,EAAE,GAClC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAQjC;AAED,+DAA+D;AAC/D,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACpC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,GACrC,OAAO,CAkBT;AAED;;;;GAIG;AACH,qBAAa,oBAAoB,CAAC,OAAO,GAAG,gBAAgB;IAU9C,OAAO,CAAC,IAAI;IATxB,OAAO,CAAC,IAAI,CAAgC;IAC5C,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,YAAY,CAAQ;IAC5B,kFAAkF;IAClF,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,UAAU,CAAI;IACtB,OAAO,CAAC,OAAO,CAAQ;gBAEH,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC;IAE3D,8FAA8F;IAC9F,GAAG,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO;IAW1C,KAAK;IAQL,4DAA4D;IAC5D,UAAU;IAKV,OAAO;IAMP;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;IAkBjE,2EAA2E;IAC3E,gBAAgB,CAAC,QAAQ,EAAE,MAAM;IAKjC,UAAU;IAKV,SAAS,IAAI,kBAAkB,EAAE;IAKjC,OAAO,CAAC,KAAK;IA+Bb,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,WAAW;IAMnB,4FAA4F;YAC9E,QAAQ;CA0BvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/out/web-renderer/wasm/Debug/web-renderer-debug.wasm
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 62327119 bytes
|
|
4
|
+
sha256: c301eac67601003d7edf977bfbd31bd28911c9fe69e71db50b81012a7b16de03
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sketch-hq/sketch-web-renderer",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.18.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Sketch Web Renderer",
|
|
6
6
|
"repository": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@rollup/plugin-replace": "5.0.2",
|
|
60
60
|
"@rollup/plugin-terser": "0.4.3",
|
|
61
61
|
"@rollup/plugin-typescript": "11.1.1",
|
|
62
|
-
"@sketch-hq/sketch-file-format-marina": "15.
|
|
62
|
+
"@sketch-hq/sketch-file-format-marina": "15.18.0",
|
|
63
63
|
"@types/node": "20.19.27",
|
|
64
64
|
"@types/offscreencanvas": "2019.7.0",
|
|
65
65
|
"@types/pixelmatch": "5.2.4",
|