@spiffcommerce/core 12.11.4 → 12.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/jsx-runtime"),i=require("react"),n=require("opentype.js"),a=require("buffer"),r=require("axios"),s=require("https"),o=require("file-type"),c=require("util"),l=require("css"),g=require("canvas"),h=require("exif"),d=require("process"),u=require("raf"),w=require("rgbcolor"),B=require("svg-pathdata"),p=require("stackblur-canvas"),E=require("@apollo/client/link/context"),m=require("@apollo/client/link/error"),C=require("cross-fetch"),f=require("lodash.isequal"),Q=require("react-dom/server"),y=require("qrcode"),D=require("svg-path-bbox"),I=require("lodash.debounce"),x=require("unicode-default-word-boundary"),M=require("@apollo/client/core");function v(t,e,A,i){Object.defineProperty(t,e,{get:A,set:i,enumerable:!0,configurable:!0})}var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function F(t){return t&&t.__esModule?t.default:t}v(module.exports,"SpiffCommerceClient",(()=>bc)),v(module.exports,"CommandContext",(()=>Ti)),v(module.exports,"spiffCoreConfiguration",(()=>da)),v(module.exports,"PromiseQueue",(()=>Or)),v(module.exports,"QueueablePromise",(()=>Tr)),v(module.exports,"MockWorkflowManager",(()=>Pc)),v(module.exports,"InformationMessageType",(()=>Bo)),v(module.exports,"StepHandle",(()=>yo)),v(module.exports,"TextStepHandle",(()=>No)),v(module.exports,"FrameStepHandle",(()=>Hc)),v(module.exports,"BulkStepHandle",(()=>Mo)),v(module.exports,"ShapeStepHandle",(()=>Po)),v(module.exports,"IllustrationStepHandle",(()=>vo)),v(module.exports,"MaterialStepHandle",(()=>So)),v(module.exports,"ModelStepHandle",(()=>Fo)),v(module.exports,"PictureStepHandle",(()=>bo)),v(module.exports,"QuestionStepHandle",(()=>Yo)),v(module.exports,"BulkPriceCalculationStrategy",(()=>Za)),v(module.exports,"Variant",(()=>fo)),v(module.exports,"OptionNotFoundError",(()=>$n)),v(module.exports,"LayoutNotFoundError",(()=>_n)),v(module.exports,"AssetNotFoundError",(()=>ta)),v(module.exports,"ResourceNotFoundError",(()=>ea)),v(module.exports,"MisconfigurationError",(()=>Aa)),v(module.exports,"ParseError",(()=>aa)),v(module.exports,"UnhandledBehaviorError",(()=>na)),v(module.exports,"assetService",(()=>Ya)),v(module.exports,"designService",(()=>zo)),v(module.exports,"createDesign",(()=>Oo)),v(module.exports,"optionService",(()=>ka)),v(module.exports,"persistenceService",(()=>ga)),v(module.exports,"graphQlManager",(()=>Qa)),v(module.exports,"toast",(()=>sr)),v(module.exports,"FrameService",(()=>Ks)),v(module.exports,"getBoundedOffsets",(()=>js)),v(module.exports,"frameStepService",(()=>eo)),v(module.exports,"modelStepService",(()=>no)),v(module.exports,"materialStepService",(()=>io)),v(module.exports,"shapeStepService",(()=>oo)),v(module.exports,"questionStepService",(()=>so)),v(module.exports,"digitalContentStepService",(()=>_s)),v(module.exports,"moduleStepService",(()=>ao)),v(module.exports,"pictureStepService",(()=>ro)),v(module.exports,"textStepService",(()=>uo)),v(module.exports,"illustrationStepService",(()=>Ao)),v(module.exports,"ProductCameraRig",(()=>Xa)),v(module.exports,"FrameStep",(()=>Rc)),v(module.exports,"ConversionLocation",(()=>_a)),v(module.exports,"ConversionDataType",(()=>er)),v(module.exports,"getWorkflow",(()=>Sc)),v(module.exports,"shortenUrl",(()=>qs)),v(module.exports,"AssetType",(()=>nA)),v(module.exports,"BringForwardCommand",(()=>mn)),v(module.exports,"BringToFrontCommand",(()=>pn)),v(module.exports,"BringToBackCommand",(()=>En)),v(module.exports,"CanvasCommand",(()=>Xi)),v(module.exports,"CreateElementCommand",(()=>nn)),v(module.exports,"CreateLayoutCommand",(()=>en)),v(module.exports,"DeleteElementCommand",(()=>an)),v(module.exports,"FontAlignmentCommand",(()=>hn)),v(module.exports,"FontColorCommand",(()=>sn)),v(module.exports,"FontSizeCommand",(()=>cn)),v(module.exports,"FontSourceCommand",(()=>gn)),v(module.exports,"GroupCommand",(()=>tn)),v(module.exports,"LayoutElementFactory",(()=>Wn)),v(module.exports,"LayoutElementType",(()=>ze)),v(module.exports,"MoveCommand",(()=>Zi)),v(module.exports,"ResizeCommand",(()=>_i)),v(module.exports,"RotateCommand",(()=>$i)),v(module.exports,"SendBackwardsCommand",(()=>Cn)),v(module.exports,"StakeholderType",(()=>ir)),v(module.exports,"StepAspectType",(()=>oA)),v(module.exports,"StepType",(()=>rA)),v(module.exports,"TextChangeCommand",(()=>un)),v(module.exports,"UnitOfMeasurement",(()=>qe)),v(module.exports,"dataUrlFromExternalUrl",(()=>qA)),v(module.exports,"findElement",(()=>ji)),v(module.exports,"frameDataCache",(()=>Fn)),v(module.exports,"generate",(()=>Te)),v(module.exports,"getAxisAlignedBoundingBox",(()=>hA)),v(module.exports,"generateSVGWithUnknownColors",(()=>Ui)),v(module.exports,"getAttributesFromArrayBuffer",(()=>Mn)),v(module.exports,"rehydrateSerializedLayout",(()=>Wi)),v(module.exports,"getFrameData",(()=>Nn)),v(module.exports,"getSvgElement",(()=>Ji)),v(module.exports,"loadFontFromDataUrl",(()=>ri)),v(module.exports,"loadFontFromExternalUrl",(()=>ai)),v(module.exports,"determineCorrectFontSizeAndLines",(()=>On)),v(module.exports,"patternImageDataCache",(()=>Sn)),v(module.exports,"generateCommands",(()=>Es)),v(module.exports,"registerJSDOM",(()=>UA)),v(module.exports,"minZoom",(()=>Nr)),v(module.exports,"AdvancedEditor",(()=>vs)),v(module.exports,"TransformWrapper",(()=>Uc)),v(module.exports,"EditorCore",(()=>Ms)),v(module.exports,"useLayouts",(()=>Ga)),v(module.exports,"useEditorState",(()=>Wa)),v(module.exports,"useEditorInteraction",(()=>kr)),v(module.exports,"useShortcutCombination",(()=>Hr)),v(module.exports,"commandReducer",(()=>za)),v(module.exports,"getDefaultState",(()=>La)),v(module.exports,"CommandContextContext",(()=>Ha)),v(module.exports,"AdvancedEditorStateProvider",(()=>Va)),v(module.exports,"AdvancedEditorContext",(()=>ja)),v(module.exports,"UICommand",(()=>Ka)),v(module.exports,"EditorSubMenu",(()=>Oa)),v(module.exports,"ElementEventType",(()=>or)),v(module.exports,"KeyEvent",(()=>lr)),v(module.exports,"gatherVaryingStepAspects",(()=>Hs));function b(t){return t.replace(/(?!\u3000)\s+/gm," ")}function Y(t){const e=t.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return e?e.map(parseFloat):[]}const P=/^[A-Z-]+$/;function N(t){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t);return e&&(e[2]||e[3]||e[4])||""}const R=/(\[[^\]]+\])/g,k=/(#[^\s+>~.[:]+)/g,H=/(\.[^\s+>~.[:]+)/g,U=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,G=/(:[\w-]+\([^)]*\))/gi,T=/(:[^\s+>~.[:]+)/g,O=/([^\s+>~.[:]+)/g;function J(t,e){const A=e.exec(t);return A?[t.replace(e," "),A.length]:[t,0]}const L=1e-8;function z(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function j(t,e){return(t[0]*e[0]+t[1]*e[1])/(z(t)*z(e))}function V(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(j(t,e))}function K(t){return t*t*t}function W(t){return 3*t*t*(1-t)}function X(t){return 3*t*(1-t)*(1-t)}function q(t){return(1-t)*(1-t)*(1-t)}function Z(t){return t*t}function $(t){return 2*t*(1-t)}function _(t){return(1-t)*(1-t)}function tt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class et{static empty(t){return new et(t,"EMPTY","")}split(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:" ";const{document:e,name:A}=this;return b(this.getString()).trim().split(t).map((t=>new et(e,A,t)))}hasValue(t){const e=this.value;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){const{value:e}=this,A="string"==typeof e;return A&&t?t.test(e):A}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;const t=this.getString();switch(!0){case t.endsWith("px"):case/^[0-9]+$/.test(t):return!0;default:return!1}}setValue(t){return this.value=t,this}getValue(t){return void 0===t||this.hasValue()?this.value:t}getNumber(t){if(!this.hasValue())return void 0===t?0:parseFloat(t);const{value:e}=this;let A=parseFloat(e);return this.isString(/%$/)&&(A/=100),A}getString(t){return void 0===t||this.hasValue()?void 0===this.value?"":String(this.value):String(t)}getColor(t){let e=this.getString(t);return this.isNormalizedColor||(this.isNormalizedColor=!0,e=function(t){if(!t.startsWith("rgb"))return t;let e=3;return t.replace(/\d+(\.\d+)?/g,((t,A)=>e--&&A?String(Math.round(parseFloat(t))):t))}(e),this.value=e),e}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasValue())return 0;const[A,i]="boolean"==typeof t?[void 0,t]:[t],{viewPort:n}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(n.computeSize("x"),n.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(n.computeSize("x"),n.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*n.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*n.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return 15*this.getNumber();case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case this.isString(/%$/)&&i:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*n.computeSize(A);default:{const t=this.getNumber();return e&&t<1?t*n.computeSize(A):t}}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():1e3*this.getNumber():0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){const t=this.getString(),e=/#([^)'"]+)/.exec(t),A=(null==e?void 0:e[1])||t;return this.document.definitions[A]}getFillStyleDefinition(t,e){let A=this.getDefinition();if(!A)return null;if("function"==typeof A.createGradient&&"getBoundingBox"in t)return A.createGradient(this.document.ctx,t,e);if("function"==typeof A.createPattern){if(A.getHrefAttribute().hasValue()){const t=A.getAttribute("patternTransform");A=A.getHrefAttribute().getDefinition(),A&&t.hasValue()&&A.getAttribute("patternTransform",!0).setValue(t.value)}if(A)return A.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){if(!this.hasValue())return null;const t=this.getString();return et.textBaselineMapping[t]||null}addOpacity(t){let e=this.getColor();const A=e.length;let i=0;for(let t=0;t<A&&(","===e[t]&&i++,3!==i);t++);if(t.hasValue()&&this.isString()&&3!==i){const A=new(F(w))(e);A.ok&&(A.alpha=t.getNumber(),e=A.toRGBA())}return new et(this.document,this.name,e)}constructor(t,e,A){tt(this,"document",void 0),tt(this,"name",void 0),tt(this,"value",void 0),tt(this,"isNormalizedColor",void 0),this.document=t,this.name=e,this.value=A,this.isNormalizedColor=!1}}function At(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}tt(et,"textBaselineMapping",{baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"});class it{clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[t]=this.viewPorts;return t||nt()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||nt()}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(t){return"number"==typeof t?t:"x"===t?this.width:"y"===t?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}constructor(){At(this,"viewPorts",[])}}function nt(){return{width:it.DEFAULT_VIEWPORT_WIDTH,height:it.DEFAULT_VIEWPORT_HEIGHT}}function at(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}At(it,"DEFAULT_VIEWPORT_WIDTH",800),At(it,"DEFAULT_VIEWPORT_HEIGHT",600);class rt{static parse(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const[A=e,i=e]=Y(t);return new rt(A,i)}static parseScale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const[A=e,i=A]=Y(t);return new rt(A,i)}static parsePath(t){const e=Y(t),A=e.length,i=[];for(let t=0;t<A;t+=2)i.push(new rt(e[t],e[t+1]));return i}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:A}=this,i=e*t[0]+A*t[2]+t[4],n=e*t[1]+A*t[3]+t[5];this.x=i,this.y=n}constructor(t,e){at(this,"x",void 0),at(this,"y",void 0),this.x=t,this.y=e}}function st(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ot{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:A}=this,i=t.ctx.canvas;i.onclick=e,i.onmousemove=A,this.working=!0}stop(){if(!this.working)return;const t=this.screen.ctx.canvas;this.working=!1,t.onclick=null,t.onmousemove=null}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(!this.working)return;const{screen:t,events:e,eventElements:A}=this,{style:i}=t.ctx.canvas;let n;i&&(i.cursor=""),e.forEach(((t,e)=>{let{run:i}=t;for(n=A[e];n;)i(n),n=n.parent})),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:A,eventElements:i}=this;A.forEach(((A,n)=>{let{x:a,y:r}=A;!i[n]&&e.isPointInPath&&e.isPointInPath(a,r)&&(i[n]=t)}))}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:A,eventElements:i}=this;A.forEach(((A,n)=>{let{x:a,y:r}=A;!i[n]&&e.isPointInBox(a,r)&&(i[n]=t)}))}mapXY(t,e){const{window:A,ctx:i}=this.screen,n=new rt(t,e);let a=i.canvas;for(;a;)n.x-=a.offsetLeft,n.y-=a.offsetTop,a=a.offsetParent;return(null==A?void 0:A.scrollX)&&(n.x+=A.scrollX),(null==A?void 0:A.scrollY)&&(n.y+=A.scrollY),n}onClick(t){const{x:e,y:A}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:A,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){const{x:e,y:A}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:A,run(t){t.onMouseMove&&t.onMouseMove()}})}constructor(t){st(this,"screen",void 0),st(this,"working",void 0),st(this,"events",void 0),st(this,"eventElements",void 0),this.screen=t,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}}function ct(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const lt="undefined"!=typeof window?window:null,gt="undefined"!=typeof fetch?fetch.bind(void 0):void 0;class ht{wait(t){this.waits.push(t)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;const t=this.waits.every((t=>t()));return t&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=t,t}setDefaults(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4}setViewBox(t){let{document:e,ctx:A,aspectRatio:i,width:n,desiredWidth:a,height:r,desiredHeight:s,minX:o=0,minY:c=0,refX:l,refY:g,clip:h=!1,clipX:d=0,clipY:u=0}=t;const w=b(i).replace(/^defer\s/,""),[B,p]=w.split(" "),E=B||"xMidYMid",m=p||"meet",C=n/a,f=r/s,Q=Math.min(C,f),y=Math.max(C,f);let D=a,I=s;"meet"===m&&(D*=Q,I*=Q),"slice"===m&&(D*=y,I*=y);const x=new et(e,"refX",l),M=new et(e,"refY",g),v=x.hasValue()&&M.hasValue();if(v&&A.translate(-Q*x.getPixels("x"),-Q*M.getPixels("y")),h){const t=Q*d,e=Q*u;A.beginPath(),A.moveTo(t,e),A.lineTo(n,e),A.lineTo(n,r),A.lineTo(t,r),A.closePath(),A.clip()}if(!v){const t="meet"===m&&Q===f,e="slice"===m&&y===f,i="meet"===m&&Q===C,a="slice"===m&&y===C;E.startsWith("xMid")&&(t||e)&&A.translate(n/2-D/2,0),E.endsWith("YMid")&&(i||a)&&A.translate(0,r/2-I/2),E.startsWith("xMax")&&(t||e)&&A.translate(n-D,0),E.endsWith("YMax")&&(i||a)&&A.translate(0,r-I)}switch(!0){case"none"===E:A.scale(C,f);break;case"meet"===m:A.scale(Q,Q);break;case"slice"===m:A.scale(y,y)}A.translate(-o,-c)}start(t){let{enableRedraw:e=!1,ignoreMouse:A=!1,ignoreAnimation:i=!1,ignoreDimensions:n=!1,ignoreClear:a=!1,forceRedraw:r,scaleWidth:s,scaleHeight:o,offsetX:c,offsetY:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mouse:g}=this,h=1e3/ht.FRAMERATE;if(this.isReadyLock=!1,this.frameDuration=h,this.readyPromise=new Promise((t=>{this.resolveReady=t})),this.isReady()&&this.render(t,n,a,s,o,c,l),!e)return;let d=Date.now(),w=d,B=0;const p=()=>{d=Date.now(),B=d-w,B>=h&&(w=d-B%h,this.shouldUpdate(i,r)&&(this.render(t,n,a,s,o,c,l),g.runEvents())),this.intervalId=F(u)(p)};A||g.start(),this.intervalId=F(u)(p)}stop(){this.intervalId&&(F(u).cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){const{frameDuration:t}=this;if(this.animations.reduce(((e,A)=>A.update(t)||e),!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,A,i,n,a,r){const{viewPort:s,ctx:o,isFirstRender:c}=this,l=o.canvas;s.clear(),l.width&&l.height&&s.setCurrent(l.width,l.height);const g=t.getStyle("width"),h=t.getStyle("height");!e&&(c||"number"!=typeof i&&"number"!=typeof n)&&(g.hasValue()&&(l.width=g.getPixels("x"),l.style&&(l.style.width=`${l.width}px`)),h.hasValue()&&(l.height=h.getPixels("y"),l.style&&(l.style.height=`${l.height}px`)));let d=l.clientWidth||l.width,u=l.clientHeight||l.height;if(e&&g.hasValue()&&h.hasValue()&&(d=g.getPixels("x"),u=h.getPixels("y")),s.setCurrent(d,u),"number"==typeof a&&t.getAttribute("x",!0).setValue(a),"number"==typeof r&&t.getAttribute("y",!0).setValue(r),"number"==typeof i||"number"==typeof n){const e=Y(t.getAttribute("viewBox").getString());let A=0,a=0;if("number"==typeof i){const n=t.getStyle("width");n.hasValue()?A=n.getPixels("x")/i:e[2]&&!isNaN(e[2])&&(A=e[2]/i)}if("number"==typeof n){const A=t.getStyle("height");A.hasValue()?a=A.getPixels("y")/n:e[3]&&!isNaN(e[3])&&(a=e[3]/n)}A||(A=a),a||(a=A),t.getAttribute("width",!0).setValue(i),t.getAttribute("height",!0).setValue(n);const r=t.getStyle("transform",!0,!0);r.setValue(`${r.getString()} scale(${1/A}, ${1/a})`)}A||o.clearRect(0,0,d,u),t.render(o),c&&(this.isFirstRender=!1)}constructor(t,{fetch:e=gt,window:A=lt}={}){if(ct(this,"ctx",void 0),ct(this,"window",void 0),ct(this,"fetch",void 0),ct(this,"viewPort",void 0),ct(this,"mouse",void 0),ct(this,"animations",void 0),ct(this,"readyPromise",void 0),ct(this,"resolveReady",void 0),ct(this,"waits",void 0),ct(this,"frameDuration",void 0),ct(this,"isReadyLock",void 0),ct(this,"isFirstRender",void 0),ct(this,"intervalId",void 0),this.ctx=t,this.viewPort=new it,this.mouse=new ot(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=A,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}function dt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}ct(ht,"defaultWindow",lt),ct(ht,"defaultFetch",gt),ct(ht,"FRAMERATE",30),ct(ht,"MAX_VIRTUAL_PIXELS",3e4);const{defaultFetch:ut}=ht,wt="undefined"!=typeof DOMParser?DOMParser:void 0;class Bt{async parse(t){return t.startsWith("<")?this.parseFromString(t):this.load(t)}parseFromString(t){const e=new this.DOMParser;try{return this.checkDocument(e.parseFromString(t,"image/svg+xml"))}catch(A){return this.checkDocument(e.parseFromString(t,"text/xml"))}}checkDocument(t){const e=t.getElementsByTagName("parsererror")[0];if(e)throw new Error(e.textContent||"Unknown parse error");return t}async load(t){const e=await this.fetch(t),A=await e.text();return this.parseFromString(A)}constructor({fetch:t=ut,DOMParser:e=wt}={}){if(dt(this,"fetch",void 0),dt(this,"DOMParser",void 0),!t)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");if(!e)throw new Error("Can't find 'DOMParser' in 'globalThis', please provide it via options");this.fetch=t,this.DOMParser=e}}function pt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Et(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function mt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Ct(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ft{apply(t){const{originX:e,originY:A,matrix:i}=this,n=e.getPixels("x"),a=A.getPixels("y");t.translate(n,a),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),t.translate(-n,-a)}unapply(t){const{originX:e,originY:A,matrix:i}=this,n=i[0],a=i[2],r=i[4],s=i[1],o=i[3],c=i[5],l=1/(n*(1*o-0*c)-a*(1*s-0*c)+r*(0*s-0*o)),g=e.getPixels("x"),h=A.getPixels("y");t.translate(g,h),t.transform(l*(1*o-0*c),l*(0*c-1*s),l*(0*r-1*a),l*(1*n-0*r),l*(a*c-r*o),l*(r*s-n*c)),t.translate(-g,-h)}applyToPoint(t){t.applyTransform(this.matrix)}constructor(t,e,A){Ct(this,"type","matrix"),Ct(this,"matrix",void 0),Ct(this,"originX",void 0),Ct(this,"originY",void 0),this.matrix=function(t){const e=Y(t);return[e[0]||0,e[1]||0,e[2]||0,e[3]||0,e[4]||0,e[5]||0]}(e),this.originX=A[0],this.originY=A[1]}}function Qt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class yt extends ft{constructor(t,e,A){super(t,e,A),Qt(this,"type","skew"),Qt(this,"angle",void 0),this.angle=new et(t,"angle",e)}}function Dt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class It{static fromElement(t,e){const A=e.getStyle("transform",!1,!0);if(A.hasValue()){const[i,n=i]=e.getStyle("transform-origin",!1,!0).split();if(i&&n){const e=[i,n];return new It(t,A.getString(),e)}}return null}apply(t){this.transforms.forEach((e=>e.apply(t)))}unapply(t){this.transforms.forEach((e=>e.unapply(t)))}applyToPoint(t){this.transforms.forEach((e=>e.applyToPoint(t)))}constructor(t,e,A){Dt(this,"document",void 0),Dt(this,"transforms",void 0),this.document=t,this.transforms=[];const i=function(t){return b(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);i.forEach((t=>{if("none"===t)return;const[e,i]=function(t){const[e="",A=""]=t.split("(");return[e.trim(),A.trim().replace(")","")]}(t),n=It.transformTypes[e];n&&this.transforms.push(new n(this.document,i,A))}))}}function xt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}Dt(It,"transformTypes",{translate:class{apply(t){const{x:e,y:A}=this.point;t.translate(e||0,A||0)}unapply(t){const{x:e,y:A}=this.point;t.translate(-1*e||0,-1*A||0)}applyToPoint(t){const{x:e,y:A}=this.point;t.applyTransform([1,0,0,1,e||0,A||0])}constructor(t,e){pt(this,"type","translate"),pt(this,"point",void 0),this.point=rt.parse(e)}},rotate:class{apply(t){const{cx:e,cy:A,originX:i,originY:n,angle:a}=this,r=e+i.getPixels("x"),s=A+n.getPixels("y");t.translate(r,s),t.rotate(a.getRadians()),t.translate(-r,-s)}unapply(t){const{cx:e,cy:A,originX:i,originY:n,angle:a}=this,r=e+i.getPixels("x"),s=A+n.getPixels("y");t.translate(r,s),t.rotate(-1*a.getRadians()),t.translate(-r,-s)}applyToPoint(t){const{cx:e,cy:A,angle:i}=this,n=i.getRadians();t.applyTransform([1,0,0,1,e||0,A||0]),t.applyTransform([Math.cos(n),Math.sin(n),-Math.sin(n),Math.cos(n),0,0]),t.applyTransform([1,0,0,1,-e||0,-A||0])}constructor(t,e,A){Et(this,"type","rotate"),Et(this,"angle",void 0),Et(this,"originX",void 0),Et(this,"originY",void 0),Et(this,"cx",void 0),Et(this,"cy",void 0);const i=Y(e);this.angle=new et(t,"angle",i[0]),this.originX=A[0],this.originY=A[1],this.cx=i[1]||0,this.cy=i[2]||0}},scale:class{apply(t){const{scale:{x:e,y:A},originX:i,originY:n}=this,a=i.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(e,A||e),t.translate(-a,-r)}unapply(t){const{scale:{x:e,y:A},originX:i,originY:n}=this,a=i.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(1/e,1/A||e),t.translate(-a,-r)}applyToPoint(t){const{x:e,y:A}=this.scale;t.applyTransform([e||0,0,0,A||0,0,0])}constructor(t,e,A){mt(this,"type","scale"),mt(this,"scale",void 0),mt(this,"originX",void 0),mt(this,"originY",void 0);const i=rt.parseScale(e);0!==i.x&&0!==i.y||(i.x=L,i.y=L),this.scale=i,this.originX=A[0],this.originY=A[1]}},matrix:ft,skewX:class extends yt{constructor(t,e,A){var i,n,a;super(t,e,A),a="skewX",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}},skewY:class extends yt{constructor(t,e,A){var i,n,a;super(t,e,A),a="skewY",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}});class Mt{getAttribute(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const A=this.attributes[t];if(!A&&e){const e=new et(this.document,t,"");return this.attributes[t]=e,e}return A||et.empty(this.document)}getHrefAttribute(){let t;for(const e in this.attributes)if("href"===e||e.endsWith(":href")){t=this.attributes[e];break}return t||et.empty(this.document)}getStyle(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=this.styles[t];if(i)return i;const n=this.getAttribute(t);if(n.hasValue())return this.styles[t]=n,n;if(!A){const{parent:e}=this;if(e){const A=e.getStyle(t);if(A.hasValue())return A}}if(e){const e=new et(this.document,t,"");return this.styles[t]=e,e}return et.empty(this.document)}render(t){if("none"!==this.getStyle("display").getString()&&"hidden"!==this.getStyle("visibility").getString()){if(t.save(),this.getStyle("mask").hasValue()){const e=this.getStyle("mask").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else if("none"!==this.getStyle("filter").getValue("none")){const e=this.getStyle("filter").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}}setContext(t){}applyEffects(t){const e=It.fromElement(this.document,this);e&&e.apply(t);const A=this.getStyle("clip-path",!1,!0);if(A.hasValue()){const e=A.getDefinition();e&&e.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach((e=>{e.render(t)}))}addChild(t){const e=t instanceof Mt?t:this.document.createElement(t);e.parent=this,Mt.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:A}=this;if(!A)return!1;if("function"==typeof A.matches)return A.matches(t);const i=null===(e=A.getAttribute)||void 0===e?void 0:e.call(A,"class");return!(!i||""===i)&&i.split(" ").some((e=>`.${e}`===t))}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let A;for(const i in t)if(!i.startsWith("@")&&this.matchesSelector(i)){const n=t[i],a=e[i];if(n)for(const t in n){let e=this.stylesSpecificity[t];void 0===e&&(e="000"),a&&a>=e&&(A=n[t],A&&(this.styles[t]=A),this.stylesSpecificity[t]=a)}}}removeStyles(t,e){return e.reduce(((e,A)=>{const i=t.getStyle(A);if(!i.hasValue())return e;const n=i.getString();return i.setValue(""),[...e,[A,n]]}),[])}restoreStyles(t,e){e.forEach((e=>{let[A,i]=e;t.getStyle(A,!0).setValue(i)}))}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}constructor(t,e,A=!1){if(xt(this,"document",void 0),xt(this,"node",void 0),xt(this,"captureTextNodes",void 0),xt(this,"type",void 0),xt(this,"attributes",void 0),xt(this,"styles",void 0),xt(this,"stylesSpecificity",void 0),xt(this,"animationFrozen",void 0),xt(this,"animationFrozenValue",void 0),xt(this,"parent",void 0),xt(this,"children",void 0),this.document=t,this.node=e,this.captureTextNodes=A,this.type="",this.attributes={},this.styles={},this.stylesSpecificity={},this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],!e||1!==e.nodeType)return;if(Array.from(e.attributes).forEach((e=>{const A=(i=e.nodeName,P.test(i)?i.toLowerCase():i);var i;this.attributes[A]=new et(t,A,e.value)})),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()){this.getAttribute("style").getString().split(";").map((t=>t.trim())).forEach((e=>{if(!e)return;const[A,i]=e.split(":").map((t=>t.trim()));A&&(this.styles[A]=new et(t,A,i))}))}const{definitions:i}=t,n=this.getAttribute("id");n.hasValue()&&(i[n.getString()]||(i[n.getString()]=this)),Array.from(e.childNodes).forEach((e=>{if(1===e.nodeType)this.addChild(e);else if(A&&(3===e.nodeType||4===e.nodeType)){const A=t.createTextNode(e);A.getText().length>0&&this.addChild(A)}}))}}xt(Mt,"ignoreChildTypes",["title"]);class vt extends Mt{constructor(t,e,A){super(t,e,A)}}function St(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Ft(t){const e=t.trim();return/^('|")/.test(e)?e:`"${e}"`}function bt(t){if(!t)return"";const e=t.trim().toLowerCase();switch(e){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return e;default:return/^oblique\s+(-|)\d+deg$/.test(e)?e:""}}function Yt(t){if(!t)return"";const e=t.trim().toLowerCase();switch(e){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return e;default:return/^[\d.]+$/.test(e)?e:""}}class Pt{static parse(){let t=arguments.length>1?arguments[1]:void 0,e="",A="",i="",n="",a="";const r=b(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").trim().split(" "),s={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return r.forEach((t=>{switch(!0){case!s.fontStyle&&Pt.styles.includes(t):"inherit"!==t&&(e=t),s.fontStyle=!0;break;case!s.fontVariant&&Pt.variants.includes(t):"inherit"!==t&&(A=t),s.fontStyle=!0,s.fontVariant=!0;break;case!s.fontWeight&&Pt.weights.includes(t):"inherit"!==t&&(i=t),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0;break;case!s.fontSize:"inherit"!==t&&(n=t.split("/")[0]||""),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0,s.fontSize=!0;break;default:"inherit"!==t&&(a+=t)}})),new Pt(e,A,i,n,a,t)}toString(){return[bt(this.fontStyle),this.fontVariant,Yt(this.fontWeight),this.fontSize,(t=this.fontFamily,void 0===d?t:t.trim().split(",").map(Ft).join(","))].join(" ").trim();var t}constructor(t,e,A,i,n,a){St(this,"fontFamily",void 0),St(this,"fontSize",void 0),St(this,"fontStyle",void 0),St(this,"fontWeight",void 0),St(this,"fontVariant",void 0);const r=a?"string"==typeof a?Pt.parse(a):a:{};this.fontFamily=n||r.fontFamily,this.fontSize=i||r.fontSize,this.fontStyle=t||r.fontStyle,this.fontWeight=A||r.fontWeight,this.fontVariant=e||r.fontVariant}}function Nt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}St(Pt,"styles","normal|italic|oblique|inherit"),St(Pt,"variants","normal|small-caps|inherit"),St(Pt,"weights","normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit");class Rt{get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(t,e){void 0!==t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),void 0!==e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))}addX(t){this.addPoint(t,0)}addY(t){this.addPoint(0,t)}addBoundingBox(t){if(!t)return;const{x1:e,y1:A,x2:i,y2:n}=t;this.addPoint(e,A),this.addPoint(i,n)}sumCubic(t,e,A,i,n){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*A+3*(1-t)*Math.pow(t,2)*i+Math.pow(t,3)*n}bezierCurveAdd(t,e,A,i,n){const a=6*e-12*A+6*i,r=-3*e+9*A-9*i+3*n,s=3*A-3*e;if(0===r){if(0===a)return;const r=-s/a;return void(0<r&&r<1&&(t?this.addX(this.sumCubic(r,e,A,i,n)):this.addY(this.sumCubic(r,e,A,i,n))))}const o=Math.pow(a,2)-4*s*r;if(o<0)return;const c=(-a+Math.sqrt(o))/(2*r);0<c&&c<1&&(t?this.addX(this.sumCubic(c,e,A,i,n)):this.addY(this.sumCubic(c,e,A,i,n)));const l=(-a-Math.sqrt(o))/(2*r);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,A,i,n)):this.addY(this.sumCubic(l,e,A,i,n)))}addBezierCurve(t,e,A,i,n,a,r,s){this.addPoint(t,e),this.addPoint(r,s),this.bezierCurveAdd(!0,t,A,n,r),this.bezierCurveAdd(!1,e,i,a,s)}addQuadraticCurve(t,e,A,i,n,a){const r=t+2/3*(A-t),s=e+2/3*(i-e),o=r+1/3*(n-t),c=s+1/3*(a-e);this.addBezierCurve(t,e,r,o,s,c,n,a)}isPointInBox(t,e){const{x1:A,y1:i,x2:n,y2:a}=this;return A<=t&&t<=n&&i<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,A=Number.NaN,i=Number.NaN){Nt(this,"x1",void 0),Nt(this,"y1",void 0),Nt(this,"x2",void 0),Nt(this,"y2",void 0),this.x1=t,this.y1=e,this.x2=A,this.y2=i,this.addPoint(t,e),this.addPoint(A,i)}}class kt extends Mt{calculateOpacity(){let t=1,e=this;for(;e;){const A=e.getStyle("opacity",!1,!0);A.hasValue(!0)&&(t*=A.getNumber()),e=e.parent}return t}setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e){const e=this.getStyle("fill"),A=this.getStyle("fill-opacity"),i=this.getStyle("stroke"),n=this.getStyle("stroke-opacity");if(e.isUrlDefinition()){const i=e.getFillStyleDefinition(this,A);i&&(t.fillStyle=i)}else if(e.hasValue()){"currentColor"===e.getString()&&e.setValue(this.getStyle("color").getColor());const A=e.getColor();"inherit"!==A&&(t.fillStyle="none"===A?"rgba(0,0,0,0)":A)}if(A.hasValue()){const e=new et(this.document,"fill",t.fillStyle).addOpacity(A).getColor();t.fillStyle=e}if(i.isUrlDefinition()){const e=i.getFillStyleDefinition(this,n);e&&(t.strokeStyle=e)}else if(i.hasValue()){"currentColor"===i.getString()&&i.setValue(this.getStyle("color").getColor());const e=i.getString();"inherit"!==e&&(t.strokeStyle="none"===e?"rgba(0,0,0,0)":e)}if(n.hasValue()){const e=new et(this.document,"stroke",t.strokeStyle).addOpacity(n).getString();t.strokeStyle=e}const a=this.getStyle("stroke-width");if(a.hasValue()){const e=a.getPixels();t.lineWidth=e||L}const r=this.getStyle("stroke-linecap"),s=this.getStyle("stroke-linejoin"),o=this.getStyle("stroke-miterlimit"),c=this.getStyle("stroke-dasharray"),l=this.getStyle("stroke-dashoffset");if(r.hasValue()&&(t.lineCap=r.getString()),s.hasValue()&&(t.lineJoin=s.getString()),o.hasValue()&&(t.miterLimit=o.getNumber()),c.hasValue()&&"none"!==c.getString()){const e=Y(c.getString());void 0!==t.setLineDash?t.setLineDash(e):void 0!==t.webkitLineDash?t.webkitLineDash=e:void 0===t.mozDash||1===e.length&&0===e[0]||(t.mozDash=e);const A=l.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=A:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=A:void 0!==t.mozDashOffset&&(t.mozDashOffset=A)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){const e=this.getStyle("font"),A=this.getStyle("font-style"),i=this.getStyle("font-variant"),n=this.getStyle("font-weight"),a=this.getStyle("font-size"),r=this.getStyle("font-family"),s=new Pt(A.getString(),i.getString(),n.getString(),a.hasValue()?`${a.getPixels(!0)}px`:"",r.getString(),Pt.parse(e.getString(),t.font));A.setValue(s.fontStyle),i.setValue(s.fontVariant),n.setValue(s.fontWeight),a.setValue(s.fontSize),r.setValue(s.fontFamily),t.font=s.toString(),a.isPixels()&&(this.document.emSize=a.getPixels(),this.modifiedEmSizeStack=!0)}e||(this.applyEffects(t),t.globalAlpha=this.calculateOpacity())}clearContext(t){super.clearContext(t),this.modifiedEmSizeStack&&this.document.popEmSize()}constructor(...t){var e,A,i;super(...t),i=!1,(A="modifiedEmSizeStack")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Ht(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ut extends kt{setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);const A=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();A&&(t.textBaseline=A)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(t){if("text"!==this.type)return this.getTElementBoundingBox(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t);let e=null;return this.children.forEach(((A,i)=>{const n=this.getChildBoundingBox(t,this,this,i);e?e.addBoundingBox(n):e=n})),e}getFontSize(){const{document:t,parent:e}=this,A=Pt.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(A)}getTElementBoundingBox(t){const e=this.getFontSize();return new Rt(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,A){const i=e[A];let n;if(t.isArabic){var a;const r=e.length,s=e[A-1],o=e[A+1];let c="isolated";(0===A||" "===s)&&A<r-1&&" "!==o&&(c="terminal"),A>0&&" "!==s&&A<r-1&&" "!==o&&(c="medial"),A>0&&" "!==s&&(A===r-1||" "===o)&&(c="initial"),n=(null===(a=t.arabicGlyphs[i])||void 0===a?void 0:a[c])||t.glyphs[i]}else n=t.glyphs[i];return n||(n=t.missingGlyph),n}getText(){return""}getTextFromNode(t){const e=t||this.node,A=Array.from(e.parentNode.childNodes),i=A.indexOf(e),n=A.length-1;let a=b(e.textContent||"");return 0===i&&(a=a.replace(/^[\n \t]+/,"")),i===n&&(a=function(t){return t.replace(/[\n \t]+$/,"")}(a)),a}renderChildren(t){if("text"!==this.type)return void this.renderTElementChildren(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t),this.children.forEach(((e,A)=>{this.renderChild(t,this,this,A)}));const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:A}=this,i=this.getText(),n=A.getStyle("font-family").getDefinition();if(null==n?void 0:n.fontFace){const{unitsPerEm:a}=n.fontFace,r=Pt.parse(e.ctx.font),s=A.getStyle("font-size").getNumber(r.fontSize),o=A.getStyle("font-style").getString(r.fontStyle),c=s/a,l=n.isRTL?i.split("").reverse().join(""):i,g=Y(A.getAttribute("dx").getString()),h=l.length;for(let e=0;e<h;e++){const A=this.getGlyph(n,l,e);t.translate(this.x,this.y),t.scale(c,-c);const i=t.lineWidth;t.lineWidth=t.lineWidth*a/s,"italic"===o&&t.transform(1,0,.4,1,0,0),A.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=i,t.scale(1/c,-1/c),t.translate(-this.x,-this.y),this.x+=s*(A.horizAdvX||n.horizAdvX)/a,void 0===g[e]||isNaN(g[e])||(this.x+=g[e])}return}const{x:a,y:r}=this;t.fillStyle&&t.fillText(i,a,r),t.strokeStyle&&t.strokeText(i,a,r)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start");let A=0;A="start"===e?t.x-this.minX:"end"===e?t.x-this.maxX:t.x-(this.minX+this.maxX)/2;for(let t=this.textChunkStart;t<this.leafTexts.length;t++)this.leafTexts[t].x+=A;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach(((e,A)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,A)})),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,A,i){const n=A.children[i];n.children.length>0?n.children.forEach(((A,i)=>{e.adjustChildCoordinatesRecursiveCore(t,e,n,i)})):this.adjustChildCoordinates(t,e,A,i)}adjustChildCoordinates(t,e,A,i){const n=A.children[i];if("function"!=typeof n.measureText)return n;t.save(),n.setContext(t,!0);const a=n.getAttribute("x"),r=n.getAttribute("y"),s=n.getAttribute("dx"),o=n.getAttribute("dy"),c=n.getStyle("font-family").getDefinition(),l=Boolean(null==c?void 0:c.isRTL);0===i&&(a.hasValue()||a.setValue(n.getInheritedAttribute("x")),r.hasValue()||r.setValue(n.getInheritedAttribute("y")),s.hasValue()||s.setValue(n.getInheritedAttribute("dx")),o.hasValue()||o.setValue(n.getInheritedAttribute("dy")));const g=n.measureText(t);return l&&(e.x-=g),a.hasValue()?(e.applyAnchoring(),n.x=a.getPixels("x"),s.hasValue()&&(n.x+=s.getPixels("x"))):(s.hasValue()&&(e.x+=s.getPixels("x")),n.x=e.x),e.x=n.x,l||(e.x+=g),r.hasValue()?(n.y=r.getPixels("y"),o.hasValue()&&(n.y+=o.getPixels("y"))):(o.hasValue()&&(e.y+=o.getPixels("y")),n.y=e.y),e.y=n.y,e.leafTexts.push(n),e.minX=Math.min(e.minX,n.x,n.x+g),e.maxX=Math.max(e.maxX,n.x,n.x+g),n.clearContext(t),t.restore(),n}getChildBoundingBox(t,e,A,i){const n=A.children[i];if("function"!=typeof n.getBoundingBox)return null;const a=n.getBoundingBox(t);return a&&n.children.forEach(((A,i)=>{const r=e.getChildBoundingBox(t,e,n,i);a.addBoundingBox(r)})),a}renderChild(t,e,A,i){const n=A.children[i];n.render(t),n.children.forEach(((A,i)=>{e.renderChild(t,e,n,i)}))}measureText(t){const{measureCache:e}=this;if(~e)return e;const A=this.getText(),i=this.measureTargetText(t,A);return this.measureCache=i,i}measureTargetText(t,e){if(!e.length)return 0;const{parent:A}=this,i=A.getStyle("font-family").getDefinition();if(i){const t=this.getFontSize(),n=i.isRTL?e.split("").reverse().join(""):e,a=Y(A.getAttribute("dx").getString()),r=n.length;let s=0;for(let e=0;e<r;e++){s+=(this.getGlyph(i,n,e).horizAdvX||i.horizAdvX)*t/i.fontFace.unitsPerEm,void 0===a[e]||isNaN(a[e])||(s+=a[e])}return s}if(!t.measureText)return 10*e.length;t.save(),this.setContext(t,!0);const{width:n}=t.measureText(e);return this.clearContext(t),t.restore(),n}getInheritedAttribute(t){let e=this;for(;e instanceof Ut&&e.isFirstChild()&&e.parent;){const A=e.parent.getAttribute(t);if(A.hasValue(!0))return A.getString("0");e=e.parent}return null}constructor(t,e,A){super(t,e,new.target===Ut||A),Ht(this,"type","text"),Ht(this,"x",0),Ht(this,"y",0),Ht(this,"leafTexts",[]),Ht(this,"textChunkStart",0),Ht(this,"minX",Number.POSITIVE_INFINITY),Ht(this,"maxX",Number.NEGATIVE_INFINITY),Ht(this,"measureCache",-1)}}function Gt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Tt extends Ut{getText(){return this.text}constructor(t,e,A){super(t,e,new.target===Tt||A),Gt(this,"type","tspan"),Gt(this,"text",void 0),this.text=this.children.length>0?"":this.getTextFromNode()}}class Ot extends Tt{constructor(...t){var e,A,i;super(...t),i="textNode",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Jt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Lt extends B.SVGPathData{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new rt(0,0),this.control=new rt(0,0),this.current=new rt(0,0),this.points=[],this.angles=[]}isEnd(){const{i:t,commands:e}=this;return t>=e.length-1}next(){const t=this.commands[++this.i];return this.previousCommand=this.command,this.command=t,t}getPoint(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"x",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y";const A=new rt(this.command[t],this.command[e]);return this.makeAbsolute(A)}getAsControlPoint(t,e){const A=this.getPoint(t,e);return this.control=A,A}getAsCurrentPoint(t,e){const A=this.getPoint(t,e);return this.current=A,A}getReflectedControlPoint(){const t=this.previousCommand.type;if(t!==B.SVGPathData.CURVE_TO&&t!==B.SVGPathData.SMOOTH_CURVE_TO&&t!==B.SVGPathData.QUAD_TO&&t!==B.SVGPathData.SMOOTH_QUAD_TO)return this.current;const{current:{x:e,y:A},control:{x:i,y:n}}=this;return new rt(2*e-i,2*A-n)}makeAbsolute(t){if(this.command.relative){const{x:e,y:A}=this.current;t.x+=e,t.y+=A}return t}addMarker(t,e,A){const{points:i,angles:n}=this;A&&n.length>0&&!n[n.length-1]&&(n[n.length-1]=i[i.length-1].angleTo(A)),this.addMarkerAngle(t,e?e.angleTo(t):null)}addMarkerAngle(t,e){this.points.push(t),this.angles.push(e)}getMarkerPoints(){return this.points}getMarkerAngles(){const{angles:t}=this,e=t.length;for(let A=0;A<e;A++)if(!t[A])for(let i=A+1;i<e;i++)if(t[i]){t[A]=t[i];break}return t}constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),Jt(this,"control",new rt(0,0)),Jt(this,"start",new rt(0,0)),Jt(this,"current",new rt(0,0)),Jt(this,"command",null),Jt(this,"commands",this.commands),Jt(this,"i",-1),Jt(this,"previousCommand",null),Jt(this,"points",[]),Jt(this,"angles",[])}}function zt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class jt extends kt{path(t){const{pathParser:e}=this,A=new Rt;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case Lt.MOVE_TO:this.pathM(t,A);break;case Lt.LINE_TO:this.pathL(t,A);break;case Lt.HORIZ_LINE_TO:this.pathH(t,A);break;case Lt.VERT_LINE_TO:this.pathV(t,A);break;case Lt.CURVE_TO:this.pathC(t,A);break;case Lt.SMOOTH_CURVE_TO:this.pathS(t,A);break;case Lt.QUAD_TO:this.pathQ(t,A);break;case Lt.SMOOTH_QUAD_TO:this.pathT(t,A);break;case Lt.ARC:this.pathA(t,A);break;case Lt.CLOSE_PATH:this.pathZ(t,A)}return A}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),A=t.getMarkerAngles();if(!e||!A)return null;return e.map(((t,e)=>[t,A[e]]))}renderChildren(t){this.path(t),this.document.screen.mouse.checkPath(this,t);const e=this.getStyle("fill-rule");""!==t.fillStyle&&("inherit"!==e.getString("inherit")?t.fill(e.getString()):t.fill()),""!==t.strokeStyle&&("non-scaling-stroke"===this.getAttribute("vector-effect").getString()?(t.save(),t.setTransform(1,0,0,1,0,0),t.stroke(),t.restore()):t.stroke());const A=this.getMarkers();if(A){const e=A.length-1,i=this.getStyle("marker-start"),n=this.getStyle("marker-mid"),a=this.getStyle("marker-end");if(i.isUrlDefinition()){const e=i.getDefinition(),[n,a]=A[0];e&&e.render(t,n,null===a?void 0:a)}if(n.isUrlDefinition()){const i=n.getDefinition();for(let n=1;n<e;n++){const[e,a]=A[n];i&&i.render(t,e,null===a?void 0:a)}}if(a.isUrlDefinition()){const i=a.getDefinition(),[n,r]=A[e];i&&i.render(t,n,null===r?void 0:r)}}}static pathM(t){const e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){const{pathParser:A}=this,{point:i}=jt.pathM(A),{x:n,y:a}=i;A.addMarker(i),e.addPoint(n,a),t&&t.moveTo(n,a)}static pathL(t){const{current:e}=t;return{current:e,point:t.getAsCurrentPoint()}}pathL(t,e){const{pathParser:A}=this,{current:i,point:n}=jt.pathL(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathH(t){const{current:e,command:A}=t,i=new rt(((null==A?void 0:A.relative)?e.x:0)+A.x,e.y);return t.current=i,{current:e,point:i}}pathH(t,e){const{pathParser:A}=this,{current:i,point:n}=jt.pathH(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathV(t){const{current:e,command:A}=t,i=new rt(e.x,(A.relative?e.y:0)+A.y);return t.current=i,{current:e,point:i}}pathV(t,e){const{pathParser:A}=this,{current:i,point:n}=jt.pathV(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathC(t){const{current:e}=t;return{current:e,point:t.getPoint("x1","y1"),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathC(t,e){const{pathParser:A}=this,{current:i,point:n,controlPoint:a,currentPoint:r}=jt.pathC(A);A.addMarker(r,a,n),e.addBezierCurve(i.x,i.y,n.x,n.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(n.x,n.y,a.x,a.y,r.x,r.y)}static pathS(t){const{current:e}=t;return{current:e,point:t.getReflectedControlPoint(),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathS(t,e){const{pathParser:A}=this,{current:i,point:n,controlPoint:a,currentPoint:r}=jt.pathS(A);A.addMarker(r,a,n),e.addBezierCurve(i.x,i.y,n.x,n.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(n.x,n.y,a.x,a.y,r.x,r.y)}static pathQ(t){const{current:e}=t;return{current:e,controlPoint:t.getAsControlPoint("x1","y1"),currentPoint:t.getAsCurrentPoint()}}pathQ(t,e){const{pathParser:A}=this,{current:i,controlPoint:n,currentPoint:a}=jt.pathQ(A);A.addMarker(a,n,n),e.addQuadraticCurve(i.x,i.y,n.x,n.y,a.x,a.y),t&&t.quadraticCurveTo(n.x,n.y,a.x,a.y)}static pathT(t){const{current:e}=t,A=t.getReflectedControlPoint();t.control=A;return{current:e,controlPoint:A,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){const{pathParser:A}=this,{current:i,controlPoint:n,currentPoint:a}=jt.pathT(A);A.addMarker(a,n,n),e.addQuadraticCurve(i.x,i.y,n.x,n.y,a.x,a.y),t&&t.quadraticCurveTo(n.x,n.y,a.x,a.y)}static pathA(t){const{current:e,command:A}=t;let{rX:i,rY:n,xRot:a,lArcFlag:r,sweepFlag:s}=A;const o=a*(Math.PI/180),c=t.getAsCurrentPoint(),l=new rt(Math.cos(o)*(e.x-c.x)/2+Math.sin(o)*(e.y-c.y)/2,-Math.sin(o)*(e.x-c.x)/2+Math.cos(o)*(e.y-c.y)/2),g=Math.pow(l.x,2)/Math.pow(i,2)+Math.pow(l.y,2)/Math.pow(n,2);g>1&&(i*=Math.sqrt(g),n*=Math.sqrt(g));let h=(r===s?-1:1)*Math.sqrt((Math.pow(i,2)*Math.pow(n,2)-Math.pow(i,2)*Math.pow(l.y,2)-Math.pow(n,2)*Math.pow(l.x,2))/(Math.pow(i,2)*Math.pow(l.y,2)+Math.pow(n,2)*Math.pow(l.x,2)));isNaN(h)&&(h=0);const d=new rt(h*i*l.y/n,h*-n*l.x/i),u=new rt((e.x+c.x)/2+Math.cos(o)*d.x-Math.sin(o)*d.y,(e.y+c.y)/2+Math.sin(o)*d.x+Math.cos(o)*d.y),w=V([1,0],[(l.x-d.x)/i,(l.y-d.y)/n]),B=[(l.x-d.x)/i,(l.y-d.y)/n],p=[(-l.x-d.x)/i,(-l.y-d.y)/n];let E=V(B,p);return j(B,p)<=-1&&(E=Math.PI),j(B,p)>=1&&(E=0),{currentPoint:c,rX:i,rY:n,sweepFlag:s,xAxisRotation:o,centp:u,a1:w,ad:E}}pathA(t,e){const{pathParser:A}=this,{currentPoint:i,rX:n,rY:a,sweepFlag:r,xAxisRotation:s,centp:o,a1:c,ad:l}=jt.pathA(A),g=1-r?1:-1,h=c+g*(l/2),d=new rt(o.x+n*Math.cos(h),o.y+a*Math.sin(h));if(A.addMarkerAngle(d,h-g*Math.PI/2),A.addMarkerAngle(i,h-g*Math.PI),e.addPoint(i.x,i.y),t&&!isNaN(c)&&!isNaN(l)){const e=n>a?n:a,A=n>a?1:n/a,i=n>a?a/n:1;t.translate(o.x,o.y),t.rotate(s),t.scale(A,i),t.arc(0,0,e,c,c+l,Boolean(1-r)),t.scale(1/A,1/i),t.rotate(-s),t.translate(-o.x,-o.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){jt.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}constructor(t,e,A){super(t,e,A),zt(this,"type","path"),zt(this,"pathParser",void 0),this.pathParser=new Lt(this.getAttribute("d").getString())}}function Vt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Kt extends kt{setContext(t){var e;const{document:A}=this,{screen:i,window:n}=A,a=t.canvas;if(i.setDefaults(t),"style"in a&&void 0!==t.font&&n&&void 0!==n.getComputedStyle){t.font=n.getComputedStyle(a).getPropertyValue("font");const e=new et(A,"fontSize",Pt.parse(t.font).fontSize);e.hasValue()&&(A.rootEmSize=e.getPixels("y"),A.emSize=A.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);let{width:r,height:s}=i.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");const o=this.getAttribute("refX"),c=this.getAttribute("refY"),l=this.getAttribute("viewBox"),g=l.hasValue()?Y(l.getString()):null,h=!this.root&&"visible"!==this.getStyle("overflow").getValue("hidden");let d=0,u=0,w=0,B=0;g&&(d=g[0],u=g[1]),this.root||(r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y"),"marker"===this.type&&(w=d,B=u,d=0,u=0)),i.viewPort.setCurrent(r,s),!this.node||this.parent&&"foreignObject"!==(null===(e=this.node.parentNode)||void 0===e?void 0:e.nodeName)||!this.getStyle("transform",!1,!0).hasValue()||this.getStyle("transform-origin",!1,!0).hasValue()||this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(t),t.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),g&&(r=g[2],s=g[3]),A.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:i.viewPort.width,desiredWidth:r,height:i.viewPort.height,desiredHeight:s,minX:d,minY:u,refX:o.getValue(),refY:c.getValue(),clip:h,clipX:w,clipY:B}),g&&(i.viewPort.removeCurrent(),i.viewPort.setCurrent(r,s))}clearContext(t){super.clearContext(t),this.document.screen.viewPort.removeCurrent()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=this.getAttribute("width",!0),n=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),r=this.getAttribute("style"),s=i.getNumber(0),o=n.getNumber(0);if(A)if("string"==typeof A)this.getAttribute("preserveAspectRatio",!0).setValue(A);else{const t=this.getAttribute("preserveAspectRatio");t.hasValue()&&t.setValue(t.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(i.setValue(t),n.setValue(e),a.hasValue()||a.setValue(`0 0 ${s||t} ${o||e}`),r.hasValue()){const A=this.getStyle("width"),i=this.getStyle("height");A.hasValue()&&A.setValue(`${t}px`),i.hasValue()&&i.setValue(`${e}px`)}}constructor(...t){super(...t),Vt(this,"type","svg"),Vt(this,"root",!1)}}class Wt extends jt{path(t){const e=this.getAttribute("x").getPixels("x"),A=this.getAttribute("y").getPixels("y"),i=this.getStyle("width",!1,!0).getPixels("x"),n=this.getStyle("height",!1,!0).getPixels("y"),a=this.getAttribute("rx"),r=this.getAttribute("ry");let s=a.getPixels("x"),o=r.getPixels("y");if(a.hasValue()&&!r.hasValue()&&(o=s),r.hasValue()&&!a.hasValue()&&(s=o),s=Math.min(s,i/2),o=Math.min(o,n/2),t){const a=(Math.sqrt(2)-1)/3*4;t.beginPath(),n>0&&i>0&&(t.moveTo(e+s,A),t.lineTo(e+i-s,A),t.bezierCurveTo(e+i-s+a*s,A,e+i,A+o-a*o,e+i,A+o),t.lineTo(e+i,A+n-o),t.bezierCurveTo(e+i,A+n-o+a*o,e+i-s+a*s,A+n,e+i-s,A+n),t.lineTo(e+s,A+n),t.bezierCurveTo(e+s-a*s,A+n,e,A+n-o+a*o,e,A+n-o),t.lineTo(e,A+o),t.bezierCurveTo(e,A+o-a*o,e+s-a*s,A,e+s,A),t.closePath())}return new Rt(e,A,e+i,A+n)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="rect",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Xt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class qt extends jt{path(t){const{points:e}=this,[{x:A,y:i}]=e,n=new Rt(A,i);return t&&(t.beginPath(),t.moveTo(A,i)),e.forEach((e=>{let{x:A,y:i}=e;n.addPoint(A,i),t&&t.lineTo(A,i)})),n}getMarkers(){const{points:t}=this,e=t.length-1,A=[];return t.forEach(((i,n)=>{n!==e&&A.push([i,i.angleTo(t[n+1])])})),A.length>0&&A.push([t[t.length-1],A[A.length-1][1]]),A}constructor(t,e,A){super(t,e,A),Xt(this,"type","polyline"),Xt(this,"points",[]),this.points=rt.parsePath(this.getAttribute("points").getString())}}class Zt extends kt{getBoundingBox(t){const e=new Rt;return this.children.forEach((A=>{A instanceof jt&&e.addBoundingBox(A.getBoundingBox(t))})),e}constructor(...t){var e,A,i;super(...t),i="g",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function $t(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class _t extends Mt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,A){let i=this;this.getHrefAttribute().hasValue()&&(i=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(i));const{stops:n}=i,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(A,n[n.length-1].color);if(n.forEach((t=>{a.addColorStop(t.offset,this.addParentOpacity(A,t.color))})),this.getAttribute("gradientTransform").hasValue()){const{document:t}=this,{MAX_VIRTUAL_PIXELS:e}=ht,{viewPort:A}=t.screen,i=A.getRoot(),n=new Wt(t);n.attributes.x=new et(t,"x",-e/3),n.attributes.y=new et(t,"y",-e/3),n.attributes.width=new et(t,"width",e),n.attributes.height=new et(t,"height",e);const r=new Zt(t);r.attributes.transform=new et(t,"transform",this.getAttribute("gradientTransform").getValue()),r.children=[n];const s=new Kt(t);s.attributes.x=new et(t,"x",0),s.attributes.y=new et(t,"y",0),s.attributes.width=new et(t,"width",i.width),s.attributes.height=new et(t,"height",i.height),s.children=[r];const o=t.createCanvas(i.width,i.height),c=o.getContext("2d");return c.fillStyle=a,s.render(c),c.createPattern(o,"no-repeat")}return a}inheritStopContainer(t){this.attributesToInherit.forEach((e=>{!this.getAttribute(e).hasValue()&&t.getAttribute(e).hasValue()&&this.getAttribute(e,!0).setValue(t.getAttribute(e).getValue())}))}addParentOpacity(t,e){if(t.hasValue()){return new et(this.document,"color",e).addOpacity(t).getColor()}return e}constructor(t,e,A){super(t,e,A),$t(this,"attributesToInherit",["gradientUnits"]),$t(this,"stops",[]);const{stops:i,children:n}=this;n.forEach((t=>{"stop"===t.type&&i.push(t)}))}}function te(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function ee(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ae extends Mt{getProperty(){var t;const e=this.getAttribute("attributeType").getString(),A=this.getAttribute("attributeName").getString();var i;return"CSS"===e?null===(i=this.parent)||void 0===i?void 0:i.getStyle(A,!0):null===(t=this.parent)||void 0===t?void 0:t.getAttribute(A,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:A,to:i}=this.getProgress();let n=A.getNumber()+(i.getNumber()-A.getNumber())*e;return"%"===t&&(n*=100),`${n}${t}`}update(t){const{parent:e}=this,A=this.getProperty();if(!A)return!1;if(this.initialValue||(this.initialValue=A.getString(),this.initialUnits=A.getUnits()),this.duration>this.maxDuration){const t=this.getAttribute("fill").getString("remove");if("indefinite"===this.getAttribute("repeatCount").getString()||"indefinite"===this.getAttribute("repeatDur").getString())this.duration=0;else if("freeze"!==t||this.frozen){if("remove"===t&&!this.removed)return this.removed=!0,e&&A&&A.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e&&A&&(e.animationFrozen=!0,e.animationFrozenValue=A.getString());return!1}this.duration+=t;let i=!1;if(this.begin<this.duration){let t=this.calcValue();const e=this.getAttribute("type");if(e.hasValue()){t=`${e.getString()}(${t})`}A.setValue(t),i=!0}return i}getProgress(){const{document:t,values:e}=this;let A,i,n=(this.duration-this.begin)/(this.maxDuration-this.begin);if(e.hasValue()){const a=n*(e.getValue().length-1),r=Math.floor(a),s=Math.ceil(a);let o;o=e.getValue()[r],A=new et(t,"from",o?parseFloat(o):0),o=e.getValue()[s],i=new et(t,"to",o?parseFloat(o):0),n=(a-r)/(s-r)}else A=this.from,i=this.to;return{progress:n,from:A,to:i}}constructor(t,e,A){super(t,e,A),ee(this,"type","animate"),ee(this,"begin",void 0),ee(this,"maxDuration",void 0),ee(this,"from",void 0),ee(this,"to",void 0),ee(this,"values",void 0),ee(this,"duration",0),ee(this,"initialValue",void 0),ee(this,"initialUnits",""),ee(this,"removed",!1),ee(this,"frozen",!1),t.screen.animations.push(this),this.begin=this.getAttribute("begin").getMilliseconds(),this.maxDuration=this.begin+this.getAttribute("dur").getMilliseconds(),this.from=this.getAttribute("from"),this.to=this.getAttribute("to"),this.values=new et(t,"values",null);const i=this.getAttribute("values");i.hasValue()&&this.values.setValue(i.getString().split(";"))}}function ie(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ne extends Mt{constructor(t,e,A){super(t,e,A),ie(this,"type","font-face"),ie(this,"ascent",void 0),ie(this,"descent",void 0),ie(this,"unitsPerEm",void 0),this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}function ae(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class re extends jt{constructor(t,e,A){super(t,e,A),ae(this,"type","glyph"),ae(this,"horizAdvX",void 0),ae(this,"unicode",void 0),ae(this,"arabicForm",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}function se(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class oe extends re{constructor(...t){super(...t),se(this,"type","missing-glyph"),se(this,"horizAdvX",0)}}function ce(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function le(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function ge(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function he(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const de=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;function ue(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class we{async load(t,e){try{const{document:A}=this,i=(await A.pith.parser.load(e)).getElementsByTagName("font");Array.from(i).forEach((e=>{const i=A.createElement(e);A.definitions[t]=i}))}catch(t){console.error(`Error while loading font "${e}":`,t)}this.loaded=!0}constructor(t){ue(this,"document",void 0),ue(this,"loaded",void 0),this.document=t,this.loaded=!1,t.fonts.push(this)}}function Be(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class pe extends Mt{constructor(t,e,A){super(t,e,A),Be(this,"type","style");b(Array.from(e.childNodes).map((t=>t.textContent)).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach((e=>{const A=e.trim();if(!A)return;const i=A.split("{"),n=i[0].split(","),a=i[1].split(";");n.forEach((e=>{const A=e.trim();if(!A)return;const i=t.styles[A]||{};if(a.forEach((e=>{const A=e.indexOf(":"),n=e.substr(0,A).trim(),a=e.substr(A+1,e.length-A).trim();n&&a&&(i[n]=new et(t,n,a))})),t.styles[A]=i,t.stylesSpecificity[A]=function(t){const e=[0,0,0];let A=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),i=0;return[A,i]=J(A,R),e[1]+=i,[A,i]=J(A,k),e[0]+=i,[A,i]=J(A,H),e[1]+=i,[A,i]=J(A,U),e[2]+=i,[A,i]=J(A,G),e[1]+=i,[A,i]=J(A,T),e[1]+=i,A=A.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[A,i]=J(A,O),e[2]+=i,e.join("")}(A),"@font-face"===A){const e=i["font-family"].getString().replace(/"|'/g,"");i.src.getString().split(",").forEach((A=>{if(A.indexOf('format("svg")')>0){const i=N(A);i&&new we(t).load(e,i)}}))}}))}))}}function Ee(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}Be(pe,"parseExternalUrl",N);function me(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Ce(t,e,A,i,n,a){return t[A*i*4+4*e+a]}function fe(t,e,A,i,n,a,r){t[A*i*4+4*e+a]=r}function Qe(t,e,A){return t[e]*A}function ye(t,e,A,i){return e+Math.cos(t)*A+Math.sin(t)*i}class De extends Mt{apply(t,e,A,i,n){const{includeOpacity:a,matrix:r}=this,s=t.getImageData(0,0,i,n);for(let t=0;t<n;t++)for(let e=0;e<i;e++){const A=Ce(s.data,e,t,i,0,0),n=Ce(s.data,e,t,i,0,1),o=Ce(s.data,e,t,i,0,2),c=Ce(s.data,e,t,i,0,3);let l=Qe(r,0,A)+Qe(r,1,n)+Qe(r,2,o)+Qe(r,3,c)+Qe(r,4,1),g=Qe(r,5,A)+Qe(r,6,n)+Qe(r,7,o)+Qe(r,8,c)+Qe(r,9,1),h=Qe(r,10,A)+Qe(r,11,n)+Qe(r,12,o)+Qe(r,13,c)+Qe(r,14,1),d=Qe(r,15,A)+Qe(r,16,n)+Qe(r,17,o)+Qe(r,18,c)+Qe(r,19,1);a&&(l=0,g=0,h=0,d*=c/255),fe(s.data,e,t,i,0,0,l),fe(s.data,e,t,i,0,1,g),fe(s.data,e,t,i,0,2,h),fe(s.data,e,t,i,0,3,d)}t.clearRect(0,0,i,n),t.putImageData(s,0,0)}constructor(t,e,A){super(t,e,A),me(this,"type","feColorMatrix"),me(this,"matrix",void 0),me(this,"includeOpacity",void 0);let i=Y(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const t=i[0];i=[.213+.787*t,.715-.715*t,.072-.072*t,0,0,.213-.213*t,.715+.285*t,.072-.072*t,0,0,.213-.213*t,.715-.715*t,.072+.928*t,0,0,0,0,0,1,0,0,0,0,0,1];break}case"hueRotate":{const t=i[0]*Math.PI/180;i=[ye(t,.213,.787,-.213),ye(t,.715,-.715,-.715),ye(t,.072,-.072,.928),0,0,ye(t,.213,-.213,.143),ye(t,.715,.285,.14),ye(t,.072,-.072,-.283),0,0,ye(t,.213,-.213,-.787),ye(t,.715,-.715,.715),ye(t,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break}case"luminanceToAlpha":i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.matrix=i,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}function Ie(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class xe extends Mt{apply(t,e){const{document:A}=this;let i=this.getAttribute("x").getPixels("x"),n=this.getAttribute("y").getPixels("y"),a=this.getStyle("width").getPixels("x"),r=this.getStyle("height").getPixels("y");if(!a&&!r){const e=new Rt;this.children.forEach((A=>{A instanceof jt&&e.addBoundingBox(A.getBoundingBox(t))})),i=Math.floor(e.x1),n=Math.floor(e.y1),a=Math.floor(e.width),r=Math.floor(e.height)}const s=this.removeStyles(e,xe.ignoreStyles),o=A.createCanvas(i+a,n+r),c=o.getContext("2d");A.screen.setDefaults(c),this.renderChildren(c),new De(A,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,i+a,n+r);const l=A.createCanvas(i+a,n+r),g=l.getContext("2d");A.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=c.createPattern(o,"no-repeat"),g.fillRect(0,0,i+a,n+r),t.fillStyle=g.createPattern(l,"no-repeat"),t.fillRect(0,0,i+a,n+r),this.restoreStyles(e,s)}render(t){}constructor(...t){super(...t),Ie(this,"type","mask")}}Ie(xe,"ignoreStyles",["mask","transform","clip-path"]);const Me=()=>{};function ve(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Se extends Mt{apply(t,e,A,i,n){const{document:a,blurRadius:r}=this,s=a.window?a.window.document.body:null,o=t.canvas;o.id=a.getUniqueId(),s&&(o.style.display="none",s.appendChild(o)),(0,p.canvasRGBA)(o,e,A,i,n,r),s&&s.removeChild(o)}constructor(t,e,A){super(t,e,A),ve(this,"type","feGaussianBlur"),ve(this,"extraFilterDistance",void 0),ve(this,"blurRadius",void 0),this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}function Fe(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class be extends Mt{apply(t,e){const{document:A,children:i}=this,n="getBoundingBox"in e?e.getBoundingBox(t):null;if(!n)return;let a=0,r=0;i.forEach((t=>{if(!(t instanceof Se))return;const e=t.extraFilterDistance||0;a=Math.max(a,e),r=Math.max(r,e)}));const s=Math.floor(n.width),o=Math.floor(n.height),c=s+2*a,l=o+2*r;if(Number.isNaN(c)||Number.isNaN(l)||c<1||l<1)return;const g=Math.floor(n.x),h=Math.floor(n.y),d=this.removeStyles(e,be.ignoreStyles),u=A.createCanvas(c,l),w=u.getContext("2d");A.screen.setDefaults(w),w.translate(-g+a,-h+r),e.render(w),i.forEach((t=>{t instanceof Se&&"function"==typeof t.apply&&t.apply(w,0,0,c,l)})),t.drawImage(u,0,0,c,l,g-a,h-r,c,l),this.restoreStyles(e,d)}render(t){}constructor(...t){super(...t),Fe(this,"type","filter")}}Fe(be,"ignoreStyles",["filter","transform","clip-path"]);const Ye={svg:Kt,rect:Wt,circle:class extends jt{path(t){const e=this.getAttribute("cx").getPixels("x"),A=this.getAttribute("cy").getPixels("y"),i=this.getAttribute("r").getPixels();return t&&i>0&&(t.beginPath(),t.arc(e,A,i,0,2*Math.PI,!1),t.closePath()),new Rt(e-i,A-i,e+i,A+i)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="circle",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},ellipse:class extends jt{path(t){const e=(Math.sqrt(2)-1)/3*4,A=this.getAttribute("rx").getPixels("x"),i=this.getAttribute("ry").getPixels("y"),n=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&A>0&&i>0&&(t.beginPath(),t.moveTo(n+A,a),t.bezierCurveTo(n+A,a+e*i,n+e*A,a+i,n,a+i),t.bezierCurveTo(n-e*A,a+i,n-A,a+e*i,n-A,a),t.bezierCurveTo(n-A,a-e*i,n-e*A,a-i,n,a-i),t.bezierCurveTo(n+e*A,a-i,n+A,a-e*i,n+A,a),t.closePath()),new Rt(n-A,a-i,n+A,a+i)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="ellipse",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},line:class extends jt{getPoints(){return[new rt(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new rt(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){const[{x:e,y:A},{x:i,y:n}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,A),t.lineTo(i,n)),new Rt(e,A,i,n)}getMarkers(){const[t,e]=this.getPoints(),A=t.angleTo(e);return[[t,A],[e,A]]}constructor(...t){var e,A,i;super(...t),i="line",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},polyline:qt,polygon:class extends qt{path(t){const e=super.path(t),[{x:A,y:i}]=this.points;return t&&(t.lineTo(A,i),t.closePath()),e}constructor(...t){var e,A,i;super(...t),i="polygon",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},path:jt,pattern:class extends Mt{createPattern(t,e,A){const i=this.getStyle("width").getPixels("x",!0),n=this.getStyle("height").getPixels("y",!0),a=this.getAttribute("data-frame-width"),r=this.getAttribute("data-frame-height"),s=a.hasValue()?a.getPixels("x",!0):i,o=r.hasValue()?r.getPixels("y",!0):n,c=a.hasValue()&&r.hasValue(),l=new Kt(this.document,void 0);l.attributes.viewBox=new et(this.document,"viewBox",this.getAttribute("viewBox").getValue()),l.attributes.width=new et(this.document,"width",`${s}px`),l.attributes.height=new et(this.document,"height",`${o}px`),l.attributes.transform=new et(this.document,"transform",this.getAttribute("patternTransform").getValue()),l.children=this.children;const g=this.document.createCanvas(s,o),h=g.getContext("2d");h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high";const d=this.getAttribute("x"),u=this.getAttribute("y");d.hasValue()&&u.hasValue()&&h.translate(d.getPixels("x",!0),u.getPixels("y",!0)),A.hasValue()?this.styles["fill-opacity"]=A:Reflect.deleteProperty(this.styles,"fill-opacity");for(let t=-1;t<=1;t++)for(let e=-1;e<=1;e++)h.save(),l.attributes.x=new et(this.document,"x",t*g.width),l.attributes.y=new et(this.document,"y",e*g.height),l.render(h),h.restore();return t.createPattern(g,c?"no-repeat":"repeat")}constructor(...t){var e,A,i;super(...t),i="pattern",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},marker:class extends Mt{render(t,e,A){if(!e)return;const{x:i,y:n}=e,a=this.getAttribute("orient").getString("auto"),r=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(i,n),"auto"===a&&A&&t.rotate(A),"strokeWidth"===r&&t.scale(t.lineWidth,t.lineWidth),t.save();const s=new Kt(this.document);s.type=this.type,s.attributes.viewBox=new et(this.document,"viewBox",this.getAttribute("viewBox").getValue()),s.attributes.refX=new et(this.document,"refX",this.getAttribute("refX").getValue()),s.attributes.refY=new et(this.document,"refY",this.getAttribute("refY").getValue()),s.attributes.width=new et(this.document,"width",this.getAttribute("markerWidth").getValue()),s.attributes.height=new et(this.document,"height",this.getAttribute("markerHeight").getValue()),s.attributes.overflow=new et(this.document,"overflow",this.getAttribute("overflow").getValue()),s.attributes.fill=new et(this.document,"fill",this.getAttribute("fill").getColor("black")),s.attributes.stroke=new et(this.document,"stroke",this.getAttribute("stroke").getValue("none")),s.children=this.children,s.render(t),t.restore(),"strokeWidth"===r&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"===a&&A&&t.rotate(-A),t.translate(-i,-n)}constructor(...t){var e,A,i;super(...t),i="marker",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},defs:class extends Mt{render(){}constructor(...t){var e,A,i;super(...t),i="defs",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},linearGradient:class extends _t{getGradient(t,e){const A="objectBoundingBox"===this.getGradientUnits(),i=A?e.getBoundingBox(t):null;if(A||!i)return null;this.getAttribute("x1").hasValue()||this.getAttribute("y1").hasValue()||this.getAttribute("x2").hasValue()||this.getAttribute("y2").hasValue()||(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));const n=A?i.x+i.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=A?i.y+i.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),r=A?i.x+i.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),s=A?i.y+i.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return n===r&&a===s?null:t.createLinearGradient(n,a,r,s)}constructor(t,e,A){var i,n,a;super(t,e,A),a="linearGradient",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.attributesToInherit.push("x1","y1","x2","y2")}},radialGradient:class extends _t{getGradient(t,e){const A="objectBoundingBox"===this.getGradientUnits(),i=e.getBoundingBox(t);if(A&&!i)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");const n=A?i.x+i.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=A?i.y+i.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let r=n,s=a;this.getAttribute("fx").hasValue()&&(r=A?i.x+i.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(s=A?i.y+i.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const o=A?(i.width+i.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),c=this.getAttribute("fr").getPixels();return t.createRadialGradient(r,s,c,n,a,o)}constructor(t,e,A){var i,n,a;super(t,e,A),a="radialGradient",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}},stop:class extends Mt{constructor(t,e,A){super(t,e,A),te(this,"type","stop"),te(this,"offset",void 0),te(this,"color",void 0);const i=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),n=this.getStyle("stop-opacity");let a=this.getStyle("stop-color",!0);""===a.getString()&&a.setValue("#000"),n.hasValue()&&(a=a.addOpacity(n)),this.offset=i,this.color=a.getColor()}},animate:Ae,animateColor:class extends Ae{calcValue(){const{progress:t,from:e,to:A}=this.getProgress(),i=new(F(w))(e.getColor()),n=new(F(w))(A.getColor());if(i.ok&&n.ok){const e=i.r+(n.r-i.r)*t,A=i.g+(n.g-i.g)*t,a=i.b+(n.b-i.b)*t;return`rgb(${Math.floor(e)}, ${Math.floor(A)}, ${Math.floor(a)})`}return this.getAttribute("from").getColor()}constructor(...t){var e,A,i;super(...t),i="animateColor",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},animateTransform:class extends Ae{calcValue(){const{progress:t,from:e,to:A}=this.getProgress(),i=Y(e.getString()),n=Y(A.getString()),a=i.map(((e,A)=>e+(n[A]-e)*t)).join(" ");return a}constructor(...t){var e,A,i;super(...t),i="animateTransform",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},font:class extends Mt{render(){}constructor(t,e,A){super(t,e,A),ce(this,"type","font"),ce(this,"isArabic",!1),ce(this,"missingGlyph",void 0),ce(this,"glyphs",{}),ce(this,"arabicGlyphs",{}),ce(this,"horizAdvX",void 0),ce(this,"isRTL",!1),ce(this,"fontFace",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:i}=t,{children:n}=this;for(const t of n)if(t instanceof ne){this.fontFace=t;const e=t.getStyle("font-family");e.hasValue()&&(i[e.getString()]=this)}else if(t instanceof oe)this.missingGlyph=t;else if(t instanceof re)if(t.arabicForm){this.isRTL=!0,this.isArabic=!0;const e=this.arabicGlyphs[t.unicode];void 0===e?this.arabicGlyphs[t.unicode]={[t.arabicForm]:t}:e[t.arabicForm]=t}else this.glyphs[t.unicode]=t}},"font-face":ne,"missing-glyph":oe,glyph:re,text:Ut,tspan:Tt,tref:class extends Ut{getText(){const t=this.getHrefAttribute().getDefinition();if(t){const e=t.children[0];if(e)return e.getText()}return""}constructor(...t){var e,A,i;super(...t),i="tref",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},a:class extends Ut{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:A,y:i}=this,{mouse:n}=e.screen,a=new et(e,"fontSize",Pt.parse(e.ctx.font).fontSize);n.isWorking()&&n.checkBoundingBox(this,new Rt(A,i-a.getPixels("y"),A+this.measureText(t),i))}else if(this.children.length>0){const e=new Zt(this.document);e.children=this.children,e.parent=this,e.render(t)}}onClick(){const{window:t}=this.document;t&&t.open(this.getHrefAttribute().getString())}onMouseMove(){this.document.ctx.canvas.style.cursor="pointer"}constructor(t,e,A){super(t,e,A),le(this,"type","a"),le(this,"hasText",void 0),le(this,"text",void 0);const{childNodes:i}=e,n=i[0],a=i.length>0&&Array.from(i).every((t=>3===t.nodeType));this.hasText=a,this.text=a?this.getTextFromNode(n):""}},textPath:class extends Ut{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach((e=>{let{type:A,points:i}=e;switch(A){case Lt.LINE_TO:t&&t.lineTo(i[0],i[1]);break;case Lt.MOVE_TO:t&&t.moveTo(i[0],i[1]);break;case Lt.CURVE_TO:t&&t.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]);break;case Lt.QUAD_TO:t&&t.quadraticCurveTo(i[0],i[1],i[2],i[3]);break;case Lt.ARC:{const[e,A,n,a,r,s,o,c]=i,l=n>a?n:a,g=n>a?1:n/a,h=n>a?a/n:1;t&&(t.translate(e,A),t.rotate(o),t.scale(g,h),t.arc(0,0,l,r,r+s,Boolean(1-c)),t.scale(1/g,1/h),t.rotate(-o),t.translate(-e,-A));break}case Lt.CLOSE_PATH:t&&t.closePath()}}))}renderChildren(t){var e;this.setTextData(t),t.save();const A=null===(e=this.parent)||void 0===e?void 0:e.getStyle("text-decoration").getString(),i=this.getFontSize(),{glyphInfo:n}=this,a=t.fillStyle;"underline"===A&&t.beginPath(),n.forEach(((e,n)=>{const{p0:a,p1:r,rotation:s,text:o}=e;t.save(),t.translate(a.x,a.y),t.rotate(s),t.fillStyle&&t.fillText(o,0,0),t.strokeStyle&&t.strokeText(o,0,0),t.restore(),"underline"===A&&(0===n&&t.moveTo(a.x,a.y+i/8),t.lineTo(r.x,r.y+i/5))})),"underline"===A&&(t.lineWidth=i/20,t.strokeStyle=a,t.stroke(),t.closePath()),t.restore()}getLetterSpacingAt(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.letterSpacingCache[t]||0}findSegmentToFitChar(t,e,A,i,n,a,r,s,o){let c=a,l=this.measureText(t,s);" "===s&&"justify"===e&&A<i&&(l+=(i-A)/n),o>-1&&(c+=this.getLetterSpacingAt(o));const g=this.textHeight/20,h=this.getEquidistantPointOnPath(c,g,0),d=this.getEquidistantPointOnPath(c+l,g,0),u={p0:h,p1:d},w=h&&d?Math.atan2(d.y-h.y,d.x-h.x):0;if(r){const t=Math.cos(Math.PI/2+w)*r,e=Math.cos(-w)*r;u.p0={...h,distance:h.distance||0,x:h.x+t,y:h.y+e},u.p1={...d,distance:d.distance||0,x:d.x+t,y:d.y+e}}return c+=l,{offset:c,segment:u,rotation:w}}measureText(t,e){const{measuresCache:A}=this,i=e||this.getText();if(A.has(i))return A.get(i);const n=this.measureTargetText(t,i);return A.set(i,n),n}setTextData(t){var e,A,i;if(this.glyphInfo)return;const n=this.getText(),a=n.split(""),r=n.split(" ").length-1,s=null===(e=this.parent)||void 0===e?void 0:e.getAttribute("dx").split().map((t=>t.getPixels("x"))),o=null===(A=this.parent)||void 0===A?void 0:A.getAttribute("dy").getPixels("y"),c=this.getAttribute("text-anchor").getString("start"),l=this.getStyle("letter-spacing"),g=null===(i=this.parent)||void 0===i?void 0:i.getStyle("letter-spacing");let h=0;l.hasValue()&&"inherit"!==l.getValue()?l.hasValue()&&"initial"!==l.getValue()&&"unset"!==l.getValue()&&(h=l.getPixels()):h=g.getPixels();const d=[],u=n.length;this.letterSpacingCache=d;for(let t=0;t<u;t++)d.push(void 0!==s[t]?s[t]:h);const w=d.reduce(((t,e,A)=>0===A?0:t+e||0),0),B=this.measureText(t),p=Math.max(B+w,0);this.textWidth=B,this.textHeight=this.getFontSize(),this.glyphInfo=[];const E=this.getPathLength(),m=this.getAttribute("startOffset").getNumber(0)*E;let C=0;"middle"!==c&&"center"!==c||(C=-p/2),"end"!==c&&"right"!==c||(C=-p),C+=m,a.forEach(((e,A)=>{const{offset:i,segment:n,rotation:s}=this.findSegmentToFitChar(t,c,p,E,r,C,o,e,A);C=i,n.p0&&n.p1&&this.glyphInfo.push({text:a[A],p0:n.p0,p1:n.p1,rotation:s})}))}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:A}=t;for(A.reset();!A.isEnd();){const{current:t}=A,i=t?t.x:0,n=t?t.y:0,a=A.next();let r=a.type,s=[];switch(a.type){case Lt.MOVE_TO:this.pathM(A,s);break;case Lt.LINE_TO:r=this.pathL(A,s);break;case Lt.HORIZ_LINE_TO:r=this.pathH(A,s);break;case Lt.VERT_LINE_TO:r=this.pathV(A,s);break;case Lt.CURVE_TO:this.pathC(A,s);break;case Lt.SMOOTH_CURVE_TO:r=this.pathS(A,s);break;case Lt.QUAD_TO:this.pathQ(A,s);break;case Lt.SMOOTH_QUAD_TO:r=this.pathT(A,s);break;case Lt.ARC:s=this.pathA(A);break;case Lt.CLOSE_PATH:jt.pathZ(A)}a.type!==Lt.CLOSE_PATH?e.push({type:r,points:s,start:{x:i,y:n},pathLength:this.calcLength(i,n,r,s)}):e.push({type:Lt.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:A,y:i}=jt.pathM(t).point;e.push(A,i)}pathL(t,e){const{x:A,y:i}=jt.pathL(t).point;return e.push(A,i),Lt.LINE_TO}pathH(t,e){const{x:A,y:i}=jt.pathH(t).point;return e.push(A,i),Lt.LINE_TO}pathV(t,e){const{x:A,y:i}=jt.pathV(t).point;return e.push(A,i),Lt.LINE_TO}pathC(t,e){const{point:A,controlPoint:i,currentPoint:n}=jt.pathC(t);e.push(A.x,A.y,i.x,i.y,n.x,n.y)}pathS(t,e){const{point:A,controlPoint:i,currentPoint:n}=jt.pathS(t);return e.push(A.x,A.y,i.x,i.y,n.x,n.y),Lt.CURVE_TO}pathQ(t,e){const{controlPoint:A,currentPoint:i}=jt.pathQ(t);e.push(A.x,A.y,i.x,i.y)}pathT(t,e){const{controlPoint:A,currentPoint:i}=jt.pathT(t);return e.push(A.x,A.y,i.x,i.y),Lt.QUAD_TO}pathA(t){let{rX:e,rY:A,sweepFlag:i,xAxisRotation:n,centp:a,a1:r,ad:s}=jt.pathA(t);return 0===i&&s>0&&(s-=2*Math.PI),1===i&&s<0&&(s+=2*Math.PI),[a.x,a.y,e,A,r,s,n,i]}calcLength(t,e,A,i){let n=0,a=null,r=null,s=0;switch(A){case Lt.LINE_TO:return this.getLineLength(t,e,i[0],i[1]);case Lt.CURVE_TO:for(n=0,a=this.getPointOnCubicBezier(0,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),s=.01;s<=1;s+=.01)r=this.getPointOnCubicBezier(s,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Lt.QUAD_TO:for(n=0,a=this.getPointOnQuadraticBezier(0,t,e,i[0],i[1],i[2],i[3]),s=.01;s<=1;s+=.01)r=this.getPointOnQuadraticBezier(s,t,e,i[0],i[1],i[2],i[3]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Lt.ARC:{n=0;const t=i[4],e=i[5],A=i[4]+e;let o=Math.PI/180;if(Math.abs(t-A)<o&&(o=Math.abs(t-A)),a=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],t,0),e<0)for(s=t-o;s>A;s-=o)r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;else for(s=t+o;s<A;s+=o)r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],A,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),n}}return 0}getPointOnLine(t,e,A,i,n){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:A;const s=(n-A)/(i-e+L);let o=Math.sqrt(t*t/(1+s*s));i<e&&(o*=-1);let c=s*o,l=null;if(i===e)l={x:a,y:r+c};else if((r-A)/(a-e+L)===s)l={x:a+o,y:r+c};else{let g=0,h=0;const d=this.getLineLength(e,A,i,n);if(d<L)return null;let u=(a-e)*(i-e)+(r-A)*(n-A);u/=d*d,g=e+u*(i-e),h=A+u*(n-A);const w=this.getLineLength(a,r,g,h),B=Math.sqrt(t*t-w*w);o=Math.sqrt(B*B/(1+s*s)),i<e&&(o*=-1),c=s*o,l={x:g+o,y:h+c}}return l}getPointOnPath(t){const e=this.getPathLength();let A=0,i=null;if(t<-5e-5||t-5e-5>e)return null;const{dataArray:n}=this;for(const e of n){if(e&&(e.pathLength<5e-5||A+e.pathLength+5e-5<t)){A+=e.pathLength;continue}const n=t-A;let a=0;switch(e.type){case Lt.LINE_TO:i=this.getPointOnLine(n,e.start.x,e.start.y,e.points[0],e.points[1],e.start.x,e.start.y);break;case Lt.ARC:{const t=e.points[4],A=e.points[5],r=e.points[4]+A;if(a=t+n/e.pathLength*A,A<0&&a<r||A>=0&&a>r)break;i=this.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],a,e.points[6]);break}case Lt.CURVE_TO:a=n/e.pathLength,a>1&&(a=1),i=this.getPointOnCubicBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);break;case Lt.QUAD_TO:a=n/e.pathLength,a>1&&(a=1),i=this.getPointOnQuadraticBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}if(i)return i;break}return null}getLineLength(t,e,A,i){return Math.sqrt((A-t)*(A-t)+(i-e)*(i-e))}getPathLength(){return-1===this.pathLength&&(this.pathLength=this.dataArray.reduce(((t,e)=>e.pathLength>0?t+e.pathLength:t),0)),this.pathLength}getPointOnCubicBezier(t,e,A,i,n,a,r,s,o){return{x:s*K(t)+a*W(t)+i*X(t)+e*q(t),y:o*K(t)+r*W(t)+n*X(t)+A*q(t)}}getPointOnQuadraticBezier(t,e,A,i,n,a,r){return{x:a*Z(t)+i*$(t)+e*_(t),y:r*Z(t)+n*$(t)+A*_(t)}}getPointOnEllipticalArc(t,e,A,i,n,a){const r=Math.cos(a),s=Math.sin(a),o=A*Math.cos(n),c=i*Math.sin(n);return{x:t+(o*r-c*s),y:e+(o*s+c*r)}}buildEquidistantCache(t,e){const A=this.getPathLength(),i=e||.25,n=t||A/100;if(!this.equidistantCache||this.equidistantCache.step!==n||this.equidistantCache.precision!==i){this.equidistantCache={step:n,precision:i,points:[]};let t=0;for(let e=0;e<=A;e+=i){const A=this.getPointOnPath(e),a=this.getPointOnPath(e+i);A&&a&&(t+=this.getLineLength(A.x,A.y,a.x,a.y),t>=n&&(this.equidistantCache.points.push({x:A.x,y:A.y,distance:e}),t-=n))}}}getEquidistantPointOnPath(t,e,A){if(this.buildEquidistantCache(e,A),t<0||t-this.getPathLength()>5e-5)return null;const i=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[i]||null}constructor(t,e,A){super(t,e,A),ge(this,"type","textPath"),ge(this,"textWidth",0),ge(this,"textHeight",0),ge(this,"pathLength",-1),ge(this,"glyphInfo",null),ge(this,"text",void 0),ge(this,"dataArray",void 0),ge(this,"letterSpacingCache",[]),ge(this,"equidistantCache",null),ge(this,"measuresCache",new Map([["",0]]));const i=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(i)}},image:class extends kt{async loadImage(t){try{const e=await this.document.createImage(t);this.image=e}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}async loadSvg(t){const e=de.exec(t);if(e){const t=e[5];t&&("base64"===e[4]?this.image=atob(t):this.image=decodeURIComponent(t))}else try{const e=await this.document.fetch(t),A=await e.text();this.image=A}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}renderChildren(t){const{document:e,image:A,loaded:i}=this,n=this.getAttribute("x").getPixels("x"),a=this.getAttribute("y").getPixels("y"),r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");if(i&&A&&r&&s){if(t.save(),t.translate(n,a),"string"==typeof A){const i=e.pith.forkString(t,A,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:r,scaleHeight:s}),{documentElement:n}=i.document;n&&(n.parent=this),i.resize(r,s,this.getAttribute("preserveAspectRatio").getString()),i.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r,desiredWidth:A.width,height:s,desiredHeight:A.height}),this.loaded&&("complete"in A&&!A.complete||t.drawImage(A,0,0));t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),A=this.getStyle("width").getPixels("x"),i=this.getStyle("height").getPixels("y");return new Rt(t,e,t+A,e+i)}constructor(t,e,A){super(t,e,A),he(this,"type","image"),he(this,"loaded",!1),he(this,"image",void 0);const i=this.getHrefAttribute().getString();if(!i)return;const n=i.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(i);t.images.push(this),n?this.loadSvg(i):this.loadImage(i)}},g:Zt,symbol:class extends kt{render(t){}constructor(...t){var e,A,i;super(...t),i="symbol",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},style:pe,use:class extends kt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),A=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),A.hasValue()&&t.translate(0,A.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:A}=this;if(A){let i=A;if("symbol"===A.type&&(i=new Kt(e),i.attributes.viewBox=new et(e,"viewBox",A.getAttribute("viewBox").getString()),i.attributes.preserveAspectRatio=new et(e,"preserveAspectRatio",A.getAttribute("preserveAspectRatio").getString()),i.attributes.overflow=new et(e,"overflow",A.getAttribute("overflow").getString()),i.children=A.children,A.styles.opacity=new et(e,"opacity",this.calculateOpacity())),"svg"===i.type){const t=this.getStyle("width",!1,!0),A=this.getStyle("height",!1,!0);t.hasValue()&&(i.attributes.width=new et(e,"width",t.getString())),A.hasValue()&&(i.attributes.height=new et(e,"height",A.getString()))}const n=i.parent;i.parent=this,i.render(t),i.parent=n}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?It.fromElement(t,e):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...t){super(...t),Ee(this,"type","use"),Ee(this,"cachedElement",void 0)}},mask:xe,clipPath:class extends Mt{apply(t){const{document:e}=this,A=Reflect.getPrototypeOf(t),{beginPath:i,closePath:n}=t;A&&(A.beginPath=Me,A.closePath=Me),Reflect.apply(i,t,[]),this.children.forEach((i=>{if(!("path"in i))return;let a="elementTransform"in i?i.elementTransform():null;a||(a=It.fromElement(e,i)),a&&a.apply(t),i.path(t),A&&(A.closePath=n),a&&a.unapply(t)})),Reflect.apply(n,t,[]),t.clip(),A&&(A.beginPath=i,A.closePath=n)}render(t){}constructor(...t){var e,A,i;super(...t),i="clipPath",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},filter:be,feDropShadow:class extends Mt{apply(t,e,A,i,n){}constructor(t,e,A){var i,n,a;super(t,e,A),a="feDropShadow",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.addStylesFromStyleDefinition()}},feMorphology:class extends Mt{apply(t,e,A,i,n){}constructor(...t){var e,A,i;super(...t),i="feMorphology",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},feComposite:class extends Mt{apply(t,e,A,i,n){}constructor(...t){var e,A,i;super(...t),i="feComposite",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},feColorMatrix:De,feGaussianBlur:Se,title:class extends Mt{constructor(...t){var e,A,i;super(...t),i="title",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},desc:class extends Mt{constructor(...t){var e,A,i;super(...t),i="desc",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}};function Pe(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ne{bindCreateImage(t,e){return"boolean"==typeof e?(A,i)=>t(A,"boolean"==typeof i?i:e):t}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){const{emSizeStack:t}=this;return t[t.length-1]||12}set emSize(t){const{emSizeStack:e}=this;e.push(t)}popEmSize(){const{emSizeStack:t}=this;t.pop()}getUniqueId(){return"pith"+ ++this.uniqueId}isImagesLoaded(){return this.images.every((t=>t.loaded))}isFontsLoaded(){return this.fonts.every((t=>t.loaded))}createDocumentElement(t){const e=this.createElement(t.documentElement);return e.root=!0,e.addStylesFromStyleDefinition(),this.documentElement=e,e}createElement(t){const e=t.nodeName.replace(/^[^:]+:/,""),A=Ne.elementTypes[e];return A?new A(this,t):new vt(this,t)}createTextNode(t){return new Ot(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=12,emSize:A=12,createCanvas:i=Ne.createCanvas,createImage:n=Ne.createImage,anonymousCrossOrigin:a}={}){Pe(this,"pith",void 0),Pe(this,"rootEmSize",void 0),Pe(this,"documentElement",void 0),Pe(this,"screen",void 0),Pe(this,"createCanvas",void 0),Pe(this,"createImage",void 0),Pe(this,"definitions",void 0),Pe(this,"styles",void 0),Pe(this,"stylesSpecificity",void 0),Pe(this,"images",void 0),Pe(this,"fonts",void 0),Pe(this,"emSizeStack",void 0),Pe(this,"uniqueId",void 0),this.pith=t,this.definitions={},this.styles={},this.stylesSpecificity={},this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=t.screen,this.rootEmSize=e,this.emSize=A,this.createCanvas=i,this.createImage=this.bindCreateImage(n,a),this.screen.wait((()=>this.isImagesLoaded())),this.screen.wait((()=>this.isFontsLoaded()))}}function Re(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}Pe(Ne,"createCanvas",(function(t,e){const A=document.createElement("canvas");return A.width=t,A.height=e,A})),Pe(Ne,"createImage",(async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const A=document.createElement("img");return e&&(A.crossOrigin="Anonymous"),new Promise(((e,i)=>{A.onload=()=>{e(A)},A.onerror=(t,e,A,n,a)=>{i(a)},A.src=t}))})),Pe(Ne,"elementTypes",Ye);class ke{static async from(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new Bt(A),n=await i.parse(e);return new ke(t,n,A)}static fromString(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new Bt(A).parseFromString(e);return new ke(t,i,A)}fork(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ke.from(t,e,{...this.options,...A})}forkString(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ke.fromString(t,e,{...this.options,...A})}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}async render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.start({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0,...t}),await this.ready(),this.stop()}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{documentElement:e,screen:A,options:i}=this;A.start(e,{enableRedraw:!0,...i,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,A)}constructor(t,e,A={}){Re(this,"parser",void 0),Re(this,"screen",void 0),Re(this,"document",void 0),Re(this,"documentElement",void 0),Re(this,"options",void 0),this.parser=new Bt(A),this.screen=new ht(t,A),this.options=A;const i=new Ne(this,A),n=i.createDocumentElement(e);this.document=i,this.documentElement=n}}function He(t,e,A,i){Object.defineProperty(t,e,{get:A,set:i,enumerable:!0,configurable:!0})}var Ue="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==S?S:{},Ge={};He(Ge,"CanvasCommand",(()=>Xi)),He(Ge,"UpdateWorkflowStateCommand",(()=>qi)),He(Ge,"MoveCommand",(()=>Zi)),He(Ge,"RotateCommand",(()=>$i)),He(Ge,"ResizeCommand",(()=>_i)),He(Ge,"GroupCommand",(()=>tn)),He(Ge,"CreateLayoutCommand",(()=>en)),He(Ge,"ClearLayoutCommand",(()=>An)),He(Ge,"CreateElementCommand",(()=>nn)),He(Ge,"DeleteElementCommand",(()=>an)),He(Ge,"CloneElementCommand",(()=>rn)),He(Ge,"FontColorCommand",(()=>sn)),He(Ge,"FontImageFillCommand",(()=>on)),He(Ge,"FontSizeCommand",(()=>cn)),He(Ge,"FontAlgorithmCommand",(()=>ln)),He(Ge,"FontSourceCommand",(()=>gn)),He(Ge,"FontAlignmentCommand",(()=>hn)),He(Ge,"UpdateFramePattern",(()=>dn)),He(Ge,"TextChangeCommand",(()=>un)),He(Ge,"IllustrationColorCommand",(()=>wn)),He(Ge,"IllustrationCacheCommand",(()=>Bn)),He(Ge,"BringToFrontCommand",(()=>pn)),He(Ge,"BringToBackCommand",(()=>En)),He(Ge,"BringForwardCommand",(()=>mn)),He(Ge,"SendBackwardsCommand",(()=>Cn)),He(Ge,"LayerCommand",(()=>fn)),He({},"generate",(()=>Te));const Te=()=>{const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()};var Oe={};He(Oe,"ElementNotFoundError",(()=>zi)),He(Oe,"findElement",(()=>ji)),He(Oe,"findLayoutForElement",(()=>Vi)),He(Oe,"updatedLayoutForElement",(()=>Ki)),He(Oe,"rehydrateSerializedLayout",(()=>Wi));var Je={};He(Je,"CommandContext",(()=>Ti)),He(Je,"getSvgElement",(()=>Ji)),He(Je,"elementFactory",(()=>Oi)),He(Je,"sortElementsByLayersWithIndex",(()=>Li)),He({},"SVGLayout",(()=>lA));var Le={};let ze;var je;let Ve;var Ke;let We;var Xe;let qe;var Ze;let $e;var _e;let tA;var eA;let AA;var iA;let nA;var aA;let rA;var sA;let oA;var cA;He(Le,"LayoutElementType",(()=>ze)),He(Le,"LayoutRenderingPurpose",(()=>Ve)),He(Le,"TextAlgorithm",(()=>We)),He(Le,"UnitOfMeasurement",(()=>qe)),He(Le,"ScaleAxis",(()=>$e)),He(Le,"AspectType",(()=>tA)),He(Le,"MaterialEffectMode",(()=>AA)),He(Le,"AssetType",(()=>nA)),He(Le,"StepType",(()=>rA)),He(Le,"StepAspectType",(()=>oA)),(je=ze||(ze={})).Frame="frame",je.Image="image",je.Illustration="illustration",je.Textbox="textbox",(Ke=Ve||(Ve={})).ThreeD="ThreeD",Ke.FreeDesign="FreeDesign",Ke.Print="Print",(Xe=We||(We={})).Autosize="Autosize",Xe.Traditional="Traditional",(Ze=qe||(qe={})).Pixel="px",Ze.Millimeter="mm",Ze.Centimeter="cm",(_e=$e||($e={}))[_e.North=0]="North",_e[_e.Northeast=1]="Northeast",_e[_e.East=2]="East",_e[_e.Southeast=3]="Southeast",_e[_e.South=4]="South",_e[_e.Southwest=5]="Southwest",_e[_e.West=6]="West",_e[_e.Northwest=7]="Northwest",(eA=tA||(tA={})).FileUpload="FileUpload",eA.Option="Option",eA.Text="Text",(iA=AA||(AA={})).None="None",iA.RemoveWhenSelected="RemoveWhenSelected",iA.ApplyWhenSelected="ApplyWhenSelected",(aA=nA||(nA={})).Font="Font",aA.Frame="Frame",aA.Illustration="Illustration",aA.Image="Image",aA.Model="Model",aA.Material="Material",aA.Color="Color",aA.QuestionnaireCollateral="QuestionnaireCollateral",aA.RequestCollateral="RequestCollateral",aA.SignupCollateral="SignupCollateral",aA.Video="Video",aA.ColorProfile="ColorProfile",(sA=rA||(rA={})).Bulk="Bulk",sA.DigitalContent="DigitalContent",sA.Finish="Finish",sA.Frame="Frame",sA.Illustration="Illustration",sA.Introduction="Introduction",sA.Material="Material",sA.Model="Model",sA.Module="Module",sA.Picture="Picture",sA.Photo="Photo",sA.ProductOverlay="ProductOverlay",sA.Question="Question",sA.Shape="Shape",sA.SilentIllustration="SilentIllustration",sA.Text="Text",(cA=oA||(oA={})).Color="Color",cA.Colors="Colors",cA.Selection="Selection",cA.Selections="Selections",cA.Text="Text",cA.Upload="Upload";const lA=({backgroundColor:t,outlineColor:e,borderRadius:i,configuration:n,elements:a,height:r,maxHeight:s,maxWidth:o,outlineArea:c,position:l,preserveAspectRatio:g,viewBox:h,width:d})=>{const u=i||0,w=2*(c?.scale||1),B=h||{x:0,y:0,width:d,height:r},p=`${B.x} ${B.y} ${B.width} ${B.height}`,E=Te(),m=n.purpose===Ve.FreeDesign&&(0,A.jsx)("defs",{children:(0,A.jsx)("clipPath",{id:"viewboxClip",children:(0,A.jsx)("rect",{width:B.width,height:B.height,rx:u})})}),C=n.colorProfiles?.map(((t,e)=>(0,A.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),f=Li(a.map((t=>({...t,_renderingConfiguration:n,mask:c?`url(#viewmask-${E})`:void 0}))));return(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:g,width:d,height:r,style:{gridColumn:1,gridRow:1,maxWidth:o,maxHeight:s,position:l},viewBox:p,children:[C,m,!!t&&(0,A.jsx)("rect",{id:"layout-background",width:B.width,height:B.height,fill:t,rx:u}),(0,A.jsx)("g",{id:"element-group",clipPath:n.purpose===Ve.FreeDesign?"url(#viewboxClip)":void 0,children:f.map((t=>Oi(t))).filter((t=>!!t))}),c&&(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:w/2,strokeDasharray:`${2*w} ${w}`}),c&&(0,A.jsxs)("mask",{id:`viewmask-${E}`,children:[(0,A.jsx)("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"black"}),(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};He({},"Image",(()=>SA));var gA={};He(gA,"getAxisAlignedBoundingBox",(()=>hA)),He(gA,"degreesToRadians",(()=>uA)),He(gA,"findAngle",(()=>dA)),He(gA,"radiansToDegrees",(()=>wA)),He(gA,"isCloseToValue",(()=>BA)),He(gA,"getTrueCoordinates",(()=>pA)),He(gA,"getPointOfRotation",(()=>EA)),He(gA,"getNWPoint",(()=>mA)),He(gA,"getNEPoint",(()=>CA)),He(gA,"getSWPoint",(()=>fA)),He(gA,"getSEPoint",(()=>QA)),He(gA,"turnRightClockwise",(()=>yA)),He(gA,"currentDirection",(()=>DA)),He(gA,"getElementVertices",(()=>IA)),He(gA,"rotateAroundPoint",(()=>xA)),He(gA,"mmPerPixel",(()=>MA)),He(gA,"cmPerPixel",(()=>vA));const hA=(t,e,A,i,n)=>{const a=uA(n),r=A/2,s=i/2,o=t+r,c=e+s,l=Math.sin(a),g=Math.cos(a),h=-s,d=r*g-h*l,u=r*g-s*l,w=r*l+h*g,B=r*l+s*g,p=Math.max(Math.abs(d),Math.abs(u)),E=Math.max(Math.abs(w),Math.abs(B));return{minX:o-p,maxX:o+p,minY:c-E,maxY:c+E}},dA=(t,e,A)=>{const i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2)),a=Math.sqrt(Math.pow(A.x-t.x,2)+Math.pow(A.y-t.y,2));return Math.acos((n*n+i*i-a*a)/(2*n*i))*(180/Math.PI)},uA=t=>t*(Math.PI/180),wA=t=>t*(180/Math.PI),BA=(t,e,A)=>Math.abs(t-e)<A,pA=(t,e,A)=>{const i=Math.sin(uA(A)),n=Math.cos(uA(A));return{x:(t.x-e.x)*n-(t.y-e.y)*i+e.x,y:(t.x-e.x)*i+(t.y-e.y)*n+e.y}},EA=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),mA=(t,e,A,i)=>({x:t.x+e?.x*A,y:t.y+e?.y*i}),CA=(t,e,A,i)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+e?.y*i}),fA=(t,e,A,i)=>({x:t.x+e?.x*A,y:t.y+(e?.y+e?.height)*i}),QA=(t,e,A,i)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+(e?.y+e?.height)*i}),yA=t=>{switch(t){case $e.North:return $e.East;case $e.East:return $e.South;case $e.South:return $e.West;case $e.West:return $e.North;case $e.Northwest:return $e.Northeast;case $e.Northeast:return $e.Southeast;case $e.Southeast:return $e.Southwest;case $e.Southwest:return $e.Northwest}},DA=(t,e)=>e>45&&e<=135?yA(t):e>135&&e<=225?yA(yA(t)):e>225&&e<=315?yA(yA(yA(t))):t,IA=(t,e={x:0,y:0},A={x:1,y:1})=>{const i=uA(t.rotation),n={x:e.x+t.x*A.x,y:e.x+t.y*A.y},a={x:t.x+t.width,y:t.y},r={x:e.x+(t.x+t.width)*A.x,y:e.y+(t.height+t.y)*A.y},s={x:e.x+t.x*A.x,y:e.y+(t.height+t.y)*A.y},o={x:(s.x+r.x)/2,y:s.y-t.height*A.y/2};return{a:xA(n,o,i),b:xA(a,o,i),c:xA(r,o,i),d:xA(s,o,i),center:o}},xA=(t,e,A)=>{const i=Math.sin(A),n=Math.cos(A);return{x:(t.x-e.x)*n-(t.y-e.y)*i+e.x,y:(t.x-e.x)*i+(t.y-e.y)*n+e.y}},MA=.352778,vA=.035277,SA=t=>{const e=t.rotation||0,i=uA(e),n=Math.cos(i),a=-Math.sin(i);return(0,A.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,A.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${n}, ${-a}, ${a}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `,children:(0,A.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};He({},"Frame",(()=>FA));const FA=t=>{const e=`spiff-frame-${t.id}`,n=`spiff-frame-blur-${t.id}`,a=`spiff-frame-blur-edge-${t.id}`,r=`spiff-frame-focal-mask-${t.id}`,s=()=>t.disablePlaceholder&&!t.pattern?"":t.pattern?t.pattern.src:"data:image/png;base64,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";if(!s())return(0,A.jsx)(F(i).Fragment,{});const o=!!t.focalBlur&&!!t.pattern,c=t.rotation||0,l=uA(c),g=Math.cos(l),h=-Math.sin(l);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("defs",{children:(i=>{const o=t.pattern?.x||0,c=t.pattern?.y||0,l=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(o):256,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(c):256,h=t.pattern?t.pattern.width*t.pattern.scaleX:256,d=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,A.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,A.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:l,height:t.pattern?1:g,"data-frame-width":t.pattern?l:void 0,"data-frame-height":t.pattern?g:void 0,id:e,children:(0,A.jsx)("image",{preserveAspectRatio:"none",x:o,y:c,width:h,height:d,xlinkHref:s()})}),i?(0,A.jsx)(bA,{path:t.path,width:t.width,height:t.height,focalBlurStrength:t.focalBlurStrength||1,focalBlurRadius:t.focalBlurRadius||10,blurFilterId:n,focalMaskId:r,blurEdgeClipId:a}):null]})})(o)}),(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${g}, ${-h}, ${h}, ${g}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n matrix(${t.scaleX}, 0, 0, ${t.scaleY}, 0, 0)\n `,children:[(0,A.jsx)("path",{filter:o?`url(#${n})`:void 0,mask:o?`url(#${a})`:void 0,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}),o?(0,A.jsx)("path",{mask:`url(#${r})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},bA=t=>{const{path:e,width:i,height:n,focalBlurStrength:a,focalBlurRadius:r,blurFilterId:s,focalMaskId:o,blurEdgeClipId:c}=t;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("filter",{id:s,children:(0,A.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,A.jsx)("mask",{id:o,children:(0,A.jsx)("circle",{cx:i/2,cy:n/2,r:r||0,fill:"white",filter:`url(#${s})`})}),(0,A.jsx)("mask",{id:c,children:(0,A.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};He({},"Textbox",(()=>Fi));var YA={};He(YA,"fontSizeStep",(()=>wi)),He(YA,"textWidth",(()=>Bi)),He(YA,"charWidth",(()=>pi)),He(YA,"lineWidth",(()=>Ei)),He(YA,"applyTextTransformations",(()=>Ci)),He(YA,"zip",(()=>fi)),He(YA,"getTextAlignment",(()=>Qi)),He(YA,"getAnchor",(()=>yi)),He(YA,"recomputeTextOnElement",(()=>Di)),He(YA,"defaultLineHeightFactor",(()=>Ii));var PA={};He(PA,"refitTextbox",(()=>di)),He(PA,"recalculateTextboxRegion",(()=>ui));var NA={};He(NA,"FontMetrics",(()=>ii)),He(NA,"loadFontFromExternalUrl",(()=>ai)),He(NA,"loadFontFromDataUrl",(()=>ri)),He(NA,"getFontMetrics",(()=>si));var RA={};He(RA,"registerJSDOM",(()=>UA)),He(RA,"createElement",(()=>JA)),He(RA,"createElementNS",(()=>LA)),He(RA,"domParser",(()=>zA)),He(RA,"fetchAsArrayBuffer",(()=>jA)),He(RA,"fetchAsString",(()=>VA)),He(RA,"loadFontFaceSet",(()=>KA)),He(RA,"xmlSerializer",(()=>WA)),He(RA,"toBase64",(()=>XA)),He(RA,"dataUrlFromExternalUrl",(()=>qA)),He(RA,"arrayBufferToDataUrl",(()=>ZA)),He(RA,"arrayBufferToBuffer",(()=>_A)),He(RA,"dataUrlToArrayBuffer",(()=>$A));var kA=a.Buffer;let HA;function UA(t){HA=t}function GA(){if(!HA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new HA}if(void 0===Ue.TextEncoder){const{TextEncoder:t}=c;Ue.TextEncoder=t}if(void 0===Ue.TextDecoder){const{TextDecoder:t}=c;Ue.TextDecoder=t}const TA=new(F(s).Agent)({rejectUnauthorized:!("local"===Ue.process?.env?.ENVIRONMENT)}),OA=t=>t.every((t=>"undefined"!==t)),JA=t=>OA([typeof document])?document.createElement(t):GA().window.document.createElement(t),LA=(t,e)=>{if(OA([typeof document]))return document.createElementNS(t,e);const A=GA().window.document.createElement(e);return A.setAttribute("xmlns",t),A},zA=()=>OA([typeof DOMParser])?new DOMParser:new(GA().window.DOMParser),jA=t=>{if(OA([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{A(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{F(r).get(e,{responseType:"arraybuffer",httpsAgent:TA}).then((e=>{t(e.data)})).catch((t=>{A(t)}))}))}},VA=t=>{if(OA([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.text())})).catch(A)}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{F(r).get(e,{responseType:"text",httpsAgent:TA}).then((e=>{t(e.data)})).catch(A)}))}},KA=async(t,e)=>{if(OA([typeof FontFace])){const A=t.names.fullName.en,i=new FontFace(A,`url(${e})`);return document.fonts.add(i),i.load()}},WA=()=>OA([typeof XMLSerializer])?new XMLSerializer:new(GA().window.XMLSerializer),XA=t=>OA([typeof btoa])?btoa(t):kA.from(t).toString("base64"),qA=async t=>{if(OA([typeof fetch,typeof Blob,typeof FileReader])){const e=await fetch(t),A=await e.blob();return await ei(A)}const e=(await F(r).get(t,{responseType:"arraybuffer"})).data;return ZA(e)},ZA=async t=>{const e=await(async t=>{const e=await(0,o.fromBuffer)(t);return e?e.mime:"image/svg+xml"})(t);return`data:${e};base64,${_A(t).toString("base64")}`},$A=t=>{const e=t.replace(/\r?\n/g,""),A=e.indexOf(",");if(-1===A||A<=4)throw new TypeError("malformed data: URI");const i=e.substring(5,A).split(";");let n=!1;for(let t=1;t<i.length;t++)"base64"===i[t]&&(n=!0);const a=n?"base64":"ascii",r=unescape(e.substring(A+1)),s=kA.from(r,a);return ti(s)},_A=t=>kA.from(t),ti=t=>{const e=new ArrayBuffer(t.byteLength),A=new Uint8Array(e);for(let e=0;e<t.length;++e)A[e]=t[e];return e},ei=t=>new Promise(((e,A)=>{const i=new FileReader;i.onload=function(t){const i=t.target;i&&i.result?e(i.result.toString()):A()},i.readAsDataURL(t)})),Ai=new Map;class ii{constructor(t){this.font=t,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(t){const e=this.glyphsFromText.get(t);if(e)return e;const A=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,A),A}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let A=0,i=0;return e.forEach((t=>{const e=t.getMetrics();A=Math.max(A,e.yMax),i=Math.min(i,e.yMin)})),A-i}getKerningValue(t,e){let A=this.kerningValues.get(t.name);A||(A=new Map,this.kerningValues.set(t.name,A));let i=A.get(e.name);return i||(i=this.font.getKerningValue(t,e),A.set(e.name,i)),i}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,A=0;return t.forEach((t=>{const i=t.getMetrics();e=Math.max(e,i.yMax),A=Math.min(A,i.yMin)})),e-A}}const ni=t=>"data:"===t.substring(0,5).toLowerCase().trim(),ai=async t=>{const e=ni(t)?ri(t):ri(await qA(t));return oi(e,{assetUrl:ni(t)?t:await qA(t),name:e.names.fullName.en}),await KA(e,t),e},ri=t=>{const e=$A(t),A=F(n).parse(e);return oi(A,{assetUrl:t,name:A.names.fullName.en}),A},si=t=>{const e=Ai.get(t.name);if(e)return e;throw new Error("Font metrics unavailable for font")},oi=(t,e)=>{const A=new ii(t);return Ai.set(e.name,A),A},ci=(t,e,A,i)=>Math.max(pi(t.join("\n"),A,i),e),li=(t,e,A,i,n,a)=>{const r=(a||Ii)*n.getApproximateHeight(),s=e.split("\n");try{const e=s.flatMap((e=>gi(e,t.width,i,n))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(i*r),fontSize:A,requiredWidth:ci(a,t.width,i,n)}}catch(a){const s=e.split("");return{lines:s,requiredHeight:s.length*(i*r),fontSize:A,requiredWidth:ci(s,t.width,i,n)}}},gi=(t,e,A,i)=>{const n=Bi(t,A,i);if(n<=e)return{lines:[t],width:n};if(!(t.indexOf(" ")>-1)){if(t.length<=1)throw new Error(`Character ${t} is wider than region`);const n=Math.floor(t.length/2),a=gi(t.slice(0,n),e,A,i),r=gi(t.slice(n),e,A,i);return{lines:[...a.lines,...r.lines],width:Math.max(a.width,r.width)}}const a=t.split(" "),r=[];let s=-1/0,o=0;for(;o<a.length;){const t=a[o];if(Bi(t,A,i)>e){const n=gi(t,e,A,i);r.push(...n.lines),s=Math.max(s,n.width),o++}else{const n=[t];s=Math.max(s,Bi(t,A,i));let c=o+1,l=!0;for(;c<a.length&&l;){const t=a[c],r=Bi(`${n.join(" ")} ${t}`,A,i);r<=e?(n.push(t),s=Math.max(s,r),c++):l=!1}r.push(n.join(" ")),o=c}}if(s<0)throw new Error(`No max width calculated for text: ${r}.`);return{lines:r,width:s}},hi=(t,e,A,i,n,a)=>{const r=(a??Ii)*e.getApproximateHeight(),s=1/A.unitsPerEm,o=i/Ei(t,s,e),c=n/(t.length*r*s);return Math.min(c,o)},di=(t,e,A,i)=>{const n=si(e.fontData),a=n.getFont(),r=e.fontSize/a.unitsPerEm;if(!A)return li(e,t,e.fontSize,r,n,i);let s;if(s=e.text?e.text.split("\n"):e.input?.split("\n")??[""],A.input===t&&e.width===A.width&&e.height===A.height&&e.lineHeight===A.lineHeight)return{lines:s,requiredHeight:e.height,requiredWidth:ci(s,e.width,r,n),fontSize:e.fontSize};const o=e.width!==A.width!=(e.height!==A.height);return e.lineHeight!==A.lineHeight||o||A.input!==t?li(e,t,e.fontSize,r,n,i):{lines:s,requiredHeight:e.height,requiredWidth:ci(s,e.width,r,n),fontSize:hi(s,n,a,e.width,e.height,i)}},ui=(t,e,A,i,n)=>{const a=si(e).getFont();let r={...t},s={...t},o=Ei(i,A/a.unitsPerEm,si(e));return o&&o<r.width&&(s.width=o,"left"===n?(s.left+=Math.sin(r.rotation*Math.PI/360)*(r.width-o),s.top+=Math.sin(r.rotation*Math.PI/180)*(o-r.width)/2):s.left+="right"===n?r.width-o:(r.width-o)/2,i&&fi(i,i).every((([t,e])=>t===e))&&(r=s)),r},wi=1,Bi=(t,e,A)=>{let i=0;const n=A.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(i+=t.advanceWidth),e<n.length-1){const a=A.getKerningValue(t,n[e+1]);i+=a}})),i*=e,i},pi=(t,e,A)=>{let i=0;const n=A.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(i=Math.max(i,t.advanceWidth)),e<n.length-1){const a=A.getKerningValue(t,n[e+1]);i=Math.max(i,a)}})),i*=e,i},Ei=(t,e,A)=>{let i=0;return t.forEach((t=>{i=Math.max(i,Bi(t,e,A))})),i},mi={stripControlCharacters:!0,vertical:!1,uppercase:!1},Ci=(t,e=mi)=>{const A={...mi,...e};let i=t||"";return A.stripControlCharacters&&(i=i.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),A.uppercase&&(i=i.toUpperCase()),A.vertical&&(i=i.split("").join("\n")),i},fi=(t,e)=>t.map(((t,A)=>[t,e[A]])),Qi=(t="center",e=!1)=>e?"center":t,yi=t=>"left"===t?"start":"right"===t?"end":"middle",Di=(t,e,A)=>t.fontData?{...t,...(()=>{if(t.algorithm===We.Traditional){const i=di(e,t,A,t.lineHeight);return{text:i.lines.join("\n"),height:i.requiredHeight,width:i.requiredWidth,fontSize:i.fontSize,input:e}}return{text:e}})()}:t,Ii=1.1;var xi={};He(xi,"colorDefinitionPrintValue",(()=>Mi)),He(xi,"spotColorDefinitionString",(()=>vi)),He(xi,"svgColorValueToDefinition",(()=>Si));const Mi=t=>{const e=vi(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},vi=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),A=e.lastIndexOf("/");return`icc-named-color(${e.slice(A+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},Si=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const A=e[1].match(/\(([^)]+)\)/gm);if(!A)throw new Error("Unhandled state of color value in SVG");const i=A[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:i[0],namedColor:i[1]}}},Fi=t=>{const e=(t.rotation||0)*Math.PI/180,i=Math.cos(e),n=-Math.sin(e),a=`text-path-${t.id}`,r=`text-fill-${t.id}`,s=t.x+(t.curved?0:t.width/2),o=t.y+(t.curved?0:t.height/2),c=(t.text||"").split("\n");return t.curved&&!t.paths?null:t.fontData?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("defs",{children:[t.textFillImage&&(0,A.jsx)("pattern",{id:r,patternUnits:"userSpaceOnUse",width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height,x:0,y:0,children:(0,A.jsx)("image",{href:t.textFillImage.src,xlinkHref:t.textFillImage.src,width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height})}),(0,A.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${t.fontData.name}';\n src: url('${t.fontData.assetUrl}') format('truetype');\n }\n `}}),t.curved&&t.paths?(0,A.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,A.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:`matrix(${i}, ${-n}, ${n}, ${i}, ${s}, ${o})`,children:(0,A.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${t.fontData.name}'`,fontSize:t.fontSize,fontStyle:"normal",fontWeight:"normal",fill:t.textFillImage?`url("#${r}")`:t._renderingConfiguration?.spotColors&&t.fillSpotColorDefinition?`${t.fill} ${vi(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,A.jsx)(Yi,{text:t.text||"",curvedPathId:a,align:t.align}):c.map(((e,i)=>(0,A.jsx)(bi,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:i,amountLines:c.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},i)))})})})]}):null},bi=t=>(0,A.jsx)("tspan",{textAnchor:yi(t.align),x:"left"===t.align?-t.textboxWidth/2:"right"===t.align?t.textboxWidth/2:0,y:`${(()=>{const e=t.fontSize*(void 0!==t.lineHeight?t.lineHeight:Ii),A=t.textboxHeight/2;if("top"===t.verticalAlign)return-A+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const i=t.amountLines-1-t.thisLineIdx;return A-t.fontSize/4-i*e}const i=(t.amountLines-1)/2;return(t.thisLineIdx-i)*e+t.fontSize/4})()}px`,children:t.text}),Yi=t=>{const e=`#${t.curvedPathId}`;return(0,A.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:yi(t.align),href:e,xlinkHref:e,children:t.text})};He({},"Illustration",(()=>Gi));var Pi={};He(Pi,"traverse",(()=>Ri)),He(Pi,"sanitizeSvgTree",(()=>ki)),He(Pi,"modifySVGWithElementProperties",(()=>Hi)),He(Pi,"generateSVGWithUnknownColors",(()=>Ui));const Ni=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Ri=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>Ri(t,e)))},ki=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const A=[];Ri(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,l.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{A.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),Ri(t,(t=>{A.forEach((e=>{e.selectors?.forEach((A=>{((t,e)=>{try{return t.matches(e)}catch(A){return t.classList.contains(e.substring(1))}})(t,A)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},Hi=(t,e,A,i,n)=>{const a=(t=>zA().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,A)=>{t.setAttribute("height",`${A}px`),t.setAttribute("width",`${e}px`)})(a,e,A),((t,e,A)=>{Ri(t,(t=>{const i=t.attributes.getNamedItem("fill");i&&"none"!==i.value&&t.classList.forEach((i=>{if(i.startsWith("spiff-fill")){const n=e[i];n&&t.setAttribute("fill",A?Mi(n):n.browserValue)}}));const n=t.attributes.getNamedItem("stroke");n&&"none"!==n.value&&t.classList.forEach((i=>{if(i.startsWith("spiff-stroke")){const n=e[i];n&&t.setAttribute("stroke",A?Mi(n):n.browserValue)}}))}))})(a,i,n),(t=>WA().serializeToString(t))(a)},Ui=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],A=e?.length>0?e[0]:"",i=zA().parseFromString(A,"image/svg+xml").firstElementChild;if(!i)throw new Error("Failed to read SVG.");ki(i);const n={};Ri(i,(t=>{Ni.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const A=Si(e.value),i=`spiff-fill-${A.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",A.browserValue),t.classList.add(i),n[i]=A}const A=t.attributes.getNamedItem("stroke");if(A&&"none"!==A.value){const e=Si(A.value),i=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(i),t.setAttribute("stroke",e.browserValue),n[i]=e}}));const a=WA().serializeToString(i);return{colors:n,svg:a}},Gi=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,A.jsx)(SA,{id:t.id,src:t.cachedObjectURL,x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation,preserveAspectRatio:"none",immutable:t.immutable,mask:t.stepName?void 0:t.mask});const e=t.rotation||0,i=uA(e),n=Math.cos(i),a=-Math.sin(i),r=`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${n}, ${-a}, ${a}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `;if(!t.svg)throw new Error(`Illustration element ${t.id} (stepName ${t.stepName}) lacked svg from src ${t.src} at render time.`);return(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:r,dangerouslySetInnerHTML:{__html:Hi(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class Ti{constructor(){this.id=Te(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(t){this.stateCallbacks.push(t)}unregisterStateCallback(t){this.stateCallbacks.filter((e=>e!==t))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((t=>t()))}apply(t,e){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.nextCommands=[],e||this.prevCommands.push(t)}undo(){if(!this.state)return;const t=this.prevCommands.pop();if(!t)return;const e=t.undo();t.varying?this.state={...this.state,variation:e}:this.state={...this.state,transaction:e},this.nextCommands.push(t),this.runStateCallbacks()}redo(){if(!this.state)return;const t=this.nextCommands.pop();t&&(this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.prevCommands.push(t))}flattenSequence(t,e){const A=this.prevCommands.filter((e=>e.sequenceId===t)).pop();A&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),A?.overrideOldState(e),this.prevCommands.push(A))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],A=this.state.variation?.layouts?.[t],i=e?.layout||A?.layout;if(!i)throw new Error(`No layout: ${t}`);const n=[...e?.elements||[],...A?.elements||[]];return this.getLayoutDataWithState(i,n)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(t)].map((t=>this.getLayoutById(t)))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:A=>Ji(t,e,A)}}initialize(t,e){if(e)return void(this.state={transaction:e});let A={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{A=new en(t).apply(A)})),this.runStateCallbacks(),this.state={transaction:A}}commandReducer(t,e){if(e.varying){const A={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(A)}}{const A=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(A)}}}}const Oi=t=>"image"===t.type?(0,A.jsx)(SA,{...t},t.id):"frame"===t.type?(0,A.jsx)(FA,{...t},t.id):"illustration"===t.type?(0,A.jsx)(Gi,{...t},t.id):"textbox"===t.type?(0,A.jsx)(Fi,{...t},t.id):null,Ji=(t,e,i)=>{const n=i.renderingConfiguration,a=n?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,A.jsx)(lA,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:i.width||t.width,height:i.height||t.height,viewBox:n?.region?{x:n.region.left,y:n.region.top,width:n.region.width,height:n.region.height}:{x:0,y:0,width:t.width,height:t.height},configuration:n,outlineArea:i.outlineArea,maxHeight:i.maxHeight,maxWidth:i.maxWidth,position:i.position,borderRadius:i.borderRadius,outlineColor:i.outlineColor})};function Li(t){return t.sort(((t,e)=>{const A=t.layer||0,i=e.layer||0;if(A<i)return-1;if(A>i)return 1;const n=t.layerIndex||0,a=e.layerIndex||0;return n<a?-1:n>a?1:0}))}class zi extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,zi.prototype)}}const ji=(t,e)=>Vi(t,e).elements.find((e=>e.id===t)),Vi=(t,e)=>{const A=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!A)throw new zi;return A},Ki=(t,e)=>{const A=Li([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:A,modificationID:Te()}},Wi=async(t,e)=>{const A=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],i=[...new Set(A)];for(let A=0;A<i.length;A++){const n=i[A],a=t.layouts[n],r=e?.layouts[n],s=a||r;await Promise.all(s.elements.map((async t=>{if("illustration"===t.type){const e=t;if(e.src&&!e.svg){const t=await VA(e.src),A=await Ui(t);e.svg=Hi(A.svg,e.width,e.height,e.colors)}}isNaN(t.x)&&(t.x=0),isNaN(t.y)&&(t.y=0),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),isNaN(t.rotation)&&(t.rotation=0)})))}};class Xi{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class qi extends Xi{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class Zi extends Xi{constructor(t,e,A){super(),this.id=t,this.x=e,this.y=A}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,x:this.x,y:this.y},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class $i extends Xi{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,rotation:this.angle},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class _i extends Xi{constructor(t,e,A){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(A)}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;let A={...e,width:this.width,height:this.height};if("frame"===e.type){const t=A;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=A,i=(t.algorithm&&t.algorithm!==We.Autosize?t.input:t.text)??"";A=Di(t,i,e)}const i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class tn extends Xi{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class en extends Xi{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Te()}}}}}class An extends Xi{constructor(t){super(),this.panelName=t}apply(t){this.oldState=t;const e=Object.values(t.layouts).map((t=>{const e=t.layout.panelId===this.panelName;return{...t,elements:e?[]:[...t.elements],modificationID:Te()}})),A={};return e.forEach((t=>{A[t.layout.id]=t})),{...t,layouts:A}}}class nn extends Xi{constructor(t,e){super(),this.element=t,this.layout=e}apply(t){this.oldState=t,t.layouts[this.layout.id]||(t.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const e=t.layouts[this.layout.id].elements;if(e.find((t=>t.id===this.element.id)))throw new Error(`Failed to apply new ${this.element.type} element because ID ${this.element.id} already taken`);if(this.element.productOverlay||0===e.length){const A=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,A)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:A,modificationID:Te()}}}}const A=e[e.length-1],i=A.productOverlay?A:null;let n;if(i&&e.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)n=[...e,this.element].sort(((t,e)=>void 0!==t.layerIndex&&void 0!==e.layerIndex?t.layerIndex-e.layerIndex:0));else{const t=this.assignIndex(this.element,e);this.element.layerIndex=void 0!==t?t:0,n=[...e,this.element]}return i&&n.push(i),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:n,modificationID:Te()}}}}assignIndex(t,e){if(0===e.length)return 0;const A=e.filter((e=>(e.layer||0)===(t.layer||0))).sort(((t,e)=>(t.layerIndex||0)-(e.layerIndex||0)))[e.length-1]?.layerIndex;return void 0!==A?A+1:0}}class an extends Xi{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const A=Object.values(t.layouts).map((t=>(t.elements.filter((t=>t.id!==this.id)).length!==t.elements.length&&(e=!0),{...t,elements:t.elements.filter((t=>t.id!==this.id)),modificationID:Te()})));e||console.log(`Failed to delete element ${this.id}`);const i={};return A.forEach((t=>{i[t.layout.id]=t})),{...t,layouts:i}}}class rn extends Xi{constructor(t,A){super(),this.el=F(e)(t),this.layout=A,this.el.id=Te(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new nn(this.el,this.layout).apply(t)}}class sn extends Xi{constructor(t,e,A){super(),this.id=t,this.color=e,this.textFillSpotColor=A}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class on extends Xi{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,textFillImage:this.imageFill},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class cn extends Xi{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,fontSize:this.size},i=Vi(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=Ki(Di(A,n),i);return{...t,layouts:{...t.layouts,[i.layout.id]:a}}}}class ln extends Xi{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,algorithm:this.algorithm},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class gn extends Xi{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,fontData:this.fontData},i=Vi(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=Ki(Di(A,n),i);return{...t,layouts:{...t.layouts,[i.layout.id]:a}}}}class hn extends Xi{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,align:this.align},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class dn extends Xi{constructor(t,e,A){super(),this.id=t,this.imageData=e,this.offsets=A}apply(t){this.oldState=t;const e=Vi(this.id,Object.values(t.layouts)),A=e.elements.findIndex((t=>t.id===this.id)),i=e.elements[A].pattern,n=[...e.elements];n.splice(A,1,{...e.elements[A],pattern:{...i,src:this.imageData.src,x:this.offsets.x,y:this.offsets.y,width:this.imageData.width,height:this.imageData.height,scaleX:this.offsets.zoom,scaleY:this.offsets.zoom}});const a={...e,elements:n,modificationID:Te()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class un extends Xi{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A=Vi(e.id,Object.values(t.layouts)),i=Ki(Di(e,this.text,e),A);return{...t,layouts:{...t.layouts,[A.layout.id]:i}}}}class wn extends Xi{constructor(t,e,A){super(),this.id=t,this.className=e,this.fill=A}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A=e.colors||{},i=A[this.className];A[this.className]={browserValue:this.fill,spotColor:i?.spotColor};const n={...e,colors:A},a=Vi(e.id,Object.values(t.layouts)),r=Ki(n,a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class Bn extends Xi{constructor(t,e,A){super(),this.id=t,this.svgBody=e,this.objectURL=A}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class pn extends Xi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!ji(this.id,Object.values(t.layouts)).id)throw new zi;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(A,1)[0]);const i=[...e.elements];return i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:i,modificationID:Te()}}}}}class En extends Xi{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");const i=A.elements.findIndex((t=>t.id===this.id));A.elements.splice(i,1),A.elements.unshift(e);const n=[...A.elements],a=n.splice(i,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[A.layout.id]:{...t.layouts[A.layout.id],elements:n,modificationID:Te()}}}}}class mn extends Xi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!ji(this.id,Object.values(t.layouts)).id)throw new zi;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id)),i=A+1,n=[...e.elements],a=n.splice(A,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class Cn extends Xi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!ji(this.id,Object.values(t.layouts)).id)throw new zi;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id)),i=A-1,n=[...e.elements],a=n.splice(A,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class fn extends Xi{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[A.layout.id]:Ki({...e,layer:this.value},A)}}}}var Qn={};He(Qn,"patternImageDataCache",(()=>Sn)),He(Qn,"frameDataCache",(()=>Fn)),He(Qn,"generateFrameSVG",(()=>bn)),He(Qn,"generateDefaultRectangleFrameSvg",(()=>Yn)),He(Qn,"getVariant",(()=>Pn)),He(Qn,"getFrameData",(()=>Nn)),He(Qn,"calculateOffsets",(()=>Rn)),He(Qn,"getPatternImageData",(()=>kn)),He(Qn,"GetSVGDimensions",(()=>Hn)),He(Qn,"svgStringDimensions",(()=>Un));var yn={};He(yn,"getExifOrientation",(()=>In)),He(yn,"canvasDims",(()=>xn)),He(yn,"getAttributesFromArrayBuffer",(()=>Mn));let Dn=null;const In=t=>new Promise((e=>{const A=_A(t);(0,o.fromBuffer)(t).then((t=>{const i=t?.mime;if("image/jpeg"!==i)return e(1);(new(0,h.ExifImage)).loadImage(A,((t,A)=>e(t?1:A.image.Orientation||1)))}))})),xn=t=>{const e=8192,A=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[A*e,e]:[e,e/A]},Mn=async t=>{const e=await(async t=>{const e=await ZA(t),A=await(0,g.loadImage)(e),[i,n]=xn(A),a=await(async()=>{if(null!==Dn)return!Dn;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Dn=2===t.width&&3===t.height,!Dn})();if(!a){const t=(0,g.createCanvas)(i,n);return t.getContext("2d").drawImage(A,0,0,i,n),t}const r=await In(t),[s,o]=r>4?[n,i]:[i,n],c=(0,g.createCanvas)(s,o),l=c.getContext("2d");switch(r){case 2:l.translate(s,0),l.scale(-1,1);break;case 3:l.translate(s,o),l.rotate(Math.PI);break;case 4:l.translate(0,o),l.scale(1,-1);break;case 5:l.rotate(-.5*Math.PI),l.scale(-1,1);break;case 6:l.rotate(-.5*Math.PI),l.translate(-s,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-s,o),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-o)}return l.drawImage(A,0,0,s,o),c})(t);return"image/jpeg"===(await(0,o.fromBuffer)(t))?.mime?{dataUrl:e.toDataURL("image/jpeg",1),height:e.height,width:e.width}:{dataUrl:e.toDataURL(),height:e.height,width:e.width}};He({},"getDefaultVariant",(()=>vn));const vn=t=>{const e=t.variants;if(e){if(1===e.length)return e[0];if(void 0!==t.defaultVariant)return e.find((e=>e.id===t.defaultVariant))}},Sn=new Map,Fn=new Map,bn=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return Yn(t)}return VA(e)},Yn=t=>{const e=t.width,A=e/t.height,i=Math.max(e,512),n=i/A;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${i} ${n}'>\n <path id="target-path" d='M0 0 h ${i} v ${n} h ${-i} Z' />\n </svg>\n `},Pn=(t,e)=>{if(!e)return;const A=e.variants?.find((e=>e.id===t.frameVariantId))||vn(e);if(!A)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!A.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return A},Nn=async t=>{const e=zA().parseFromString(t,"image/svg+xml"),A=e.querySelector("svg");if(!A)throw new Error("Malformed frame SVG: <svg> tag not found");const i=A.getAttribute("viewBox");if(!i)throw new Error("SVG missing viewBox.");const n=i.split(" "),a=parseFloat(n[3])||1,r=parseFloat(n[2])||1,s=e.getElementById("target-path"),o=e.getElementsByClassName("st0").item(0);if(s){const t=s.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:r,height:a};return Fn.set(t,e),e}if(o){const t=o.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:r,height:a};return Fn.set(t,e),e}throw new Error("Malformed frame SVG")},Rn=(t,e,A)=>{const i=e.width>=e.height,n=t.width>=t.height,a=e.width/2,r=e.height/2,s=(i?e.height:e.width)/(n?t.width:t.height),o=A?.scale||s,c=a-t.width/2*o,l=A?.left||c,g=r-t.height/2*o;return{x:l,y:A?.top||g,zoom:o}},kn=async t=>{if(Sn.has(t))return Sn.get(t);if(t.endsWith("svg")){const e=await Hn(t),A=e.width,i=e.height,n={src:t,width:A,height:i,aspect:A/i};return Sn.set(t,n),n}{const e=await jA(t),A=await Mn(e),i={src:t,width:A.width,height:A.height,aspect:A.width/A.height};return Sn.set(t,i),i}},Hn=async t=>{const e=await VA(t);return Un(e)},Un=t=>{const e=zA().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const A=e.getAttribute("viewBox"),i=e.getAttribute("width"),n=e.getAttribute("height"),a=A?A?.split(" ").map((t=>Number(t))):[0,0,Number(i),Number(n)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var Gn={};He(Gn,"determineCorrectFontSizeAndLines",(()=>On)),He(Gn,"determineCorrectTextboxRegion",(()=>Jn));const Tn=(t,e,A,i,n)=>{if(e.some((t=>null==t)))throw new Error(`Failed to autosize lines: ${e.join(", ")}`);let a=e.map((t=>t.split("\n"))).flat(),r=a.length,s=a.map((t=>Bi(t,i,n)));const o=n.getApproximateHeight()*i;let c=!0;for(;c;){if(o+(r-1)*A>t.height)return[null,null];const e=Math.max(...s);if(e<=t.width)return[a,e];const l=s.reduce(((t,e,A,i)=>e>i[t]?A:t),0),g=a[l];let h=!1,d=g.length;for(;!h&&d>-1;){d=g.lastIndexOf(" ",d-1);const e=[g.slice(0,d),g.slice(d+1)],A=e.map((t=>Bi(t,i,n)));A[0]<=t.width&&(a=[...a.slice(0,l),...e,...a.slice(l+1)],s=[...s.slice(0,l),...A,...s.slice(l+1)],r+=1,h=!0)}h||(c=!1)}return[null,null]},On=(t,e,A,i,n)=>{let a,r;const s=si(e),o=s.getFont();if(n.size){const e=t/o.unitsPerEm;return[a,r]=Tn(A,i,t,e,s),[n.size,a,r]}let c=6-wi;if(i.length>0){let t=i,e=0;for(;(!n.maxSize||c<=n.maxSize)&&t;)c+=wi,e=c/o.unitsPerEm,[t,r]=Tn(A,i,c,e,s)}c>6&&(c-=wi),n.minSize&&c<n.minSize&&(c=n.minSize);const l=c/o.unitsPerEm;return[a,r]=Tn(A,i,c,l,s),[c,a,r]},Jn=(t,e,A,i,n)=>{let a={...t},r={...t},[s,o,c]=On(A,e,r,i,{size:0,minSize:A,maxSize:A});var l,g;return c&&c<a.width&&(r.width=c,"left"===n?(r.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),r.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):r.left+="right"===n?a.width-c:(a.width-c)/2,[s,o]=On(A,e,r,i,{size:A}),s===A&&o&&(l=i,g=o,l.map(((t,e)=>[t,g[e]]))).every((([t,e])=>t===e))&&(a=r)),a};var Ln={};He(Ln,"svgObjectURL",(()=>Vn)),He(Ln,"LayoutElementFactory",(()=>Wn));const zn=(t,e)=>{const A=t.layoutState.elements.filter((t=>t.layer===e)),i=Math.max(...A.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(i,0)+1},jn=async t=>new Promise((e=>{VA(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),Vn=async t=>{const e=zA().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const A=(new XMLSerializer).serializeToString(e),i=document.createElement("canvas"),n=i.getContext("2d"),a=await ke.from(n,A,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),r=e.getAttribute("width"),s=e.getAttribute("height"),o=2048;if(s&&r){const t=parseFloat(s),e=parseFloat(r)/t;e>1?a.resize(o,o/e):a.resize(o*e,o)}else a.resize(o,o);return await a.render(),await(async t=>new Promise(((e,A)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((A=>{if(!A){if(0===t.width||0===t.height)throw new Error(`Canvas dimensions are invalid (${t.width},${t.height})`);if(t.width*t.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${t.width},${t.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}e(URL.createObjectURL(A))}))}catch(t){A(t)}})))(i)},Kn=async(t,e,A,i)=>{const n=t.layoutState.layout.useEditableArea&&t.layoutState.layout.editableArea||{width:t.layoutState.layout.width,height:t.layoutState.layout.height,x:0,y:0},a=n.width<n.height?n.width:n.height,r=t.layoutState.layout.useEditableArea?a/1.3:a/2,s={top:n.y+n.height/2-r/2,left:n.x+n.width/2-r/2,width:r,height:r,rotation:0,panelId:t.layoutState.layout.panelId};if(A&&e===ze.Illustration){const t=await Ui(await jn(A)),e=zA().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const i=s.height,n=e.split(" "),a=(parseFloat(n[2])||1)/(parseFloat(n[3])||1);s.height=s.width/a,s.top+=(i-s.height)/2}if(A&&e===ze.Image){const t=s.height,e=await jA(A),i=await Mn(e),n=i.width/i.height;s.height=s.width/n,s.top+=(t-s.height)/2}if(A&&e===ze.Textbox&&i?.text&&i?.fontScale){const t={assetUrl:A,name:(await ai(A)).names.fullName.en},e=si(t),a=Bi(i.text,i?.fontScale,e);s.width=Math.min(a,.85*n.width),s.left=n.x+n.width/2-s.width/2}return s};class Wn{static async getFrame(t,e){const A=await bn(e.region,e.src),i=await Nn(A),n=e.region||await Kn(t,ze.Frame);return{id:Te(),x:n.left,y:n.top,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||zn(t,n.layer||0),rotation:n.rotation,scaleX:n.width/i.width,scaleY:n.height/i.height,path:i.path,type:ze.Frame,disablePlaceholder:e.configuration.disablePlaceholder,focalBlur:e.configuration.focalBlur,focalBlurStrength:e.configuration.focalBlurStrength,focalBlurRadius:e.configuration.focalBlurRadius,forceImageCover:e.configuration.forceImageCover,pattern:void 0,immutable:n.immutable}}static async getImage(t,e){const A=e.region||await Kn(t,ze.Image,e.src);return{id:Te(),src:e.src,type:ze.Image,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||zn(t,A.layer||0),immutable:A.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:A,fontSrc:i,designInputStep:n}=e,a=await ai(i),r={assetUrl:i,name:a.names.fullName.en},s=n?.text||A.defaultText||"",o=A.replaceableText?A.replaceableText.replace("{{}}",s):s,c=Ci(o,{vertical:A.vertical,uppercase:A.uppercase}),l=e.region||await Kn(t,ze.Textbox,i,{text:c,fontScale:A.size?A.size/a.unitsPerEm:void 0}),g=Di({id:Te(),type:ze.Textbox,x:l.left,y:l.top,width:l.width,height:l.height,align:Qi(A.textAlign,A.vertical),curved:A.curved,fill:n?.color||A.colour||"#000000",fontData:r,layer:l.layer||0,layerIndex:l.layerIndex||zn(t,l.layer||0),paths:A.paths,rotation:l.rotation,vertical:A.vertical,verticalAlign:A.verticalAlign||"middle",algorithm:We.Traditional,fontSize:A.size||Math.max(Math.round(.025*l.height),1),text:c,input:s},c),h=ui({...l,height:g.height},r,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:h.left,y:h.top+(l.height-h.height)/2,width:h.width,height:h.height}}static async getShape(t,e){const A=`\n <svg\n xmlns="http://www.w3.org/2000/svg"\n xmlnsXlink="http://www.w3.org/1999/xlink"\n xmlSpace="preserve"\n preserveAspectRatio="none"\n version="1.1"\n width="1"\n height="1"\n viewBox="0 0 1 1"\n >\n <rect\n x="0"\n y="0"\n width="1"\n height="1"\n class="spiff-fill-shape"\n fill="${e.color}"\n />\n </svg>\n `,i={};i["spiff-fill-shape"]={browserValue:e.color};const n=e.region||await Kn(t,ze.Illustration),a=Te();return{stepRegion:e.region,colors:i,id:a,svg:A,type:ze.Illustration,y:n.top,x:n.left,rotation:n.rotation,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||zn(t,n.layer||0),immutable:n.immutable}}static async getIllustration(t,e){const A=e.region||await Kn(t,ze.Illustration,e.src),i=await Ui(await jn(e.src)),n=await Vn(i.svg),a=Te();return{cachedObjectURL:n,stepRegion:e.region,colors:i.colors,id:a,src:e.src,svg:i.svg,type:ze.Illustration,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||zn(t,A.layer||0),immutable:A.immutable}}}function Xn(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class qn extends Error{constructor(t){super(t),this.name=this.constructor.name}}class Zn extends qn{constructor(t){super(`ConfigurationError - ${t}`)}}class $n extends Zn{constructor(t){super(`Option not Configured: ${t.stepTitle}`),Xn(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class _n extends Zn{constructor(t){super(`Panel not Found: ${t.panelId}`),Xn(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class ta extends Zn{constructor(t){super(`Asset not found for variant: ${t.name}`),Xn(this,"variant",void 0),this.variant=t}}class ea extends Zn{constructor(t){super(`Resource not found for asset: ${t.name}`),Xn(this,"asset",void 0),this.asset=t}}class Aa extends Zn{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),Xn(this,"step",void 0),this.step=t}}class ia extends qn{constructor(t){super(`ImplementationError - ${t}`)}}class na extends ia{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class aa extends ia{constructor(t){super(`Parsing Error: ${t}`)}}class ra extends ia{constructor(t){super(`Client Error: ${t}`)}}class sa extends ia{constructor(t){super(`Resource Generation Failed: ${t}`)}}function oa(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ca{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}class la{constructor(){oa(this,"storage",new Map)}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}const ga=(()=>{try{return localStorage?new ca:new la}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new la}})();function ha(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const da=new class{constructor(){ha(this,"defaultServerUrl","https://api.spiff.com.au"),ha(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ha(this,"defaultHubUrl","https://hub.spiff.com.au"),ha(this,"serverUrl",void 0),ha(this,"servicesApiUrl",void 0),ha(this,"hubUrl",void 0),ha(this,"serverUrlCallbacks",void 0),this.serverUrl=this.defaultServerUrl,this.servicesApiUrl=this.defaultServicesApiUrl,this.hubUrl=this.defaultHubUrl,this.serverUrlCallbacks=[]}getServerUrl(){return this.serverUrl}getServicesApiUrl(){return this.servicesApiUrl}getHubUrl(){return this.hubUrl}setServerUrl(t){this.serverUrl=t,this.serverUrlCallbacks.forEach((t=>t()))}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}};function ua(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let wa;const Ba=t=>{wa=t};let pa;const Ea=t=>{pa=t};let ma;const Ca=t=>{ma=t};let fa;const Qa=new class{constructor(){ua(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),da.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${da.getServerUrl()}/graphql`,fetch:C.fetch}),A=(0,E.setContext)((async(t,{headers:e})=>{const A=e||{},i=await(async()=>{const t={applicationKey:fa,bundleOwnerId:pa,customerToken:ma,transactionOwnerId:wa};return"undefined"!=typeof window&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await new Promise((t=>{const e=da.getHubUrl(),A=i=>{i.origin===e&&(window.removeEventListener("message",A),t(i.data))};window.parent!==window&&(window.addEventListener("message",A,!1),window.parent.postMessage("ready",e))})),...t}:t})();return i.bearer&&(A.Authorization=`Bearer ${i.bearer}`),i.partnerId&&(A.partnerId=i.partnerId),i.activeIntegration&&(A.activeIntegration=i.activeIntegration),i.transactionOwnerId&&(A.transactionOwnerId=i.transactionOwnerId),i.customerToken&&(A.customerToken=i.customerToken),i.applicationKey&&(A["X-Application-Key"]=i.applicationKey),i.bundleOwnerId&&(A.bundleOwnerId=i.bundleOwnerId),{headers:A}})),i=(0,m.onError)((({operation:t,graphQLErrors:e,networkError:A})=>{(e||[]).forEach((({message:e,locations:A,path:i})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(A,null,2)}, Path: ${i}`),console.log("Variables:"+JSON.stringify(t.variables))})),A&&console.log("GraphQL Network error")}));const n=new(0,t.InMemoryCache)({addTypename:!1,typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(t=null)=>t,merge:(t,e)=>e||t||null},transactionOwnerId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},customLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowFooterLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowState:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkSourceUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lastSyncedAt:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lineItem:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},WorkflowProduct:{fields:{isPresent:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},Product:{fields:{imageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},overlayImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},preloadImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},weight:{read:(t=null)=>t,merge:(t,e)=>e||t||null},conversionConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}}}});return new(0,t.ApolloClient)({link:(0,t.from)([i,A,e]),cache:n,name:"Core"})}};function ya(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Da=t.gql`
1
+ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/jsx-runtime"),i=require("react"),n=require("opentype.js"),a=require("buffer"),r=require("axios"),s=require("https"),o=require("file-type"),c=require("util"),l=require("css"),g=require("canvas"),h=require("exif"),d=require("process"),u=require("raf"),w=require("rgbcolor"),B=require("svg-pathdata"),p=require("stackblur-canvas"),E=require("@apollo/client/link/context"),m=require("@apollo/client/link/error"),C=require("cross-fetch"),f=require("lodash.isequal"),Q=require("react-dom/server"),y=require("qrcode"),D=require("svg-path-bbox"),I=require("lodash.debounce"),x=require("unicode-default-word-boundary"),M=require("@apollo/client/core");function v(t,e,A,i){Object.defineProperty(t,e,{get:A,set:i,enumerable:!0,configurable:!0})}var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function F(t){return t&&t.__esModule?t.default:t}v(module.exports,"SpiffCommerceClient",(()=>Yc)),v(module.exports,"CommandContext",(()=>Ti)),v(module.exports,"spiffCoreConfiguration",(()=>da)),v(module.exports,"PromiseQueue",(()=>Or)),v(module.exports,"QueueablePromise",(()=>Tr)),v(module.exports,"MockWorkflowManager",(()=>Nc)),v(module.exports,"InformationMessageType",(()=>Bo)),v(module.exports,"StepHandle",(()=>yo)),v(module.exports,"TextStepHandle",(()=>No)),v(module.exports,"FrameStepHandle",(()=>Uc)),v(module.exports,"BulkStepHandle",(()=>Mo)),v(module.exports,"ShapeStepHandle",(()=>Po)),v(module.exports,"IllustrationStepHandle",(()=>vo)),v(module.exports,"MaterialStepHandle",(()=>So)),v(module.exports,"ModelStepHandle",(()=>Fo)),v(module.exports,"PictureStepHandle",(()=>bo)),v(module.exports,"QuestionStepHandle",(()=>Yo)),v(module.exports,"BulkPriceCalculationStrategy",(()=>Za)),v(module.exports,"Variant",(()=>fo)),v(module.exports,"OptionNotFoundError",(()=>$n)),v(module.exports,"LayoutNotFoundError",(()=>_n)),v(module.exports,"AssetNotFoundError",(()=>ta)),v(module.exports,"ResourceNotFoundError",(()=>ea)),v(module.exports,"MisconfigurationError",(()=>Aa)),v(module.exports,"ParseError",(()=>aa)),v(module.exports,"UnhandledBehaviorError",(()=>na)),v(module.exports,"assetService",(()=>Ya)),v(module.exports,"designService",(()=>zo)),v(module.exports,"createDesign",(()=>Oo)),v(module.exports,"optionService",(()=>ka)),v(module.exports,"persistenceService",(()=>ga)),v(module.exports,"graphQlManager",(()=>Qa)),v(module.exports,"toast",(()=>sr)),v(module.exports,"FrameService",(()=>Ks)),v(module.exports,"getBoundedOffsets",(()=>js)),v(module.exports,"frameStepService",(()=>eo)),v(module.exports,"modelStepService",(()=>no)),v(module.exports,"materialStepService",(()=>io)),v(module.exports,"shapeStepService",(()=>oo)),v(module.exports,"questionStepService",(()=>so)),v(module.exports,"digitalContentStepService",(()=>_s)),v(module.exports,"moduleStepService",(()=>ao)),v(module.exports,"pictureStepService",(()=>ro)),v(module.exports,"textStepService",(()=>uo)),v(module.exports,"illustrationStepService",(()=>Ao)),v(module.exports,"ProductCameraRig",(()=>Xa)),v(module.exports,"FrameStep",(()=>kc)),v(module.exports,"ConversionLocation",(()=>_a)),v(module.exports,"ConversionDataType",(()=>er)),v(module.exports,"getWorkflow",(()=>Fc)),v(module.exports,"shortenUrl",(()=>qs)),v(module.exports,"AssetType",(()=>nA)),v(module.exports,"BringForwardCommand",(()=>mn)),v(module.exports,"BringToFrontCommand",(()=>pn)),v(module.exports,"BringToBackCommand",(()=>En)),v(module.exports,"CanvasCommand",(()=>Xi)),v(module.exports,"CreateElementCommand",(()=>nn)),v(module.exports,"CreateLayoutCommand",(()=>en)),v(module.exports,"DeleteElementCommand",(()=>an)),v(module.exports,"FontAlignmentCommand",(()=>hn)),v(module.exports,"FontColorCommand",(()=>sn)),v(module.exports,"FontSizeCommand",(()=>cn)),v(module.exports,"FontSourceCommand",(()=>gn)),v(module.exports,"GroupCommand",(()=>tn)),v(module.exports,"LayoutElementFactory",(()=>Wn)),v(module.exports,"LayoutElementType",(()=>ze)),v(module.exports,"MoveCommand",(()=>Zi)),v(module.exports,"ResizeCommand",(()=>_i)),v(module.exports,"RotateCommand",(()=>$i)),v(module.exports,"SendBackwardsCommand",(()=>Cn)),v(module.exports,"StakeholderType",(()=>ir)),v(module.exports,"StepAspectType",(()=>oA)),v(module.exports,"StepType",(()=>rA)),v(module.exports,"TextChangeCommand",(()=>un)),v(module.exports,"UnitOfMeasurement",(()=>qe)),v(module.exports,"dataUrlFromExternalUrl",(()=>qA)),v(module.exports,"findElement",(()=>ji)),v(module.exports,"frameDataCache",(()=>Fn)),v(module.exports,"generate",(()=>Te)),v(module.exports,"getAxisAlignedBoundingBox",(()=>hA)),v(module.exports,"generateSVGWithUnknownColors",(()=>Ui)),v(module.exports,"getAttributesFromArrayBuffer",(()=>Mn)),v(module.exports,"rehydrateSerializedLayout",(()=>Wi)),v(module.exports,"getFrameData",(()=>Nn)),v(module.exports,"getSvgElement",(()=>Ji)),v(module.exports,"loadFontFromDataUrl",(()=>ri)),v(module.exports,"loadFontFromExternalUrl",(()=>ai)),v(module.exports,"determineCorrectFontSizeAndLines",(()=>On)),v(module.exports,"patternImageDataCache",(()=>Sn)),v(module.exports,"generateCommands",(()=>Es)),v(module.exports,"registerJSDOM",(()=>UA)),v(module.exports,"minZoom",(()=>Nr)),v(module.exports,"AdvancedEditor",(()=>vs)),v(module.exports,"TransformWrapper",(()=>Gc)),v(module.exports,"EditorCore",(()=>Ms)),v(module.exports,"useLayouts",(()=>Ga)),v(module.exports,"useEditorState",(()=>Wa)),v(module.exports,"useEditorInteraction",(()=>kr)),v(module.exports,"useShortcutCombination",(()=>Hr)),v(module.exports,"commandReducer",(()=>za)),v(module.exports,"getDefaultState",(()=>La)),v(module.exports,"CommandContextContext",(()=>Ha)),v(module.exports,"AdvancedEditorStateProvider",(()=>Va)),v(module.exports,"AdvancedEditorContext",(()=>ja)),v(module.exports,"UICommand",(()=>Ka)),v(module.exports,"EditorSubMenu",(()=>Oa)),v(module.exports,"ElementEventType",(()=>or)),v(module.exports,"KeyEvent",(()=>lr)),v(module.exports,"gatherVaryingStepAspects",(()=>Hs));function b(t){return t.replace(/(?!\u3000)\s+/gm," ")}function Y(t){const e=t.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return e?e.map(parseFloat):[]}const P=/^[A-Z-]+$/;function N(t){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t);return e&&(e[2]||e[3]||e[4])||""}const R=/(\[[^\]]+\])/g,k=/(#[^\s+>~.[:]+)/g,H=/(\.[^\s+>~.[:]+)/g,U=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,G=/(:[\w-]+\([^)]*\))/gi,T=/(:[^\s+>~.[:]+)/g,O=/([^\s+>~.[:]+)/g;function J(t,e){const A=e.exec(t);return A?[t.replace(e," "),A.length]:[t,0]}const L=1e-8;function z(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function j(t,e){return(t[0]*e[0]+t[1]*e[1])/(z(t)*z(e))}function V(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(j(t,e))}function K(t){return t*t*t}function W(t){return 3*t*t*(1-t)}function X(t){return 3*t*(1-t)*(1-t)}function q(t){return(1-t)*(1-t)*(1-t)}function Z(t){return t*t}function $(t){return 2*t*(1-t)}function _(t){return(1-t)*(1-t)}function tt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class et{static empty(t){return new et(t,"EMPTY","")}split(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:" ";const{document:e,name:A}=this;return b(this.getString()).trim().split(t).map((t=>new et(e,A,t)))}hasValue(t){const e=this.value;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){const{value:e}=this,A="string"==typeof e;return A&&t?t.test(e):A}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;const t=this.getString();switch(!0){case t.endsWith("px"):case/^[0-9]+$/.test(t):return!0;default:return!1}}setValue(t){return this.value=t,this}getValue(t){return void 0===t||this.hasValue()?this.value:t}getNumber(t){if(!this.hasValue())return void 0===t?0:parseFloat(t);const{value:e}=this;let A=parseFloat(e);return this.isString(/%$/)&&(A/=100),A}getString(t){return void 0===t||this.hasValue()?void 0===this.value?"":String(this.value):String(t)}getColor(t){let e=this.getString(t);return this.isNormalizedColor||(this.isNormalizedColor=!0,e=function(t){if(!t.startsWith("rgb"))return t;let e=3;return t.replace(/\d+(\.\d+)?/g,((t,A)=>e--&&A?String(Math.round(parseFloat(t))):t))}(e),this.value=e),e}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasValue())return 0;const[A,i]="boolean"==typeof t?[void 0,t]:[t],{viewPort:n}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(n.computeSize("x"),n.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(n.computeSize("x"),n.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*n.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*n.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return 15*this.getNumber();case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case this.isString(/%$/)&&i:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*n.computeSize(A);default:{const t=this.getNumber();return e&&t<1?t*n.computeSize(A):t}}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():1e3*this.getNumber():0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){const t=this.getString(),e=/#([^)'"]+)/.exec(t),A=(null==e?void 0:e[1])||t;return this.document.definitions[A]}getFillStyleDefinition(t,e){let A=this.getDefinition();if(!A)return null;if("function"==typeof A.createGradient&&"getBoundingBox"in t)return A.createGradient(this.document.ctx,t,e);if("function"==typeof A.createPattern){if(A.getHrefAttribute().hasValue()){const t=A.getAttribute("patternTransform");A=A.getHrefAttribute().getDefinition(),A&&t.hasValue()&&A.getAttribute("patternTransform",!0).setValue(t.value)}if(A)return A.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){if(!this.hasValue())return null;const t=this.getString();return et.textBaselineMapping[t]||null}addOpacity(t){let e=this.getColor();const A=e.length;let i=0;for(let t=0;t<A&&(","===e[t]&&i++,3!==i);t++);if(t.hasValue()&&this.isString()&&3!==i){const A=new(F(w))(e);A.ok&&(A.alpha=t.getNumber(),e=A.toRGBA())}return new et(this.document,this.name,e)}constructor(t,e,A){tt(this,"document",void 0),tt(this,"name",void 0),tt(this,"value",void 0),tt(this,"isNormalizedColor",void 0),this.document=t,this.name=e,this.value=A,this.isNormalizedColor=!1}}function At(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}tt(et,"textBaselineMapping",{baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"});class it{clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[t]=this.viewPorts;return t||nt()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||nt()}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(t){return"number"==typeof t?t:"x"===t?this.width:"y"===t?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}constructor(){At(this,"viewPorts",[])}}function nt(){return{width:it.DEFAULT_VIEWPORT_WIDTH,height:it.DEFAULT_VIEWPORT_HEIGHT}}function at(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}At(it,"DEFAULT_VIEWPORT_WIDTH",800),At(it,"DEFAULT_VIEWPORT_HEIGHT",600);class rt{static parse(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const[A=e,i=e]=Y(t);return new rt(A,i)}static parseScale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const[A=e,i=A]=Y(t);return new rt(A,i)}static parsePath(t){const e=Y(t),A=e.length,i=[];for(let t=0;t<A;t+=2)i.push(new rt(e[t],e[t+1]));return i}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:A}=this,i=e*t[0]+A*t[2]+t[4],n=e*t[1]+A*t[3]+t[5];this.x=i,this.y=n}constructor(t,e){at(this,"x",void 0),at(this,"y",void 0),this.x=t,this.y=e}}function st(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ot{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:A}=this,i=t.ctx.canvas;i.onclick=e,i.onmousemove=A,this.working=!0}stop(){if(!this.working)return;const t=this.screen.ctx.canvas;this.working=!1,t.onclick=null,t.onmousemove=null}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(!this.working)return;const{screen:t,events:e,eventElements:A}=this,{style:i}=t.ctx.canvas;let n;i&&(i.cursor=""),e.forEach(((t,e)=>{let{run:i}=t;for(n=A[e];n;)i(n),n=n.parent})),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:A,eventElements:i}=this;A.forEach(((A,n)=>{let{x:a,y:r}=A;!i[n]&&e.isPointInPath&&e.isPointInPath(a,r)&&(i[n]=t)}))}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:A,eventElements:i}=this;A.forEach(((A,n)=>{let{x:a,y:r}=A;!i[n]&&e.isPointInBox(a,r)&&(i[n]=t)}))}mapXY(t,e){const{window:A,ctx:i}=this.screen,n=new rt(t,e);let a=i.canvas;for(;a;)n.x-=a.offsetLeft,n.y-=a.offsetTop,a=a.offsetParent;return(null==A?void 0:A.scrollX)&&(n.x+=A.scrollX),(null==A?void 0:A.scrollY)&&(n.y+=A.scrollY),n}onClick(t){const{x:e,y:A}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:A,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){const{x:e,y:A}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:A,run(t){t.onMouseMove&&t.onMouseMove()}})}constructor(t){st(this,"screen",void 0),st(this,"working",void 0),st(this,"events",void 0),st(this,"eventElements",void 0),this.screen=t,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}}function ct(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const lt="undefined"!=typeof window?window:null,gt="undefined"!=typeof fetch?fetch.bind(void 0):void 0;class ht{wait(t){this.waits.push(t)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;const t=this.waits.every((t=>t()));return t&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=t,t}setDefaults(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4}setViewBox(t){let{document:e,ctx:A,aspectRatio:i,width:n,desiredWidth:a,height:r,desiredHeight:s,minX:o=0,minY:c=0,refX:l,refY:g,clip:h=!1,clipX:d=0,clipY:u=0}=t;const w=b(i).replace(/^defer\s/,""),[B,p]=w.split(" "),E=B||"xMidYMid",m=p||"meet",C=n/a,f=r/s,Q=Math.min(C,f),y=Math.max(C,f);let D=a,I=s;"meet"===m&&(D*=Q,I*=Q),"slice"===m&&(D*=y,I*=y);const x=new et(e,"refX",l),M=new et(e,"refY",g),v=x.hasValue()&&M.hasValue();if(v&&A.translate(-Q*x.getPixels("x"),-Q*M.getPixels("y")),h){const t=Q*d,e=Q*u;A.beginPath(),A.moveTo(t,e),A.lineTo(n,e),A.lineTo(n,r),A.lineTo(t,r),A.closePath(),A.clip()}if(!v){const t="meet"===m&&Q===f,e="slice"===m&&y===f,i="meet"===m&&Q===C,a="slice"===m&&y===C;E.startsWith("xMid")&&(t||e)&&A.translate(n/2-D/2,0),E.endsWith("YMid")&&(i||a)&&A.translate(0,r/2-I/2),E.startsWith("xMax")&&(t||e)&&A.translate(n-D,0),E.endsWith("YMax")&&(i||a)&&A.translate(0,r-I)}switch(!0){case"none"===E:A.scale(C,f);break;case"meet"===m:A.scale(Q,Q);break;case"slice"===m:A.scale(y,y)}A.translate(-o,-c)}start(t){let{enableRedraw:e=!1,ignoreMouse:A=!1,ignoreAnimation:i=!1,ignoreDimensions:n=!1,ignoreClear:a=!1,forceRedraw:r,scaleWidth:s,scaleHeight:o,offsetX:c,offsetY:l}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mouse:g}=this,h=1e3/ht.FRAMERATE;if(this.isReadyLock=!1,this.frameDuration=h,this.readyPromise=new Promise((t=>{this.resolveReady=t})),this.isReady()&&this.render(t,n,a,s,o,c,l),!e)return;let d=Date.now(),w=d,B=0;const p=()=>{d=Date.now(),B=d-w,B>=h&&(w=d-B%h,this.shouldUpdate(i,r)&&(this.render(t,n,a,s,o,c,l),g.runEvents())),this.intervalId=F(u)(p)};A||g.start(),this.intervalId=F(u)(p)}stop(){this.intervalId&&(F(u).cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){const{frameDuration:t}=this;if(this.animations.reduce(((e,A)=>A.update(t)||e),!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,A,i,n,a,r){const{viewPort:s,ctx:o,isFirstRender:c}=this,l=o.canvas;s.clear(),l.width&&l.height&&s.setCurrent(l.width,l.height);const g=t.getStyle("width"),h=t.getStyle("height");!e&&(c||"number"!=typeof i&&"number"!=typeof n)&&(g.hasValue()&&(l.width=g.getPixels("x"),l.style&&(l.style.width=`${l.width}px`)),h.hasValue()&&(l.height=h.getPixels("y"),l.style&&(l.style.height=`${l.height}px`)));let d=l.clientWidth||l.width,u=l.clientHeight||l.height;if(e&&g.hasValue()&&h.hasValue()&&(d=g.getPixels("x"),u=h.getPixels("y")),s.setCurrent(d,u),"number"==typeof a&&t.getAttribute("x",!0).setValue(a),"number"==typeof r&&t.getAttribute("y",!0).setValue(r),"number"==typeof i||"number"==typeof n){const e=Y(t.getAttribute("viewBox").getString());let A=0,a=0;if("number"==typeof i){const n=t.getStyle("width");n.hasValue()?A=n.getPixels("x")/i:e[2]&&!isNaN(e[2])&&(A=e[2]/i)}if("number"==typeof n){const A=t.getStyle("height");A.hasValue()?a=A.getPixels("y")/n:e[3]&&!isNaN(e[3])&&(a=e[3]/n)}A||(A=a),a||(a=A),t.getAttribute("width",!0).setValue(i),t.getAttribute("height",!0).setValue(n);const r=t.getStyle("transform",!0,!0);r.setValue(`${r.getString()} scale(${1/A}, ${1/a})`)}A||o.clearRect(0,0,d,u),t.render(o),c&&(this.isFirstRender=!1)}constructor(t,{fetch:e=gt,window:A=lt}={}){if(ct(this,"ctx",void 0),ct(this,"window",void 0),ct(this,"fetch",void 0),ct(this,"viewPort",void 0),ct(this,"mouse",void 0),ct(this,"animations",void 0),ct(this,"readyPromise",void 0),ct(this,"resolveReady",void 0),ct(this,"waits",void 0),ct(this,"frameDuration",void 0),ct(this,"isReadyLock",void 0),ct(this,"isFirstRender",void 0),ct(this,"intervalId",void 0),this.ctx=t,this.viewPort=new it,this.mouse=new ot(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=A,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}function dt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}ct(ht,"defaultWindow",lt),ct(ht,"defaultFetch",gt),ct(ht,"FRAMERATE",30),ct(ht,"MAX_VIRTUAL_PIXELS",3e4);const{defaultFetch:ut}=ht,wt="undefined"!=typeof DOMParser?DOMParser:void 0;class Bt{async parse(t){return t.startsWith("<")?this.parseFromString(t):this.load(t)}parseFromString(t){const e=new this.DOMParser;try{return this.checkDocument(e.parseFromString(t,"image/svg+xml"))}catch(A){return this.checkDocument(e.parseFromString(t,"text/xml"))}}checkDocument(t){const e=t.getElementsByTagName("parsererror")[0];if(e)throw new Error(e.textContent||"Unknown parse error");return t}async load(t){const e=await this.fetch(t),A=await e.text();return this.parseFromString(A)}constructor({fetch:t=ut,DOMParser:e=wt}={}){if(dt(this,"fetch",void 0),dt(this,"DOMParser",void 0),!t)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");if(!e)throw new Error("Can't find 'DOMParser' in 'globalThis', please provide it via options");this.fetch=t,this.DOMParser=e}}function pt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Et(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function mt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Ct(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ft{apply(t){const{originX:e,originY:A,matrix:i}=this,n=e.getPixels("x"),a=A.getPixels("y");t.translate(n,a),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),t.translate(-n,-a)}unapply(t){const{originX:e,originY:A,matrix:i}=this,n=i[0],a=i[2],r=i[4],s=i[1],o=i[3],c=i[5],l=1/(n*(1*o-0*c)-a*(1*s-0*c)+r*(0*s-0*o)),g=e.getPixels("x"),h=A.getPixels("y");t.translate(g,h),t.transform(l*(1*o-0*c),l*(0*c-1*s),l*(0*r-1*a),l*(1*n-0*r),l*(a*c-r*o),l*(r*s-n*c)),t.translate(-g,-h)}applyToPoint(t){t.applyTransform(this.matrix)}constructor(t,e,A){Ct(this,"type","matrix"),Ct(this,"matrix",void 0),Ct(this,"originX",void 0),Ct(this,"originY",void 0),this.matrix=function(t){const e=Y(t);return[e[0]||0,e[1]||0,e[2]||0,e[3]||0,e[4]||0,e[5]||0]}(e),this.originX=A[0],this.originY=A[1]}}function Qt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class yt extends ft{constructor(t,e,A){super(t,e,A),Qt(this,"type","skew"),Qt(this,"angle",void 0),this.angle=new et(t,"angle",e)}}function Dt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class It{static fromElement(t,e){const A=e.getStyle("transform",!1,!0);if(A.hasValue()){const[i,n=i]=e.getStyle("transform-origin",!1,!0).split();if(i&&n){const e=[i,n];return new It(t,A.getString(),e)}}return null}apply(t){this.transforms.forEach((e=>e.apply(t)))}unapply(t){this.transforms.forEach((e=>e.unapply(t)))}applyToPoint(t){this.transforms.forEach((e=>e.applyToPoint(t)))}constructor(t,e,A){Dt(this,"document",void 0),Dt(this,"transforms",void 0),this.document=t,this.transforms=[];const i=function(t){return b(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);i.forEach((t=>{if("none"===t)return;const[e,i]=function(t){const[e="",A=""]=t.split("(");return[e.trim(),A.trim().replace(")","")]}(t),n=It.transformTypes[e];n&&this.transforms.push(new n(this.document,i,A))}))}}function xt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}Dt(It,"transformTypes",{translate:class{apply(t){const{x:e,y:A}=this.point;t.translate(e||0,A||0)}unapply(t){const{x:e,y:A}=this.point;t.translate(-1*e||0,-1*A||0)}applyToPoint(t){const{x:e,y:A}=this.point;t.applyTransform([1,0,0,1,e||0,A||0])}constructor(t,e){pt(this,"type","translate"),pt(this,"point",void 0),this.point=rt.parse(e)}},rotate:class{apply(t){const{cx:e,cy:A,originX:i,originY:n,angle:a}=this,r=e+i.getPixels("x"),s=A+n.getPixels("y");t.translate(r,s),t.rotate(a.getRadians()),t.translate(-r,-s)}unapply(t){const{cx:e,cy:A,originX:i,originY:n,angle:a}=this,r=e+i.getPixels("x"),s=A+n.getPixels("y");t.translate(r,s),t.rotate(-1*a.getRadians()),t.translate(-r,-s)}applyToPoint(t){const{cx:e,cy:A,angle:i}=this,n=i.getRadians();t.applyTransform([1,0,0,1,e||0,A||0]),t.applyTransform([Math.cos(n),Math.sin(n),-Math.sin(n),Math.cos(n),0,0]),t.applyTransform([1,0,0,1,-e||0,-A||0])}constructor(t,e,A){Et(this,"type","rotate"),Et(this,"angle",void 0),Et(this,"originX",void 0),Et(this,"originY",void 0),Et(this,"cx",void 0),Et(this,"cy",void 0);const i=Y(e);this.angle=new et(t,"angle",i[0]),this.originX=A[0],this.originY=A[1],this.cx=i[1]||0,this.cy=i[2]||0}},scale:class{apply(t){const{scale:{x:e,y:A},originX:i,originY:n}=this,a=i.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(e,A||e),t.translate(-a,-r)}unapply(t){const{scale:{x:e,y:A},originX:i,originY:n}=this,a=i.getPixels("x"),r=n.getPixels("y");t.translate(a,r),t.scale(1/e,1/A||e),t.translate(-a,-r)}applyToPoint(t){const{x:e,y:A}=this.scale;t.applyTransform([e||0,0,0,A||0,0,0])}constructor(t,e,A){mt(this,"type","scale"),mt(this,"scale",void 0),mt(this,"originX",void 0),mt(this,"originY",void 0);const i=rt.parseScale(e);0!==i.x&&0!==i.y||(i.x=L,i.y=L),this.scale=i,this.originX=A[0],this.originY=A[1]}},matrix:ft,skewX:class extends yt{constructor(t,e,A){var i,n,a;super(t,e,A),a="skewX",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}},skewY:class extends yt{constructor(t,e,A){var i,n,a;super(t,e,A),a="skewY",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}});class Mt{getAttribute(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const A=this.attributes[t];if(!A&&e){const e=new et(this.document,t,"");return this.attributes[t]=e,e}return A||et.empty(this.document)}getHrefAttribute(){let t;for(const e in this.attributes)if("href"===e||e.endsWith(":href")){t=this.attributes[e];break}return t||et.empty(this.document)}getStyle(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=this.styles[t];if(i)return i;const n=this.getAttribute(t);if(n.hasValue())return this.styles[t]=n,n;if(!A){const{parent:e}=this;if(e){const A=e.getStyle(t);if(A.hasValue())return A}}if(e){const e=new et(this.document,t,"");return this.styles[t]=e,e}return et.empty(this.document)}render(t){if("none"!==this.getStyle("display").getString()&&"hidden"!==this.getStyle("visibility").getString()){if(t.save(),this.getStyle("mask").hasValue()){const e=this.getStyle("mask").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else if("none"!==this.getStyle("filter").getValue("none")){const e=this.getStyle("filter").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}}setContext(t){}applyEffects(t){const e=It.fromElement(this.document,this);e&&e.apply(t);const A=this.getStyle("clip-path",!1,!0);if(A.hasValue()){const e=A.getDefinition();e&&e.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach((e=>{e.render(t)}))}addChild(t){const e=t instanceof Mt?t:this.document.createElement(t);e.parent=this,Mt.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:A}=this;if(!A)return!1;if("function"==typeof A.matches)return A.matches(t);const i=null===(e=A.getAttribute)||void 0===e?void 0:e.call(A,"class");return!(!i||""===i)&&i.split(" ").some((e=>`.${e}`===t))}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let A;for(const i in t)if(!i.startsWith("@")&&this.matchesSelector(i)){const n=t[i],a=e[i];if(n)for(const t in n){let e=this.stylesSpecificity[t];void 0===e&&(e="000"),a&&a>=e&&(A=n[t],A&&(this.styles[t]=A),this.stylesSpecificity[t]=a)}}}removeStyles(t,e){return e.reduce(((e,A)=>{const i=t.getStyle(A);if(!i.hasValue())return e;const n=i.getString();return i.setValue(""),[...e,[A,n]]}),[])}restoreStyles(t,e){e.forEach((e=>{let[A,i]=e;t.getStyle(A,!0).setValue(i)}))}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}constructor(t,e,A=!1){if(xt(this,"document",void 0),xt(this,"node",void 0),xt(this,"captureTextNodes",void 0),xt(this,"type",void 0),xt(this,"attributes",void 0),xt(this,"styles",void 0),xt(this,"stylesSpecificity",void 0),xt(this,"animationFrozen",void 0),xt(this,"animationFrozenValue",void 0),xt(this,"parent",void 0),xt(this,"children",void 0),this.document=t,this.node=e,this.captureTextNodes=A,this.type="",this.attributes={},this.styles={},this.stylesSpecificity={},this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],!e||1!==e.nodeType)return;if(Array.from(e.attributes).forEach((e=>{const A=(i=e.nodeName,P.test(i)?i.toLowerCase():i);var i;this.attributes[A]=new et(t,A,e.value)})),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()){this.getAttribute("style").getString().split(";").map((t=>t.trim())).forEach((e=>{if(!e)return;const[A,i]=e.split(":").map((t=>t.trim()));A&&(this.styles[A]=new et(t,A,i))}))}const{definitions:i}=t,n=this.getAttribute("id");n.hasValue()&&(i[n.getString()]||(i[n.getString()]=this)),Array.from(e.childNodes).forEach((e=>{if(1===e.nodeType)this.addChild(e);else if(A&&(3===e.nodeType||4===e.nodeType)){const A=t.createTextNode(e);A.getText().length>0&&this.addChild(A)}}))}}xt(Mt,"ignoreChildTypes",["title"]);class vt extends Mt{constructor(t,e,A){super(t,e,A)}}function St(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Ft(t){const e=t.trim();return/^('|")/.test(e)?e:`"${e}"`}function bt(t){if(!t)return"";const e=t.trim().toLowerCase();switch(e){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return e;default:return/^oblique\s+(-|)\d+deg$/.test(e)?e:""}}function Yt(t){if(!t)return"";const e=t.trim().toLowerCase();switch(e){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return e;default:return/^[\d.]+$/.test(e)?e:""}}class Pt{static parse(){let t=arguments.length>1?arguments[1]:void 0,e="",A="",i="",n="",a="";const r=b(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").trim().split(" "),s={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return r.forEach((t=>{switch(!0){case!s.fontStyle&&Pt.styles.includes(t):"inherit"!==t&&(e=t),s.fontStyle=!0;break;case!s.fontVariant&&Pt.variants.includes(t):"inherit"!==t&&(A=t),s.fontStyle=!0,s.fontVariant=!0;break;case!s.fontWeight&&Pt.weights.includes(t):"inherit"!==t&&(i=t),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0;break;case!s.fontSize:"inherit"!==t&&(n=t.split("/")[0]||""),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0,s.fontSize=!0;break;default:"inherit"!==t&&(a+=t)}})),new Pt(e,A,i,n,a,t)}toString(){return[bt(this.fontStyle),this.fontVariant,Yt(this.fontWeight),this.fontSize,(t=this.fontFamily,void 0===d?t:t.trim().split(",").map(Ft).join(","))].join(" ").trim();var t}constructor(t,e,A,i,n,a){St(this,"fontFamily",void 0),St(this,"fontSize",void 0),St(this,"fontStyle",void 0),St(this,"fontWeight",void 0),St(this,"fontVariant",void 0);const r=a?"string"==typeof a?Pt.parse(a):a:{};this.fontFamily=n||r.fontFamily,this.fontSize=i||r.fontSize,this.fontStyle=t||r.fontStyle,this.fontWeight=A||r.fontWeight,this.fontVariant=e||r.fontVariant}}function Nt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}St(Pt,"styles","normal|italic|oblique|inherit"),St(Pt,"variants","normal|small-caps|inherit"),St(Pt,"weights","normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit");class Rt{get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(t,e){void 0!==t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),void 0!==e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))}addX(t){this.addPoint(t,0)}addY(t){this.addPoint(0,t)}addBoundingBox(t){if(!t)return;const{x1:e,y1:A,x2:i,y2:n}=t;this.addPoint(e,A),this.addPoint(i,n)}sumCubic(t,e,A,i,n){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*A+3*(1-t)*Math.pow(t,2)*i+Math.pow(t,3)*n}bezierCurveAdd(t,e,A,i,n){const a=6*e-12*A+6*i,r=-3*e+9*A-9*i+3*n,s=3*A-3*e;if(0===r){if(0===a)return;const r=-s/a;return void(0<r&&r<1&&(t?this.addX(this.sumCubic(r,e,A,i,n)):this.addY(this.sumCubic(r,e,A,i,n))))}const o=Math.pow(a,2)-4*s*r;if(o<0)return;const c=(-a+Math.sqrt(o))/(2*r);0<c&&c<1&&(t?this.addX(this.sumCubic(c,e,A,i,n)):this.addY(this.sumCubic(c,e,A,i,n)));const l=(-a-Math.sqrt(o))/(2*r);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,A,i,n)):this.addY(this.sumCubic(l,e,A,i,n)))}addBezierCurve(t,e,A,i,n,a,r,s){this.addPoint(t,e),this.addPoint(r,s),this.bezierCurveAdd(!0,t,A,n,r),this.bezierCurveAdd(!1,e,i,a,s)}addQuadraticCurve(t,e,A,i,n,a){const r=t+2/3*(A-t),s=e+2/3*(i-e),o=r+1/3*(n-t),c=s+1/3*(a-e);this.addBezierCurve(t,e,r,o,s,c,n,a)}isPointInBox(t,e){const{x1:A,y1:i,x2:n,y2:a}=this;return A<=t&&t<=n&&i<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,A=Number.NaN,i=Number.NaN){Nt(this,"x1",void 0),Nt(this,"y1",void 0),Nt(this,"x2",void 0),Nt(this,"y2",void 0),this.x1=t,this.y1=e,this.x2=A,this.y2=i,this.addPoint(t,e),this.addPoint(A,i)}}class kt extends Mt{calculateOpacity(){let t=1,e=this;for(;e;){const A=e.getStyle("opacity",!1,!0);A.hasValue(!0)&&(t*=A.getNumber()),e=e.parent}return t}setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e){const e=this.getStyle("fill"),A=this.getStyle("fill-opacity"),i=this.getStyle("stroke"),n=this.getStyle("stroke-opacity");if(e.isUrlDefinition()){const i=e.getFillStyleDefinition(this,A);i&&(t.fillStyle=i)}else if(e.hasValue()){"currentColor"===e.getString()&&e.setValue(this.getStyle("color").getColor());const A=e.getColor();"inherit"!==A&&(t.fillStyle="none"===A?"rgba(0,0,0,0)":A)}if(A.hasValue()){const e=new et(this.document,"fill",t.fillStyle).addOpacity(A).getColor();t.fillStyle=e}if(i.isUrlDefinition()){const e=i.getFillStyleDefinition(this,n);e&&(t.strokeStyle=e)}else if(i.hasValue()){"currentColor"===i.getString()&&i.setValue(this.getStyle("color").getColor());const e=i.getString();"inherit"!==e&&(t.strokeStyle="none"===e?"rgba(0,0,0,0)":e)}if(n.hasValue()){const e=new et(this.document,"stroke",t.strokeStyle).addOpacity(n).getString();t.strokeStyle=e}const a=this.getStyle("stroke-width");if(a.hasValue()){const e=a.getPixels();t.lineWidth=e||L}const r=this.getStyle("stroke-linecap"),s=this.getStyle("stroke-linejoin"),o=this.getStyle("stroke-miterlimit"),c=this.getStyle("stroke-dasharray"),l=this.getStyle("stroke-dashoffset");if(r.hasValue()&&(t.lineCap=r.getString()),s.hasValue()&&(t.lineJoin=s.getString()),o.hasValue()&&(t.miterLimit=o.getNumber()),c.hasValue()&&"none"!==c.getString()){const e=Y(c.getString());void 0!==t.setLineDash?t.setLineDash(e):void 0!==t.webkitLineDash?t.webkitLineDash=e:void 0===t.mozDash||1===e.length&&0===e[0]||(t.mozDash=e);const A=l.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=A:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=A:void 0!==t.mozDashOffset&&(t.mozDashOffset=A)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){const e=this.getStyle("font"),A=this.getStyle("font-style"),i=this.getStyle("font-variant"),n=this.getStyle("font-weight"),a=this.getStyle("font-size"),r=this.getStyle("font-family"),s=new Pt(A.getString(),i.getString(),n.getString(),a.hasValue()?`${a.getPixels(!0)}px`:"",r.getString(),Pt.parse(e.getString(),t.font));A.setValue(s.fontStyle),i.setValue(s.fontVariant),n.setValue(s.fontWeight),a.setValue(s.fontSize),r.setValue(s.fontFamily),t.font=s.toString(),a.isPixels()&&(this.document.emSize=a.getPixels(),this.modifiedEmSizeStack=!0)}e||(this.applyEffects(t),t.globalAlpha=this.calculateOpacity())}clearContext(t){super.clearContext(t),this.modifiedEmSizeStack&&this.document.popEmSize()}constructor(...t){var e,A,i;super(...t),i=!1,(A="modifiedEmSizeStack")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Ht(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ut extends kt{setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);const A=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();A&&(t.textBaseline=A)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(t){if("text"!==this.type)return this.getTElementBoundingBox(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t);let e=null;return this.children.forEach(((A,i)=>{const n=this.getChildBoundingBox(t,this,this,i);e?e.addBoundingBox(n):e=n})),e}getFontSize(){const{document:t,parent:e}=this,A=Pt.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(A)}getTElementBoundingBox(t){const e=this.getFontSize();return new Rt(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,A){const i=e[A];let n;if(t.isArabic){var a;const r=e.length,s=e[A-1],o=e[A+1];let c="isolated";(0===A||" "===s)&&A<r-1&&" "!==o&&(c="terminal"),A>0&&" "!==s&&A<r-1&&" "!==o&&(c="medial"),A>0&&" "!==s&&(A===r-1||" "===o)&&(c="initial"),n=(null===(a=t.arabicGlyphs[i])||void 0===a?void 0:a[c])||t.glyphs[i]}else n=t.glyphs[i];return n||(n=t.missingGlyph),n}getText(){return""}getTextFromNode(t){const e=t||this.node,A=Array.from(e.parentNode.childNodes),i=A.indexOf(e),n=A.length-1;let a=b(e.textContent||"");return 0===i&&(a=a.replace(/^[\n \t]+/,"")),i===n&&(a=function(t){return t.replace(/[\n \t]+$/,"")}(a)),a}renderChildren(t){if("text"!==this.type)return void this.renderTElementChildren(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t),this.children.forEach(((e,A)=>{this.renderChild(t,this,this,A)}));const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:A}=this,i=this.getText(),n=A.getStyle("font-family").getDefinition();if(null==n?void 0:n.fontFace){const{unitsPerEm:a}=n.fontFace,r=Pt.parse(e.ctx.font),s=A.getStyle("font-size").getNumber(r.fontSize),o=A.getStyle("font-style").getString(r.fontStyle),c=s/a,l=n.isRTL?i.split("").reverse().join(""):i,g=Y(A.getAttribute("dx").getString()),h=l.length;for(let e=0;e<h;e++){const A=this.getGlyph(n,l,e);t.translate(this.x,this.y),t.scale(c,-c);const i=t.lineWidth;t.lineWidth=t.lineWidth*a/s,"italic"===o&&t.transform(1,0,.4,1,0,0),A.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=i,t.scale(1/c,-1/c),t.translate(-this.x,-this.y),this.x+=s*(A.horizAdvX||n.horizAdvX)/a,void 0===g[e]||isNaN(g[e])||(this.x+=g[e])}return}const{x:a,y:r}=this;t.fillStyle&&t.fillText(i,a,r),t.strokeStyle&&t.strokeText(i,a,r)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start");let A=0;A="start"===e?t.x-this.minX:"end"===e?t.x-this.maxX:t.x-(this.minX+this.maxX)/2;for(let t=this.textChunkStart;t<this.leafTexts.length;t++)this.leafTexts[t].x+=A;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach(((e,A)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,A)})),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,A,i){const n=A.children[i];n.children.length>0?n.children.forEach(((A,i)=>{e.adjustChildCoordinatesRecursiveCore(t,e,n,i)})):this.adjustChildCoordinates(t,e,A,i)}adjustChildCoordinates(t,e,A,i){const n=A.children[i];if("function"!=typeof n.measureText)return n;t.save(),n.setContext(t,!0);const a=n.getAttribute("x"),r=n.getAttribute("y"),s=n.getAttribute("dx"),o=n.getAttribute("dy"),c=n.getStyle("font-family").getDefinition(),l=Boolean(null==c?void 0:c.isRTL);0===i&&(a.hasValue()||a.setValue(n.getInheritedAttribute("x")),r.hasValue()||r.setValue(n.getInheritedAttribute("y")),s.hasValue()||s.setValue(n.getInheritedAttribute("dx")),o.hasValue()||o.setValue(n.getInheritedAttribute("dy")));const g=n.measureText(t);return l&&(e.x-=g),a.hasValue()?(e.applyAnchoring(),n.x=a.getPixels("x"),s.hasValue()&&(n.x+=s.getPixels("x"))):(s.hasValue()&&(e.x+=s.getPixels("x")),n.x=e.x),e.x=n.x,l||(e.x+=g),r.hasValue()?(n.y=r.getPixels("y"),o.hasValue()&&(n.y+=o.getPixels("y"))):(o.hasValue()&&(e.y+=o.getPixels("y")),n.y=e.y),e.y=n.y,e.leafTexts.push(n),e.minX=Math.min(e.minX,n.x,n.x+g),e.maxX=Math.max(e.maxX,n.x,n.x+g),n.clearContext(t),t.restore(),n}getChildBoundingBox(t,e,A,i){const n=A.children[i];if("function"!=typeof n.getBoundingBox)return null;const a=n.getBoundingBox(t);return a&&n.children.forEach(((A,i)=>{const r=e.getChildBoundingBox(t,e,n,i);a.addBoundingBox(r)})),a}renderChild(t,e,A,i){const n=A.children[i];n.render(t),n.children.forEach(((A,i)=>{e.renderChild(t,e,n,i)}))}measureText(t){const{measureCache:e}=this;if(~e)return e;const A=this.getText(),i=this.measureTargetText(t,A);return this.measureCache=i,i}measureTargetText(t,e){if(!e.length)return 0;const{parent:A}=this,i=A.getStyle("font-family").getDefinition();if(i){const t=this.getFontSize(),n=i.isRTL?e.split("").reverse().join(""):e,a=Y(A.getAttribute("dx").getString()),r=n.length;let s=0;for(let e=0;e<r;e++){s+=(this.getGlyph(i,n,e).horizAdvX||i.horizAdvX)*t/i.fontFace.unitsPerEm,void 0===a[e]||isNaN(a[e])||(s+=a[e])}return s}if(!t.measureText)return 10*e.length;t.save(),this.setContext(t,!0);const{width:n}=t.measureText(e);return this.clearContext(t),t.restore(),n}getInheritedAttribute(t){let e=this;for(;e instanceof Ut&&e.isFirstChild()&&e.parent;){const A=e.parent.getAttribute(t);if(A.hasValue(!0))return A.getString("0");e=e.parent}return null}constructor(t,e,A){super(t,e,new.target===Ut||A),Ht(this,"type","text"),Ht(this,"x",0),Ht(this,"y",0),Ht(this,"leafTexts",[]),Ht(this,"textChunkStart",0),Ht(this,"minX",Number.POSITIVE_INFINITY),Ht(this,"maxX",Number.NEGATIVE_INFINITY),Ht(this,"measureCache",-1)}}function Gt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Tt extends Ut{getText(){return this.text}constructor(t,e,A){super(t,e,new.target===Tt||A),Gt(this,"type","tspan"),Gt(this,"text",void 0),this.text=this.children.length>0?"":this.getTextFromNode()}}class Ot extends Tt{constructor(...t){var e,A,i;super(...t),i="textNode",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Jt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Lt extends B.SVGPathData{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new rt(0,0),this.control=new rt(0,0),this.current=new rt(0,0),this.points=[],this.angles=[]}isEnd(){const{i:t,commands:e}=this;return t>=e.length-1}next(){const t=this.commands[++this.i];return this.previousCommand=this.command,this.command=t,t}getPoint(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"x",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y";const A=new rt(this.command[t],this.command[e]);return this.makeAbsolute(A)}getAsControlPoint(t,e){const A=this.getPoint(t,e);return this.control=A,A}getAsCurrentPoint(t,e){const A=this.getPoint(t,e);return this.current=A,A}getReflectedControlPoint(){const t=this.previousCommand.type;if(t!==B.SVGPathData.CURVE_TO&&t!==B.SVGPathData.SMOOTH_CURVE_TO&&t!==B.SVGPathData.QUAD_TO&&t!==B.SVGPathData.SMOOTH_QUAD_TO)return this.current;const{current:{x:e,y:A},control:{x:i,y:n}}=this;return new rt(2*e-i,2*A-n)}makeAbsolute(t){if(this.command.relative){const{x:e,y:A}=this.current;t.x+=e,t.y+=A}return t}addMarker(t,e,A){const{points:i,angles:n}=this;A&&n.length>0&&!n[n.length-1]&&(n[n.length-1]=i[i.length-1].angleTo(A)),this.addMarkerAngle(t,e?e.angleTo(t):null)}addMarkerAngle(t,e){this.points.push(t),this.angles.push(e)}getMarkerPoints(){return this.points}getMarkerAngles(){const{angles:t}=this,e=t.length;for(let A=0;A<e;A++)if(!t[A])for(let i=A+1;i<e;i++)if(t[i]){t[A]=t[i];break}return t}constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),Jt(this,"control",new rt(0,0)),Jt(this,"start",new rt(0,0)),Jt(this,"current",new rt(0,0)),Jt(this,"command",null),Jt(this,"commands",this.commands),Jt(this,"i",-1),Jt(this,"previousCommand",null),Jt(this,"points",[]),Jt(this,"angles",[])}}function zt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class jt extends kt{path(t){const{pathParser:e}=this,A=new Rt;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case Lt.MOVE_TO:this.pathM(t,A);break;case Lt.LINE_TO:this.pathL(t,A);break;case Lt.HORIZ_LINE_TO:this.pathH(t,A);break;case Lt.VERT_LINE_TO:this.pathV(t,A);break;case Lt.CURVE_TO:this.pathC(t,A);break;case Lt.SMOOTH_CURVE_TO:this.pathS(t,A);break;case Lt.QUAD_TO:this.pathQ(t,A);break;case Lt.SMOOTH_QUAD_TO:this.pathT(t,A);break;case Lt.ARC:this.pathA(t,A);break;case Lt.CLOSE_PATH:this.pathZ(t,A)}return A}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),A=t.getMarkerAngles();if(!e||!A)return null;return e.map(((t,e)=>[t,A[e]]))}renderChildren(t){this.path(t),this.document.screen.mouse.checkPath(this,t);const e=this.getStyle("fill-rule");""!==t.fillStyle&&("inherit"!==e.getString("inherit")?t.fill(e.getString()):t.fill()),""!==t.strokeStyle&&("non-scaling-stroke"===this.getAttribute("vector-effect").getString()?(t.save(),t.setTransform(1,0,0,1,0,0),t.stroke(),t.restore()):t.stroke());const A=this.getMarkers();if(A){const e=A.length-1,i=this.getStyle("marker-start"),n=this.getStyle("marker-mid"),a=this.getStyle("marker-end");if(i.isUrlDefinition()){const e=i.getDefinition(),[n,a]=A[0];e&&e.render(t,n,null===a?void 0:a)}if(n.isUrlDefinition()){const i=n.getDefinition();for(let n=1;n<e;n++){const[e,a]=A[n];i&&i.render(t,e,null===a?void 0:a)}}if(a.isUrlDefinition()){const i=a.getDefinition(),[n,r]=A[e];i&&i.render(t,n,null===r?void 0:r)}}}static pathM(t){const e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){const{pathParser:A}=this,{point:i}=jt.pathM(A),{x:n,y:a}=i;A.addMarker(i),e.addPoint(n,a),t&&t.moveTo(n,a)}static pathL(t){const{current:e}=t;return{current:e,point:t.getAsCurrentPoint()}}pathL(t,e){const{pathParser:A}=this,{current:i,point:n}=jt.pathL(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathH(t){const{current:e,command:A}=t,i=new rt(((null==A?void 0:A.relative)?e.x:0)+A.x,e.y);return t.current=i,{current:e,point:i}}pathH(t,e){const{pathParser:A}=this,{current:i,point:n}=jt.pathH(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathV(t){const{current:e,command:A}=t,i=new rt(e.x,(A.relative?e.y:0)+A.y);return t.current=i,{current:e,point:i}}pathV(t,e){const{pathParser:A}=this,{current:i,point:n}=jt.pathV(A),{x:a,y:r}=n;A.addMarker(n,i),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathC(t){const{current:e}=t;return{current:e,point:t.getPoint("x1","y1"),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathC(t,e){const{pathParser:A}=this,{current:i,point:n,controlPoint:a,currentPoint:r}=jt.pathC(A);A.addMarker(r,a,n),e.addBezierCurve(i.x,i.y,n.x,n.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(n.x,n.y,a.x,a.y,r.x,r.y)}static pathS(t){const{current:e}=t;return{current:e,point:t.getReflectedControlPoint(),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathS(t,e){const{pathParser:A}=this,{current:i,point:n,controlPoint:a,currentPoint:r}=jt.pathS(A);A.addMarker(r,a,n),e.addBezierCurve(i.x,i.y,n.x,n.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(n.x,n.y,a.x,a.y,r.x,r.y)}static pathQ(t){const{current:e}=t;return{current:e,controlPoint:t.getAsControlPoint("x1","y1"),currentPoint:t.getAsCurrentPoint()}}pathQ(t,e){const{pathParser:A}=this,{current:i,controlPoint:n,currentPoint:a}=jt.pathQ(A);A.addMarker(a,n,n),e.addQuadraticCurve(i.x,i.y,n.x,n.y,a.x,a.y),t&&t.quadraticCurveTo(n.x,n.y,a.x,a.y)}static pathT(t){const{current:e}=t,A=t.getReflectedControlPoint();t.control=A;return{current:e,controlPoint:A,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){const{pathParser:A}=this,{current:i,controlPoint:n,currentPoint:a}=jt.pathT(A);A.addMarker(a,n,n),e.addQuadraticCurve(i.x,i.y,n.x,n.y,a.x,a.y),t&&t.quadraticCurveTo(n.x,n.y,a.x,a.y)}static pathA(t){const{current:e,command:A}=t;let{rX:i,rY:n,xRot:a,lArcFlag:r,sweepFlag:s}=A;const o=a*(Math.PI/180),c=t.getAsCurrentPoint(),l=new rt(Math.cos(o)*(e.x-c.x)/2+Math.sin(o)*(e.y-c.y)/2,-Math.sin(o)*(e.x-c.x)/2+Math.cos(o)*(e.y-c.y)/2),g=Math.pow(l.x,2)/Math.pow(i,2)+Math.pow(l.y,2)/Math.pow(n,2);g>1&&(i*=Math.sqrt(g),n*=Math.sqrt(g));let h=(r===s?-1:1)*Math.sqrt((Math.pow(i,2)*Math.pow(n,2)-Math.pow(i,2)*Math.pow(l.y,2)-Math.pow(n,2)*Math.pow(l.x,2))/(Math.pow(i,2)*Math.pow(l.y,2)+Math.pow(n,2)*Math.pow(l.x,2)));isNaN(h)&&(h=0);const d=new rt(h*i*l.y/n,h*-n*l.x/i),u=new rt((e.x+c.x)/2+Math.cos(o)*d.x-Math.sin(o)*d.y,(e.y+c.y)/2+Math.sin(o)*d.x+Math.cos(o)*d.y),w=V([1,0],[(l.x-d.x)/i,(l.y-d.y)/n]),B=[(l.x-d.x)/i,(l.y-d.y)/n],p=[(-l.x-d.x)/i,(-l.y-d.y)/n];let E=V(B,p);return j(B,p)<=-1&&(E=Math.PI),j(B,p)>=1&&(E=0),{currentPoint:c,rX:i,rY:n,sweepFlag:s,xAxisRotation:o,centp:u,a1:w,ad:E}}pathA(t,e){const{pathParser:A}=this,{currentPoint:i,rX:n,rY:a,sweepFlag:r,xAxisRotation:s,centp:o,a1:c,ad:l}=jt.pathA(A),g=1-r?1:-1,h=c+g*(l/2),d=new rt(o.x+n*Math.cos(h),o.y+a*Math.sin(h));if(A.addMarkerAngle(d,h-g*Math.PI/2),A.addMarkerAngle(i,h-g*Math.PI),e.addPoint(i.x,i.y),t&&!isNaN(c)&&!isNaN(l)){const e=n>a?n:a,A=n>a?1:n/a,i=n>a?a/n:1;t.translate(o.x,o.y),t.rotate(s),t.scale(A,i),t.arc(0,0,e,c,c+l,Boolean(1-r)),t.scale(1/A,1/i),t.rotate(-s),t.translate(-o.x,-o.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){jt.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}constructor(t,e,A){super(t,e,A),zt(this,"type","path"),zt(this,"pathParser",void 0),this.pathParser=new Lt(this.getAttribute("d").getString())}}function Vt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Kt extends kt{setContext(t){var e;const{document:A}=this,{screen:i,window:n}=A,a=t.canvas;if(i.setDefaults(t),"style"in a&&void 0!==t.font&&n&&void 0!==n.getComputedStyle){t.font=n.getComputedStyle(a).getPropertyValue("font");const e=new et(A,"fontSize",Pt.parse(t.font).fontSize);e.hasValue()&&(A.rootEmSize=e.getPixels("y"),A.emSize=A.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);let{width:r,height:s}=i.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");const o=this.getAttribute("refX"),c=this.getAttribute("refY"),l=this.getAttribute("viewBox"),g=l.hasValue()?Y(l.getString()):null,h=!this.root&&"visible"!==this.getStyle("overflow").getValue("hidden");let d=0,u=0,w=0,B=0;g&&(d=g[0],u=g[1]),this.root||(r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y"),"marker"===this.type&&(w=d,B=u,d=0,u=0)),i.viewPort.setCurrent(r,s),!this.node||this.parent&&"foreignObject"!==(null===(e=this.node.parentNode)||void 0===e?void 0:e.nodeName)||!this.getStyle("transform",!1,!0).hasValue()||this.getStyle("transform-origin",!1,!0).hasValue()||this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(t),t.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),g&&(r=g[2],s=g[3]),A.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:i.viewPort.width,desiredWidth:r,height:i.viewPort.height,desiredHeight:s,minX:d,minY:u,refX:o.getValue(),refY:c.getValue(),clip:h,clipX:w,clipY:B}),g&&(i.viewPort.removeCurrent(),i.viewPort.setCurrent(r,s))}clearContext(t){super.clearContext(t),this.document.screen.viewPort.removeCurrent()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=this.getAttribute("width",!0),n=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),r=this.getAttribute("style"),s=i.getNumber(0),o=n.getNumber(0);if(A)if("string"==typeof A)this.getAttribute("preserveAspectRatio",!0).setValue(A);else{const t=this.getAttribute("preserveAspectRatio");t.hasValue()&&t.setValue(t.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(i.setValue(t),n.setValue(e),a.hasValue()||a.setValue(`0 0 ${s||t} ${o||e}`),r.hasValue()){const A=this.getStyle("width"),i=this.getStyle("height");A.hasValue()&&A.setValue(`${t}px`),i.hasValue()&&i.setValue(`${e}px`)}}constructor(...t){super(...t),Vt(this,"type","svg"),Vt(this,"root",!1)}}class Wt extends jt{path(t){const e=this.getAttribute("x").getPixels("x"),A=this.getAttribute("y").getPixels("y"),i=this.getStyle("width",!1,!0).getPixels("x"),n=this.getStyle("height",!1,!0).getPixels("y"),a=this.getAttribute("rx"),r=this.getAttribute("ry");let s=a.getPixels("x"),o=r.getPixels("y");if(a.hasValue()&&!r.hasValue()&&(o=s),r.hasValue()&&!a.hasValue()&&(s=o),s=Math.min(s,i/2),o=Math.min(o,n/2),t){const a=(Math.sqrt(2)-1)/3*4;t.beginPath(),n>0&&i>0&&(t.moveTo(e+s,A),t.lineTo(e+i-s,A),t.bezierCurveTo(e+i-s+a*s,A,e+i,A+o-a*o,e+i,A+o),t.lineTo(e+i,A+n-o),t.bezierCurveTo(e+i,A+n-o+a*o,e+i-s+a*s,A+n,e+i-s,A+n),t.lineTo(e+s,A+n),t.bezierCurveTo(e+s-a*s,A+n,e,A+n-o+a*o,e,A+n-o),t.lineTo(e,A+o),t.bezierCurveTo(e,A+o-a*o,e+s-a*s,A,e+s,A),t.closePath())}return new Rt(e,A,e+i,A+n)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="rect",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function Xt(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class qt extends jt{path(t){const{points:e}=this,[{x:A,y:i}]=e,n=new Rt(A,i);return t&&(t.beginPath(),t.moveTo(A,i)),e.forEach((e=>{let{x:A,y:i}=e;n.addPoint(A,i),t&&t.lineTo(A,i)})),n}getMarkers(){const{points:t}=this,e=t.length-1,A=[];return t.forEach(((i,n)=>{n!==e&&A.push([i,i.angleTo(t[n+1])])})),A.length>0&&A.push([t[t.length-1],A[A.length-1][1]]),A}constructor(t,e,A){super(t,e,A),Xt(this,"type","polyline"),Xt(this,"points",[]),this.points=rt.parsePath(this.getAttribute("points").getString())}}class Zt extends kt{getBoundingBox(t){const e=new Rt;return this.children.forEach((A=>{A instanceof jt&&e.addBoundingBox(A.getBoundingBox(t))})),e}constructor(...t){var e,A,i;super(...t),i="g",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}function $t(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class _t extends Mt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,A){let i=this;this.getHrefAttribute().hasValue()&&(i=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(i));const{stops:n}=i,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(A,n[n.length-1].color);if(n.forEach((t=>{a.addColorStop(t.offset,this.addParentOpacity(A,t.color))})),this.getAttribute("gradientTransform").hasValue()){const{document:t}=this,{MAX_VIRTUAL_PIXELS:e}=ht,{viewPort:A}=t.screen,i=A.getRoot(),n=new Wt(t);n.attributes.x=new et(t,"x",-e/3),n.attributes.y=new et(t,"y",-e/3),n.attributes.width=new et(t,"width",e),n.attributes.height=new et(t,"height",e);const r=new Zt(t);r.attributes.transform=new et(t,"transform",this.getAttribute("gradientTransform").getValue()),r.children=[n];const s=new Kt(t);s.attributes.x=new et(t,"x",0),s.attributes.y=new et(t,"y",0),s.attributes.width=new et(t,"width",i.width),s.attributes.height=new et(t,"height",i.height),s.children=[r];const o=t.createCanvas(i.width,i.height),c=o.getContext("2d");return c.fillStyle=a,s.render(c),c.createPattern(o,"no-repeat")}return a}inheritStopContainer(t){this.attributesToInherit.forEach((e=>{!this.getAttribute(e).hasValue()&&t.getAttribute(e).hasValue()&&this.getAttribute(e,!0).setValue(t.getAttribute(e).getValue())}))}addParentOpacity(t,e){if(t.hasValue()){return new et(this.document,"color",e).addOpacity(t).getColor()}return e}constructor(t,e,A){super(t,e,A),$t(this,"attributesToInherit",["gradientUnits"]),$t(this,"stops",[]);const{stops:i,children:n}=this;n.forEach((t=>{"stop"===t.type&&i.push(t)}))}}function te(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function ee(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ae extends Mt{getProperty(){var t;const e=this.getAttribute("attributeType").getString(),A=this.getAttribute("attributeName").getString();var i;return"CSS"===e?null===(i=this.parent)||void 0===i?void 0:i.getStyle(A,!0):null===(t=this.parent)||void 0===t?void 0:t.getAttribute(A,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:A,to:i}=this.getProgress();let n=A.getNumber()+(i.getNumber()-A.getNumber())*e;return"%"===t&&(n*=100),`${n}${t}`}update(t){const{parent:e}=this,A=this.getProperty();if(!A)return!1;if(this.initialValue||(this.initialValue=A.getString(),this.initialUnits=A.getUnits()),this.duration>this.maxDuration){const t=this.getAttribute("fill").getString("remove");if("indefinite"===this.getAttribute("repeatCount").getString()||"indefinite"===this.getAttribute("repeatDur").getString())this.duration=0;else if("freeze"!==t||this.frozen){if("remove"===t&&!this.removed)return this.removed=!0,e&&A&&A.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e&&A&&(e.animationFrozen=!0,e.animationFrozenValue=A.getString());return!1}this.duration+=t;let i=!1;if(this.begin<this.duration){let t=this.calcValue();const e=this.getAttribute("type");if(e.hasValue()){t=`${e.getString()}(${t})`}A.setValue(t),i=!0}return i}getProgress(){const{document:t,values:e}=this;let A,i,n=(this.duration-this.begin)/(this.maxDuration-this.begin);if(e.hasValue()){const a=n*(e.getValue().length-1),r=Math.floor(a),s=Math.ceil(a);let o;o=e.getValue()[r],A=new et(t,"from",o?parseFloat(o):0),o=e.getValue()[s],i=new et(t,"to",o?parseFloat(o):0),n=(a-r)/(s-r)}else A=this.from,i=this.to;return{progress:n,from:A,to:i}}constructor(t,e,A){super(t,e,A),ee(this,"type","animate"),ee(this,"begin",void 0),ee(this,"maxDuration",void 0),ee(this,"from",void 0),ee(this,"to",void 0),ee(this,"values",void 0),ee(this,"duration",0),ee(this,"initialValue",void 0),ee(this,"initialUnits",""),ee(this,"removed",!1),ee(this,"frozen",!1),t.screen.animations.push(this),this.begin=this.getAttribute("begin").getMilliseconds(),this.maxDuration=this.begin+this.getAttribute("dur").getMilliseconds(),this.from=this.getAttribute("from"),this.to=this.getAttribute("to"),this.values=new et(t,"values",null);const i=this.getAttribute("values");i.hasValue()&&this.values.setValue(i.getString().split(";"))}}function ie(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ne extends Mt{constructor(t,e,A){super(t,e,A),ie(this,"type","font-face"),ie(this,"ascent",void 0),ie(this,"descent",void 0),ie(this,"unitsPerEm",void 0),this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}function ae(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class re extends jt{constructor(t,e,A){super(t,e,A),ae(this,"type","glyph"),ae(this,"horizAdvX",void 0),ae(this,"unicode",void 0),ae(this,"arabicForm",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}function se(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class oe extends re{constructor(...t){super(...t),se(this,"type","missing-glyph"),se(this,"horizAdvX",0)}}function ce(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function le(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function ge(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function he(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const de=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;function ue(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class we{async load(t,e){try{const{document:A}=this,i=(await A.pith.parser.load(e)).getElementsByTagName("font");Array.from(i).forEach((e=>{const i=A.createElement(e);A.definitions[t]=i}))}catch(t){console.error(`Error while loading font "${e}":`,t)}this.loaded=!0}constructor(t){ue(this,"document",void 0),ue(this,"loaded",void 0),this.document=t,this.loaded=!1,t.fonts.push(this)}}function Be(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class pe extends Mt{constructor(t,e,A){super(t,e,A),Be(this,"type","style");b(Array.from(e.childNodes).map((t=>t.textContent)).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach((e=>{const A=e.trim();if(!A)return;const i=A.split("{"),n=i[0].split(","),a=i[1].split(";");n.forEach((e=>{const A=e.trim();if(!A)return;const i=t.styles[A]||{};if(a.forEach((e=>{const A=e.indexOf(":"),n=e.substr(0,A).trim(),a=e.substr(A+1,e.length-A).trim();n&&a&&(i[n]=new et(t,n,a))})),t.styles[A]=i,t.stylesSpecificity[A]=function(t){const e=[0,0,0];let A=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),i=0;return[A,i]=J(A,R),e[1]+=i,[A,i]=J(A,k),e[0]+=i,[A,i]=J(A,H),e[1]+=i,[A,i]=J(A,U),e[2]+=i,[A,i]=J(A,G),e[1]+=i,[A,i]=J(A,T),e[1]+=i,A=A.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[A,i]=J(A,O),e[2]+=i,e.join("")}(A),"@font-face"===A){const e=i["font-family"].getString().replace(/"|'/g,"");i.src.getString().split(",").forEach((A=>{if(A.indexOf('format("svg")')>0){const i=N(A);i&&new we(t).load(e,i)}}))}}))}))}}function Ee(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}Be(pe,"parseExternalUrl",N);function me(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}function Ce(t,e,A,i,n,a){return t[A*i*4+4*e+a]}function fe(t,e,A,i,n,a,r){t[A*i*4+4*e+a]=r}function Qe(t,e,A){return t[e]*A}function ye(t,e,A,i){return e+Math.cos(t)*A+Math.sin(t)*i}class De extends Mt{apply(t,e,A,i,n){const{includeOpacity:a,matrix:r}=this,s=t.getImageData(0,0,i,n);for(let t=0;t<n;t++)for(let e=0;e<i;e++){const A=Ce(s.data,e,t,i,0,0),n=Ce(s.data,e,t,i,0,1),o=Ce(s.data,e,t,i,0,2),c=Ce(s.data,e,t,i,0,3);let l=Qe(r,0,A)+Qe(r,1,n)+Qe(r,2,o)+Qe(r,3,c)+Qe(r,4,1),g=Qe(r,5,A)+Qe(r,6,n)+Qe(r,7,o)+Qe(r,8,c)+Qe(r,9,1),h=Qe(r,10,A)+Qe(r,11,n)+Qe(r,12,o)+Qe(r,13,c)+Qe(r,14,1),d=Qe(r,15,A)+Qe(r,16,n)+Qe(r,17,o)+Qe(r,18,c)+Qe(r,19,1);a&&(l=0,g=0,h=0,d*=c/255),fe(s.data,e,t,i,0,0,l),fe(s.data,e,t,i,0,1,g),fe(s.data,e,t,i,0,2,h),fe(s.data,e,t,i,0,3,d)}t.clearRect(0,0,i,n),t.putImageData(s,0,0)}constructor(t,e,A){super(t,e,A),me(this,"type","feColorMatrix"),me(this,"matrix",void 0),me(this,"includeOpacity",void 0);let i=Y(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const t=i[0];i=[.213+.787*t,.715-.715*t,.072-.072*t,0,0,.213-.213*t,.715+.285*t,.072-.072*t,0,0,.213-.213*t,.715-.715*t,.072+.928*t,0,0,0,0,0,1,0,0,0,0,0,1];break}case"hueRotate":{const t=i[0]*Math.PI/180;i=[ye(t,.213,.787,-.213),ye(t,.715,-.715,-.715),ye(t,.072,-.072,.928),0,0,ye(t,.213,-.213,.143),ye(t,.715,.285,.14),ye(t,.072,-.072,-.283),0,0,ye(t,.213,-.213,-.787),ye(t,.715,-.715,.715),ye(t,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break}case"luminanceToAlpha":i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.matrix=i,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}function Ie(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class xe extends Mt{apply(t,e){const{document:A}=this;let i=this.getAttribute("x").getPixels("x"),n=this.getAttribute("y").getPixels("y"),a=this.getStyle("width").getPixels("x"),r=this.getStyle("height").getPixels("y");if(!a&&!r){const e=new Rt;this.children.forEach((A=>{A instanceof jt&&e.addBoundingBox(A.getBoundingBox(t))})),i=Math.floor(e.x1),n=Math.floor(e.y1),a=Math.floor(e.width),r=Math.floor(e.height)}const s=this.removeStyles(e,xe.ignoreStyles),o=A.createCanvas(i+a,n+r),c=o.getContext("2d");A.screen.setDefaults(c),this.renderChildren(c),new De(A,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,i+a,n+r);const l=A.createCanvas(i+a,n+r),g=l.getContext("2d");A.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=c.createPattern(o,"no-repeat"),g.fillRect(0,0,i+a,n+r),t.fillStyle=g.createPattern(l,"no-repeat"),t.fillRect(0,0,i+a,n+r),this.restoreStyles(e,s)}render(t){}constructor(...t){super(...t),Ie(this,"type","mask")}}Ie(xe,"ignoreStyles",["mask","transform","clip-path"]);const Me=()=>{};function ve(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Se extends Mt{apply(t,e,A,i,n){const{document:a,blurRadius:r}=this,s=a.window?a.window.document.body:null,o=t.canvas;o.id=a.getUniqueId(),s&&(o.style.display="none",s.appendChild(o)),(0,p.canvasRGBA)(o,e,A,i,n,r),s&&s.removeChild(o)}constructor(t,e,A){super(t,e,A),ve(this,"type","feGaussianBlur"),ve(this,"extraFilterDistance",void 0),ve(this,"blurRadius",void 0),this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}function Fe(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class be extends Mt{apply(t,e){const{document:A,children:i}=this,n="getBoundingBox"in e?e.getBoundingBox(t):null;if(!n)return;let a=0,r=0;i.forEach((t=>{if(!(t instanceof Se))return;const e=t.extraFilterDistance||0;a=Math.max(a,e),r=Math.max(r,e)}));const s=Math.floor(n.width),o=Math.floor(n.height),c=s+2*a,l=o+2*r;if(Number.isNaN(c)||Number.isNaN(l)||c<1||l<1)return;const g=Math.floor(n.x),h=Math.floor(n.y),d=this.removeStyles(e,be.ignoreStyles),u=A.createCanvas(c,l),w=u.getContext("2d");A.screen.setDefaults(w),w.translate(-g+a,-h+r),e.render(w),i.forEach((t=>{t instanceof Se&&"function"==typeof t.apply&&t.apply(w,0,0,c,l)})),t.drawImage(u,0,0,c,l,g-a,h-r,c,l),this.restoreStyles(e,d)}render(t){}constructor(...t){super(...t),Fe(this,"type","filter")}}Fe(be,"ignoreStyles",["filter","transform","clip-path"]);const Ye={svg:Kt,rect:Wt,circle:class extends jt{path(t){const e=this.getAttribute("cx").getPixels("x"),A=this.getAttribute("cy").getPixels("y"),i=this.getAttribute("r").getPixels();return t&&i>0&&(t.beginPath(),t.arc(e,A,i,0,2*Math.PI,!1),t.closePath()),new Rt(e-i,A-i,e+i,A+i)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="circle",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},ellipse:class extends jt{path(t){const e=(Math.sqrt(2)-1)/3*4,A=this.getAttribute("rx").getPixels("x"),i=this.getAttribute("ry").getPixels("y"),n=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&A>0&&i>0&&(t.beginPath(),t.moveTo(n+A,a),t.bezierCurveTo(n+A,a+e*i,n+e*A,a+i,n,a+i),t.bezierCurveTo(n-e*A,a+i,n-A,a+e*i,n-A,a),t.bezierCurveTo(n-A,a-e*i,n-e*A,a-i,n,a-i),t.bezierCurveTo(n+e*A,a-i,n+A,a-e*i,n+A,a),t.closePath()),new Rt(n-A,a-i,n+A,a+i)}getMarkers(){return null}constructor(...t){var e,A,i;super(...t),i="ellipse",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},line:class extends jt{getPoints(){return[new rt(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new rt(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){const[{x:e,y:A},{x:i,y:n}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,A),t.lineTo(i,n)),new Rt(e,A,i,n)}getMarkers(){const[t,e]=this.getPoints(),A=t.angleTo(e);return[[t,A],[e,A]]}constructor(...t){var e,A,i;super(...t),i="line",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},polyline:qt,polygon:class extends qt{path(t){const e=super.path(t),[{x:A,y:i}]=this.points;return t&&(t.lineTo(A,i),t.closePath()),e}constructor(...t){var e,A,i;super(...t),i="polygon",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},path:jt,pattern:class extends Mt{createPattern(t,e,A){const i=this.getStyle("width").getPixels("x",!0),n=this.getStyle("height").getPixels("y",!0),a=this.getAttribute("data-frame-width"),r=this.getAttribute("data-frame-height"),s=a.hasValue()?a.getPixels("x",!0):i,o=r.hasValue()?r.getPixels("y",!0):n,c=a.hasValue()&&r.hasValue(),l=new Kt(this.document,void 0);l.attributes.viewBox=new et(this.document,"viewBox",this.getAttribute("viewBox").getValue()),l.attributes.width=new et(this.document,"width",`${s}px`),l.attributes.height=new et(this.document,"height",`${o}px`),l.attributes.transform=new et(this.document,"transform",this.getAttribute("patternTransform").getValue()),l.children=this.children;const g=this.document.createCanvas(s,o),h=g.getContext("2d");h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high";const d=this.getAttribute("x"),u=this.getAttribute("y");d.hasValue()&&u.hasValue()&&h.translate(d.getPixels("x",!0),u.getPixels("y",!0)),A.hasValue()?this.styles["fill-opacity"]=A:Reflect.deleteProperty(this.styles,"fill-opacity");for(let t=-1;t<=1;t++)for(let e=-1;e<=1;e++)h.save(),l.attributes.x=new et(this.document,"x",t*g.width),l.attributes.y=new et(this.document,"y",e*g.height),l.render(h),h.restore();return t.createPattern(g,c?"no-repeat":"repeat")}constructor(...t){var e,A,i;super(...t),i="pattern",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},marker:class extends Mt{render(t,e,A){if(!e)return;const{x:i,y:n}=e,a=this.getAttribute("orient").getString("auto"),r=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(i,n),"auto"===a&&A&&t.rotate(A),"strokeWidth"===r&&t.scale(t.lineWidth,t.lineWidth),t.save();const s=new Kt(this.document);s.type=this.type,s.attributes.viewBox=new et(this.document,"viewBox",this.getAttribute("viewBox").getValue()),s.attributes.refX=new et(this.document,"refX",this.getAttribute("refX").getValue()),s.attributes.refY=new et(this.document,"refY",this.getAttribute("refY").getValue()),s.attributes.width=new et(this.document,"width",this.getAttribute("markerWidth").getValue()),s.attributes.height=new et(this.document,"height",this.getAttribute("markerHeight").getValue()),s.attributes.overflow=new et(this.document,"overflow",this.getAttribute("overflow").getValue()),s.attributes.fill=new et(this.document,"fill",this.getAttribute("fill").getColor("black")),s.attributes.stroke=new et(this.document,"stroke",this.getAttribute("stroke").getValue("none")),s.children=this.children,s.render(t),t.restore(),"strokeWidth"===r&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"===a&&A&&t.rotate(-A),t.translate(-i,-n)}constructor(...t){var e,A,i;super(...t),i="marker",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},defs:class extends Mt{render(){}constructor(...t){var e,A,i;super(...t),i="defs",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},linearGradient:class extends _t{getGradient(t,e){const A="objectBoundingBox"===this.getGradientUnits(),i=A?e.getBoundingBox(t):null;if(A||!i)return null;this.getAttribute("x1").hasValue()||this.getAttribute("y1").hasValue()||this.getAttribute("x2").hasValue()||this.getAttribute("y2").hasValue()||(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));const n=A?i.x+i.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=A?i.y+i.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),r=A?i.x+i.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),s=A?i.y+i.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return n===r&&a===s?null:t.createLinearGradient(n,a,r,s)}constructor(t,e,A){var i,n,a;super(t,e,A),a="linearGradient",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.attributesToInherit.push("x1","y1","x2","y2")}},radialGradient:class extends _t{getGradient(t,e){const A="objectBoundingBox"===this.getGradientUnits(),i=e.getBoundingBox(t);if(A&&!i)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");const n=A?i.x+i.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=A?i.y+i.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let r=n,s=a;this.getAttribute("fx").hasValue()&&(r=A?i.x+i.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(s=A?i.y+i.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const o=A?(i.width+i.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),c=this.getAttribute("fr").getPixels();return t.createRadialGradient(r,s,c,n,a,o)}constructor(t,e,A){var i,n,a;super(t,e,A),a="radialGradient",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}},stop:class extends Mt{constructor(t,e,A){super(t,e,A),te(this,"type","stop"),te(this,"offset",void 0),te(this,"color",void 0);const i=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),n=this.getStyle("stop-opacity");let a=this.getStyle("stop-color",!0);""===a.getString()&&a.setValue("#000"),n.hasValue()&&(a=a.addOpacity(n)),this.offset=i,this.color=a.getColor()}},animate:Ae,animateColor:class extends Ae{calcValue(){const{progress:t,from:e,to:A}=this.getProgress(),i=new(F(w))(e.getColor()),n=new(F(w))(A.getColor());if(i.ok&&n.ok){const e=i.r+(n.r-i.r)*t,A=i.g+(n.g-i.g)*t,a=i.b+(n.b-i.b)*t;return`rgb(${Math.floor(e)}, ${Math.floor(A)}, ${Math.floor(a)})`}return this.getAttribute("from").getColor()}constructor(...t){var e,A,i;super(...t),i="animateColor",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},animateTransform:class extends Ae{calcValue(){const{progress:t,from:e,to:A}=this.getProgress(),i=Y(e.getString()),n=Y(A.getString()),a=i.map(((e,A)=>e+(n[A]-e)*t)).join(" ");return a}constructor(...t){var e,A,i;super(...t),i="animateTransform",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},font:class extends Mt{render(){}constructor(t,e,A){super(t,e,A),ce(this,"type","font"),ce(this,"isArabic",!1),ce(this,"missingGlyph",void 0),ce(this,"glyphs",{}),ce(this,"arabicGlyphs",{}),ce(this,"horizAdvX",void 0),ce(this,"isRTL",!1),ce(this,"fontFace",void 0),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:i}=t,{children:n}=this;for(const t of n)if(t instanceof ne){this.fontFace=t;const e=t.getStyle("font-family");e.hasValue()&&(i[e.getString()]=this)}else if(t instanceof oe)this.missingGlyph=t;else if(t instanceof re)if(t.arabicForm){this.isRTL=!0,this.isArabic=!0;const e=this.arabicGlyphs[t.unicode];void 0===e?this.arabicGlyphs[t.unicode]={[t.arabicForm]:t}:e[t.arabicForm]=t}else this.glyphs[t.unicode]=t}},"font-face":ne,"missing-glyph":oe,glyph:re,text:Ut,tspan:Tt,tref:class extends Ut{getText(){const t=this.getHrefAttribute().getDefinition();if(t){const e=t.children[0];if(e)return e.getText()}return""}constructor(...t){var e,A,i;super(...t),i="tref",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},a:class extends Ut{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:A,y:i}=this,{mouse:n}=e.screen,a=new et(e,"fontSize",Pt.parse(e.ctx.font).fontSize);n.isWorking()&&n.checkBoundingBox(this,new Rt(A,i-a.getPixels("y"),A+this.measureText(t),i))}else if(this.children.length>0){const e=new Zt(this.document);e.children=this.children,e.parent=this,e.render(t)}}onClick(){const{window:t}=this.document;t&&t.open(this.getHrefAttribute().getString())}onMouseMove(){this.document.ctx.canvas.style.cursor="pointer"}constructor(t,e,A){super(t,e,A),le(this,"type","a"),le(this,"hasText",void 0),le(this,"text",void 0);const{childNodes:i}=e,n=i[0],a=i.length>0&&Array.from(i).every((t=>3===t.nodeType));this.hasText=a,this.text=a?this.getTextFromNode(n):""}},textPath:class extends Ut{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach((e=>{let{type:A,points:i}=e;switch(A){case Lt.LINE_TO:t&&t.lineTo(i[0],i[1]);break;case Lt.MOVE_TO:t&&t.moveTo(i[0],i[1]);break;case Lt.CURVE_TO:t&&t.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]);break;case Lt.QUAD_TO:t&&t.quadraticCurveTo(i[0],i[1],i[2],i[3]);break;case Lt.ARC:{const[e,A,n,a,r,s,o,c]=i,l=n>a?n:a,g=n>a?1:n/a,h=n>a?a/n:1;t&&(t.translate(e,A),t.rotate(o),t.scale(g,h),t.arc(0,0,l,r,r+s,Boolean(1-c)),t.scale(1/g,1/h),t.rotate(-o),t.translate(-e,-A));break}case Lt.CLOSE_PATH:t&&t.closePath()}}))}renderChildren(t){var e;this.setTextData(t),t.save();const A=null===(e=this.parent)||void 0===e?void 0:e.getStyle("text-decoration").getString(),i=this.getFontSize(),{glyphInfo:n}=this,a=t.fillStyle;"underline"===A&&t.beginPath(),n.forEach(((e,n)=>{const{p0:a,p1:r,rotation:s,text:o}=e;t.save(),t.translate(a.x,a.y),t.rotate(s),t.fillStyle&&t.fillText(o,0,0),t.strokeStyle&&t.strokeText(o,0,0),t.restore(),"underline"===A&&(0===n&&t.moveTo(a.x,a.y+i/8),t.lineTo(r.x,r.y+i/5))})),"underline"===A&&(t.lineWidth=i/20,t.strokeStyle=a,t.stroke(),t.closePath()),t.restore()}getLetterSpacingAt(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.letterSpacingCache[t]||0}findSegmentToFitChar(t,e,A,i,n,a,r,s,o){let c=a,l=this.measureText(t,s);" "===s&&"justify"===e&&A<i&&(l+=(i-A)/n),o>-1&&(c+=this.getLetterSpacingAt(o));const g=this.textHeight/20,h=this.getEquidistantPointOnPath(c,g,0),d=this.getEquidistantPointOnPath(c+l,g,0),u={p0:h,p1:d},w=h&&d?Math.atan2(d.y-h.y,d.x-h.x):0;if(r){const t=Math.cos(Math.PI/2+w)*r,e=Math.cos(-w)*r;u.p0={...h,distance:h.distance||0,x:h.x+t,y:h.y+e},u.p1={...d,distance:d.distance||0,x:d.x+t,y:d.y+e}}return c+=l,{offset:c,segment:u,rotation:w}}measureText(t,e){const{measuresCache:A}=this,i=e||this.getText();if(A.has(i))return A.get(i);const n=this.measureTargetText(t,i);return A.set(i,n),n}setTextData(t){var e,A,i;if(this.glyphInfo)return;const n=this.getText(),a=n.split(""),r=n.split(" ").length-1,s=null===(e=this.parent)||void 0===e?void 0:e.getAttribute("dx").split().map((t=>t.getPixels("x"))),o=null===(A=this.parent)||void 0===A?void 0:A.getAttribute("dy").getPixels("y"),c=this.getAttribute("text-anchor").getString("start"),l=this.getStyle("letter-spacing"),g=null===(i=this.parent)||void 0===i?void 0:i.getStyle("letter-spacing");let h=0;l.hasValue()&&"inherit"!==l.getValue()?l.hasValue()&&"initial"!==l.getValue()&&"unset"!==l.getValue()&&(h=l.getPixels()):h=g.getPixels();const d=[],u=n.length;this.letterSpacingCache=d;for(let t=0;t<u;t++)d.push(void 0!==s[t]?s[t]:h);const w=d.reduce(((t,e,A)=>0===A?0:t+e||0),0),B=this.measureText(t),p=Math.max(B+w,0);this.textWidth=B,this.textHeight=this.getFontSize(),this.glyphInfo=[];const E=this.getPathLength(),m=this.getAttribute("startOffset").getNumber(0)*E;let C=0;"middle"!==c&&"center"!==c||(C=-p/2),"end"!==c&&"right"!==c||(C=-p),C+=m,a.forEach(((e,A)=>{const{offset:i,segment:n,rotation:s}=this.findSegmentToFitChar(t,c,p,E,r,C,o,e,A);C=i,n.p0&&n.p1&&this.glyphInfo.push({text:a[A],p0:n.p0,p1:n.p1,rotation:s})}))}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:A}=t;for(A.reset();!A.isEnd();){const{current:t}=A,i=t?t.x:0,n=t?t.y:0,a=A.next();let r=a.type,s=[];switch(a.type){case Lt.MOVE_TO:this.pathM(A,s);break;case Lt.LINE_TO:r=this.pathL(A,s);break;case Lt.HORIZ_LINE_TO:r=this.pathH(A,s);break;case Lt.VERT_LINE_TO:r=this.pathV(A,s);break;case Lt.CURVE_TO:this.pathC(A,s);break;case Lt.SMOOTH_CURVE_TO:r=this.pathS(A,s);break;case Lt.QUAD_TO:this.pathQ(A,s);break;case Lt.SMOOTH_QUAD_TO:r=this.pathT(A,s);break;case Lt.ARC:s=this.pathA(A);break;case Lt.CLOSE_PATH:jt.pathZ(A)}a.type!==Lt.CLOSE_PATH?e.push({type:r,points:s,start:{x:i,y:n},pathLength:this.calcLength(i,n,r,s)}):e.push({type:Lt.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:A,y:i}=jt.pathM(t).point;e.push(A,i)}pathL(t,e){const{x:A,y:i}=jt.pathL(t).point;return e.push(A,i),Lt.LINE_TO}pathH(t,e){const{x:A,y:i}=jt.pathH(t).point;return e.push(A,i),Lt.LINE_TO}pathV(t,e){const{x:A,y:i}=jt.pathV(t).point;return e.push(A,i),Lt.LINE_TO}pathC(t,e){const{point:A,controlPoint:i,currentPoint:n}=jt.pathC(t);e.push(A.x,A.y,i.x,i.y,n.x,n.y)}pathS(t,e){const{point:A,controlPoint:i,currentPoint:n}=jt.pathS(t);return e.push(A.x,A.y,i.x,i.y,n.x,n.y),Lt.CURVE_TO}pathQ(t,e){const{controlPoint:A,currentPoint:i}=jt.pathQ(t);e.push(A.x,A.y,i.x,i.y)}pathT(t,e){const{controlPoint:A,currentPoint:i}=jt.pathT(t);return e.push(A.x,A.y,i.x,i.y),Lt.QUAD_TO}pathA(t){let{rX:e,rY:A,sweepFlag:i,xAxisRotation:n,centp:a,a1:r,ad:s}=jt.pathA(t);return 0===i&&s>0&&(s-=2*Math.PI),1===i&&s<0&&(s+=2*Math.PI),[a.x,a.y,e,A,r,s,n,i]}calcLength(t,e,A,i){let n=0,a=null,r=null,s=0;switch(A){case Lt.LINE_TO:return this.getLineLength(t,e,i[0],i[1]);case Lt.CURVE_TO:for(n=0,a=this.getPointOnCubicBezier(0,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),s=.01;s<=1;s+=.01)r=this.getPointOnCubicBezier(s,t,e,i[0],i[1],i[2],i[3],i[4],i[5]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Lt.QUAD_TO:for(n=0,a=this.getPointOnQuadraticBezier(0,t,e,i[0],i[1],i[2],i[3]),s=.01;s<=1;s+=.01)r=this.getPointOnQuadraticBezier(s,t,e,i[0],i[1],i[2],i[3]),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return n;case Lt.ARC:{n=0;const t=i[4],e=i[5],A=i[4]+e;let o=Math.PI/180;if(Math.abs(t-A)<o&&(o=Math.abs(t-A)),a=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],t,0),e<0)for(s=t-o;s>A;s-=o)r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;else for(s=t+o;s<A;s+=o)r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],s,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return r=this.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],A,0),n+=this.getLineLength(a.x,a.y,r.x,r.y),n}}return 0}getPointOnLine(t,e,A,i,n){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:A;const s=(n-A)/(i-e+L);let o=Math.sqrt(t*t/(1+s*s));i<e&&(o*=-1);let c=s*o,l=null;if(i===e)l={x:a,y:r+c};else if((r-A)/(a-e+L)===s)l={x:a+o,y:r+c};else{let g=0,h=0;const d=this.getLineLength(e,A,i,n);if(d<L)return null;let u=(a-e)*(i-e)+(r-A)*(n-A);u/=d*d,g=e+u*(i-e),h=A+u*(n-A);const w=this.getLineLength(a,r,g,h),B=Math.sqrt(t*t-w*w);o=Math.sqrt(B*B/(1+s*s)),i<e&&(o*=-1),c=s*o,l={x:g+o,y:h+c}}return l}getPointOnPath(t){const e=this.getPathLength();let A=0,i=null;if(t<-5e-5||t-5e-5>e)return null;const{dataArray:n}=this;for(const e of n){if(e&&(e.pathLength<5e-5||A+e.pathLength+5e-5<t)){A+=e.pathLength;continue}const n=t-A;let a=0;switch(e.type){case Lt.LINE_TO:i=this.getPointOnLine(n,e.start.x,e.start.y,e.points[0],e.points[1],e.start.x,e.start.y);break;case Lt.ARC:{const t=e.points[4],A=e.points[5],r=e.points[4]+A;if(a=t+n/e.pathLength*A,A<0&&a<r||A>=0&&a>r)break;i=this.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],a,e.points[6]);break}case Lt.CURVE_TO:a=n/e.pathLength,a>1&&(a=1),i=this.getPointOnCubicBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);break;case Lt.QUAD_TO:a=n/e.pathLength,a>1&&(a=1),i=this.getPointOnQuadraticBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}if(i)return i;break}return null}getLineLength(t,e,A,i){return Math.sqrt((A-t)*(A-t)+(i-e)*(i-e))}getPathLength(){return-1===this.pathLength&&(this.pathLength=this.dataArray.reduce(((t,e)=>e.pathLength>0?t+e.pathLength:t),0)),this.pathLength}getPointOnCubicBezier(t,e,A,i,n,a,r,s,o){return{x:s*K(t)+a*W(t)+i*X(t)+e*q(t),y:o*K(t)+r*W(t)+n*X(t)+A*q(t)}}getPointOnQuadraticBezier(t,e,A,i,n,a,r){return{x:a*Z(t)+i*$(t)+e*_(t),y:r*Z(t)+n*$(t)+A*_(t)}}getPointOnEllipticalArc(t,e,A,i,n,a){const r=Math.cos(a),s=Math.sin(a),o=A*Math.cos(n),c=i*Math.sin(n);return{x:t+(o*r-c*s),y:e+(o*s+c*r)}}buildEquidistantCache(t,e){const A=this.getPathLength(),i=e||.25,n=t||A/100;if(!this.equidistantCache||this.equidistantCache.step!==n||this.equidistantCache.precision!==i){this.equidistantCache={step:n,precision:i,points:[]};let t=0;for(let e=0;e<=A;e+=i){const A=this.getPointOnPath(e),a=this.getPointOnPath(e+i);A&&a&&(t+=this.getLineLength(A.x,A.y,a.x,a.y),t>=n&&(this.equidistantCache.points.push({x:A.x,y:A.y,distance:e}),t-=n))}}}getEquidistantPointOnPath(t,e,A){if(this.buildEquidistantCache(e,A),t<0||t-this.getPathLength()>5e-5)return null;const i=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[i]||null}constructor(t,e,A){super(t,e,A),ge(this,"type","textPath"),ge(this,"textWidth",0),ge(this,"textHeight",0),ge(this,"pathLength",-1),ge(this,"glyphInfo",null),ge(this,"text",void 0),ge(this,"dataArray",void 0),ge(this,"letterSpacingCache",[]),ge(this,"equidistantCache",null),ge(this,"measuresCache",new Map([["",0]]));const i=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(i)}},image:class extends kt{async loadImage(t){try{const e=await this.document.createImage(t);this.image=e}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}async loadSvg(t){const e=de.exec(t);if(e){const t=e[5];t&&("base64"===e[4]?this.image=atob(t):this.image=decodeURIComponent(t))}else try{const e=await this.document.fetch(t),A=await e.text();this.image=A}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}renderChildren(t){const{document:e,image:A,loaded:i}=this,n=this.getAttribute("x").getPixels("x"),a=this.getAttribute("y").getPixels("y"),r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");if(i&&A&&r&&s){if(t.save(),t.translate(n,a),"string"==typeof A){const i=e.pith.forkString(t,A,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:r,scaleHeight:s}),{documentElement:n}=i.document;n&&(n.parent=this),i.resize(r,s,this.getAttribute("preserveAspectRatio").getString()),i.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r,desiredWidth:A.width,height:s,desiredHeight:A.height}),this.loaded&&("complete"in A&&!A.complete||t.drawImage(A,0,0));t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),A=this.getStyle("width").getPixels("x"),i=this.getStyle("height").getPixels("y");return new Rt(t,e,t+A,e+i)}constructor(t,e,A){super(t,e,A),he(this,"type","image"),he(this,"loaded",!1),he(this,"image",void 0);const i=this.getHrefAttribute().getString();if(!i)return;const n=i.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(i);t.images.push(this),n?this.loadSvg(i):this.loadImage(i)}},g:Zt,symbol:class extends kt{render(t){}constructor(...t){var e,A,i;super(...t),i="symbol",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},style:pe,use:class extends kt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),A=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),A.hasValue()&&t.translate(0,A.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:A}=this;if(A){let i=A;if("symbol"===A.type&&(i=new Kt(e),i.attributes.viewBox=new et(e,"viewBox",A.getAttribute("viewBox").getString()),i.attributes.preserveAspectRatio=new et(e,"preserveAspectRatio",A.getAttribute("preserveAspectRatio").getString()),i.attributes.overflow=new et(e,"overflow",A.getAttribute("overflow").getString()),i.children=A.children,A.styles.opacity=new et(e,"opacity",this.calculateOpacity())),"svg"===i.type){const t=this.getStyle("width",!1,!0),A=this.getStyle("height",!1,!0);t.hasValue()&&(i.attributes.width=new et(e,"width",t.getString())),A.hasValue()&&(i.attributes.height=new et(e,"height",A.getString()))}const n=i.parent;i.parent=this,i.render(t),i.parent=n}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?It.fromElement(t,e):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...t){super(...t),Ee(this,"type","use"),Ee(this,"cachedElement",void 0)}},mask:xe,clipPath:class extends Mt{apply(t){const{document:e}=this,A=Reflect.getPrototypeOf(t),{beginPath:i,closePath:n}=t;A&&(A.beginPath=Me,A.closePath=Me),Reflect.apply(i,t,[]),this.children.forEach((i=>{if(!("path"in i))return;let a="elementTransform"in i?i.elementTransform():null;a||(a=It.fromElement(e,i)),a&&a.apply(t),i.path(t),A&&(A.closePath=n),a&&a.unapply(t)})),Reflect.apply(n,t,[]),t.clip(),A&&(A.beginPath=i,A.closePath=n)}render(t){}constructor(...t){var e,A,i;super(...t),i="clipPath",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},filter:be,feDropShadow:class extends Mt{apply(t,e,A,i,n){}constructor(t,e,A){var i,n,a;super(t,e,A),a="feDropShadow",(n="type")in(i=this)?Object.defineProperty(i,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[n]=a,this.addStylesFromStyleDefinition()}},feMorphology:class extends Mt{apply(t,e,A,i,n){}constructor(...t){var e,A,i;super(...t),i="feMorphology",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},feComposite:class extends Mt{apply(t,e,A,i,n){}constructor(...t){var e,A,i;super(...t),i="feComposite",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},feColorMatrix:De,feGaussianBlur:Se,title:class extends Mt{constructor(...t){var e,A,i;super(...t),i="title",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}},desc:class extends Mt{constructor(...t){var e,A,i;super(...t),i="desc",(A="type")in(e=this)?Object.defineProperty(e,A,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[A]=i}}};function Pe(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Ne{bindCreateImage(t,e){return"boolean"==typeof e?(A,i)=>t(A,"boolean"==typeof i?i:e):t}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){const{emSizeStack:t}=this;return t[t.length-1]||12}set emSize(t){const{emSizeStack:e}=this;e.push(t)}popEmSize(){const{emSizeStack:t}=this;t.pop()}getUniqueId(){return"pith"+ ++this.uniqueId}isImagesLoaded(){return this.images.every((t=>t.loaded))}isFontsLoaded(){return this.fonts.every((t=>t.loaded))}createDocumentElement(t){const e=this.createElement(t.documentElement);return e.root=!0,e.addStylesFromStyleDefinition(),this.documentElement=e,e}createElement(t){const e=t.nodeName.replace(/^[^:]+:/,""),A=Ne.elementTypes[e];return A?new A(this,t):new vt(this,t)}createTextNode(t){return new Ot(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=12,emSize:A=12,createCanvas:i=Ne.createCanvas,createImage:n=Ne.createImage,anonymousCrossOrigin:a}={}){Pe(this,"pith",void 0),Pe(this,"rootEmSize",void 0),Pe(this,"documentElement",void 0),Pe(this,"screen",void 0),Pe(this,"createCanvas",void 0),Pe(this,"createImage",void 0),Pe(this,"definitions",void 0),Pe(this,"styles",void 0),Pe(this,"stylesSpecificity",void 0),Pe(this,"images",void 0),Pe(this,"fonts",void 0),Pe(this,"emSizeStack",void 0),Pe(this,"uniqueId",void 0),this.pith=t,this.definitions={},this.styles={},this.stylesSpecificity={},this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=t.screen,this.rootEmSize=e,this.emSize=A,this.createCanvas=i,this.createImage=this.bindCreateImage(n,a),this.screen.wait((()=>this.isImagesLoaded())),this.screen.wait((()=>this.isFontsLoaded()))}}function Re(t,e,A){return e in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}Pe(Ne,"createCanvas",(function(t,e){const A=document.createElement("canvas");return A.width=t,A.height=e,A})),Pe(Ne,"createImage",(async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const A=document.createElement("img");return e&&(A.crossOrigin="Anonymous"),new Promise(((e,i)=>{A.onload=()=>{e(A)},A.onerror=(t,e,A,n,a)=>{i(a)},A.src=t}))})),Pe(Ne,"elementTypes",Ye);class ke{static async from(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new Bt(A),n=await i.parse(e);return new ke(t,n,A)}static fromString(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=new Bt(A).parseFromString(e);return new ke(t,i,A)}fork(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ke.from(t,e,{...this.options,...A})}forkString(t,e){let A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ke.fromString(t,e,{...this.options,...A})}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}async render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.start({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0,...t}),await this.ready(),this.stop()}start(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{documentElement:e,screen:A,options:i}=this;A.start(e,{enableRedraw:!0,...i,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,A=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,A)}constructor(t,e,A={}){Re(this,"parser",void 0),Re(this,"screen",void 0),Re(this,"document",void 0),Re(this,"documentElement",void 0),Re(this,"options",void 0),this.parser=new Bt(A),this.screen=new ht(t,A),this.options=A;const i=new Ne(this,A),n=i.createDocumentElement(e);this.document=i,this.documentElement=n}}function He(t,e,A,i){Object.defineProperty(t,e,{get:A,set:i,enumerable:!0,configurable:!0})}var Ue="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==S?S:{},Ge={};He(Ge,"CanvasCommand",(()=>Xi)),He(Ge,"UpdateWorkflowStateCommand",(()=>qi)),He(Ge,"MoveCommand",(()=>Zi)),He(Ge,"RotateCommand",(()=>$i)),He(Ge,"ResizeCommand",(()=>_i)),He(Ge,"GroupCommand",(()=>tn)),He(Ge,"CreateLayoutCommand",(()=>en)),He(Ge,"ClearLayoutCommand",(()=>An)),He(Ge,"CreateElementCommand",(()=>nn)),He(Ge,"DeleteElementCommand",(()=>an)),He(Ge,"CloneElementCommand",(()=>rn)),He(Ge,"FontColorCommand",(()=>sn)),He(Ge,"FontImageFillCommand",(()=>on)),He(Ge,"FontSizeCommand",(()=>cn)),He(Ge,"FontAlgorithmCommand",(()=>ln)),He(Ge,"FontSourceCommand",(()=>gn)),He(Ge,"FontAlignmentCommand",(()=>hn)),He(Ge,"UpdateFramePattern",(()=>dn)),He(Ge,"TextChangeCommand",(()=>un)),He(Ge,"IllustrationColorCommand",(()=>wn)),He(Ge,"IllustrationCacheCommand",(()=>Bn)),He(Ge,"BringToFrontCommand",(()=>pn)),He(Ge,"BringToBackCommand",(()=>En)),He(Ge,"BringForwardCommand",(()=>mn)),He(Ge,"SendBackwardsCommand",(()=>Cn)),He(Ge,"LayerCommand",(()=>fn)),He({},"generate",(()=>Te));const Te=()=>{const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()};var Oe={};He(Oe,"ElementNotFoundError",(()=>zi)),He(Oe,"findElement",(()=>ji)),He(Oe,"findLayoutForElement",(()=>Vi)),He(Oe,"updatedLayoutForElement",(()=>Ki)),He(Oe,"rehydrateSerializedLayout",(()=>Wi));var Je={};He(Je,"CommandContext",(()=>Ti)),He(Je,"getSvgElement",(()=>Ji)),He(Je,"elementFactory",(()=>Oi)),He(Je,"sortElementsByLayersWithIndex",(()=>Li)),He({},"SVGLayout",(()=>lA));var Le={};let ze;var je;let Ve;var Ke;let We;var Xe;let qe;var Ze;let $e;var _e;let tA;var eA;let AA;var iA;let nA;var aA;let rA;var sA;let oA;var cA;He(Le,"LayoutElementType",(()=>ze)),He(Le,"LayoutRenderingPurpose",(()=>Ve)),He(Le,"TextAlgorithm",(()=>We)),He(Le,"UnitOfMeasurement",(()=>qe)),He(Le,"ScaleAxis",(()=>$e)),He(Le,"AspectType",(()=>tA)),He(Le,"MaterialEffectMode",(()=>AA)),He(Le,"AssetType",(()=>nA)),He(Le,"StepType",(()=>rA)),He(Le,"StepAspectType",(()=>oA)),(je=ze||(ze={})).Frame="frame",je.Image="image",je.Illustration="illustration",je.Textbox="textbox",(Ke=Ve||(Ve={})).ThreeD="ThreeD",Ke.FreeDesign="FreeDesign",Ke.Print="Print",(Xe=We||(We={})).Autosize="Autosize",Xe.Traditional="Traditional",(Ze=qe||(qe={})).Pixel="px",Ze.Millimeter="mm",Ze.Centimeter="cm",(_e=$e||($e={}))[_e.North=0]="North",_e[_e.Northeast=1]="Northeast",_e[_e.East=2]="East",_e[_e.Southeast=3]="Southeast",_e[_e.South=4]="South",_e[_e.Southwest=5]="Southwest",_e[_e.West=6]="West",_e[_e.Northwest=7]="Northwest",(eA=tA||(tA={})).FileUpload="FileUpload",eA.Option="Option",eA.Text="Text",(iA=AA||(AA={})).None="None",iA.RemoveWhenSelected="RemoveWhenSelected",iA.ApplyWhenSelected="ApplyWhenSelected",(aA=nA||(nA={})).Font="Font",aA.Frame="Frame",aA.Illustration="Illustration",aA.Image="Image",aA.Model="Model",aA.Material="Material",aA.Color="Color",aA.QuestionnaireCollateral="QuestionnaireCollateral",aA.RequestCollateral="RequestCollateral",aA.SignupCollateral="SignupCollateral",aA.Video="Video",aA.ColorProfile="ColorProfile",(sA=rA||(rA={})).Bulk="Bulk",sA.DigitalContent="DigitalContent",sA.Finish="Finish",sA.Frame="Frame",sA.Illustration="Illustration",sA.Introduction="Introduction",sA.Material="Material",sA.Model="Model",sA.Module="Module",sA.Picture="Picture",sA.Photo="Photo",sA.ProductOverlay="ProductOverlay",sA.Question="Question",sA.Shape="Shape",sA.SilentIllustration="SilentIllustration",sA.Text="Text",(cA=oA||(oA={})).Color="Color",cA.Colors="Colors",cA.Selection="Selection",cA.Selections="Selections",cA.Text="Text",cA.Upload="Upload";const lA=({backgroundColor:t,outlineColor:e,borderRadius:i,configuration:n,elements:a,height:r,maxHeight:s,maxWidth:o,outlineArea:c,position:l,preserveAspectRatio:g,viewBox:h,width:d})=>{const u=i||0,w=2*(c?.scale||1),B=h||{x:0,y:0,width:d,height:r},p=`${B.x} ${B.y} ${B.width} ${B.height}`,E=Te(),m=n.purpose===Ve.FreeDesign&&(0,A.jsx)("defs",{children:(0,A.jsx)("clipPath",{id:"viewboxClip",children:(0,A.jsx)("rect",{width:B.width,height:B.height,rx:u})})}),C=n.colorProfiles?.map(((t,e)=>(0,A.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),f=Li(a.map((t=>({...t,_renderingConfiguration:n,mask:c?`url(#viewmask-${E})`:void 0}))));return(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:g,width:d,height:r,style:{gridColumn:1,gridRow:1,maxWidth:o,maxHeight:s,position:l},viewBox:p,children:[C,m,!!t&&(0,A.jsx)("rect",{id:"layout-background",width:B.width,height:B.height,fill:t,rx:u}),(0,A.jsx)("g",{id:"element-group",clipPath:n.purpose===Ve.FreeDesign?"url(#viewboxClip)":void 0,children:f.map((t=>Oi(t))).filter((t=>!!t))}),c&&(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:w/2,strokeDasharray:`${2*w} ${w}`}),c&&(0,A.jsxs)("mask",{id:`viewmask-${E}`,children:[(0,A.jsx)("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"black"}),(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};He({},"Image",(()=>SA));var gA={};He(gA,"getAxisAlignedBoundingBox",(()=>hA)),He(gA,"degreesToRadians",(()=>uA)),He(gA,"findAngle",(()=>dA)),He(gA,"radiansToDegrees",(()=>wA)),He(gA,"isCloseToValue",(()=>BA)),He(gA,"getTrueCoordinates",(()=>pA)),He(gA,"getPointOfRotation",(()=>EA)),He(gA,"getNWPoint",(()=>mA)),He(gA,"getNEPoint",(()=>CA)),He(gA,"getSWPoint",(()=>fA)),He(gA,"getSEPoint",(()=>QA)),He(gA,"turnRightClockwise",(()=>yA)),He(gA,"currentDirection",(()=>DA)),He(gA,"getElementVertices",(()=>IA)),He(gA,"rotateAroundPoint",(()=>xA)),He(gA,"mmPerPixel",(()=>MA)),He(gA,"cmPerPixel",(()=>vA));const hA=(t,e,A,i,n)=>{const a=uA(n),r=A/2,s=i/2,o=t+r,c=e+s,l=Math.sin(a),g=Math.cos(a),h=-s,d=r*g-h*l,u=r*g-s*l,w=r*l+h*g,B=r*l+s*g,p=Math.max(Math.abs(d),Math.abs(u)),E=Math.max(Math.abs(w),Math.abs(B));return{minX:o-p,maxX:o+p,minY:c-E,maxY:c+E}},dA=(t,e,A)=>{const i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2)),a=Math.sqrt(Math.pow(A.x-t.x,2)+Math.pow(A.y-t.y,2));return Math.acos((n*n+i*i-a*a)/(2*n*i))*(180/Math.PI)},uA=t=>t*(Math.PI/180),wA=t=>t*(180/Math.PI),BA=(t,e,A)=>Math.abs(t-e)<A,pA=(t,e,A)=>{const i=Math.sin(uA(A)),n=Math.cos(uA(A));return{x:(t.x-e.x)*n-(t.y-e.y)*i+e.x,y:(t.x-e.x)*i+(t.y-e.y)*n+e.y}},EA=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),mA=(t,e,A,i)=>({x:t.x+e?.x*A,y:t.y+e?.y*i}),CA=(t,e,A,i)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+e?.y*i}),fA=(t,e,A,i)=>({x:t.x+e?.x*A,y:t.y+(e?.y+e?.height)*i}),QA=(t,e,A,i)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+(e?.y+e?.height)*i}),yA=t=>{switch(t){case $e.North:return $e.East;case $e.East:return $e.South;case $e.South:return $e.West;case $e.West:return $e.North;case $e.Northwest:return $e.Northeast;case $e.Northeast:return $e.Southeast;case $e.Southeast:return $e.Southwest;case $e.Southwest:return $e.Northwest}},DA=(t,e)=>e>45&&e<=135?yA(t):e>135&&e<=225?yA(yA(t)):e>225&&e<=315?yA(yA(yA(t))):t,IA=(t,e={x:0,y:0},A={x:1,y:1})=>{const i=uA(t.rotation),n={x:e.x+t.x*A.x,y:e.x+t.y*A.y},a={x:t.x+t.width,y:t.y},r={x:e.x+(t.x+t.width)*A.x,y:e.y+(t.height+t.y)*A.y},s={x:e.x+t.x*A.x,y:e.y+(t.height+t.y)*A.y},o={x:(s.x+r.x)/2,y:s.y-t.height*A.y/2};return{a:xA(n,o,i),b:xA(a,o,i),c:xA(r,o,i),d:xA(s,o,i),center:o}},xA=(t,e,A)=>{const i=Math.sin(A),n=Math.cos(A);return{x:(t.x-e.x)*n-(t.y-e.y)*i+e.x,y:(t.x-e.x)*i+(t.y-e.y)*n+e.y}},MA=.352778,vA=.035277,SA=t=>{const e=t.rotation||0,i=uA(e),n=Math.cos(i),a=-Math.sin(i);return(0,A.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,A.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${n}, ${-a}, ${a}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `,children:(0,A.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};He({},"Frame",(()=>FA));const FA=t=>{const e=`spiff-frame-${t.id}`,n=`spiff-frame-blur-${t.id}`,a=`spiff-frame-blur-edge-${t.id}`,r=`spiff-frame-focal-mask-${t.id}`,s=()=>t.disablePlaceholder&&!t.pattern?"":t.pattern?t.pattern.src:"data:image/png;base64,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";if(!s())return(0,A.jsx)(F(i).Fragment,{});const o=!!t.focalBlur&&!!t.pattern,c=t.rotation||0,l=uA(c),g=Math.cos(l),h=-Math.sin(l);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("defs",{children:(i=>{const o=t.pattern?.x||0,c=t.pattern?.y||0,l=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(o):256,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(c):256,h=t.pattern?t.pattern.width*t.pattern.scaleX:256,d=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,A.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,A.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:l,height:t.pattern?1:g,"data-frame-width":t.pattern?l:void 0,"data-frame-height":t.pattern?g:void 0,id:e,children:(0,A.jsx)("image",{preserveAspectRatio:"none",x:o,y:c,width:h,height:d,xlinkHref:s()})}),i?(0,A.jsx)(bA,{path:t.path,width:t.width,height:t.height,focalBlurStrength:t.focalBlurStrength||1,focalBlurRadius:t.focalBlurRadius||10,blurFilterId:n,focalMaskId:r,blurEdgeClipId:a}):null]})})(o)}),(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${g}, ${-h}, ${h}, ${g}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n matrix(${t.scaleX}, 0, 0, ${t.scaleY}, 0, 0)\n `,children:[(0,A.jsx)("path",{filter:o?`url(#${n})`:void 0,mask:o?`url(#${a})`:void 0,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}),o?(0,A.jsx)("path",{mask:`url(#${r})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},bA=t=>{const{path:e,width:i,height:n,focalBlurStrength:a,focalBlurRadius:r,blurFilterId:s,focalMaskId:o,blurEdgeClipId:c}=t;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("filter",{id:s,children:(0,A.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,A.jsx)("mask",{id:o,children:(0,A.jsx)("circle",{cx:i/2,cy:n/2,r:r||0,fill:"white",filter:`url(#${s})`})}),(0,A.jsx)("mask",{id:c,children:(0,A.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};He({},"Textbox",(()=>Fi));var YA={};He(YA,"fontSizeStep",(()=>wi)),He(YA,"textWidth",(()=>Bi)),He(YA,"charWidth",(()=>pi)),He(YA,"lineWidth",(()=>Ei)),He(YA,"applyTextTransformations",(()=>Ci)),He(YA,"zip",(()=>fi)),He(YA,"getTextAlignment",(()=>Qi)),He(YA,"getAnchor",(()=>yi)),He(YA,"recomputeTextOnElement",(()=>Di)),He(YA,"defaultLineHeightFactor",(()=>Ii));var PA={};He(PA,"refitTextbox",(()=>di)),He(PA,"recalculateTextboxRegion",(()=>ui));var NA={};He(NA,"FontMetrics",(()=>ii)),He(NA,"loadFontFromExternalUrl",(()=>ai)),He(NA,"loadFontFromDataUrl",(()=>ri)),He(NA,"getFontMetrics",(()=>si));var RA={};He(RA,"registerJSDOM",(()=>UA)),He(RA,"createElement",(()=>JA)),He(RA,"createElementNS",(()=>LA)),He(RA,"domParser",(()=>zA)),He(RA,"fetchAsArrayBuffer",(()=>jA)),He(RA,"fetchAsString",(()=>VA)),He(RA,"loadFontFaceSet",(()=>KA)),He(RA,"xmlSerializer",(()=>WA)),He(RA,"toBase64",(()=>XA)),He(RA,"dataUrlFromExternalUrl",(()=>qA)),He(RA,"arrayBufferToDataUrl",(()=>ZA)),He(RA,"arrayBufferToBuffer",(()=>_A)),He(RA,"dataUrlToArrayBuffer",(()=>$A));var kA=a.Buffer;let HA;function UA(t){HA=t}function GA(){if(!HA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new HA}if(void 0===Ue.TextEncoder){const{TextEncoder:t}=c;Ue.TextEncoder=t}if(void 0===Ue.TextDecoder){const{TextDecoder:t}=c;Ue.TextDecoder=t}const TA=new(F(s).Agent)({rejectUnauthorized:!("local"===Ue.process?.env?.ENVIRONMENT)}),OA=t=>t.every((t=>"undefined"!==t)),JA=t=>OA([typeof document])?document.createElement(t):GA().window.document.createElement(t),LA=(t,e)=>{if(OA([typeof document]))return document.createElementNS(t,e);const A=GA().window.document.createElement(e);return A.setAttribute("xmlns",t),A},zA=()=>OA([typeof DOMParser])?new DOMParser:new(GA().window.DOMParser),jA=t=>{if(OA([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{A(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{F(r).get(e,{responseType:"arraybuffer",httpsAgent:TA}).then((e=>{t(e.data)})).catch((t=>{A(t)}))}))}},VA=t=>{if(OA([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.text())})).catch(A)}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{F(r).get(e,{responseType:"text",httpsAgent:TA}).then((e=>{t(e.data)})).catch(A)}))}},KA=async(t,e)=>{if(OA([typeof FontFace])){const A=t.names.fullName.en,i=new FontFace(A,`url(${e})`);return document.fonts.add(i),i.load()}},WA=()=>OA([typeof XMLSerializer])?new XMLSerializer:new(GA().window.XMLSerializer),XA=t=>OA([typeof btoa])?btoa(t):kA.from(t).toString("base64"),qA=async t=>{if(OA([typeof fetch,typeof Blob,typeof FileReader])){const e=await fetch(t),A=await e.blob();return await ei(A)}const e=(await F(r).get(t,{responseType:"arraybuffer"})).data;return ZA(e)},ZA=async t=>{const e=await(async t=>{const e=await(0,o.fromBuffer)(t);return e?e.mime:"image/svg+xml"})(t);return`data:${e};base64,${_A(t).toString("base64")}`},$A=t=>{const e=t.replace(/\r?\n/g,""),A=e.indexOf(",");if(-1===A||A<=4)throw new TypeError("malformed data: URI");const i=e.substring(5,A).split(";");let n=!1;for(let t=1;t<i.length;t++)"base64"===i[t]&&(n=!0);const a=n?"base64":"ascii",r=unescape(e.substring(A+1)),s=kA.from(r,a);return ti(s)},_A=t=>kA.from(t),ti=t=>{const e=new ArrayBuffer(t.byteLength),A=new Uint8Array(e);for(let e=0;e<t.length;++e)A[e]=t[e];return e},ei=t=>new Promise(((e,A)=>{const i=new FileReader;i.onload=function(t){const i=t.target;i&&i.result?e(i.result.toString()):A()},i.readAsDataURL(t)})),Ai=new Map;class ii{constructor(t){this.font=t,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(t){const e=this.glyphsFromText.get(t);if(e)return e;const A=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,A),A}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let A=0,i=0;return e.forEach((t=>{const e=t.getMetrics();A=Math.max(A,e.yMax),i=Math.min(i,e.yMin)})),A-i}getKerningValue(t,e){let A=this.kerningValues.get(t.name);A||(A=new Map,this.kerningValues.set(t.name,A));let i=A.get(e.name);return i||(i=this.font.getKerningValue(t,e),A.set(e.name,i)),i}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,A=0;return t.forEach((t=>{const i=t.getMetrics();e=Math.max(e,i.yMax),A=Math.min(A,i.yMin)})),e-A}}const ni=t=>"data:"===t.substring(0,5).toLowerCase().trim(),ai=async t=>{const e=ni(t)?ri(t):ri(await qA(t));return oi(e,{assetUrl:ni(t)?t:await qA(t),name:e.names.fullName.en}),await KA(e,t),e},ri=t=>{const e=$A(t),A=F(n).parse(e);return oi(A,{assetUrl:t,name:A.names.fullName.en}),A},si=t=>{const e=Ai.get(t.name);if(e)return e;throw new Error("Font metrics unavailable for font")},oi=(t,e)=>{const A=new ii(t);return Ai.set(e.name,A),A},ci=(t,e,A,i)=>Math.max(pi(t.join("\n"),A,i),e),li=(t,e,A,i,n,a)=>{const r=(a||Ii)*n.getApproximateHeight(),s=e.split("\n");try{const e=s.flatMap((e=>gi(e,t.width,i,n))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(i*r),fontSize:A,requiredWidth:ci(a,t.width,i,n)}}catch(a){const s=e.split("");return{lines:s,requiredHeight:s.length*(i*r),fontSize:A,requiredWidth:ci(s,t.width,i,n)}}},gi=(t,e,A,i)=>{const n=Bi(t,A,i);if(n<=e)return{lines:[t],width:n};if(!(t.indexOf(" ")>-1)){if(t.length<=1)throw new Error(`Character ${t} is wider than region`);const n=Math.floor(t.length/2),a=gi(t.slice(0,n),e,A,i),r=gi(t.slice(n),e,A,i);return{lines:[...a.lines,...r.lines],width:Math.max(a.width,r.width)}}const a=t.split(" "),r=[];let s=-1/0,o=0;for(;o<a.length;){const t=a[o];if(Bi(t,A,i)>e){const n=gi(t,e,A,i);r.push(...n.lines),s=Math.max(s,n.width),o++}else{const n=[t];s=Math.max(s,Bi(t,A,i));let c=o+1,l=!0;for(;c<a.length&&l;){const t=a[c],r=Bi(`${n.join(" ")} ${t}`,A,i);r<=e?(n.push(t),s=Math.max(s,r),c++):l=!1}r.push(n.join(" ")),o=c}}if(s<0)throw new Error(`No max width calculated for text: ${r}.`);return{lines:r,width:s}},hi=(t,e,A,i,n,a)=>{const r=(a??Ii)*e.getApproximateHeight(),s=1/A.unitsPerEm,o=i/Ei(t,s,e),c=n/(t.length*r*s);return Math.min(c,o)},di=(t,e,A,i)=>{const n=si(e.fontData),a=n.getFont(),r=e.fontSize/a.unitsPerEm;if(!A)return li(e,t,e.fontSize,r,n,i);let s;if(s=e.text?e.text.split("\n"):e.input?.split("\n")??[""],A.input===t&&e.width===A.width&&e.height===A.height&&e.lineHeight===A.lineHeight)return{lines:s,requiredHeight:e.height,requiredWidth:ci(s,e.width,r,n),fontSize:e.fontSize};const o=e.width!==A.width!=(e.height!==A.height);return e.lineHeight!==A.lineHeight||o||A.input!==t?li(e,t,e.fontSize,r,n,i):{lines:s,requiredHeight:e.height,requiredWidth:ci(s,e.width,r,n),fontSize:hi(s,n,a,e.width,e.height,i)}},ui=(t,e,A,i,n)=>{const a=si(e).getFont();let r={...t},s={...t},o=Ei(i,A/a.unitsPerEm,si(e));return o&&o<r.width&&(s.width=o,"left"===n?(s.left+=Math.sin(r.rotation*Math.PI/360)*(r.width-o),s.top+=Math.sin(r.rotation*Math.PI/180)*(o-r.width)/2):s.left+="right"===n?r.width-o:(r.width-o)/2,i&&fi(i,i).every((([t,e])=>t===e))&&(r=s)),r},wi=1,Bi=(t,e,A)=>{let i=0;const n=A.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(i+=t.advanceWidth),e<n.length-1){const a=A.getKerningValue(t,n[e+1]);i+=a}})),i*=e,i},pi=(t,e,A)=>{let i=0;const n=A.getGlyphs(t);return n.forEach(((t,e)=>{if(t.advanceWidth&&(i=Math.max(i,t.advanceWidth)),e<n.length-1){const a=A.getKerningValue(t,n[e+1]);i=Math.max(i,a)}})),i*=e,i},Ei=(t,e,A)=>{let i=0;return t.forEach((t=>{i=Math.max(i,Bi(t,e,A))})),i},mi={stripControlCharacters:!0,vertical:!1,uppercase:!1},Ci=(t,e=mi)=>{const A={...mi,...e};let i=t||"";return A.stripControlCharacters&&(i=i.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),A.uppercase&&(i=i.toUpperCase()),A.vertical&&(i=i.split("").join("\n")),i},fi=(t,e)=>t.map(((t,A)=>[t,e[A]])),Qi=(t="center",e=!1)=>e?"center":t,yi=t=>"left"===t?"start":"right"===t?"end":"middle",Di=(t,e,A)=>t.fontData?{...t,...(()=>{if(t.algorithm===We.Traditional){const i=di(e,t,A,t.lineHeight);return{text:i.lines.join("\n"),height:i.requiredHeight,width:i.requiredWidth,fontSize:i.fontSize,input:e}}return{text:e}})()}:t,Ii=1.1;var xi={};He(xi,"colorDefinitionPrintValue",(()=>Mi)),He(xi,"spotColorDefinitionString",(()=>vi)),He(xi,"svgColorValueToDefinition",(()=>Si));const Mi=t=>{const e=vi(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},vi=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),A=e.lastIndexOf("/");return`icc-named-color(${e.slice(A+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},Si=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const A=e[1].match(/\(([^)]+)\)/gm);if(!A)throw new Error("Unhandled state of color value in SVG");const i=A[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:i[0],namedColor:i[1]}}},Fi=t=>{const e=(t.rotation||0)*Math.PI/180,i=Math.cos(e),n=-Math.sin(e),a=`text-path-${t.id}`,r=`text-fill-${t.id}`,s=t.x+(t.curved?0:t.width/2),o=t.y+(t.curved?0:t.height/2),c=(t.text||"").split("\n");return t.curved&&!t.paths?null:t.fontData?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("defs",{children:[t.textFillImage&&(0,A.jsx)("pattern",{id:r,patternUnits:"userSpaceOnUse",width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height,x:0,y:0,children:(0,A.jsx)("image",{href:t.textFillImage.src,xlinkHref:t.textFillImage.src,width:t.textFillImage.scale*t.textFillImage.width,height:t.textFillImage.scale*t.textFillImage.height})}),(0,A.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${t.fontData.name}';\n src: url('${t.fontData.assetUrl}') format('truetype');\n }\n `}}),t.curved&&t.paths?(0,A.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,A.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:`matrix(${i}, ${-n}, ${n}, ${i}, ${s}, ${o})`,children:(0,A.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${t.fontData.name}'`,fontSize:t.fontSize,fontStyle:"normal",fontWeight:"normal",fill:t.textFillImage?`url("#${r}")`:t._renderingConfiguration?.spotColors&&t.fillSpotColorDefinition?`${t.fill} ${vi(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,A.jsx)(Yi,{text:t.text||"",curvedPathId:a,align:t.align}):c.map(((e,i)=>(0,A.jsx)(bi,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:i,amountLines:c.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},i)))})})})]}):null},bi=t=>(0,A.jsx)("tspan",{textAnchor:yi(t.align),x:"left"===t.align?-t.textboxWidth/2:"right"===t.align?t.textboxWidth/2:0,y:`${(()=>{const e=t.fontSize*(void 0!==t.lineHeight?t.lineHeight:Ii),A=t.textboxHeight/2;if("top"===t.verticalAlign)return-A+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const i=t.amountLines-1-t.thisLineIdx;return A-t.fontSize/4-i*e}const i=(t.amountLines-1)/2;return(t.thisLineIdx-i)*e+t.fontSize/4})()}px`,children:t.text}),Yi=t=>{const e=`#${t.curvedPathId}`;return(0,A.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:yi(t.align),href:e,xlinkHref:e,children:t.text})};He({},"Illustration",(()=>Gi));var Pi={};He(Pi,"traverse",(()=>Ri)),He(Pi,"sanitizeSvgTree",(()=>ki)),He(Pi,"modifySVGWithElementProperties",(()=>Hi)),He(Pi,"generateSVGWithUnknownColors",(()=>Ui));const Ni=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Ri=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>Ri(t,e)))},ki=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const A=[];Ri(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,l.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{A.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),Ri(t,(t=>{A.forEach((e=>{e.selectors?.forEach((A=>{((t,e)=>{try{return t.matches(e)}catch(A){return t.classList.contains(e.substring(1))}})(t,A)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},Hi=(t,e,A,i,n)=>{const a=(t=>zA().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,A)=>{t.setAttribute("height",`${A}px`),t.setAttribute("width",`${e}px`)})(a,e,A),((t,e,A)=>{Ri(t,(t=>{const i=t.attributes.getNamedItem("fill");i&&"none"!==i.value&&t.classList.forEach((i=>{if(i.startsWith("spiff-fill")){const n=e[i];n&&t.setAttribute("fill",A?Mi(n):n.browserValue)}}));const n=t.attributes.getNamedItem("stroke");n&&"none"!==n.value&&t.classList.forEach((i=>{if(i.startsWith("spiff-stroke")){const n=e[i];n&&t.setAttribute("stroke",A?Mi(n):n.browserValue)}}))}))})(a,i,n),(t=>WA().serializeToString(t))(a)},Ui=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],A=e?.length>0?e[0]:"",i=zA().parseFromString(A,"image/svg+xml").firstElementChild;if(!i)throw new Error("Failed to read SVG.");ki(i);const n={};Ri(i,(t=>{Ni.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const A=Si(e.value),i=`spiff-fill-${A.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",A.browserValue),t.classList.add(i),n[i]=A}const A=t.attributes.getNamedItem("stroke");if(A&&"none"!==A.value){const e=Si(A.value),i=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(i),t.setAttribute("stroke",e.browserValue),n[i]=e}}));const a=WA().serializeToString(i);return{colors:n,svg:a}},Gi=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,A.jsx)(SA,{id:t.id,src:t.cachedObjectURL,x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation,preserveAspectRatio:"none",immutable:t.immutable,mask:t.stepName?void 0:t.mask});const e=t.rotation||0,i=uA(e),n=Math.cos(i),a=-Math.sin(i),r=`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${n}, ${-a}, ${a}, ${n}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `;if(!t.svg)throw new Error(`Illustration element ${t.id} (stepName ${t.stepName}) lacked svg from src ${t.src} at render time.`);return(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:r,dangerouslySetInnerHTML:{__html:Hi(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class Ti{constructor(){this.id=Te(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(t){this.stateCallbacks.push(t)}unregisterStateCallback(t){this.stateCallbacks.filter((e=>e!==t))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((t=>t()))}apply(t,e){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.nextCommands=[],e||this.prevCommands.push(t)}undo(){if(!this.state)return;const t=this.prevCommands.pop();if(!t)return;const e=t.undo();t.varying?this.state={...this.state,variation:e}:this.state={...this.state,transaction:e},this.nextCommands.push(t),this.runStateCallbacks()}redo(){if(!this.state)return;const t=this.nextCommands.pop();t&&(this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.prevCommands.push(t))}flattenSequence(t,e){const A=this.prevCommands.filter((e=>e.sequenceId===t)).pop();A&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),A?.overrideOldState(e),this.prevCommands.push(A))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],A=this.state.variation?.layouts?.[t],i=e?.layout||A?.layout;if(!i)throw new Error(`No layout: ${t}`);const n=[...e?.elements||[],...A?.elements||[]];return this.getLayoutDataWithState(i,n)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(t)].map((t=>this.getLayoutById(t)))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:A=>Ji(t,e,A)}}initialize(t,e){if(e)return void(this.state={transaction:e});let A={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{A=new en(t).apply(A)})),this.runStateCallbacks(),this.state={transaction:A}}commandReducer(t,e){if(e.varying){const A={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(A)}}{const A=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(A)}}}}const Oi=t=>"image"===t.type?(0,A.jsx)(SA,{...t},t.id):"frame"===t.type?(0,A.jsx)(FA,{...t},t.id):"illustration"===t.type?(0,A.jsx)(Gi,{...t},t.id):"textbox"===t.type?(0,A.jsx)(Fi,{...t},t.id):null,Ji=(t,e,i)=>{const n=i.renderingConfiguration,a=n?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,A.jsx)(lA,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:i.width||t.width,height:i.height||t.height,viewBox:n?.region?{x:n.region.left,y:n.region.top,width:n.region.width,height:n.region.height}:{x:0,y:0,width:t.width,height:t.height},configuration:n,outlineArea:i.outlineArea,maxHeight:i.maxHeight,maxWidth:i.maxWidth,position:i.position,borderRadius:i.borderRadius,outlineColor:i.outlineColor})};function Li(t){return t.sort(((t,e)=>{const A=t.layer||0,i=e.layer||0;if(A<i)return-1;if(A>i)return 1;const n=t.layerIndex||0,a=e.layerIndex||0;return n<a?-1:n>a?1:0}))}class zi extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,zi.prototype)}}const ji=(t,e)=>Vi(t,e).elements.find((e=>e.id===t)),Vi=(t,e)=>{const A=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!A)throw new zi;return A},Ki=(t,e)=>{const A=Li([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:A,modificationID:Te()}},Wi=async(t,e)=>{const A=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],i=[...new Set(A)];for(let A=0;A<i.length;A++){const n=i[A],a=t.layouts[n],r=e?.layouts[n],s=a||r;await Promise.all(s.elements.map((async t=>{if("illustration"===t.type){const e=t;if(e.src&&!e.svg){const t=await VA(e.src),A=await Ui(t);e.svg=Hi(A.svg,e.width,e.height,e.colors)}}isNaN(t.x)&&(t.x=0),isNaN(t.y)&&(t.y=0),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),isNaN(t.rotation)&&(t.rotation=0)})))}};class Xi{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class qi extends Xi{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class Zi extends Xi{constructor(t,e,A){super(),this.id=t,this.x=e,this.y=A}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,x:this.x,y:this.y},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class $i extends Xi{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,rotation:this.angle},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class _i extends Xi{constructor(t,e,A){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(A)}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;let A={...e,width:this.width,height:this.height};if("frame"===e.type){const t=A;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=A,i=(t.algorithm&&t.algorithm!==We.Autosize?t.input:t.text)??"";A=Di(t,i,e)}const i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class tn extends Xi{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class en extends Xi{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Te()}}}}}class An extends Xi{constructor(t){super(),this.panelName=t}apply(t){this.oldState=t;const e=Object.values(t.layouts).map((t=>{const e=t.layout.panelId===this.panelName;return{...t,elements:e?[]:[...t.elements],modificationID:Te()}})),A={};return e.forEach((t=>{A[t.layout.id]=t})),{...t,layouts:A}}}class nn extends Xi{constructor(t,e){super(),this.element=t,this.layout=e}apply(t){this.oldState=t,t.layouts[this.layout.id]||(t.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const e=t.layouts[this.layout.id].elements;if(e.find((t=>t.id===this.element.id)))throw new Error(`Failed to apply new ${this.element.type} element because ID ${this.element.id} already taken`);if(this.element.productOverlay||0===e.length){const A=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,A)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:A,modificationID:Te()}}}}const A=e[e.length-1],i=A.productOverlay?A:null;let n;if(i&&e.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)n=[...e,this.element].sort(((t,e)=>void 0!==t.layerIndex&&void 0!==e.layerIndex?t.layerIndex-e.layerIndex:0));else{const t=this.assignIndex(this.element,e);this.element.layerIndex=void 0!==t?t:0,n=[...e,this.element]}return i&&n.push(i),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:n,modificationID:Te()}}}}assignIndex(t,e){if(0===e.length)return 0;const A=e.filter((e=>(e.layer||0)===(t.layer||0))).sort(((t,e)=>(t.layerIndex||0)-(e.layerIndex||0)))[e.length-1]?.layerIndex;return void 0!==A?A+1:0}}class an extends Xi{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const A=Object.values(t.layouts).map((t=>(t.elements.filter((t=>t.id!==this.id)).length!==t.elements.length&&(e=!0),{...t,elements:t.elements.filter((t=>t.id!==this.id)),modificationID:Te()})));e||console.log(`Failed to delete element ${this.id}`);const i={};return A.forEach((t=>{i[t.layout.id]=t})),{...t,layouts:i}}}class rn extends Xi{constructor(t,A){super(),this.el=F(e)(t),this.layout=A,this.el.id=Te(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new nn(this.el,this.layout).apply(t)}}class sn extends Xi{constructor(t,e,A){super(),this.id=t,this.color=e,this.textFillSpotColor=A}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class on extends Xi{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,textFillImage:this.imageFill},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class cn extends Xi{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,fontSize:this.size},i=Vi(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=Ki(Di(A,n),i);return{...t,layouts:{...t.layouts,[i.layout.id]:a}}}}class ln extends Xi{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,algorithm:this.algorithm},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class gn extends Xi{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,fontData:this.fontData},i=Vi(e.id,Object.values(t.layouts)),n=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=Ki(Di(A,n),i);return{...t,layouts:{...t.layouts,[i.layout.id]:a}}}}class hn extends Xi{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,align:this.align},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class dn extends Xi{constructor(t,e,A){super(),this.id=t,this.imageData=e,this.offsets=A}apply(t){this.oldState=t;const e=Vi(this.id,Object.values(t.layouts)),A=e.elements.findIndex((t=>t.id===this.id)),i=e.elements[A].pattern,n=[...e.elements];n.splice(A,1,{...e.elements[A],pattern:{...i,src:this.imageData.src,x:this.offsets.x,y:this.offsets.y,width:this.imageData.width,height:this.imageData.height,scaleX:this.offsets.zoom,scaleY:this.offsets.zoom}});const a={...e,elements:n,modificationID:Te()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class un extends Xi{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A=Vi(e.id,Object.values(t.layouts)),i=Ki(Di(e,this.text,e),A);return{...t,layouts:{...t.layouts,[A.layout.id]:i}}}}class wn extends Xi{constructor(t,e,A){super(),this.id=t,this.className=e,this.fill=A}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A=e.colors||{},i=A[this.className];A[this.className]={browserValue:this.fill,spotColor:i?.spotColor};const n={...e,colors:A},a=Vi(e.id,Object.values(t.layouts)),r=Ki(n,a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class Bn extends Xi{constructor(t,e,A){super(),this.id=t,this.svgBody=e,this.objectURL=A}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},i=Vi(e.id,Object.values(t.layouts)),n=Ki(A,i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class pn extends Xi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!ji(this.id,Object.values(t.layouts)).id)throw new zi;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(A,1)[0]);const i=[...e.elements];return i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:i,modificationID:Te()}}}}}class En extends Xi{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");const i=A.elements.findIndex((t=>t.id===this.id));A.elements.splice(i,1),A.elements.unshift(e);const n=[...A.elements],a=n.splice(i,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[A.layout.id]:{...t.layouts[A.layout.id],elements:n,modificationID:Te()}}}}}class mn extends Xi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!ji(this.id,Object.values(t.layouts)).id)throw new zi;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id)),i=A+1,n=[...e.elements],a=n.splice(A,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class Cn extends Xi{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!ji(this.id,Object.values(t.layouts)).id)throw new zi;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id)),i=A-1,n=[...e.elements],a=n.splice(A,1)[0];return n.splice(i,0,a),n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class fn extends Xi{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=ji(this.id,Object.values(t.layouts));if(!e.id)throw new zi;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[A.layout.id]:Ki({...e,layer:this.value},A)}}}}var Qn={};He(Qn,"patternImageDataCache",(()=>Sn)),He(Qn,"frameDataCache",(()=>Fn)),He(Qn,"generateFrameSVG",(()=>bn)),He(Qn,"generateDefaultRectangleFrameSvg",(()=>Yn)),He(Qn,"getVariant",(()=>Pn)),He(Qn,"getFrameData",(()=>Nn)),He(Qn,"calculateOffsets",(()=>Rn)),He(Qn,"getPatternImageData",(()=>kn)),He(Qn,"GetSVGDimensions",(()=>Hn)),He(Qn,"svgStringDimensions",(()=>Un));var yn={};He(yn,"getExifOrientation",(()=>In)),He(yn,"canvasDims",(()=>xn)),He(yn,"getAttributesFromArrayBuffer",(()=>Mn));let Dn=null;const In=t=>new Promise((e=>{const A=_A(t);(0,o.fromBuffer)(t).then((t=>{const i=t?.mime;if("image/jpeg"!==i)return e(1);(new(0,h.ExifImage)).loadImage(A,((t,A)=>e(t?1:A.image.Orientation||1)))}))})),xn=t=>{const e=8192,A=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[A*e,e]:[e,e/A]},Mn=async t=>{const e=await(async t=>{const e=await ZA(t),A=await(0,g.loadImage)(e),[i,n]=xn(A),a=await(async()=>{if(null!==Dn)return!Dn;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Dn=2===t.width&&3===t.height,!Dn})();if(!a){const t=(0,g.createCanvas)(i,n);return t.getContext("2d").drawImage(A,0,0,i,n),t}const r=await In(t),[s,o]=r>4?[n,i]:[i,n],c=(0,g.createCanvas)(s,o),l=c.getContext("2d");switch(r){case 2:l.translate(s,0),l.scale(-1,1);break;case 3:l.translate(s,o),l.rotate(Math.PI);break;case 4:l.translate(0,o),l.scale(1,-1);break;case 5:l.rotate(-.5*Math.PI),l.scale(-1,1);break;case 6:l.rotate(-.5*Math.PI),l.translate(-s,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-s,o),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-o)}return l.drawImage(A,0,0,s,o),c})(t);return"image/jpeg"===(await(0,o.fromBuffer)(t))?.mime?{dataUrl:e.toDataURL("image/jpeg",1),height:e.height,width:e.width}:{dataUrl:e.toDataURL(),height:e.height,width:e.width}};He({},"getDefaultVariant",(()=>vn));const vn=t=>{const e=t.variants;if(e){if(1===e.length)return e[0];if(void 0!==t.defaultVariant)return e.find((e=>e.id===t.defaultVariant))}},Sn=new Map,Fn=new Map,bn=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return Yn(t)}return VA(e)},Yn=t=>{const e=t.width,A=e/t.height,i=Math.max(e,512),n=i/A;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${i} ${n}'>\n <path id="target-path" d='M0 0 h ${i} v ${n} h ${-i} Z' />\n </svg>\n `},Pn=(t,e)=>{if(!e)return;const A=e.variants?.find((e=>e.id===t.frameVariantId))||vn(e);if(!A)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!A.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return A},Nn=async t=>{const e=zA().parseFromString(t,"image/svg+xml"),A=e.querySelector("svg");if(!A)throw new Error("Malformed frame SVG: <svg> tag not found");const i=A.getAttribute("viewBox");if(!i)throw new Error("SVG missing viewBox.");const n=i.split(" "),a=parseFloat(n[3])||1,r=parseFloat(n[2])||1,s=e.getElementById("target-path"),o=e.getElementsByClassName("st0").item(0);if(s){const t=s.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:r,height:a};return Fn.set(t,e),e}if(o){const t=o.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:r,height:a};return Fn.set(t,e),e}throw new Error("Malformed frame SVG")},Rn=(t,e,A)=>{const i=e.width>=e.height,n=t.width>=t.height,a=e.width/2,r=e.height/2,s=(i?e.height:e.width)/(n?t.width:t.height),o=A?.scale||s,c=a-t.width/2*o,l=A?.left||c,g=r-t.height/2*o;return{x:l,y:A?.top||g,zoom:o}},kn=async t=>{if(Sn.has(t))return Sn.get(t);if(t.endsWith("svg")){const e=await Hn(t),A=e.width,i=e.height,n={src:t,width:A,height:i,aspect:A/i};return Sn.set(t,n),n}{const e=await jA(t),A=await Mn(e),i={src:t,width:A.width,height:A.height,aspect:A.width/A.height};return Sn.set(t,i),i}},Hn=async t=>{const e=await VA(t);return Un(e)},Un=t=>{const e=zA().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const A=e.getAttribute("viewBox"),i=e.getAttribute("width"),n=e.getAttribute("height"),a=A?A?.split(" ").map((t=>Number(t))):[0,0,Number(i),Number(n)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var Gn={};He(Gn,"determineCorrectFontSizeAndLines",(()=>On)),He(Gn,"determineCorrectTextboxRegion",(()=>Jn));const Tn=(t,e,A,i,n)=>{if(e.some((t=>null==t)))throw new Error(`Failed to autosize lines: ${e.join(", ")}`);let a=e.map((t=>t.split("\n"))).flat(),r=a.length,s=a.map((t=>Bi(t,i,n)));const o=n.getApproximateHeight()*i;let c=!0;for(;c;){if(o+(r-1)*A>t.height)return[null,null];const e=Math.max(...s);if(e<=t.width)return[a,e];const l=s.reduce(((t,e,A,i)=>e>i[t]?A:t),0),g=a[l];let h=!1,d=g.length;for(;!h&&d>-1;){d=g.lastIndexOf(" ",d-1);const e=[g.slice(0,d),g.slice(d+1)],A=e.map((t=>Bi(t,i,n)));A[0]<=t.width&&(a=[...a.slice(0,l),...e,...a.slice(l+1)],s=[...s.slice(0,l),...A,...s.slice(l+1)],r+=1,h=!0)}h||(c=!1)}return[null,null]},On=(t,e,A,i,n)=>{let a,r;const s=si(e),o=s.getFont();if(n.size){const e=t/o.unitsPerEm;return[a,r]=Tn(A,i,t,e,s),[n.size,a,r]}let c=6-wi;if(i.length>0){let t=i,e=0;for(;(!n.maxSize||c<=n.maxSize)&&t;)c+=wi,e=c/o.unitsPerEm,[t,r]=Tn(A,i,c,e,s)}c>6&&(c-=wi),n.minSize&&c<n.minSize&&(c=n.minSize);const l=c/o.unitsPerEm;return[a,r]=Tn(A,i,c,l,s),[c,a,r]},Jn=(t,e,A,i,n)=>{let a={...t},r={...t},[s,o,c]=On(A,e,r,i,{size:0,minSize:A,maxSize:A});var l,g;return c&&c<a.width&&(r.width=c,"left"===n?(r.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),r.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):r.left+="right"===n?a.width-c:(a.width-c)/2,[s,o]=On(A,e,r,i,{size:A}),s===A&&o&&(l=i,g=o,l.map(((t,e)=>[t,g[e]]))).every((([t,e])=>t===e))&&(a=r)),a};var Ln={};He(Ln,"svgObjectURL",(()=>Vn)),He(Ln,"LayoutElementFactory",(()=>Wn));const zn=(t,e)=>{const A=t.layoutState.elements.filter((t=>t.layer===e)),i=Math.max(...A.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(i,0)+1},jn=async t=>new Promise((e=>{VA(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),Vn=async t=>{const e=zA().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const A=(new XMLSerializer).serializeToString(e),i=document.createElement("canvas"),n=i.getContext("2d"),a=await ke.from(n,A,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),r=e.getAttribute("width"),s=e.getAttribute("height"),o=2048;if(s&&r){const t=parseFloat(s),e=parseFloat(r)/t;e>1?a.resize(o,o/e):a.resize(o*e,o)}else a.resize(o,o);return await a.render(),await(async t=>new Promise(((e,A)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((A=>{if(!A){if(0===t.width||0===t.height)throw new Error(`Canvas dimensions are invalid (${t.width},${t.height})`);if(t.width*t.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${t.width},${t.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}e(URL.createObjectURL(A))}))}catch(t){A(t)}})))(i)},Kn=async(t,e,A,i)=>{const n=t.layoutState.layout.useEditableArea&&t.layoutState.layout.editableArea||{width:t.layoutState.layout.width,height:t.layoutState.layout.height,x:0,y:0},a=n.width<n.height?n.width:n.height,r=t.layoutState.layout.useEditableArea?a/1.3:a/2,s={top:n.y+n.height/2-r/2,left:n.x+n.width/2-r/2,width:r,height:r,rotation:0,panelId:t.layoutState.layout.panelId};if(A&&e===ze.Illustration){const t=await Ui(await jn(A)),e=zA().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const i=s.height,n=e.split(" "),a=(parseFloat(n[2])||1)/(parseFloat(n[3])||1);s.height=s.width/a,s.top+=(i-s.height)/2}if(A&&e===ze.Image){const t=s.height,e=await jA(A),i=await Mn(e),n=i.width/i.height;s.height=s.width/n,s.top+=(t-s.height)/2}if(A&&e===ze.Textbox&&i?.text&&i?.fontScale){const t={assetUrl:A,name:(await ai(A)).names.fullName.en},e=si(t),a=Bi(i.text,i?.fontScale,e);s.width=Math.min(a,.85*n.width),s.left=n.x+n.width/2-s.width/2}return s};class Wn{static async getFrame(t,e){const A=await bn(e.region,e.src),i=await Nn(A),n=e.region||await Kn(t,ze.Frame);return{id:Te(),x:n.left,y:n.top,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||zn(t,n.layer||0),rotation:n.rotation,scaleX:n.width/i.width,scaleY:n.height/i.height,path:i.path,type:ze.Frame,disablePlaceholder:e.configuration.disablePlaceholder,focalBlur:e.configuration.focalBlur,focalBlurStrength:e.configuration.focalBlurStrength,focalBlurRadius:e.configuration.focalBlurRadius,forceImageCover:e.configuration.forceImageCover,pattern:void 0,immutable:n.immutable}}static async getImage(t,e){const A=e.region||await Kn(t,ze.Image,e.src);return{id:Te(),src:e.src,type:ze.Image,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||zn(t,A.layer||0),immutable:A.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:A,fontSrc:i,designInputStep:n}=e,a=await ai(i),r={assetUrl:i,name:a.names.fullName.en},s=n?.text||A.defaultText||"",o=A.replaceableText?A.replaceableText.replace("{{}}",s):s,c=Ci(o,{vertical:A.vertical,uppercase:A.uppercase}),l=e.region||await Kn(t,ze.Textbox,i,{text:c,fontScale:A.size?A.size/a.unitsPerEm:void 0}),g=Di({id:Te(),type:ze.Textbox,x:l.left,y:l.top,width:l.width,height:l.height,align:Qi(A.textAlign,A.vertical),curved:A.curved,fill:n?.color||A.colour||"#000000",fontData:r,layer:l.layer||0,layerIndex:l.layerIndex||zn(t,l.layer||0),paths:A.paths,rotation:l.rotation,vertical:A.vertical,verticalAlign:A.verticalAlign||"middle",algorithm:We.Traditional,fontSize:A.size||Math.max(Math.round(.025*l.height),1),text:c,input:s},c),h=ui({...l,height:g.height},r,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:h.left,y:h.top+(l.height-h.height)/2,width:h.width,height:h.height}}static async getShape(t,e){const A=`\n <svg\n xmlns="http://www.w3.org/2000/svg"\n xmlnsXlink="http://www.w3.org/1999/xlink"\n xmlSpace="preserve"\n preserveAspectRatio="none"\n version="1.1"\n width="1"\n height="1"\n viewBox="0 0 1 1"\n >\n <rect\n x="0"\n y="0"\n width="1"\n height="1"\n class="spiff-fill-shape"\n fill="${e.color}"\n />\n </svg>\n `,i={};i["spiff-fill-shape"]={browserValue:e.color};const n=e.region||await Kn(t,ze.Illustration),a=Te();return{stepRegion:e.region,colors:i,id:a,svg:A,type:ze.Illustration,y:n.top,x:n.left,rotation:n.rotation,width:n.width,height:n.height,layer:n.layer||0,layerIndex:n.layerIndex||zn(t,n.layer||0),immutable:n.immutable}}static async getIllustration(t,e){const A=e.region||await Kn(t,ze.Illustration,e.src),i=await Ui(await jn(e.src)),n=await Vn(i.svg),a=Te();return{cachedObjectURL:n,stepRegion:e.region,colors:i.colors,id:a,src:e.src,svg:i.svg,type:ze.Illustration,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||zn(t,A.layer||0),immutable:A.immutable}}}function Xn(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class qn extends Error{constructor(t){super(t),this.name=this.constructor.name}}class Zn extends qn{constructor(t){super(`ConfigurationError - ${t}`)}}class $n extends Zn{constructor(t){super(`Option not Configured: ${t.stepTitle}`),Xn(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class _n extends Zn{constructor(t){super(`Panel not Found: ${t.panelId}`),Xn(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class ta extends Zn{constructor(t){super(`Asset not found for variant: ${t.name}`),Xn(this,"variant",void 0),this.variant=t}}class ea extends Zn{constructor(t){super(`Resource not found for asset: ${t.name}`),Xn(this,"asset",void 0),this.asset=t}}class Aa extends Zn{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),Xn(this,"step",void 0),this.step=t}}class ia extends qn{constructor(t){super(`ImplementationError - ${t}`)}}class na extends ia{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class aa extends ia{constructor(t){super(`Parsing Error: ${t}`)}}class ra extends ia{constructor(t){super(`Client Error: ${t}`)}}class sa extends ia{constructor(t){super(`Resource Generation Failed: ${t}`)}}function oa(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class ca{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}class la{constructor(){oa(this,"storage",new Map)}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}const ga=(()=>{try{return localStorage?new ca:new la}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new la}})();function ha(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const da=new class{constructor(){ha(this,"defaultServerUrl","https://api.spiff.com.au"),ha(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ha(this,"defaultHubUrl","https://hub.spiff.com.au"),ha(this,"serverUrl",void 0),ha(this,"servicesApiUrl",void 0),ha(this,"hubUrl",void 0),ha(this,"serverUrlCallbacks",void 0),this.serverUrl=this.defaultServerUrl,this.servicesApiUrl=this.defaultServicesApiUrl,this.hubUrl=this.defaultHubUrl,this.serverUrlCallbacks=[]}getServerUrl(){return this.serverUrl}getServicesApiUrl(){return this.servicesApiUrl}getHubUrl(){return this.hubUrl}setServerUrl(t){this.serverUrl=t,this.serverUrlCallbacks.forEach((t=>t()))}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}};function ua(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let wa;const Ba=t=>{wa=t};let pa;const Ea=t=>{pa=t};let ma;const Ca=t=>{ma=t};let fa;const Qa=new class{constructor(){ua(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),da.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${da.getServerUrl()}/graphql`,fetch:C.fetch}),A=(0,E.setContext)((async(t,{headers:e})=>{const A=e||{},i=await(async()=>{const t={applicationKey:fa,bundleOwnerId:pa,customerToken:ma,transactionOwnerId:wa};return"undefined"!=typeof window&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await new Promise((t=>{const e=da.getHubUrl(),A=i=>{i.origin===e&&(window.removeEventListener("message",A),t(i.data))};window.parent!==window&&(window.addEventListener("message",A,!1),window.parent.postMessage("ready",e))})),...t}:t})();return i.bearer&&(A.Authorization=`Bearer ${i.bearer}`),i.partnerId&&(A.partnerId=i.partnerId),i.activeIntegration&&(A.activeIntegration=i.activeIntegration),i.transactionOwnerId&&(A.transactionOwnerId=i.transactionOwnerId),i.customerToken&&(A.customerToken=i.customerToken),i.applicationKey&&(A["X-Application-Key"]=i.applicationKey),i.bundleOwnerId&&(A.bundleOwnerId=i.bundleOwnerId),{headers:A}})),i=(0,m.onError)((({operation:t,graphQLErrors:e,networkError:A})=>{(e||[]).forEach((({message:e,locations:A,path:i})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(A,null,2)}, Path: ${i}`),console.log("Variables:"+JSON.stringify(t.variables))})),A&&console.log("GraphQL Network error")}));const n=new(0,t.InMemoryCache)({addTypename:!1,typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(t=null)=>t,merge:(t,e)=>e||t||null},transactionOwnerId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},customLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowFooterLogoLink:{read:(t=null)=>t,merge:(t,e)=>e||t||null},workflowState:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkSourceUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalDesignProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},externalCartProductVariantId:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lastSyncedAt:{read:(t=null)=>t,merge:(t,e)=>e||t||null},lineItem:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},WorkflowProduct:{fields:{isPresent:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}},Product:{fields:{imageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},overlayImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},preloadImageUrl:{read:(t=null)=>t,merge:(t,e)=>e||t||null},weight:{read:(t=null)=>t,merge:(t,e)=>e||t||null},conversionConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null},bulkConfiguration:{read:(t=null)=>t,merge:(t,e)=>e||t||null}}}}});return new(0,t.ApolloClient)({link:(0,t.from)([i,A,e]),cache:n,name:"Core"})}};function ya(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Da=t.gql`
2
2
  fragment AssetFields on Asset {
3
3
  name
4
4
  key
@@ -487,7 +487,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
487
487
  id
488
488
  }
489
489
  }
490
- `;class Mo extends yo{constructor(t,e){super(t,e),Do(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await Qa.getShadowGraphqlClient().mutate({mutation:xo,variables:{transactionId:this.manager.getTransaction().id,designName:t}});const e=this.manager.getTransaction();this.manager.setTransaction({...e,designName:t})}addVariationRecord(){const t=this.manager.addVariationRecord({transactionId:this.transaction.id,values:[]});return this.manager.setCurrentVariationRecord(t),t}updateBulkIsConnected(t){this.manager.updateStorage(this.getId(),{bulkIsConnected:t})}openBulkSourceUrl(){window.open(this.transaction.bulkSourceUrl,"_blank")}async sendGoogleSheetLinkToEmail(t){await Qa.getShadowGraphqlClient().mutate({mutation:Io,variables:{id:this.transaction.id,details:{emailAddress:t},type:"Owner"}}),this.openBulkSourceUrl()}deleteVariationRecord(t){this.manager.removeVariationRecord(t)}getAspects(){return this.step.data.aspects}}class vo extends yo{constructor(t,e){super(t,e)}async selectVariant(t){if(this.getCurrentVariant()!==t)return Ao.selectVariant(this.step,t.getResource(),this.manager.getRegionElements(this.step.stepName)||[],(t=>this.setUpdateState(t)),this.manager)}getColors(){const t=this.manager.getRegionElements(this.step.stepName)||[];if(0!==t.length)try{return ji(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,e){const A=new Map;return A.set(t,e),Ao.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),A)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?Ao.availableColors(this.step,this.manager):Promise.resolve([])}hasVaryingSelection(){return this.step.data.varySelection}hasVaryingColors(){return this.step.data.varyColors}isColorPickerEnabled(){return this.step.data.colorPickerEnabled}}class So extends yo{constructor(t,e){super(t,e)}selectVariant(t){return io.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Fo extends yo{constructor(t,e){super(t,e)}selectVariant(t){return no.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class bo extends yo{constructor(t,e){super(t,e)}selectVariant(t){return ro.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Yo extends yo{constructor(t,e){super(t,e)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await so.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.option?.displayType}}class Po extends yo{constructor(t,e){super(t,e)}selectVariant(t){const e=t.getResource();return oo.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return oo.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return oo.availableColours(this.step)}}class No extends yo{constructor(t,e){super(t,e)}async selectVariant(t){uo.selectVariant(this.step,t.getResource(),this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Bo.Error,stepID:this.step.stepName}]);else{const t=this.manager.getInformationResults().filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}}),(t=>{}))}getAvailableFillColors(){return this.step.data.colorPickerEnabled?uo.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await uo.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return uo.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await uo.changeFillImage(this.step,t,e,this.manager)}getFillImage(){return this.manager.getStepStorage(this.step.stepName)?.fillImage}setFullTextCustomization(t){const e=this.manager.getStepStorage(this.step.stepName)?.inputText||"",A=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",e):e,i=t?A:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:i,defaultCleared:!1});return this.setText(i)}setText(t){const e={input:t},A=uo.findLayoutElements(this.manager,this.step),i=uo.filterUnsupportedCharacters(t,A[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&i.length>this.step.data.maxLength||(e.input=i);const n=A.length<=0,a=n?{inputText:i,text:i}:{inputText:i};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:i}),n)return e;const{command:r,errors:s,helperText:o}=uo.updateInputText(i,A,this.step,this.manager);r&&this.manager.getCommandDispatcher()(r);const c=this.manager.getInformationResults(),l=s[0]?.localizationKey;if(l)this.manager.setInformationResults([...c,{message:`${l} - ${this.step.stepTitle}`,messageType:Bo.Error,stepID:this.step.stepName}]);else{const t=c.filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}return e.helperText=l||o,e.errorText=l,e}getText(){const t=this.step.data.defaultText;return this.manager.getStepStorage(this.step.stepName)?.text||t||""}isReplaceable(){return this.step.data.userCanReplaceText}clearDefaultTextIfNecessary(){if(!this.manager.getStepStorage(this.step.stepName)?.defaultCleared&&this.step.data.deleteDefaultOnFocus){const t=this.setText("");return this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""}),t}}hasVaryingText(){return this.step.data.varyText}hasVaryingColor(){return this.step.data.varyColor}hasVaryingSelection(){return this.step.data.varySelection}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(void 0===t)return;return t-this.getText().length}}class Ro{static get(t,e){switch(e.type){case rA.Question:return new Yo(t,e);case rA.Text:return new No(t,e);case rA.Illustration:return new vo(t,e);case rA.Picture:return new bo(t,e);case rA.Shape:return new Po(t,e);case rA.Material:return new So(t,e);case rA.Model:return new Fo(t,e);case rA.Frame:return new Hc(t,e);case rA.Bulk:return new Mo(t,e);default:throw new na(`Step type ${e.type} not yet supported in Core SDK`)}}}function ko(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Ho=t.gql`
490
+ `;class Mo extends yo{constructor(t,e){super(t,e),Do(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await Qa.getShadowGraphqlClient().mutate({mutation:xo,variables:{transactionId:this.manager.getTransaction().id,designName:t}});const e=this.manager.getTransaction();this.manager.setTransaction({...e,designName:t})}addVariationRecord(){const t=this.manager.addVariationRecord({transactionId:this.transaction.id,values:[]});return this.manager.setCurrentVariationRecord(t),t}updateBulkIsConnected(t){this.manager.updateStorage(this.getId(),{bulkIsConnected:t})}openBulkSourceUrl(){window.open(this.transaction.bulkSourceUrl,"_blank")}async sendGoogleSheetLinkToEmail(t){await Qa.getShadowGraphqlClient().mutate({mutation:Io,variables:{id:this.transaction.id,details:{emailAddress:t},type:"Owner"}}),this.openBulkSourceUrl()}deleteVariationRecord(t){this.manager.removeVariationRecord(t)}getAspects(){return this.step.data.aspects}}class vo extends yo{constructor(t,e){super(t,e)}async selectVariant(t){if(this.getCurrentVariant()!==t)return Ao.selectVariant(this.step,t.getResource(),this.manager.getRegionElements(this.step.stepName)||[],(t=>this.setUpdateState(t)),this.manager)}getColors(){const t=this.manager.getRegionElements(this.step.stepName)||[];if(0!==t.length)try{return ji(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,e){const A=new Map;return A.set(t,e),Ao.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),A)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?Ao.availableColors(this.step,this.manager):Promise.resolve([])}hasVaryingSelection(){return this.step.data.varySelection}hasVaryingColors(){return this.step.data.varyColors}isColorPickerEnabled(){return this.step.data.colorPickerEnabled}}class So extends yo{constructor(t,e){super(t,e)}selectVariant(t){return io.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Fo extends yo{constructor(t,e){super(t,e)}selectVariant(t){return no.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class bo extends yo{constructor(t,e){super(t,e)}selectVariant(t){return ro.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Yo extends yo{constructor(t,e){super(t,e)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await so.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.option?.displayType}}class Po extends yo{constructor(t,e){super(t,e)}selectVariant(t){const e=t.getResource();return oo.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return oo.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return oo.availableColours(this.step)}}class No extends yo{constructor(t,e){super(t,e)}async selectVariant(t){uo.selectVariant(this.step,t.getResource(),this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Bo.Error,stepID:this.step.stepName}]);else{const t=this.manager.getInformationResults().filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}}),(t=>{}))}getAvailableFillColors(){return this.step.data.colorPickerEnabled?uo.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await uo.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return uo.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await uo.changeFillImage(this.step,t,e,this.manager)}getFillImage(){return this.manager.getStepStorage(this.step.stepName)?.fillImage}setFullTextCustomization(t){const e=this.manager.getStepStorage(this.step.stepName)?.inputText||"",A=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",e):e,i=t?A:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:i,defaultCleared:!1});return this.setText(i)}setText(t){const e={input:t},A=uo.findLayoutElements(this.manager,this.step),i=uo.filterUnsupportedCharacters(t,A[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&i.length>this.step.data.maxLength||(e.input=i);const n=A.length<=0,a=n?{inputText:i,text:i}:{inputText:i};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:i}),n)return e;const{command:r,errors:s,helperText:o}=uo.updateInputText(i,A,this.step,this.manager);r&&this.manager.getCommandDispatcher()(r);const c=this.manager.getInformationResults(),l=s[0]?.localizationKey;if(l)this.manager.setInformationResults([...c,{message:`${l} - ${this.step.stepTitle}`,messageType:Bo.Error,stepID:this.step.stepName}]);else{const t=c.filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}return e.helperText=l||o,e.errorText=l,e}getText(){const t=this.step.data.defaultText;return this.manager.getStepStorage(this.step.stepName)?.text||t||""}isReplaceable(){return this.step.data.userCanReplaceText}clearDefaultTextIfNecessary(){if(!this.manager.getStepStorage(this.step.stepName)?.defaultCleared&&this.step.data.deleteDefaultOnFocus){const t=this.setText("");return this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""}),t}}hasVaryingText(){return this.step.data.varyText}hasVaryingColor(){return this.step.data.varyColor}hasVaryingSelection(){return this.step.data.varySelection}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(void 0===t)return;return t-this.getText().length}}class Ro{static get(t,e){switch(e.type){case rA.Question:return new Yo(t,e);case rA.Text:return new No(t,e);case rA.Illustration:return new vo(t,e);case rA.Picture:return new bo(t,e);case rA.Shape:return new Po(t,e);case rA.Material:return new So(t,e);case rA.Model:return new Fo(t,e);case rA.Frame:return new Uc(t,e);case rA.Bulk:return new Mo(t,e);default:throw new na(`Step type ${e.type} not yet supported in Core SDK`)}}}function ko(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Ho=t.gql`
491
491
  mutation CreateDesign(
492
492
  $name: String!
493
493
  $layouts: [LayoutInput]!
@@ -519,7 +519,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
519
519
  }
520
520
  }
521
521
  }
522
- `,Uo=(t,e,A)=>{const i={};return e.steps.forEach((e=>{Object.assign(i,(e=>{const i={};if("Frame"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideImageInCart&&A)return i;i[`${e.stepTitle} image`]=n.image}if("Illustration"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideColorsInCart&&A||!n.colors)return i;if(n.colors.length>0){const t=n.colors.join(", ").toUpperCase();i[`${e.stepTitle} colors`]=t}}if("Module"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideTextInCart&&A)return i;i[`${e.stepTitle} text`]=n.text}if("Text"===e.type){const n=t[e.stepName];if(!n)return i;const a=e.data;a.hideTextInCart&&A||(i[`${e.stepTitle} text`]=n.text),!n.color||a.hideColorInCart&&A||(i[`${e.stepTitle} color`]=n.color)}return i})(e))})),i},Go=(t,e,A,i,n,a,r,s,o,c)=>{const l=(ga.getMap("transactionOwnerIds")||new Map).get(t.id),g={baseCost:A,designProductId:t.externalDesignProductId,designProductVariantId:t.externalDesignProductVariantId,event:"onComplete",exportedData:a,externalCartProductId:t.externalCartProductId,externalCartProductVariantId:t.externalCartProductVariantId,lineItemImageUrl:r||"",optionsCost:i,processExecutionId:c,transactionId:t.id,transactionOwnerId:l,weight:e.weight,workflowViewerLink:t.workflowViewerLink||"",workflowViewerReadOnlyLink:t.workflowViewerReadOnlyLink||""};return n&&(g.metadata=n),s&&(g.selectedVariants=s),o&&(g.sku=o),g},To=async(t,e,A,i,n,a,r,s)=>{const o=t.product?.basePrice||0,c=t.priceModifierTotal||0,l=((t,e,A,i)=>{const n={};let a;if(A){a=Uo(A,e,!1);for(const t of Object.keys(a))n[t]={value:a[t],priceModifier:0}}else if(i){a=i;for(const t of Object.keys(a))n[t]={value:a[t],priceModifier:0}}for(const A of Object.keys(t)){const i=t[A],a=e.steps.find((t=>t.stepTitle===A));if(1===i.length)n[`${a?.stepTitle} selection`]={value:i[0].name,priceModifier:i[0].priceModifier};else if(i.length>1)for(let t=0;t<i.length;t++)n[`${a?.stepTitle} selection ${t+1}`]={value:i[t].name,priceModifier:i[t].priceModifier}}return n})(i,A,void 0,a);return Go(t,e,o,c,a,l,r,i,n,s)},Oo=async(t,e,A,i,n,a,r,s,o,c,l,g,h)=>{o("workflow.steps.finish.finalize.buildingLayouts"),await t.outstandingRequestsPromise();const d=Qa.getShadowGraphqlClient(),u=await d.query({query:ks,variables:{id:a.id},fetchPolicy:"no-cache",errorPolicy:"all"}),w=u.data?.transactions[0].workflowState;!u.errors&&w||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(i())),u.errors&&u.errors.forEach((t=>{u.errors&&console.log("Server Error:",t.message)})),await t.updateStateWithServerImmediate(i),console.log("Server state is undefined @ Workflow completion"));const B=t.getPreviewService(),p=e?.finalizeStepConfig?.lookAtAnimation,E=B&&100===B.getSceneInitializationProgress()&&e.showModelOnFinishStep&&!!p,m=h&&Uo(h,e,!0),C=h&&Uo(h,e,!1),f=async t=>{const A={};let i=0;if(Object.keys(r).length>0)for(const n of Object.keys(r)){const a=r[n],s=e.steps.find((t=>t.stepName===n));for(let e=0;e<a.selections.length;++e){const n=a.selections[e];if(s&&(!t||s.option&&(s.option.variants||[]).length>1&&!s.data.hideSelectionInCart&&!s.data.hideSelectionsInCart)){const t=s.stepTitle;A[t]?A[t].push({id:n.id||"",name:n.name,priceModifier:n.priceModifier}):A[t]=[{id:n.id||"",name:n.name,priceModifier:n.priceModifier}]}i+=n.priceModifier}}return[A,i]},[Q]=await f(!0),y=Object.fromEntries(Object.keys(Q).map((t=>[t,Q[t].map((t=>t.id))]))),[D]=await f(!1),I=Object.fromEntries(Object.keys(D).map((t=>[t,D[t].map((t=>t.id))]))),x=await g(E);o("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(l);const M=await(async t=>(await Qa.getShadowGraphqlClient().mutate({mutation:Ho,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:t.name,layouts:t.layouts,workflowId:t.workflowId,transactionId:t.transactionId,previewImage:t.previewImage,useThreeDimPreview:t.useThreeDimPreview,metadata:t.metadata,selectedVariants:t.selectedVariants}})).data?.designCreate)((()=>{const t={name:s,layouts:A.map((t=>({index:t.index,panelId:t.panelId}))),workflowId:e.id,transactionId:a.id,useThreeDimPreview:!!E,previewImage:x};if(C){const e=[];for(const[t,A]of Object.entries(C))e.push({key:t,value:A});t.metadata=e}if(y){const e=[];for(const[t,A]of Object.entries(I))e.push({key:t,ids:A});t.selectedVariants=e}return t})()),v=M?.transaction?.previewImageLink;o("workflow.steps.finish.finalize.updatingTransaction");const S=(await Qa.getShadowGraphqlClient().query({query:Rs,variables:{id:a.id}})).data.transactions[0];return a.bulk?((t,e,A,i)=>{const n=(t.product?.basePrice||0)*(t.variationsCount||0),a=t.priceModifierTotal||0,r={items:{value:t.variationsCount?`${t.variationsCount}`:"0",priceModifier:0}};return Go(t,e,n,a,void 0,r,A,void 0,void 0,i)})(S,n,v,M?.processExecution?.id):await To(S,n,e,Q,M?.sku,m,v,M?.processExecution?.id)};let Jo;var Lo;(Lo=Jo||(Jo={})).Local="Local",Lo.Remote="Remote";const zo=new class{constructor(){ko(this,"localPersistenceKey","designTransactions"),ko(this,"storageMethod",Jo.Local),ko(this,"designSavedListeners",[])}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter((e=>e!==t))}async getSavedDesigns(){if(this.storageMethod===Jo.Local){const t=ga.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new na("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find((e=>e.transactionId===t))}async addDesign(t){const e=(await this.getSavedDesigns()).filter((e=>e.transactionId!==t.transactionId));e.unshift(t),await this.setDesigns(e),this.designSavedListeners.forEach((e=>e(t)))}async renameDesign(t,e){const A=await this.getSavedDesigns(),i=A.find((e=>e.transactionId===t));if(!i)throw new Error(`No saved design for transaction ${t}.`);i.title=e,await this.setDesigns(A)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter((e=>e.transactionId!==t)))}async setDesigns(t){if(this.storageMethod!==Jo.Local)throw new na("Unexpected storage method requested");ga.set(this.localPersistenceKey,JSON.stringify(t))}};function jo(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Vo{constructor(t,e){if(jo(this,"client",void 0),jo(this,"commandContext",void 0),jo(this,"workflowManager",void 0),jo(this,"isReadOnly",void 0),jo(this,"renderableScenes",[]),jo(this,"renderableSceneCallbacks",[]),jo(this,"debouncedSavedDesignUpdate",F(I)((async()=>{await zo.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),jo(this,"getCanvasObjectURLAsync",(async t=>new Promise(((e,A)=>{try{t.toBlob((t=>{if(t){const A=URL.createObjectURL(t);e(A)}}))}catch(t){A(t)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const A=e.layouts;this.commandContext=new Ti,this.commandContext.initialize(A,e.reloadedState),this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.workflowManager=new mo(e.workflow,e.product.profanities?.map((t=>t.word))||[],A,this.commandContext,(t=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(t)}),e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly,e.modelContainer,e.isReloadedTransaction),this.workflowManager.addSelectionCallback((t=>{const e=t.traversableScenes.map((t=>{const e=t.renderableSteps.map((t=>t.stepName));return{id:t.name,title:t.title,renderableSteps:e}}));this.renderableScenes=e,this.renderableSceneCallbacks.forEach((t=>t(e)))}))}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async updateVariationRecords(t){await Qa.getShadowGraphqlClient().mutate({mutation:Ns,variables:{transactionId:this.workflowManager.getTransaction().id,updates:t.map((t=>({recordNumber:t.recordNumber,values:t.values.map((t=>({aspect:t.aspect,stepName:t.stepName,value:t.value})))})))}})}async createPreviewImage(t,e){const A=this.workflowManager.getWorkflow(),i=A?.finalizeStepConfig?.lookAtAnimation;if(t){if(!i)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,i))||""}const n=document.createElement("canvas");let a=2048;e&&e<=2048&&(a=e),n.width=a,n.height=a;const r=this.commandContext.getAllLayouts(),s=A.defaultPreviewPanelIndex||0,o=A.panels[s],c=r.find((t=>t.layoutState?.layout.panelId===o?.name))||r[0],l=c.layoutState.layout.previewRegion?{x:c.layoutState.layout.previewRegion.left,y:c.layoutState.layout.previewRegion.top,width:c.layoutState.layout.previewRegion.width,height:c.layoutState.layout.previewRegion.height}:{x:0,y:0,width:c.layoutState.layout.width,height:c.layoutState.layout.height},g=this.commandContext.getLayoutById(c.layoutState.layout.id),h=n.getContext("2d");if(!h)throw new sa("Failed to obtain 2D context for preview image creation");const d=Ji(g.layoutState.layout,g.layoutState.elements,{renderingConfiguration:{purpose:Ve.Print,region:{left:l.x,top:l.y,width:l.width,height:l.height}}}),u=F(Q).renderToStaticMarkup(d),w=await ke.from(h,u,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await w.render();const B=await this.getCanvasObjectURLAsync(n);return n.toDataURL(B)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t));if(e&&this.stepHasHandle(e))return Ro.get(this.getWorkflowManager(),e)}getSteps(){return this.getScenes().flatMap((t=>this.getStepsByScene(t)))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map((t=>({id:t.id,name:t.name,stepIds:t.stepNames})))}getSelectionPriceSubunits(){const t=this.getWorkflowManager().getWorkflowSelections();let e=0;return Object.values(t).forEach((t=>{e+=t.selections.map((t=>t.priceModifier)).reduce(((t,e)=>t+e))})),e}getBasePriceSubunits(){return this.getWorkflowManager().getProduct().basePrice||0}getTotalPriceSubunits(){return this.getBasePriceSubunits()+this.getSelectionPriceSubunits()}getBulkStep(){if(this.getWorkflowManager().getTransaction().bulk){const t=this.getWorkflowManager().getProduct().bulkConfiguration,e={type:rA.Bulk,stepName:"Bulk",stepTitle:t?.stepTitle??"workflow.steps.bulk.title",helpText:t?.helpText,data:{aspects:Hs(this.getWorkflowManager().getWorkflow())},conditions:[]};return Ro.get(this.getWorkflowManager(),e)}}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepTitle===t));if(e&&this.stepHasHandle(e))return Ro.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter((e=>e.type===t)).map((t=>Ro.get(this.getWorkflowManager(),t)))}getStepsByScene(t){if(!this.getWorkflowManager().getWorkflow().stepGroups.find((e=>e.name===t.name)))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return t.stepIds.map((t=>this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t)))).filter((t=>this.stepHasHandle(t))).map((t=>Ro.get(this.getWorkflowManager(),t)))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){const e=(await Qa.getShadowGraphqlClient().mutate({mutation:Io,variables:{id:this.getWorkflowManager().getTransaction().id,details:t,type:"Owner"}})).data?.transactionAddStakeholder?.stakeholders?.find((e=>e.customer?.emailAddress===t.emailAddress));if(e?.customer){this.getWorkflowManager().setTransactionCustomer(e.customer);const t=ga.getMap("transactionCustomerIds")||new Map;t.set(this.getWorkflowManager().getTransaction().id,e.customer.id),ga.setMap("transactionCustomerIds",t)}}attachRenderableSceneListener(t){this.renderableSceneCallbacks.push(t),t(this.renderableScenes)}detachRenderableSceneListener(t){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter((e=>e!==t))}async save(t){if(!this.getCommandContext().getState())throw new na("State undefined!");const e={title:await(async()=>{if(t)return t;const e=this.getWorkflowManager().getTransaction().id,A=(await zo.getSavedDesigns()).find((t=>t.transactionId===e))?.title;return A||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await zo.addDesign(e),e}async copy(){const t=F(e)(this.getCommandContext().getState());if(!t)throw new na("Internal state is undefined! Cannot copy experience!");const A=JSON.stringify(t.transaction),i=this.getWorkflowManager().getWorkflow(),n=new bc({}),a=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!a)throw new na("Integration product id is undefined!");await n.initFromIntegrationProduct(a);return await n.getWorkflowExperience(i.id,A,void 0)}async onDesignFinished(t){return Oo(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),(()=>this.commandContext.getState()),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,t||(()=>{}),(t=>this.updateVariationRecords(t)),this.workflowManager.getVariationRecords(),(t=>this.createPreviewImage(t)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==rA.SilentIllustration&&t.type!==rA.ProductOverlay}getExportedData(){const t=new Map,e=this.getWorkflowManager().getWorkflowMetadata(),A=this.getWorkflowManager().getWorkflowSelections();return Object.keys(e).forEach((A=>{const i=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===A));if(!i)return;t.has(i.stepTitle)||t.set(i.stepTitle,{});const n=e[A];Object.keys(n).forEach((e=>{t.get(i.stepTitle)[e]=n[e]}))})),Object.keys(A)?.forEach((e=>{const i=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===e));i&&(t.has(i.stepTitle)||t.set(i.stepTitle,{}),t.get(i.stepTitle).selection=A[e].selections[0].name)})),t}}const Ko=M.gql`
522
+ `,Uo=(t,e,A)=>{const i={};return e.steps.forEach((e=>{Object.assign(i,(e=>{const i={};if("Frame"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideImageInCart&&A)return i;i[`${e.stepTitle} image`]=n.image}if("Illustration"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideColorsInCart&&A||!n.colors)return i;if(n.colors.length>0){const t=n.colors.join(", ").toUpperCase();i[`${e.stepTitle} colors`]=t}}if("Module"===e.type){const n=t[e.stepName],a=e.data;if(!n||a.hideTextInCart&&A)return i;i[`${e.stepTitle} text`]=n.text}if("Text"===e.type){const n=t[e.stepName];if(!n)return i;const a=e.data;a.hideTextInCart&&A||(i[`${e.stepTitle} text`]=n.text),!n.color||a.hideColorInCart&&A||(i[`${e.stepTitle} color`]=n.color)}return i})(e))})),i},Go=(t,e,A,i,n,a,r,s,o,c)=>{const l=(ga.getMap("transactionOwnerIds")||new Map).get(t.id),g={baseCost:A,designProductId:t.externalDesignProductId,designProductVariantId:t.externalDesignProductVariantId,event:"onComplete",exportedData:a,externalCartProductId:t.externalCartProductId,externalCartProductVariantId:t.externalCartProductVariantId,lineItemImageUrl:r||"",optionsCost:i,processExecutionId:c,transactionId:t.id,transactionOwnerId:l,weight:e.weight,workflowViewerLink:t.workflowViewerLink||"",workflowViewerReadOnlyLink:t.workflowViewerReadOnlyLink||""};return n&&(g.metadata=n),s&&(g.selectedVariants=s),o&&(g.sku=o),g},To=async(t,e,A,i,n,a,r,s)=>{const o=t.product?.basePrice||0,c=t.priceModifierTotal||0,l=((t,e,A,i)=>{const n={};let a;if(A){a=Uo(A,e,!1);for(const t of Object.keys(a))n[t]={value:a[t],priceModifier:0}}else if(i){a=i;for(const t of Object.keys(a))n[t]={value:a[t],priceModifier:0}}for(const A of Object.keys(t)){const i=t[A],a=e.steps.find((t=>t.stepTitle===A));if(1===i.length)n[`${a?.stepTitle} selection`]={value:i[0].name,priceModifier:i[0].priceModifier};else if(i.length>1)for(let t=0;t<i.length;t++)n[`${a?.stepTitle} selection ${t+1}`]={value:i[t].name,priceModifier:i[t].priceModifier}}return n})(i,A,void 0,a);return Go(t,e,o,c,a,l,r,i,n,s)},Oo=async(t,e,A,i,n,a,r,s,o,c,l,g,h)=>{o("workflow.steps.finish.finalize.buildingLayouts"),await t.outstandingRequestsPromise();const d=Qa.getShadowGraphqlClient(),u=await d.query({query:ks,variables:{id:a.id},fetchPolicy:"no-cache",errorPolicy:"all"}),w=u.data?.transactions[0].workflowState;!u.errors&&w||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(i())),u.errors&&u.errors.forEach((t=>{u.errors&&console.log("Server Error:",t.message)})),await t.updateStateWithServerImmediate(i),console.log("Server state is undefined @ Workflow completion"));const B=t.getPreviewService(),p=e?.finalizeStepConfig?.lookAtAnimation,E=B&&100===B.getSceneInitializationProgress()&&e.showModelOnFinishStep&&!!p,m=h&&Uo(h,e,!0),C=h&&Uo(h,e,!1),f=async t=>{const A={};let i=0;if(Object.keys(r).length>0)for(const n of Object.keys(r)){const a=r[n],s=e.steps.find((t=>t.stepName===n));for(let e=0;e<a.selections.length;++e){const n=a.selections[e];if(s&&(!t||s.option&&(s.option.variants||[]).length>1&&!s.data.hideSelectionInCart&&!s.data.hideSelectionsInCart)){const t=s.stepTitle;A[t]?A[t].push({id:n.id||"",name:n.name,priceModifier:n.priceModifier}):A[t]=[{id:n.id||"",name:n.name,priceModifier:n.priceModifier}]}i+=n.priceModifier}}return[A,i]},[Q]=await f(!0),y=Object.fromEntries(Object.keys(Q).map((t=>[t,Q[t].map((t=>t.id))]))),[D]=await f(!1),I=Object.fromEntries(Object.keys(D).map((t=>[t,D[t].map((t=>t.id))]))),x=await g(E);o("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(l);const M=await(async t=>(await Qa.getShadowGraphqlClient().mutate({mutation:Ho,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:t.name,layouts:t.layouts,workflowId:t.workflowId,transactionId:t.transactionId,previewImage:t.previewImage,useThreeDimPreview:t.useThreeDimPreview,metadata:t.metadata,selectedVariants:t.selectedVariants}})).data?.designCreate)((()=>{const t={name:s,layouts:A.map((t=>({index:t.index,panelId:t.panelId}))),workflowId:e.id,transactionId:a.id,useThreeDimPreview:!!E,previewImage:x};if(C){const e=[];for(const[t,A]of Object.entries(C))e.push({key:t,value:A});t.metadata=e}if(y){const e=[];for(const[t,A]of Object.entries(I))e.push({key:t,ids:A});t.selectedVariants=e}return t})()),v=M?.transaction?.previewImageLink;o("workflow.steps.finish.finalize.updatingTransaction");const S=(await Qa.getShadowGraphqlClient().query({query:Rs,variables:{id:a.id}})).data.transactions[0];return a.bulk?((t,e,A,i)=>{const n=(t.product?.basePrice||0)*(t.variationsCount||0),a=t.priceModifierTotal||0,r={items:{value:t.variationsCount?`${t.variationsCount}`:"0",priceModifier:0}};return Go(t,e,n,a,void 0,r,A,void 0,void 0,i)})(S,n,v,M?.processExecution?.id):await To(S,n,e,Q,M?.sku,m,v,M?.processExecution?.id)};let Jo;var Lo;(Lo=Jo||(Jo={})).Local="Local",Lo.Remote="Remote";const zo=new class{constructor(){ko(this,"localPersistenceKey","designTransactions"),ko(this,"storageMethod",Jo.Local),ko(this,"designSavedListeners",[])}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter((e=>e!==t))}async getSavedDesigns(){if(this.storageMethod===Jo.Local){const t=ga.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new na("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find((e=>e.transactionId===t))}async addDesign(t){const e=(await this.getSavedDesigns()).filter((e=>e.transactionId!==t.transactionId));e.unshift(t),await this.setDesigns(e),this.designSavedListeners.forEach((e=>e(t)))}async renameDesign(t,e){const A=await this.getSavedDesigns(),i=A.find((e=>e.transactionId===t));if(!i)throw new Error(`No saved design for transaction ${t}.`);i.title=e,await this.setDesigns(A)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter((e=>e.transactionId!==t)))}async setDesigns(t){if(this.storageMethod!==Jo.Local)throw new na("Unexpected storage method requested");ga.set(this.localPersistenceKey,JSON.stringify(t))}};function jo(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Vo{constructor(t,e){if(jo(this,"client",void 0),jo(this,"commandContext",void 0),jo(this,"workflowManager",void 0),jo(this,"isReadOnly",void 0),jo(this,"renderableScenes",[]),jo(this,"renderableSceneCallbacks",[]),jo(this,"debouncedSavedDesignUpdate",F(I)((async()=>{await zo.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),jo(this,"getCanvasObjectURLAsync",(async t=>new Promise(((e,A)=>{try{t.toBlob((t=>{if(t){const A=URL.createObjectURL(t);e(A)}}))}catch(t){A(t)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const A=e.layouts;this.commandContext=new Ti,this.commandContext.initialize(A,e.reloadedState),this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.workflowManager=new mo(e.workflow,e.product.profanities?.map((t=>t.word))||[],A,this.commandContext,(t=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(t)}),e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly,e.modelContainer,e.isReloadedTransaction),this.workflowManager.addSelectionCallback((t=>{const e=t.traversableScenes.map((t=>{const e=t.renderableSteps.map((t=>t.stepName));return{id:t.name,title:t.title,renderableSteps:e}}));this.renderableScenes=e,this.renderableSceneCallbacks.forEach((t=>t(e)))}))}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async updateVariationRecords(t){await Qa.getShadowGraphqlClient().mutate({mutation:Ns,variables:{transactionId:this.workflowManager.getTransaction().id,updates:t.map((t=>({recordNumber:t.recordNumber,values:t.values.map((t=>({aspect:t.aspect,stepName:t.stepName,value:t.value})))})))}})}async createPreviewImage(t,e){const A=this.workflowManager.getWorkflow(),i=A?.finalizeStepConfig?.lookAtAnimation;if(t){if(!i)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,i))||""}const n=document.createElement("canvas");let a=2048;e&&e<=2048&&(a=e),n.width=a,n.height=a;const r=this.commandContext.getAllLayouts(),s=A.defaultPreviewPanelIndex||0,o=A.panels[s],c=r.find((t=>t.layoutState?.layout.panelId===o?.name))||r[0],l=c.layoutState.layout.previewRegion?{x:c.layoutState.layout.previewRegion.left,y:c.layoutState.layout.previewRegion.top,width:c.layoutState.layout.previewRegion.width,height:c.layoutState.layout.previewRegion.height}:{x:0,y:0,width:c.layoutState.layout.width,height:c.layoutState.layout.height},g=this.commandContext.getLayoutById(c.layoutState.layout.id),h=n.getContext("2d");if(!h)throw new sa("Failed to obtain 2D context for preview image creation");const d=Ji(g.layoutState.layout,g.layoutState.elements,{renderingConfiguration:{purpose:Ve.Print,region:{left:l.x,top:l.y,width:l.width,height:l.height}}}),u=F(Q).renderToStaticMarkup(d),w=await ke.from(h,u,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await w.render();const B=await this.getCanvasObjectURLAsync(n);return n.toDataURL(B)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t));if(e&&this.stepHasHandle(e))return Ro.get(this.getWorkflowManager(),e)}getSteps(){return this.getScenes().flatMap((t=>this.getStepsByScene(t)))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map((t=>({id:t.id,name:t.name,stepIds:t.stepNames})))}getSelectionPriceSubunits(){const t=this.getWorkflowManager().getWorkflowSelections();let e=0;return Object.values(t).forEach((t=>{e+=t.selections.map((t=>t.priceModifier)).reduce(((t,e)=>t+e))})),e}getBasePriceSubunits(){return this.getWorkflowManager().getProduct().basePrice||0}getTotalPriceSubunits(){return this.getBasePriceSubunits()+this.getSelectionPriceSubunits()}getBulkStep(){if(this.getWorkflowManager().getTransaction().bulk){const t=this.getWorkflowManager().getProduct().bulkConfiguration,e={type:rA.Bulk,stepName:"Bulk",stepTitle:t?.stepTitle??"workflow.steps.bulk.title",helpText:t?.helpText,data:{aspects:Hs(this.getWorkflowManager().getWorkflow())},conditions:[]};return Ro.get(this.getWorkflowManager(),e)}}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepTitle===t));if(e&&this.stepHasHandle(e))return Ro.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter((e=>e.type===t)).map((t=>Ro.get(this.getWorkflowManager(),t)))}getStepsByScene(t){if(!this.getWorkflowManager().getWorkflow().stepGroups.find((e=>e.name===t.name)))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return t.stepIds.map((t=>this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t)))).filter((t=>this.stepHasHandle(t))).map((t=>Ro.get(this.getWorkflowManager(),t)))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){const e=(await Qa.getShadowGraphqlClient().mutate({mutation:Io,variables:{id:this.getWorkflowManager().getTransaction().id,details:t,type:"Owner"}})).data?.transactionAddStakeholder?.stakeholders?.find((e=>e.customer?.emailAddress===t.emailAddress));if(e?.customer){this.getWorkflowManager().setTransactionCustomer(e.customer);const t=ga.getMap("transactionCustomerIds")||new Map;t.set(this.getWorkflowManager().getTransaction().id,e.customer.id),ga.setMap("transactionCustomerIds",t)}}attachRenderableSceneListener(t){this.renderableSceneCallbacks.push(t),t(this.renderableScenes)}detachRenderableSceneListener(t){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter((e=>e!==t))}async save(t){if(!this.getCommandContext().getState())throw new na("State undefined!");const e={title:await(async()=>{if(t)return t;const e=this.getWorkflowManager().getTransaction().id,A=(await zo.getSavedDesigns()).find((t=>t.transactionId===e))?.title;return A||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await zo.addDesign(e),e}async copy(){const t=F(e)(this.getCommandContext().getState());if(!t)throw new na("Internal state is undefined! Cannot copy experience!");const A=JSON.stringify(t.transaction),i=this.getWorkflowManager().getWorkflow(),n=new Yc({}),a=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!a)throw new na("Integration product id is undefined!");await n.initFromIntegrationProduct(a);return await n.getWorkflowExperience(i.id,A,void 0)}async onDesignFinished(t){return Oo(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),(()=>this.commandContext.getState()),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,t||(()=>{}),(t=>this.updateVariationRecords(t)),this.workflowManager.getVariationRecords(),(t=>this.createPreviewImage(t)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==rA.SilentIllustration&&t.type!==rA.ProductOverlay}getExportedData(){const t=new Map,e=this.getWorkflowManager().getWorkflowMetadata(),A=this.getWorkflowManager().getWorkflowSelections();return Object.keys(e).forEach((A=>{const i=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===A));if(!i)return;t.has(i.stepTitle)||t.set(i.stepTitle,{});const n=e[A];Object.keys(n).forEach((e=>{t.get(i.stepTitle)[e]=n[e]}))})),Object.keys(A)?.forEach((e=>{const i=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===e));i&&(t.has(i.stepTitle)||t.set(i.stepTitle,{}),t.get(i.stepTitle).selection=A[e].selections[0].name)})),t}}const Ko=M.gql`
523
523
  fragment ProductCollectionProductFields on Product {
524
524
  id
525
525
  basePrice
@@ -811,12 +811,20 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
811
811
  }
812
812
  }
813
813
  `,fc=t.gql`
814
+ fragment ModelAnimationFields on ModelAnimation {
815
+ from
816
+ to
817
+ loop
818
+ name
819
+ }
820
+ `,Qc=t.gql`
814
821
  ${Da}
815
822
  ${xa}
816
823
  ${Na}
817
824
  ${Ec}
818
825
  ${mc}
819
826
  ${Cc}
827
+ ${fc}
820
828
  query GetWorkflow($id: String!) {
821
829
  workflow(id: $id) {
822
830
  allowProofDownload
@@ -827,9 +835,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
827
835
  ...LookAtAnimationFields
828
836
  }
829
837
  modelAnimation {
830
- from
831
- to
832
- loop
838
+ ...ModelAnimationFields
833
839
  }
834
840
  }
835
841
  globalPreviewConfig {
@@ -927,9 +933,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
927
933
  ...LookAtAnimationFields
928
934
  }
929
935
  modelAnimation {
930
- from
931
- to
932
- loop
936
+ ...ModelAnimationFields
933
937
  }
934
938
  regions {
935
939
  ...RegionFields
@@ -956,9 +960,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
956
960
  ...LookAtAnimationFields
957
961
  }
958
962
  modelAnimation {
959
- from
960
- to
961
- loop
963
+ ...ModelAnimationFields
962
964
  }
963
965
  overlayImageKey
964
966
  overlayImageUrl
@@ -989,9 +991,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
989
991
  ...LookAtAnimationFields
990
992
  }
991
993
  modelAnimation {
992
- from
993
- to
994
- loop
994
+ ...ModelAnimationFields
995
995
  }
996
996
  regions {
997
997
  ...RegionFields
@@ -1012,9 +1012,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1012
1012
  ...LookAtAnimationFields
1013
1013
  }
1014
1014
  modelAnimation {
1015
- from
1016
- to
1017
- loop
1015
+ ...ModelAnimationFields
1018
1016
  }
1019
1017
  targetMaterials
1020
1018
  varySelection
@@ -1032,9 +1030,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1032
1030
  ...LookAtAnimationFields
1033
1031
  }
1034
1032
  modelAnimation {
1035
- from
1036
- to
1037
- loop
1033
+ ...ModelAnimationFields
1038
1034
  }
1039
1035
  replaceProductModel
1040
1036
  varySelection
@@ -1053,9 +1049,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1053
1049
  }
1054
1050
  maxLength
1055
1051
  modelAnimation {
1056
- from
1057
- to
1058
- loop
1052
+ ...ModelAnimationFields
1059
1053
  }
1060
1054
  module
1061
1055
  regions {
@@ -1076,9 +1070,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1076
1070
  ...LookAtAnimationFields
1077
1071
  }
1078
1072
  modelAnimation {
1079
- from
1080
- to
1081
- loop
1073
+ ...ModelAnimationFields
1082
1074
  }
1083
1075
  regions {
1084
1076
  ...RegionFields
@@ -1105,9 +1097,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1105
1097
  ...LookAtAnimationFields
1106
1098
  }
1107
1099
  modelAnimation {
1108
- from
1109
- to
1110
- loop
1100
+ ...ModelAnimationFields
1111
1101
  }
1112
1102
  varySelections
1113
1103
  }
@@ -1125,9 +1115,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1125
1115
  ...LookAtAnimationFields
1126
1116
  }
1127
1117
  modelAnimation {
1128
- from
1129
- to
1130
- loop
1118
+ ...ModelAnimationFields
1131
1119
  }
1132
1120
  regions {
1133
1121
  ...RegionFields
@@ -1149,9 +1137,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1149
1137
  ...LookAtAnimationFields
1150
1138
  }
1151
1139
  modelAnimation {
1152
- from
1153
- to
1154
- loop
1140
+ ...ModelAnimationFields
1155
1141
  }
1156
1142
  regions {
1157
1143
  ...RegionFields
@@ -1191,9 +1177,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1191
1177
  maxSize
1192
1178
  minSize
1193
1179
  modelAnimation {
1194
- from
1195
- to
1196
- loop
1180
+ ...ModelAnimationFields
1197
1181
  }
1198
1182
  paths
1199
1183
  regions {
@@ -1214,7 +1198,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1214
1198
  }
1215
1199
  }
1216
1200
  }
1217
- `,Qc=t.gql`
1201
+ `,yc=t.gql`
1218
1202
  query GetTransactionForPartner($id: String!) {
1219
1203
  transactions(ids: [$id]) {
1220
1204
  id
@@ -1231,7 +1215,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1231
1215
  }
1232
1216
  }
1233
1217
  }
1234
- `,yc=t.gql`
1218
+ `,Dc=t.gql`
1235
1219
  ${Da}
1236
1220
  query GetWorkflowForTheme($id: String!) {
1237
1221
  workflow(id: $id) {
@@ -1253,21 +1237,21 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1253
1237
  }
1254
1238
  }
1255
1239
  }
1256
- `,Dc=t.gql`
1240
+ `,Ic=t.gql`
1257
1241
  query GetCustomer($emailAddress: String!) {
1258
1242
  customer(emailAddress: $emailAddress) {
1259
1243
  id
1260
1244
  emailAddress
1261
1245
  }
1262
1246
  }
1263
- `,Ic=t.gql`
1247
+ `,xc=t.gql`
1264
1248
  mutation CustomerCreate($details: CustomerDetailsInput!) {
1265
1249
  customerCreate(details: $details) {
1266
1250
  id
1267
1251
  emailAddress
1268
1252
  }
1269
1253
  }
1270
- `,xc=t.gql`
1254
+ `,Mc=t.gql`
1271
1255
  mutation CustomerAuthenticate($loginToken: String!) {
1272
1256
  customerAuthenticate(loginToken: $loginToken) {
1273
1257
  id
@@ -1291,11 +1275,11 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1291
1275
  }
1292
1276
  }
1293
1277
  }
1294
- `,Mc=t.gql`
1278
+ `,vc=t.gql`
1295
1279
  mutation CustomerGenerateVerificationCode($emailAddress: String!) {
1296
1280
  customerGenerateVerificationCode(emailAddress: $emailAddress)
1297
1281
  }
1298
- `,vc=t.gql`
1282
+ `,Sc=t.gql`
1299
1283
  mutation CustomerVerifyCode($emailAddress: String!, $verificationCode: String!) {
1300
1284
  customerVerifyCode(emailAddress: $emailAddress, verificationCode: $verificationCode) {
1301
1285
  id
@@ -1323,5 +1307,5 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
1323
1307
  }
1324
1308
  }
1325
1309
  }
1326
- `,Sc=async t=>{const e=(await Qa.getShadowGraphqlClient().query({query:fc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},Fc=(t,e)=>{const A=t.workflowState,i=A?JSON.parse(A):void 0;return i?Object.values(i.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:Te(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class bc{constructor(t){var e;pc(this,"options",void 0),pc(this,"initialized",void 0),pc(this,"currencyCode",void 0),pc(this,"customer",void 0),pc(this,"experienceOptions",void 0),pc(this,"updateTransactionState",(async t=>{try{return Qa.getShadowGraphqlClient().mutate({...t,mutation:Ys})}catch(t){throw console.error(t),new ra("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,fa=e)}getAssetManager(){return Ya}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const e=ga.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return Ea(A),Promise.resolve({success:!0,stakeholderType:ir.Owner})}const A=ga.getMap("bundleCustomerIds");if(A?.has(t)){const e=A.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=Qa.getShadowGraphqlClient(),A=await e.query({query:Qc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||0===A.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const i=A.data.transactions[0],n=i.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(i.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=ga.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return Ba(e),Promise.resolve({success:!0,stakeholderType:ir.Owner})}const r=ga.getMap("transactionCustomerIds");if(r?.has(t)){const e=r.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const s=(await e.query({query:yc,errorPolicy:"all",variables:{id:i.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${i.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:i.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=ga.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),ga.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=Qa.getShadowGraphqlClient(),A=(await e.query({query:Dc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:Ic,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!A)throw new Error("Unable to create customer.");return this.customer=A,{customer:A,isAuthenticated:!1}}const i=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:i}}async authenticateCustomerId(t){const e=Qa.getShadowGraphqlClient(),A=ga.getMap("customerTokens");if(!A?.has(t))return!1;const i=A.get(t);if(!i)return!1;const n=(await e.mutate({mutation:xc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:i}})).data?.customerAuthenticate;return!!n&&(Ca(i),this.customer=n,!0)}async generateVerificationCode(t){await Qa.getShadowGraphqlClient().mutate({mutation:Mc,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await Qa.getShadowGraphqlClient().mutate({mutation:vc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(A?.loginToken){if(!A.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=ga.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),ga.setMap("customerTokens",e),Ca(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await Qa.getShadowGraphqlClient().mutate({mutation:Zo,variables:{collectionId:t}})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");Ea(e.bundleOwnerId);const A=ga.getMap("bundleOwnerIds")||new Map;return A.set(e.id,e.bundleOwnerId),ga.setMap("bundleOwnerIds",A),new Bc(this,e)}async getExistingBundle(t,e){const A=await Qa.getShadowGraphqlClient().query({query:Xo,variables:{id:t}});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const i=A.data?.bundles[0],n=ga.getMap("bundleOwnerIds");n?.has(i.id)&&Ea(n.get(i.id));const a=new Bc(this,i);if(i.transactions&&i.transactions.length>0){const t=t=>{const A=e?A=>e(A,t):void 0;return this.getWorkflowExperience(void 0,void 0,A,{type:"transaction",transactionId:t})},A=await Promise.all(i.transactions.map((e=>t(e.id))));a._setWorkflowExperiencesInternal(A)}return a}async getWorkflowExperience(t,e,A,i){if(!i)return await this.getWorkflowExperienceDeprecated(t,e,A);const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await Vn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ai(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=Qa.getShadowGraphqlClient();if("transaction"===i.type){const{transactionId:e,readOnly:A}=i,n=await t.query({query:bs,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!n.data?.transactions||0===n.data.transactions.length)throw new ra("Existing transaction not found.");const a=n.data?.transactions[0];if(!a.workflowId)throw new ra("Existing transaction has no workflow ID.");const r=await Sc(a.workflowId);if(!a.product)throw new ra("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:A}}if("integration"===i.type||"external"===i.type){const e=async()=>{const e="integration"===i.type?{integrationProductId:i.integrationProductId}:{externalIntegrationId:i.externalIntegrationId,externalProductId:i.externalProductId},A=await t.mutate({mutation:Ss,variables:{...e,bulk:i.bulk,workflowId:i.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ra("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new ra("Failed to create transaction, product not available.");return n},A=Sc(i.workflowId),[n,a]=await Promise.all([e(),A]);return{transaction:n,workflow:a}}throw new ra("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new na("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:r};if("transaction"===i.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await n(t),o.reloadedState=t}else if(!s&&i.workflowState){const t=JSON.parse(i.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await n(t),o.reloadedState=t}else o.layouts=Fc(o.transaction,o.workflow);if(o.renderableContextService=new Cs(o.layouts),i.previewService?(o.previewService=i.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=A&&A(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==i.type){const t=ga.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),Ba(a.transactionOwnerId||""),ga.setMap("transactionOwnerIds",t)}else{const t=(ga.getMap("transactionOwnerIds")||new Map).get(a.id);t&&Ba(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new Vo(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==i.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new ra("No integration product ID provided.");const e=Qa.getShadowGraphqlClient(),A=await e.mutate({mutation:Ss,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ra("Failed to create transaction!");const i=A.data.transactionCreate;if(!i.product)throw new ra("Failed to create transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode;const n=ga.getMap("transactionOwnerIds")||new Map;n.set(i.id,i.transactionOwnerId),Ba(i.transactionOwnerId||""),ga.setMap("transactionOwnerIds",n),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new ra("No transaction ID provided.");const A=Qa.getShadowGraphqlClient();if(e)return await(async()=>{const i=(await A.query({query:bs,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!i)throw new ra("Failed to read transaction.");if(!i.product)throw new ra("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:async()=>{throw new na("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const i=ga.getMap("transactionOwnerIds")||new Map,n=i.get(t);if(n){Ba(n);const i=(await A.query({query:bs,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!i)throw new ra("Failed to read transaction.");if(!i.product)throw new ra("Failed to load transaction, product not available.");return this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await A.mutate({mutation:Fs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new ra("Failed to read transaction.");if(!n.product)throw new ra("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(i.set(n.id,n.transactionOwnerId),Ba(n.transactionOwnerId),ga.setMap("transactionOwnerIds",i)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new ra("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot launch experience: Not initialized.");const i=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await Vn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ai(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Sc(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await i(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new Cs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Vo(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=Qa.getShadowGraphqlClient().mutate({mutation:Ps,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Sc(t);if(await Promise.all([n,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await i(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=Fc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await a),this.experienceOptions.renderableContextService=new Cs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const r=new Vo(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new ra("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Yc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Pc{constructor(){Yc(this,"getProduct",void 0),Yc(this,"getCommandContext",void 0),Yc(this,"getAllLayoutData",void 0),Yc(this,"getMetadata",void 0),Yc(this,"getWorkflowMetadata",void 0),Yc(this,"getStepStorage",void 0),Yc(this,"setModelContainer",void 0),Yc(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Nc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let Rc;var kc;(kc=Rc||(Rc={})).SelectFrame="SelectFrame",kc.SelectImage="SelectImage",kc.Position="Position";class Hc extends yo{constructor(t,e){super(t,e),Nc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return eo.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return eo.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,i){return i&&i.length>1&&void 0===t?Rc.SelectFrame:e||A||this.getImageData()?Rc.Position:Rc.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Uc=t=>{const e=(0,i.useRef)(null),n=(0,i.useRef)(void 0),[a,r]=(0,i.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=Ua(),[g,h]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1),{state:w,uiDispatcher:B}=Wa(),p=(0,i.useCallback)((t=>{const e=t;B(new Ka({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),E=(0,i.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&r(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,i.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new Ka({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),C=(0,i.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,A=2===l.length&&"touch"===l[0].pointerType;if(g&&A){const[t,e]=l,A=Math.abs(t.clientX-e.clientX),i=a;i&&p(w.zoom-.0055*(i-A)),r(A)}if(d&&(e||A)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,A=(n?.current?.y||t.screenY)-t.screenY;B(new Ka({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-A/w.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),f=(0,i.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,i.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,A=e.current.hasPointerCapture(t);d&&!A&&e.current.setPointerCapture(t),!d&&A&&e.current.releasePointerCapture(t)}),[e,d,l]),Hr([" "],(()=>{u(!0),B(new Ka({selectedElement:void 0}))}),(()=>u(!1))),Hr(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,i.useMemo)((()=>({cursor:d&&0===l.length?"grab":d&&1===l.length?"grabbing":g?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[d,g,l]);return(0,A.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:f,onPointerDown:m,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:C,style:Q,children:t.children})};
1310
+ `,Fc=async t=>{const e=(await Qa.getShadowGraphqlClient().query({query:Qc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}})).data.workflow;return e.steps.forEach((t=>{delete t.data.__typename})),e},bc=(t,e)=>{const A=t.workflowState,i=A?JSON.parse(A):void 0;return i?Object.values(i.layouts).map((t=>t.layout)):e.panels.sort(((t,e)=>t.index-e.index)).map((t=>({id:Te(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})))};class Yc{constructor(t){var e;pc(this,"options",void 0),pc(this,"initialized",void 0),pc(this,"currencyCode",void 0),pc(this,"customer",void 0),pc(this,"experienceOptions",void 0),pc(this,"updateTransactionState",(async t=>{try{return Qa.getShadowGraphqlClient().mutate({...t,mutation:Ys})}catch(t){throw console.error(t),new ra("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,fa=e)}getAssetManager(){return Ya}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}async authenticateBundleFromLocalStorage(t){const e=ga.getMap("bundleOwnerIds");if(e?.has(t)){const A=e.get(t);return Ea(A),Promise.resolve({success:!0,stakeholderType:ir.Owner})}const A=ga.getMap("bundleCustomerIds");if(A?.has(t)){const e=A.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){const e=Qa.getShadowGraphqlClient(),A=await e.query({query:yc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||0===A.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const i=A.data.transactions[0],n=i.product?.partner?.id;if(!n)throw new Error(`Unable to read transaction: ${t}`);if(i.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=ga.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return Ba(e),Promise.resolve({success:!0,stakeholderType:ir.Owner})}const r=ga.getMap("transactionCustomerIds");if(r?.has(t)){const e=r.get(t);if(e){if(await this.authenticateCustomerId(e)){const e=this.customer?.bundleStakeholders?.find((e=>e.bundle?.transactions?.some((e=>e.id===t))))||this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return Promise.resolve({success:!0,stakeholderType:e.type})}}}const s=(await e.query({query:Dc,errorPolicy:"all",variables:{id:i.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${i.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:i.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=ga.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),ga.setMap("transactionCustomerIds",e))}getStakeholderTypeForTransaction(t){const e=this.customer?.stakeholders?.find((e=>e.transaction?.id===t));if(e)return e.type}async getOrCreateCustomer(t){this.customer=void 0;const e=Qa.getShadowGraphqlClient(),A=(await e.query({query:Ic,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!A.id){const A=(await e.mutate({mutation:xc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!A)throw new Error("Unable to create customer.");return this.customer=A,{customer:A,isAuthenticated:!1}}const i=await this.authenticateCustomerId(A.id);return{customer:this.customer||A,isAuthenticated:i}}async authenticateCustomerId(t){const e=Qa.getShadowGraphqlClient(),A=ga.getMap("customerTokens");if(!A?.has(t))return!1;const i=A.get(t);if(!i)return!1;const n=(await e.mutate({mutation:Mc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:i}})).data?.customerAuthenticate;return!!n&&(Ca(i),this.customer=n,!0)}async generateVerificationCode(t){await Qa.getShadowGraphqlClient().mutate({mutation:vc,variables:{emailAddress:t}})}async verifyCode(t,e){const A=(await Qa.getShadowGraphqlClient().mutate({mutation:Sc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(A?.loginToken){if(!A.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=ga.getMap("customerTokens")||new Map;return e.set(A.id,A.loginToken),ga.setMap("customerTokens",e),Ca(A.loginToken),this.customer={...A,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await Qa.getShadowGraphqlClient().mutate({mutation:Zo,variables:{collectionId:t}})).data?.bundleCreate;if(!e)throw new Error("Unable to create bundle");Ea(e.bundleOwnerId);const A=ga.getMap("bundleOwnerIds")||new Map;return A.set(e.id,e.bundleOwnerId),ga.setMap("bundleOwnerIds",A),new Bc(this,e)}async getExistingBundle(t,e){const A=await Qa.getShadowGraphqlClient().query({query:Xo,variables:{id:t}});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const i=A.data?.bundles[0],n=ga.getMap("bundleOwnerIds");n?.has(i.id)&&Ea(n.get(i.id));const a=new Bc(this,i);if(i.transactions&&i.transactions.length>0){const t=t=>{const A=e?A=>e(A,t):void 0;return this.getWorkflowExperience(void 0,void 0,A,{type:"transaction",transactionId:t})},A=await Promise.all(i.transactions.map((e=>t(e.id))));a._setWorkflowExperiencesInternal(A)}return a}async getWorkflowExperience(t,e,A,i){if(!i)return await this.getWorkflowExperienceDeprecated(t,e,A);const n=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await Vn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ai(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=Qa.getShadowGraphqlClient();if("transaction"===i.type){const{transactionId:e,readOnly:A}=i,n=await t.query({query:bs,variables:{id:e},errorPolicy:"all",fetchPolicy:"no-cache"});if(!n.data?.transactions||0===n.data.transactions.length)throw new ra("Existing transaction not found.");const a=n.data?.transactions[0];if(!a.workflowId)throw new ra("Existing transaction has no workflow ID.");const r=await Fc(a.workflowId);if(!a.product)throw new ra("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:A}}if("integration"===i.type||"external"===i.type){const e=async()=>{const e="integration"===i.type?{integrationProductId:i.integrationProductId}:{externalIntegrationId:i.externalIntegrationId,externalProductId:i.externalProductId},A=await t.mutate({mutation:Ss,variables:{...e,bulk:i.bulk,workflowId:i.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ra("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new ra("Failed to create transaction, product not available.");return n},A=Fc(i.workflowId),[n,a]=await Promise.all([e(),A]);return{transaction:n,workflow:a}}throw new ra("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new na("State mutation is forbidden in read only mode!")}:this.updateTransactionState,readOnly:s,workflow:r};if("transaction"===i.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await n(t),o.reloadedState=t}else if(!s&&i.workflowState){const t=JSON.parse(i.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await n(t),o.reloadedState=t}else o.layouts=bc(o.transaction,o.workflow);if(o.renderableContextService=new Cs(o.layouts),i.previewService?(o.previewService=i.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=A&&A(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==i.type){const t=ga.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),Ba(a.transactionOwnerId||""),ga.setMap("transactionOwnerIds",t)}else{const t=(ga.getMap("transactionOwnerIds")||new Map).get(a.id);t&&Ba(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new Vo(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==i.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async initFromIntegrationProduct(t){if(""===t)throw new ra("No integration product ID provided.");const e=Qa.getShadowGraphqlClient(),A=await e.mutate({mutation:Ss,variables:{integrationProductId:t,bulk:this.options.bulk||!1,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new ra("Failed to create transaction!");const i=A.data.transactionCreate;if(!i.product)throw new ra("Failed to create transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode;const n=ga.getMap("transactionOwnerIds")||new Map;n.set(i.id,i.transactionOwnerId),Ba(i.transactionOwnerId||""),ga.setMap("transactionOwnerIds",n),this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new ra("No transaction ID provided.");const A=Qa.getShadowGraphqlClient();if(e)return await(async()=>{const i=(await A.query({query:bs,variables:{id:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!i)throw new ra("Failed to read transaction.");if(!i.product)throw new ra("Failed to load transaction, product not available.");this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:async()=>{throw new na("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const i=ga.getMap("transactionOwnerIds")||new Map,n=i.get(t);if(n){Ba(n);const i=(await A.query({query:bs,variables:{id:t},errorPolicy:"all"})).data?.transactions[0];if(!i)throw new ra("Failed to read transaction.");if(!i.product)throw new ra("Failed to load transaction, product not available.");return this.currencyCode=i.product.partner?.currencyCode,this.experienceOptions={product:i.product,transaction:i,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const n=(await A.mutate({mutation:Fs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!n)throw new ra("Failed to read transaction.");if(!n.product)throw new ra("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,n.transactionOwnerId&&(i.set(n.id,n.transactionOwnerId),Ba(n.transactionOwnerId),ga.setMap("transactionOwnerIds",i)),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new ra("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,A){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot launch experience: Not initialized.");const i=async t=>{for(const e in t.layouts){const A=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<A.length;++t){const e=A[t];e.src&&e.svg&&(e.cachedObjectURL=await Vn(e.svg))}const i=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<i.length;++t){const e=i[t];e.fontData?.assetUrl&&ai(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await Fc(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=t,this.experienceOptions.transaction.workflowState){const t=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await i(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=A&&A(t),this.experienceOptions.renderableContextService=new Cs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const e=new Vo(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const n=Qa.getShadowGraphqlClient().mutate({mutation:Ps,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=Fc(t);if(await Promise.all([n,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Wi(t),await i(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=bc(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await a),this.experienceOptions.renderableContextService=new Cs(this.experienceOptions.layouts),this.experienceOptions.product?.modelUrl&&(this.experienceOptions.previewService?.initialize({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}),this.experienceOptions.modelContainer=this.experienceOptions.previewService?.getAllModels()[0]);const r=new Vo(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new ra("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new ra("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function Pc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Nc{constructor(){Pc(this,"getProduct",void 0),Pc(this,"getCommandContext",void 0),Pc(this,"getAllLayoutData",void 0),Pc(this,"getMetadata",void 0),Pc(this,"getWorkflowMetadata",void 0),Pc(this,"getStepStorage",void 0),Pc(this,"setModelContainer",void 0),Pc(this,"getUpdatesPending",void 0)}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}getVariationRecords(){return[]}async reset(){}updateStateWithServer(t){}addVariationRecord(t){return{recordNumber:0,transactionId:"",values:[]}}getCurrentVariationRecord(){}removeVariationRecord(t){return[]}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addCurrentVariationCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}addVariationRecordsCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(t){}setCurrentVariationRecord(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function Rc(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var i=A.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let kc;var Hc;(Hc=kc||(kc={})).SelectFrame="SelectFrame",Hc.SelectImage="SelectImage",Hc.Position="Position";class Uc extends yo{constructor(t,e){super(t,e),Rc(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return eo.selectVariant(this.step,t.getResource(),e,this.manager,(t=>this.setUpdateState(t)))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged((e=>{e&&t(e)}))}selectImage(t){return eo.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,A,i){return i&&i.length>1&&void 0===t?kc.SelectFrame:e||A||this.getImageData()?kc.Position:kc.SelectImage}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}hasVaryingUpload(){return this.step.data.varyUpload}hasVaryingSelection(){return this.step.data.varySelection}}const Gc=t=>{const e=(0,i.useRef)(null),n=(0,i.useRef)(void 0),[a,r]=(0,i.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=Ua(),[g,h]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1),{state:w,uiDispatcher:B}=Wa(),p=(0,i.useCallback)((t=>{const e=t;B(new Ka({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),E=(0,i.useCallback)((t=>{o(t),1===l.length&&(n.current=void 0),2===l.length&&r(void 0);"touch"===t.pointerType&&l.length>1&&l.length-1==1&&(u(!1),h(!1))}),[o,l.length]),m=(0,i.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new Ka({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),C=(0,i.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,A=2===l.length&&"touch"===l[0].pointerType;if(g&&A){const[t,e]=l,A=Math.abs(t.clientX-e.clientX),i=a;i&&p(w.zoom-.0055*(i-A)),r(A)}if(d&&(e||A)&&t.isPrimary){const e=(n?.current?.x||t.screenX)-t.screenX,A=(n?.current?.y||t.screenY)-t.screenY;B(new Ka({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-A/w.zoom}))}t.isPrimary&&(n.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),f=(0,i.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,i.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,A=e.current.hasPointerCapture(t);d&&!A&&e.current.setPointerCapture(t),!d&&A&&e.current.releasePointerCapture(t)}),[e,d,l]),Hr([" "],(()=>{u(!0),B(new Ka({selectedElement:void 0}))}),(()=>u(!1))),Hr(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,i.useMemo)((()=>({cursor:d&&0===l.length?"grab":d&&1===l.length?"grabbing":g?"zoom-in":void 0,width:"100%",height:"100%",overflow:"clip"})),[d,g,l]);return(0,A.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:f,onPointerDown:m,onPointerUp:E,onPointerCancel:E,onPointerLeave:E,onPointerMove:C,style:Q,children:t.children})};
1327
1311
  //# sourceMappingURL=main.js.map