@sketch-hq/sketch-web-renderer 5.0.2 → 5.1.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.
Files changed (39) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/module-debug-75a788ec.js +6654 -0
  3. package/dist/module-debug.wasm +0 -0
  4. package/dist/module-release-46e1fe74.js +15 -0
  5. package/dist/module-release.wasm +0 -0
  6. package/dist/ts/canvas-renderer/CanvasRenderer.d.ts +3 -0
  7. package/dist/ts/canvas-renderer/CanvasRenderer.d.ts.map +1 -1
  8. package/dist/ts/canvas-renderer/react/CanvasRendererProvider.d.ts.map +1 -1
  9. package/dist/ts/canvas-renderer/react/CanvasRendererReact.d.ts.map +1 -1
  10. package/dist/ts/canvas-renderer/react/hooks/actions.d.ts.map +1 -1
  11. package/dist/ts/index.d.ts +0 -2
  12. package/dist/ts/index.d.ts.map +1 -1
  13. package/dist/ts/prototype-renderer/PrototypeRenderer.d.ts +3 -0
  14. package/dist/ts/prototype-renderer/PrototypeRenderer.d.ts.map +1 -1
  15. package/dist/ts/prototype-renderer/react/PrototypeRendererProvider.d.ts.map +1 -1
  16. package/dist/ts/prototype-renderer/react/PrototypeRendererReact.d.ts.map +1 -1
  17. package/dist/ts/types/Events.d.ts +2 -2
  18. package/dist/ts/types/Events.d.ts.map +1 -1
  19. package/dist/ts/types/index.d.ts +0 -1
  20. package/dist/ts/types/index.d.ts.map +1 -1
  21. package/dist/ts/types/wasm/CanvasRendererWasm.d.ts +1 -2
  22. package/dist/ts/types/wasm/CanvasRendererWasm.d.ts.map +1 -1
  23. package/dist/ts/types/wasm/PrototypeRendererWasm.d.ts +1 -2
  24. package/dist/ts/types/wasm/PrototypeRendererWasm.d.ts.map +1 -1
  25. package/dist/ts/utils/Performance.d.ts +1 -1
  26. package/dist/ts/utils/Performance.d.ts.map +1 -1
  27. package/dist/ts/utils/WasmModule.d.ts +1 -1
  28. package/dist/ts/utils/WasmModule.d.ts.map +1 -1
  29. package/dist/ts/utils/index.d.ts +0 -1
  30. package/dist/ts/utils/index.d.ts.map +1 -1
  31. package/package.json +3 -3
  32. package/dist/ts/canvas-renderer/react/utils.d.ts +0 -6
  33. package/dist/ts/canvas-renderer/react/utils.d.ts.map +0 -1
  34. package/dist/ts/prototype-renderer/react/utils.d.ts +0 -6
  35. package/dist/ts/prototype-renderer/react/utils.d.ts.map +0 -1
  36. package/dist/ts/types/Warning.d.ts +0 -7
  37. package/dist/ts/types/Warning.d.ts.map +0 -1
  38. package/dist/ts/utils/Logger.d.ts +0 -11
  39. package/dist/ts/utils/Logger.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import t,{createContext as e,useContext as n,useRef as o,useReducer as i,useCallback as r,useMemo as s,useEffect as a,useState as u}from"react";const c=new Int32Array(2);var d,l;new Float32Array(c.buffer),new Float64Array(c.buffer),new Uint16Array(new Uint8Array([1,0]).buffer)[0],function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(d||(d={})),function(t){t[t.Default=0]="Default",t[t.None=1]="None",t[t.Low=2]="Low",t[t.Medium=3]="Medium",t[t.High=4]="High"}(l||(l={}));var h,b=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.x=function(){return this.bb.readFloat32(this.bb_pos)},t.prototype.y=function(){return this.bb.readFloat32(this.bb_pos+4)},t.sizeOf=function(){return 8},t.createPoint=function(t,e,n){return t.prep(4,8),t.writeFloat32(n),t.writeFloat32(e),t.offset()},t}(),p=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.width=function(){return this.bb.readFloat32(this.bb_pos)},t.prototype.height=function(){return this.bb.readFloat32(this.bb_pos+4)},t.sizeOf=function(){return 8},t.createSize=function(t,e,n){return t.prep(4,8),t.writeFloat32(n),t.writeFloat32(e),t.offset()},t}(),f=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.origin=function(t){return(t||new b).__init(this.bb_pos,this.bb)},t.prototype.size=function(t){return(t||new p).__init(this.bb_pos+8,this.bb)},t.sizeOf=function(){return 16},t.createRect=function(t,e,n,o,i){return t.prep(4,16),t.prep(4,8),t.writeFloat32(i),t.writeFloat32(o),t.prep(4,8),t.writeFloat32(n),t.writeFloat32(e),t.offset()},t}(),_=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsImageDrawing=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsImageDrawing=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.imageIndex=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb_pos+t):0},t.prototype.rect=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?(t||new f).__init(this.bb_pos+e,this.bb):null},t.prototype.interpolationQuality=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt8(this.bb_pos+t):l.High},t.startImageDrawing=function(t){t.startObject(3)},t.addImageIndex=function(t,e){t.addFieldInt32(0,e,0)},t.addRect=function(t,e){t.addFieldStruct(1,e,0)},t.addInterpolationQuality=function(t,e){t.addFieldInt8(2,e,l.High)},t.endImageDrawing=function(t){return t.endObject()},t}(),g=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsShapeEllipse=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsShapeEllipse=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.rect=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new f).__init(this.bb_pos+e,this.bb):null},t.startShapeEllipse=function(t){t.startObject(1)},t.addRect=function(t,e){t.addFieldStruct(0,e,0)},t.endShapeEllipse=function(t){return t.endObject()},t.createShapeEllipse=function(e,n){return t.startShapeEllipse(e),t.addRect(e,n),t.endShapeEllipse(e)},t}();!function(t){t[t.Winding=0]="Winding",t[t.EvenOdd=1]="EvenOdd"}(h||(h={}));var v,m=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsPath=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsPath=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.points=function(t,e){var n=this.bb.__offset(this.bb_pos,4);return n?(e||new b).__init(this.bb.__vector(this.bb_pos+n)+8*t,this.bb):null},t.prototype.pointsLength=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.operations=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb.__vector(this.bb_pos+e)+t):0},t.prototype.operationsLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.operationsArray=function(){var t=this.bb.__offset(this.bb_pos,6);return t?new Int8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},t.startPath=function(t){t.startObject(2)},t.addPoints=function(t,e){t.addFieldOffset(0,e,0)},t.startPointsVector=function(t,e){t.startVector(8,e,4)},t.addOperations=function(t,e){t.addFieldOffset(1,e,0)},t.createOperationsVector=function(t,e){t.startVector(1,e.length,1);for(var n=e.length-1;n>=0;n--)t.addInt8(e[n]);return t.endVector()},t.startOperationsVector=function(t,e){t.startVector(1,e,1)},t.endPath=function(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e},t.createPath=function(e,n,o){return t.startPath(e),t.addPoints(e,n),t.addOperations(e,o),t.endPath(e)},t}(),y=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsShapePath=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsShapePath=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.path=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new m).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.fillRule=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):h.Winding},t.startShapePath=function(t){t.startObject(2)},t.addPath=function(t,e){t.addFieldOffset(0,e,0)},t.addFillRule=function(t,e){t.addFieldInt8(1,e,h.Winding)},t.endShapePath=function(t){var e=t.endObject();return t.requiredField(e,4),e},t.createShapePath=function(e,n,o){return t.startShapePath(e),t.addPath(e,n),t.addFillRule(e,o),t.endShapePath(e)},t}(),w=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsShapeRect=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsShapeRect=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.rect=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new f).__init(this.bb_pos+e,this.bb):null},t.startShapeRect=function(t){t.startObject(1)},t.addRect=function(t,e){t.addFieldStruct(0,e,0)},t.endShapeRect=function(t){return t.endObject()},t.createShapeRect=function(e,n){return t.startShapeRect(e),t.addRect(e,n),t.endShapeRect(e)},t}();!function(t){t[t.NONE=0]="NONE",t[t.ShapePath=1]="ShapePath",t[t.ShapeRect=2]="ShapeRect",t[t.ShapeEllipse=3]="ShapeEllipse"}(v||(v={}));var C,F=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsBackgroundFilterComponent=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsBackgroundFilterComponent=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.shapeType=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):v.NONE},t.prototype.shape=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__union(t,this.bb_pos+e):null},t.prototype.image=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?(t||new _).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.radius=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.saturation=function(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readFloat32(this.bb_pos+t):1},t.startBackgroundFilterComponent=function(t){t.startObject(5)},t.addShapeType=function(t,e){t.addFieldInt8(0,e,v.NONE)},t.addShape=function(t,e){t.addFieldOffset(1,e,0)},t.addImage=function(t,e){t.addFieldOffset(2,e,0)},t.addRadius=function(t,e){t.addFieldFloat32(3,e,0)},t.addSaturation=function(t,e){t.addFieldFloat32(4,e,1)},t.endBackgroundFilterComponent=function(t){return t.endObject()},t}();!function(t){t[t.Normal=0]="Normal",t[t.DestAtop=1]="DestAtop",t[t.Clear=2]="Clear",t[t.Source=3]="Source",t[t.Darken=4]="Darken",t[t.Multiply=5]="Multiply",t[t.ColorBurn=6]="ColorBurn",t[t.Lighten=7]="Lighten",t[t.Screen=8]="Screen",t[t.ColorDodge=9]="ColorDodge",t[t.Overlay=10]="Overlay",t[t.SoftLight=11]="SoftLight",t[t.HardLight=12]="HardLight",t[t.Difference=13]="Difference",t[t.Exclusion=14]="Exclusion",t[t.Hue=15]="Hue",t[t.Saturation=16]="Saturation",t[t.Color=17]="Color",t[t.Luminosity=18]="Luminosity",t[t.PlusDarker=19]="PlusDarker",t[t.PlusLighter=20]="PlusLighter"}(C||(C={}));var P,I,S,R,E=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsBlendComponent=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsBlendComponent=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.mode=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):C.Normal},t.prototype.opacity=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat32(this.bb_pos+t):1},t.startBlendComponent=function(t){t.startObject(2)},t.addMode=function(t,e){t.addFieldInt8(0,e,C.Normal)},t.addOpacity=function(t,e){t.addFieldFloat32(1,e,1)},t.endBlendComponent=function(t){return t.endObject()},t.createBlendComponent=function(e,n,o){return t.startBlendComponent(e),t.addMode(e,n),t.addOpacity(e,o),t.endBlendComponent(e)},t}(),M=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsCachedExtentComponent=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsCachedExtentComponent=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.rect=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new f).__init(this.bb_pos+e,this.bb):null},t.startCachedExtentComponent=function(t){t.startObject(1)},t.addRect=function(t,e){t.addFieldStruct(0,e,0)},t.endCachedExtentComponent=function(t){return t.endObject()},t.createCachedExtentComponent=function(e,n){return t.startCachedExtentComponent(e),t.addRect(e,n),t.endCachedExtentComponent(e)},t}(),L=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.r=function(){return this.bb.readFloat32(this.bb_pos)},t.prototype.g=function(){return this.bb.readFloat32(this.bb_pos+4)},t.prototype.b=function(){return this.bb.readFloat32(this.bb_pos+8)},t.prototype.a=function(){return this.bb.readFloat32(this.bb_pos+12)},t.sizeOf=function(){return 16},t.createRGBAColor=function(t,e,n,o,i){return t.prep(4,16),t.writeFloat32(i),t.writeFloat32(o),t.writeFloat32(n),t.writeFloat32(e),t.offset()},t}(),D=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDrawingContentAngularGradient=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsDrawingContentAngularGradient=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.center=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new b).__init(this.bb_pos+e,this.bb):null},t.prototype.angle=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.locations=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0},t.prototype.locationsLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.locationsArray=function(){var t=this.bb.__offset(this.bb_pos,8);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},t.prototype.colors=function(t,e){var n=this.bb.__offset(this.bb_pos,10);return n?(e||new L).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null},t.prototype.colorsLength=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0},t.startDrawingContentAngularGradient=function(t){t.startObject(4)},t.addCenter=function(t,e){t.addFieldStruct(0,e,0)},t.addAngle=function(t,e){t.addFieldFloat32(1,e,0)},t.addLocations=function(t,e){t.addFieldOffset(2,e,0)},t.createLocationsVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addFloat32(e[n]);return t.endVector()},t.startLocationsVector=function(t,e){t.startVector(4,e,4)},t.addColors=function(t,e){t.addFieldOffset(3,e,0)},t.startColorsVector=function(t,e){t.startVector(16,e,4)},t.endDrawingContentAngularGradient=function(t){var e=t.endObject();return t.requiredField(e,8),t.requiredField(e,10),e},t.createDrawingContentAngularGradient=function(e,n,o,i,r){return t.startDrawingContentAngularGradient(e),t.addCenter(e,n),t.addAngle(e,o),t.addLocations(e,i),t.addColors(e,r),t.endDrawingContentAngularGradient(e)},t}(),x=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDrawingContentColor=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsDrawingContentColor=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.color=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new L).__init(this.bb_pos+e,this.bb):null},t.startDrawingContentColor=function(t){t.startObject(1)},t.addColor=function(t,e){t.addFieldStruct(0,e,0)},t.endDrawingContentColor=function(t){return t.endObject()},t.createDrawingContentColor=function(e,n){return t.startDrawingContentColor(e),t.addColor(e,n),t.endDrawingContentColor(e)},t}(),O=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDrawingContentImage=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsDrawingContentImage=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.image=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new _).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.tile=function(){var t=this.bb.__offset(this.bb_pos,6);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},t.startDrawingContentImage=function(t){t.startObject(2)},t.addImage=function(t,e){t.addFieldOffset(0,e,0)},t.addTile=function(t,e){t.addFieldInt8(1,+e,0)},t.endDrawingContentImage=function(t){var e=t.endObject();return t.requiredField(e,4),e},t.createDrawingContentImage=function(e,n,o){return t.startDrawingContentImage(e),t.addImage(e,n),t.addTile(e,o),t.endDrawingContentImage(e)},t}(),T=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDrawingContentLinearGradient=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsDrawingContentLinearGradient=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.start=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new b).__init(this.bb_pos+e,this.bb):null},t.prototype.end=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?(t||new b).__init(this.bb_pos+e,this.bb):null},t.prototype.locations=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0},t.prototype.locationsLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.locationsArray=function(){var t=this.bb.__offset(this.bb_pos,8);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},t.prototype.colors=function(t,e){var n=this.bb.__offset(this.bb_pos,10);return n?(e||new L).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null},t.prototype.colorsLength=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0},t.startDrawingContentLinearGradient=function(t){t.startObject(4)},t.addStart=function(t,e){t.addFieldStruct(0,e,0)},t.addEnd=function(t,e){t.addFieldStruct(1,e,0)},t.addLocations=function(t,e){t.addFieldOffset(2,e,0)},t.createLocationsVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addFloat32(e[n]);return t.endVector()},t.startLocationsVector=function(t,e){t.startVector(4,e,4)},t.addColors=function(t,e){t.addFieldOffset(3,e,0)},t.startColorsVector=function(t,e){t.startVector(16,e,4)},t.endDrawingContentLinearGradient=function(t){var e=t.endObject();return t.requiredField(e,8),t.requiredField(e,10),e},t}(),A=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.prototype.a=function(){return this.bb.readFloat32(this.bb_pos)},t.prototype.b=function(){return this.bb.readFloat32(this.bb_pos+4)},t.prototype.c=function(){return this.bb.readFloat32(this.bb_pos+8)},t.prototype.d=function(){return this.bb.readFloat32(this.bb_pos+12)},t.prototype.tx=function(){return this.bb.readFloat32(this.bb_pos+16)},t.prototype.ty=function(){return this.bb.readFloat32(this.bb_pos+20)},t.sizeOf=function(){return 24},t.createMatrix=function(t,e,n,o,i,r,s){return t.prep(4,24),t.writeFloat32(s),t.writeFloat32(r),t.writeFloat32(i),t.writeFloat32(o),t.writeFloat32(n),t.writeFloat32(e),t.offset()},t}(),B=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDrawingContentRadialGradient=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsDrawingContentRadialGradient=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.center=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new b).__init(this.bb_pos+e,this.bb):null},t.prototype.radius=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.locations=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0},t.prototype.locationsLength=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.locationsArray=function(){var t=this.bb.__offset(this.bb_pos,8);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},t.prototype.colors=function(t,e){var n=this.bb.__offset(this.bb_pos,10);return n?(e||new L).__init(this.bb.__vector(this.bb_pos+n)+16*t,this.bb):null},t.prototype.colorsLength=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.ellipseTransform=function(t){var e=this.bb.__offset(this.bb_pos,12);return e?(t||new A).__init(this.bb_pos+e,this.bb):null},t.startDrawingContentRadialGradient=function(t){t.startObject(5)},t.addCenter=function(t,e){t.addFieldStruct(0,e,0)},t.addRadius=function(t,e){t.addFieldFloat32(1,e,0)},t.addLocations=function(t,e){t.addFieldOffset(2,e,0)},t.createLocationsVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addFloat32(e[n]);return t.endVector()},t.startLocationsVector=function(t,e){t.startVector(4,e,4)},t.addColors=function(t,e){t.addFieldOffset(3,e,0)},t.startColorsVector=function(t,e){t.startVector(16,e,4)},t.addEllipseTransform=function(t,e){t.addFieldStruct(4,e,0)},t.endDrawingContentRadialGradient=function(t){var e=t.endObject();return t.requiredField(e,8),t.requiredField(e,10),e},t}(),W=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDrawingContentText=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsDrawingContentText=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startDrawingContentText=function(t){t.startObject(0)},t.endDrawingContentText=function(t){return t.endObject()},t.createDrawingContentText=function(e){return t.startDrawingContentText(e),t.endDrawingContentText(e)},t}();!function(t){t[t.NONE=0]="NONE",t[t.DrawingContentColor=1]="DrawingContentColor",t[t.DrawingContentLinearGradient=2]="DrawingContentLinearGradient",t[t.DrawingContentAngularGradient=3]="DrawingContentAngularGradient",t[t.DrawingContentRadialGradient=4]="DrawingContentRadialGradient",t[t.DrawingContentImage=5]="DrawingContentImage",t[t.DrawingContentText=6]="DrawingContentText"}(P||(P={})),function(t){t[t.Fill=0]="Fill",t[t.Stroke=1]="Stroke",t[t.Knockout=2]="Knockout"}(I||(I={})),function(t){t[t.Butt=0]="Butt",t[t.Round=1]="Round",t[t.Square=2]="Square"}(S||(S={})),function(t){t[t.Miter=0]="Miter",t[t.Round=1]="Round",t[t.Bevel=2]="Bevel"}(R||(R={}));var k,G=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsStroke=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsStroke=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.lineWidth=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.lineCap=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):S.Butt},t.prototype.lineJoin=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt8(this.bb_pos+t):R.Miter},t.prototype.lineDashPhase=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.lineDashPattern=function(t){var e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0},t.prototype.lineDashPatternLength=function(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.lineDashPatternArray=function(){var t=this.bb.__offset(this.bb_pos,12);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},t.prototype.miterLimit=function(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readFloat32(this.bb_pos+t):10},t.startStroke=function(t){t.startObject(6)},t.addLineWidth=function(t,e){t.addFieldFloat32(0,e,0)},t.addLineCap=function(t,e){t.addFieldInt8(1,e,S.Butt)},t.addLineJoin=function(t,e){t.addFieldInt8(2,e,R.Miter)},t.addLineDashPhase=function(t,e){t.addFieldFloat32(3,e,0)},t.addLineDashPattern=function(t,e){t.addFieldOffset(4,e,0)},t.createLineDashPatternVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addFloat32(e[n]);return t.endVector()},t.startLineDashPatternVector=function(t,e){t.startVector(4,e,4)},t.addMiterLimit=function(t,e){t.addFieldFloat32(5,e,10)},t.endStroke=function(t){var e=t.endObject();return t.requiredField(e,12),e},t.createStroke=function(e,n,o,i,r,s,a){return t.startStroke(e),t.addLineWidth(e,n),t.addLineCap(e,o),t.addLineJoin(e,i),t.addLineDashPhase(e,r),t.addLineDashPattern(e,s),t.addMiterLimit(e,a),t.endStroke(e)},t}(),z=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDrawingMask=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsDrawingMask=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.mode=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):I.Fill},t.prototype.shapeType=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):v.NONE},t.prototype.shape=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null},t.prototype.stroke=function(t){var e=this.bb.__offset(this.bb_pos,10);return e?(t||new G).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.strokedPath=function(t){var e=this.bb.__offset(this.bb_pos,12);return e?(t||new m).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.knockoutRect=function(t){var e=this.bb.__offset(this.bb_pos,14);return e?(t||new f).__init(this.bb_pos+e,this.bb):null},t.startDrawingMask=function(t){t.startObject(6)},t.addMode=function(t,e){t.addFieldInt8(0,e,I.Fill)},t.addShapeType=function(t,e){t.addFieldInt8(1,e,v.NONE)},t.addShape=function(t,e){t.addFieldOffset(2,e,0)},t.addStroke=function(t,e){t.addFieldOffset(3,e,0)},t.addStrokedPath=function(t,e){t.addFieldOffset(4,e,0)},t.addKnockoutRect=function(t,e){t.addFieldStruct(5,e,0)},t.endDrawingMask=function(t){return t.endObject()},t}(),N=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsDrawingComponent=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsDrawingComponent=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.contentType=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint8(this.bb_pos+t):P.NONE},t.prototype.content=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__union(t,this.bb_pos+e):null},t.prototype.mask=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?(t||new z).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.startDrawingComponent=function(t){t.startObject(3)},t.addContentType=function(t,e){t.addFieldInt8(0,e,P.NONE)},t.addContent=function(t,e){t.addFieldOffset(1,e,0)},t.addMask=function(t,e){t.addFieldOffset(2,e,0)},t.endDrawingComponent=function(t){var e=t.endObject();return t.requiredField(e,6),e},t}(),j=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsLayerInfoComponent=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsLayerInfoComponent=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.bounds=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new f).__init(this.bb_pos+e,this.bb):null},t.prototype.objectId=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null},t.prototype.traits=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint32(this.bb_pos+t):0},t.prototype.name=function(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null},t.startLayerInfoComponent=function(t){t.startObject(4)},t.addBounds=function(t,e){t.addFieldStruct(0,e,0)},t.addObjectId=function(t,e){t.addFieldOffset(1,e,0)},t.addTraits=function(t,e){t.addFieldInt32(2,e,0)},t.addName=function(t,e){t.addFieldOffset(3,e,0)},t.endLayerInfoComponent=function(t){var e=t.endObject();return t.requiredField(e,6),t.requiredField(e,10),e},t.createLayerInfoComponent=function(e,n,o,i,r){return t.startLayerInfoComponent(e),t.addBounds(e,n),t.addObjectId(e,o),t.addTraits(e,i),t.addName(e,r),t.endLayerInfoComponent(e)},t}();!function(t){t[t.Node=0]="Node",t[t.Clip=1]="Clip",t[t.Knockout=2]="Knockout"}(k||(k={}));var U,Z=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsFragment=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFragment=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.objectId=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},t.startFragment=function(t){t.startObject(1)},t.addObjectId=function(t,e){t.addFieldOffset(0,e,0)},t.endFragment=function(t){return t.endObject()},t.createFragment=function(e,n){return t.startFragment(e),t.addObjectId(e,n),t.endFragment(e)},t}(),V=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsFilterColorControls=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFilterColorControls=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.saturation=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat32(this.bb_pos+t):1},t.prototype.brightness=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.contrast=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.hue=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readFloat32(this.bb_pos+t):0},t.startFilterColorControls=function(t){t.startObject(4)},t.addSaturation=function(t,e){t.addFieldFloat32(0,e,1)},t.addBrightness=function(t,e){t.addFieldFloat32(1,e,0)},t.addContrast=function(t,e){t.addFieldFloat32(2,e,0)},t.addHue=function(t,e){t.addFieldFloat32(3,e,0)},t.endFilterColorControls=function(t){return t.endObject()},t.createFilterColorControls=function(e,n,o,i,r){return t.startFilterColorControls(e),t.addSaturation(e,n),t.addBrightness(e,o),t.addContrast(e,i),t.addHue(e,r),t.endFilterColorControls(e)},t}(),q=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsFilterGaussianBlur=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFilterGaussianBlur=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.radius=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat32(this.bb_pos+t):0},t.startFilterGaussianBlur=function(t){t.startObject(1)},t.addRadius=function(t,e){t.addFieldFloat32(0,e,0)},t.endFilterGaussianBlur=function(t){return t.endObject()},t.createFilterGaussianBlur=function(e,n){return t.startFilterGaussianBlur(e),t.addRadius(e,n),t.endFilterGaussianBlur(e)},t}(),H=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsFilterMotionBlur=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFilterMotionBlur=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.radius=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.angle=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readFloat32(this.bb_pos+t):0},t.startFilterMotionBlur=function(t){t.startObject(2)},t.addRadius=function(t,e){t.addFieldFloat32(0,e,0)},t.addAngle=function(t,e){t.addFieldFloat32(1,e,0)},t.endFilterMotionBlur=function(t){return t.endObject()},t.createFilterMotionBlur=function(e,n,o){return t.startFilterMotionBlur(e),t.addRadius(e,n),t.addAngle(e,o),t.endFilterMotionBlur(e)},t}(),K=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsShadow=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsShadow=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.radius=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.offset=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?(t||new p).__init(this.bb_pos+e,this.bb):null},t.prototype.spread=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.color=function(t){var e=this.bb.__offset(this.bb_pos,10);return e?(t||new L).__init(this.bb_pos+e,this.bb):null},t.startShadow=function(t){t.startObject(4)},t.addRadius=function(t,e){t.addFieldFloat32(0,e,0)},t.addOffset=function(t,e){t.addFieldStruct(1,e,0)},t.addSpread=function(t,e){t.addFieldFloat32(2,e,0)},t.addColor=function(t,e){t.addFieldStruct(3,e,0)},t.endShadow=function(t){return t.endObject()},t}(),Y=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsFilterShadow=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFilterShadow=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.shadow=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new K).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.startFilterShadow=function(t){t.startObject(1)},t.addShadow=function(t,e){t.addFieldOffset(0,e,0)},t.endFilterShadow=function(t){var e=t.endObject();return t.requiredField(e,4),e},t.createFilterShadow=function(e,n){return t.startFilterShadow(e),t.addShadow(e,n),t.endFilterShadow(e)},t}(),$=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsFilterZoomBlur=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFilterZoomBlur=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.radius=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readFloat32(this.bb_pos+t):0},t.prototype.center=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?(t||new b).__init(this.bb_pos+e,this.bb):null},t.startFilterZoomBlur=function(t){t.startObject(2)},t.addRadius=function(t,e){t.addFieldFloat32(0,e,0)},t.addCenter=function(t,e){t.addFieldStruct(1,e,0)},t.endFilterZoomBlur=function(t){return t.endObject()},t}();!function(t){t[t.NONE=0]="NONE",t[t.FilterColorControls=1]="FilterColorControls",t[t.FilterGaussianBlur=2]="FilterGaussianBlur",t[t.FilterMotionBlur=3]="FilterMotionBlur",t[t.FilterZoomBlur=4]="FilterZoomBlur",t[t.FilterShadow=5]="FilterShadow"}(U||(U={}));var X,J=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsSurfaceComponent=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsSurfaceComponent=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.shouldBlendSourceOver=function(){var t=this.bb.__offset(this.bb_pos,4);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},t.prototype.filterType=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):U.NONE},t.prototype.filter=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null},t.startSurfaceComponent=function(t){t.startObject(3)},t.addShouldBlendSourceOver=function(t,e){t.addFieldInt8(0,+e,0)},t.addFilterType=function(t,e){t.addFieldInt8(1,e,U.NONE)},t.addFilter=function(t,e){t.addFieldOffset(2,e,0)},t.endSurfaceComponent=function(t){return t.endObject()},t.createSurfaceComponent=function(e,n,o,i){return t.startSurfaceComponent(e),t.addShouldBlendSourceOver(e,n),t.addFilterType(e,o),t.addFilter(e,i),t.endSurfaceComponent(e)},t}(),Q=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsTransformComponent=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsTransformComponent=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.matrix=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?(t||new A).__init(this.bb_pos+e,this.bb):null},t.startTransformComponent=function(t){t.startObject(1)},t.addMatrix=function(t,e){t.addFieldStruct(0,e,0)},t.endTransformComponent=function(t){return t.endObject()},t.createTransformComponent=function(e,n){return t.startTransformComponent(e),t.addMatrix(e,n),t.endTransformComponent(e)},t}(),tt=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsNode=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsNode=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.children=function(e,n){var o=this.bb.__offset(this.bb_pos,4);return o?(n||new t).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+o)+4*e),this.bb):null},t.prototype.childrenLength=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.enabled=function(){var t=this.bb.__offset(this.bb_pos,6);return!t||!!this.bb.readInt8(this.bb_pos+t)},t.prototype.name=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null},t.prototype.componentsType=function(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0},t.prototype.componentsTypeLength=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.componentsTypeArray=function(){var t=this.bb.__offset(this.bb_pos,10);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},t.prototype.components=function(t,e){var n=this.bb.__offset(this.bb_pos,12);return n?this.bb.__union(e,this.bb.__vector(this.bb_pos+n)+4*t):null},t.prototype.componentsLength=function(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.drawing=function(t){var e=this.bb.__offset(this.bb_pos,14);return e?(t||new N).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.layerInfo=function(t){var e=this.bb.__offset(this.bb_pos,16);return e?(t||new j).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.transform=function(t){var e=this.bb.__offset(this.bb_pos,18);return e?(t||new Q).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.mask=function(t){var e=this.bb.__offset(this.bb_pos,20);return e?(t||new et).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.blend=function(t){var e=this.bb.__offset(this.bb_pos,22);return e?(t||new E).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.surface=function(t){var e=this.bb.__offset(this.bb_pos,24);return e?(t||new J).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.backgroundFilter=function(t){var e=this.bb.__offset(this.bb_pos,26);return e?(t||new F).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.cachedExtent=function(t){var e=this.bb.__offset(this.bb_pos,28);return e?(t||new M).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.fragment=function(t){var e=this.bb.__offset(this.bb_pos,30);return e?(t||new Z).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.startNode=function(t){t.startObject(14)},t.addChildren=function(t,e){t.addFieldOffset(0,e,0)},t.createChildrenVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},t.startChildrenVector=function(t,e){t.startVector(4,e,4)},t.addEnabled=function(t,e){t.addFieldInt8(1,+e,1)},t.addName=function(t,e){t.addFieldOffset(2,e,0)},t.addComponentsType=function(t,e){t.addFieldOffset(3,e,0)},t.createComponentsTypeVector=function(t,e){t.startVector(1,e.length,1);for(var n=e.length-1;n>=0;n--)t.addInt8(e[n]);return t.endVector()},t.startComponentsTypeVector=function(t,e){t.startVector(1,e,1)},t.addComponents=function(t,e){t.addFieldOffset(4,e,0)},t.createComponentsVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},t.startComponentsVector=function(t,e){t.startVector(4,e,4)},t.addDrawing=function(t,e){t.addFieldOffset(5,e,0)},t.addLayerInfo=function(t,e){t.addFieldOffset(6,e,0)},t.addTransform=function(t,e){t.addFieldOffset(7,e,0)},t.addMask=function(t,e){t.addFieldOffset(8,e,0)},t.addBlend=function(t,e){t.addFieldOffset(9,e,0)},t.addSurface=function(t,e){t.addFieldOffset(10,e,0)},t.addBackgroundFilter=function(t,e){t.addFieldOffset(11,e,0)},t.addCachedExtent=function(t,e){t.addFieldOffset(12,e,0)},t.addFragment=function(t,e){t.addFieldOffset(13,e,0)},t.endNode=function(t){var e=t.endObject();return t.requiredField(e,4),e},t}(),et=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsMaskComponent=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsMaskComponent=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.mode=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):k.Node},t.prototype.clipShapeType=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):v.NONE},t.prototype.clipShape=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null},t.prototype.node=function(t){var e=this.bb.__offset(this.bb_pos,10);return e?(t||new tt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.prototype.knockoutRect=function(t){var e=this.bb.__offset(this.bb_pos,12);return e?(t||new f).__init(this.bb_pos+e,this.bb):null},t.startMaskComponent=function(t){t.startObject(5)},t.addMode=function(t,e){t.addFieldInt8(0,e,k.Node)},t.addClipShapeType=function(t,e){t.addFieldInt8(1,e,v.NONE)},t.addClipShape=function(t,e){t.addFieldOffset(2,e,0)},t.addNode=function(t,e){t.addFieldOffset(3,e,0)},t.addKnockoutRect=function(t,e){t.addFieldStruct(4,e,0)},t.endMaskComponent=function(t){return t.endObject()},t}();!function(t){t[t.NONE=0]="NONE",t[t.TransformComponent=1]="TransformComponent",t[t.BlendComponent=2]="BlendComponent",t[t.MaskComponent=3]="MaskComponent",t[t.DrawingComponent=4]="DrawingComponent",t[t.CachedExtentComponent=5]="CachedExtentComponent",t[t.LayerInfoComponent=6]="LayerInfoComponent",t[t.SurfaceComponent=7]="SurfaceComponent",t[t.BackgroundFilterComponent=8]="BackgroundFilterComponent"}(X||(X={}));var nt,ot=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsImage=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsImage=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.prototype.uuid=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},t.prototype.width=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint32(this.bb_pos+t):0},t.prototype.height=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint32(this.bb_pos+t):0},t.prototype.format=function(t){var e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null},t.startImage=function(t){t.startObject(4)},t.addUuid=function(t,e){t.addFieldOffset(0,e,0)},t.addWidth=function(t,e){t.addFieldInt32(1,e,0)},t.addHeight=function(t,e){t.addFieldInt32(2,e,0)},t.addFormat=function(t,e){t.addFieldOffset(3,e,0)},t.endImage=function(t){var e=t.endObject();return t.requiredField(e,10),e},t.createImage=function(e,n,o,i,r){return t.startImage(e),t.addUuid(e,n),t.addWidth(e,o),t.addHeight(e,i),t.addFormat(e,r),t.endImage(e)},t}();!function(t){t[t.MoveTo=0]="MoveTo",t[t.LineTo=1]="LineTo",t[t.QuadTo=2]="QuadTo",t[t.CubicTo=3]="CubicTo",t[t.Close=4]="Close"}(nt||(nt={}));var it=function(){function t(){this.bb=null,this.bb_pos=0}return t.prototype.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},t.getRootAsPresentation=function(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsPresentation=function(e,n){return e.setPosition(e.position()+4),(n||new t).__init(e.readInt32(e.position())+e.position(),e)},t.bufferHasIdentifier=function(t){return t.__has_identifier("PRMR")},t.prototype.images=function(t,e){var n=this.bb.__offset(this.bb_pos,4);return n?(e||new ot).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+4*t),this.bb):null},t.prototype.imagesLength=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0},t.prototype.root=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?(t||new tt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},t.startPresentation=function(t){t.startObject(3)},t.addImages=function(t,e){t.addFieldOffset(0,e,0)},t.createImagesVector=function(t,e){t.startVector(4,e.length,4);for(var n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()},t.startImagesVector=function(t,e){t.startVector(4,e,4)},t.addRoot=function(t,e){t.addFieldOffset(1,e,0)},t.endPresentation=function(t){var e=t.endObject();return t.requiredField(e,4),t.requiredField(e,6),e},t.finishPresentationBuffer=function(t,e){t.finish(e,"PRMR")},t.finishSizePrefixedPresentationBuffer=function(t,e){t.finish(e,"PRMR",!0)},t}(),rt=Object.freeze({__proto__:null,BackgroundFilterComponent:F,BlendComponent:E,get BlendMode(){return C},CachedExtentComponent:M,get Component(){return X},unionToComponent:function(t,e){switch(X[t]){case"NONE":default:return null;case"TransformComponent":return e(new Q);case"BlendComponent":return e(new E);case"MaskComponent":return e(new et);case"DrawingComponent":return e(new N);case"CachedExtentComponent":return e(new M);case"LayerInfoComponent":return e(new j);case"SurfaceComponent":return e(new J);case"BackgroundFilterComponent":return e(new F)}},unionListToComponent:function(t,e,n){switch(X[t]){case"NONE":default:return null;case"TransformComponent":return e(n,new Q);case"BlendComponent":return e(n,new E);case"MaskComponent":return e(n,new et);case"DrawingComponent":return e(n,new N);case"CachedExtentComponent":return e(n,new M);case"LayerInfoComponent":return e(n,new j);case"SurfaceComponent":return e(n,new J);case"BackgroundFilterComponent":return e(n,new F)}},DrawingComponent:N,get DrawingContent(){return P},unionToDrawingContent:function(t,e){switch(P[t]){case"NONE":default:return null;case"DrawingContentColor":return e(new x);case"DrawingContentLinearGradient":return e(new T);case"DrawingContentAngularGradient":return e(new D);case"DrawingContentRadialGradient":return e(new B);case"DrawingContentImage":return e(new O);case"DrawingContentText":return e(new W)}},unionListToDrawingContent:function(t,e,n){switch(P[t]){case"NONE":default:return null;case"DrawingContentColor":return e(n,new x);case"DrawingContentLinearGradient":return e(n,new T);case"DrawingContentAngularGradient":return e(n,new D);case"DrawingContentRadialGradient":return e(n,new B);case"DrawingContentImage":return e(n,new O);case"DrawingContentText":return e(n,new W)}},DrawingContentAngularGradient:D,DrawingContentColor:x,DrawingContentImage:O,DrawingContentLinearGradient:T,DrawingContentRadialGradient:B,DrawingContentText:W,DrawingMask:z,get DrawingMaskMode(){return I},get FillRule(){return h},get Filter(){return U},unionToFilter:function(t,e){switch(U[t]){case"NONE":default:return null;case"FilterColorControls":return e(new V);case"FilterGaussianBlur":return e(new q);case"FilterMotionBlur":return e(new H);case"FilterZoomBlur":return e(new $);case"FilterShadow":return e(new Y)}},unionListToFilter:function(t,e,n){switch(U[t]){case"NONE":default:return null;case"FilterColorControls":return e(n,new V);case"FilterGaussianBlur":return e(n,new q);case"FilterMotionBlur":return e(n,new H);case"FilterZoomBlur":return e(n,new $);case"FilterShadow":return e(n,new Y)}},FilterColorControls:V,FilterGaussianBlur:q,FilterMotionBlur:H,FilterShadow:Y,FilterZoomBlur:$,Fragment:Z,Image:ot,ImageDrawing:_,get InterpolationQuality(){return l},LayerInfoComponent:j,get LineCap(){return S},get LineJoin(){return R},MaskComponent:et,get MaskComponentMode(){return k},Matrix:A,Node:tt,Path:m,get PathOperation(){return nt},Point:b,Presentation:it,RGBAColor:L,Rect:f,Shadow:K,get Shape(){return v},unionToShape:function(t,e){switch(v[t]){case"NONE":default:return null;case"ShapePath":return e(new y);case"ShapeRect":return e(new w);case"ShapeEllipse":return e(new g)}},unionListToShape:function(t,e,n){switch(v[t]){case"NONE":default:return null;case"ShapePath":return e(n,new y);case"ShapeRect":return e(n,new w);case"ShapeEllipse":return e(n,new g)}},ShapeEllipse:g,ShapePath:y,ShapeRect:w,Size:p,Stroke:G,SurfaceComponent:J,TransformComponent:Q}),st=function(t,e){return st=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},st(t,e)};function at(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}st(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var ut=function(){return ut=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},ut.apply(this,arguments)};function ct(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{u(o.next(t))}catch(t){r(t)}}function a(t){try{u(o.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((o=o.apply(t,e||[])).next())}))}function dt(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(s=0)),s;)try{if(n=1,o&&(i=2&a[0]?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],o=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function lt(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}function ht(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{u(o.next(t))}catch(t){r(t)}}function a(t){try{u(o.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((o=o.apply(t,e||[])).next())}))}const bt=["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 pt(t){return t.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const ft="undefined"==typeof window,_t=(()=>{if(ft)return;const{userAgent:t,platform:e,maxTouchPoints:n}=window.navigator,o=/(iphone|ipod|ipad)/i.test(t),i="iPad"===e||"MacIntel"===e&&n>0&&!window.MSStream;return{isIpad:i,isMobile:/android/i.test(t)||o||i,isSafari12:/Version\/12.+Safari/.test(t)}})();const gt=[],vt=[];function mt(t,e){if(t===e)return 0;const n=t;t.length>e.length&&(t=e,e=n);let o=t.length,i=e.length;for(;o>0&&t.charCodeAt(~-o)===e.charCodeAt(~-i);)o--,i--;let r,s=0;for(;s<o&&t.charCodeAt(s)===e.charCodeAt(s);)s++;if(o-=s,i-=s,0===o)return i;let a,u,c=0,d=0,l=0;for(;d<o;)vt[d]=t.charCodeAt(s+d),gt[d]=++d;for(;l<i;)for(r=e.charCodeAt(s+l),a=l++,c=l,d=0;d<o;d++)u=r===vt[d]?a:a+1,a=gt[d],c=gt[d]=a>c?u>c?c+1:u:u>a?a+1:u;return c}function yt(t){return null!=t}class wt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}const Ct=({mobileTiers:t=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:n={},glContext:o,failIfMajorPerformanceCaveat:i=!1,benchmarksURL:r="https://unpkg.com/detect-gpu@4.0.47/dist/benchmarks"}={})=>ht(void 0,void 0,void 0,(function*(){const s={};if(ft)return{tier:0,type:"SSR"};const{isIpad:a=!!(null==_t?void 0:_t.isIpad),isMobile:u=!!(null==_t?void 0:_t.isMobile),screenSize:c=window.screen,loadBenchmarks:d=(t=>ht(void 0,void 0,void 0,(function*(){const e=yield fetch(`${r}/${t}`).then((t=>t.json()));if(parseInt(e.shift().split(".")[0],10)<4)throw new wt("Detect GPU benchmark data is out of date. Please update to version 4x");return e})))}=n;let{renderer:l}=n;const h=(t,e,n,o,i)=>({device:i,fps:o,gpu:n,isMobile:u,tier:t,type:e});let b,p="";if(l)l=pt(l),b=[l];else{const t=o||function(t,e=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:e,powerPreference:"high-performance",stencil:!1};t&&delete n.powerPreference;const o=window.document.createElement("canvas"),i=o.getContext("webgl",n)||o.getContext("experimental-webgl",n);return null!=i?i:void 0}(null==_t?void 0:_t.isSafari12,i);if(!t)return h(0,"WEBGL_UNSUPPORTED");const e=t.getExtension("WEBGL_debug_renderer_info");if(e&&(l=t.getParameter(e.UNMASKED_RENDERER_WEBGL)),!l)return h(1,"FALLBACK");p=l,l=pt(l),b=function(t,e,n){return"apple gpu"===e?function(t,e,n){if(!n)return[e];const o=function(t){const e=t.createShader(35633),n=t.createShader(35632),o=t.createProgram();if(!(n&&e&&o))return;t.shaderSource(e,"\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 "),t.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 "),t.compileShader(e),t.compileShader(n),t.attachShader(o,e),t.attachShader(o,n),t.linkProgram(o),t.detachShader(o,e),t.detachShader(o,n),t.deleteShader(e),t.deleteShader(n),t.useProgram(o);const i=t.createBuffer();t.bindBuffer(34962,i),t.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const r=t.getAttribLocation(o,"aPosition");t.vertexAttribPointer(r,3,5126,!1,0,0),t.enableVertexAttribArray(r),t.clearColor(1,1,1,1),t.clear(16384),t.viewport(0,0,1,1),t.drawArrays(4,0,3);const s=new Uint8Array(4);return t.readPixels(0,0,1,1,6408,5121,s),t.deleteProgram(o),t.deleteBuffer(i),s.join("")}(t),i="801621810",r="8016218135",s="80162181161",a=(null==_t?void 0:_t.isIpad)?[["a7",s,12],["a8",r,15],["a8x",r,15],["a9",r,15],["a9x",r,15],["a10",r,15],["a10x",r,15],["a12",i,15],["a12x",i,15],["a12z",i,15],["a14",i,15],["m1",i,15]]:[["a7",s,12],["a8",r,12],["a9",r,15],["a10",r,15],["a11",i,15],["a12",i,15],["a13",i,15],["a14",i,15]];let u;return"80162181255"===o?u=a.filter((([,,t])=>t>=14)):(u=a.filter((([,t])=>t===o)),u.length||(u=a)),u.map((([t])=>`apple ${t} gpu`))}(t,e,n):[e]}(t,l,u)}const f=(yield Promise.all(b.map((function(t){var e;return ht(this,void 0,void 0,(function*(){const n=(t=>{const e=u?["adreno","apple","mali-t","mali","nvidia","powervr"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of e)if(t.includes(n))return n})(t);if(!n)return;const o=`${u?"m":"d"}-${n}${a?"-ipad":""}.json`,i=s[o]=null!==(e=s[o])&&void 0!==e?e:d(o);let r;try{r=yield i}catch(n){if(n instanceof wt)throw n;return}const l=function(t){var e;const n=(t=t.replace(/\([^)]+\)/,"")).match(/\d+/)||t.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(e=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==e?e:""}(t);let h=r.filter((([,t])=>t===l));h.length||(h=r.filter((([e])=>e.includes(t))));const b=h.length;if(0===b)return;let p,[f,,,_]=b>1?h.map((e=>[e,mt(t,e[0])])).sort((([,t],[,e])=>t-e))[0][0]:h[0],g=Number.MAX_VALUE;const{devicePixelRatio:v}=window,m=c.width*v*c.height*v;for(const t of _){const[e,n]=t,o=e*n,i=Math.abs(m-o);i<g&&(g=i,p=t)}if(!p)return;const[,,y,w]=p;return[g,y,f,w]}))})))).filter(yt).sort((([t=Number.MAX_VALUE,e],[n=Number.MAX_VALUE,o])=>t===n?e-o:t-n));if(!f.length){const t=bt.find((t=>l.includes(t)));return t?h(0,"BLOCKLISTED",t):h(1,"FALLBACK",`${l} (${p})`)}const[,_,g,v]=f[0];if(-1===_)return h(0,"BLOCKLISTED",g,_,v);const m=u?t:e;let y=0;for(let t=0;t<m.length;t++)_>=m[t]&&(y=t);return h(y,"BENCHMARK",g,_,v)}));var Ft,Pt=function(t){function e(n,o,i){var r=this.constructor,s=t.call(this,"(".concat(n,") ").concat(o))||this;return s.code=n,s.cause=i,s.name=e.name,Object.setPrototypeOf(s,r.prototype),s}return at(e,t),e}(Error);!function(t){t.debug="debug",t.release="release"}(Ft||(Ft={}));var It=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){var n,o;this.listeners[t]=null!==(n=this.listeners[t])&&void 0!==n?n:new Set,null===(o=this.listeners[t])||void 0===o||o.add(e)},t.prototype.off=function(t,e){var n;null===(n=this.listeners[t])||void 0===n||n.delete(e)},t.prototype.forwardEvent=function(t,e){this.on(e,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];t.emit.apply(t,lt([e],n,!1))}))},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var o=this.listeners[t];(null==o?void 0:o.size)&&o.forEach((function(t){Promise.resolve().then((function(){t.apply(void 0,e)}))}))},t.prototype.detachAllListeners=function(){this.listeners={}},t}(),St=function(){function t(){this.removeListenerCallbacks=[]}return t.prototype.add=function(t,e,n,o){t.addEventListener(e,n,o);var i=function(){t.removeEventListener(e,n,o)};return this.removeListenerCallbacks.push(i),i},t.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(t){return t()}))},t}(),Rt={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1},Et=function(t){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(t)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},Mt=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,Lt=function(t){if(void 0===t&&(t=window.navigator.userAgent),t.includes("Chrome/")||t.includes("Chromium/")||t.includes("Opera/")||t.includes("Firefox/"))return null;var e=t.match(Mt);if(!e)return null;var n=e[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(e[4])||0,minor:parseInt(e[5])||0,patch:parseInt(e[6])||0}}};function Dt(t,e){var n;function o(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];clearTimeout(n),n=setTimeout((function(){t.apply(void 0,o)}),e)}return o.cancel=function(){n&&clearTimeout(n)},o}function xt(t){var e,n,o,i,r,s=null!==(n=null===(e=t.touches)||void 0===e?void 0:e[0])&&void 0!==n?n:null===(o=t.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(i=null==s?void 0:s.clientX)&&void 0!==i?i:t.clientX,y:null!==(r=null==s?void 0:s.clientY)&&void 0!==r?r:t.clientY}}function Ot(t,e,n){return Math.max(e,Math.min(n,t))}function Tt(){return Lt()&&!Rt.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function At(t){for(var e=t.size(),n=[],o=0;o<e;++o){var i=t.get(o);if(null==i)throw Error("Error converting embind vector to array");n.push(i)}return n}function Bt(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function Wt(t){var e=t;return Object.keys(e).forEach((function(t){void 0===e[t]&&delete e[t]})),e}function kt(t){return Bt()?{onTouchEnd:t}:{onClick:t}}var Gt=function(t){function e(e){var n=t.call(this)||this;return n.listenersCollector=new St,n.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},n.handleGestureStart=function(t){t.preventDefault(),n.state.lastGestureScale=t.scale},n.handleGestureChange=function(t){t.preventDefault();var e=t.scale/n.state.lastGestureScale;n.state.lastGestureScale=t.scale;var o=n.getCorrectPointerPosition(t);n.emitZoomEvent(e,o)},n.handleGestureEnd=function(t){t.preventDefault()},n.handleTouchStart=function(t){t.preventDefault(),n.handleTouchPinchToZoomStart(t),n.emit("pointerdown",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleMouseDown=function(t){t.ctrlKey||(t.preventDefault(),n.emit("pointerdown",{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0}))},n.handleTouchMove=function(t){n.handleTouchPinchToZoomChange(t),n.emit("pointermove",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleMouseMove=function(t){n.updateMousePosition(t)},n.handleGlobalTouchMove=function(t){n.emit("globalpointermove",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleGlobalMouseMove=function(t){n.updateGlobalMousePosition(t)},n.handleTouchPinchToZoomStart=function(t){var e;!t.touches||(null===(e=t.touches)||void 0===e?void 0:e.length)<2||(n.state.pinchToZoomLastDistance=n.calculateDistanceBetweenTouches(t.touches[0],t.touches[1]))},n.handleTouchPinchToZoomChange=function(t){var e;if(t.touches&&!((null===(e=t.touches)||void 0===e?void 0:e.length)<2)){var o=n.calculateDistanceBetweenTouches(t.touches[0],t.touches[1]),i=n.getCorrectPointerPosition(t),r=1+.004*(o-n.state.pinchToZoomLastDistance);n.state.pinchToZoomLastDistance=o,n.emitZoomEvent(r,i)}},n.handleTouchEnd=function(t){var e=n.getCorrectPointerPosition(t);n.emit("pointerup",{position:e,type:"touch",button:0,touchesCount:t.touches.length})},n.handleMouseUp=function(t){n.emit("pointerup",{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},n.handleMouseWheel=function(t){t.preventDefault();var e=t.ctrlKey&&!n.state.isCtrlPressed,o=t.metaKey||e||n.state.isCtrlPressed;if(n.updateMousePosition(t),n.updateGlobalMousePosition(t),o){var i=e?-1:1,r=n.getCorrectPointerPosition(t),s=1+.005*t.deltaY*i;n.emitZoomEvent(s,r)}else n.emit("wheel",{x:-t.deltaX,y:-t.deltaY},{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},n.target=e,n.targetBounds=e.getBoundingClientRect(),n.addListeners(),n}return at(e,t),e.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},e.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},e.prototype.addKeyboardEventListeners=function(){var t=this;this.listenersCollector.add(document,"keydown",(function(e){"Control"===e.key&&(t.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(e){"Control"===e.key&&(t.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(e){e.ctrlKey&&(t.state.isCtrlPressed=!1)}))},e.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)},e.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)},e.prototype.addSafariGesturesEventListeners=function(){Bt()||(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}))},e.prototype.clampPointerToTargetBounds=function(t){return{x:Ot(t.x-this.targetBounds.x,0,this.target.clientWidth),y:Ot(t.y-this.targetBounds.y,0,this.target.clientHeight)}},e.prototype.getCorrectPointerPosition=function(t){var e,n={x:0,y:0};if((null===(e=t.touches)||void 0===e?void 0:e.length)>1){var o=t,i=o.touches[0],r=o.touches[1];n={x:(i.clientX+r.clientX)/2,y:(i.clientY+r.clientY)/2}}else n=xt(t);return this.clampPointerToTargetBounds(n)},e.prototype.updateMousePosition=function(t){this.emit("pointermove",{type:"mouse",position:this.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},e.prototype.updateGlobalMousePosition=function(t){this.emit("globalpointermove",{type:"mouse",position:this.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},e.prototype.calculateDistanceBetweenTouches=function(t,e){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)},e.prototype.emitZoomEvent=function(t,e){this.emit("pinchToZoom",t,e)},e.prototype.dispose=function(){this.listenersCollector.dispose()},e}(It),zt=function(t){function e(e){var n=t.call(this)||this;return n.listenersCollector=new St,n.handleKeyUp=function(t){n.emit("keyUp",t.code)},n.target=e,n.addListeners(),n}return at(e,t),e.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},e.prototype.dispose=function(){this.listenersCollector.dispose()},e}(It),Nt=function(){function t(){this.active=!0}return t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.active&&console.debug.apply(console,lt(["[WR:Debug]"],t,!1))},t.prototype.warning=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.active&&console.warn.apply(console,lt(["[WR:Warn]"],t,!1))},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];console.error.apply(console,lt(["[WR:Error]"],t,!1))},t}(),jt=new Nt,Ut=function(){function t(t){this.label=t,this.startTime=performance.now(),this.startTimestamp=Date.now(),jt.debug("[Performance] Start: ".concat(this.label))}return t.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},t.prototype.printMeasurement=function(){var t=this.measure().duration;if(t<1e3){var e=t.toFixed(2);jt.debug("[Performance] End: ".concat(this.label," -> ").concat(e," ms"))}else{var n=(t/1e3).toFixed(2);jt.debug("[Performance] End: ".concat(this.label," -> ").concat(n," s"))}},t}();function Zt(t){setTimeout((function(){t()}),0)}var Vt=function(t){function e(e){var n=t.call(this)||this;return n.listenersCollector=new St,n.size={width:0,height:0},n.pixelRatio=1,n.handleCanvasResizeObserver=function(t){n.resizeCanvas(t[0].contentRect)},n.resizeCanvas=function(t){var e=t.width,o=t.height;window.requestAnimationFrame((function(){n.setSize(e,o),n.emit("resize",e,o,n.getDevicePixelRatio())}))},n.getCanvasCenterPoint=function(){var t=n.getBoundingClientRect();return{x:t.width/2+t.x,y:t.height/2+t.y}},n.container=e.container,n.canvas=e.canvas,n.canvasResizeObserver=new ResizeObserver(n.handleCanvasResizeObserver),n.canvasResizeObserver.observe(n.container),n.listenersCollector.add(window,"orientationchange",n.handleDeviceOrientationChange),n.setSize(n.container.clientWidth,n.container.clientHeight),n}return at(e,t),e.prototype.setSize=function(t,e){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(t,"px"),this.canvas.style.height="".concat(e,"px"),this.size.width=t*this.pixelRatio,this.size.height=e*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},e.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},e.prototype.getDevicePixelRatio=function(){return Ot(window.devicePixelRatio,1,2)},e.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},e.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},e}(It),qt=function(){function t(t){this.settings=t}return t.prototype.isReleaseMode=function(){return this.settings.mode===Ft.release},t.prototype.init=function(){return ct(this,void 0,void 0,(function(){var t,e,n,o,i,r=this;return dt(this,(function(s){switch(s.label){case 0:return[4,this.importModule()];case 1:t=s.sent(),e=t.default,s.label=2;case 2:return s.trys.push([2,4,,5]),n=this,[4,e({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:Tt(),bridge:this.settings.jsBridge,locateFile:function(t){return r.settings.locateFile.replace("{file}",t)}})];case 3:return n.instance=s.sent(),[3,5];case 4:throw o=s.sent(),new Pt("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerType.Unset,mouse:this.instance.PRUserPointerType.Mouse,touch:this.instance.PRUserPointerType.Touch},this.prCursorTypeToCSSCursorMap=((i={})[this.instance.PRCursorType.Auto.value]="auto",i[this.instance.PRCursorType.Default.value]="default",i[this.instance.PRCursorType.Pointer.value]="pointer",i[this.instance.PRCursorType.Grab.value]="grab",i[this.instance.PRCursorType.Grabbing.value]="grabbing",i),[2]}}))}))},t.prototype.makeWebGLContext=function(t,e){void 0===e&&(e={});var n=ut({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},e);jt.debug("Using WebGL ".concat(n.majorVersion));var o=this.instance.GL.createContext(t,n);if(!o)throw new Pt("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");return o},t.prototype.destroyWebGLContext=function(t){var e,n=null===(e=this.instance)||void 0===e?void 0:e.GL.getContext(t);if(n){var o=n.GLctx.getExtension("WEBGL_lose_context");o?o.loseContext():jt.warning("Unable to retrieve WEBGL_lose_context extension")}else jt.warning("Unable to loose context. WebGL rendering context not found")},t.prototype.importModule=function(){return this.isReleaseMode()?import("./module-release-0b378fd1.js"):import("./module-debug-7ee9ba03.js")},t.prototype.mapToCSSCursor=function(t){return this.prCursorTypeToCSSCursorMap[t.value]},t.prototype.mapToPRPointerType=function(t){var e;return null!==(e=this.pointerTypeToWASMMap[t])&&void 0!==e?e:this.instance.PRUserPointerType.Unset},t.prototype.mapPointerInfo=function(t){return ut(ut({},t),{type:this.mapToPRPointerType(t.type)})},t}(),Ht=function(t){function e(e){var n=t.call(this)||this;return n.status={type:"INIT"},n.handleCanvasResize=function(t,e,o){var i;null===(i=n.pageCanvasWasm)||void 0===i||i.resize(t,e,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(t,e){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(t,e.x,e.y)},n.handleWheelEvent=function(t,e){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(t.x,t.y,n.wasmModule.mapPointerInfo(e))},n.handlePointerDownEvent=function(t){var e;null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(t))},n.handlePointerMoveEvent=function(t){var e;null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(t))},n.handleGlobalPointerMoveEvent=function(t){var e;null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(t))},n.handlePointerUpEvent=function(t){var e;null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(t))},n.settings=ut(ut({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1,panBoundariesPadding:0},Wt(e)),{featureFlags:ut(ut({},Rt),e.featureFlags)}),jt.active=n.settings.mode===Ft.debug,n.gestureManager=new Gt(n.settings.container),n.canvasManager=new Vt({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new qt({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.settings.manualInitialization||n.init(),n}return at(e,t),e.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)},e.prototype.collectAndEmitDeviceInfo=function(){return ct(this,void 0,void 0,(function(){var t;return dt(this,(function(e){switch(e.label){case 0:return[4,Ct()];case 1:return t=e.sent(),this.deviceInfo=ut(ut({},t),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},e.prototype.init=function(){return ct(this,void 0,void 0,(function(){var t;return dt(this,(function(e){switch(e.label){case 0:this.traceFirstPaint=new Ut("FirstPaint"),this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),e.label=1;case 1:return e.trys.push([1,6,,7]),[4,this.initWasmModule()];case 2:return e.sent(),[4,this.initCanvasRendererWasm()];case 3:return e.sent(),[4,this.setFile(this.settings.filePath)];case 4:return e.sent(),[4,this.preloadImages()];case 5:return e.sent(),[3,7];case 6:return t=e.sent(),[2,this.fail(t instanceof Pt?t:new Pt("ERROR","Unexpected exception initializing the web renderer",t))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},e.prototype.setInitialCameraState=function(){var t,e,n,o=void 0!==this.settings.initialZoom,i=void 0!==this.settings.initialPan;o||i?(o&&this.setZoom(this.settings.initialZoom||1),i&&this.setPan((null===(t=this.settings.initialPan)||void 0===t?void 0:t.x)||0,(null===(e=this.settings.initialPan)||void 0===e?void 0:e.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport)):this.zoomToFit()},e.prototype.preloadImages=function(){var t=this;return new Promise((function(e){var n;null===(n=t.pageCanvasWasm)||void 0===n||n.preloadImages((function(){e()}))}))},e.prototype.startRendering=function(){var t;this.traceInitialRender=new Ut("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(t=this.pageCanvasWasm)||void 0===t||t.startRenderLoop()},e.prototype.createJSBridge=function(){var t=this;return{logDebug:function(t){jt.debug("[C++] ".concat(t))},logWarning:function(t){jt.warning("[C++] ".concat(t))},logError:function(t){jt.error("[C++] ".concat(t))},emitMetric:function(e,n,o,i){t.emit("metric",{id:e,start:n,end:o,duration:i})},resolveImageUrl:function(e){return t.settings.imagesURLFormat?t.settings.imagesURLFormat.replace(":imageId",e):t.settings.imagesURLMap&&t.settings.imagesURLMap[e]?t.settings.imagesURLMap[e]:(jt.warning("Not able to resolve the url for the image with UUID: ".concat(e)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){t.emit("allImagesReady")},onCameraMoveStart:function(){t.emit("cameraMoveStart")},onCameraMoveEnd:function(){t.emit("cameraMoveEnd")},onCameraZoomStart:function(){t.emit("cameraZoomStart")},onCameraZoomEnd:function(){t.emit("cameraZoomEnd")},onCameraZoomChange:function(e){t.emit("cameraZoomChange",e)},onCameraPanChange:function(){var e=t.getPan();t.emit("cameraPanChange",(null==e?void 0:e.x)||0,(null==e?void 0:e.y)||0)},onCursorChange:function(e){var n=t.wasmModule.mapToCSSCursor(e);t.emit("cursorChange",n)},onPlayStateChange:function(){}}},e.prototype.downloadImages=function(){var t=this;return new Promise((function(e){var n,o=new Ut("ImagesDownload");null===(n=t.pageCanvasWasm)||void 0===n||n.downloadImages((function(){o.printMeasurement(),t.emit("metric",o.measure()),jt.debug("Images downloaded"),e()}))}))},e.prototype.initWasmModule=function(){return ct(this,void 0,void 0,(function(){var t;return dt(this,(function(e){switch(e.label){case 0:return t=new Ut("WasmModuleDownload"),[4,this.wasmModule.init()];case 1:return e.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},e.prototype.initCanvasRendererWasm=function(){return ct(this,void 0,void 0,(function(){return dt(this,(function(t){try{this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:Tt()}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.pageCanvasWasm=new this.wasmModule.instance.CanvasRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(t){throw new Pt("WASM_ERROR","An error occurred while trying to create the wasm object.",t)}return this.userEventsCollectorWasm=this.pageCanvasWasm.getUserEventsCollector(),this.pageCanvasWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.pageCanvasWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.pageCanvasWasm.setPanBoundariesPadding(this.settings.panBoundariesPadding),[2]}))}))},e.prototype.setIsCameraLocked=function(t){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.setIsCameraLocked(t)},e.prototype.setBackgroundColor=function(t){var e;t.r===this.settings.backgroundColor.r&&t.g===this.settings.backgroundColor.g&&t.b===this.settings.backgroundColor.b&&t.a===this.settings.backgroundColor.a||(null===(e=this.pageCanvasWasm)||void 0===e||e.setBackgroundColor(t.r,t.g,t.b,t.a),this.settings.backgroundColor=t)},e.prototype.generateDocumentPNG=function(){var t;return ct(this,void 0,void 0,(function(){return dt(this,(function(e){switch(e.label){case 0:return[4,this.downloadImages()];case 1:return e.sent(),[2,(null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.generateDocumentPNG())||new Uint8Array(0)]}}))}))},e.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}),this.downloadImages())},e.prototype.looseWebGLContext=function(){this.wasmModule.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},e.prototype.zoomToFit=function(){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.scaleDocumentToFit()},e.prototype.setFile=function(t){return ct(this,void 0,void 0,(function(){var e=this;return dt(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var i;null===(i=e.pageCanvasWasm)||void 0===i||i.setFile(t,(function(t,o,i,r){if(void 0===r&&(r=[]),r.length){jt.debug("Parser warnings: ".concat(r));var s=r.map((function(t){return{key:t}}));e.emit("warnings",s)}e.setStatus({type:"FILE_READY"});var a="".concat(t,"-v").concat("5.0.2");e.emit("fileReady",e.getDocument(),a,o,i),n()}),(function(){return o(new Pt("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},e.prototype.fail=function(t){this.setStatus({type:"FAILURE",code:t.code,message:"".concat(t.toString()).concat(t.cause?"\nWrapped Error: ".concat(t.cause.toString()):"")}),jt.error(t),t.cause&&jt.error(t.cause)},e.prototype.setStatus=function(t){"FAILURE"!==this.status.type&&(jt.debug("Status transition ".concat(this.status.type," => ").concat(t.type,"}")),this.status=t,this.emit("status",t))},e.prototype.getDocument=function(){if(!this.pageCanvasWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var t=this.pageCanvasWasm.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:ut(ut({},t),{artboards:At(t.artboards)})}}return this.cachedDocumentInfo.document},e.prototype.getArtboardAtPosition=function(t,e){if(this.pageCanvasWasm){var n=this.getDocument();if(n){for(var o=this.pageCanvasWasm.getPan(),i=this.pageCanvasWasm.getZoom(),r=(t-o.x)/i,s=(e-o.y)/i,a=0,u=n.artboards;a<u.length;a++){var c=u[a],d=c.bounds.x+c.bounds.width,l=c.bounds.y+c.bounds.height;if(r>=c.bounds.x&&s>=c.bounds.y&&r<=d&&s<=l)return c.objectId}return null}}},e.prototype.getPanAtPosition=function(t,e){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),i=t/o,r=e/o;return{x:n.x-i,y:n.y-r}},e.prototype.getStatus=function(){return this.status},e.prototype.setZoom=function(t,e){var n,o=null!=e?e:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(t,o.x,o.y)},e.prototype.getPan=function(){var t,e,n=this.getDocument().bounds,o=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getPan(),i=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom();return o&&i?{x:o.x/i+n.x,y:o.y/i+n.y}:{x:0,y:0}},e.prototype.getZoom=function(){var t;return(null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom())||0},e.prototype.setPan=function(t,e,n){var o;void 0===n&&(n=!1);var i=t,r=e,s=this.getDocument().bounds,a=this.getZoom();if(n){var u=Math.max(2*a*this.canvasManager.pixelRatio,Number.EPSILON);i+=this.canvasManager.size.width/u,r+=this.canvasManager.size.height/u}var c=(i-s.x)*a,d=(r-s.y)*a;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(c,d)},e.prototype.dispose=function(){var t,e;try{this.detachAllListeners(),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.pageCanvasWasm)||void 0===t||t.stopRenderLoop(),null===(e=this.pageCanvasWasm)||void 0===e||e.delete(),this.renderTarget.delete(),this.pageCanvasWasm=void 0}catch(t){this.fail(new Pt("ERROR","Unexpected exception while disposing the wasm object",t))}},e}(It),Kt=e(void 0),Yt=e(void 0),$t=e(void 0),Xt=e(void 0),Jt=e(void 0),Qt=e(void 0),te=e("auto"),ee=e(void 0),ne=function(){var t=n(ee);if(void 0===t)throw Error("useInternalContext must be used within a provider");return t},oe=function(t,e){switch(e.type){case"on-status":return ut(ut({},t),{status:e.status});case"on-file-ready":return ut(ut({},t),{document:e.document});case"on-zoom":return ut(ut({},t),{zoom:e.zoom});case"on-pan":return ut(ut({},t),{pan:e.pan});case"dispose":return ut(ut({},t),{status:null,zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return ut(ut({},t),{isCameraZooming:!0});case"on-camera-zoom-end":return ut(ut({},t),{isCameraZooming:!1});case"on-camera-move-start":return ut(ut({},t),{isCameraMoving:!0});case"on-camera-move-end":return ut(ut({},t),{isCameraMoving:!1});case"on-cursor-change":return ut(ut({},t),{cursor:e.cursor});default:return t}},ie=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return jt.debug.apply(jt,lt(["CanvasRendererReact"],t,!1))},re=function(e){var n=o(null),a=o(null),u=i(oe,{pan:null,zoom:null,status:null,document:null,isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),c=u[0],d=c.status,l=c.document,h=c.zoom,b=c.pan,p=c.isCameraZooming,f=c.isCameraMoving,_=c.cursor,g=u[1],v=r((function(t){return g({type:"on-zoom",zoom:t})}),[]),m=r((function(t,e){return g({type:"on-pan",pan:{x:t,y:e}})}),[]),y=r((function(t){g({type:"on-status",status:t})}),[]),w=r((function(t){g({type:"on-file-ready",document:t})}),[]),C=r((function(){return g({type:"on-camera-zoom-start"})}),[]),F=r((function(){return g({type:"on-camera-zoom-end"})}),[]),P=r((function(){return g({type:"on-camera-move-start"})}),[]),I=r((function(){return g({type:"on-camera-move-end"})}),[]),S=r((function(t){return g({type:"on-cursor-change",cursor:t})}),[]),R=r((function(){var t=n.current;t&&(ie("dispose"),t.off("status",y),t.off("fileReady",w),t.off("cameraZoomChange",v),t.off("cameraPanChange",m),t.off("cameraZoomStart",C),t.off("cameraZoomEnd",F),t.off("cameraMoveStart",P),t.off("cameraMoveEnd",I),t.off("cursorChange",S),t.dispose(),n.current=null,g({type:"dispose"}))}),[y,w,m,v,C,F,P,I,S]),E=r((function(t,e,o){if(""!==t&&e&&o&&a.current){ie("init");var i=new Ht(ut(ut({},a.current),{filePath:t,container:o,canvas:e}));i.on("status",y),i.on("fileReady",w),i.on("cameraZoomChange",v),i.on("cameraPanChange",m),i.on("cameraZoomStart",C),i.on("cameraZoomEnd",F),i.on("cameraMoveStart",P),i.on("cameraMoveEnd",I),i.on("cursorChange",S),n.current=i}}),[y,w,v,m,C,F,P,I,S]),M=r((function(t){var e;ie("setSettings",t),t.backgroundColor&&(null===(e=n.current)||void 0===e||e.setBackgroundColor(t.backgroundColor)),a.current=t}),[]),L=r((function(){return n.current}),[]),D=s((function(){return{dispose:R,init:E,setSettings:M,getInstance:L,dispatch:g}}),[R,E,M,L]);return t.createElement(ee.Provider,{value:D},t.createElement(Kt.Provider,{value:d},t.createElement(Yt.Provider,{value:l},t.createElement($t.Provider,{value:h},t.createElement(Qt.Provider,{value:b},t.createElement(Xt.Provider,{value:p},t.createElement(Jt.Provider,{value:f},t.createElement(te.Provider,{value:_},e.children))))))))},se=function(){var t=n(Kt);if(void 0===t)throw Error("useStatus must be used within a provider");return t},ae=function(){var t=n(Yt);if(void 0===t)throw Error("useDocument must be used within a provider");return t},ue=function(){var t=n($t);if(void 0===t)throw Error("useZoom must be used within a provider");return t},ce=function(){var t=n(Qt);if(void 0===t)throw Error("usePan must be used within a provider");return t},de=function(){var t=n(te);if(void 0===t)throw Error("useCursor must be used within a provider");return t},le=function(){var t=n(Xt);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return t},he=function(){var t=n(Jt);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return t},be=function(){var t=(0,ne().getInstance)();return r((function(e){ie("setZoom",e),null==t||t.setZoom(e)}),[t])},pe=function(){var t=be(),e=ue();return r((function(){var n;(ie("incrementZoom"),"number"==typeof e)&&(n=e>=1?Math.round(2*e):e>.5?1:2*e,t(n))}),[t,e])},fe=function(){var t=be(),e=ue();return r((function(){ie("decrementZoom"),"number"==typeof e&&t(e/2)}),[t,e])},_e=function(){var t=(0,ne().getInstance)();return r((function(e){var n=e.x,o=e.y,i=e.centerPointInViewport;ie("setPan",n,o,"centerPointInViewport",i),null==t||t.setPan(n,o,i)}),[t])},ge=function(){var t=(0,ne().getInstance)();return r((function(){ie("zoomToFit"),null==t||t.zoomToFit()}),[t])},ve=function(){var t=(0,ne().getInstance)();return r((function(){ie("looseWebGLContext"),null==t||t.looseWebGLContext()}),[t])},me=function(){var t=(0,ne().getInstance)();return r((function(){return ct(void 0,void 0,void 0,(function(){return dt(this,(function(e){switch(e.label){case 0:return ie("generateDocumentPNG"),[4,null==t?void 0:t.generateDocumentPNG()];case 1:return[2,e.sent()]}}))}))}),[t])},ye=function(){var t=(0,ne().getInstance)();return r((function(e,n){return ct(void 0,void 0,void 0,(function(){return dt(this,(function(o){switch(o.label){case 0:return ie("getArtboardAtPosition",e,n),[4,null==t?void 0:t.getArtboardAtPosition(e,n)];case 1:return[2,o.sent()||null]}}))}))}),[t])},we=function(){var t=(0,ne().getInstance)();return r((function(e,n){return ct(void 0,void 0,void 0,(function(){return dt(this,(function(o){switch(o.label){case 0:return ie("getPanAtPosition",e,n),[4,null==t?void 0:t.getPanAtPosition(e,n)];case 1:return[2,o.sent()||null]}}))}))}),[t])},Ce=function(){var t=(0,ne().getInstance)();return r((function(e){ie("setIsCameraLocked",e),null==t||t.setIsCameraLocked(e)}),[t])},Fe=function(t,e){var n=(0,ne().getInstance)();a((function(){return null==n||n.on(t,e),function(){null==n||n.off(t,e)}}),[t,n,e])},Pe={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Ie={position:"absolute",top:0,left:0},Se=function(e){jt.active=e.mode===Ft.debug;var n=e.filePath,i=e.locateFile,c=e.imagesURLFormat,d=e.imagesURLMap,l=e.backgroundColor,h=e.mode,b=e.showTilesBorders,p=e.minimumZoomLevel,f=e.maximumZoomLevel,_=e.preserveDrawingBuffer,g=e.panBoundariesPadding,v=e.initialPan,m=e.initialZoom,y=e.children,w=e.containerProps,C=void 0===w?{}:w,F=e.canvasProps,P=void 0===F?{}:F,I=e.featureFlags,S=void 0===I?{}:I,R=o(null),E=o(null),M=u(!1),L=M[0],D=M[1],x=r((function(){return D(!0)}),[]),O=ne(),T=O.dispose,A=O.init,B=O.setSettings,W=de(),k=se();Fe("allImagesReady",x),a((function(){B({locateFile:i,imagesURLFormat:c,imagesURLMap:d,backgroundColor:l,mode:h,showTilesBorders:b,minimumZoomLevel:p,maximumZoomLevel:f,preserveDrawingBuffer:_,panBoundariesPadding:g,initialPan:v,initialZoom:m,featureFlags:S})}),[B,i,c,d,l,h,b,p,f,_,g,v,m,S]),a((function(){if(n)return A(n,R.current,E.current),function(){T()}}),[T,A,n]);var G=s((function(){var t;return null!==(t=e.cursor)&&void 0!==t?t:W}),[e.cursor,W]),z=s((function(){return ut(ut({},Pe),{cursor:G})}),[G]);return t.createElement("div",ut({},C,{ref:E,style:z}),n&&t.createElement("canvas",ut({},P,{key:n,ref:R,"data-sketchweb-all-images-ready":L,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==k?void 0:k.type.toLowerCase())||"null"),style:Ie})),"READY"===(null==k?void 0:k.type)&&y)},Re=function(t){function e(e){var n=t.call(this)||this;return n.status={type:"INIT"},n.handleCanvasResize=function(t,e,o){var i;null===(i=n.playerWasm)||void 0===i||i.resize(t,e,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(t,e){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(t,e.x,e.y)},n.handleWheelEvent=function(t,e){n.userEventsCollectorWasm.dispatchWheelEvent(t.x,t.y,n.wasmModule.mapPointerInfo(e))},n.handlePointerDownEvent=function(t){n.userEventsCollectorWasm.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(t))},n.handlePointerMoveEvent=function(t){n.userEventsCollectorWasm.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(t))},n.handleGlobalPointerMoveEvent=function(t){n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(t))},n.handlePointerUpEvent=function(t){n.userEventsCollectorWasm.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(t))},n.restartPrototype=function(t){var e;null===(e=n.playerWasm)||void 0===e||e.restartPrototype(t)},n.goBack=function(){var t;null===(t=n.playerWasm)||void 0===t||t.goBack()},n.goForwards=function(){var t;null===(t=n.playerWasm)||void 0===t||t.goForwards()},n.settings=ut(ut({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1},Wt(e)),{featureFlags:ut(ut({},Rt),e.featureFlags)}),jt.active=n.settings.mode===Ft.debug,n.gestureManager=new Gt(n.settings.container),n.canvasManager=new Vt({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new qt({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.settings.manualInitialization||n.init(),n}return at(e,t),e.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)},e.prototype.collectAndEmitDeviceInfo=function(){return ct(this,void 0,void 0,(function(){var t;return dt(this,(function(e){switch(e.label){case 0:return[4,Ct()];case 1:return t=e.sent(),this.deviceInfo=ut(ut({},t),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},e.prototype.init=function(){return ct(this,void 0,void 0,(function(){var t;return dt(this,(function(e){switch(e.label){case 0:this.traceFirstPaint=new Ut("FirstPaint"),this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),e.label=1;case 1:return e.trys.push([1,6,,7]),[4,this.initWasmModule()];case 2:return e.sent(),[4,this.initPlayerWasm()];case 3:return e.sent(),[4,this.setFile(this.settings.filePath)];case 4:return e.sent(),[4,this.preloadImages()];case 5:return e.sent(),[3,7];case 6:return t=e.sent(),[2,this.fail(t instanceof Pt?t:new Pt("ERROR","Unexpected exception initializing the web renderer",t))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},e.prototype.initWasmModule=function(){return ct(this,void 0,void 0,(function(){var t;return dt(this,(function(e){switch(e.label){case 0:return t=new Ut("WasmModuleDownload"),[4,this.wasmModule.init()];case 1:return e.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},e.prototype.setInitialCameraState=function(){this.zoomToFit()},e.prototype.preloadImages=function(){var t=this;return new Promise((function(e){var n;null===(n=t.playerWasm)||void 0===n||n.preloadImages((function(){e()}))}))},e.prototype.startRendering=function(){var t;this.traceInitialRender=new Ut("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(t=this.playerWasm)||void 0===t||t.startRenderLoop()},e.prototype.createJSBridge=function(){var t=this;return{logDebug:function(t){jt.debug("[C++] ".concat(t))},logWarning:function(t){jt.warning("[C++] ".concat(t))},logError:function(t){jt.error("[C++] ".concat(t))},emitMetric:function(e,n,o,i){t.emit("metric",{id:e,start:n,end:o,duration:i})},resolveImageUrl:function(e){return t.settings.imagesURLFormat?t.settings.imagesURLFormat.replace(":imageId",e):t.settings.imagesURLMap&&t.settings.imagesURLMap[e]?t.settings.imagesURLMap[e]:(jt.warning("Not able to resolve the url for the image with UUID: ".concat(e)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){t.emit("allImagesReady")},onCameraMoveStart:function(){t.emit("cameraMoveStart")},onCameraMoveEnd:function(){t.emit("cameraMoveEnd")},onCameraZoomStart:function(){t.emit("cameraZoomStart")},onCameraZoomEnd:function(){t.emit("cameraZoomEnd")},onCameraZoomChange:function(e){t.emit("cameraZoomChange",e)},onCameraPanChange:function(e,n){t.emit("cameraPanChange",e,n)},onCursorChange:function(e){var n=t.wasmModule.mapToCSSCursor(e);t.emit("cursorChange",n)},onPlayStateChange:function(e,n,o){t.emit("playStateChange",{screenArtboardId:e,canGoBack:n,canGoForwards:o})}}},e.prototype.downloadImages=function(){var t=this;return new Promise((function(e){var n,o=new Ut("ImagesDownload");null===(n=t.playerWasm)||void 0===n||n.downloadImages((function(){o.printMeasurement(),t.emit("metric",o.measure()),jt.debug("Images downloaded"),e()}))}))},e.prototype.initPlayerWasm=function(){return ct(this,void 0,void 0,(function(){return dt(this,(function(t){try{this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:Tt()}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.playerWasm=new this.wasmModule.instance.PrototypeRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID)}catch(t){throw new Pt("WASM_ERROR","An error occurred while trying to create the WebRendererWasm object.",t)}return this.userEventsCollectorWasm=this.playerWasm.getUserEventsCollector(),this.playerWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.playerWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),[2]}))}))},e.prototype.setIsCameraLocked=function(t){var e;null===(e=this.playerWasm)||void 0===e||e.setIsCameraLocked(t)},e.prototype.setBackgroundColor=function(t){var e;t.r===this.settings.backgroundColor.r&&t.g===this.settings.backgroundColor.g&&t.b===this.settings.backgroundColor.b&&t.a===this.settings.backgroundColor.a||(null===(e=this.playerWasm)||void 0===e||e.setBackgroundColor(t.r,t.g,t.b,t.a),this.settings.backgroundColor=t)},e.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}),this.downloadImages())},e.prototype.looseWebGLContext=function(){this.wasmModule.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},e.prototype.zoomToFit=function(){var t;null===(t=this.playerWasm)||void 0===t||t.scaleDocumentToFit()},e.prototype.setFile=function(t){return ct(this,void 0,void 0,(function(){var e=this;return dt(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var i;null===(i=e.playerWasm)||void 0===i||i.setFile(t,(function(t,o,i,r){if(void 0===r&&(r=[]),r.length){jt.debug("Parser warnings: ".concat(r));var s=r.map((function(t){return{key:t}}));e.emit("warnings",s)}e.setStatus({type:"FILE_READY"});var a="".concat(t,"-v").concat("5.0.2");e.emit("fileReady",e.getDocument(),a,o,i),n()}),(function(){return o(new Pt("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},e.prototype.fail=function(t){this.setStatus({type:"FAILURE",code:t.code,message:"".concat(t.toString()).concat(t.cause?"\nWrapped Error: ".concat(t.cause.toString()):"")}),jt.error(t),t.cause&&jt.error(t.cause)},e.prototype.setStatus=function(t){"FAILURE"!==this.status.type&&(jt.debug("Status transition ".concat(this.status.type," => ").concat(t.type,"}")),this.status=t,this.emit("status",t))},e.prototype.getStatus=function(){return this.status},e.prototype.getDocument=function(){var t;if(!this.playerWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var e=null===(t=this.playerWasm)||void 0===t?void 0:t.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:ut(ut({},e),{artboards:At(e.artboards)})}}return this.cachedDocumentInfo.document},e.prototype.dispose=function(){var t,e;try{this.detachAllListeners(),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.playerWasm)||void 0===t||t.stopRenderLoop(),null===(e=this.playerWasm)||void 0===e||e.delete(),this.renderTarget.delete(),this.playerWasm=void 0}catch(t){this.fail(new Pt("ERROR","Unexpected exception while disposing the WebRendererWasm object",t))}},e}(It),Ee=e(void 0),Me=e("auto"),Le=e(void 0),De=e(void 0),xe=function(){var t=n(De);if(void 0===t)throw Error("useInternalContext must be used within a provider");return t},Oe=function(t,e){switch(e.type){case"on-status":return ut(ut({},t),{status:e.status});case"dispose":return ut(ut({},t),{status:null,cursor:"auto"});case"on-cursor-change":return ut(ut({},t),{cursor:e.cursor});case"on-play-state-change":return ut(ut({},t),{playState:ut(ut({},t.playState),e.playState)});default:return t}},Te=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return jt.debug.apply(jt,lt(["PrototypeRendererReact"],t,!1))},Ae=function(e){var n=o(null),a=o(null),u=i(Oe,{status:null,cursor:"auto",playState:{screenArtboardId:"",canGoBack:!0,canGoForwards:!0}}),c=u[0],d=c.status,l=c.cursor,h=c.playState,b=u[1],p=r((function(t){b({type:"on-status",status:t})}),[]),f=r((function(t){return b({type:"on-cursor-change",cursor:t})}),[]),_=r((function(t){return b({type:"on-play-state-change",playState:t})}),[]),g=r((function(){var t=n.current;t&&(Te("dispose"),t.off("status",p),t.off("cursorChange",f),t.off("playStateChange",_),t.dispose(),n.current=null,b({type:"dispose"}))}),[p,f,_]),v=r((function(t,e,o){if(""!==t&&e&&o&&a.current){Te("init");var i=new Re(ut(ut({},a.current),{filePath:t,container:o,canvas:e}));i.on("status",p),i.on("cursorChange",f),i.on("playStateChange",_),n.current=i}}),[p,f,_]),m=r((function(t){var e;Te("setSettings",t),t.backgroundColor&&(null===(e=n.current)||void 0===e||e.setBackgroundColor(t.backgroundColor)),a.current=t}),[]),y=r((function(){return n.current}),[]),w=s((function(){return{dispose:g,init:v,setSettings:m,getInstance:y,dispatch:b}}),[g,v,m,y]);return t.createElement(De.Provider,{value:w},t.createElement(Ee.Provider,{value:d},t.createElement(Me.Provider,{value:l},t.createElement(Le.Provider,{value:h},e.children))))},Be=function(){var t=(0,xe().getInstance)();return r((function(e){null==t||t.restartPrototype(e)}),[t])},We=function(){var t=(0,xe().getInstance)();return r((function(){null==t||t.goBack()}),[t])},ke=function(){var t=(0,xe().getInstance)();return r((function(){null==t||t.goForwards()}),[t])},Ge=function(){var t=n(Ee);if(void 0===t)throw Error("usePrototypeStatus must be used within a provider");return t},ze=function(){var t=n(Me);if(void 0===t)throw Error("usePrototypeCursor must be used within a provider");return t},Ne=function(){var t=n(Le);if(void 0===t)throw Error("usePrototypePlayState must be used within a provider");return t},je=function(t,e){var n=(0,xe().getInstance)();a((function(){return null==n||n.on(t,e),function(){null==n||n.off(t,e)}}),[t,n,e])},Ue={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Ze={position:"absolute",top:0,left:0},Ve=function(e){jt.active=e.mode===Ft.debug;var n=e.filePath,i=e.locateFile,r=e.imagesURLFormat,u=e.imagesURLMap,c=e.backgroundColor,d=e.mode,l=e.showTilesBorders,h=e.minimumZoomLevel,b=e.maximumZoomLevel,p=e.preserveDrawingBuffer,f=e.children,_=e.containerProps,g=void 0===_?{}:_,v=e.canvasProps,m=void 0===v?{}:v,y=e.featureFlags,w=void 0===y?{}:y,C=e.startArtboardUUID,F=o(null),P=o(null),I=xe(),S=I.dispose,R=I.init,E=I.setSettings,M=ze(),L=Ge();a((function(){E({locateFile:i,imagesURLFormat:r,imagesURLMap:u,backgroundColor:c,mode:d,showTilesBorders:l,minimumZoomLevel:h,maximumZoomLevel:b,preserveDrawingBuffer:p,featureFlags:w,startArtboardUUID:C})}),[E,i,r,u,c,d,l,h,b,p,w,C]),a((function(){if(n)return R(n,F.current,P.current),function(){S()}}),[S,R,n]);var D=s((function(){return ut(ut({},Ue),{cursor:M})}),[M]);return t.createElement("div",ut({},g,{ref:P,style:D}),n&&t.createElement("canvas",ut({},m,{key:n,ref:F,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==L?void 0:L.type.toLowerCase())||"null"),style:Ze})),"READY"===(null==L?void 0:L.type)&&f)};export{Jt as CameraMoveContext,Xt as CameraZoomingContext,Ht as CanvasRenderer,re as CanvasRendererProvider,Se as CanvasRendererReact,te as CursorContext,Rt as DefaultFeatureFlags,Yt as DocumentContext,It as EventEmitter,rt as FileFormat,Gt as GestureManager,zt as KeyboardManager,St as ListenersCollector,Nt as Logger,Qt as PanContext,Ut as Performance,Re as PrototypeRenderer,Ae as PrototypeRendererProvider,Ve as PrototypeRendererReact,Kt as StatusContext,Pt as WebRendererError,Ft as WebRendererMode,$t as ZoomContext,Ot as clamp,At as convertEmbindVectorToArray,Dt as debounce,xt as extractPointer,Tt as getSupportedWebGLVersion,Et as getiOSVersion,Bt as isTouchDevice,jt as logger,Zt as nextTick,Lt as parseSafariUserAgent,oe as reducer,Wt as removeUndefinedKeys,kt as touchableClick,de as useCursor,fe as useDecrementZoom,ae as useDocument,Fe as useEvent,me as useGenerateDocumentPNG,ye as useGetArtboardAtPosititon,we as useGetPanAtPosition,We as useGoBack,ke as useGoForwards,pe as useIncrementZoom,he as useIsCameraMoving,le as useIsCameraZooming,Ce as useLockCamera,ve as useLooseWebGLContext,ce as usePan,ze as usePrototypeCursor,je as usePrototypeEvent,Ne as usePrototypePlayState,Ge as usePrototypeStatus,Be as useRestartPrototype,_e as useSetPan,be as useSetZoom,se as useStatus,ue as useZoom,ge as useZoomToFit};
1
+ import t,{createContext as e,useContext as n,useRef as o,useReducer as r,useCallback as i,useMemo as a,useEffect as s,useState as u}from"react";var c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)};function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var d=function(){return d=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},d.apply(this,arguments)};function h(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function s(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((o=o.apply(t,e||[])).next())}))}function p(t,e){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=e.call(t,a)}catch(t){s=[6,t],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 v(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function g(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function s(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((o=o.apply(t,e||[])).next())}))}const f=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function m(t){return t.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const y="undefined"==typeof window,C=(()=>{if(y)return;const{userAgent:t,platform:e,maxTouchPoints:n}=window.navigator,o=/(iphone|ipod|ipad)/i.test(t),r="iPad"===e||"MacIntel"===e&&n>0&&!window.MSStream;return{isIpad:r,isMobile:/android/i.test(t)||o||r,isSafari12:/Version\/12.+Safari/.test(t)}})();const w=[],b=[];function P(t,e){if(t===e)return 0;const n=t;t.length>e.length&&(t=e,e=n);let o=t.length,r=e.length;for(;o>0&&t.charCodeAt(~-o)===e.charCodeAt(~-r);)o--,r--;let i,a=0;for(;a<o&&t.charCodeAt(a)===e.charCodeAt(a);)a++;if(o-=a,r-=a,0===o)return r;let s,u,c=0,l=0,d=0;for(;l<o;)b[l]=t.charCodeAt(a+l),w[l]=++l;for(;d<r;)for(i=e.charCodeAt(a+d),s=d++,c=d,l=0;l<o;l++)u=i===b[l]?s:s+1,s=w[l],c=w[l]=s>c?u>c?c+1:u:u>s?s+1:u;return c}function E(t){return null!=t}class M extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}const R=({mobileTiers:t=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:n={},glContext:o,failIfMajorPerformanceCaveat:r=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@4.0.47/dist/benchmarks"}={})=>g(void 0,void 0,void 0,(function*(){const a={};if(y)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==C?void 0:C.isIpad),isMobile:u=!!(null==C?void 0:C.isMobile),screenSize:c=window.screen,loadBenchmarks:l=(t=>g(void 0,void 0,void 0,(function*(){const e=yield fetch(`${i}/${t}`).then((t=>t.json()));if(parseInt(e.shift().split(".")[0],10)<4)throw new M("Detect GPU benchmark data is out of date. Please update to version 4x");return e})))}=n;let{renderer:d}=n;const h=(t,e,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:u,tier:t,type:e});let p,v="";if(d)d=m(d),p=[d];else{const t=o||function(t,e=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:e,powerPreference:"high-performance",stencil:!1};t&&delete n.powerPreference;const o=window.document.createElement("canvas"),r=o.getContext("webgl",n)||o.getContext("experimental-webgl",n);return null!=r?r:void 0}(null==C?void 0:C.isSafari12,r);if(!t)return h(0,"WEBGL_UNSUPPORTED");const e=t.getExtension("WEBGL_debug_renderer_info");if(e&&(d=t.getParameter(e.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");v=d,d=m(d),p=function(t,e,n){return"apple gpu"===e?function(t,e,n){if(!n)return[e];const o=function(t){const e=t.createShader(35633),n=t.createShader(35632),o=t.createProgram();if(!(n&&e&&o))return;t.shaderSource(e,"\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 "),t.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 "),t.compileShader(e),t.compileShader(n),t.attachShader(o,e),t.attachShader(o,n),t.linkProgram(o),t.detachShader(o,e),t.detachShader(o,n),t.deleteShader(e),t.deleteShader(n),t.useProgram(o);const r=t.createBuffer();t.bindBuffer(34962,r),t.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const i=t.getAttribLocation(o,"aPosition");t.vertexAttribPointer(i,3,5126,!1,0,0),t.enableVertexAttribArray(i),t.clearColor(1,1,1,1),t.clear(16384),t.viewport(0,0,1,1),t.drawArrays(4,0,3);const a=new Uint8Array(4);return t.readPixels(0,0,1,1,6408,5121,a),t.deleteProgram(o),t.deleteBuffer(r),a.join("")}(t),r="801621810",i="8016218135",a="80162181161",s=(null==C?void 0:C.isIpad)?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["m1",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15]];let u;return"80162181255"===o?u=s.filter((([,,t])=>t>=14)):(u=s.filter((([,t])=>t===o)),u.length||(u=s)),u.map((([t])=>`apple ${t} gpu`))}(t,e,n):[e]}(t,d,u)}const w=(yield Promise.all(p.map((function(t){var e;return g(this,void 0,void 0,(function*(){const n=(t=>{const e=u?["adreno","apple","mali-t","mali","nvidia","powervr"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of e)if(t.includes(n))return n})(t);if(!n)return;const o=`${u?"m":"d"}-${n}${s?"-ipad":""}.json`,r=a[o]=null!==(e=a[o])&&void 0!==e?e:l(o);let i;try{i=yield r}catch(n){if(n instanceof M)throw n;return}const d=function(t){var e;const n=(t=t.replace(/\([^)]+\)/,"")).match(/\d+/)||t.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(e=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==e?e:""}(t);let h=i.filter((([,t])=>t===d));h.length||(h=i.filter((([e])=>e.includes(t))));const p=h.length;if(0===p)return;let v,[g,,,f]=p>1?h.map((e=>[e,P(t,e[0])])).sort((([,t],[,e])=>t-e))[0][0]:h[0],m=Number.MAX_VALUE;const{devicePixelRatio:y}=window,C=c.width*y*c.height*y;for(const t of f){const[e,n]=t,o=e*n,r=Math.abs(C-o);r<m&&(m=r,v=t)}if(!v)return;const[,,w,b]=v;return[m,w,g,b]}))})))).filter(E).sort((([t=Number.MAX_VALUE,e],[n=Number.MAX_VALUE,o])=>t===n?e-o:t-n));if(!w.length){const t=f.find((t=>d.includes(t)));return t?h(0,"BLOCKLISTED",t):h(1,"FALLBACK",`${d} (${v})`)}const[,b,R,L]=w[0];if(-1===b)return h(0,"BLOCKLISTED",R,b,L);const I=u?t:e;let W=0;for(let t=0;t<I.length;t++)b>=I[t]&&(W=t);return h(W,"BENCHMARK",R,b,L)}));var L,I=function(t){function e(n,o,r){var i=this.constructor,a=t.call(this,"(".concat(n,") ").concat(o))||this;return a.code=n,a.cause=r,a.name=e.name,Object.setPrototypeOf(a,i.prototype),a}return l(e,t),e}(Error);!function(t){t.debug="debug",t.release="release"}(L||(L={}));var W=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){var n,o;this.listeners[t]=null!==(n=this.listeners[t])&&void 0!==n?n:new Set,null===(o=this.listeners[t])||void 0===o||o.add(e)},t.prototype.off=function(t,e){var n;null===(n=this.listeners[t])||void 0===n||n.delete(e)},t.prototype.forwardEvent=function(t,e){this.on(e,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];t.emit.apply(t,v([e],n,!1))}))},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var o=this.listeners[t];(null==o?void 0:o.size)&&o.forEach((function(t){Promise.resolve().then((function(){t.apply(void 0,e)}))}))},t.prototype.detachAllListeners=function(){this.listeners={}},t}(),x=function(){function t(){this.removeListenerCallbacks=[]}return t.prototype.add=function(t,e,n,o){t.addEventListener(e,n,o);var r=function(){t.removeEventListener(e,n,o)};return this.removeListenerCallbacks.push(r),r},t.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(t){return t()}))},t}(),S={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1},T=function(t){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(t)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},D=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,F=function(t){if(void 0===t&&(t=window.navigator.userAgent),t.includes("Chrome/")||t.includes("Chromium/")||t.includes("Opera/")||t.includes("Firefox/"))return null;var e=t.match(D);if(!e)return null;var n=e[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(e[4])||0,minor:parseInt(e[5])||0,patch:parseInt(e[6])||0}}};function A(t,e){var n;function o(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){t.apply(void 0,o)}),e)}return o.cancel=function(){n&&clearTimeout(n)},o}function k(t){var e,n,o,r,i,a=null!==(n=null===(e=t.touches)||void 0===e?void 0:e[0])&&void 0!==n?n:null===(o=t.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(r=null==a?void 0:a.clientX)&&void 0!==r?r:t.clientX,y:null!==(i=null==a?void 0:a.clientY)&&void 0!==i?i:t.clientY}}function B(t,e,n){return Math.max(e,Math.min(n,t))}function G(){return F()&&!S.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function Z(t){for(var e=t.size(),n=[],o=0;o<e;++o){var r=t.get(o);if(null==r)throw Error("Error converting embind vector to array");n.push(r)}return n}function U(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function z(t){var e=t;return Object.keys(e).forEach((function(t){void 0===e[t]&&delete e[t]})),e}function O(t){return U()?{onTouchEnd:t}:{onClick:t}}var _=function(t){function e(e){var n=t.call(this)||this;return n.listenersCollector=new x,n.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},n.handleGestureStart=function(t){t.preventDefault(),n.state.lastGestureScale=t.scale},n.handleGestureChange=function(t){t.preventDefault();var e=t.scale/n.state.lastGestureScale;n.state.lastGestureScale=t.scale;var o=n.getCorrectPointerPosition(t);n.emitZoomEvent(e,o)},n.handleGestureEnd=function(t){t.preventDefault()},n.handleTouchStart=function(t){t.preventDefault(),n.handleTouchPinchToZoomStart(t),n.emit("pointerdown",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleMouseDown=function(t){t.ctrlKey||(t.preventDefault(),n.emit("pointerdown",{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0}))},n.handleTouchMove=function(t){n.handleTouchPinchToZoomChange(t),n.emit("pointermove",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleMouseMove=function(t){n.updateMousePosition(t)},n.handleGlobalTouchMove=function(t){n.emit("globalpointermove",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleGlobalMouseMove=function(t){n.updateGlobalMousePosition(t)},n.handleTouchPinchToZoomStart=function(t){var e;!t.touches||(null===(e=t.touches)||void 0===e?void 0:e.length)<2||(n.state.pinchToZoomLastDistance=n.calculateDistanceBetweenTouches(t.touches[0],t.touches[1]))},n.handleTouchPinchToZoomChange=function(t){var e;if(t.touches&&!((null===(e=t.touches)||void 0===e?void 0:e.length)<2)){var o=n.calculateDistanceBetweenTouches(t.touches[0],t.touches[1]),r=n.getCorrectPointerPosition(t),i=1+.004*(o-n.state.pinchToZoomLastDistance);n.state.pinchToZoomLastDistance=o,n.emitZoomEvent(i,r)}},n.handleTouchEnd=function(t){var e=n.getCorrectPointerPosition(t);n.emit("pointerup",{position:e,type:"touch",button:0,touchesCount:t.touches.length})},n.handleMouseUp=function(t){n.emit("pointerup",{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},n.handleMouseWheel=function(t){t.preventDefault();var e=t.ctrlKey&&!n.state.isCtrlPressed,o=t.metaKey||e||n.state.isCtrlPressed;if(n.updateMousePosition(t),n.updateGlobalMousePosition(t),o){var r=e?-1:1,i=n.getCorrectPointerPosition(t),a=1+.005*t.deltaY*r;n.emitZoomEvent(a,i)}else n.emit("wheel",{x:-t.deltaX,y:-t.deltaY},{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},n.target=e,n.targetBounds=e.getBoundingClientRect(),n.addListeners(),n}return l(e,t),e.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},e.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},e.prototype.addKeyboardEventListeners=function(){var t=this;this.listenersCollector.add(document,"keydown",(function(e){"Control"===e.key&&(t.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(e){"Control"===e.key&&(t.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(e){e.ctrlKey&&(t.state.isCtrlPressed=!1)}))},e.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)},e.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)},e.prototype.addSafariGesturesEventListeners=function(){U()||(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}))},e.prototype.clampPointerToTargetBounds=function(t){return{x:B(t.x-this.targetBounds.x,0,this.target.clientWidth),y:B(t.y-this.targetBounds.y,0,this.target.clientHeight)}},e.prototype.getCorrectPointerPosition=function(t){var e,n={x:0,y:0};if((null===(e=t.touches)||void 0===e?void 0:e.length)>1){var o=t,r=o.touches[0],i=o.touches[1];n={x:(r.clientX+i.clientX)/2,y:(r.clientY+i.clientY)/2}}else n=k(t);return this.clampPointerToTargetBounds(n)},e.prototype.updateMousePosition=function(t){this.emit("pointermove",{type:"mouse",position:this.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},e.prototype.updateGlobalMousePosition=function(t){this.emit("globalpointermove",{type:"mouse",position:this.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},e.prototype.calculateDistanceBetweenTouches=function(t,e){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)},e.prototype.emitZoomEvent=function(t,e){this.emit("pinchToZoom",t,e)},e.prototype.dispose=function(){this.listenersCollector.dispose()},e}(W),N=function(t){function e(e){var n=t.call(this)||this;return n.listenersCollector=new x,n.handleKeyUp=function(t){n.emit("keyUp",t.code)},n.target=e,n.addListeners(),n}return l(e,t),e.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},e.prototype.dispose=function(){this.listenersCollector.dispose()},e}(W),j=function(){function t(t){this.label=t,this.startTime=performance.now(),this.startTimestamp=Date.now()}return t.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},t.prototype.printMeasurement=function(){var t=this.measure().duration;if(t<1e3){var e=t.toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(e," ms")}var n=(t/1e3).toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(n," s")},t}();function K(t){setTimeout((function(){t()}),0)}var Y=function(t){function e(e){var n=t.call(this)||this;return n.listenersCollector=new x,n.size={width:0,height:0},n.pixelRatio=1,n.handleCanvasResizeObserver=function(t){n.resizeCanvas(t[0].contentRect)},n.resizeCanvas=function(t){var e=t.width,o=t.height;window.requestAnimationFrame((function(){n.setSize(e,o),n.emit("resize",e,o,n.getDevicePixelRatio())}))},n.getCanvasCenterPoint=function(){var t=n.getBoundingClientRect();return{x:t.width/2+t.x,y:t.height/2+t.y}},n.container=e.container,n.canvas=e.canvas,n.canvasResizeObserver=new ResizeObserver(n.handleCanvasResizeObserver),n.canvasResizeObserver.observe(n.container),n.listenersCollector.add(window,"orientationchange",n.handleDeviceOrientationChange),n.setSize(n.container.clientWidth,n.container.clientHeight),n}return l(e,t),e.prototype.setSize=function(t,e){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(t,"px"),this.canvas.style.height="".concat(e,"px"),this.size.width=t*this.pixelRatio,this.size.height=e*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},e.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},e.prototype.getDevicePixelRatio=function(){return B(window.devicePixelRatio,1,2)},e.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},e.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},e}(W),$=function(){function t(t){this.settings=t}return t.prototype.isReleaseMode=function(){return this.settings.mode===L.release},t.prototype.init=function(){return h(this,void 0,void 0,(function(){var t,e,n,o,r,i=this;return p(this,(function(a){switch(a.label){case 0:return[4,this.importModule()];case 1:t=a.sent(),e=t.default,a.label=2;case 2:return a.trys.push([2,4,,5]),n=this,[4,e({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:G(),bridge:this.settings.jsBridge,locateFile:function(t){return i.settings.locateFile.replace("{file}",t)}})];case 3:return n.instance=a.sent(),[3,5];case 4:throw o=a.sent(),new I("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerType.Unset,mouse:this.instance.PRUserPointerType.Mouse,touch:this.instance.PRUserPointerType.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorType.Auto.value]="auto",r[this.instance.PRCursorType.Default.value]="default",r[this.instance.PRCursorType.Pointer.value]="pointer",r[this.instance.PRCursorType.Grab.value]="grab",r[this.instance.PRCursorType.Grabbing.value]="grabbing",r),[2]}}))}))},t.prototype.makeWebGLContext=function(t,e){void 0===e&&(e={});var n=d({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},e),o=this.instance.GL.createContext(t,n);if(!o)throw new I("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");return o},t.prototype.destroyWebGLContext=function(t){var e,n=null===(e=this.instance)||void 0===e?void 0:e.GL.getContext(t);if(n){var o=n.GLctx.getExtension("WEBGL_lose_context");if(o)return o.loseContext(),!0}},t.prototype.importModule=function(){return this.isReleaseMode()?import("./module-release-0b378fd1.js"):import("./module-debug-7ee9ba03.js")},t.prototype.mapToCSSCursor=function(t){return this.prCursorTypeToCSSCursorMap[t.value]},t.prototype.mapToPRPointerType=function(t){var e;return null!==(e=this.pointerTypeToWASMMap[t])&&void 0!==e?e:this.instance.PRUserPointerType.Unset},t.prototype.mapPointerInfo=function(t){return d(d({},t),{type:this.mapToPRPointerType(t.type)})},t}(),H=function(t){function e(e){var n=t.call(this)||this;return n.status={type:"INIT"},n.handleCanvasResize=function(t,e,o){var r;null===(r=n.pageCanvasWasm)||void 0===r||r.resize(t,e,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(t,e){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(t,e.x,e.y)},n.handleWheelEvent=function(t,e){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(t.x,t.y,n.wasmModule.mapPointerInfo(e))},n.handlePointerDownEvent=function(t){var e;null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(t))},n.handlePointerMoveEvent=function(t){var e;null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(t))},n.handleGlobalPointerMoveEvent=function(t){var e;null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(t))},n.handlePointerUpEvent=function(t){var e;null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(t))},n.settings=d(d({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1,panBoundariesPadding:0},z(e)),{featureFlags:d(d({},S),e.featureFlags)}),n.gestureManager=new _(n.settings.container),n.canvasManager=new Y({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new $({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.settings.manualInitialization||n.init(),n}return l(e,t),e.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)},e.prototype.collectAndEmitDeviceInfo=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return[4,R()];case 1:return t=e.sent(),this.deviceInfo=d(d({},t),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},e.prototype.init=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:this.traceFirstPaint=new j("FirstPaint"),this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),e.label=1;case 1:return e.trys.push([1,6,,7]),[4,this.initWasmModule()];case 2:return e.sent(),[4,this.initCanvasRendererWasm()];case 3:return e.sent(),[4,this.setFile(this.settings.filePath)];case 4:return e.sent(),[4,this.preloadImages()];case 5:return e.sent(),[3,7];case 6:return t=e.sent(),[2,this.fail(t instanceof I?t:new I("ERROR","Unexpected exception initializing the web renderer",t))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},e.prototype.setInitialCameraState=function(){var t,e,n,o=void 0!==this.settings.initialZoom,r=void 0!==this.settings.initialPan;o||r?(o&&this.setZoom(this.settings.initialZoom||1),r&&this.setPan((null===(t=this.settings.initialPan)||void 0===t?void 0:t.x)||0,(null===(e=this.settings.initialPan)||void 0===e?void 0:e.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport)):this.zoomToFit()},e.prototype.preloadImages=function(){var t=this;return new Promise((function(e){var n;null===(n=t.pageCanvasWasm)||void 0===n||n.preloadImages((function(){e()}))}))},e.prototype.startRendering=function(){var t;this.traceInitialRender=new j("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(t=this.pageCanvasWasm)||void 0===t||t.startRenderLoop()},e.prototype.createJSBridge=function(){var t=this;return{logDebug:function(e){t.logDebug("[C++] ".concat(e))},logWarning:function(e){t.logWarning("[C++] ".concat(e))},logError:function(e){t.logError("[C++] ".concat(e))},emitMetric:function(e,n,o,r){t.emit("metric",{id:e,start:n,end:o,duration:r})},resolveImageUrl:function(e){return t.settings.imagesURLFormat?t.settings.imagesURLFormat.replace(":imageId",e):t.settings.imagesURLMap&&t.settings.imagesURLMap[e]?t.settings.imagesURLMap[e]:(t.logWarning("Not able to resolve the url for the image with UUID: ".concat(e)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){t.emit("allImagesReady")},onCameraMoveStart:function(){t.emit("cameraMoveStart")},onCameraMoveEnd:function(){t.emit("cameraMoveEnd")},onCameraZoomStart:function(){t.emit("cameraZoomStart")},onCameraZoomEnd:function(){t.emit("cameraZoomEnd")},onCameraZoomChange:function(e){t.emit("cameraZoomChange",e)},onCameraPanChange:function(){var e=t.getPan();t.emit("cameraPanChange",(null==e?void 0:e.x)||0,(null==e?void 0:e.y)||0)},onCursorChange:function(e){var n=t.wasmModule.mapToCSSCursor(e);t.emit("cursorChange",n)},onPlayStateChange:function(){}}},e.prototype.downloadImages=function(){var t=this;return new Promise((function(e){var n,o=new j("ImagesDownload");null===(n=t.pageCanvasWasm)||void 0===n||n.downloadImages((function(){t.logDebug(o.printMeasurement()),t.emit("metric",o.measure()),t.logDebug("Images downloaded"),e()}))}))},e.prototype.initWasmModule=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return t=new j("WasmModuleDownload"),[4,this.wasmModule.init()];case 1:return e.sent(),this.logDebug(t.printMeasurement()),this.emit("metric",t.measure()),[2]}}))}))},e.prototype.initCanvasRendererWasm=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){try{t=G(),this.logDebug("Using WebGL ".concat(t)),this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:t}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.pageCanvasWasm=new this.wasmModule.instance.CanvasRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(t){throw new I("WASM_ERROR","An error occurred while trying to create the wasm object.",t)}return this.userEventsCollectorWasm=this.pageCanvasWasm.getUserEventsCollector(),this.pageCanvasWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.pageCanvasWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.pageCanvasWasm.setPanBoundariesPadding(this.settings.panBoundariesPadding),[2]}))}))},e.prototype.setIsCameraLocked=function(t){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.setIsCameraLocked(t)},e.prototype.setBackgroundColor=function(t){var e;t.r===this.settings.backgroundColor.r&&t.g===this.settings.backgroundColor.g&&t.b===this.settings.backgroundColor.b&&t.a===this.settings.backgroundColor.a||(null===(e=this.pageCanvasWasm)||void 0===e||e.setBackgroundColor(t.r,t.g,t.b,t.a),this.settings.backgroundColor=t)},e.prototype.generateDocumentPNG=function(){var t;return h(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this.downloadImages()];case 1:return e.sent(),[2,(null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.generateDocumentPNG())||new Uint8Array(0)]}}))}))},e.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),this.logDebug(this.traceFirstPaint.printMeasurement()),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}),this.downloadImages())},e.prototype.looseWebGLContext=function(){this.wasmModule.destroyWebGLContext(this.webglCtxHandle)||this.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},e.prototype.zoomToFit=function(){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.scaleDocumentToFit()},e.prototype.setFile=function(t){return h(this,void 0,void 0,(function(){var e=this;return p(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=e.pageCanvasWasm)||void 0===r||r.setFile(t,(function(t,o,r){e.setStatus({type:"FILE_READY"});var i="".concat(t,"-v").concat("5.1.0");e.emit("fileReady",e.getDocument(),i,o,r),n()}),(function(){return o(new I("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},e.prototype.fail=function(t){this.setStatus({type:"FAILURE",code:t.code,message:"".concat(t.toString()).concat(t.cause?"\nWrapped Error: ".concat(t.cause.toString()):"")}),this.logError(t),t.cause&&this.logError(t.cause)},e.prototype.setStatus=function(t){"FAILURE"!==this.status.type&&(this.logDebug("Status transition ".concat(this.status.type," => ").concat(t.type,"}")),this.status=t,this.emit("status",t))},e.prototype.getDocument=function(){if(!this.pageCanvasWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var t=this.pageCanvasWasm.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:d(d({},t),{artboards:Z(t.artboards)})}}return this.cachedDocumentInfo.document},e.prototype.getArtboardAtPosition=function(t,e){if(this.pageCanvasWasm){var n=this.getDocument();if(n){for(var o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(t-o.x)/r,a=(e-o.y)/r,s=0,u=n.artboards;s<u.length;s++){var c=u[s],l=c.bounds.x+c.bounds.width,d=c.bounds.y+c.bounds.height;if(i>=c.bounds.x&&a>=c.bounds.y&&i<=l&&a<=d)return c.objectId}return null}}},e.prototype.getPanAtPosition=function(t,e){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),r=t/o,i=e/o;return{x:n.x-r,y:n.y-i}},e.prototype.getStatus=function(){return this.status},e.prototype.setZoom=function(t,e){var n,o=null!=e?e:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(t,o.x,o.y)},e.prototype.getPan=function(){var t,e,n=this.getDocument().bounds,o=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getPan(),r=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom();return o&&r?{x:o.x/r+n.x,y:o.y/r+n.y}:{x:0,y:0}},e.prototype.getZoom=function(){var t;return(null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom())||0},e.prototype.setPan=function(t,e,n){var o;void 0===n&&(n=!1);var r=t,i=e,a=this.getDocument().bounds,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);r+=this.canvasManager.size.width/u,i+=this.canvasManager.size.height/u}var c=(r-a.x)*s,l=(i-a.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(c,l)},e.prototype.logDebug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,v(["log","debug"],t,!1))},e.prototype.logWarning=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,v(["log","warn"],t,!1))},e.prototype.logError=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,v(["log","error"],t,!1))},e.prototype.dispose=function(){var t,e;try{this.detachAllListeners(),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.pageCanvasWasm)||void 0===t||t.stopRenderLoop(),null===(e=this.pageCanvasWasm)||void 0===e||e.delete(),this.renderTarget.delete(),this.pageCanvasWasm=void 0}catch(t){this.fail(new I("ERROR","Unexpected exception while disposing the wasm object",t))}},e}(W),X=e(void 0),V=e(void 0),q=e(void 0),J=e(void 0),Q=e(void 0),tt=e(void 0),et=e("auto"),nt=e(void 0),ot=function(){var t=n(nt);if(void 0===t)throw Error("useInternalContext must be used within a provider");return t},rt=function(t,e){switch(e.type){case"on-status":return d(d({},t),{status:e.status});case"on-file-ready":return d(d({},t),{document:e.document});case"on-zoom":return d(d({},t),{zoom:e.zoom});case"on-pan":return d(d({},t),{pan:e.pan});case"dispose":return d(d({},t),{status:null,zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return d(d({},t),{isCameraZooming:!0});case"on-camera-zoom-end":return d(d({},t),{isCameraZooming:!1});case"on-camera-move-start":return d(d({},t),{isCameraMoving:!0});case"on-camera-move-end":return d(d({},t),{isCameraMoving:!1});case"on-cursor-change":return d(d({},t),{cursor:e.cursor});default:return t}},it=function(e){var n=o(null),s=o(null),u=r(rt,{pan:null,zoom:null,status:null,document:null,isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),c=u[0],l=c.status,h=c.document,p=c.zoom,v=c.pan,g=c.isCameraZooming,f=c.isCameraMoving,m=c.cursor,y=u[1],C=i((function(t){return y({type:"on-zoom",zoom:t})}),[]),w=i((function(t,e){return y({type:"on-pan",pan:{x:t,y:e}})}),[]),b=i((function(t){y({type:"on-status",status:t})}),[]),P=i((function(t){y({type:"on-file-ready",document:t})}),[]),E=i((function(){return y({type:"on-camera-zoom-start"})}),[]),M=i((function(){return y({type:"on-camera-zoom-end"})}),[]),R=i((function(){return y({type:"on-camera-move-start"})}),[]),L=i((function(){return y({type:"on-camera-move-end"})}),[]),I=i((function(t){return y({type:"on-cursor-change",cursor:t})}),[]),W=function(){for(var t,e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];null===(t=n.current)||void 0===t||t.logDebug.apply(t,e)},x=i((function(){var t=n.current;t&&(W("dispose"),t.off("status",b),t.off("fileReady",P),t.off("cameraZoomChange",C),t.off("cameraPanChange",w),t.off("cameraZoomStart",E),t.off("cameraZoomEnd",M),t.off("cameraMoveStart",R),t.off("cameraMoveEnd",L),t.off("cursorChange",I),t.dispose(),n.current=null,y({type:"dispose"}))}),[b,P,w,C,E,M,R,L,I]),S=i((function(t,e,o){if(""!==t&&e&&o&&s.current){W("init");var r=new H(d(d({},s.current),{filePath:t,container:o,canvas:e}));r.on("status",b),r.on("fileReady",P),r.on("cameraZoomChange",C),r.on("cameraPanChange",w),r.on("cameraZoomStart",E),r.on("cameraZoomEnd",M),r.on("cameraMoveStart",R),r.on("cameraMoveEnd",L),r.on("cursorChange",I),n.current=r}}),[b,P,C,w,E,M,R,L,I]),T=i((function(t){var e;W(T,t),t.backgroundColor&&(null===(e=n.current)||void 0===e||e.setBackgroundColor(t.backgroundColor)),s.current=t}),[]),D=i((function(){return n.current}),[]),F=a((function(){return{dispose:x,init:S,setSettings:T,getInstance:D,dispatch:y}}),[x,S,T,D]);return t.createElement(nt.Provider,{value:F},t.createElement(X.Provider,{value:l},t.createElement(V.Provider,{value:h},t.createElement(q.Provider,{value:p},t.createElement(tt.Provider,{value:v},t.createElement(J.Provider,{value:g},t.createElement(Q.Provider,{value:f},t.createElement(et.Provider,{value:m},e.children))))))))},at=function(){var t=n(X);if(void 0===t)throw Error("useStatus must be used within a provider");return t},st=function(){var t=n(V);if(void 0===t)throw Error("useDocument must be used within a provider");return t},ut=function(){var t=n(q);if(void 0===t)throw Error("useZoom must be used within a provider");return t},ct=function(){var t=n(tt);if(void 0===t)throw Error("usePan must be used within a provider");return t},lt=function(){var t=n(et);if(void 0===t)throw Error("useCursor must be used within a provider");return t},dt=function(){var t=n(J);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return t},ht=function(){var t=n(Q);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return t},pt=function(){var t=(0,ot().getInstance)();return i((function(e){null==t||t.setZoom(e)}),[t])},vt=function(){var t=pt(),e=ut();return i((function(){var n;"number"==typeof e&&(n=e>=1?Math.round(2*e):e>.5?1:2*e,t(n))}),[t,e])},gt=function(){var t=pt(),e=ut();return i((function(){"number"==typeof e&&t(e/2)}),[t,e])},ft=function(){var t=(0,ot().getInstance)();return i((function(e){var n=e.x,o=e.y,r=e.centerPointInViewport;null==t||t.setPan(n,o,r)}),[t])},mt=function(){var t=(0,ot().getInstance)();return i((function(){null==t||t.zoomToFit()}),[t])},yt=function(){var t=(0,ot().getInstance)();return i((function(){null==t||t.looseWebGLContext()}),[t])},Ct=function(){var t=(0,ot().getInstance)();return i((function(){return h(void 0,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,null==t?void 0:t.generateDocumentPNG()];case 1:return[2,e.sent()]}}))}))}),[t])},wt=function(){var t=(0,ot().getInstance)();return i((function(e,n){return h(void 0,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,null==t?void 0:t.getArtboardAtPosition(e,n)];case 1:return[2,o.sent()||null]}}))}))}),[t])},bt=function(){var t=(0,ot().getInstance)();return i((function(e,n){return h(void 0,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,null==t?void 0:t.getPanAtPosition(e,n)];case 1:return[2,o.sent()||null]}}))}))}),[t])},Pt=function(){var t=(0,ot().getInstance)();return i((function(e){null==t||t.setIsCameraLocked(e)}),[t])},Et=function(t,e){var n=(0,ot().getInstance)();s((function(){return null==n||n.on(t,e),function(){null==n||n.off(t,e)}}),[t,n,e])},Mt={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Rt={position:"absolute",top:0,left:0},Lt=function(e){var n=e.filePath,r=e.locateFile,c=e.imagesURLFormat,l=e.imagesURLMap,h=e.backgroundColor,p=e.mode,v=e.showTilesBorders,g=e.minimumZoomLevel,f=e.maximumZoomLevel,m=e.preserveDrawingBuffer,y=e.panBoundariesPadding,C=e.initialPan,w=e.initialZoom,b=e.children,P=e.containerProps,E=void 0===P?{}:P,M=e.canvasProps,R=void 0===M?{}:M,L=e.featureFlags,I=void 0===L?{}:L,W=o(null),x=o(null),S=u(!1),T=S[0],D=S[1],F=i((function(){return D(!0)}),[]),A=ot(),k=A.dispose,B=A.init,G=A.setSettings,Z=lt(),U=at();Et("allImagesReady",F),s((function(){G({locateFile:r,imagesURLFormat:c,imagesURLMap:l,backgroundColor:h,mode:p,showTilesBorders:v,minimumZoomLevel:g,maximumZoomLevel:f,preserveDrawingBuffer:m,panBoundariesPadding:y,initialPan:C,initialZoom:w,featureFlags:I})}),[G,r,c,l,h,p,v,g,f,m,y,C,w,I]),s((function(){if(n)return B(n,W.current,x.current),function(){k()}}),[k,B,n]);var z=a((function(){var t;return null!==(t=e.cursor)&&void 0!==t?t:Z}),[e.cursor,Z]),O=a((function(){return d(d({},Mt),{cursor:z})}),[z]);return t.createElement("div",d({},E,{ref:x,style:O}),n&&t.createElement("canvas",d({},R,{key:n,ref:W,"data-sketchweb-all-images-ready":T,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==U?void 0:U.type.toLowerCase())||"null"),style:Rt})),"READY"===(null==U?void 0:U.type)&&b)},It=function(t){function e(e){var n=t.call(this)||this;return n.status={type:"INIT"},n.handleCanvasResize=function(t,e,o){var r;null===(r=n.playerWasm)||void 0===r||r.resize(t,e,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(t,e){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(t,e.x,e.y)},n.handleWheelEvent=function(t,e){n.userEventsCollectorWasm.dispatchWheelEvent(t.x,t.y,n.wasmModule.mapPointerInfo(e))},n.handlePointerDownEvent=function(t){n.userEventsCollectorWasm.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(t))},n.handlePointerMoveEvent=function(t){n.userEventsCollectorWasm.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(t))},n.handleGlobalPointerMoveEvent=function(t){n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(t))},n.handlePointerUpEvent=function(t){n.userEventsCollectorWasm.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(t))},n.restartPrototype=function(t){var e;null===(e=n.playerWasm)||void 0===e||e.restartPrototype(t)},n.goBack=function(){var t;null===(t=n.playerWasm)||void 0===t||t.goBack()},n.goForwards=function(){var t;null===(t=n.playerWasm)||void 0===t||t.goForwards()},n.settings=d(d({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1},z(e)),{featureFlags:d(d({},S),e.featureFlags)}),n.gestureManager=new _(n.settings.container),n.canvasManager=new Y({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new $({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.settings.manualInitialization||n.init(),n}return l(e,t),e.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)},e.prototype.collectAndEmitDeviceInfo=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return[4,R()];case 1:return t=e.sent(),this.deviceInfo=d(d({},t),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},e.prototype.init=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:this.traceFirstPaint=new j("FirstPaint"),this.setStatus({type:"INIT"}),this.collectAndEmitDeviceInfo(),e.label=1;case 1:return e.trys.push([1,6,,7]),[4,this.initWasmModule()];case 2:return e.sent(),[4,this.initPlayerWasm()];case 3:return e.sent(),[4,this.setFile(this.settings.filePath)];case 4:return e.sent(),[4,this.preloadImages()];case 5:return e.sent(),[3,7];case 6:return t=e.sent(),[2,this.fail(t instanceof I?t:new I("ERROR","Unexpected exception initializing the web renderer",t))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},e.prototype.initWasmModule=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return t=new j("WasmModuleDownload"),[4,this.wasmModule.init()];case 1:return e.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},e.prototype.setInitialCameraState=function(){this.zoomToFit()},e.prototype.preloadImages=function(){var t=this;return new Promise((function(e){var n;null===(n=t.playerWasm)||void 0===n||n.preloadImages((function(){e()}))}))},e.prototype.startRendering=function(){var t;this.traceInitialRender=new j("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(t=this.playerWasm)||void 0===t||t.startRenderLoop()},e.prototype.createJSBridge=function(){var t=this;return{logDebug:function(e){t.logDebug("[C++] ".concat(e))},logWarning:function(e){t.logWarning("[C++] ".concat(e))},logError:function(e){t.logError("[C++] ".concat(e))},emitMetric:function(e,n,o,r){t.emit("metric",{id:e,start:n,end:o,duration:r})},resolveImageUrl:function(e){return t.settings.imagesURLFormat?t.settings.imagesURLFormat.replace(":imageId",e):t.settings.imagesURLMap&&t.settings.imagesURLMap[e]?t.settings.imagesURLMap[e]:(t.logWarning("Not able to resolve the url for the image with UUID: ".concat(e)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){t.emit("allImagesReady")},onCameraMoveStart:function(){t.emit("cameraMoveStart")},onCameraMoveEnd:function(){t.emit("cameraMoveEnd")},onCameraZoomStart:function(){t.emit("cameraZoomStart")},onCameraZoomEnd:function(){t.emit("cameraZoomEnd")},onCameraZoomChange:function(e){t.emit("cameraZoomChange",e)},onCameraPanChange:function(e,n){t.emit("cameraPanChange",e,n)},onCursorChange:function(e){var n=t.wasmModule.mapToCSSCursor(e);t.emit("cursorChange",n)},onPlayStateChange:function(e,n,o){t.emit("playStateChange",{screenArtboardId:e,canGoBack:n,canGoForwards:o})}}},e.prototype.downloadImages=function(){var t=this;return new Promise((function(e){var n,o=new j("ImagesDownload");null===(n=t.playerWasm)||void 0===n||n.downloadImages((function(){o.printMeasurement(),t.emit("metric",o.measure()),t.logDebug("Images downloaded"),e()}))}))},e.prototype.initPlayerWasm=function(){return h(this,void 0,void 0,(function(){return p(this,(function(t){try{this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:G()}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.playerWasm=new this.wasmModule.instance.PrototypeRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID)}catch(t){throw new I("WASM_ERROR","An error occurred while trying to create the WebRendererWasm object.",t)}return this.userEventsCollectorWasm=this.playerWasm.getUserEventsCollector(),this.playerWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.playerWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),[2]}))}))},e.prototype.setIsCameraLocked=function(t){var e;null===(e=this.playerWasm)||void 0===e||e.setIsCameraLocked(t)},e.prototype.setBackgroundColor=function(t){var e;t.r===this.settings.backgroundColor.r&&t.g===this.settings.backgroundColor.g&&t.b===this.settings.backgroundColor.b&&t.a===this.settings.backgroundColor.a||(null===(e=this.playerWasm)||void 0===e||e.setBackgroundColor(t.r,t.g,t.b,t.a),this.settings.backgroundColor=t)},e.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}),this.downloadImages())},e.prototype.looseWebGLContext=function(){this.wasmModule.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},e.prototype.zoomToFit=function(){var t;null===(t=this.playerWasm)||void 0===t||t.scaleDocumentToFit()},e.prototype.setFile=function(t){return h(this,void 0,void 0,(function(){var e=this;return p(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=e.playerWasm)||void 0===r||r.setFile(t,(function(t,o,r){e.setStatus({type:"FILE_READY"});var i="".concat(t,"-v").concat("5.1.0");e.emit("fileReady",e.getDocument(),i,o,r),n()}),(function(){return o(new I("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},e.prototype.fail=function(t){this.setStatus({type:"FAILURE",code:t.code,message:"".concat(t.toString()).concat(t.cause?"\nWrapped Error: ".concat(t.cause.toString()):"")}),this.logError(t),t.cause&&this.logError(t.cause)},e.prototype.setStatus=function(t){"FAILURE"!==this.status.type&&(this.logDebug("Status transition ".concat(this.status.type," => ").concat(t.type,"}")),this.status=t,this.emit("status",t))},e.prototype.getStatus=function(){return this.status},e.prototype.getDocument=function(){var t;if(!this.playerWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var e=null===(t=this.playerWasm)||void 0===t?void 0:t.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:d(d({},e),{artboards:Z(e.artboards)})}}return this.cachedDocumentInfo.document},e.prototype.logDebug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,v(["log","debug"],t,!1))},e.prototype.logWarning=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,v(["log","warn"],t,!1))},e.prototype.logError=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,v(["log","error"],t,!1))},e.prototype.dispose=function(){var t,e;try{this.detachAllListeners(),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.playerWasm)||void 0===t||t.stopRenderLoop(),null===(e=this.playerWasm)||void 0===e||e.delete(),this.renderTarget.delete(),this.playerWasm=void 0}catch(t){this.fail(new I("ERROR","Unexpected exception while disposing the WebRendererWasm object",t))}},e}(W),Wt=e(void 0),xt=e("auto"),St=e(void 0),Tt=e(void 0),Dt=function(){var t=n(Tt);if(void 0===t)throw Error("useInternalContext must be used within a provider");return t},Ft=function(t,e){switch(e.type){case"on-status":return d(d({},t),{status:e.status});case"dispose":return d(d({},t),{status:null,cursor:"auto"});case"on-cursor-change":return d(d({},t),{cursor:e.cursor});case"on-play-state-change":return d(d({},t),{playState:d(d({},t.playState),e.playState)});default:return t}},At=function(e){var n=o(null),s=o(null),u=r(Ft,{status:null,cursor:"auto",playState:{screenArtboardId:"",canGoBack:!0,canGoForwards:!0}}),c=u[0],l=c.status,h=c.cursor,p=c.playState,v=u[1],g=i((function(t){v({type:"on-status",status:t})}),[]),f=i((function(t){return v({type:"on-cursor-change",cursor:t})}),[]),m=i((function(t){return v({type:"on-play-state-change",playState:t})}),[]),y=function(){for(var t,e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];null===(t=n.current)||void 0===t||t.logDebug.apply(t,e)},C=i((function(){var t=n.current;t&&(y("dispose"),t.off("status",g),t.off("cursorChange",f),t.off("playStateChange",m),t.dispose(),n.current=null,v({type:"dispose"}))}),[g,f,m]),w=i((function(t,e,o){if(""!==t&&e&&o&&s.current){y("init");var r=new It(d(d({},s.current),{filePath:t,container:o,canvas:e}));r.on("status",g),r.on("cursorChange",f),r.on("playStateChange",m),n.current=r}}),[g,f,m]),b=i((function(t){var e;y("setSettings",t),t.backgroundColor&&(null===(e=n.current)||void 0===e||e.setBackgroundColor(t.backgroundColor)),s.current=t}),[]),P=i((function(){return n.current}),[]),E=a((function(){return{dispose:C,init:w,setSettings:b,getInstance:P,dispatch:v}}),[C,w,b,P]);return t.createElement(Tt.Provider,{value:E},t.createElement(Wt.Provider,{value:l},t.createElement(xt.Provider,{value:h},t.createElement(St.Provider,{value:p},e.children))))},kt=function(){var t=(0,Dt().getInstance)();return i((function(e){null==t||t.restartPrototype(e)}),[t])},Bt=function(){var t=(0,Dt().getInstance)();return i((function(){null==t||t.goBack()}),[t])},Gt=function(){var t=(0,Dt().getInstance)();return i((function(){null==t||t.goForwards()}),[t])},Zt=function(){var t=n(Wt);if(void 0===t)throw Error("usePrototypeStatus must be used within a provider");return t},Ut=function(){var t=n(xt);if(void 0===t)throw Error("usePrototypeCursor must be used within a provider");return t},zt=function(){var t=n(St);if(void 0===t)throw Error("usePrototypePlayState must be used within a provider");return t},Ot=function(t,e){var n=(0,Dt().getInstance)();s((function(){return null==n||n.on(t,e),function(){null==n||n.off(t,e)}}),[t,n,e])},_t={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Nt={position:"absolute",top:0,left:0},jt=function(e){var n=e.filePath,r=e.locateFile,i=e.imagesURLFormat,u=e.imagesURLMap,c=e.backgroundColor,l=e.mode,h=e.showTilesBorders,p=e.minimumZoomLevel,v=e.maximumZoomLevel,g=e.preserveDrawingBuffer,f=e.children,m=e.containerProps,y=void 0===m?{}:m,C=e.canvasProps,w=void 0===C?{}:C,b=e.featureFlags,P=void 0===b?{}:b,E=e.startArtboardUUID,M=o(null),R=o(null),L=Dt(),I=L.dispose,W=L.init,x=L.setSettings,S=Ut(),T=Zt();s((function(){x({locateFile:r,imagesURLFormat:i,imagesURLMap:u,backgroundColor:c,mode:l,showTilesBorders:h,minimumZoomLevel:p,maximumZoomLevel:v,preserveDrawingBuffer:g,featureFlags:P,startArtboardUUID:E})}),[x,r,i,u,c,l,h,p,v,g,P,E]),s((function(){if(n)return W(n,M.current,R.current),function(){I()}}),[I,W,n]);var D=a((function(){return d(d({},_t),{cursor:S})}),[S]);return t.createElement("div",d({},y,{ref:R,style:D}),n&&t.createElement("canvas",d({},w,{key:n,ref:M,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==T?void 0:T.type.toLowerCase())||"null"),style:Nt})),"READY"===(null==T?void 0:T.type)&&f)};export{Q as CameraMoveContext,J as CameraZoomingContext,H as CanvasRenderer,it as CanvasRendererProvider,Lt as CanvasRendererReact,et as CursorContext,S as DefaultFeatureFlags,V as DocumentContext,W as EventEmitter,_ as GestureManager,N as KeyboardManager,x as ListenersCollector,tt as PanContext,j as Performance,It as PrototypeRenderer,At as PrototypeRendererProvider,jt as PrototypeRendererReact,X as StatusContext,I as WebRendererError,L as WebRendererMode,q as ZoomContext,B as clamp,Z as convertEmbindVectorToArray,A as debounce,k as extractPointer,G as getSupportedWebGLVersion,T as getiOSVersion,U as isTouchDevice,K as nextTick,F as parseSafariUserAgent,rt as reducer,z as removeUndefinedKeys,O as touchableClick,lt as useCursor,gt as useDecrementZoom,st as useDocument,Et as useEvent,Ct as useGenerateDocumentPNG,wt as useGetArtboardAtPosititon,bt as useGetPanAtPosition,Bt as useGoBack,Gt as useGoForwards,vt as useIncrementZoom,ht as useIsCameraMoving,dt as useIsCameraZooming,Pt as useLockCamera,yt as useLooseWebGLContext,ct as usePan,Ut as usePrototypeCursor,Ot as usePrototypeEvent,zt as usePrototypePlayState,Zt as usePrototypeStatus,kt as useRestartPrototype,ft as useSetPan,pt as useSetZoom,at as useStatus,ut as useZoom,mt as useZoomToFit};