@spiffcommerce/core 15.0.3 → 15.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/jsx-runtime"),n=require("react"),A=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"),m=require("@apollo/client/link/context"),E=require("@apollo/client/link/error"),f=require("cross-fetch"),C=require("lodash.isequal"),Q=require("react-dom/server"),y=require("qrcode"),I=require("svg-path-bbox"),D=require("lodash.debounce"),x=require("unicode-default-word-boundary"),v=require("@apollo/client/core");function M(t,e,i,n){Object.defineProperty(t,e,{get:i,set:n,enumerable:!0,configurable:!0})}var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function b(t){return t&&t.__esModule?t.default:t}M(module.exports,"SpiffCommerceClient",(()=>ol)),M(module.exports,"CommandContext",(()=>Ln)),M(module.exports,"spiffCoreConfiguration",(()=>wa)),M(module.exports,"PromiseQueue",(()=>Xr)),M(module.exports,"QueueablePromise",(()=>Wr)),M(module.exports,"MockWorkflowManager",(()=>ll)),M(module.exports,"InformationMessageType",(()=>Do)),M(module.exports,"StepHandle",(()=>Po)),M(module.exports,"TextStepHandle",(()=>Lo)),M(module.exports,"FrameStepHandle",(()=>ul)),M(module.exports,"BulkStepHandle",(()=>Ro)),M(module.exports,"ShapeStepHandle",(()=>Jo)),M(module.exports,"IllustrationStepHandle",(()=>Ho)),M(module.exports,"MaterialStepHandle",(()=>Uo)),M(module.exports,"ModelStepHandle",(()=>Go)),M(module.exports,"PictureStepHandle",(()=>To)),M(module.exports,"QuestionStepHandle",(()=>Oo)),M(module.exports,"GlobalPropertyHandle",(()=>Qc)),M(module.exports,"BulkPriceCalculationStrategy",(()=>ar)),M(module.exports,"Variant",(()=>bo)),M(module.exports,"WorkflowExperienceImpl",(()=>ac)),M(module.exports,"OptionNotFoundError",(()=>ta)),M(module.exports,"LayoutNotFoundError",(()=>ea)),M(module.exports,"AssetNotFoundError",(()=>ia)),M(module.exports,"ResourceNotFoundError",(()=>na)),M(module.exports,"MisconfigurationError",(()=>Aa)),M(module.exports,"ParseError",(()=>sa)),M(module.exports,"UnhandledBehaviorError",(()=>ra)),M(module.exports,"assetService",(()=>ka)),M(module.exports,"designService",(()=>nc)),M(module.exports,"createDesign",(()=>_o)),M(module.exports,"optionService",(()=>Ja)),M(module.exports,"persistenceService",(()=>da)),M(module.exports,"graphQlManager",(()=>Ia)),M(module.exports,"toast",(()=>wr)),M(module.exports,"FrameService",(()=>eo)),M(module.exports,"getBoundedOffsets",(()=>_s)),M(module.exports,"frameStepService",(()=>co)),M(module.exports,"modelStepService",(()=>ho)),M(module.exports,"materialStepService",(()=>go)),M(module.exports,"shapeStepService",(()=>mo)),M(module.exports,"questionStepService",(()=>Bo)),M(module.exports,"digitalContentStepService",(()=>so)),M(module.exports,"moduleStepService",(()=>uo)),M(module.exports,"pictureStepService",(()=>wo)),M(module.exports,"textStepService",(()=>yo)),M(module.exports,"illustrationStepService",(()=>lo)),M(module.exports,"ProductCameraRig",(()=>nr)),M(module.exports,"FrameStep",(()=>hl)),M(module.exports,"ConversionLocation",(()=>sr)),M(module.exports,"ConversionDataType",(()=>cr)),M(module.exports,"getWorkflow",(()=>rl)),M(module.exports,"getWorkflows",(()=>al)),M(module.exports,"shortenUrl",(()=>Ao)),M(module.exports,"ObjectInput",(()=>jc)),M(module.exports,"TextInput",(()=>Vc)),M(module.exports,"ObjectInputType",(()=>Lc)),M(module.exports,"ProductCollection",(()=>kc)),M(module.exports,"CollectionProduct",(()=>Rc)),M(module.exports,"AssetType",(()=>ai)),M(module.exports,"BringForwardCommand",(()=>CA)),M(module.exports,"BringToFrontCommand",(()=>EA)),M(module.exports,"BringToBackCommand",(()=>fA)),M(module.exports,"CanvasCommand",(()=>$n)),M(module.exports,"CreateElementCommand",(()=>rA)),M(module.exports,"CreateLayoutCommand",(()=>AA)),M(module.exports,"DeleteElementCommand",(()=>sA)),M(module.exports,"FontAlignmentCommand",(()=>uA)),M(module.exports,"FontColorCommand",(()=>cA)),M(module.exports,"FontSizeCommand",(()=>gA)),M(module.exports,"FontSourceCommand",(()=>dA)),M(module.exports,"GroupCommand",(()=>nA)),M(module.exports,"LayoutElementFactory",(()=>qA)),M(module.exports,"LayoutElementType",(()=>ze)),M(module.exports,"MoveCommand",(()=>tA)),M(module.exports,"ResizeCommand",(()=>iA)),M(module.exports,"RotateCommand",(()=>eA)),M(module.exports,"SendBackwardsCommand",(()=>QA)),M(module.exports,"StakeholderType",(()=>gr)),M(module.exports,"StepAspectType",(()=>ci)),M(module.exports,"StepType",(()=>si)),M(module.exports,"TextChangeCommand",(()=>BA)),M(module.exports,"UnitOfMeasurement",(()=>qe)),M(module.exports,"dataUrlFromExternalUrl",(()=>_i)),M(module.exports,"findElement",(()=>Wn)),M(module.exports,"frameDataCache",(()=>PA)),M(module.exports,"generate",(()=>Te)),M(module.exports,"getAxisAlignedBoundingBox",(()=>di)),M(module.exports,"generateSVGWithUnknownColors",(()=>On)),M(module.exports,"getAttributesFromArrayBuffer",(()=>SA)),M(module.exports,"rehydrateSerializedLayout",(()=>Zn)),M(module.exports,"getFrameData",(()=>RA)),M(module.exports,"getSvgElement",(()=>jn)),M(module.exports,"loadFontFromDataUrl",(()=>cn)),M(module.exports,"loadFontFromExternalUrl",(()=>on)),M(module.exports,"determineCorrectFontSizeAndLines",(()=>LA)),M(module.exports,"patternImageDataCache",(()=>FA)),M(module.exports,"generateCommands",(()=>xs)),M(module.exports,"registerJSDOM",(()=>Oi)),M(module.exports,"minZoom",(()=>Jr)),M(module.exports,"AdvancedEditor",(()=>Rs)),M(module.exports,"TransformWrapper",(()=>wl)),M(module.exports,"EditorCore",(()=>ks)),M(module.exports,"useLayouts",(()=>ja)),M(module.exports,"useEditorState",(()=>tr)),M(module.exports,"useEditorInteraction",(()=>zr)),M(module.exports,"useShortcutCombination",(()=>jr)),M(module.exports,"commandReducer",(()=>qa)),M(module.exports,"getDefaultState",(()=>Xa)),M(module.exports,"CommandContextContext",(()=>La)),M(module.exports,"AdvancedEditorStateProvider",(()=>$a)),M(module.exports,"AdvancedEditorContext",(()=>Za)),M(module.exports,"UICommand",(()=>_a)),M(module.exports,"EditorSubMenu",(()=>Ka)),M(module.exports,"ElementEventType",(()=>Br)),M(module.exports,"KeyEvent",(()=>mr)),M(module.exports,"gatherVaryingStepAspects",(()=>js));function F(t){return t.replace(/(?!\u3000)\s+/gm," ")}function P(t){const e=t.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return e?e.map(parseFloat):[]}const Y=/^[A-Z-]+$/;function N(t){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t);return e&&(e[2]||e[3]||e[4])||""}const k=/(\[[^\]]+\])/g,R=/(#[^\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 i=e.exec(t);return i?[t.replace(e," "),i.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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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:i}=this;return F(this.getString()).trim().split(t).map((t=>new et(e,i,t)))}hasValue(t){const e=this.value;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){const{value:e}=this,i="string"==typeof e;return i&&t?t.test(e):i}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 i=parseFloat(e);return this.isString(/%$/)&&(i/=100),i}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,i)=>e--&&i?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[i,n]="boolean"==typeof t?[void 0,t]:[t],{viewPort:A}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(A.computeSize("x"),A.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(A.computeSize("x"),A.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*A.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*A.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(/%$/)&&n:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*A.computeSize(i);default:{const t=this.getNumber();return e&&t<1?t*A.computeSize(i):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),i=(null==e?void 0:e[1])||t;return this.document.definitions[i]}getFillStyleDefinition(t,e){let i=this.getDefinition();if(!i)return null;if("function"==typeof i.createGradient&&"getBoundingBox"in t)return i.createGradient(this.document.ctx,t,e);if("function"==typeof i.createPattern){if(i.getHrefAttribute().hasValue()){const t=i.getAttribute("patternTransform");i=i.getHrefAttribute().getDefinition(),i&&t.hasValue()&&i.getAttribute("patternTransform",!0).setValue(t.value)}if(i)return i.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 i=e.length;let n=0;for(let t=0;t<i&&(","===e[t]&&n++,3!==n);t++);if(t.hasValue()&&this.isString()&&3!==n){const i=new(b(w))(e);i.ok&&(i.alpha=t.getNumber(),e=i.toRGBA())}return new et(this.document,this.name,e)}constructor(t,e,i){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=i,this.isNormalizedColor=!1}}function it(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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 nt{clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[t]=this.viewPorts;return t||At()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||At()}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(){it(this,"viewPorts",[])}}function At(){return{width:nt.DEFAULT_VIEWPORT_WIDTH,height:nt.DEFAULT_VIEWPORT_HEIGHT}}function at(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}it(nt,"DEFAULT_VIEWPORT_WIDTH",800),it(nt,"DEFAULT_VIEWPORT_HEIGHT",600);class rt{static parse(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const[i=e,n=e]=P(t);return new rt(i,n)}static parseScale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const[i=e,n=i]=P(t);return new rt(i,n)}static parsePath(t){const e=P(t),i=e.length,n=[];for(let t=0;t<i;t+=2)n.push(new rt(e[t],e[t+1]));return n}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:i}=this,n=e*t[0]+i*t[2]+t[4],A=e*t[1]+i*t[3]+t[5];this.x=n,this.y=A}constructor(t,e){at(this,"x",void 0),at(this,"y",void 0),this.x=t,this.y=e}}function st(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ot{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:i}=this,n=t.ctx.canvas;n.onclick=e,n.onmousemove=i,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:i}=this,{style:n}=t.ctx.canvas;let A;n&&(n.cursor=""),e.forEach(((t,e)=>{let{run:n}=t;for(A=i[e];A;)n(A),A=A.parent})),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:i,eventElements:n}=this;i.forEach(((i,A)=>{let{x:a,y:r}=i;!n[A]&&e.isPointInPath&&e.isPointInPath(a,r)&&(n[A]=t)}))}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:i,eventElements:n}=this;i.forEach(((i,A)=>{let{x:a,y:r}=i;!n[A]&&e.isPointInBox(a,r)&&(n[A]=t)}))}mapXY(t,e){const{window:i,ctx:n}=this.screen,A=new rt(t,e);let a=n.canvas;for(;a;)A.x-=a.offsetLeft,A.y-=a.offsetTop,a=a.offsetParent;return(null==i?void 0:i.scrollX)&&(A.x+=i.scrollX),(null==i?void 0:i.scrollY)&&(A.y+=i.scrollY),A}onClick(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:i,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:i,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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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:i,aspectRatio:n,width:A,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=F(n).replace(/^defer\s/,""),[B,p]=w.split(" "),m=B||"xMidYMid",E=p||"meet",f=A/a,C=r/s,Q=Math.min(f,C),y=Math.max(f,C);let I=a,D=s;"meet"===E&&(I*=Q,D*=Q),"slice"===E&&(I*=y,D*=y);const x=new et(e,"refX",l),v=new et(e,"refY",g),M=x.hasValue()&&v.hasValue();if(M&&i.translate(-Q*x.getPixels("x"),-Q*v.getPixels("y")),h){const t=Q*d,e=Q*u;i.beginPath(),i.moveTo(t,e),i.lineTo(A,e),i.lineTo(A,r),i.lineTo(t,r),i.closePath(),i.clip()}if(!M){const t="meet"===E&&Q===C,e="slice"===E&&y===C,n="meet"===E&&Q===f,a="slice"===E&&y===f;m.startsWith("xMid")&&(t||e)&&i.translate(A/2-I/2,0),m.endsWith("YMid")&&(n||a)&&i.translate(0,r/2-D/2),m.startsWith("xMax")&&(t||e)&&i.translate(A-I,0),m.endsWith("YMax")&&(n||a)&&i.translate(0,r-D)}switch(!0){case"none"===m:i.scale(f,C);break;case"meet"===E:i.scale(Q,Q);break;case"slice"===E:i.scale(y,y)}i.translate(-o,-c)}start(t){let{enableRedraw:e=!1,ignoreMouse:i=!1,ignoreAnimation:n=!1,ignoreDimensions:A=!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,A,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(n,r)&&(this.render(t,A,a,s,o,c,l),g.runEvents())),this.intervalId=b(u)(p)};i||g.start(),this.intervalId=b(u)(p)}stop(){this.intervalId&&(b(u).cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){const{frameDuration:t}=this;if(this.animations.reduce(((e,i)=>i.update(t)||e),!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,i,n,A,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 n&&"number"!=typeof A)&&(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 n||"number"==typeof A){const e=P(t.getAttribute("viewBox").getString());let i=0,a=0;if("number"==typeof n){const A=t.getStyle("width");A.hasValue()?i=A.getPixels("x")/n:e[2]&&!isNaN(e[2])&&(i=e[2]/n)}if("number"==typeof A){const i=t.getStyle("height");i.hasValue()?a=i.getPixels("y")/A:e[3]&&!isNaN(e[3])&&(a=e[3]/A)}i||(i=a),a||(a=i),t.getAttribute("width",!0).setValue(n),t.getAttribute("height",!0).setValue(A);const r=t.getStyle("transform",!0,!0);r.setValue(`${r.getString()} scale(${1/i}, ${1/a})`)}i||o.clearRect(0,0,d,u),t.render(o),c&&(this.isFirstRender=!1)}constructor(t,{fetch:e=gt,window:i=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 nt,this.mouse=new ot(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=i,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}function dt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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(i){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),i=await e.text();return this.parseFromString(i)}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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function mt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Et(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ft(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ct{apply(t){const{originX:e,originY:i,matrix:n}=this,A=e.getPixels("x"),a=i.getPixels("y");t.translate(A,a),t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.translate(-A,-a)}unapply(t){const{originX:e,originY:i,matrix:n}=this,A=n[0],a=n[2],r=n[4],s=n[1],o=n[3],c=n[5],l=1/(A*(1*o-0*c)-a*(1*s-0*c)+r*(0*s-0*o)),g=e.getPixels("x"),h=i.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*A-0*r),l*(a*c-r*o),l*(r*s-A*c)),t.translate(-g,-h)}applyToPoint(t){t.applyTransform(this.matrix)}constructor(t,e,i){ft(this,"type","matrix"),ft(this,"matrix",void 0),ft(this,"originX",void 0),ft(this,"originY",void 0),this.matrix=function(t){const e=P(t);return[e[0]||0,e[1]||0,e[2]||0,e[3]||0,e[4]||0,e[5]||0]}(e),this.originX=i[0],this.originY=i[1]}}function Qt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class yt extends Ct{constructor(t,e,i){super(t,e,i),Qt(this,"type","skew"),Qt(this,"angle",void 0),this.angle=new et(t,"angle",e)}}function It(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Dt{static fromElement(t,e){const i=e.getStyle("transform",!1,!0);if(i.hasValue()){const[n,A=n]=e.getStyle("transform-origin",!1,!0).split();if(n&&A){const e=[n,A];return new Dt(t,i.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,i){It(this,"document",void 0),It(this,"transforms",void 0),this.document=t,this.transforms=[];const n=function(t){return F(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);n.forEach((t=>{if("none"===t)return;const[e,n]=function(t){const[e="",i=""]=t.split("(");return[e.trim(),i.trim().replace(")","")]}(t),A=Dt.transformTypes[e];A&&this.transforms.push(new A(this.document,n,i))}))}}function xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}It(Dt,"transformTypes",{translate:class{apply(t){const{x:e,y:i}=this.point;t.translate(e||0,i||0)}unapply(t){const{x:e,y:i}=this.point;t.translate(-1*e||0,-1*i||0)}applyToPoint(t){const{x:e,y:i}=this.point;t.applyTransform([1,0,0,1,e||0,i||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:i,originX:n,originY:A,angle:a}=this,r=e+n.getPixels("x"),s=i+A.getPixels("y");t.translate(r,s),t.rotate(a.getRadians()),t.translate(-r,-s)}unapply(t){const{cx:e,cy:i,originX:n,originY:A,angle:a}=this,r=e+n.getPixels("x"),s=i+A.getPixels("y");t.translate(r,s),t.rotate(-1*a.getRadians()),t.translate(-r,-s)}applyToPoint(t){const{cx:e,cy:i,angle:n}=this,A=n.getRadians();t.applyTransform([1,0,0,1,e||0,i||0]),t.applyTransform([Math.cos(A),Math.sin(A),-Math.sin(A),Math.cos(A),0,0]),t.applyTransform([1,0,0,1,-e||0,-i||0])}constructor(t,e,i){mt(this,"type","rotate"),mt(this,"angle",void 0),mt(this,"originX",void 0),mt(this,"originY",void 0),mt(this,"cx",void 0),mt(this,"cy",void 0);const n=P(e);this.angle=new et(t,"angle",n[0]),this.originX=i[0],this.originY=i[1],this.cx=n[1]||0,this.cy=n[2]||0}},scale:class{apply(t){const{scale:{x:e,y:i},originX:n,originY:A}=this,a=n.getPixels("x"),r=A.getPixels("y");t.translate(a,r),t.scale(e,i||e),t.translate(-a,-r)}unapply(t){const{scale:{x:e,y:i},originX:n,originY:A}=this,a=n.getPixels("x"),r=A.getPixels("y");t.translate(a,r),t.scale(1/e,1/i||e),t.translate(-a,-r)}applyToPoint(t){const{x:e,y:i}=this.scale;t.applyTransform([e||0,0,0,i||0,0,0])}constructor(t,e,i){Et(this,"type","scale"),Et(this,"scale",void 0),Et(this,"originX",void 0),Et(this,"originY",void 0);const n=rt.parseScale(e);0!==n.x&&0!==n.y||(n.x=L,n.y=L),this.scale=n,this.originX=i[0],this.originY=i[1]}},matrix:Ct,skewX:class extends yt{constructor(t,e,i){var n,A,a;super(t,e,i),a="skewX",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}},skewY:class extends yt{constructor(t,e,i){var n,A,a;super(t,e,i),a="skewY",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}});class vt{getAttribute(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.attributes[t];if(!i&&e){const e=new et(this.document,t,"");return this.attributes[t]=e,e}return i||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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=this.styles[t];if(n)return n;const A=this.getAttribute(t);if(A.hasValue())return this.styles[t]=A,A;if(!i){const{parent:e}=this;if(e){const i=e.getStyle(t);if(i.hasValue())return i}}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=Dt.fromElement(this.document,this);e&&e.apply(t);const i=this.getStyle("clip-path",!1,!0);if(i.hasValue()){const e=i.getDefinition();e&&e.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach((e=>{e.render(t)}))}addChild(t){const e=t instanceof vt?t:this.document.createElement(t);e.parent=this,vt.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:i}=this;if(!i)return!1;if("function"==typeof i.matches)return i.matches(t);const n=null===(e=i.getAttribute)||void 0===e?void 0:e.call(i,"class");return!(!n||""===n)&&n.split(" ").some((e=>`.${e}`===t))}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let i;for(const n in t)if(!n.startsWith("@")&&this.matchesSelector(n)){const A=t[n],a=e[n];if(A)for(const t in A){let e=this.stylesSpecificity[t];void 0===e&&(e="000"),a&&a>=e&&(i=A[t],i&&(this.styles[t]=i),this.stylesSpecificity[t]=a)}}}removeStyles(t,e){return e.reduce(((e,i)=>{const n=t.getStyle(i);if(!n.hasValue())return e;const A=n.getString();return n.setValue(""),[...e,[i,A]]}),[])}restoreStyles(t,e){e.forEach((e=>{let[i,n]=e;t.getStyle(i,!0).setValue(n)}))}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}constructor(t,e,i=!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=i,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 i=(n=e.nodeName,Y.test(n)?n.toLowerCase():n);var n;this.attributes[i]=new et(t,i,e.value)})),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()){this.getAttribute("style").getString().split(";").map((t=>t.trim())).forEach((e=>{if(!e)return;const[i,n]=e.split(":").map((t=>t.trim()));i&&(this.styles[i]=new et(t,i,n))}))}const{definitions:n}=t,A=this.getAttribute("id");A.hasValue()&&(n[A.getString()]||(n[A.getString()]=this)),Array.from(e.childNodes).forEach((e=>{if(1===e.nodeType)this.addChild(e);else if(i&&(3===e.nodeType||4===e.nodeType)){const i=t.createTextNode(e);i.getText().length>0&&this.addChild(i)}}))}}xt(vt,"ignoreChildTypes",["title"]);class Mt extends vt{constructor(t,e,i){super(t,e,i)}}function St(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function bt(t){const e=t.trim();return/^('|")/.test(e)?e:`"${e}"`}function Ft(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 Pt(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 Yt{static parse(){let t=arguments.length>1?arguments[1]:void 0,e="",i="",n="",A="",a="";const r=F(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&&Yt.styles.includes(t):"inherit"!==t&&(e=t),s.fontStyle=!0;break;case!s.fontVariant&&Yt.variants.includes(t):"inherit"!==t&&(i=t),s.fontStyle=!0,s.fontVariant=!0;break;case!s.fontWeight&&Yt.weights.includes(t):"inherit"!==t&&(n=t),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0;break;case!s.fontSize:"inherit"!==t&&(A=t.split("/")[0]||""),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0,s.fontSize=!0;break;default:"inherit"!==t&&(a+=t)}})),new Yt(e,i,n,A,a,t)}toString(){return[Ft(this.fontStyle),this.fontVariant,Pt(this.fontWeight),this.fontSize,(t=this.fontFamily,void 0===d?t:t.trim().split(",").map(bt).join(","))].join(" ").trim();var t}constructor(t,e,i,n,A,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?Yt.parse(a):a:{};this.fontFamily=A||r.fontFamily,this.fontSize=n||r.fontSize,this.fontStyle=t||r.fontStyle,this.fontWeight=i||r.fontWeight,this.fontVariant=e||r.fontVariant}}function Nt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}St(Yt,"styles","normal|italic|oblique|inherit"),St(Yt,"variants","normal|small-caps|inherit"),St(Yt,"weights","normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit");class kt{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:i,x2:n,y2:A}=t;this.addPoint(e,i),this.addPoint(n,A)}sumCubic(t,e,i,n,A){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*i+3*(1-t)*Math.pow(t,2)*n+Math.pow(t,3)*A}bezierCurveAdd(t,e,i,n,A){const a=6*e-12*i+6*n,r=-3*e+9*i-9*n+3*A,s=3*i-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,i,n,A)):this.addY(this.sumCubic(r,e,i,n,A))))}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,i,n,A)):this.addY(this.sumCubic(c,e,i,n,A)));const l=(-a-Math.sqrt(o))/(2*r);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,i,n,A)):this.addY(this.sumCubic(l,e,i,n,A)))}addBezierCurve(t,e,i,n,A,a,r,s){this.addPoint(t,e),this.addPoint(r,s),this.bezierCurveAdd(!0,t,i,A,r),this.bezierCurveAdd(!1,e,n,a,s)}addQuadraticCurve(t,e,i,n,A,a){const r=t+2/3*(i-t),s=e+2/3*(n-e),o=r+1/3*(A-t),c=s+1/3*(a-e);this.addBezierCurve(t,e,r,o,s,c,A,a)}isPointInBox(t,e){const{x1:i,y1:n,x2:A,y2:a}=this;return i<=t&&t<=A&&n<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,i=Number.NaN,n=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=i,this.y2=n,this.addPoint(t,e),this.addPoint(i,n)}}class Rt extends vt{calculateOpacity(){let t=1,e=this;for(;e;){const i=e.getStyle("opacity",!1,!0);i.hasValue(!0)&&(t*=i.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"),i=this.getStyle("fill-opacity"),n=this.getStyle("stroke"),A=this.getStyle("stroke-opacity");if(e.isUrlDefinition()){const n=e.getFillStyleDefinition(this,i);n&&(t.fillStyle=n)}else if(e.hasValue()){"currentColor"===e.getString()&&e.setValue(this.getStyle("color").getColor());const i=e.getColor();"inherit"!==i&&(t.fillStyle="none"===i?"rgba(0,0,0,0)":i)}if(i.hasValue()){const e=new et(this.document,"fill",t.fillStyle).addOpacity(i).getColor();t.fillStyle=e}if(n.isUrlDefinition()){const e=n.getFillStyleDefinition(this,A);e&&(t.strokeStyle=e)}else if(n.hasValue()){"currentColor"===n.getString()&&n.setValue(this.getStyle("color").getColor());const e=n.getString();"inherit"!==e&&(t.strokeStyle="none"===e?"rgba(0,0,0,0)":e)}if(A.hasValue()){const e=new et(this.document,"stroke",t.strokeStyle).addOpacity(A).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=P(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 i=l.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=i:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=i:void 0!==t.mozDashOffset&&(t.mozDashOffset=i)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){const e=this.getStyle("font"),i=this.getStyle("font-style"),n=this.getStyle("font-variant"),A=this.getStyle("font-weight"),a=this.getStyle("font-size"),r=this.getStyle("font-family"),s=new Yt(i.getString(),n.getString(),A.getString(),a.hasValue()?`${a.getPixels(!0)}px`:"",r.getString(),Yt.parse(e.getString(),t.font));i.setValue(s.fontStyle),n.setValue(s.fontVariant),A.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,i,n;super(...t),n=!1,(i="modifiedEmSizeStack")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}function Ht(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ut extends Rt{setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);const i=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();i&&(t.textBaseline=i)}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(((i,n)=>{const A=this.getChildBoundingBox(t,this,this,n);e?e.addBoundingBox(A):e=A})),e}getFontSize(){const{document:t,parent:e}=this,i=Yt.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(i)}getTElementBoundingBox(t){const e=this.getFontSize();return new kt(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,i){const n=e[i];let A;if(t.isArabic){var a;const r=e.length,s=e[i-1],o=e[i+1];let c="isolated";(0===i||" "===s)&&i<r-1&&" "!==o&&(c="terminal"),i>0&&" "!==s&&i<r-1&&" "!==o&&(c="medial"),i>0&&" "!==s&&(i===r-1||" "===o)&&(c="initial"),A=(null===(a=t.arabicGlyphs[n])||void 0===a?void 0:a[c])||t.glyphs[n]}else A=t.glyphs[n];return A||(A=t.missingGlyph),A}getText(){return""}getTextFromNode(t){const e=t||this.node,i=Array.from(e.parentNode.childNodes),n=i.indexOf(e),A=i.length-1;let a=F(e.textContent||"");return 0===n&&(a=a.replace(/^[\n \t]+/,"")),n===A&&(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,i)=>{this.renderChild(t,this,this,i)}));const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:i}=this,n=this.getText(),A=i.getStyle("font-family").getDefinition();if(null==A?void 0:A.fontFace){const{unitsPerEm:a}=A.fontFace,r=Yt.parse(e.ctx.font),s=i.getStyle("font-size").getNumber(r.fontSize),o=i.getStyle("font-style").getString(r.fontStyle),c=s/a,l=A.isRTL?n.split("").reverse().join(""):n,g=P(i.getAttribute("dx").getString()),h=l.length;for(let e=0;e<h;e++){const i=this.getGlyph(A,l,e);t.translate(this.x,this.y),t.scale(c,-c);const n=t.lineWidth;t.lineWidth=t.lineWidth*a/s,"italic"===o&&t.transform(1,0,.4,1,0,0),i.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=n,t.scale(1/c,-1/c),t.translate(-this.x,-this.y),this.x+=s*(i.horizAdvX||A.horizAdvX)/a,void 0===g[e]||isNaN(g[e])||(this.x+=g[e])}return}const{x:a,y:r}=this;t.fillStyle&&t.fillText(n,a,r),t.strokeStyle&&t.strokeText(n,a,r)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start");let i=0;i="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+=i;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach(((e,i)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,i)})),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,i,n){const A=i.children[n];A.children.length>0?A.children.forEach(((i,n)=>{e.adjustChildCoordinatesRecursiveCore(t,e,A,n)})):this.adjustChildCoordinates(t,e,i,n)}adjustChildCoordinates(t,e,i,n){const A=i.children[n];if("function"!=typeof A.measureText)return A;t.save(),A.setContext(t,!0);const a=A.getAttribute("x"),r=A.getAttribute("y"),s=A.getAttribute("dx"),o=A.getAttribute("dy"),c=A.getStyle("font-family").getDefinition(),l=Boolean(null==c?void 0:c.isRTL);0===n&&(a.hasValue()||a.setValue(A.getInheritedAttribute("x")),r.hasValue()||r.setValue(A.getInheritedAttribute("y")),s.hasValue()||s.setValue(A.getInheritedAttribute("dx")),o.hasValue()||o.setValue(A.getInheritedAttribute("dy")));const g=A.measureText(t);return l&&(e.x-=g),a.hasValue()?(e.applyAnchoring(),A.x=a.getPixels("x"),s.hasValue()&&(A.x+=s.getPixels("x"))):(s.hasValue()&&(e.x+=s.getPixels("x")),A.x=e.x),e.x=A.x,l||(e.x+=g),r.hasValue()?(A.y=r.getPixels("y"),o.hasValue()&&(A.y+=o.getPixels("y"))):(o.hasValue()&&(e.y+=o.getPixels("y")),A.y=e.y),e.y=A.y,e.leafTexts.push(A),e.minX=Math.min(e.minX,A.x,A.x+g),e.maxX=Math.max(e.maxX,A.x,A.x+g),A.clearContext(t),t.restore(),A}getChildBoundingBox(t,e,i,n){const A=i.children[n];if("function"!=typeof A.getBoundingBox)return null;const a=A.getBoundingBox(t);return a&&A.children.forEach(((i,n)=>{const r=e.getChildBoundingBox(t,e,A,n);a.addBoundingBox(r)})),a}renderChild(t,e,i,n){const A=i.children[n];A.render(t),A.children.forEach(((i,n)=>{e.renderChild(t,e,A,n)}))}measureText(t){const{measureCache:e}=this;if(~e)return e;const i=this.getText(),n=this.measureTargetText(t,i);return this.measureCache=n,n}measureTargetText(t,e){if(!e.length)return 0;const{parent:i}=this,n=i.getStyle("font-family").getDefinition();if(n){const t=this.getFontSize(),A=n.isRTL?e.split("").reverse().join(""):e,a=P(i.getAttribute("dx").getString()),r=A.length;let s=0;for(let e=0;e<r;e++){s+=(this.getGlyph(n,A,e).horizAdvX||n.horizAdvX)*t/n.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:A}=t.measureText(e);return this.clearContext(t),t.restore(),A}getInheritedAttribute(t){let e=this;for(;e instanceof Ut&&e.isFirstChild()&&e.parent;){const i=e.parent.getAttribute(t);if(i.hasValue(!0))return i.getString("0");e=e.parent}return null}constructor(t,e,i){super(t,e,new.target===Ut||i),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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Tt extends Ut{getText(){return this.text}constructor(t,e,i){super(t,e,new.target===Tt||i),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,i,n;super(...t),n="textNode",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}function Jt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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 i=new rt(this.command[t],this.command[e]);return this.makeAbsolute(i)}getAsControlPoint(t,e){const i=this.getPoint(t,e);return this.control=i,i}getAsCurrentPoint(t,e){const i=this.getPoint(t,e);return this.current=i,i}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:i},control:{x:n,y:A}}=this;return new rt(2*e-n,2*i-A)}makeAbsolute(t){if(this.command.relative){const{x:e,y:i}=this.current;t.x+=e,t.y+=i}return t}addMarker(t,e,i){const{points:n,angles:A}=this;i&&A.length>0&&!A[A.length-1]&&(A[A.length-1]=n[n.length-1].angleTo(i)),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 i=0;i<e;i++)if(!t[i])for(let n=i+1;n<e;n++)if(t[n]){t[i]=t[n];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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class jt extends Rt{path(t){const{pathParser:e}=this,i=new kt;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case Lt.MOVE_TO:this.pathM(t,i);break;case Lt.LINE_TO:this.pathL(t,i);break;case Lt.HORIZ_LINE_TO:this.pathH(t,i);break;case Lt.VERT_LINE_TO:this.pathV(t,i);break;case Lt.CURVE_TO:this.pathC(t,i);break;case Lt.SMOOTH_CURVE_TO:this.pathS(t,i);break;case Lt.QUAD_TO:this.pathQ(t,i);break;case Lt.SMOOTH_QUAD_TO:this.pathT(t,i);break;case Lt.ARC:this.pathA(t,i);break;case Lt.CLOSE_PATH:this.pathZ(t,i)}return i}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),i=t.getMarkerAngles();if(!e||!i)return null;return e.map(((t,e)=>[t,i[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 i=this.getMarkers();if(i){const e=i.length-1,n=this.getStyle("marker-start"),A=this.getStyle("marker-mid"),a=this.getStyle("marker-end");if(n.isUrlDefinition()){const e=n.getDefinition(),[A,a]=i[0];e&&e.render(t,A,null===a?void 0:a)}if(A.isUrlDefinition()){const n=A.getDefinition();for(let A=1;A<e;A++){const[e,a]=i[A];n&&n.render(t,e,null===a?void 0:a)}}if(a.isUrlDefinition()){const n=a.getDefinition(),[A,r]=i[e];n&&n.render(t,A,null===r?void 0:r)}}}static pathM(t){const e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){const{pathParser:i}=this,{point:n}=jt.pathM(i),{x:A,y:a}=n;i.addMarker(n),e.addPoint(A,a),t&&t.moveTo(A,a)}static pathL(t){const{current:e}=t;return{current:e,point:t.getAsCurrentPoint()}}pathL(t,e){const{pathParser:i}=this,{current:n,point:A}=jt.pathL(i),{x:a,y:r}=A;i.addMarker(A,n),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathH(t){const{current:e,command:i}=t,n=new rt(((null==i?void 0:i.relative)?e.x:0)+i.x,e.y);return t.current=n,{current:e,point:n}}pathH(t,e){const{pathParser:i}=this,{current:n,point:A}=jt.pathH(i),{x:a,y:r}=A;i.addMarker(A,n),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathV(t){const{current:e,command:i}=t,n=new rt(e.x,(i.relative?e.y:0)+i.y);return t.current=n,{current:e,point:n}}pathV(t,e){const{pathParser:i}=this,{current:n,point:A}=jt.pathV(i),{x:a,y:r}=A;i.addMarker(A,n),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:i}=this,{current:n,point:A,controlPoint:a,currentPoint:r}=jt.pathC(i);i.addMarker(r,a,A),e.addBezierCurve(n.x,n.y,A.x,A.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(A.x,A.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:i}=this,{current:n,point:A,controlPoint:a,currentPoint:r}=jt.pathS(i);i.addMarker(r,a,A),e.addBezierCurve(n.x,n.y,A.x,A.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(A.x,A.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:i}=this,{current:n,controlPoint:A,currentPoint:a}=jt.pathQ(i);i.addMarker(a,A,A),e.addQuadraticCurve(n.x,n.y,A.x,A.y,a.x,a.y),t&&t.quadraticCurveTo(A.x,A.y,a.x,a.y)}static pathT(t){const{current:e}=t,i=t.getReflectedControlPoint();t.control=i;return{current:e,controlPoint:i,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){const{pathParser:i}=this,{current:n,controlPoint:A,currentPoint:a}=jt.pathT(i);i.addMarker(a,A,A),e.addQuadraticCurve(n.x,n.y,A.x,A.y,a.x,a.y),t&&t.quadraticCurveTo(A.x,A.y,a.x,a.y)}static pathA(t){const{current:e,command:i}=t;let{rX:n,rY:A,xRot:a,lArcFlag:r,sweepFlag:s}=i;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(n,2)+Math.pow(l.y,2)/Math.pow(A,2);g>1&&(n*=Math.sqrt(g),A*=Math.sqrt(g));let h=(r===s?-1:1)*Math.sqrt((Math.pow(n,2)*Math.pow(A,2)-Math.pow(n,2)*Math.pow(l.y,2)-Math.pow(A,2)*Math.pow(l.x,2))/(Math.pow(n,2)*Math.pow(l.y,2)+Math.pow(A,2)*Math.pow(l.x,2)));isNaN(h)&&(h=0);const d=new rt(h*n*l.y/A,h*-A*l.x/n),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)/n,(l.y-d.y)/A]),B=[(l.x-d.x)/n,(l.y-d.y)/A],p=[(-l.x-d.x)/n,(-l.y-d.y)/A];let m=V(B,p);return j(B,p)<=-1&&(m=Math.PI),j(B,p)>=1&&(m=0),{currentPoint:c,rX:n,rY:A,sweepFlag:s,xAxisRotation:o,centp:u,a1:w,ad:m}}pathA(t,e){const{pathParser:i}=this,{currentPoint:n,rX:A,rY:a,sweepFlag:r,xAxisRotation:s,centp:o,a1:c,ad:l}=jt.pathA(i),g=1-r?1:-1,h=c+g*(l/2),d=new rt(o.x+A*Math.cos(h),o.y+a*Math.sin(h));if(i.addMarkerAngle(d,h-g*Math.PI/2),i.addMarkerAngle(n,h-g*Math.PI),e.addPoint(n.x,n.y),t&&!isNaN(c)&&!isNaN(l)){const e=A>a?A:a,i=A>a?1:A/a,n=A>a?a/A:1;t.translate(o.x,o.y),t.rotate(s),t.scale(i,n),t.arc(0,0,e,c,c+l,Boolean(1-r)),t.scale(1/i,1/n),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,i){super(t,e,i),zt(this,"type","path"),zt(this,"pathParser",void 0),this.pathParser=new Lt(this.getAttribute("d").getString())}}function Vt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Kt extends Rt{setContext(t){var e;const{document:i}=this,{screen:n,window:A}=i,a=t.canvas;if(n.setDefaults(t),"style"in a&&void 0!==t.font&&A&&void 0!==A.getComputedStyle){t.font=A.getComputedStyle(a).getPropertyValue("font");const e=new et(i,"fontSize",Yt.parse(t.font).fontSize);e.hasValue()&&(i.rootEmSize=e.getPixels("y"),i.emSize=i.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}=n.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()?P(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)),n.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]),i.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:n.viewPort.width,desiredWidth:r,height:n.viewPort.height,desiredHeight:s,minX:d,minY:u,refX:o.getValue(),refY:c.getValue(),clip:h,clipX:w,clipY:B}),g&&(n.viewPort.removeCurrent(),n.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,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=this.getAttribute("width",!0),A=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),r=this.getAttribute("style"),s=n.getNumber(0),o=A.getNumber(0);if(i)if("string"==typeof i)this.getAttribute("preserveAspectRatio",!0).setValue(i);else{const t=this.getAttribute("preserveAspectRatio");t.hasValue()&&t.setValue(t.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(n.setValue(t),A.setValue(e),a.hasValue()||a.setValue(`0 0 ${s||t} ${o||e}`),r.hasValue()){const i=this.getStyle("width"),n=this.getStyle("height");i.hasValue()&&i.setValue(`${t}px`),n.hasValue()&&n.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"),i=this.getAttribute("y").getPixels("y"),n=this.getStyle("width",!1,!0).getPixels("x"),A=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,n/2),o=Math.min(o,A/2),t){const a=(Math.sqrt(2)-1)/3*4;t.beginPath(),A>0&&n>0&&(t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.bezierCurveTo(e+n-s+a*s,i,e+n,i+o-a*o,e+n,i+o),t.lineTo(e+n,i+A-o),t.bezierCurveTo(e+n,i+A-o+a*o,e+n-s+a*s,i+A,e+n-s,i+A),t.lineTo(e+s,i+A),t.bezierCurveTo(e+s-a*s,i+A,e,i+A-o+a*o,e,i+A-o),t.lineTo(e,i+o),t.bezierCurveTo(e,i+o-a*o,e+s-a*s,i,e+s,i),t.closePath())}return new kt(e,i,e+n,i+A)}getMarkers(){return null}constructor(...t){var e,i,n;super(...t),n="rect",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}function Xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class qt extends jt{path(t){const{points:e}=this,[{x:i,y:n}]=e,A=new kt(i,n);return t&&(t.beginPath(),t.moveTo(i,n)),e.forEach((e=>{let{x:i,y:n}=e;A.addPoint(i,n),t&&t.lineTo(i,n)})),A}getMarkers(){const{points:t}=this,e=t.length-1,i=[];return t.forEach(((n,A)=>{A!==e&&i.push([n,n.angleTo(t[A+1])])})),i.length>0&&i.push([t[t.length-1],i[i.length-1][1]]),i}constructor(t,e,i){super(t,e,i),Xt(this,"type","polyline"),Xt(this,"points",[]),this.points=rt.parsePath(this.getAttribute("points").getString())}}class Zt extends Rt{getBoundingBox(t){const e=new kt;return this.children.forEach((i=>{i instanceof jt&&e.addBoundingBox(i.getBoundingBox(t))})),e}constructor(...t){var e,i,n;super(...t),n="g",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}function $t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class _t extends vt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,i){let n=this;this.getHrefAttribute().hasValue()&&(n=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(n));const{stops:A}=n,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(i,A[A.length-1].color);if(A.forEach((t=>{a.addColorStop(t.offset,this.addParentOpacity(i,t.color))})),this.getAttribute("gradientTransform").hasValue()){const{document:t}=this,{MAX_VIRTUAL_PIXELS:e}=ht,{viewPort:i}=t.screen,n=i.getRoot(),A=new Wt(t);A.attributes.x=new et(t,"x",-e/3),A.attributes.y=new et(t,"y",-e/3),A.attributes.width=new et(t,"width",e),A.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=[A];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",n.width),s.attributes.height=new et(t,"height",n.height),s.children=[r];const o=t.createCanvas(n.width,n.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,i){super(t,e,i),$t(this,"attributesToInherit",["gradientUnits"]),$t(this,"stops",[]);const{stops:n,children:A}=this;A.forEach((t=>{"stop"===t.type&&n.push(t)}))}}function te(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ee(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ie extends vt{getProperty(){var t;const e=this.getAttribute("attributeType").getString(),i=this.getAttribute("attributeName").getString();var n;return"CSS"===e?null===(n=this.parent)||void 0===n?void 0:n.getStyle(i,!0):null===(t=this.parent)||void 0===t?void 0:t.getAttribute(i,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:i,to:n}=this.getProgress();let A=i.getNumber()+(n.getNumber()-i.getNumber())*e;return"%"===t&&(A*=100),`${A}${t}`}update(t){const{parent:e}=this,i=this.getProperty();if(!i)return!1;if(this.initialValue||(this.initialValue=i.getString(),this.initialUnits=i.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&&i&&i.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e&&i&&(e.animationFrozen=!0,e.animationFrozenValue=i.getString());return!1}this.duration+=t;let n=!1;if(this.begin<this.duration){let t=this.calcValue();const e=this.getAttribute("type");if(e.hasValue()){t=`${e.getString()}(${t})`}i.setValue(t),n=!0}return n}getProgress(){const{document:t,values:e}=this;let i,n,A=(this.duration-this.begin)/(this.maxDuration-this.begin);if(e.hasValue()){const a=A*(e.getValue().length-1),r=Math.floor(a),s=Math.ceil(a);let o;o=e.getValue()[r],i=new et(t,"from",o?parseFloat(o):0),o=e.getValue()[s],n=new et(t,"to",o?parseFloat(o):0),A=(a-r)/(s-r)}else i=this.from,n=this.to;return{progress:A,from:i,to:n}}constructor(t,e,i){super(t,e,i),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 n=this.getAttribute("values");n.hasValue()&&this.values.setValue(n.getString().split(";"))}}function ne(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ae extends vt{constructor(t,e,i){super(t,e,i),ne(this,"type","font-face"),ne(this,"ascent",void 0),ne(this,"descent",void 0),ne(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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class re extends jt{constructor(t,e,i){super(t,e,i),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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class oe extends re{constructor(...t){super(...t),se(this,"type","missing-glyph"),se(this,"horizAdvX",0)}}function ce(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function le(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ge(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function he(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const de=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;function ue(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class we{async load(t,e){try{const{document:i}=this,n=(await i.pith.parser.load(e)).getElementsByTagName("font");Array.from(n).forEach((e=>{const n=i.createElement(e);i.definitions[t]=n}))}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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class pe extends vt{constructor(t,e,i){super(t,e,i),Be(this,"type","style");F(Array.from(e.childNodes).map((t=>t.textContent)).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach((e=>{const i=e.trim();if(!i)return;const n=i.split("{"),A=n[0].split(","),a=n[1].split(";");A.forEach((e=>{const i=e.trim();if(!i)return;const n=t.styles[i]||{};if(a.forEach((e=>{const i=e.indexOf(":"),A=e.substr(0,i).trim(),a=e.substr(i+1,e.length-i).trim();A&&a&&(n[A]=new et(t,A,a))})),t.styles[i]=n,t.stylesSpecificity[i]=function(t){const e=[0,0,0];let i=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),n=0;return[i,n]=J(i,k),e[1]+=n,[i,n]=J(i,R),e[0]+=n,[i,n]=J(i,H),e[1]+=n,[i,n]=J(i,U),e[2]+=n,[i,n]=J(i,G),e[1]+=n,[i,n]=J(i,T),e[1]+=n,i=i.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[i,n]=J(i,O),e[2]+=n,e.join("")}(i),"@font-face"===i){const e=n["font-family"].getString().replace(/"|'/g,"");n.src.getString().split(",").forEach((i=>{if(i.indexOf('format("svg")')>0){const n=N(i);n&&new we(t).load(e,n)}}))}}))}))}}function me(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Be(pe,"parseExternalUrl",N);function Ee(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function fe(t,e,i,n,A,a){return t[i*n*4+4*e+a]}function Ce(t,e,i,n,A,a,r){t[i*n*4+4*e+a]=r}function Qe(t,e,i){return t[e]*i}function ye(t,e,i,n){return e+Math.cos(t)*i+Math.sin(t)*n}class Ie extends vt{apply(t,e,i,n,A){const{includeOpacity:a,matrix:r}=this,s=t.getImageData(0,0,n,A);for(let t=0;t<A;t++)for(let e=0;e<n;e++){const i=fe(s.data,e,t,n,0,0),A=fe(s.data,e,t,n,0,1),o=fe(s.data,e,t,n,0,2),c=fe(s.data,e,t,n,0,3);let l=Qe(r,0,i)+Qe(r,1,A)+Qe(r,2,o)+Qe(r,3,c)+Qe(r,4,1),g=Qe(r,5,i)+Qe(r,6,A)+Qe(r,7,o)+Qe(r,8,c)+Qe(r,9,1),h=Qe(r,10,i)+Qe(r,11,A)+Qe(r,12,o)+Qe(r,13,c)+Qe(r,14,1),d=Qe(r,15,i)+Qe(r,16,A)+Qe(r,17,o)+Qe(r,18,c)+Qe(r,19,1);a&&(l=0,g=0,h=0,d*=c/255),Ce(s.data,e,t,n,0,0,l),Ce(s.data,e,t,n,0,1,g),Ce(s.data,e,t,n,0,2,h),Ce(s.data,e,t,n,0,3,d)}t.clearRect(0,0,n,A),t.putImageData(s,0,0)}constructor(t,e,i){super(t,e,i),Ee(this,"type","feColorMatrix"),Ee(this,"matrix",void 0),Ee(this,"includeOpacity",void 0);let n=P(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const t=n[0];n=[.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=n[0]*Math.PI/180;n=[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":n=[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=n,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}function De(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class xe extends vt{apply(t,e){const{document:i}=this;let n=this.getAttribute("x").getPixels("x"),A=this.getAttribute("y").getPixels("y"),a=this.getStyle("width").getPixels("x"),r=this.getStyle("height").getPixels("y");if(!a&&!r){const e=new kt;this.children.forEach((i=>{i instanceof jt&&e.addBoundingBox(i.getBoundingBox(t))})),n=Math.floor(e.x1),A=Math.floor(e.y1),a=Math.floor(e.width),r=Math.floor(e.height)}const s=this.removeStyles(e,xe.ignoreStyles),o=i.createCanvas(n+a,A+r),c=o.getContext("2d");i.screen.setDefaults(c),this.renderChildren(c),new Ie(i,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,n+a,A+r);const l=i.createCanvas(n+a,A+r),g=l.getContext("2d");i.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=c.createPattern(o,"no-repeat"),g.fillRect(0,0,n+a,A+r),t.fillStyle=g.createPattern(l,"no-repeat"),t.fillRect(0,0,n+a,A+r),this.restoreStyles(e,s)}render(t){}constructor(...t){super(...t),De(this,"type","mask")}}De(xe,"ignoreStyles",["mask","transform","clip-path"]);const ve=()=>{};function Me(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Se extends vt{apply(t,e,i,n,A){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,i,n,A,r),s&&s.removeChild(o)}constructor(t,e,i){super(t,e,i),Me(this,"type","feGaussianBlur"),Me(this,"extraFilterDistance",void 0),Me(this,"blurRadius",void 0),this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}function be(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Fe extends vt{apply(t,e){const{document:i,children:n}=this,A="getBoundingBox"in e?e.getBoundingBox(t):null;if(!A)return;let a=0,r=0;n.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(A.width),o=Math.floor(A.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(A.x),h=Math.floor(A.y),d=this.removeStyles(e,Fe.ignoreStyles),u=i.createCanvas(c,l),w=u.getContext("2d");i.screen.setDefaults(w),w.translate(-g+a,-h+r),e.render(w),n.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),be(this,"type","filter")}}be(Fe,"ignoreStyles",["filter","transform","clip-path"]);const Pe={svg:Kt,rect:Wt,circle:class extends jt{path(t){const e=this.getAttribute("cx").getPixels("x"),i=this.getAttribute("cy").getPixels("y"),n=this.getAttribute("r").getPixels();return t&&n>0&&(t.beginPath(),t.arc(e,i,n,0,2*Math.PI,!1),t.closePath()),new kt(e-n,i-n,e+n,i+n)}getMarkers(){return null}constructor(...t){var e,i,n;super(...t),n="circle",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},ellipse:class extends jt{path(t){const e=(Math.sqrt(2)-1)/3*4,i=this.getAttribute("rx").getPixels("x"),n=this.getAttribute("ry").getPixels("y"),A=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&i>0&&n>0&&(t.beginPath(),t.moveTo(A+i,a),t.bezierCurveTo(A+i,a+e*n,A+e*i,a+n,A,a+n),t.bezierCurveTo(A-e*i,a+n,A-i,a+e*n,A-i,a),t.bezierCurveTo(A-i,a-e*n,A-e*i,a-n,A,a-n),t.bezierCurveTo(A+e*i,a-n,A+i,a-e*n,A+i,a),t.closePath()),new kt(A-i,a-n,A+i,a+n)}getMarkers(){return null}constructor(...t){var e,i,n;super(...t),n="ellipse",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},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:i},{x:n,y:A}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,i),t.lineTo(n,A)),new kt(e,i,n,A)}getMarkers(){const[t,e]=this.getPoints(),i=t.angleTo(e);return[[t,i],[e,i]]}constructor(...t){var e,i,n;super(...t),n="line",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},polyline:qt,polygon:class extends qt{path(t){const e=super.path(t),[{x:i,y:n}]=this.points;return t&&(t.lineTo(i,n),t.closePath()),e}constructor(...t){var e,i,n;super(...t),n="polygon",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},path:jt,pattern:class extends vt{createPattern(t,e,i){const n=this.getStyle("width").getPixels("x",!0),A=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):n,o=r.hasValue()?r.getPixels("y",!0):A,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)),i.hasValue()?this.styles["fill-opacity"]=i: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,i,n;super(...t),n="pattern",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},marker:class extends vt{render(t,e,i){if(!e)return;const{x:n,y:A}=e,a=this.getAttribute("orient").getString("auto"),r=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(n,A),"auto"===a&&i&&t.rotate(i),"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&&i&&t.rotate(-i),t.translate(-n,-A)}constructor(...t){var e,i,n;super(...t),n="marker",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},defs:class extends vt{render(){}constructor(...t){var e,i,n;super(...t),n="defs",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},linearGradient:class extends _t{getGradient(t,e){const i="objectBoundingBox"===this.getGradientUnits(),n=i?e.getBoundingBox(t):null;if(i||!n)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 A=i?n.x+n.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=i?n.y+n.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),r=i?n.x+n.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),s=i?n.y+n.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return A===r&&a===s?null:t.createLinearGradient(A,a,r,s)}constructor(t,e,i){var n,A,a;super(t,e,i),a="linearGradient",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.attributesToInherit.push("x1","y1","x2","y2")}},radialGradient:class extends _t{getGradient(t,e){const i="objectBoundingBox"===this.getGradientUnits(),n=e.getBoundingBox(t);if(i&&!n)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 A=i?n.x+n.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=i?n.y+n.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let r=A,s=a;this.getAttribute("fx").hasValue()&&(r=i?n.x+n.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(s=i?n.y+n.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const o=i?(n.width+n.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),c=this.getAttribute("fr").getPixels();return t.createRadialGradient(r,s,c,A,a,o)}constructor(t,e,i){var n,A,a;super(t,e,i),a="radialGradient",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}},stop:class extends vt{constructor(t,e,i){super(t,e,i),te(this,"type","stop"),te(this,"offset",void 0),te(this,"color",void 0);const n=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),A=this.getStyle("stop-opacity");let a=this.getStyle("stop-color",!0);""===a.getString()&&a.setValue("#000"),A.hasValue()&&(a=a.addOpacity(A)),this.offset=n,this.color=a.getColor()}},animate:ie,animateColor:class extends ie{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),n=new(b(w))(e.getColor()),A=new(b(w))(i.getColor());if(n.ok&&A.ok){const e=n.r+(A.r-n.r)*t,i=n.g+(A.g-n.g)*t,a=n.b+(A.b-n.b)*t;return`rgb(${Math.floor(e)}, ${Math.floor(i)}, ${Math.floor(a)})`}return this.getAttribute("from").getColor()}constructor(...t){var e,i,n;super(...t),n="animateColor",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},animateTransform:class extends ie{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),n=P(e.getString()),A=P(i.getString()),a=n.map(((e,i)=>e+(A[i]-e)*t)).join(" ");return a}constructor(...t){var e,i,n;super(...t),n="animateTransform",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},font:class extends vt{render(){}constructor(t,e,i){super(t,e,i),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:n}=t,{children:A}=this;for(const t of A)if(t instanceof Ae){this.fontFace=t;const e=t.getStyle("font-family");e.hasValue()&&(n[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":Ae,"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,i,n;super(...t),n="tref",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},a:class extends Ut{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:i,y:n}=this,{mouse:A}=e.screen,a=new et(e,"fontSize",Yt.parse(e.ctx.font).fontSize);A.isWorking()&&A.checkBoundingBox(this,new kt(i,n-a.getPixels("y"),i+this.measureText(t),n))}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,i){super(t,e,i),le(this,"type","a"),le(this,"hasText",void 0),le(this,"text",void 0);const{childNodes:n}=e,A=n[0],a=n.length>0&&Array.from(n).every((t=>3===t.nodeType));this.hasText=a,this.text=a?this.getTextFromNode(A):""}},textPath:class extends Ut{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach((e=>{let{type:i,points:n}=e;switch(i){case Lt.LINE_TO:t&&t.lineTo(n[0],n[1]);break;case Lt.MOVE_TO:t&&t.moveTo(n[0],n[1]);break;case Lt.CURVE_TO:t&&t.bezierCurveTo(n[0],n[1],n[2],n[3],n[4],n[5]);break;case Lt.QUAD_TO:t&&t.quadraticCurveTo(n[0],n[1],n[2],n[3]);break;case Lt.ARC:{const[e,i,A,a,r,s,o,c]=n,l=A>a?A:a,g=A>a?1:A/a,h=A>a?a/A:1;t&&(t.translate(e,i),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,-i));break}case Lt.CLOSE_PATH:t&&t.closePath()}}))}renderChildren(t){var e;this.setTextData(t),t.save();const i=null===(e=this.parent)||void 0===e?void 0:e.getStyle("text-decoration").getString(),n=this.getFontSize(),{glyphInfo:A}=this,a=t.fillStyle;"underline"===i&&t.beginPath(),A.forEach(((e,A)=>{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"===i&&(0===A&&t.moveTo(a.x,a.y+n/8),t.lineTo(r.x,r.y+n/5))})),"underline"===i&&(t.lineWidth=n/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,i,n,A,a,r,s,o){let c=a,l=this.measureText(t,s);" "===s&&"justify"===e&&i<n&&(l+=(n-i)/A),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:i}=this,n=e||this.getText();if(i.has(n))return i.get(n);const A=this.measureTargetText(t,n);return i.set(n,A),A}setTextData(t){var e,i,n;if(this.glyphInfo)return;const A=this.getText(),a=A.split(""),r=A.split(" ").length-1,s=null===(e=this.parent)||void 0===e?void 0:e.getAttribute("dx").split().map((t=>t.getPixels("x"))),o=null===(i=this.parent)||void 0===i?void 0:i.getAttribute("dy").getPixels("y"),c=this.getAttribute("text-anchor").getString("start"),l=this.getStyle("letter-spacing"),g=null===(n=this.parent)||void 0===n?void 0:n.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=A.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,i)=>0===i?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 m=this.getPathLength(),E=this.getAttribute("startOffset").getNumber(0)*m;let f=0;"middle"!==c&&"center"!==c||(f=-p/2),"end"!==c&&"right"!==c||(f=-p),f+=E,a.forEach(((e,i)=>{const{offset:n,segment:A,rotation:s}=this.findSegmentToFitChar(t,c,p,m,r,f,o,e,i);f=n,A.p0&&A.p1&&this.glyphInfo.push({text:a[i],p0:A.p0,p1:A.p1,rotation:s})}))}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:i}=t;for(i.reset();!i.isEnd();){const{current:t}=i,n=t?t.x:0,A=t?t.y:0,a=i.next();let r=a.type,s=[];switch(a.type){case Lt.MOVE_TO:this.pathM(i,s);break;case Lt.LINE_TO:r=this.pathL(i,s);break;case Lt.HORIZ_LINE_TO:r=this.pathH(i,s);break;case Lt.VERT_LINE_TO:r=this.pathV(i,s);break;case Lt.CURVE_TO:this.pathC(i,s);break;case Lt.SMOOTH_CURVE_TO:r=this.pathS(i,s);break;case Lt.QUAD_TO:this.pathQ(i,s);break;case Lt.SMOOTH_QUAD_TO:r=this.pathT(i,s);break;case Lt.ARC:s=this.pathA(i);break;case Lt.CLOSE_PATH:jt.pathZ(i)}a.type!==Lt.CLOSE_PATH?e.push({type:r,points:s,start:{x:n,y:A},pathLength:this.calcLength(n,A,r,s)}):e.push({type:Lt.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:i,y:n}=jt.pathM(t).point;e.push(i,n)}pathL(t,e){const{x:i,y:n}=jt.pathL(t).point;return e.push(i,n),Lt.LINE_TO}pathH(t,e){const{x:i,y:n}=jt.pathH(t).point;return e.push(i,n),Lt.LINE_TO}pathV(t,e){const{x:i,y:n}=jt.pathV(t).point;return e.push(i,n),Lt.LINE_TO}pathC(t,e){const{point:i,controlPoint:n,currentPoint:A}=jt.pathC(t);e.push(i.x,i.y,n.x,n.y,A.x,A.y)}pathS(t,e){const{point:i,controlPoint:n,currentPoint:A}=jt.pathS(t);return e.push(i.x,i.y,n.x,n.y,A.x,A.y),Lt.CURVE_TO}pathQ(t,e){const{controlPoint:i,currentPoint:n}=jt.pathQ(t);e.push(i.x,i.y,n.x,n.y)}pathT(t,e){const{controlPoint:i,currentPoint:n}=jt.pathT(t);return e.push(i.x,i.y,n.x,n.y),Lt.QUAD_TO}pathA(t){let{rX:e,rY:i,sweepFlag:n,xAxisRotation:A,centp:a,a1:r,ad:s}=jt.pathA(t);return 0===n&&s>0&&(s-=2*Math.PI),1===n&&s<0&&(s+=2*Math.PI),[a.x,a.y,e,i,r,s,A,n]}calcLength(t,e,i,n){let A=0,a=null,r=null,s=0;switch(i){case Lt.LINE_TO:return this.getLineLength(t,e,n[0],n[1]);case Lt.CURVE_TO:for(A=0,a=this.getPointOnCubicBezier(0,t,e,n[0],n[1],n[2],n[3],n[4],n[5]),s=.01;s<=1;s+=.01)r=this.getPointOnCubicBezier(s,t,e,n[0],n[1],n[2],n[3],n[4],n[5]),A+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return A;case Lt.QUAD_TO:for(A=0,a=this.getPointOnQuadraticBezier(0,t,e,n[0],n[1],n[2],n[3]),s=.01;s<=1;s+=.01)r=this.getPointOnQuadraticBezier(s,t,e,n[0],n[1],n[2],n[3]),A+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return A;case Lt.ARC:{A=0;const t=n[4],e=n[5],i=n[4]+e;let o=Math.PI/180;if(Math.abs(t-i)<o&&(o=Math.abs(t-i)),a=this.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],t,0),e<0)for(s=t-o;s>i;s-=o)r=this.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],s,0),A+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;else for(s=t+o;s<i;s+=o)r=this.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],s,0),A+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return r=this.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),A+=this.getLineLength(a.x,a.y,r.x,r.y),A}}return 0}getPointOnLine(t,e,i,n,A){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:i;const s=(A-i)/(n-e+L);let o=Math.sqrt(t*t/(1+s*s));n<e&&(o*=-1);let c=s*o,l=null;if(n===e)l={x:a,y:r+c};else if((r-i)/(a-e+L)===s)l={x:a+o,y:r+c};else{let g=0,h=0;const d=this.getLineLength(e,i,n,A);if(d<L)return null;let u=(a-e)*(n-e)+(r-i)*(A-i);u/=d*d,g=e+u*(n-e),h=i+u*(A-i);const w=this.getLineLength(a,r,g,h),B=Math.sqrt(t*t-w*w);o=Math.sqrt(B*B/(1+s*s)),n<e&&(o*=-1),c=s*o,l={x:g+o,y:h+c}}return l}getPointOnPath(t){const e=this.getPathLength();let i=0,n=null;if(t<-5e-5||t-5e-5>e)return null;const{dataArray:A}=this;for(const e of A){if(e&&(e.pathLength<5e-5||i+e.pathLength+5e-5<t)){i+=e.pathLength;continue}const A=t-i;let a=0;switch(e.type){case Lt.LINE_TO:n=this.getPointOnLine(A,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],i=e.points[5],r=e.points[4]+i;if(a=t+A/e.pathLength*i,i<0&&a<r||i>=0&&a>r)break;n=this.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],a,e.points[6]);break}case Lt.CURVE_TO:a=A/e.pathLength,a>1&&(a=1),n=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=A/e.pathLength,a>1&&(a=1),n=this.getPointOnQuadraticBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}if(n)return n;break}return null}getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-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,i,n,A,a,r,s,o){return{x:s*K(t)+a*W(t)+n*X(t)+e*q(t),y:o*K(t)+r*W(t)+A*X(t)+i*q(t)}}getPointOnQuadraticBezier(t,e,i,n,A,a,r){return{x:a*Z(t)+n*$(t)+e*_(t),y:r*Z(t)+A*$(t)+i*_(t)}}getPointOnEllipticalArc(t,e,i,n,A,a){const r=Math.cos(a),s=Math.sin(a),o=i*Math.cos(A),c=n*Math.sin(A);return{x:t+(o*r-c*s),y:e+(o*s+c*r)}}buildEquidistantCache(t,e){const i=this.getPathLength(),n=e||.25,A=t||i/100;if(!this.equidistantCache||this.equidistantCache.step!==A||this.equidistantCache.precision!==n){this.equidistantCache={step:A,precision:n,points:[]};let t=0;for(let e=0;e<=i;e+=n){const i=this.getPointOnPath(e),a=this.getPointOnPath(e+n);i&&a&&(t+=this.getLineLength(i.x,i.y,a.x,a.y),t>=A&&(this.equidistantCache.points.push({x:i.x,y:i.y,distance:e}),t-=A))}}}getEquidistantPointOnPath(t,e,i){if(this.buildEquidistantCache(e,i),t<0||t-this.getPathLength()>5e-5)return null;const n=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[n]||null}constructor(t,e,i){super(t,e,i),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 n=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(n)}},image:class extends Rt{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),i=await e.text();this.image=i}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}renderChildren(t){const{document:e,image:i,loaded:n}=this,A=this.getAttribute("x").getPixels("x"),a=this.getAttribute("y").getPixels("y"),r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");if(n&&i&&r&&s){if(t.save(),t.translate(A,a),"string"==typeof i){const n=e.pith.forkString(t,i,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:r,scaleHeight:s}),{documentElement:A}=n.document;A&&(A.parent=this),n.resize(r,s,this.getAttribute("preserveAspectRatio").getString()),n.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r,desiredWidth:i.width,height:s,desiredHeight:i.height}),this.loaded&&("complete"in i&&!i.complete||t.drawImage(i,0,0));t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),i=this.getStyle("width").getPixels("x"),n=this.getStyle("height").getPixels("y");return new kt(t,e,t+i,e+n)}constructor(t,e,i){super(t,e,i),he(this,"type","image"),he(this,"loaded",!1),he(this,"image",void 0);const n=this.getHrefAttribute().getString();if(!n)return;const A=n.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(n);t.images.push(this),A?this.loadSvg(n):this.loadImage(n)}},g:Zt,symbol:class extends Rt{render(t){}constructor(...t){var e,i,n;super(...t),n="symbol",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},style:pe,use:class extends Rt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),i=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),i.hasValue()&&t.translate(0,i.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:i}=this;if(i){let n=i;if("symbol"===i.type&&(n=new Kt(e),n.attributes.viewBox=new et(e,"viewBox",i.getAttribute("viewBox").getString()),n.attributes.preserveAspectRatio=new et(e,"preserveAspectRatio",i.getAttribute("preserveAspectRatio").getString()),n.attributes.overflow=new et(e,"overflow",i.getAttribute("overflow").getString()),n.children=i.children,i.styles.opacity=new et(e,"opacity",this.calculateOpacity())),"svg"===n.type){const t=this.getStyle("width",!1,!0),i=this.getStyle("height",!1,!0);t.hasValue()&&(n.attributes.width=new et(e,"width",t.getString())),i.hasValue()&&(n.attributes.height=new et(e,"height",i.getString()))}const A=n.parent;n.parent=this,n.render(t),n.parent=A}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?Dt.fromElement(t,e):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...t){super(...t),me(this,"type","use"),me(this,"cachedElement",void 0)}},mask:xe,clipPath:class extends vt{apply(t){const{document:e}=this,i=Reflect.getPrototypeOf(t),{beginPath:n,closePath:A}=t;i&&(i.beginPath=ve,i.closePath=ve),Reflect.apply(n,t,[]),this.children.forEach((n=>{if(!("path"in n))return;let a="elementTransform"in n?n.elementTransform():null;a||(a=Dt.fromElement(e,n)),a&&a.apply(t),n.path(t),i&&(i.closePath=A),a&&a.unapply(t)})),Reflect.apply(A,t,[]),t.clip(),i&&(i.beginPath=n,i.closePath=A)}render(t){}constructor(...t){var e,i,n;super(...t),n="clipPath",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},filter:Fe,feDropShadow:class extends vt{apply(t,e,i,n,A){}constructor(t,e,i){var n,A,a;super(t,e,i),a="feDropShadow",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.addStylesFromStyleDefinition()}},feMorphology:class extends vt{apply(t,e,i,n,A){}constructor(...t){var e,i,n;super(...t),n="feMorphology",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},feComposite:class extends vt{apply(t,e,i,n,A){}constructor(...t){var e,i,n;super(...t),n="feComposite",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},feColorMatrix:Ie,feGaussianBlur:Se,title:class extends vt{constructor(...t){var e,i,n;super(...t),n="title",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},desc:class extends vt{constructor(...t){var e,i,n;super(...t),n="desc",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}};function Ye(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ne{bindCreateImage(t,e){return"boolean"==typeof e?(i,n)=>t(i,"boolean"==typeof n?n: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(/^[^:]+:/,""),i=Ne.elementTypes[e];return i?new i(this,t):new Mt(this,t)}createTextNode(t){return new Ot(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=12,emSize:i=12,createCanvas:n=Ne.createCanvas,createImage:A=Ne.createImage,anonymousCrossOrigin:a}={}){Ye(this,"pith",void 0),Ye(this,"rootEmSize",void 0),Ye(this,"documentElement",void 0),Ye(this,"screen",void 0),Ye(this,"createCanvas",void 0),Ye(this,"createImage",void 0),Ye(this,"definitions",void 0),Ye(this,"styles",void 0),Ye(this,"stylesSpecificity",void 0),Ye(this,"images",void 0),Ye(this,"fonts",void 0),Ye(this,"emSizeStack",void 0),Ye(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=i,this.createCanvas=n,this.createImage=this.bindCreateImage(A,a),this.screen.wait((()=>this.isImagesLoaded())),this.screen.wait((()=>this.isFontsLoaded()))}}function ke(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Ye(Ne,"createCanvas",(function(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i})),Ye(Ne,"createImage",(async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=document.createElement("img");return e&&(i.crossOrigin="Anonymous"),new Promise(((e,n)=>{i.onload=()=>{e(i)},i.onerror=(t,e,i,A,a)=>{n(a)},i.src=t}))})),Ye(Ne,"elementTypes",Pe);class Re{static async from(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new Bt(i),A=await n.parse(e);return new Re(t,A,i)}static fromString(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new Bt(i).parseFromString(e);return new Re(t,n,i)}fork(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Re.from(t,e,{...this.options,...i})}forkString(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Re.fromString(t,e,{...this.options,...i})}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:i,options:n}=this;i.start(e,{enableRedraw:!0,...n,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,i)}constructor(t,e,i={}){ke(this,"parser",void 0),ke(this,"screen",void 0),ke(this,"document",void 0),ke(this,"documentElement",void 0),ke(this,"options",void 0),this.parser=new Bt(i),this.screen=new ht(t,i),this.options=i;const n=new Ne(this,i),A=n.createDocumentElement(e);this.document=n,this.documentElement=A}}function He(t,e,i,n){Object.defineProperty(t,e,{get:i,set:n,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",(()=>$n)),He(Ge,"UpdateWorkflowStateCommand",(()=>_n)),He(Ge,"MoveCommand",(()=>tA)),He(Ge,"RotateCommand",(()=>eA)),He(Ge,"ResizeCommand",(()=>iA)),He(Ge,"GroupCommand",(()=>nA)),He(Ge,"CreateLayoutCommand",(()=>AA)),He(Ge,"ClearLayoutCommand",(()=>aA)),He(Ge,"CreateElementCommand",(()=>rA)),He(Ge,"DeleteElementCommand",(()=>sA)),He(Ge,"CloneElementCommand",(()=>oA)),He(Ge,"FontColorCommand",(()=>cA)),He(Ge,"FontImageFillCommand",(()=>lA)),He(Ge,"FontSizeCommand",(()=>gA)),He(Ge,"FontAlgorithmCommand",(()=>hA)),He(Ge,"FontSourceCommand",(()=>dA)),He(Ge,"FontAlignmentCommand",(()=>uA)),He(Ge,"UpdateFramePattern",(()=>wA)),He(Ge,"TextChangeCommand",(()=>BA)),He(Ge,"IllustrationColorCommand",(()=>pA)),He(Ge,"IllustrationCacheCommand",(()=>mA)),He(Ge,"BringToFrontCommand",(()=>EA)),He(Ge,"BringToBackCommand",(()=>fA)),He(Ge,"BringForwardCommand",(()=>CA)),He(Ge,"SendBackwardsCommand",(()=>QA)),He(Ge,"LayerCommand",(()=>yA)),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",(()=>Kn)),He(Oe,"findElement",(()=>Wn)),He(Oe,"findLayoutForElement",(()=>Xn)),He(Oe,"updatedLayoutForElement",(()=>qn)),He(Oe,"rehydrateSerializedLayout",(()=>Zn));var Je={};He(Je,"CommandContext",(()=>Ln)),He(Je,"getSvgElement",(()=>jn)),He(Je,"elementFactory",(()=>zn)),He(Je,"sortElementsByLayersWithIndex",(()=>Vn)),He({},"SVGLayout",(()=>gi));var Le={};let ze;var je;let Ve;var Ke;let We;var Xe;let qe;var Ze;let $e;var _e;let ti,ei;var ii;let ni;var Ai;let ai;var ri;let si;var oi;let ci;var li;He(Le,"LayoutElementType",(()=>ze)),He(Le,"LayoutRenderingPurpose",(()=>Ve)),He(Le,"TextAlgorithm",(()=>We)),He(Le,"UnitOfMeasurement",(()=>qe)),He(Le,"ScaleAxis",(()=>$e)),He(Le,"AspectConditionAction",(()=>ti)),He(Le,"AspectType",(()=>ei)),He(Le,"MaterialEffectMode",(()=>ni)),He(Le,"AssetType",(()=>ai)),He(Le,"StepType",(()=>si)),He(Le,"StepAspectType",(()=>ci)),(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",(ti||(ti={})).Show="Show",(ii=ei||(ei={})).FileUpload="FileUpload",ii.Option="Option",ii.Text="Text",(Ai=ni||(ni={})).None="None",Ai.RemoveWhenSelected="RemoveWhenSelected",Ai.ApplyWhenSelected="ApplyWhenSelected",(ri=ai||(ai={})).Font="Font",ri.Frame="Frame",ri.Illustration="Illustration",ri.Image="Image",ri.Model="Model",ri.Material="Material",ri.Color="Color",ri.QuestionnaireCollateral="QuestionnaireCollateral",ri.RequestCollateral="RequestCollateral",ri.SignupCollateral="SignupCollateral",ri.Video="Video",ri.ColorProfile="ColorProfile",(oi=si||(si={})).Bulk="Bulk",oi.DigitalContent="DigitalContent",oi.Finish="Finish",oi.Frame="Frame",oi.Illustration="Illustration",oi.Introduction="Introduction",oi.Material="Material",oi.Model="Model",oi.Module="Module",oi.Picture="Picture",oi.Photo="Photo",oi.ProductOverlay="ProductOverlay",oi.Question="Question",oi.Shape="Shape",oi.SilentIllustration="SilentIllustration",oi.Text="Text",(li=ci||(ci={})).Color="Color",li.Colors="Colors",li.Selection="Selection",li.Selections="Selections",li.Text="Text",li.Upload="Upload";const gi=({backgroundColor:t,outlineColor:e,borderRadius:n,configuration:A,elements:a,height:r,maxHeight:s,maxWidth:o,outlineArea:c,position:l,preserveAspectRatio:g,viewBox:h,width:d})=>{const u=n||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}`,m=Te(),E=A.purpose===Ve.FreeDesign&&(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"viewboxClip",children:(0,i.jsx)("rect",{width:B.width,height:B.height,rx:u})})}),f=A.colorProfiles?.map(((t,e)=>(0,i.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),C=Vn(a.map((t=>({...t,_renderingConfiguration:A,mask:c?`url(#viewmask-${m})`:void 0}))));return(0,i.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:[f,E,!!t&&(0,i.jsx)("rect",{id:"layout-background",width:B.width,height:B.height,fill:t,rx:u}),(0,i.jsx)("g",{id:"element-group",clipPath:A.purpose===Ve.FreeDesign?"url(#viewboxClip)":void 0,children:C.map((t=>zn(t))).filter((t=>!!t))}),c&&(0,i.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,i.jsxs)("mask",{id:`viewmask-${m}`,children:[(0,i.jsx)("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"black"}),(0,i.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};He({},"Image",(()=>bi));var hi={};He(hi,"getAxisAlignedBoundingBox",(()=>di)),He(hi,"degreesToRadians",(()=>wi)),He(hi,"findAngle",(()=>ui)),He(hi,"radiansToDegrees",(()=>Bi)),He(hi,"isCloseToValue",(()=>pi)),He(hi,"getTrueCoordinates",(()=>mi)),He(hi,"getPointOfRotation",(()=>Ei)),He(hi,"getNWPoint",(()=>fi)),He(hi,"getNEPoint",(()=>Ci)),He(hi,"getSWPoint",(()=>Qi)),He(hi,"getSEPoint",(()=>yi)),He(hi,"turnRightClockwise",(()=>Ii)),He(hi,"currentDirection",(()=>Di)),He(hi,"getElementVertices",(()=>xi)),He(hi,"rotateAroundPoint",(()=>vi)),He(hi,"mmPerPixel",(()=>Mi)),He(hi,"cmPerPixel",(()=>Si));const di=(t,e,i,n,A)=>{const a=wi(A),r=i/2,s=n/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)),m=Math.max(Math.abs(w),Math.abs(B));return{minX:o-p,maxX:o+p,minY:c-m,maxY:c+m}},ui=(t,e,i)=>{const n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),A=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((A*A+n*n-a*a)/(2*A*n))*(180/Math.PI)},wi=t=>t*(Math.PI/180),Bi=t=>t*(180/Math.PI),pi=(t,e,i)=>Math.abs(t-e)<i,mi=(t,e,i)=>{const n=Math.sin(wi(i)),A=Math.cos(wi(i));return{x:(t.x-e.x)*A-(t.y-e.y)*n+e.x,y:(t.x-e.x)*n+(t.y-e.y)*A+e.y}},Ei=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),fi=(t,e,i,n)=>({x:t.x+e?.x*i,y:t.y+e?.y*n}),Ci=(t,e,i,n)=>({x:t.x+(e?.x+e?.width)*i,y:t.y+e?.y*n}),Qi=(t,e,i,n)=>({x:t.x+e?.x*i,y:t.y+(e?.y+e?.height)*n}),yi=(t,e,i,n)=>({x:t.x+(e?.x+e?.width)*i,y:t.y+(e?.y+e?.height)*n}),Ii=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}},Di=(t,e)=>e>45&&e<=135?Ii(t):e>135&&e<=225?Ii(Ii(t)):e>225&&e<=315?Ii(Ii(Ii(t))):t,xi=(t,e={x:0,y:0},i={x:1,y:1})=>{const n=wi(t.rotation),A={x:e.x+t.x*i.x,y:e.x+t.y*i.y},a={x:t.x+t.width,y:t.y},r={x:e.x+(t.x+t.width)*i.x,y:e.y+(t.height+t.y)*i.y},s={x:e.x+t.x*i.x,y:e.y+(t.height+t.y)*i.y},o={x:(s.x+r.x)/2,y:s.y-t.height*i.y/2};return{a:vi(A,o,n),b:vi(a,o,n),c:vi(r,o,n),d:vi(s,o,n),center:o}},vi=(t,e,i)=>{const n=Math.sin(i),A=Math.cos(i);return{x:(t.x-e.x)*A-(t.y-e.y)*n+e.x,y:(t.x-e.x)*n+(t.y-e.y)*A+e.y}},Mi=.352778,Si=.035277,bi=t=>{const e=t.rotation||0,n=wi(e),A=Math.cos(n),a=-Math.sin(n);return(0,i.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,i.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(${A}, ${-a}, ${a}, ${A}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `,children:(0,i.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};He({},"Frame",(()=>Pi));const Fi=256,Pi=t=>{const e=`spiff-frame-${t.id}`,A=`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,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsSAAALEgHS3X78AAAZL0lEQVR4nO2diVIbSRZFq/GCsZBZjRea6fn/r+oZGrMYBBhkLGwzE1cmTSqVWXuqVFXnRHREG6OlpX43X771j5O/7/+XAEAvWeFrB+gvCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAECPQQAAGuLnz5+Nf/QIAEADyPhHl+fJ5/PTRj/+53z5AItFxn9y+in5Nvn2+3Xf7r5r5FvAAwBYID7jH4/Hyfcf3xv5GhAAgAXhM/5nK8+SD+8/Ji+ev2jka0AAABZAmvGvrr5q7CsgBgAQGZ/x68R/t/e+UeNPEACAuPiM/9Xqq+T9u4/Js2fPGv/0uQIARGLZjT/BAwCIw2TyLTk9O5mJ7i+b8ScIAED9yPiPTz4lPx+eKv2W0fgTrgAA9VKn8esKcXx8NH3OWCAAADUhd981frG9tVPK+BU/+Prt6/Q5Y4kAAgBQE0rtDQaDuSdTLKCIAbvBQwnKaHQR5WtCAABqRDX9b4ZvZp5QBpz3FA9lDvb23kf5mhAAgJpJE4G0mv8m0oYIAEAEQiJwdnbinQPQVM0AAgAQCZ8IyMBl6LYIyCtoqmAIAQAoyZeb68w2XonAK6fe3xYBxQWOjg4bqxZkOzBAQW7HN9OovIxfJ3zWMA+fe588Gvr3798bLRjCAwDIiQz59Ox4psT3y82XTC9Axiyj9nkCdRq/3l/ROYMIAEAOpq76p8Pkdnw788vq6R/f3mQ+QUgEDPIk9j8eVDJ+eRnnF2eFHkcvAEAGvvJesbO1kwyHG7mN1oiA7zpQhZkrxiRJVs5Pc88YxAMASCFU2//nx4Nkc3O78Ikd8gR0lSgzIdgXX7i/v899FUAAAAL4jF+uugy4yiQfiYAq+3R9sCkqAnXUDiAAAB5kXOcXn+eMX651HRF69Q1oHmBZETAxiarpQwQAwMP19eWMceVJ9xVFXkQZETCeSR3DRhAAAIe7u6/J5fXl7x/KuLa3dit9TKE7eVERqHvYCAIA4HB1dTnzg92dt5XcflUMHv7zn2A3YJoI6LGGGJOGEAAACxmZhnAY5PpXCfjJgD+fn02NdhpTKOgJ6LF6jlhjxhAAAIuxU+jzZrhR+uMxxm/wNQLZSATeefr+9Ryu8a8P1mspGUYAACzsSj9F6sue/q7xG7JEYG3tdfJ2d2/u52424t3eh1qyEQgAwCOKqtuR9bW1tVIfzdXVyGv8hiwRkNfhE4EkQjYCAQB45Mf32aaeMgs7Fbm/uHya36c7vaoG88wFsPGJQIxUJAIA8Ihb618UGb8i9wZ7+acM9/Wr1zPPWEQEYhh/ggAAPOF6AEVwjdi3+Vflv76W4NHlefCVJAIf3+9HMf4EAQB4wg34PTw85P50FJAzI8BCa7/LNgIpMBgLBAAgwN23u8IfjSoG03b+190NWBUEAOAR96SVe5417cdFBp6VOkwTgdEofB2IAQIAYOEG6pTSi4ERATfTsLKyWJNEAAAs3Nx/npl/ZXn438PMc0sMhhUqD8uAAABYTEd8OfX4WuYRA9fd394uvkS0KggAgIUMcHNjc+ZnigXUHaDT1cIuO1Zt//pguPCvAgGATqA8vN06WwWfF+C25lZBz2NXC8r1393xl/7GBgGA1mNm46n+/r+Hf1c2VHkBoa68qkFBt0lIQqPXWrTrb2AzELSa0NYdnaq6U1dxq2Xs9kltkLuuE7uI0ep9quLPLhVOpqvD9iq1HFcFAYDWEjJ+G6X1Nje3SlfTufX9Bp3cihXk2QugU19ThtxsQtPGnyAA0GYkABq1ZZp4ZJShhp4qQhASAfOag8FgWvwjr+P5ixfTngK9j/vJZBro86URl8H4EwQA2o5rnDKsm5svQa+grBCErgNFkUjozl9lzFidIADQanS6KvBnkIF/+LA/Ndir66tUj2D37V6hnn/N5dNcv7JrvdQopF6BpgJ+PhAAaD2uF6D2WZ3wuiLcOCk3FxmlVnwVEYLQnT6EgoZy92N29ZUFAYDWE/ICDPp7eQShe3xSUgjkEWiI6GQySSb3k9/exq9ZgqvJ6svVZLA+LDVZaFEgANAJjo+PZsZ5Gy/AJpYQtBkEADqBtvl8Ojn6/Z+iVlvt2/eRRwiKrv5uKwgAdIY8XoCNREN3efsxNkVy/W2FUmDoDErv2bgrvlwkDooVuDMADLrTK4CoWgN5DHl37rcJBAA6gwzavrvrZNcpn4YyCCEPwNBlIUAAoFO4XkBaY5CbPlTc4F8H/062Nra8v28LQV2dgU2DAMBSYRZhlkX5dtsLCJXi+ozfjOja3t6dCoG7zMMgITCdh7fjm1b/D4QAwNJgWmW1CDPLdU9jPhbw1MIr9/3o06HX+O1An4RAY77ThEBjw9ueLkQAYCnQiWz65HXCKqVX1s0evF6fGehh5vr5ugezVmyHhCA0+79tkAaExknrtivbNec278h47+/vZ4y/TF+/PBMJ0+bGVuuNXzxfgvcAEERewcPPn9PqvCIod283A7kCU3bXnjINy1jTXxauANA4rnG7CzN0khcdyqlTPXR3j7Vos40gANA4umfbxTgrf6zMGW+Z1VnDN/NXB7n9GP8TCAAsBcM3TwavwhzN8vOJwOnZce5CHAlLyAuAXyAAsBTI4O2Umsp4zbZdG+X103bqu7jXi1BdQF9BAGBpsPP38gJUEOQTAUXy84qAREVuv02sfX9tBAGApWE+f/+rDiBNBPJUDbppxJj7/toGAgBLgxu5tw01JAKqGswSAaXtFrX1t20gALBUuJF721B9IqA8fx4RmG8SwgtIEABYNtzIvWuoEgFN67ExIpBWOiwvwK0vuPnSjY6+KiAAsHS467zGt7Mdd4rsq0TYxnTopYnA0JNW7OKQjyIgALB0uKf1tKTXMVQF9lwRSB5Lh0Mi4LYKSzRuOtLXXxYEAGpDRqpqvSqtvAb7tA4ZqhEBd5W3RGA0Ovc+rxsLUEtvn0EAoBYUhDN99mrl1YDOKkLgntahbkH9ntpyXRG4vL70lg6/sXb/Tzf1bO/2+n8ABAAqM3lMx9nBOhXyVBUCOxio5w659mrL9YlAqH9Ak35pCPoF8wCgEjLMo6PD4A4+Q5mlnO72X3fjj4sRIve96HF7e+9/9/3rebs+7z8veABQCbnpa2trM0+hk9gdlVXGI5CRavW2/Rxp+X55Agd//jWX7tPj7NJhjP8JBAAqo6k6ttHpBJYouPn6pIQQuM08WWPCZNwa8eWKQJH+gT6BAEBlZHRTF9uZw6cIu2bp+RZv5BWCrMIgHyERUGaB038WBABqQYaqQJyNIvEybt3btabLN0E3jxC4XoBbGOTDiIDEQ8Kk1y8zW7DrEASEWjGjvW3swZ76+9HoIhg0lLew+3ZvTizswaEyaN31857miht0YYBnDPAAIBd5784ydHezjgzeBO/09zJexQfctF3y6BFo4YYM3nb1bS9A4jH+epv7i8P4wyAAkIkp8sm7sUfFNfYQDrdjTye3DDpNCHTaK71odvG5sYCsxZ+QDwQAUrGLfPK03Rp8mYHzi88znoQRgv39A+/sPrOLT+KjFVy2F6D30/a1XMsAMQAI4ivyKbIRx/d4icL+x4Pg7+vED5X9Kj6w8mxlOtcvyVEYBNngAUAQud12IU5SYABHEsgMKB8fGu+dtY9P8QFj/EmOwiDIBgGAVKpM4UkeA3Bu265O+FC3XmIJwZ8fD7w1BLPPxVCPKiAAkEmaCOQZq+XLDKhGIMt4p00+jzUEISFgqEc1EADIRUgEzs5OchmgmxlIHvv283gRaiAKCcEbqvsqQRAQCuHb5Ju1YtvgW89dZs22KgZHlxfJy5cvaemtCAIAhVFa7ptzcucVgVBmIM9joX64AkBhqnTbhTIDukrA4kEAoDBVW259mQGl9Ipu/4XqIABQiqoi4MsMKLbAxp7FggBAadJEYHQZzvMbfJkBlf5S4rs4EACoREgEQgM5XdyeAXF+/pkKvwWBAEBlfBOBkpwi4HusKTKiwCc+CADUgonulxEBX2aArT2LAQGA2ig6n9/GzQyows8dBQb1QyEQ1E5oPn+eZRxqEtLjqPBbDAgARCEkAvZ8QGgeBKDjKJB2fz+Zi6o/f/EiWXv1Omr5LSKw/CAAHUW59PH4dmaAhg911w3W16MZpBp3NPbbBRFYDhCAjmE65dxmnSyUi9/deRtlgq5vVHiCCCwFCEBHkKt/fX05HbRRBU3pjRF9D4mAevyLLAyFennO59l+1GKrbjrfqa+TffB6dq7f5H6S3N3deZdzqBRXz1d3FN6c9LYIKCuA8TcLAtByfIE25eG1A3+wPvSu4zLoVNZ8fXeslxn4EVME2M+/HHAFaDE+4w+t1gqhq4Mad3yjuGMZqeIUnPzLAQLQUnzGX+X+TqCun1AK3EJ8xi9DrRK8k5G7QzqSx71+eSb/QjtBAFpGyPjrOKV9IjBd6fV53jOAboAAtAjd12MZv0HP5Y7/1riu0O5+aDcIQEswI7Vt45ehxrifb2/tzgUR2cbbTRCAlqBIvZvnXx8Mo7z5X1t7Z+f1yQsgFtA9EIAWc3p2Em10ljwL1wsY3zKrr2sgAC2h6pLOMrivpwpC6BYIQIuouqSzKG6xzo8fP/r3oXccBKBlVF3SWQS3M7BohyEsPwhAC/GJQN6FHEXJW1IM7QQBaCkSgbJbeYrw8PDw+7fdYZ/QfhCAFlNlNVde7LqD1Zerff/IOwcC0GKq7ufLws0urK2t9f0j7xwIQMuJKQJu+S8tvN0DAWgAGeWXGrfeVF3SGcKeEaBgYIx5gdAsCMCCMTX96r3/7+HftQlB1SWdLnpfdm2BWxoM3QABWCDG+E0+XQZmhKCOldhVlnTaTKcEjS5+/0SnP0NBugkCsCBc47eREKiu//j4qHLbbZUlnYbzi7O5lmPoJgjAAvn+/cml9uXU1XGnJRpVhaDKkk79vb1MZGtji+Bfh0EAFoTc88HgaTz3rwWYe3N39qQmISgjArr324E/vbeNDe7+XQYBWCDuzL7x7W2y//FgOswzyyMo0+yTJgJu8FFbee2hoHrMNJ4QcXcgNA9TgReMTl/7lDWbcRQjuLm5ni7mCGF25hetz89a0um+Jxm/hIO0X/dBABaMTnJF/Q2a4//hw/7vP+vvr65G3jn9hjJCEFrSqeewvQuMv18gAA0gl17uvcG3Hy+GEIRm/xsw/v6BADSAexor2KZYgI88QqAYwnC4keu+HhKBmNuBYXlBABoijxdgI9HQZF77MTZmH2AeIXBFQMavKkICfv2DLEBDuKW1WWO3JQ6KFShm4EMBPgUQD//5z9RjSGsCsheA6BqB8fcXtgM3hAzaDsCZ5RtpXoCi9SEPwGCE4Or6KtUjMFN/KfLpN3gADeJ6AWmNQW6qTm77vw7+Pa3U82F7BKHnxfiBGEDDKCVop+Fk1G5U32f8ttueJ1Co59ze3om2TATaCR5Aw8zHAka//133+KNPh6nGnzwat2YESjzcYaEGzfZjwCe4IAANM3i9PlOqK2PXie7rHsyK1oeEgPw+hOAKsATo1LdLgGW89/f3M8a/PlhPdnf2CkXrFVTU/X9zYwvjBy8IQAl0Qqu+/sf32Qad5y9eJGuvXhdOqem0V7DOrdU3SBB0sgPUDWnAAug0VQdfVipOrvqwwOpuCYaM/PJ6vhYA44eYIAA50Gl/fvE592os/Z7+UXGPgnx5hGD4ZmNOAOT2Y/wQE4KAGejU/+fTYam9eGbm3+nZceZ47l9z9/wRfIBY4AGk4ObfDSrHdZdk3N3dBa8GGrGlv8+KxKuzz349PW77x3fSdxANgoAB3Mh8kqP91gz1MKk8lzzpOHkL9kw+YgAQE64AHpQ+s41fhvtu7/3UENNOYwXzJBBmzJeL2eXvrtyyceMFITEBqAMEwEGnuDsbT6d2kRJaIwRq8XXn8RkRCBm16vPdjj+7OhCgThAAhxt3I87GZukiGhnzwZ9/zU3+lQicnZ0EHzffJIQXAHFAABzcunt3km9R0vb2hU52CYf7+zdf6tslCGBAACy0nss+aYc1peVCK7sUZwid7O5rS5jq2vkPYEAALNzSXjXq1IWCh7u7b+eeLeQFmIEdBl0bbmrcKAyQIACzKFdvU/eYLAUS3WKftPu9GwtQSy9AnSAAAUKz96riiymMb/2bgeUFmGuDhGN7ezfmfzL0EATAwq7ky2r4KYuv5Hf8dRx8NmUhKAaCWCAAFnPpukhBN7fYJ63PYDid4IvxQxwQAIuVP2Y/jrtIXoDqCtyKwlB1IOO6ISYIgMXq6urMn6vs6M/CFQACfNAECIDFS0cAYube3W5CgCZAACzWPJF/cu/QZRAACzOay0bVemnde2WZ3E9mHsmSDmgCBMDBl6fXOLC6rwKTyZMAuNkHgEWBADj48vRK040uz2t7DXkUdvXf2iviAdAMCICH7a3ducYdBQQ1IqwO3F19GggK0ASdEYA6XXTFAnyNO3WIwK9lHU8tx/I2mPkHTdEJAZBLrR16dQbr1Ljj27wr480z5deH3t+pNQhEXkbVeQMAVWi9AMiozIitrHl7RVHzjW9Ut4Z2pq3d9qFZA3p/9vYfbevl9IcmafVUYBn90dHhjFHFWIQZGg+eWEHDwfrQa8wy/JsvX+aai2jwgWWg9WPBfcYZQwR8Y8JdJAC2CCjX79v3h/HDstCJvQCLEgEF8DQxuOyATr0nuf15dwYCxKYzi0FCIrC/f1D7PVvewNX1VXCbrw8NGNl9u8edH5aKTm0G8omAquw0lbfutlplAcZfb6degUaJ+cRAxq4Fn4PBOvv5YSnp3GqwRYqAja4F9lDRly9X6eWHpaeTuwGPPNt8FyECAG2jNXUAcrnlbucJwIUWcZycfmK2PoDFUnsAMnZtxFHhjW34Cu4NBoPMTb0y+JiegF4DjwLazFIKgAzr+voyuby+zPxdleuGxmXHFAHz3NrgQ1oP2srSXQEmj656HuMX+r1Qg07aXr4q7b22sKguoEhJMMAysVQCYOr63RNbbr7y6PrHbdNNMrr0QiJQtrPP51XcsLcPWsrSXAF0itp7+ZPH4hmtx3LHZel3R6OLudz7u733wT3+vr6BpGBZrs/4yS5Am1kKD0ANM67x72ztJB8+7Htn5enOrTJf1xuQKISQF+F7TF5PwLQcY/zQJRoXABnW+fnnmZ+93d3L7JNXZZ0M2kanfNp93DymqAjYLccGjB+6QKMCYAzLdstl/Hmj6jJot18/ax5AURHwvUeMH7pCYwKg+/R02q5lWHL7i6bU3N//8f1H5mPSRMD2IDB+6DqNCcD5xdlctL/MbPyyTTYhETBpPYwf+kBjArCyMv/SdY/0ykIioMyBi0TANX519WH80DUaEwCl3tz7uwyuqAi4vQFFd+7J61DcwcU2fr3Pd3sfMH7oHI0GAdNEIO/UHXeDb5krwZvpDv55EUgY3wUdp/E0YEgEzs5OMqvr9PdXV08lw8r1l92x5xMBjB+6TnQByLNj3ycCedp3Vc9vewqqGqyCLQIYP/SBqAKgvPqnk6NczTIytiI9/HpOe/KPyobr6MrTc3x8v4/xQy+IJgD2aK68HXN5B3m4fQNK5WngZl2wqhv6QhQBcPffJY8ikHUdSGvflQjI3ZewuMavfD7TdgGKE60bcDQ6n+vpzzurPzTIwyXG7H+APhHtCuDbq5c3zx/yBGZ+B+MHqEzUIGCVYp80EZDxH/z5F8YPUJHoacCqIrC3936uXl+PrzLSCwB+sZBCoCoiUHWQBwCEWVglYJoIZFX8lR3kAQDpLLQU2FfsIxHIs7ADEQCon4X3AlTZ2pN3kAcA5GPhApBV7FNWBJjPD1Cc3AJQ59z7OkQgNMgDEQDITy4BMCOx65zWkyYCagXOIjTIAxEAyE+mANgjsese2RUSga/fvuYK7IUGeeTpOwCADAEwRm/GY5UZ2ZVFqNhHgT0tDMkiNMiDjj6AbFIFQEU4WsNtE0MEQsU+WhiSJ/bAIA+AcuTqBrR7+w0xmnHktmuAiE3a+m/f4zn5AfKTKwhYx/DOPMh4tRzERi3FeTMQGD9AMXKnASUCmo1vk3d4ZxGGw4254R7jr7d8rQARKFQItLuzVzp3nxcFBV1vg4g+QBwKCUDVAp68DJ3hnpPJhK8fIAKFS4EXIQJ6DfsaUGecAQCeKNULsAgRYMgnQHxKNwPFFgH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC";if(!s())return(0,i.jsx)(b(n).Fragment,{});const o=!!t.focalBlur&&!!t.pattern,c=t.rotation||0,l=wi(c),g=Math.cos(l),h=-Math.sin(l);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("defs",{children:(n=>{const o=t.pattern?.x||0,c=t.pattern?.y||0,l=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(o):0,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(c):0,h=t.dataWidth||l||Fi,d=t.dataHeight||g||256,u=t.pattern?t.pattern.width*t.pattern.scaleX:Fi,w=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,i.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,i.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:Fi,height:t.pattern?1:Fi,"data-frame-width":t.pattern?h:void 0,"data-frame-height":t.pattern?d:void 0,id:e,children:(0,i.jsx)("image",{preserveAspectRatio:"none",x:o,y:c,width:u,height:w,xlinkHref:s()})}),n?(0,i.jsx)(Yi,{path:t.path,width:t.width,height:t.height,focalBlurStrength:t.focalBlurStrength||1,focalBlurRadius:t.focalBlurRadius||10,blurFilterId:A,focalMaskId:r,blurEdgeClipId:a}):null]})})(o)}),(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.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,i.jsx)("path",{filter:o?`url(#${A})`:void 0,mask:o?`url(#${a})`:void 0,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}),o?(0,i.jsx)("path",{mask:`url(#${r})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},Yi=t=>{const{path:e,width:n,height:A,focalBlurStrength:a,focalBlurRadius:r,blurFilterId:s,focalMaskId:o,blurEdgeClipId:c}=t;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("filter",{id:s,children:(0,i.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,i.jsx)("mask",{id:o,children:(0,i.jsx)("circle",{cx:n/2,cy:A/2,r:r||0,fill:"white",filter:`url(#${s})`})}),(0,i.jsx)("mask",{id:c,children:(0,i.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};He({},"Textbox",(()=>Yn));var Ni={};He(Ni,"fontSizeStep",(()=>mn)),He(Ni,"textWidth",(()=>En)),He(Ni,"charWidth",(()=>fn)),He(Ni,"lineWidth",(()=>Cn)),He(Ni,"applyTextTransformations",(()=>yn)),He(Ni,"zip",(()=>In)),He(Ni,"getTextAlignment",(()=>Dn)),He(Ni,"getAnchor",(()=>xn)),He(Ni,"recomputeTextOnElement",(()=>vn)),He(Ni,"defaultLineHeightFactor",(()=>Mn));var ki={};He(ki,"refitTextbox",(()=>Bn)),He(ki,"recalculateTextboxRegion",(()=>pn));var Ri={};He(Ri,"FontMetrics",(()=>sn)),He(Ri,"loadFontFromExternalUrl",(()=>on)),He(Ri,"getFontMetrics",(()=>ln)),He(Ri,"loadFontFromDataUrl",(()=>cn));var Hi={};He(Hi,"registerJSDOM",(()=>Oi)),He(Hi,"createElement",(()=>ji)),He(Hi,"createElementNS",(()=>Vi)),He(Hi,"domParser",(()=>Ki)),He(Hi,"fetchAsArrayBuffer",(()=>Wi)),He(Hi,"fetchAsString",(()=>Xi)),He(Hi,"loadFontFaceSet",(()=>qi)),He(Hi,"xmlSerializer",(()=>Zi)),He(Hi,"toBase64",(()=>$i)),He(Hi,"dataUrlFromExternalUrl",(()=>_i)),He(Hi,"arrayBufferToDataUrl",(()=>tn)),He(Hi,"arrayBufferToBuffer",(()=>nn)),He(Hi,"dataUrlToArrayBuffer",(()=>en));var Ui=a.Buffer;let Gi;const Ti=new Map;function Oi(t){Gi=t}function Ji(){if(!Gi)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new Gi}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 Li=new(b(s).Agent)({rejectUnauthorized:!("local"===Ue.process?.env?.ENVIRONMENT)}),zi=t=>t.every((t=>"undefined"!==t)),ji=t=>zi([typeof document])?document.createElement(t):Ji().window.document.createElement(t),Vi=(t,e)=>{if(zi([typeof document]))return document.createElementNS(t,e);const i=Ji().window.document.createElement(e);return i.setAttribute("xmlns",t),i},Ki=()=>zi([typeof DOMParser])?new DOMParser:new(Ji().window.DOMParser),Wi=t=>{if(zi([typeof fetch]))return new Promise(((e,i)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{i(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,i)=>{b(r).get(e,{responseType:"arraybuffer",httpsAgent:Li}).then((e=>{t(e.data)})).catch((t=>{i(t)}))}))}},Xi=t=>{if(zi([typeof fetch]))return new Promise(((e,i)=>{fetch(t).then((t=>{e(t.text())})).catch(i)}));{const e=t.replace("localhost","localstack");return new Promise(((t,i)=>{b(r).get(e,{responseType:"text",httpsAgent:Li}).then((e=>{t(e.data)})).catch(i)}))}},qi=async(t,e)=>{if(zi([typeof FontFace])){const i=t.names.fullName.en,n=new FontFace(i,`url(${e})`);return document.fonts.add(n),n.load()}},Zi=()=>zi([typeof XMLSerializer])?new XMLSerializer:new(Ji().window.XMLSerializer),$i=t=>zi([typeof btoa])?btoa(t):Ui.from(t).toString("base64"),_i=async t=>{if(zi([typeof fetch,typeof Blob,typeof FileReader])){const e=await(async t=>{const e=Ti.get(t);if(e)return e;const i=(await fetch(t)).blob();return Ti.set(t,i),i})(t);return await an(e)}const e=(await b(r).get(t,{responseType:"arraybuffer"})).data;return tn(e)},tn=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,${nn(t).toString("base64")}`},en=t=>{const e=t.replace(/\r?\n/g,""),i=e.indexOf(",");if(-1===i||i<=4)throw new TypeError("malformed data: URI");const n=e.substring(5,i).split(";");let A=!1;for(let t=1;t<n.length;t++)"base64"===n[t]&&(A=!0);const a=A?"base64":"ascii",r=unescape(e.substring(i+1)),s=Ui.from(r,a);return An(s)},nn=t=>Ui.from(t),An=t=>{const e=new ArrayBuffer(t.byteLength),i=new Uint8Array(e);for(let e=0;e<t.length;++e)i[e]=t[e];return e},an=t=>new Promise(((e,i)=>{const n=new FileReader;n.onload=function(t){const n=t.target;n&&n.result?e(n.result.toString()):i()},n.readAsDataURL(t)})),rn=new Map;class sn{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 i=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,i),i}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let i=0,n=0;return e.forEach((t=>{const e=t.getMetrics();i=Math.max(i,e.yMax),n=Math.min(n,e.yMin)})),i-n}getKerningValue(t,e){let i=this.kerningValues.get(t.name);i||(i=new Map,this.kerningValues.set(t.name,i));let n=i.get(e.name);return n||(n=this.font.getKerningValue(t,e),i.set(e.name,n)),n}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,i=0;return t.forEach((t=>{const n=t.getMetrics();e=Math.max(e,n.yMax),i=Math.min(i,n.yMin)})),e-i}}const on=async t=>{try{return ln(t).getFont()}catch{const e="data:"===t.substring(0,5).toLowerCase().trim()?cn(t):cn(await _i(t));return gn(t,e),await qi(e,t),e}},cn=t=>{try{return ln(t).getFont()}catch{const e=en(t),i=b(A).parse(e);return gn(t,i),i}},ln=t=>{const e=rn.get(t);if(e)return e;throw new Error("Font metrics unavailable for font")},gn=(t,e)=>{const i=new sn(e);return rn.set(t,i),i},hn=(t,e,i,n)=>Math.max(fn(t.join("\n"),i,n),e),dn=(t,e,i,n,A,a)=>{const r=(a||Mn)*A.getApproximateHeight(),s=e.split("\n");try{const e=s.flatMap((e=>un(e,t.width,n,A))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(n*r),fontSize:i,requiredWidth:hn(a,t.width,n,A)}}catch(a){const s=e.split("");return{lines:s,requiredHeight:s.length*(n*r),fontSize:i,requiredWidth:hn(s,t.width,n,A)}}},un=(t,e,i,n)=>{const A=En(t,i,n);if(A<=e)return{lines:[t],width:A};if(!(t.indexOf(" ")>-1)){if(t.length<=1)throw new Error(`Character ${t} is wider than region`);const A=Math.floor(t.length/2),a=un(t.slice(0,A),e,i,n),r=un(t.slice(A),e,i,n);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(En(t,i,n)>e){const A=un(t,e,i,n);r.push(...A.lines),s=Math.max(s,A.width),o++}else{const A=[t];s=Math.max(s,En(t,i,n));let c=o+1,l=!0;for(;c<a.length&&l;){const t=a[c],r=En(`${A.join(" ")} ${t}`,i,n);r<=e?(A.push(t),s=Math.max(s,r),c++):l=!1}r.push(A.join(" ")),o=c}}if(s<0)throw new Error(`No max width calculated for text: ${r}.`);return{lines:r,width:s}},wn=(t,e,i,n,A,a)=>{const r=(a??Mn)*e.getApproximateHeight(),s=1/i.unitsPerEm,o=n/Cn(t,s,e),c=A/(t.length*r*s);return Math.min(c,o)},Bn=(t,e,i,n)=>{const A=ln(e.fontData.assetUrl),a=A.getFont(),r=e.fontSize/a.unitsPerEm;if(!i)return dn(e,t,e.fontSize,r,A,n);let s;if(s=e.text?e.text.split("\n"):e.input?.split("\n")??[""],i.input===t&&e.width===i.width&&e.height===i.height&&e.lineHeight===i.lineHeight)return{lines:s,requiredHeight:e.height,requiredWidth:hn(s,e.width,r,A),fontSize:e.fontSize};const o=e.width!==i.width!=(e.height!==i.height);return e.lineHeight!==i.lineHeight||o||i.input!==t?dn(e,t,e.fontSize,r,A,n):{lines:s,requiredHeight:e.height,requiredWidth:hn(s,e.width,r,A),fontSize:wn(s,A,a,e.width,e.height,n)}},pn=(t,e,i,n,A)=>{const a=ln(e.assetUrl).getFont();let r={...t},s={...t},o=Cn(n,i/a.unitsPerEm,ln(e.assetUrl));return o&&o<r.width&&(s.width=o,"left"===A?(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"===A?r.width-o:(r.width-o)/2,n&&In(n,n).every((([t,e])=>t===e))&&(r=s)),r},mn=1,En=(t,e,i)=>{let n=0;const A=i.getGlyphs(t);return A.forEach(((t,e)=>{if(t.advanceWidth&&(n+=t.advanceWidth),e<A.length-1){const a=i.getKerningValue(t,A[e+1]);n+=a}})),n*=e,n},fn=(t,e,i)=>{let n=0;const A=i.getGlyphs(t);return A.forEach(((t,e)=>{if(t.advanceWidth&&(n=Math.max(n,t.advanceWidth)),e<A.length-1){const a=i.getKerningValue(t,A[e+1]);n=Math.max(n,a)}})),n*=e,n},Cn=(t,e,i)=>{let n=0;return t.forEach((t=>{n=Math.max(n,En(t,e,i))})),n},Qn={stripControlCharacters:!0,vertical:!1,uppercase:!1},yn=(t,e=Qn)=>{const i={...Qn,...e};let n=t||"";return i.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),i.uppercase&&(n=n.toUpperCase()),i.vertical&&(n=n.split("").join("\n")),n},In=(t,e)=>t.map(((t,i)=>[t,e[i]])),Dn=(t="center",e=!1)=>e?"center":t,xn=t=>"left"===t?"start":"right"===t?"end":"middle",vn=(t,e,i)=>t.fontData?{...t,...(()=>{if(t.algorithm===We.Traditional){const n=Bn(e,t,i,t.lineHeight);return{text:n.lines.join("\n"),height:n.requiredHeight,width:n.requiredWidth,fontSize:n.fontSize,input:e}}return{text:e}})()}:t,Mn=1.1;var Sn={};He(Sn,"colorDefinitionPrintValue",(()=>bn)),He(Sn,"spotColorDefinitionString",(()=>Fn)),He(Sn,"svgColorValueToDefinition",(()=>Pn));const bn=t=>{const e=Fn(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},Fn=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),i=e.lastIndexOf("/");return`icc-named-color(${e.slice(i+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},Pn=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const i=e[1].match(/\(([^)]+)\)/gm);if(!i)throw new Error("Unhandled state of color value in SVG");const n=i[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:n[0],namedColor:n[1]}}},Yn=t=>{const e=(t.rotation||0)*Math.PI/180,n=Math.cos(e),A=-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,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("defs",{children:[t.textFillImage&&(0,i.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,i.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,i.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,i.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,i.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsx)("g",{transform:`matrix(${n}, ${-A}, ${A}, ${n}, ${s}, ${o})`,children:(0,i.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} ${Fn(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,i.jsx)(kn,{text:t.text||"",curvedPathId:a,align:t.align}):c.map(((e,n)=>(0,i.jsx)(Nn,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:n,amountLines:c.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},n)))})})})]}):null},Nn=t=>(0,i.jsx)("tspan",{textAnchor:xn(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:Mn),i=t.textboxHeight/2;if("top"===t.verticalAlign)return-i+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const n=t.amountLines-1-t.thisLineIdx;return i-t.fontSize/4-n*e}const n=(t.amountLines-1)/2;return(t.thisLineIdx-n)*e+t.fontSize/4})()}px`,children:t.text}),kn=t=>{const e=`#${t.curvedPathId}`;return(0,i.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:xn(t.align),href:e,xlinkHref:e,children:t.text})};He({},"Illustration",(()=>Jn));var Rn={};He(Rn,"traverse",(()=>Un)),He(Rn,"sanitizeSvgTree",(()=>Gn)),He(Rn,"modifySVGWithElementProperties",(()=>Tn)),He(Rn,"generateSVGWithUnknownColors",(()=>On));const Hn=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Un=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>Un(t,e)))},Gn=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const i=[];Un(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,l.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{i.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),Un(t,(t=>{i.forEach((e=>{e.selectors?.forEach((i=>{((t,e)=>{try{return t.matches(e)}catch(i){return t.classList.contains(e.substring(1))}})(t,i)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},Tn=(t,e,i,n,A)=>{const a=(t=>Ki().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,i)=>{t.setAttribute("height",`${i}px`),t.setAttribute("width",`${e}px`)})(a,e,i),((t,e,i)=>{Un(t,(t=>{const n=t.attributes.getNamedItem("fill");n&&"none"!==n.value&&t.classList.forEach((n=>{if(n.startsWith("spiff-fill")){const A=e[n];A&&t.setAttribute("fill",i?bn(A):A.browserValue)}}));const A=t.attributes.getNamedItem("stroke");A&&"none"!==A.value&&t.classList.forEach((n=>{if(n.startsWith("spiff-stroke")){const A=e[n];A&&t.setAttribute("stroke",i?bn(A):A.browserValue)}}))}))})(a,n,A),(t=>Zi().serializeToString(t))(a)},On=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],i=e?.length>0?e[0]:"",n=Ki().parseFromString(i,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");Gn(n);const A={};Un(n,(t=>{Hn.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const i=Pn(e.value),n=`spiff-fill-${i.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",i.browserValue),t.classList.add(n),A[n]=i}const i=t.attributes.getNamedItem("stroke");if(i&&"none"!==i.value){const e=Pn(i.value),n=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(n),t.setAttribute("stroke",e.browserValue),A[n]=e}}));const a=Zi().serializeToString(n);return{colors:A,svg:a}},Jn=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,i.jsx)(bi,{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,n=wi(e),A=Math.cos(n),a=-Math.sin(n),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(${A}, ${-a}, ${a}, ${A}, 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,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsx)("g",{transform:r,dangerouslySetInnerHTML:{__html:Tn(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class Ln{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 i=this.prevCommands.filter((e=>e.sequenceId===t)).pop();i&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),i?.overrideOldState(e),this.prevCommands.push(i))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],i=this.state.variation?.layouts?.[t],n=e?.layout||i?.layout;if(!n)throw new Error(`No layout: ${t}`);const A=[...e?.elements||[],...i?.elements||[]];return this.getLayoutDataWithState(n,A)}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:i=>jn(t,e,i)}}initialize(t,e){if(e)return void(this.state={transaction:e});let i={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{i=new AA(t).apply(i)})),this.runStateCallbacks(),this.state={transaction:i}}commandReducer(t,e){if(e.varying){const i={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(i)}}{const i=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(i)}}}}const zn=t=>"image"===t.type?(0,i.jsx)(bi,{...t},t.id):"frame"===t.type?(0,i.jsx)(Pi,{...t},t.id):"illustration"===t.type?(0,i.jsx)(Jn,{...t},t.id):"textbox"===t.type?(0,i.jsx)(Yn,{...t},t.id):null,jn=(t,e,n)=>{const A=n.renderingConfiguration,a=A?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,i.jsx)(gi,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:n.width||t.width,height:n.height||t.height,viewBox:A?.region?{x:A.region.left,y:A.region.top,width:A.region.width,height:A.region.height}:{x:0,y:0,width:t.width,height:t.height},configuration:A,outlineArea:n.outlineArea,maxHeight:n.maxHeight,maxWidth:n.maxWidth,position:n.position,borderRadius:n.borderRadius,outlineColor:n.outlineColor})};function Vn(t){return t.sort(((t,e)=>{const i=t.layer||0,n=e.layer||0;if(i<n)return-1;if(i>n)return 1;const A=t.layerIndex||0,a=e.layerIndex||0;return A<a?-1:A>a?1:0}))}class Kn extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,Kn.prototype)}}const Wn=(t,e)=>Xn(t,e).elements.find((e=>e.id===t)),Xn=(t,e)=>{const i=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!i)throw new Kn;return i},qn=(t,e)=>{const i=Vn([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:i,modificationID:Te()}},Zn=async(t,e)=>{const i=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],n=[...new Set(i)];for(let i=0;i<n.length;i++){const A=n[i],a=t.layouts[A],r=e?.layouts[A],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 Xi(e.src),i=await On(t);e.svg=Tn(i.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 $n{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class _n extends $n{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class tA extends $n{constructor(t,e,i){super(),this.id=t,this.x=e,this.y=i}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,x:this.x,y:this.y},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class eA extends $n{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,rotation:this.angle},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class iA extends $n{constructor(t,e,i){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(i)}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;let i={...e,width:this.width,height:this.height};if("frame"===e.type){const t=i;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=i,n=(t.algorithm&&t.algorithm!==We.Autosize?t.input:t.text)??"";i=vn(t,n,e)}const n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class nA extends $n{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class AA extends $n{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 aA extends $n{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()}})),i={};return e.forEach((t=>{i[t.layout.id]=t})),{...t,layouts:i}}}class rA extends $n{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 i=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,i)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:i,modificationID:Te()}}}}const i=e[e.length-1],n=i.productOverlay?i:null;let A;if(n&&e.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)A=[...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,A=[...e,this.element]}return n&&A.push(n),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:A,modificationID:Te()}}}}assignIndex(t,e){if(0===e.length)return 0;const i=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!==i?i+1:0}}class sA extends $n{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const i=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 n={};return i.forEach((t=>{n[t.layout.id]=t})),{...t,layouts:n}}}class oA extends $n{constructor(t,i){super(),this.el=b(e)(t),this.layout=i,this.el.id=Te(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new rA(this.el,this.layout).apply(t)}}class cA extends $n{constructor(t,e,i){super(),this.id=t,this.color=e,this.textFillSpotColor=i}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class lA extends $n{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,textFillImage:this.imageFill},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class gA extends $n{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,fontSize:this.size},n=Xn(e.id,Object.values(t.layouts)),A=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=qn(vn(i,A),n);return{...t,layouts:{...t.layouts,[n.layout.id]:a}}}}class hA extends $n{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,algorithm:this.algorithm},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class dA extends $n{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,fontData:this.fontData},n=Xn(e.id,Object.values(t.layouts)),A=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=qn(vn(i,A),n);return{...t,layouts:{...t.layouts,[n.layout.id]:a}}}}class uA extends $n{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,align:this.align},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class wA extends $n{constructor(t,e,i){super(),this.id=t,this.imageData=e,this.offsets=i}apply(t){this.oldState=t;const e=Xn(this.id,Object.values(t.layouts)),i=e.elements.findIndex((t=>t.id===this.id)),n=e.elements[i].pattern,A=[...e.elements];A.splice(i,1,{...e.elements[i],pattern:{...n,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:A,modificationID:Te()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class BA extends $n{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i=Xn(e.id,Object.values(t.layouts)),n=qn(vn(e,this.text,e),i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class pA extends $n{constructor(t,e,i){super(),this.id=t,this.className=e,this.fill=i}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i=e.colors||{},n=i[this.className];i[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const A={...e,colors:i},a=Xn(e.id,Object.values(t.layouts)),r=qn(A,a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class mA extends $n{constructor(t,e,i){super(),this.id=t,this.svgBody=e,this.objectURL=i}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class EA extends $n{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Wn(this.id,Object.values(t.layouts)).id)throw new Kn;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 i=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(i,1)[0]);const n=[...e.elements];return n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class fA extends $n{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!i)throw new Error("Layout missing from state!");const n=i.elements.findIndex((t=>t.id===this.id));i.elements.splice(n,1),i.elements.unshift(e);const A=[...i.elements],a=A.splice(n,1)[0];return A.splice(n,0,a),A.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[i.layout.id]:{...t.layouts[i.layout.id],elements:A,modificationID:Te()}}}}}class CA extends $n{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Wn(this.id,Object.values(t.layouts)).id)throw new Kn;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 i=e.elements.findIndex((t=>t.id===this.id)),n=i+1,A=[...e.elements],a=A.splice(i,1)[0];return A.splice(n,0,a),A.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:A,modificationID:Te()}}}}}class QA extends $n{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Wn(this.id,Object.values(t.layouts)).id)throw new Kn;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 i=e.elements.findIndex((t=>t.id===this.id)),n=i-1,A=[...e.elements],a=A.splice(i,1)[0];return A.splice(n,0,a),A.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:A,modificationID:Te()}}}}}class yA extends $n{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!i)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[i.layout.id]:qn({...e,layer:this.value},i)}}}}var IA={};He(IA,"patternImageDataCache",(()=>FA)),He(IA,"frameDataCache",(()=>PA)),He(IA,"generateFrameSVG",(()=>YA)),He(IA,"generateDefaultRectangleFrameSvg",(()=>NA)),He(IA,"getVariant",(()=>kA)),He(IA,"getFrameData",(()=>RA)),He(IA,"calculateOffsets",(()=>HA)),He(IA,"getPatternImageData",(()=>UA)),He(IA,"GetSVGDimensions",(()=>GA)),He(IA,"svgStringDimensions",(()=>TA));var DA={};He(DA,"getExifOrientation",(()=>vA)),He(DA,"canvasDims",(()=>MA)),He(DA,"getAttributesFromArrayBuffer",(()=>SA));let xA=null;const vA=t=>new Promise((e=>{const i=nn(t);(0,o.fromBuffer)(t).then((t=>{const n=t?.mime;if("image/jpeg"!==n)return e(1);(new(0,h.ExifImage)).loadImage(i,((t,i)=>e(t?1:i.image.Orientation||1)))}))})),MA=t=>{const e=8192,i=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[i*e,e]:[e,e/i]},SA=async t=>{const e=await(async t=>{const e=await tn(t),i=await(0,g.loadImage)(e),[n,A]=MA(i),a=await(async()=>{if(null!==xA)return!xA;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return xA=2===t.width&&3===t.height,!xA})();if(!a){const t=(0,g.createCanvas)(n,A);return t.getContext("2d").drawImage(i,0,0,n,A),t}const r=await vA(t),[s,o]=r>4?[A,n]:[n,A],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(i,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",(()=>bA));const bA=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))}},FA=new Map,PA=new Map,YA=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return NA(t)}return Xi(e)},NA=t=>{const e=t.width,i=e/t.height,n=Math.max(e,512),A=n/i;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${n} ${A}'>\n <path id="target-path" d='M0 0 h ${n} v ${A} h ${-n} Z' />\n </svg>\n `},kA=(t,e)=>{if(!e)return;const i=e.variants?.find((e=>e.id===t.frameVariantId))||bA(e);if(!i)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!i.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return i},RA=async t=>{const e=Ki().parseFromString(t,"image/svg+xml"),i=e.querySelector("svg");if(!i)throw new Error("Malformed frame SVG: <svg> tag not found");const n=i.getAttribute("viewBox");if(!n)throw new Error("SVG missing viewBox.");const A=n.split(" "),a=parseFloat(A[3])||1,r=parseFloat(A[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 PA.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 PA.set(t,e),e}throw new Error("Malformed frame SVG")},HA=(t,e,i)=>{const n=e.width>=e.height,A=t.width>=t.height,a=e.width/2,r=e.height/2,s=(n?e.height:e.width)/(A?t.width:t.height),o=i?.scale||s,c=a-t.width/2*o,l=i?.left||c,g=r-t.height/2*o;return{x:l,y:i?.top||g,zoom:o}},UA=async t=>{if(FA.has(t))return FA.get(t);if(t.endsWith("svg")){const e=await GA(t),i=e.width,n=e.height,A={src:t,width:i,height:n,aspect:i/n};return FA.set(t,A),A}{const e=await Wi(t),i=await SA(e),n={src:t,width:i.width,height:i.height,aspect:i.width/i.height};return FA.set(t,n),n}},GA=async t=>{const e=await Xi(t);return TA(e)},TA=t=>{const e=Ki().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const i=e.getAttribute("viewBox"),n=e.getAttribute("width"),A=e.getAttribute("height"),a=i?i?.split(" ").map((t=>Number(t))):[0,0,Number(n),Number(A)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var OA={};He(OA,"determineCorrectFontSizeAndLines",(()=>LA)),He(OA,"determineCorrectTextboxRegion",(()=>zA));const JA=(t,e,i,n,A)=>{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=>En(t,n,A)));const o=A.getApproximateHeight()*n;let c=!0;for(;c;){if(o+(r-1)*i>t.height)return[null,null];const e=Math.max(...s);if(e<=t.width)return[a,e];const l=s.reduce(((t,e,i,n)=>e>n[t]?i: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)],i=e.map((t=>En(t,n,A)));i[0]<=t.width&&(a=[...a.slice(0,l),...e,...a.slice(l+1)],s=[...s.slice(0,l),...i,...s.slice(l+1)],r+=1,h=!0)}h||(c=!1)}return[null,null]},LA=(t,e,i,n,A)=>{let a,r;const s=ln(e.assetUrl),o=s.getFont();if(A.size){const e=t/o.unitsPerEm;return[a,r]=JA(i,n,t,e,s),[A.size,a,r]}let c=6-mn;if(n.length>0){let t=n,e=0;for(;(!A.maxSize||c<=A.maxSize)&&t;)c+=mn,e=c/o.unitsPerEm,[t,r]=JA(i,n,c,e,s)}c>6&&(c-=mn),A.minSize&&c<A.minSize&&(c=A.minSize);const l=c/o.unitsPerEm;return[a,r]=JA(i,n,c,l,s),[c,a,r]},zA=(t,e,i,n,A)=>{let a={...t},r={...t},[s,o,c]=LA(i,e,r,n,{size:0,minSize:i,maxSize:i});var l,g;return c&&c<a.width&&(r.width=c,"left"===A?(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"===A?a.width-c:(a.width-c)/2,[s,o]=LA(i,e,r,n,{size:i}),s===i&&o&&(l=n,g=o,l.map(((t,e)=>[t,g[e]]))).every((([t,e])=>t===e))&&(a=r)),a};var jA={};He(jA,"svgObjectURL",(()=>WA)),He(jA,"LayoutElementFactory",(()=>qA));const VA=(t,e)=>{const i=t.layoutState.elements.filter((t=>t.layer===e)),n=Math.max(...i.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(n,0)+1},KA=async t=>new Promise((e=>{Xi(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),WA=async t=>{const e=Ki().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const i=(new XMLSerializer).serializeToString(e),n=document.createElement("canvas"),A=n.getContext("2d"),a=await Re.from(A,i,{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,i)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((i=>{if(!i){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(i))}))}catch(t){i(t)}})))(n)},XA=async(t,e,i,n)=>{const A=t.layoutState.layout.useEditableArea&&t.layoutState.layout.editableArea||{width:t.layoutState.layout.width,height:t.layoutState.layout.height,x:0,y:0},a=A.width<A.height?A.width:A.height,r=t.layoutState.layout.useEditableArea?a/1.3:a/2,s={top:A.y+A.height/2-r/2,left:A.x+A.width/2-r/2,width:r,height:r,rotation:0,panelId:t.layoutState.layout.panelId};if(i&&e===ze.Illustration){const t=await On(await KA(i)),e=Ki().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const n=s.height,A=e.split(" "),a=(parseFloat(A[2])||1)/(parseFloat(A[3])||1);s.height=s.width/a,s.top+=(n-s.height)/2}if(i&&e===ze.Image){const t=s.height,e=await Wi(i),n=await SA(e),A=n.width/n.height;s.height=s.width/A,s.top+=(t-s.height)/2}if(i&&e===ze.Textbox&&n?.text&&n?.fontScale){await on(i);const t=ln(i),e=En(n.text,n?.fontScale,t);s.width=Math.min(e,.85*A.width),s.left=A.x+A.width/2-s.width/2}return s};class qA{static async getFrame(t,e){const i=await YA(e.region,e.src),n=await RA(i),A=e.region||await XA(t,ze.Frame);return{id:Te(),x:A.left,y:A.top,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||VA(t,A.layer||0),rotation:A.rotation,scaleX:A.width/n.width,scaleY:A.height/n.height,path:n.path,dataWidth:n.width,dataHeight:n.height,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:A.immutable}}static async getImage(t,e){const i=e.region||await XA(t,ze.Image,e.src);return{id:Te(),src:e.src,type:ze.Image,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||VA(t,i.layer||0),immutable:i.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:i,fontSrc:n,designInputStep:A}=e,a=await on(n),r={assetUrl:n,name:a.names.fullName.en},s=A?.text||i.defaultText||"",o=i.replaceableText?i.replaceableText.replace("{{}}",s):s,c=yn(o,{vertical:i.vertical,uppercase:i.uppercase}),l=e.region||await XA(t,ze.Textbox,n,{text:c,fontScale:i.size?i.size/a.unitsPerEm:void 0}),g=vn({id:Te(),type:ze.Textbox,x:l.left,y:l.top,width:l.width,height:l.height,align:Dn(i.textAlign,i.vertical),curved:i.curved,fill:A?.color||i.colour||"#000000",fontData:r,layer:l.layer||0,layerIndex:l.layerIndex||VA(t,l.layer||0),paths:i.paths,rotation:l.rotation,vertical:i.vertical,verticalAlign:i.verticalAlign||"middle",algorithm:We.Traditional,fontSize:i.size||Math.max(Math.round(.025*l.height),1),text:c,input:s},c),h=pn({...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 i=`\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 `,n={};n["spiff-fill-shape"]={browserValue:e.color};const A=e.region||await XA(t,ze.Illustration),a=Te();return{stepRegion:e.region,colors:n,id:a,svg:i,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||VA(t,A.layer||0),immutable:A.immutable}}static async getIllustration(t,e){const i=e.region||await XA(t,ze.Illustration,e.src),n=await On(await KA(e.src)),A=await WA(n.svg),a=Te();return{cachedObjectURL:A,stepRegion:e.region,colors:n.colors,id:a,src:e.src,svg:n.svg,type:ze.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||VA(t,i.layer||0),immutable:i.immutable}}}function ZA(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class $A extends Error{constructor(t){super(t),this.name=this.constructor.name}}class _A extends $A{constructor(t){super(`ConfigurationError - ${t}`)}}class ta extends _A{constructor(t){super(`Option not Configured: ${t.stepTitle}`),ZA(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class ea extends _A{constructor(t){super(`Panel not Found: ${t.panelId}`),ZA(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class ia extends _A{constructor(t){super(`Asset not found for variant: ${t.name}`),ZA(this,"variant",void 0),this.variant=t}}class na extends _A{constructor(t){super(`Resource not found for asset: ${t.name}`),ZA(this,"asset",void 0),this.asset=t}}class Aa extends _A{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),ZA(this,"step",void 0),this.step=t}}class aa extends $A{constructor(t){super(`ImplementationError - ${t}`)}}class ra extends aa{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class sa extends aa{constructor(t){super(`Parsing Error: ${t}`)}}class oa extends aa{constructor(t){super(`Client Error: ${t}`)}}class ca extends aa{constructor(t){super(`Resource Generation Failed: ${t}`)}}function la(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ga{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 i=JSON.stringify([...e.entries()]);this.set(t,i)}}class ha{constructor(){la(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 i=JSON.stringify([...e.entries()]);this.set(t,i)}}const da=(()=>{try{return localStorage?new ga:new ha}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new ha}})();function ua(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const wa=new class{constructor(){ua(this,"defaultServerUrl","https://api.spiff.com.au"),ua(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ua(this,"defaultHubUrl","https://hub.spiff.com.au"),ua(this,"serverUrl",void 0),ua(this,"servicesApiUrl",void 0),ua(this,"hubUrl",void 0),ua(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 Ba(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let pa;const ma=t=>{pa=t};let Ea;const fa=t=>{Ea=t};let Ca;const Qa=t=>{Ca=t};let ya;const Ia=new class{constructor(){Ba(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),wa.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${wa.getServerUrl()}/graphql`,fetch:f.fetch}),i=(0,m.setContext)((async(t,e)=>{const{headers:i}=e,n=i||{},A=await(async()=>{const t={applicationKey:ya,bundleOwnerId:Ea,customerToken:Ca,transactionOwnerId:pa};return"undefined"!=typeof window&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await new Promise((t=>{const e=wa.getHubUrl(),i=n=>{n.origin===e&&(window.removeEventListener("message",i),t(n.data))};window.parent!==window&&(window.addEventListener("message",i,!1),window.parent.postMessage("ready",e))})),...t}:t})(),a=e.bearer??A.bearer,r=e.partnerId??A.partnerId,s=e.activeIntegration??A.activeIntegration,o=e.transactionOwnerId??A.transactionOwnerId,c=e.customerToken??A.customerToken,l=e.applicationKey??A.applicationKey,g=e.bundleOwnerId??A.bundleOwnerId;return a&&(n.Authorization=`Bearer ${a}`),r&&(n.partnerId=r),s&&(n.activeIntegration=s),o&&(n.transactionOwnerId=o),c&&(n.customerToken=c),l&&(n["X-Application-Key"]=l),g&&(n.bundleOwnerId=g),{headers:n}})),n=(0,E.onError)((({operation:t,graphQLErrors:e,networkError:i})=>{(e||[]).forEach((({message:e,locations:i,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(i,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(t.variables))})),i&&console.log("GraphQL Network error")}));const A=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)([n,i,e]),cache:A,name:"Core"})}};function Da(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const xa=t.gql`
1
+ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/jsx-runtime"),n=require("react"),A=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"),m=require("@apollo/client/link/context"),E=require("@apollo/client/link/error"),f=require("cross-fetch"),C=require("lodash.isequal"),Q=require("react-dom/server"),y=require("qrcode"),I=require("svg-path-bbox"),D=require("lodash.debounce"),x=require("unicode-default-word-boundary"),v=require("@apollo/client/core");function M(t,e,i,n){Object.defineProperty(t,e,{get:i,set:n,enumerable:!0,configurable:!0})}var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function b(t){return t&&t.__esModule?t.default:t}M(module.exports,"SpiffCommerceClient",(()=>cl)),M(module.exports,"CommandContext",(()=>Ln)),M(module.exports,"spiffCoreConfiguration",(()=>wa)),M(module.exports,"PromiseQueue",(()=>Xr)),M(module.exports,"QueueablePromise",(()=>Wr)),M(module.exports,"MockWorkflowManager",(()=>gl)),M(module.exports,"InformationMessageType",(()=>Do)),M(module.exports,"StepHandle",(()=>Po)),M(module.exports,"TextStepHandle",(()=>Lo)),M(module.exports,"FrameStepHandle",(()=>wl)),M(module.exports,"BulkStepHandle",(()=>Ro)),M(module.exports,"ShapeStepHandle",(()=>Jo)),M(module.exports,"IllustrationStepHandle",(()=>Ho)),M(module.exports,"MaterialStepHandle",(()=>Uo)),M(module.exports,"ModelStepHandle",(()=>Go)),M(module.exports,"PictureStepHandle",(()=>To)),M(module.exports,"QuestionStepHandle",(()=>Oo)),M(module.exports,"GlobalPropertyHandle",(()=>yc)),M(module.exports,"BulkPriceCalculationStrategy",(()=>ar)),M(module.exports,"Variant",(()=>bo)),M(module.exports,"WorkflowExperienceImpl",(()=>rc)),M(module.exports,"OptionNotFoundError",(()=>ta)),M(module.exports,"LayoutNotFoundError",(()=>ea)),M(module.exports,"AssetNotFoundError",(()=>ia)),M(module.exports,"ResourceNotFoundError",(()=>na)),M(module.exports,"MisconfigurationError",(()=>Aa)),M(module.exports,"ParseError",(()=>sa)),M(module.exports,"UnhandledBehaviorError",(()=>ra)),M(module.exports,"assetService",(()=>ka)),M(module.exports,"designService",(()=>Ac)),M(module.exports,"createDesign",(()=>tc)),M(module.exports,"optionService",(()=>Ja)),M(module.exports,"persistenceService",(()=>da)),M(module.exports,"graphQlManager",(()=>Ia)),M(module.exports,"toast",(()=>wr)),M(module.exports,"FrameService",(()=>eo)),M(module.exports,"getBoundedOffsets",(()=>_s)),M(module.exports,"frameStepService",(()=>co)),M(module.exports,"modelStepService",(()=>ho)),M(module.exports,"materialStepService",(()=>go)),M(module.exports,"shapeStepService",(()=>mo)),M(module.exports,"questionStepService",(()=>Bo)),M(module.exports,"digitalContentStepService",(()=>so)),M(module.exports,"moduleStepService",(()=>uo)),M(module.exports,"pictureStepService",(()=>wo)),M(module.exports,"textStepService",(()=>yo)),M(module.exports,"illustrationStepService",(()=>lo)),M(module.exports,"ProductCameraRig",(()=>nr)),M(module.exports,"FrameStep",(()=>dl)),M(module.exports,"ConversionLocation",(()=>sr)),M(module.exports,"ConversionDataType",(()=>cr)),M(module.exports,"getWorkflow",(()=>sl)),M(module.exports,"getWorkflows",(()=>rl)),M(module.exports,"shortenUrl",(()=>Ao)),M(module.exports,"ObjectInput",(()=>Vc)),M(module.exports,"TextInput",(()=>Kc)),M(module.exports,"ObjectInputType",(()=>zc)),M(module.exports,"ProductCollection",(()=>Rc)),M(module.exports,"CollectionProduct",(()=>Hc)),M(module.exports,"AssetType",(()=>ai)),M(module.exports,"BringForwardCommand",(()=>CA)),M(module.exports,"BringToFrontCommand",(()=>EA)),M(module.exports,"BringToBackCommand",(()=>fA)),M(module.exports,"CanvasCommand",(()=>$n)),M(module.exports,"CreateElementCommand",(()=>rA)),M(module.exports,"CreateLayoutCommand",(()=>AA)),M(module.exports,"DeleteElementCommand",(()=>sA)),M(module.exports,"FontAlignmentCommand",(()=>uA)),M(module.exports,"FontColorCommand",(()=>cA)),M(module.exports,"FontSizeCommand",(()=>gA)),M(module.exports,"FontSourceCommand",(()=>dA)),M(module.exports,"GroupCommand",(()=>nA)),M(module.exports,"LayoutElementFactory",(()=>qA)),M(module.exports,"LayoutElementType",(()=>ze)),M(module.exports,"MoveCommand",(()=>tA)),M(module.exports,"ResizeCommand",(()=>iA)),M(module.exports,"RotateCommand",(()=>eA)),M(module.exports,"SendBackwardsCommand",(()=>QA)),M(module.exports,"StakeholderType",(()=>gr)),M(module.exports,"StepAspectType",(()=>ci)),M(module.exports,"StepType",(()=>si)),M(module.exports,"TextChangeCommand",(()=>BA)),M(module.exports,"UnitOfMeasurement",(()=>qe)),M(module.exports,"dataUrlFromExternalUrl",(()=>_i)),M(module.exports,"findElement",(()=>Wn)),M(module.exports,"frameDataCache",(()=>PA)),M(module.exports,"generate",(()=>Te)),M(module.exports,"getAxisAlignedBoundingBox",(()=>di)),M(module.exports,"generateSVGWithUnknownColors",(()=>On)),M(module.exports,"getAttributesFromArrayBuffer",(()=>SA)),M(module.exports,"rehydrateSerializedLayout",(()=>Zn)),M(module.exports,"getFrameData",(()=>RA)),M(module.exports,"getSvgElement",(()=>jn)),M(module.exports,"loadFontFromDataUrl",(()=>cn)),M(module.exports,"loadFontFromExternalUrl",(()=>on)),M(module.exports,"determineCorrectFontSizeAndLines",(()=>LA)),M(module.exports,"patternImageDataCache",(()=>FA)),M(module.exports,"generateCommands",(()=>xs)),M(module.exports,"registerJSDOM",(()=>Oi)),M(module.exports,"minZoom",(()=>Jr)),M(module.exports,"AdvancedEditor",(()=>Rs)),M(module.exports,"TransformWrapper",(()=>Bl)),M(module.exports,"EditorCore",(()=>ks)),M(module.exports,"useLayouts",(()=>ja)),M(module.exports,"useEditorState",(()=>tr)),M(module.exports,"useEditorInteraction",(()=>zr)),M(module.exports,"useShortcutCombination",(()=>jr)),M(module.exports,"commandReducer",(()=>qa)),M(module.exports,"getDefaultState",(()=>Xa)),M(module.exports,"CommandContextContext",(()=>La)),M(module.exports,"AdvancedEditorStateProvider",(()=>$a)),M(module.exports,"AdvancedEditorContext",(()=>Za)),M(module.exports,"UICommand",(()=>_a)),M(module.exports,"EditorSubMenu",(()=>Ka)),M(module.exports,"ElementEventType",(()=>Br)),M(module.exports,"KeyEvent",(()=>mr)),M(module.exports,"gatherVaryingStepAspects",(()=>js));function F(t){return t.replace(/(?!\u3000)\s+/gm," ")}function P(t){const e=t.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return e?e.map(parseFloat):[]}const Y=/^[A-Z-]+$/;function N(t){const e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t);return e&&(e[2]||e[3]||e[4])||""}const k=/(\[[^\]]+\])/g,R=/(#[^\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 i=e.exec(t);return i?[t.replace(e," "),i.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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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:i}=this;return F(this.getString()).trim().split(t).map((t=>new et(e,i,t)))}hasValue(t){const e=this.value;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){const{value:e}=this,i="string"==typeof e;return i&&t?t.test(e):i}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 i=parseFloat(e);return this.isString(/%$/)&&(i/=100),i}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,i)=>e--&&i?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[i,n]="boolean"==typeof t?[void 0,t]:[t],{viewPort:A}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(A.computeSize("x"),A.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(A.computeSize("x"),A.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*A.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*A.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(/%$/)&&n:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*A.computeSize(i);default:{const t=this.getNumber();return e&&t<1?t*A.computeSize(i):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),i=(null==e?void 0:e[1])||t;return this.document.definitions[i]}getFillStyleDefinition(t,e){let i=this.getDefinition();if(!i)return null;if("function"==typeof i.createGradient&&"getBoundingBox"in t)return i.createGradient(this.document.ctx,t,e);if("function"==typeof i.createPattern){if(i.getHrefAttribute().hasValue()){const t=i.getAttribute("patternTransform");i=i.getHrefAttribute().getDefinition(),i&&t.hasValue()&&i.getAttribute("patternTransform",!0).setValue(t.value)}if(i)return i.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 i=e.length;let n=0;for(let t=0;t<i&&(","===e[t]&&n++,3!==n);t++);if(t.hasValue()&&this.isString()&&3!==n){const i=new(b(w))(e);i.ok&&(i.alpha=t.getNumber(),e=i.toRGBA())}return new et(this.document,this.name,e)}constructor(t,e,i){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=i,this.isNormalizedColor=!1}}function it(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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 nt{clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[t]=this.viewPorts;return t||At()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||At()}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(){it(this,"viewPorts",[])}}function At(){return{width:nt.DEFAULT_VIEWPORT_WIDTH,height:nt.DEFAULT_VIEWPORT_HEIGHT}}function at(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}it(nt,"DEFAULT_VIEWPORT_WIDTH",800),it(nt,"DEFAULT_VIEWPORT_HEIGHT",600);class rt{static parse(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const[i=e,n=e]=P(t);return new rt(i,n)}static parseScale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const[i=e,n=i]=P(t);return new rt(i,n)}static parsePath(t){const e=P(t),i=e.length,n=[];for(let t=0;t<i;t+=2)n.push(new rt(e[t],e[t+1]));return n}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:i}=this,n=e*t[0]+i*t[2]+t[4],A=e*t[1]+i*t[3]+t[5];this.x=n,this.y=A}constructor(t,e){at(this,"x",void 0),at(this,"y",void 0),this.x=t,this.y=e}}function st(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ot{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:i}=this,n=t.ctx.canvas;n.onclick=e,n.onmousemove=i,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:i}=this,{style:n}=t.ctx.canvas;let A;n&&(n.cursor=""),e.forEach(((t,e)=>{let{run:n}=t;for(A=i[e];A;)n(A),A=A.parent})),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:i,eventElements:n}=this;i.forEach(((i,A)=>{let{x:a,y:r}=i;!n[A]&&e.isPointInPath&&e.isPointInPath(a,r)&&(n[A]=t)}))}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:i,eventElements:n}=this;i.forEach(((i,A)=>{let{x:a,y:r}=i;!n[A]&&e.isPointInBox(a,r)&&(n[A]=t)}))}mapXY(t,e){const{window:i,ctx:n}=this.screen,A=new rt(t,e);let a=n.canvas;for(;a;)A.x-=a.offsetLeft,A.y-=a.offsetTop,a=a.offsetParent;return(null==i?void 0:i.scrollX)&&(A.x+=i.scrollX),(null==i?void 0:i.scrollY)&&(A.y+=i.scrollY),A}onClick(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:i,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:i,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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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:i,aspectRatio:n,width:A,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=F(n).replace(/^defer\s/,""),[B,p]=w.split(" "),m=B||"xMidYMid",E=p||"meet",f=A/a,C=r/s,Q=Math.min(f,C),y=Math.max(f,C);let I=a,D=s;"meet"===E&&(I*=Q,D*=Q),"slice"===E&&(I*=y,D*=y);const x=new et(e,"refX",l),v=new et(e,"refY",g),M=x.hasValue()&&v.hasValue();if(M&&i.translate(-Q*x.getPixels("x"),-Q*v.getPixels("y")),h){const t=Q*d,e=Q*u;i.beginPath(),i.moveTo(t,e),i.lineTo(A,e),i.lineTo(A,r),i.lineTo(t,r),i.closePath(),i.clip()}if(!M){const t="meet"===E&&Q===C,e="slice"===E&&y===C,n="meet"===E&&Q===f,a="slice"===E&&y===f;m.startsWith("xMid")&&(t||e)&&i.translate(A/2-I/2,0),m.endsWith("YMid")&&(n||a)&&i.translate(0,r/2-D/2),m.startsWith("xMax")&&(t||e)&&i.translate(A-I,0),m.endsWith("YMax")&&(n||a)&&i.translate(0,r-D)}switch(!0){case"none"===m:i.scale(f,C);break;case"meet"===E:i.scale(Q,Q);break;case"slice"===E:i.scale(y,y)}i.translate(-o,-c)}start(t){let{enableRedraw:e=!1,ignoreMouse:i=!1,ignoreAnimation:n=!1,ignoreDimensions:A=!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,A,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(n,r)&&(this.render(t,A,a,s,o,c,l),g.runEvents())),this.intervalId=b(u)(p)};i||g.start(),this.intervalId=b(u)(p)}stop(){this.intervalId&&(b(u).cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){const{frameDuration:t}=this;if(this.animations.reduce(((e,i)=>i.update(t)||e),!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,i,n,A,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 n&&"number"!=typeof A)&&(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 n||"number"==typeof A){const e=P(t.getAttribute("viewBox").getString());let i=0,a=0;if("number"==typeof n){const A=t.getStyle("width");A.hasValue()?i=A.getPixels("x")/n:e[2]&&!isNaN(e[2])&&(i=e[2]/n)}if("number"==typeof A){const i=t.getStyle("height");i.hasValue()?a=i.getPixels("y")/A:e[3]&&!isNaN(e[3])&&(a=e[3]/A)}i||(i=a),a||(a=i),t.getAttribute("width",!0).setValue(n),t.getAttribute("height",!0).setValue(A);const r=t.getStyle("transform",!0,!0);r.setValue(`${r.getString()} scale(${1/i}, ${1/a})`)}i||o.clearRect(0,0,d,u),t.render(o),c&&(this.isFirstRender=!1)}constructor(t,{fetch:e=gt,window:i=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 nt,this.mouse=new ot(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=i,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}function dt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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(i){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),i=await e.text();return this.parseFromString(i)}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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function mt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Et(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ft(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ct{apply(t){const{originX:e,originY:i,matrix:n}=this,A=e.getPixels("x"),a=i.getPixels("y");t.translate(A,a),t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.translate(-A,-a)}unapply(t){const{originX:e,originY:i,matrix:n}=this,A=n[0],a=n[2],r=n[4],s=n[1],o=n[3],c=n[5],l=1/(A*(1*o-0*c)-a*(1*s-0*c)+r*(0*s-0*o)),g=e.getPixels("x"),h=i.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*A-0*r),l*(a*c-r*o),l*(r*s-A*c)),t.translate(-g,-h)}applyToPoint(t){t.applyTransform(this.matrix)}constructor(t,e,i){ft(this,"type","matrix"),ft(this,"matrix",void 0),ft(this,"originX",void 0),ft(this,"originY",void 0),this.matrix=function(t){const e=P(t);return[e[0]||0,e[1]||0,e[2]||0,e[3]||0,e[4]||0,e[5]||0]}(e),this.originX=i[0],this.originY=i[1]}}function Qt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class yt extends Ct{constructor(t,e,i){super(t,e,i),Qt(this,"type","skew"),Qt(this,"angle",void 0),this.angle=new et(t,"angle",e)}}function It(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Dt{static fromElement(t,e){const i=e.getStyle("transform",!1,!0);if(i.hasValue()){const[n,A=n]=e.getStyle("transform-origin",!1,!0).split();if(n&&A){const e=[n,A];return new Dt(t,i.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,i){It(this,"document",void 0),It(this,"transforms",void 0),this.document=t,this.transforms=[];const n=function(t){return F(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);n.forEach((t=>{if("none"===t)return;const[e,n]=function(t){const[e="",i=""]=t.split("(");return[e.trim(),i.trim().replace(")","")]}(t),A=Dt.transformTypes[e];A&&this.transforms.push(new A(this.document,n,i))}))}}function xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}It(Dt,"transformTypes",{translate:class{apply(t){const{x:e,y:i}=this.point;t.translate(e||0,i||0)}unapply(t){const{x:e,y:i}=this.point;t.translate(-1*e||0,-1*i||0)}applyToPoint(t){const{x:e,y:i}=this.point;t.applyTransform([1,0,0,1,e||0,i||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:i,originX:n,originY:A,angle:a}=this,r=e+n.getPixels("x"),s=i+A.getPixels("y");t.translate(r,s),t.rotate(a.getRadians()),t.translate(-r,-s)}unapply(t){const{cx:e,cy:i,originX:n,originY:A,angle:a}=this,r=e+n.getPixels("x"),s=i+A.getPixels("y");t.translate(r,s),t.rotate(-1*a.getRadians()),t.translate(-r,-s)}applyToPoint(t){const{cx:e,cy:i,angle:n}=this,A=n.getRadians();t.applyTransform([1,0,0,1,e||0,i||0]),t.applyTransform([Math.cos(A),Math.sin(A),-Math.sin(A),Math.cos(A),0,0]),t.applyTransform([1,0,0,1,-e||0,-i||0])}constructor(t,e,i){mt(this,"type","rotate"),mt(this,"angle",void 0),mt(this,"originX",void 0),mt(this,"originY",void 0),mt(this,"cx",void 0),mt(this,"cy",void 0);const n=P(e);this.angle=new et(t,"angle",n[0]),this.originX=i[0],this.originY=i[1],this.cx=n[1]||0,this.cy=n[2]||0}},scale:class{apply(t){const{scale:{x:e,y:i},originX:n,originY:A}=this,a=n.getPixels("x"),r=A.getPixels("y");t.translate(a,r),t.scale(e,i||e),t.translate(-a,-r)}unapply(t){const{scale:{x:e,y:i},originX:n,originY:A}=this,a=n.getPixels("x"),r=A.getPixels("y");t.translate(a,r),t.scale(1/e,1/i||e),t.translate(-a,-r)}applyToPoint(t){const{x:e,y:i}=this.scale;t.applyTransform([e||0,0,0,i||0,0,0])}constructor(t,e,i){Et(this,"type","scale"),Et(this,"scale",void 0),Et(this,"originX",void 0),Et(this,"originY",void 0);const n=rt.parseScale(e);0!==n.x&&0!==n.y||(n.x=L,n.y=L),this.scale=n,this.originX=i[0],this.originY=i[1]}},matrix:Ct,skewX:class extends yt{constructor(t,e,i){var n,A,a;super(t,e,i),a="skewX",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}},skewY:class extends yt{constructor(t,e,i){var n,A,a;super(t,e,i),a="skewY",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}});class vt{getAttribute(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.attributes[t];if(!i&&e){const e=new et(this.document,t,"");return this.attributes[t]=e,e}return i||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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=this.styles[t];if(n)return n;const A=this.getAttribute(t);if(A.hasValue())return this.styles[t]=A,A;if(!i){const{parent:e}=this;if(e){const i=e.getStyle(t);if(i.hasValue())return i}}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=Dt.fromElement(this.document,this);e&&e.apply(t);const i=this.getStyle("clip-path",!1,!0);if(i.hasValue()){const e=i.getDefinition();e&&e.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach((e=>{e.render(t)}))}addChild(t){const e=t instanceof vt?t:this.document.createElement(t);e.parent=this,vt.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:i}=this;if(!i)return!1;if("function"==typeof i.matches)return i.matches(t);const n=null===(e=i.getAttribute)||void 0===e?void 0:e.call(i,"class");return!(!n||""===n)&&n.split(" ").some((e=>`.${e}`===t))}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let i;for(const n in t)if(!n.startsWith("@")&&this.matchesSelector(n)){const A=t[n],a=e[n];if(A)for(const t in A){let e=this.stylesSpecificity[t];void 0===e&&(e="000"),a&&a>=e&&(i=A[t],i&&(this.styles[t]=i),this.stylesSpecificity[t]=a)}}}removeStyles(t,e){return e.reduce(((e,i)=>{const n=t.getStyle(i);if(!n.hasValue())return e;const A=n.getString();return n.setValue(""),[...e,[i,A]]}),[])}restoreStyles(t,e){e.forEach((e=>{let[i,n]=e;t.getStyle(i,!0).setValue(n)}))}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}constructor(t,e,i=!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=i,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 i=(n=e.nodeName,Y.test(n)?n.toLowerCase():n);var n;this.attributes[i]=new et(t,i,e.value)})),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()){this.getAttribute("style").getString().split(";").map((t=>t.trim())).forEach((e=>{if(!e)return;const[i,n]=e.split(":").map((t=>t.trim()));i&&(this.styles[i]=new et(t,i,n))}))}const{definitions:n}=t,A=this.getAttribute("id");A.hasValue()&&(n[A.getString()]||(n[A.getString()]=this)),Array.from(e.childNodes).forEach((e=>{if(1===e.nodeType)this.addChild(e);else if(i&&(3===e.nodeType||4===e.nodeType)){const i=t.createTextNode(e);i.getText().length>0&&this.addChild(i)}}))}}xt(vt,"ignoreChildTypes",["title"]);class Mt extends vt{constructor(t,e,i){super(t,e,i)}}function St(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function bt(t){const e=t.trim();return/^('|")/.test(e)?e:`"${e}"`}function Ft(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 Pt(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 Yt{static parse(){let t=arguments.length>1?arguments[1]:void 0,e="",i="",n="",A="",a="";const r=F(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&&Yt.styles.includes(t):"inherit"!==t&&(e=t),s.fontStyle=!0;break;case!s.fontVariant&&Yt.variants.includes(t):"inherit"!==t&&(i=t),s.fontStyle=!0,s.fontVariant=!0;break;case!s.fontWeight&&Yt.weights.includes(t):"inherit"!==t&&(n=t),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0;break;case!s.fontSize:"inherit"!==t&&(A=t.split("/")[0]||""),s.fontStyle=!0,s.fontVariant=!0,s.fontWeight=!0,s.fontSize=!0;break;default:"inherit"!==t&&(a+=t)}})),new Yt(e,i,n,A,a,t)}toString(){return[Ft(this.fontStyle),this.fontVariant,Pt(this.fontWeight),this.fontSize,(t=this.fontFamily,void 0===d?t:t.trim().split(",").map(bt).join(","))].join(" ").trim();var t}constructor(t,e,i,n,A,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?Yt.parse(a):a:{};this.fontFamily=A||r.fontFamily,this.fontSize=n||r.fontSize,this.fontStyle=t||r.fontStyle,this.fontWeight=i||r.fontWeight,this.fontVariant=e||r.fontVariant}}function Nt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}St(Yt,"styles","normal|italic|oblique|inherit"),St(Yt,"variants","normal|small-caps|inherit"),St(Yt,"weights","normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit");class kt{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:i,x2:n,y2:A}=t;this.addPoint(e,i),this.addPoint(n,A)}sumCubic(t,e,i,n,A){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*i+3*(1-t)*Math.pow(t,2)*n+Math.pow(t,3)*A}bezierCurveAdd(t,e,i,n,A){const a=6*e-12*i+6*n,r=-3*e+9*i-9*n+3*A,s=3*i-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,i,n,A)):this.addY(this.sumCubic(r,e,i,n,A))))}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,i,n,A)):this.addY(this.sumCubic(c,e,i,n,A)));const l=(-a-Math.sqrt(o))/(2*r);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,i,n,A)):this.addY(this.sumCubic(l,e,i,n,A)))}addBezierCurve(t,e,i,n,A,a,r,s){this.addPoint(t,e),this.addPoint(r,s),this.bezierCurveAdd(!0,t,i,A,r),this.bezierCurveAdd(!1,e,n,a,s)}addQuadraticCurve(t,e,i,n,A,a){const r=t+2/3*(i-t),s=e+2/3*(n-e),o=r+1/3*(A-t),c=s+1/3*(a-e);this.addBezierCurve(t,e,r,o,s,c,A,a)}isPointInBox(t,e){const{x1:i,y1:n,x2:A,y2:a}=this;return i<=t&&t<=A&&n<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,i=Number.NaN,n=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=i,this.y2=n,this.addPoint(t,e),this.addPoint(i,n)}}class Rt extends vt{calculateOpacity(){let t=1,e=this;for(;e;){const i=e.getStyle("opacity",!1,!0);i.hasValue(!0)&&(t*=i.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"),i=this.getStyle("fill-opacity"),n=this.getStyle("stroke"),A=this.getStyle("stroke-opacity");if(e.isUrlDefinition()){const n=e.getFillStyleDefinition(this,i);n&&(t.fillStyle=n)}else if(e.hasValue()){"currentColor"===e.getString()&&e.setValue(this.getStyle("color").getColor());const i=e.getColor();"inherit"!==i&&(t.fillStyle="none"===i?"rgba(0,0,0,0)":i)}if(i.hasValue()){const e=new et(this.document,"fill",t.fillStyle).addOpacity(i).getColor();t.fillStyle=e}if(n.isUrlDefinition()){const e=n.getFillStyleDefinition(this,A);e&&(t.strokeStyle=e)}else if(n.hasValue()){"currentColor"===n.getString()&&n.setValue(this.getStyle("color").getColor());const e=n.getString();"inherit"!==e&&(t.strokeStyle="none"===e?"rgba(0,0,0,0)":e)}if(A.hasValue()){const e=new et(this.document,"stroke",t.strokeStyle).addOpacity(A).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=P(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 i=l.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=i:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=i:void 0!==t.mozDashOffset&&(t.mozDashOffset=i)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){const e=this.getStyle("font"),i=this.getStyle("font-style"),n=this.getStyle("font-variant"),A=this.getStyle("font-weight"),a=this.getStyle("font-size"),r=this.getStyle("font-family"),s=new Yt(i.getString(),n.getString(),A.getString(),a.hasValue()?`${a.getPixels(!0)}px`:"",r.getString(),Yt.parse(e.getString(),t.font));i.setValue(s.fontStyle),n.setValue(s.fontVariant),A.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,i,n;super(...t),n=!1,(i="modifiedEmSizeStack")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}function Ht(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ut extends Rt{setContext(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);const i=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();i&&(t.textBaseline=i)}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(((i,n)=>{const A=this.getChildBoundingBox(t,this,this,n);e?e.addBoundingBox(A):e=A})),e}getFontSize(){const{document:t,parent:e}=this,i=Yt.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(i)}getTElementBoundingBox(t){const e=this.getFontSize();return new kt(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,i){const n=e[i];let A;if(t.isArabic){var a;const r=e.length,s=e[i-1],o=e[i+1];let c="isolated";(0===i||" "===s)&&i<r-1&&" "!==o&&(c="terminal"),i>0&&" "!==s&&i<r-1&&" "!==o&&(c="medial"),i>0&&" "!==s&&(i===r-1||" "===o)&&(c="initial"),A=(null===(a=t.arabicGlyphs[n])||void 0===a?void 0:a[c])||t.glyphs[n]}else A=t.glyphs[n];return A||(A=t.missingGlyph),A}getText(){return""}getTextFromNode(t){const e=t||this.node,i=Array.from(e.parentNode.childNodes),n=i.indexOf(e),A=i.length-1;let a=F(e.textContent||"");return 0===n&&(a=a.replace(/^[\n \t]+/,"")),n===A&&(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,i)=>{this.renderChild(t,this,this,i)}));const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:i}=this,n=this.getText(),A=i.getStyle("font-family").getDefinition();if(null==A?void 0:A.fontFace){const{unitsPerEm:a}=A.fontFace,r=Yt.parse(e.ctx.font),s=i.getStyle("font-size").getNumber(r.fontSize),o=i.getStyle("font-style").getString(r.fontStyle),c=s/a,l=A.isRTL?n.split("").reverse().join(""):n,g=P(i.getAttribute("dx").getString()),h=l.length;for(let e=0;e<h;e++){const i=this.getGlyph(A,l,e);t.translate(this.x,this.y),t.scale(c,-c);const n=t.lineWidth;t.lineWidth=t.lineWidth*a/s,"italic"===o&&t.transform(1,0,.4,1,0,0),i.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=n,t.scale(1/c,-1/c),t.translate(-this.x,-this.y),this.x+=s*(i.horizAdvX||A.horizAdvX)/a,void 0===g[e]||isNaN(g[e])||(this.x+=g[e])}return}const{x:a,y:r}=this;t.fillStyle&&t.fillText(n,a,r),t.strokeStyle&&t.strokeText(n,a,r)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start");let i=0;i="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+=i;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach(((e,i)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,i)})),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,i,n){const A=i.children[n];A.children.length>0?A.children.forEach(((i,n)=>{e.adjustChildCoordinatesRecursiveCore(t,e,A,n)})):this.adjustChildCoordinates(t,e,i,n)}adjustChildCoordinates(t,e,i,n){const A=i.children[n];if("function"!=typeof A.measureText)return A;t.save(),A.setContext(t,!0);const a=A.getAttribute("x"),r=A.getAttribute("y"),s=A.getAttribute("dx"),o=A.getAttribute("dy"),c=A.getStyle("font-family").getDefinition(),l=Boolean(null==c?void 0:c.isRTL);0===n&&(a.hasValue()||a.setValue(A.getInheritedAttribute("x")),r.hasValue()||r.setValue(A.getInheritedAttribute("y")),s.hasValue()||s.setValue(A.getInheritedAttribute("dx")),o.hasValue()||o.setValue(A.getInheritedAttribute("dy")));const g=A.measureText(t);return l&&(e.x-=g),a.hasValue()?(e.applyAnchoring(),A.x=a.getPixels("x"),s.hasValue()&&(A.x+=s.getPixels("x"))):(s.hasValue()&&(e.x+=s.getPixels("x")),A.x=e.x),e.x=A.x,l||(e.x+=g),r.hasValue()?(A.y=r.getPixels("y"),o.hasValue()&&(A.y+=o.getPixels("y"))):(o.hasValue()&&(e.y+=o.getPixels("y")),A.y=e.y),e.y=A.y,e.leafTexts.push(A),e.minX=Math.min(e.minX,A.x,A.x+g),e.maxX=Math.max(e.maxX,A.x,A.x+g),A.clearContext(t),t.restore(),A}getChildBoundingBox(t,e,i,n){const A=i.children[n];if("function"!=typeof A.getBoundingBox)return null;const a=A.getBoundingBox(t);return a&&A.children.forEach(((i,n)=>{const r=e.getChildBoundingBox(t,e,A,n);a.addBoundingBox(r)})),a}renderChild(t,e,i,n){const A=i.children[n];A.render(t),A.children.forEach(((i,n)=>{e.renderChild(t,e,A,n)}))}measureText(t){const{measureCache:e}=this;if(~e)return e;const i=this.getText(),n=this.measureTargetText(t,i);return this.measureCache=n,n}measureTargetText(t,e){if(!e.length)return 0;const{parent:i}=this,n=i.getStyle("font-family").getDefinition();if(n){const t=this.getFontSize(),A=n.isRTL?e.split("").reverse().join(""):e,a=P(i.getAttribute("dx").getString()),r=A.length;let s=0;for(let e=0;e<r;e++){s+=(this.getGlyph(n,A,e).horizAdvX||n.horizAdvX)*t/n.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:A}=t.measureText(e);return this.clearContext(t),t.restore(),A}getInheritedAttribute(t){let e=this;for(;e instanceof Ut&&e.isFirstChild()&&e.parent;){const i=e.parent.getAttribute(t);if(i.hasValue(!0))return i.getString("0");e=e.parent}return null}constructor(t,e,i){super(t,e,new.target===Ut||i),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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Tt extends Ut{getText(){return this.text}constructor(t,e,i){super(t,e,new.target===Tt||i),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,i,n;super(...t),n="textNode",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}function Jt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,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 i=new rt(this.command[t],this.command[e]);return this.makeAbsolute(i)}getAsControlPoint(t,e){const i=this.getPoint(t,e);return this.control=i,i}getAsCurrentPoint(t,e){const i=this.getPoint(t,e);return this.current=i,i}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:i},control:{x:n,y:A}}=this;return new rt(2*e-n,2*i-A)}makeAbsolute(t){if(this.command.relative){const{x:e,y:i}=this.current;t.x+=e,t.y+=i}return t}addMarker(t,e,i){const{points:n,angles:A}=this;i&&A.length>0&&!A[A.length-1]&&(A[A.length-1]=n[n.length-1].angleTo(i)),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 i=0;i<e;i++)if(!t[i])for(let n=i+1;n<e;n++)if(t[n]){t[i]=t[n];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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class jt extends Rt{path(t){const{pathParser:e}=this,i=new kt;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case Lt.MOVE_TO:this.pathM(t,i);break;case Lt.LINE_TO:this.pathL(t,i);break;case Lt.HORIZ_LINE_TO:this.pathH(t,i);break;case Lt.VERT_LINE_TO:this.pathV(t,i);break;case Lt.CURVE_TO:this.pathC(t,i);break;case Lt.SMOOTH_CURVE_TO:this.pathS(t,i);break;case Lt.QUAD_TO:this.pathQ(t,i);break;case Lt.SMOOTH_QUAD_TO:this.pathT(t,i);break;case Lt.ARC:this.pathA(t,i);break;case Lt.CLOSE_PATH:this.pathZ(t,i)}return i}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),i=t.getMarkerAngles();if(!e||!i)return null;return e.map(((t,e)=>[t,i[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 i=this.getMarkers();if(i){const e=i.length-1,n=this.getStyle("marker-start"),A=this.getStyle("marker-mid"),a=this.getStyle("marker-end");if(n.isUrlDefinition()){const e=n.getDefinition(),[A,a]=i[0];e&&e.render(t,A,null===a?void 0:a)}if(A.isUrlDefinition()){const n=A.getDefinition();for(let A=1;A<e;A++){const[e,a]=i[A];n&&n.render(t,e,null===a?void 0:a)}}if(a.isUrlDefinition()){const n=a.getDefinition(),[A,r]=i[e];n&&n.render(t,A,null===r?void 0:r)}}}static pathM(t){const e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){const{pathParser:i}=this,{point:n}=jt.pathM(i),{x:A,y:a}=n;i.addMarker(n),e.addPoint(A,a),t&&t.moveTo(A,a)}static pathL(t){const{current:e}=t;return{current:e,point:t.getAsCurrentPoint()}}pathL(t,e){const{pathParser:i}=this,{current:n,point:A}=jt.pathL(i),{x:a,y:r}=A;i.addMarker(A,n),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathH(t){const{current:e,command:i}=t,n=new rt(((null==i?void 0:i.relative)?e.x:0)+i.x,e.y);return t.current=n,{current:e,point:n}}pathH(t,e){const{pathParser:i}=this,{current:n,point:A}=jt.pathH(i),{x:a,y:r}=A;i.addMarker(A,n),e.addPoint(a,r),t&&t.lineTo(a,r)}static pathV(t){const{current:e,command:i}=t,n=new rt(e.x,(i.relative?e.y:0)+i.y);return t.current=n,{current:e,point:n}}pathV(t,e){const{pathParser:i}=this,{current:n,point:A}=jt.pathV(i),{x:a,y:r}=A;i.addMarker(A,n),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:i}=this,{current:n,point:A,controlPoint:a,currentPoint:r}=jt.pathC(i);i.addMarker(r,a,A),e.addBezierCurve(n.x,n.y,A.x,A.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(A.x,A.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:i}=this,{current:n,point:A,controlPoint:a,currentPoint:r}=jt.pathS(i);i.addMarker(r,a,A),e.addBezierCurve(n.x,n.y,A.x,A.y,a.x,a.y,r.x,r.y),t&&t.bezierCurveTo(A.x,A.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:i}=this,{current:n,controlPoint:A,currentPoint:a}=jt.pathQ(i);i.addMarker(a,A,A),e.addQuadraticCurve(n.x,n.y,A.x,A.y,a.x,a.y),t&&t.quadraticCurveTo(A.x,A.y,a.x,a.y)}static pathT(t){const{current:e}=t,i=t.getReflectedControlPoint();t.control=i;return{current:e,controlPoint:i,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){const{pathParser:i}=this,{current:n,controlPoint:A,currentPoint:a}=jt.pathT(i);i.addMarker(a,A,A),e.addQuadraticCurve(n.x,n.y,A.x,A.y,a.x,a.y),t&&t.quadraticCurveTo(A.x,A.y,a.x,a.y)}static pathA(t){const{current:e,command:i}=t;let{rX:n,rY:A,xRot:a,lArcFlag:r,sweepFlag:s}=i;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(n,2)+Math.pow(l.y,2)/Math.pow(A,2);g>1&&(n*=Math.sqrt(g),A*=Math.sqrt(g));let h=(r===s?-1:1)*Math.sqrt((Math.pow(n,2)*Math.pow(A,2)-Math.pow(n,2)*Math.pow(l.y,2)-Math.pow(A,2)*Math.pow(l.x,2))/(Math.pow(n,2)*Math.pow(l.y,2)+Math.pow(A,2)*Math.pow(l.x,2)));isNaN(h)&&(h=0);const d=new rt(h*n*l.y/A,h*-A*l.x/n),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)/n,(l.y-d.y)/A]),B=[(l.x-d.x)/n,(l.y-d.y)/A],p=[(-l.x-d.x)/n,(-l.y-d.y)/A];let m=V(B,p);return j(B,p)<=-1&&(m=Math.PI),j(B,p)>=1&&(m=0),{currentPoint:c,rX:n,rY:A,sweepFlag:s,xAxisRotation:o,centp:u,a1:w,ad:m}}pathA(t,e){const{pathParser:i}=this,{currentPoint:n,rX:A,rY:a,sweepFlag:r,xAxisRotation:s,centp:o,a1:c,ad:l}=jt.pathA(i),g=1-r?1:-1,h=c+g*(l/2),d=new rt(o.x+A*Math.cos(h),o.y+a*Math.sin(h));if(i.addMarkerAngle(d,h-g*Math.PI/2),i.addMarkerAngle(n,h-g*Math.PI),e.addPoint(n.x,n.y),t&&!isNaN(c)&&!isNaN(l)){const e=A>a?A:a,i=A>a?1:A/a,n=A>a?a/A:1;t.translate(o.x,o.y),t.rotate(s),t.scale(i,n),t.arc(0,0,e,c,c+l,Boolean(1-r)),t.scale(1/i,1/n),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,i){super(t,e,i),zt(this,"type","path"),zt(this,"pathParser",void 0),this.pathParser=new Lt(this.getAttribute("d").getString())}}function Vt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Kt extends Rt{setContext(t){var e;const{document:i}=this,{screen:n,window:A}=i,a=t.canvas;if(n.setDefaults(t),"style"in a&&void 0!==t.font&&A&&void 0!==A.getComputedStyle){t.font=A.getComputedStyle(a).getPropertyValue("font");const e=new et(i,"fontSize",Yt.parse(t.font).fontSize);e.hasValue()&&(i.rootEmSize=e.getPixels("y"),i.emSize=i.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}=n.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()?P(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)),n.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]),i.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:n.viewPort.width,desiredWidth:r,height:n.viewPort.height,desiredHeight:s,minX:d,minY:u,refX:o.getValue(),refY:c.getValue(),clip:h,clipX:w,clipY:B}),g&&(n.viewPort.removeCurrent(),n.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,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=this.getAttribute("width",!0),A=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),r=this.getAttribute("style"),s=n.getNumber(0),o=A.getNumber(0);if(i)if("string"==typeof i)this.getAttribute("preserveAspectRatio",!0).setValue(i);else{const t=this.getAttribute("preserveAspectRatio");t.hasValue()&&t.setValue(t.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(n.setValue(t),A.setValue(e),a.hasValue()||a.setValue(`0 0 ${s||t} ${o||e}`),r.hasValue()){const i=this.getStyle("width"),n=this.getStyle("height");i.hasValue()&&i.setValue(`${t}px`),n.hasValue()&&n.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"),i=this.getAttribute("y").getPixels("y"),n=this.getStyle("width",!1,!0).getPixels("x"),A=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,n/2),o=Math.min(o,A/2),t){const a=(Math.sqrt(2)-1)/3*4;t.beginPath(),A>0&&n>0&&(t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.bezierCurveTo(e+n-s+a*s,i,e+n,i+o-a*o,e+n,i+o),t.lineTo(e+n,i+A-o),t.bezierCurveTo(e+n,i+A-o+a*o,e+n-s+a*s,i+A,e+n-s,i+A),t.lineTo(e+s,i+A),t.bezierCurveTo(e+s-a*s,i+A,e,i+A-o+a*o,e,i+A-o),t.lineTo(e,i+o),t.bezierCurveTo(e,i+o-a*o,e+s-a*s,i,e+s,i),t.closePath())}return new kt(e,i,e+n,i+A)}getMarkers(){return null}constructor(...t){var e,i,n;super(...t),n="rect",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}function Xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class qt extends jt{path(t){const{points:e}=this,[{x:i,y:n}]=e,A=new kt(i,n);return t&&(t.beginPath(),t.moveTo(i,n)),e.forEach((e=>{let{x:i,y:n}=e;A.addPoint(i,n),t&&t.lineTo(i,n)})),A}getMarkers(){const{points:t}=this,e=t.length-1,i=[];return t.forEach(((n,A)=>{A!==e&&i.push([n,n.angleTo(t[A+1])])})),i.length>0&&i.push([t[t.length-1],i[i.length-1][1]]),i}constructor(t,e,i){super(t,e,i),Xt(this,"type","polyline"),Xt(this,"points",[]),this.points=rt.parsePath(this.getAttribute("points").getString())}}class Zt extends Rt{getBoundingBox(t){const e=new kt;return this.children.forEach((i=>{i instanceof jt&&e.addBoundingBox(i.getBoundingBox(t))})),e}constructor(...t){var e,i,n;super(...t),n="g",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}function $t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class _t extends vt{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,i){let n=this;this.getHrefAttribute().hasValue()&&(n=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(n));const{stops:A}=n,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(i,A[A.length-1].color);if(A.forEach((t=>{a.addColorStop(t.offset,this.addParentOpacity(i,t.color))})),this.getAttribute("gradientTransform").hasValue()){const{document:t}=this,{MAX_VIRTUAL_PIXELS:e}=ht,{viewPort:i}=t.screen,n=i.getRoot(),A=new Wt(t);A.attributes.x=new et(t,"x",-e/3),A.attributes.y=new et(t,"y",-e/3),A.attributes.width=new et(t,"width",e),A.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=[A];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",n.width),s.attributes.height=new et(t,"height",n.height),s.children=[r];const o=t.createCanvas(n.width,n.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,i){super(t,e,i),$t(this,"attributesToInherit",["gradientUnits"]),$t(this,"stops",[]);const{stops:n,children:A}=this;A.forEach((t=>{"stop"===t.type&&n.push(t)}))}}function te(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ee(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ie extends vt{getProperty(){var t;const e=this.getAttribute("attributeType").getString(),i=this.getAttribute("attributeName").getString();var n;return"CSS"===e?null===(n=this.parent)||void 0===n?void 0:n.getStyle(i,!0):null===(t=this.parent)||void 0===t?void 0:t.getAttribute(i,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:i,to:n}=this.getProgress();let A=i.getNumber()+(n.getNumber()-i.getNumber())*e;return"%"===t&&(A*=100),`${A}${t}`}update(t){const{parent:e}=this,i=this.getProperty();if(!i)return!1;if(this.initialValue||(this.initialValue=i.getString(),this.initialUnits=i.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&&i&&i.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e&&i&&(e.animationFrozen=!0,e.animationFrozenValue=i.getString());return!1}this.duration+=t;let n=!1;if(this.begin<this.duration){let t=this.calcValue();const e=this.getAttribute("type");if(e.hasValue()){t=`${e.getString()}(${t})`}i.setValue(t),n=!0}return n}getProgress(){const{document:t,values:e}=this;let i,n,A=(this.duration-this.begin)/(this.maxDuration-this.begin);if(e.hasValue()){const a=A*(e.getValue().length-1),r=Math.floor(a),s=Math.ceil(a);let o;o=e.getValue()[r],i=new et(t,"from",o?parseFloat(o):0),o=e.getValue()[s],n=new et(t,"to",o?parseFloat(o):0),A=(a-r)/(s-r)}else i=this.from,n=this.to;return{progress:A,from:i,to:n}}constructor(t,e,i){super(t,e,i),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 n=this.getAttribute("values");n.hasValue()&&this.values.setValue(n.getString().split(";"))}}function ne(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ae extends vt{constructor(t,e,i){super(t,e,i),ne(this,"type","font-face"),ne(this,"ascent",void 0),ne(this,"descent",void 0),ne(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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class re extends jt{constructor(t,e,i){super(t,e,i),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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class oe extends re{constructor(...t){super(...t),se(this,"type","missing-glyph"),se(this,"horizAdvX",0)}}function ce(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function le(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ge(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function he(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const de=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;function ue(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class we{async load(t,e){try{const{document:i}=this,n=(await i.pith.parser.load(e)).getElementsByTagName("font");Array.from(n).forEach((e=>{const n=i.createElement(e);i.definitions[t]=n}))}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,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class pe extends vt{constructor(t,e,i){super(t,e,i),Be(this,"type","style");F(Array.from(e.childNodes).map((t=>t.textContent)).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach((e=>{const i=e.trim();if(!i)return;const n=i.split("{"),A=n[0].split(","),a=n[1].split(";");A.forEach((e=>{const i=e.trim();if(!i)return;const n=t.styles[i]||{};if(a.forEach((e=>{const i=e.indexOf(":"),A=e.substr(0,i).trim(),a=e.substr(i+1,e.length-i).trim();A&&a&&(n[A]=new et(t,A,a))})),t.styles[i]=n,t.stylesSpecificity[i]=function(t){const e=[0,0,0];let i=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),n=0;return[i,n]=J(i,k),e[1]+=n,[i,n]=J(i,R),e[0]+=n,[i,n]=J(i,H),e[1]+=n,[i,n]=J(i,U),e[2]+=n,[i,n]=J(i,G),e[1]+=n,[i,n]=J(i,T),e[1]+=n,i=i.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[i,n]=J(i,O),e[2]+=n,e.join("")}(i),"@font-face"===i){const e=n["font-family"].getString().replace(/"|'/g,"");n.src.getString().split(",").forEach((i=>{if(i.indexOf('format("svg")')>0){const n=N(i);n&&new we(t).load(e,n)}}))}}))}))}}function me(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Be(pe,"parseExternalUrl",N);function Ee(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function fe(t,e,i,n,A,a){return t[i*n*4+4*e+a]}function Ce(t,e,i,n,A,a,r){t[i*n*4+4*e+a]=r}function Qe(t,e,i){return t[e]*i}function ye(t,e,i,n){return e+Math.cos(t)*i+Math.sin(t)*n}class Ie extends vt{apply(t,e,i,n,A){const{includeOpacity:a,matrix:r}=this,s=t.getImageData(0,0,n,A);for(let t=0;t<A;t++)for(let e=0;e<n;e++){const i=fe(s.data,e,t,n,0,0),A=fe(s.data,e,t,n,0,1),o=fe(s.data,e,t,n,0,2),c=fe(s.data,e,t,n,0,3);let l=Qe(r,0,i)+Qe(r,1,A)+Qe(r,2,o)+Qe(r,3,c)+Qe(r,4,1),g=Qe(r,5,i)+Qe(r,6,A)+Qe(r,7,o)+Qe(r,8,c)+Qe(r,9,1),h=Qe(r,10,i)+Qe(r,11,A)+Qe(r,12,o)+Qe(r,13,c)+Qe(r,14,1),d=Qe(r,15,i)+Qe(r,16,A)+Qe(r,17,o)+Qe(r,18,c)+Qe(r,19,1);a&&(l=0,g=0,h=0,d*=c/255),Ce(s.data,e,t,n,0,0,l),Ce(s.data,e,t,n,0,1,g),Ce(s.data,e,t,n,0,2,h),Ce(s.data,e,t,n,0,3,d)}t.clearRect(0,0,n,A),t.putImageData(s,0,0)}constructor(t,e,i){super(t,e,i),Ee(this,"type","feColorMatrix"),Ee(this,"matrix",void 0),Ee(this,"includeOpacity",void 0);let n=P(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const t=n[0];n=[.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=n[0]*Math.PI/180;n=[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":n=[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=n,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}function De(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class xe extends vt{apply(t,e){const{document:i}=this;let n=this.getAttribute("x").getPixels("x"),A=this.getAttribute("y").getPixels("y"),a=this.getStyle("width").getPixels("x"),r=this.getStyle("height").getPixels("y");if(!a&&!r){const e=new kt;this.children.forEach((i=>{i instanceof jt&&e.addBoundingBox(i.getBoundingBox(t))})),n=Math.floor(e.x1),A=Math.floor(e.y1),a=Math.floor(e.width),r=Math.floor(e.height)}const s=this.removeStyles(e,xe.ignoreStyles),o=i.createCanvas(n+a,A+r),c=o.getContext("2d");i.screen.setDefaults(c),this.renderChildren(c),new Ie(i,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,n+a,A+r);const l=i.createCanvas(n+a,A+r),g=l.getContext("2d");i.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=c.createPattern(o,"no-repeat"),g.fillRect(0,0,n+a,A+r),t.fillStyle=g.createPattern(l,"no-repeat"),t.fillRect(0,0,n+a,A+r),this.restoreStyles(e,s)}render(t){}constructor(...t){super(...t),De(this,"type","mask")}}De(xe,"ignoreStyles",["mask","transform","clip-path"]);const ve=()=>{};function Me(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Se extends vt{apply(t,e,i,n,A){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,i,n,A,r),s&&s.removeChild(o)}constructor(t,e,i){super(t,e,i),Me(this,"type","feGaussianBlur"),Me(this,"extraFilterDistance",void 0),Me(this,"blurRadius",void 0),this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}function be(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Fe extends vt{apply(t,e){const{document:i,children:n}=this,A="getBoundingBox"in e?e.getBoundingBox(t):null;if(!A)return;let a=0,r=0;n.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(A.width),o=Math.floor(A.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(A.x),h=Math.floor(A.y),d=this.removeStyles(e,Fe.ignoreStyles),u=i.createCanvas(c,l),w=u.getContext("2d");i.screen.setDefaults(w),w.translate(-g+a,-h+r),e.render(w),n.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),be(this,"type","filter")}}be(Fe,"ignoreStyles",["filter","transform","clip-path"]);const Pe={svg:Kt,rect:Wt,circle:class extends jt{path(t){const e=this.getAttribute("cx").getPixels("x"),i=this.getAttribute("cy").getPixels("y"),n=this.getAttribute("r").getPixels();return t&&n>0&&(t.beginPath(),t.arc(e,i,n,0,2*Math.PI,!1),t.closePath()),new kt(e-n,i-n,e+n,i+n)}getMarkers(){return null}constructor(...t){var e,i,n;super(...t),n="circle",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},ellipse:class extends jt{path(t){const e=(Math.sqrt(2)-1)/3*4,i=this.getAttribute("rx").getPixels("x"),n=this.getAttribute("ry").getPixels("y"),A=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&i>0&&n>0&&(t.beginPath(),t.moveTo(A+i,a),t.bezierCurveTo(A+i,a+e*n,A+e*i,a+n,A,a+n),t.bezierCurveTo(A-e*i,a+n,A-i,a+e*n,A-i,a),t.bezierCurveTo(A-i,a-e*n,A-e*i,a-n,A,a-n),t.bezierCurveTo(A+e*i,a-n,A+i,a-e*n,A+i,a),t.closePath()),new kt(A-i,a-n,A+i,a+n)}getMarkers(){return null}constructor(...t){var e,i,n;super(...t),n="ellipse",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},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:i},{x:n,y:A}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,i),t.lineTo(n,A)),new kt(e,i,n,A)}getMarkers(){const[t,e]=this.getPoints(),i=t.angleTo(e);return[[t,i],[e,i]]}constructor(...t){var e,i,n;super(...t),n="line",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},polyline:qt,polygon:class extends qt{path(t){const e=super.path(t),[{x:i,y:n}]=this.points;return t&&(t.lineTo(i,n),t.closePath()),e}constructor(...t){var e,i,n;super(...t),n="polygon",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},path:jt,pattern:class extends vt{createPattern(t,e,i){const n=this.getStyle("width").getPixels("x",!0),A=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):n,o=r.hasValue()?r.getPixels("y",!0):A,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)),i.hasValue()?this.styles["fill-opacity"]=i: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,i,n;super(...t),n="pattern",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},marker:class extends vt{render(t,e,i){if(!e)return;const{x:n,y:A}=e,a=this.getAttribute("orient").getString("auto"),r=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(n,A),"auto"===a&&i&&t.rotate(i),"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&&i&&t.rotate(-i),t.translate(-n,-A)}constructor(...t){var e,i,n;super(...t),n="marker",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},defs:class extends vt{render(){}constructor(...t){var e,i,n;super(...t),n="defs",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},linearGradient:class extends _t{getGradient(t,e){const i="objectBoundingBox"===this.getGradientUnits(),n=i?e.getBoundingBox(t):null;if(i||!n)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 A=i?n.x+n.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=i?n.y+n.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),r=i?n.x+n.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),s=i?n.y+n.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return A===r&&a===s?null:t.createLinearGradient(A,a,r,s)}constructor(t,e,i){var n,A,a;super(t,e,i),a="linearGradient",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.attributesToInherit.push("x1","y1","x2","y2")}},radialGradient:class extends _t{getGradient(t,e){const i="objectBoundingBox"===this.getGradientUnits(),n=e.getBoundingBox(t);if(i&&!n)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 A=i?n.x+n.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=i?n.y+n.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let r=A,s=a;this.getAttribute("fx").hasValue()&&(r=i?n.x+n.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(s=i?n.y+n.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const o=i?(n.width+n.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),c=this.getAttribute("fr").getPixels();return t.createRadialGradient(r,s,c,A,a,o)}constructor(t,e,i){var n,A,a;super(t,e,i),a="radialGradient",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}},stop:class extends vt{constructor(t,e,i){super(t,e,i),te(this,"type","stop"),te(this,"offset",void 0),te(this,"color",void 0);const n=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),A=this.getStyle("stop-opacity");let a=this.getStyle("stop-color",!0);""===a.getString()&&a.setValue("#000"),A.hasValue()&&(a=a.addOpacity(A)),this.offset=n,this.color=a.getColor()}},animate:ie,animateColor:class extends ie{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),n=new(b(w))(e.getColor()),A=new(b(w))(i.getColor());if(n.ok&&A.ok){const e=n.r+(A.r-n.r)*t,i=n.g+(A.g-n.g)*t,a=n.b+(A.b-n.b)*t;return`rgb(${Math.floor(e)}, ${Math.floor(i)}, ${Math.floor(a)})`}return this.getAttribute("from").getColor()}constructor(...t){var e,i,n;super(...t),n="animateColor",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},animateTransform:class extends ie{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),n=P(e.getString()),A=P(i.getString()),a=n.map(((e,i)=>e+(A[i]-e)*t)).join(" ");return a}constructor(...t){var e,i,n;super(...t),n="animateTransform",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},font:class extends vt{render(){}constructor(t,e,i){super(t,e,i),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:n}=t,{children:A}=this;for(const t of A)if(t instanceof Ae){this.fontFace=t;const e=t.getStyle("font-family");e.hasValue()&&(n[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":Ae,"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,i,n;super(...t),n="tref",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},a:class extends Ut{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:i,y:n}=this,{mouse:A}=e.screen,a=new et(e,"fontSize",Yt.parse(e.ctx.font).fontSize);A.isWorking()&&A.checkBoundingBox(this,new kt(i,n-a.getPixels("y"),i+this.measureText(t),n))}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,i){super(t,e,i),le(this,"type","a"),le(this,"hasText",void 0),le(this,"text",void 0);const{childNodes:n}=e,A=n[0],a=n.length>0&&Array.from(n).every((t=>3===t.nodeType));this.hasText=a,this.text=a?this.getTextFromNode(A):""}},textPath:class extends Ut{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach((e=>{let{type:i,points:n}=e;switch(i){case Lt.LINE_TO:t&&t.lineTo(n[0],n[1]);break;case Lt.MOVE_TO:t&&t.moveTo(n[0],n[1]);break;case Lt.CURVE_TO:t&&t.bezierCurveTo(n[0],n[1],n[2],n[3],n[4],n[5]);break;case Lt.QUAD_TO:t&&t.quadraticCurveTo(n[0],n[1],n[2],n[3]);break;case Lt.ARC:{const[e,i,A,a,r,s,o,c]=n,l=A>a?A:a,g=A>a?1:A/a,h=A>a?a/A:1;t&&(t.translate(e,i),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,-i));break}case Lt.CLOSE_PATH:t&&t.closePath()}}))}renderChildren(t){var e;this.setTextData(t),t.save();const i=null===(e=this.parent)||void 0===e?void 0:e.getStyle("text-decoration").getString(),n=this.getFontSize(),{glyphInfo:A}=this,a=t.fillStyle;"underline"===i&&t.beginPath(),A.forEach(((e,A)=>{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"===i&&(0===A&&t.moveTo(a.x,a.y+n/8),t.lineTo(r.x,r.y+n/5))})),"underline"===i&&(t.lineWidth=n/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,i,n,A,a,r,s,o){let c=a,l=this.measureText(t,s);" "===s&&"justify"===e&&i<n&&(l+=(n-i)/A),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:i}=this,n=e||this.getText();if(i.has(n))return i.get(n);const A=this.measureTargetText(t,n);return i.set(n,A),A}setTextData(t){var e,i,n;if(this.glyphInfo)return;const A=this.getText(),a=A.split(""),r=A.split(" ").length-1,s=null===(e=this.parent)||void 0===e?void 0:e.getAttribute("dx").split().map((t=>t.getPixels("x"))),o=null===(i=this.parent)||void 0===i?void 0:i.getAttribute("dy").getPixels("y"),c=this.getAttribute("text-anchor").getString("start"),l=this.getStyle("letter-spacing"),g=null===(n=this.parent)||void 0===n?void 0:n.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=A.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,i)=>0===i?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 m=this.getPathLength(),E=this.getAttribute("startOffset").getNumber(0)*m;let f=0;"middle"!==c&&"center"!==c||(f=-p/2),"end"!==c&&"right"!==c||(f=-p),f+=E,a.forEach(((e,i)=>{const{offset:n,segment:A,rotation:s}=this.findSegmentToFitChar(t,c,p,m,r,f,o,e,i);f=n,A.p0&&A.p1&&this.glyphInfo.push({text:a[i],p0:A.p0,p1:A.p1,rotation:s})}))}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:i}=t;for(i.reset();!i.isEnd();){const{current:t}=i,n=t?t.x:0,A=t?t.y:0,a=i.next();let r=a.type,s=[];switch(a.type){case Lt.MOVE_TO:this.pathM(i,s);break;case Lt.LINE_TO:r=this.pathL(i,s);break;case Lt.HORIZ_LINE_TO:r=this.pathH(i,s);break;case Lt.VERT_LINE_TO:r=this.pathV(i,s);break;case Lt.CURVE_TO:this.pathC(i,s);break;case Lt.SMOOTH_CURVE_TO:r=this.pathS(i,s);break;case Lt.QUAD_TO:this.pathQ(i,s);break;case Lt.SMOOTH_QUAD_TO:r=this.pathT(i,s);break;case Lt.ARC:s=this.pathA(i);break;case Lt.CLOSE_PATH:jt.pathZ(i)}a.type!==Lt.CLOSE_PATH?e.push({type:r,points:s,start:{x:n,y:A},pathLength:this.calcLength(n,A,r,s)}):e.push({type:Lt.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:i,y:n}=jt.pathM(t).point;e.push(i,n)}pathL(t,e){const{x:i,y:n}=jt.pathL(t).point;return e.push(i,n),Lt.LINE_TO}pathH(t,e){const{x:i,y:n}=jt.pathH(t).point;return e.push(i,n),Lt.LINE_TO}pathV(t,e){const{x:i,y:n}=jt.pathV(t).point;return e.push(i,n),Lt.LINE_TO}pathC(t,e){const{point:i,controlPoint:n,currentPoint:A}=jt.pathC(t);e.push(i.x,i.y,n.x,n.y,A.x,A.y)}pathS(t,e){const{point:i,controlPoint:n,currentPoint:A}=jt.pathS(t);return e.push(i.x,i.y,n.x,n.y,A.x,A.y),Lt.CURVE_TO}pathQ(t,e){const{controlPoint:i,currentPoint:n}=jt.pathQ(t);e.push(i.x,i.y,n.x,n.y)}pathT(t,e){const{controlPoint:i,currentPoint:n}=jt.pathT(t);return e.push(i.x,i.y,n.x,n.y),Lt.QUAD_TO}pathA(t){let{rX:e,rY:i,sweepFlag:n,xAxisRotation:A,centp:a,a1:r,ad:s}=jt.pathA(t);return 0===n&&s>0&&(s-=2*Math.PI),1===n&&s<0&&(s+=2*Math.PI),[a.x,a.y,e,i,r,s,A,n]}calcLength(t,e,i,n){let A=0,a=null,r=null,s=0;switch(i){case Lt.LINE_TO:return this.getLineLength(t,e,n[0],n[1]);case Lt.CURVE_TO:for(A=0,a=this.getPointOnCubicBezier(0,t,e,n[0],n[1],n[2],n[3],n[4],n[5]),s=.01;s<=1;s+=.01)r=this.getPointOnCubicBezier(s,t,e,n[0],n[1],n[2],n[3],n[4],n[5]),A+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return A;case Lt.QUAD_TO:for(A=0,a=this.getPointOnQuadraticBezier(0,t,e,n[0],n[1],n[2],n[3]),s=.01;s<=1;s+=.01)r=this.getPointOnQuadraticBezier(s,t,e,n[0],n[1],n[2],n[3]),A+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return A;case Lt.ARC:{A=0;const t=n[4],e=n[5],i=n[4]+e;let o=Math.PI/180;if(Math.abs(t-i)<o&&(o=Math.abs(t-i)),a=this.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],t,0),e<0)for(s=t-o;s>i;s-=o)r=this.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],s,0),A+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;else for(s=t+o;s<i;s+=o)r=this.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],s,0),A+=this.getLineLength(a.x,a.y,r.x,r.y),a=r;return r=this.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],i,0),A+=this.getLineLength(a.x,a.y,r.x,r.y),A}}return 0}getPointOnLine(t,e,i,n,A){let a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:i;const s=(A-i)/(n-e+L);let o=Math.sqrt(t*t/(1+s*s));n<e&&(o*=-1);let c=s*o,l=null;if(n===e)l={x:a,y:r+c};else if((r-i)/(a-e+L)===s)l={x:a+o,y:r+c};else{let g=0,h=0;const d=this.getLineLength(e,i,n,A);if(d<L)return null;let u=(a-e)*(n-e)+(r-i)*(A-i);u/=d*d,g=e+u*(n-e),h=i+u*(A-i);const w=this.getLineLength(a,r,g,h),B=Math.sqrt(t*t-w*w);o=Math.sqrt(B*B/(1+s*s)),n<e&&(o*=-1),c=s*o,l={x:g+o,y:h+c}}return l}getPointOnPath(t){const e=this.getPathLength();let i=0,n=null;if(t<-5e-5||t-5e-5>e)return null;const{dataArray:A}=this;for(const e of A){if(e&&(e.pathLength<5e-5||i+e.pathLength+5e-5<t)){i+=e.pathLength;continue}const A=t-i;let a=0;switch(e.type){case Lt.LINE_TO:n=this.getPointOnLine(A,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],i=e.points[5],r=e.points[4]+i;if(a=t+A/e.pathLength*i,i<0&&a<r||i>=0&&a>r)break;n=this.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],a,e.points[6]);break}case Lt.CURVE_TO:a=A/e.pathLength,a>1&&(a=1),n=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=A/e.pathLength,a>1&&(a=1),n=this.getPointOnQuadraticBezier(a,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}if(n)return n;break}return null}getLineLength(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-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,i,n,A,a,r,s,o){return{x:s*K(t)+a*W(t)+n*X(t)+e*q(t),y:o*K(t)+r*W(t)+A*X(t)+i*q(t)}}getPointOnQuadraticBezier(t,e,i,n,A,a,r){return{x:a*Z(t)+n*$(t)+e*_(t),y:r*Z(t)+A*$(t)+i*_(t)}}getPointOnEllipticalArc(t,e,i,n,A,a){const r=Math.cos(a),s=Math.sin(a),o=i*Math.cos(A),c=n*Math.sin(A);return{x:t+(o*r-c*s),y:e+(o*s+c*r)}}buildEquidistantCache(t,e){const i=this.getPathLength(),n=e||.25,A=t||i/100;if(!this.equidistantCache||this.equidistantCache.step!==A||this.equidistantCache.precision!==n){this.equidistantCache={step:A,precision:n,points:[]};let t=0;for(let e=0;e<=i;e+=n){const i=this.getPointOnPath(e),a=this.getPointOnPath(e+n);i&&a&&(t+=this.getLineLength(i.x,i.y,a.x,a.y),t>=A&&(this.equidistantCache.points.push({x:i.x,y:i.y,distance:e}),t-=A))}}}getEquidistantPointOnPath(t,e,i){if(this.buildEquidistantCache(e,i),t<0||t-this.getPathLength()>5e-5)return null;const n=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[n]||null}constructor(t,e,i){super(t,e,i),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 n=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(n)}},image:class extends Rt{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),i=await e.text();this.image=i}catch(e){console.error(`Error while loading image "${t}":`,e)}this.loaded=!0}renderChildren(t){const{document:e,image:i,loaded:n}=this,A=this.getAttribute("x").getPixels("x"),a=this.getAttribute("y").getPixels("y"),r=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");if(n&&i&&r&&s){if(t.save(),t.translate(A,a),"string"==typeof i){const n=e.pith.forkString(t,i,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:r,scaleHeight:s}),{documentElement:A}=n.document;A&&(A.parent=this),n.resize(r,s,this.getAttribute("preserveAspectRatio").getString()),n.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r,desiredWidth:i.width,height:s,desiredHeight:i.height}),this.loaded&&("complete"in i&&!i.complete||t.drawImage(i,0,0));t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),i=this.getStyle("width").getPixels("x"),n=this.getStyle("height").getPixels("y");return new kt(t,e,t+i,e+n)}constructor(t,e,i){super(t,e,i),he(this,"type","image"),he(this,"loaded",!1),he(this,"image",void 0);const n=this.getHrefAttribute().getString();if(!n)return;const A=n.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(n);t.images.push(this),A?this.loadSvg(n):this.loadImage(n)}},g:Zt,symbol:class extends Rt{render(t){}constructor(...t){var e,i,n;super(...t),n="symbol",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},style:pe,use:class extends Rt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),i=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),i.hasValue()&&t.translate(0,i.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:i}=this;if(i){let n=i;if("symbol"===i.type&&(n=new Kt(e),n.attributes.viewBox=new et(e,"viewBox",i.getAttribute("viewBox").getString()),n.attributes.preserveAspectRatio=new et(e,"preserveAspectRatio",i.getAttribute("preserveAspectRatio").getString()),n.attributes.overflow=new et(e,"overflow",i.getAttribute("overflow").getString()),n.children=i.children,i.styles.opacity=new et(e,"opacity",this.calculateOpacity())),"svg"===n.type){const t=this.getStyle("width",!1,!0),i=this.getStyle("height",!1,!0);t.hasValue()&&(n.attributes.width=new et(e,"width",t.getString())),i.hasValue()&&(n.attributes.height=new et(e,"height",i.getString()))}const A=n.parent;n.parent=this,n.render(t),n.parent=A}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?Dt.fromElement(t,e):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...t){super(...t),me(this,"type","use"),me(this,"cachedElement",void 0)}},mask:xe,clipPath:class extends vt{apply(t){const{document:e}=this,i=Reflect.getPrototypeOf(t),{beginPath:n,closePath:A}=t;i&&(i.beginPath=ve,i.closePath=ve),Reflect.apply(n,t,[]),this.children.forEach((n=>{if(!("path"in n))return;let a="elementTransform"in n?n.elementTransform():null;a||(a=Dt.fromElement(e,n)),a&&a.apply(t),n.path(t),i&&(i.closePath=A),a&&a.unapply(t)})),Reflect.apply(A,t,[]),t.clip(),i&&(i.beginPath=n,i.closePath=A)}render(t){}constructor(...t){var e,i,n;super(...t),n="clipPath",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},filter:Fe,feDropShadow:class extends vt{apply(t,e,i,n,A){}constructor(t,e,i){var n,A,a;super(t,e,i),a="feDropShadow",(A="type")in(n=this)?Object.defineProperty(n,A,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[A]=a,this.addStylesFromStyleDefinition()}},feMorphology:class extends vt{apply(t,e,i,n,A){}constructor(...t){var e,i,n;super(...t),n="feMorphology",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},feComposite:class extends vt{apply(t,e,i,n,A){}constructor(...t){var e,i,n;super(...t),n="feComposite",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},feColorMatrix:Ie,feGaussianBlur:Se,title:class extends vt{constructor(...t){var e,i,n;super(...t),n="title",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}},desc:class extends vt{constructor(...t){var e,i,n;super(...t),n="desc",(i="type")in(e=this)?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n}}};function Ye(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Ne{bindCreateImage(t,e){return"boolean"==typeof e?(i,n)=>t(i,"boolean"==typeof n?n: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(/^[^:]+:/,""),i=Ne.elementTypes[e];return i?new i(this,t):new Mt(this,t)}createTextNode(t){return new Ot(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=12,emSize:i=12,createCanvas:n=Ne.createCanvas,createImage:A=Ne.createImage,anonymousCrossOrigin:a}={}){Ye(this,"pith",void 0),Ye(this,"rootEmSize",void 0),Ye(this,"documentElement",void 0),Ye(this,"screen",void 0),Ye(this,"createCanvas",void 0),Ye(this,"createImage",void 0),Ye(this,"definitions",void 0),Ye(this,"styles",void 0),Ye(this,"stylesSpecificity",void 0),Ye(this,"images",void 0),Ye(this,"fonts",void 0),Ye(this,"emSizeStack",void 0),Ye(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=i,this.createCanvas=n,this.createImage=this.bindCreateImage(A,a),this.screen.wait((()=>this.isImagesLoaded())),this.screen.wait((()=>this.isFontsLoaded()))}}function ke(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Ye(Ne,"createCanvas",(function(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i})),Ye(Ne,"createImage",(async function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=document.createElement("img");return e&&(i.crossOrigin="Anonymous"),new Promise(((e,n)=>{i.onload=()=>{e(i)},i.onerror=(t,e,i,A,a)=>{n(a)},i.src=t}))})),Ye(Ne,"elementTypes",Pe);class Re{static async from(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new Bt(i),A=await n.parse(e);return new Re(t,A,i)}static fromString(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=new Bt(i).parseFromString(e);return new Re(t,n,i)}fork(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Re.from(t,e,{...this.options,...i})}forkString(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Re.fromString(t,e,{...this.options,...i})}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:i,options:n}=this;i.start(e,{enableRedraw:!0,...n,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,i)}constructor(t,e,i={}){ke(this,"parser",void 0),ke(this,"screen",void 0),ke(this,"document",void 0),ke(this,"documentElement",void 0),ke(this,"options",void 0),this.parser=new Bt(i),this.screen=new ht(t,i),this.options=i;const n=new Ne(this,i),A=n.createDocumentElement(e);this.document=n,this.documentElement=A}}function He(t,e,i,n){Object.defineProperty(t,e,{get:i,set:n,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",(()=>$n)),He(Ge,"UpdateWorkflowStateCommand",(()=>_n)),He(Ge,"MoveCommand",(()=>tA)),He(Ge,"RotateCommand",(()=>eA)),He(Ge,"ResizeCommand",(()=>iA)),He(Ge,"GroupCommand",(()=>nA)),He(Ge,"CreateLayoutCommand",(()=>AA)),He(Ge,"ClearLayoutCommand",(()=>aA)),He(Ge,"CreateElementCommand",(()=>rA)),He(Ge,"DeleteElementCommand",(()=>sA)),He(Ge,"CloneElementCommand",(()=>oA)),He(Ge,"FontColorCommand",(()=>cA)),He(Ge,"FontImageFillCommand",(()=>lA)),He(Ge,"FontSizeCommand",(()=>gA)),He(Ge,"FontAlgorithmCommand",(()=>hA)),He(Ge,"FontSourceCommand",(()=>dA)),He(Ge,"FontAlignmentCommand",(()=>uA)),He(Ge,"UpdateFramePattern",(()=>wA)),He(Ge,"TextChangeCommand",(()=>BA)),He(Ge,"IllustrationColorCommand",(()=>pA)),He(Ge,"IllustrationCacheCommand",(()=>mA)),He(Ge,"BringToFrontCommand",(()=>EA)),He(Ge,"BringToBackCommand",(()=>fA)),He(Ge,"BringForwardCommand",(()=>CA)),He(Ge,"SendBackwardsCommand",(()=>QA)),He(Ge,"LayerCommand",(()=>yA)),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",(()=>Kn)),He(Oe,"findElement",(()=>Wn)),He(Oe,"findLayoutForElement",(()=>Xn)),He(Oe,"updatedLayoutForElement",(()=>qn)),He(Oe,"rehydrateSerializedLayout",(()=>Zn));var Je={};He(Je,"CommandContext",(()=>Ln)),He(Je,"getSvgElement",(()=>jn)),He(Je,"elementFactory",(()=>zn)),He(Je,"sortElementsByLayersWithIndex",(()=>Vn)),He({},"SVGLayout",(()=>gi));var Le={};let ze;var je;let Ve;var Ke;let We;var Xe;let qe;var Ze;let $e;var _e;let ti,ei;var ii;let ni;var Ai;let ai;var ri;let si;var oi;let ci;var li;He(Le,"LayoutElementType",(()=>ze)),He(Le,"LayoutRenderingPurpose",(()=>Ve)),He(Le,"TextAlgorithm",(()=>We)),He(Le,"UnitOfMeasurement",(()=>qe)),He(Le,"ScaleAxis",(()=>$e)),He(Le,"AspectConditionAction",(()=>ti)),He(Le,"AspectType",(()=>ei)),He(Le,"MaterialEffectMode",(()=>ni)),He(Le,"AssetType",(()=>ai)),He(Le,"StepType",(()=>si)),He(Le,"StepAspectType",(()=>ci)),(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",(ti||(ti={})).Show="Show",(ii=ei||(ei={})).FileUpload="FileUpload",ii.Option="Option",ii.Text="Text",(Ai=ni||(ni={})).None="None",Ai.RemoveWhenSelected="RemoveWhenSelected",Ai.ApplyWhenSelected="ApplyWhenSelected",(ri=ai||(ai={})).Font="Font",ri.Frame="Frame",ri.Illustration="Illustration",ri.Image="Image",ri.Model="Model",ri.Material="Material",ri.Color="Color",ri.QuestionnaireCollateral="QuestionnaireCollateral",ri.RequestCollateral="RequestCollateral",ri.SignupCollateral="SignupCollateral",ri.Video="Video",ri.ColorProfile="ColorProfile",(oi=si||(si={})).Information="Information",oi.Bulk="Bulk",oi.DigitalContent="DigitalContent",oi.Finish="Finish",oi.Frame="Frame",oi.Illustration="Illustration",oi.Introduction="Introduction",oi.Material="Material",oi.Model="Model",oi.Module="Module",oi.Picture="Picture",oi.Photo="Photo",oi.ProductOverlay="ProductOverlay",oi.Question="Question",oi.Shape="Shape",oi.SilentIllustration="SilentIllustration",oi.Text="Text",(li=ci||(ci={})).Color="Color",li.Colors="Colors",li.Selection="Selection",li.Selections="Selections",li.Text="Text",li.Upload="Upload";const gi=({backgroundColor:t,outlineColor:e,borderRadius:n,configuration:A,elements:a,height:r,maxHeight:s,maxWidth:o,outlineArea:c,position:l,preserveAspectRatio:g,viewBox:h,width:d})=>{const u=n||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}`,m=Te(),E=A.purpose===Ve.FreeDesign&&(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"viewboxClip",children:(0,i.jsx)("rect",{width:B.width,height:B.height,rx:u})})}),f=A.colorProfiles?.map(((t,e)=>(0,i.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),C=Vn(a.map((t=>({...t,_renderingConfiguration:A,mask:c?`url(#viewmask-${m})`:void 0}))));return(0,i.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:[f,E,!!t&&(0,i.jsx)("rect",{id:"layout-background",width:B.width,height:B.height,fill:t,rx:u}),(0,i.jsx)("g",{id:"element-group",clipPath:A.purpose===Ve.FreeDesign?"url(#viewboxClip)":void 0,children:C.map((t=>zn(t))).filter((t=>!!t))}),c&&(0,i.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,i.jsxs)("mask",{id:`viewmask-${m}`,children:[(0,i.jsx)("rect",{x:B.x,y:B.y,width:B.width,height:B.height,fill:"black"}),(0,i.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};He({},"Image",(()=>bi));var hi={};He(hi,"getAxisAlignedBoundingBox",(()=>di)),He(hi,"degreesToRadians",(()=>wi)),He(hi,"findAngle",(()=>ui)),He(hi,"radiansToDegrees",(()=>Bi)),He(hi,"isCloseToValue",(()=>pi)),He(hi,"getTrueCoordinates",(()=>mi)),He(hi,"getPointOfRotation",(()=>Ei)),He(hi,"getNWPoint",(()=>fi)),He(hi,"getNEPoint",(()=>Ci)),He(hi,"getSWPoint",(()=>Qi)),He(hi,"getSEPoint",(()=>yi)),He(hi,"turnRightClockwise",(()=>Ii)),He(hi,"currentDirection",(()=>Di)),He(hi,"getElementVertices",(()=>xi)),He(hi,"rotateAroundPoint",(()=>vi)),He(hi,"mmPerPixel",(()=>Mi)),He(hi,"cmPerPixel",(()=>Si));const di=(t,e,i,n,A)=>{const a=wi(A),r=i/2,s=n/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)),m=Math.max(Math.abs(w),Math.abs(B));return{minX:o-p,maxX:o+p,minY:c-m,maxY:c+m}},ui=(t,e,i)=>{const n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),A=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2));return Math.acos((A*A+n*n-a*a)/(2*A*n))*(180/Math.PI)},wi=t=>t*(Math.PI/180),Bi=t=>t*(180/Math.PI),pi=(t,e,i)=>Math.abs(t-e)<i,mi=(t,e,i)=>{const n=Math.sin(wi(i)),A=Math.cos(wi(i));return{x:(t.x-e.x)*A-(t.y-e.y)*n+e.x,y:(t.x-e.x)*n+(t.y-e.y)*A+e.y}},Ei=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),fi=(t,e,i,n)=>({x:t.x+e?.x*i,y:t.y+e?.y*n}),Ci=(t,e,i,n)=>({x:t.x+(e?.x+e?.width)*i,y:t.y+e?.y*n}),Qi=(t,e,i,n)=>({x:t.x+e?.x*i,y:t.y+(e?.y+e?.height)*n}),yi=(t,e,i,n)=>({x:t.x+(e?.x+e?.width)*i,y:t.y+(e?.y+e?.height)*n}),Ii=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}},Di=(t,e)=>e>45&&e<=135?Ii(t):e>135&&e<=225?Ii(Ii(t)):e>225&&e<=315?Ii(Ii(Ii(t))):t,xi=(t,e={x:0,y:0},i={x:1,y:1})=>{const n=wi(t.rotation),A={x:e.x+t.x*i.x,y:e.x+t.y*i.y},a={x:t.x+t.width,y:t.y},r={x:e.x+(t.x+t.width)*i.x,y:e.y+(t.height+t.y)*i.y},s={x:e.x+t.x*i.x,y:e.y+(t.height+t.y)*i.y},o={x:(s.x+r.x)/2,y:s.y-t.height*i.y/2};return{a:vi(A,o,n),b:vi(a,o,n),c:vi(r,o,n),d:vi(s,o,n),center:o}},vi=(t,e,i)=>{const n=Math.sin(i),A=Math.cos(i);return{x:(t.x-e.x)*A-(t.y-e.y)*n+e.x,y:(t.x-e.x)*n+(t.y-e.y)*A+e.y}},Mi=.352778,Si=.035277,bi=t=>{const e=t.rotation||0,n=wi(e),A=Math.cos(n),a=-Math.sin(n);return(0,i.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,i.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(${A}, ${-a}, ${a}, ${A}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `,children:(0,i.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};He({},"Frame",(()=>Pi));const Fi=256,Pi=t=>{const e=`spiff-frame-${t.id}`,A=`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,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsSAAALEgHS3X78AAAZL0lEQVR4nO2diVIbSRZFq/GCsZBZjRea6fn/r+oZGrMYBBhkLGwzE1cmTSqVWXuqVFXnRHREG6OlpX43X771j5O/7/+XAEAvWeFrB+gvCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAECPQQAAGuLnz5+Nf/QIAEADyPhHl+fJ5/PTRj/+53z5AItFxn9y+in5Nvn2+3Xf7r5r5FvAAwBYID7jH4/Hyfcf3xv5GhAAgAXhM/5nK8+SD+8/Ji+ev2jka0AAABZAmvGvrr5q7CsgBgAQGZ/x68R/t/e+UeNPEACAuPiM/9Xqq+T9u4/Js2fPGv/0uQIARGLZjT/BAwCIw2TyLTk9O5mJ7i+b8ScIAED9yPiPTz4lPx+eKv2W0fgTrgAA9VKn8esKcXx8NH3OWCAAADUhd981frG9tVPK+BU/+Prt6/Q5Y4kAAgBQE0rtDQaDuSdTLKCIAbvBQwnKaHQR5WtCAABqRDX9b4ZvZp5QBpz3FA9lDvb23kf5mhAAgJpJE4G0mv8m0oYIAEAEQiJwdnbinQPQVM0AAgAQCZ8IyMBl6LYIyCtoqmAIAQAoyZeb68w2XonAK6fe3xYBxQWOjg4bqxZkOzBAQW7HN9OovIxfJ3zWMA+fe588Gvr3798bLRjCAwDIiQz59Ox4psT3y82XTC9Axiyj9nkCdRq/3l/ROYMIAEAOpq76p8Pkdnw788vq6R/f3mQ+QUgEDPIk9j8eVDJ+eRnnF2eFHkcvAEAGvvJesbO1kwyHG7mN1oiA7zpQhZkrxiRJVs5Pc88YxAMASCFU2//nx4Nkc3O78Ikd8gR0lSgzIdgXX7i/v899FUAAAAL4jF+uugy4yiQfiYAq+3R9sCkqAnXUDiAAAB5kXOcXn+eMX651HRF69Q1oHmBZETAxiarpQwQAwMP19eWMceVJ9xVFXkQZETCeSR3DRhAAAIe7u6/J5fXl7x/KuLa3dit9TKE7eVERqHvYCAIA4HB1dTnzg92dt5XcflUMHv7zn2A3YJoI6LGGGJOGEAAACxmZhnAY5PpXCfjJgD+fn02NdhpTKOgJ6LF6jlhjxhAAAIuxU+jzZrhR+uMxxm/wNQLZSATeefr+9Ryu8a8P1mspGUYAACzsSj9F6sue/q7xG7JEYG3tdfJ2d2/u52424t3eh1qyEQgAwCOKqtuR9bW1tVIfzdXVyGv8hiwRkNfhE4EkQjYCAQB45Mf32aaeMgs7Fbm/uHya36c7vaoG88wFsPGJQIxUJAIA8Ihb618UGb8i9wZ7+acM9/Wr1zPPWEQEYhh/ggAAPOF6AEVwjdi3+Vflv76W4NHlefCVJAIf3+9HMf4EAQB4wg34PTw85P50FJAzI8BCa7/LNgIpMBgLBAAgwN23u8IfjSoG03b+190NWBUEAOAR96SVe5417cdFBp6VOkwTgdEofB2IAQIAYOEG6pTSi4ERATfTsLKyWJNEAAAs3Nx/npl/ZXn438PMc0sMhhUqD8uAAABYTEd8OfX4WuYRA9fd394uvkS0KggAgIUMcHNjc+ZnigXUHaDT1cIuO1Zt//pguPCvAgGATqA8vN06WwWfF+C25lZBz2NXC8r1393xl/7GBgGA1mNm46n+/r+Hf1c2VHkBoa68qkFBt0lIQqPXWrTrb2AzELSa0NYdnaq6U1dxq2Xs9kltkLuuE7uI0ep9quLPLhVOpqvD9iq1HFcFAYDWEjJ+G6X1Nje3SlfTufX9Bp3cihXk2QugU19ThtxsQtPGnyAA0GYkABq1ZZp4ZJShhp4qQhASAfOag8FgWvwjr+P5ixfTngK9j/vJZBro86URl8H4EwQA2o5rnDKsm5svQa+grBCErgNFkUjozl9lzFidIADQanS6KvBnkIF/+LA/Ndir66tUj2D37V6hnn/N5dNcv7JrvdQopF6BpgJ+PhAAaD2uF6D2WZ3wuiLcOCk3FxmlVnwVEYLQnT6EgoZy92N29ZUFAYDWE/ICDPp7eQShe3xSUgjkEWiI6GQySSb3k9/exq9ZgqvJ6svVZLA+LDVZaFEgANAJjo+PZsZ5Gy/AJpYQtBkEADqBtvl8Ojn6/Z+iVlvt2/eRRwiKrv5uKwgAdIY8XoCNREN3efsxNkVy/W2FUmDoDErv2bgrvlwkDooVuDMADLrTK4CoWgN5DHl37rcJBAA6gwzavrvrZNcpn4YyCCEPwNBlIUAAoFO4XkBaY5CbPlTc4F8H/062Nra8v28LQV2dgU2DAMBSYRZhlkX5dtsLCJXi+ozfjOja3t6dCoG7zMMgITCdh7fjm1b/D4QAwNJgWmW1CDPLdU9jPhbw1MIr9/3o06HX+O1An4RAY77ThEBjw9ueLkQAYCnQiWz65HXCKqVX1s0evF6fGehh5vr5ugezVmyHhCA0+79tkAaExknrtivbNec278h47+/vZ4y/TF+/PBMJ0+bGVuuNXzxfgvcAEERewcPPn9PqvCIod283A7kCU3bXnjINy1jTXxauANA4rnG7CzN0khcdyqlTPXR3j7Vos40gANA4umfbxTgrf6zMGW+Z1VnDN/NXB7n9GP8TCAAsBcM3TwavwhzN8vOJwOnZce5CHAlLyAuAXyAAsBTI4O2Umsp4zbZdG+X103bqu7jXi1BdQF9BAGBpsPP38gJUEOQTAUXy84qAREVuv02sfX9tBAGApWE+f/+rDiBNBPJUDbppxJj7/toGAgBLgxu5tw01JAKqGswSAaXtFrX1t20gALBUuJF721B9IqA8fx4RmG8SwgtIEABYNtzIvWuoEgFN67ExIpBWOiwvwK0vuPnSjY6+KiAAsHS467zGt7Mdd4rsq0TYxnTopYnA0JNW7OKQjyIgALB0uKf1tKTXMVQF9lwRSB5Lh0Mi4LYKSzRuOtLXXxYEAGpDRqpqvSqtvAb7tA4ZqhEBd5W3RGA0Ovc+rxsLUEtvn0EAoBYUhDN99mrl1YDOKkLgntahbkH9ntpyXRG4vL70lg6/sXb/Tzf1bO/2+n8ABAAqM3lMx9nBOhXyVBUCOxio5w659mrL9YlAqH9Ak35pCPoF8wCgEjLMo6PD4A4+Q5mlnO72X3fjj4sRIve96HF7e+9/9/3rebs+7z8veABQCbnpa2trM0+hk9gdlVXGI5CRavW2/Rxp+X55Agd//jWX7tPj7NJhjP8JBAAqo6k6ttHpBJYouPn6pIQQuM08WWPCZNwa8eWKQJH+gT6BAEBlZHRTF9uZw6cIu2bp+RZv5BWCrMIgHyERUGaB038WBABqQYaqQJyNIvEybt3btabLN0E3jxC4XoBbGOTDiIDEQ8Kk1y8zW7DrEASEWjGjvW3swZ76+9HoIhg0lLew+3ZvTizswaEyaN31857miht0YYBnDPAAIBd5784ydHezjgzeBO/09zJexQfctF3y6BFo4YYM3nb1bS9A4jH+epv7i8P4wyAAkIkp8sm7sUfFNfYQDrdjTye3DDpNCHTaK71odvG5sYCsxZ+QDwQAUrGLfPK03Rp8mYHzi88znoQRgv39A+/sPrOLT+KjFVy2F6D30/a1XMsAMQAI4ivyKbIRx/d4icL+x4Pg7+vED5X9Kj6w8mxlOtcvyVEYBNngAUAQud12IU5SYABHEsgMKB8fGu+dtY9P8QFj/EmOwiDIBgGAVKpM4UkeA3Bu265O+FC3XmIJwZ8fD7w1BLPPxVCPKiAAkEmaCOQZq+XLDKhGIMt4p00+jzUEISFgqEc1EADIRUgEzs5OchmgmxlIHvv283gRaiAKCcEbqvsqQRAQCuHb5Ju1YtvgW89dZs22KgZHlxfJy5cvaemtCAIAhVFa7ptzcucVgVBmIM9joX64AkBhqnTbhTIDukrA4kEAoDBVW259mQGl9Ipu/4XqIABQiqoi4MsMKLbAxp7FggBAadJEYHQZzvMbfJkBlf5S4rs4EACoREgEQgM5XdyeAXF+/pkKvwWBAEBlfBOBkpwi4HusKTKiwCc+CADUgonulxEBX2aArT2LAQGA2ig6n9/GzQyows8dBQb1QyEQ1E5oPn+eZRxqEtLjqPBbDAgARCEkAvZ8QGgeBKDjKJB2fz+Zi6o/f/EiWXv1Omr5LSKw/CAAHUW59PH4dmaAhg911w3W16MZpBp3NPbbBRFYDhCAjmE65dxmnSyUi9/deRtlgq5vVHiCCCwFCEBHkKt/fX05HbRRBU3pjRF9D4mAevyLLAyFennO59l+1GKrbjrfqa+TffB6dq7f5H6S3N3deZdzqBRXz1d3FN6c9LYIKCuA8TcLAtByfIE25eG1A3+wPvSu4zLoVNZ8fXeslxn4EVME2M+/HHAFaDE+4w+t1gqhq4Mad3yjuGMZqeIUnPzLAQLQUnzGX+X+TqCun1AK3EJ8xi9DrRK8k5G7QzqSx71+eSb/QjtBAFpGyPjrOKV9IjBd6fV53jOAboAAtAjd12MZv0HP5Y7/1riu0O5+aDcIQEswI7Vt45ehxrifb2/tzgUR2cbbTRCAlqBIvZvnXx8Mo7z5X1t7Z+f1yQsgFtA9EIAWc3p2Em10ljwL1wsY3zKrr2sgAC2h6pLOMrivpwpC6BYIQIuouqSzKG6xzo8fP/r3oXccBKBlVF3SWQS3M7BohyEsPwhAC/GJQN6FHEXJW1IM7QQBaCkSgbJbeYrw8PDw+7fdYZ/QfhCAFlNlNVde7LqD1Zerff/IOwcC0GKq7ufLws0urK2t9f0j7xwIQMuJKQJu+S8tvN0DAWgAGeWXGrfeVF3SGcKeEaBgYIx5gdAsCMCCMTX96r3/7+HftQlB1SWdLnpfdm2BWxoM3QABWCDG+E0+XQZmhKCOldhVlnTaTKcEjS5+/0SnP0NBugkCsCBc47eREKiu//j4qHLbbZUlnYbzi7O5lmPoJgjAAvn+/cml9uXU1XGnJRpVhaDKkk79vb1MZGtji+Bfh0EAFoTc88HgaTz3rwWYe3N39qQmISgjArr324E/vbeNDe7+XQYBWCDuzL7x7W2y//FgOswzyyMo0+yTJgJu8FFbee2hoHrMNJ4QcXcgNA9TgReMTl/7lDWbcRQjuLm5ni7mCGF25hetz89a0um+Jxm/hIO0X/dBABaMTnJF/Q2a4//hw/7vP+vvr65G3jn9hjJCEFrSqeewvQuMv18gAA0gl17uvcG3Hy+GEIRm/xsw/v6BADSAexor2KZYgI88QqAYwnC4keu+HhKBmNuBYXlBABoijxdgI9HQZF77MTZmH2AeIXBFQMavKkICfv2DLEBDuKW1WWO3JQ6KFShm4EMBPgUQD//5z9RjSGsCsheA6BqB8fcXtgM3hAzaDsCZ5RtpXoCi9SEPwGCE4Or6KtUjMFN/KfLpN3gADeJ6AWmNQW6qTm77vw7+Pa3U82F7BKHnxfiBGEDDKCVop+Fk1G5U32f8ttueJ1Co59ze3om2TATaCR5Aw8zHAka//133+KNPh6nGnzwat2YESjzcYaEGzfZjwCe4IAANM3i9PlOqK2PXie7rHsyK1oeEgPw+hOAKsATo1LdLgGW89/f3M8a/PlhPdnf2CkXrFVTU/X9zYwvjBy8IQAl0Qqu+/sf32Qad5y9eJGuvXhdOqem0V7DOrdU3SBB0sgPUDWnAAug0VQdfVipOrvqwwOpuCYaM/PJ6vhYA44eYIAA50Gl/fvE592os/Z7+UXGPgnx5hGD4ZmNOAOT2Y/wQE4KAGejU/+fTYam9eGbm3+nZceZ47l9z9/wRfIBY4AGk4ObfDSrHdZdk3N3dBa8GGrGlv8+KxKuzz349PW77x3fSdxANgoAB3Mh8kqP91gz1MKk8lzzpOHkL9kw+YgAQE64AHpQ+s41fhvtu7/3UENNOYwXzJBBmzJeL2eXvrtyyceMFITEBqAMEwEGnuDsbT6d2kRJaIwRq8XXn8RkRCBm16vPdjj+7OhCgThAAhxt3I87GZukiGhnzwZ9/zU3+lQicnZ0EHzffJIQXAHFAABzcunt3km9R0vb2hU52CYf7+zdf6tslCGBAACy0nss+aYc1peVCK7sUZwid7O5rS5jq2vkPYEAALNzSXjXq1IWCh7u7b+eeLeQFmIEdBl0bbmrcKAyQIACzKFdvU/eYLAUS3WKftPu9GwtQSy9AnSAAAUKz96riiymMb/2bgeUFmGuDhGN7ezfmfzL0EATAwq7ky2r4KYuv5Hf8dRx8NmUhKAaCWCAAFnPpukhBN7fYJ63PYDid4IvxQxwQAIuVP2Y/jrtIXoDqCtyKwlB1IOO6ISYIgMXq6urMn6vs6M/CFQACfNAECIDFS0cAYube3W5CgCZAACzWPJF/cu/QZRAACzOay0bVemnde2WZ3E9mHsmSDmgCBMDBl6fXOLC6rwKTyZMAuNkHgEWBADj48vRK040uz2t7DXkUdvXf2iviAdAMCICH7a3ducYdBQQ1IqwO3F19GggK0ASdEYA6XXTFAnyNO3WIwK9lHU8tx/I2mPkHTdEJAZBLrR16dQbr1Ljj27wr480z5deH3t+pNQhEXkbVeQMAVWi9AMiozIitrHl7RVHzjW9Ut4Z2pq3d9qFZA3p/9vYfbevl9IcmafVUYBn90dHhjFHFWIQZGg+eWEHDwfrQa8wy/JsvX+aai2jwgWWg9WPBfcYZQwR8Y8JdJAC2CCjX79v3h/HDstCJvQCLEgEF8DQxuOyATr0nuf15dwYCxKYzi0FCIrC/f1D7PVvewNX1VXCbrw8NGNl9u8edH5aKTm0G8omAquw0lbfutlplAcZfb6degUaJ+cRAxq4Fn4PBOvv5YSnp3GqwRYqAja4F9lDRly9X6eWHpaeTuwGPPNt8FyECAG2jNXUAcrnlbucJwIUWcZycfmK2PoDFUnsAMnZtxFHhjW34Cu4NBoPMTb0y+JiegF4DjwLazFIKgAzr+voyuby+zPxdleuGxmXHFAHz3NrgQ1oP2srSXQEmj656HuMX+r1Qg07aXr4q7b22sKguoEhJMMAysVQCYOr63RNbbr7y6PrHbdNNMrr0QiJQtrPP51XcsLcPWsrSXAF0itp7+ZPH4hmtx3LHZel3R6OLudz7u733wT3+vr6BpGBZrs/4yS5Am1kKD0ANM67x72ztJB8+7Htn5enOrTJf1xuQKISQF+F7TF5PwLQcY/zQJRoXABnW+fnnmZ+93d3L7JNXZZ0M2kanfNp93DymqAjYLccGjB+6QKMCYAzLdstl/Hmj6jJot18/ax5AURHwvUeMH7pCYwKg+/R02q5lWHL7i6bU3N//8f1H5mPSRMD2IDB+6DqNCcD5xdlctL/MbPyyTTYhETBpPYwf+kBjArCyMv/SdY/0ykIioMyBi0TANX519WH80DUaEwCl3tz7uwyuqAi4vQFFd+7J61DcwcU2fr3Pd3sfMH7oHI0GAdNEIO/UHXeDb5krwZvpDv55EUgY3wUdp/E0YEgEzs5OMqvr9PdXV08lw8r1l92x5xMBjB+6TnQByLNj3ycCedp3Vc9vewqqGqyCLQIYP/SBqAKgvPqnk6NczTIytiI9/HpOe/KPyobr6MrTc3x8v4/xQy+IJgD2aK68HXN5B3m4fQNK5WngZl2wqhv6QhQBcPffJY8ikHUdSGvflQjI3ZewuMavfD7TdgGKE60bcDQ6n+vpzzurPzTIwyXG7H+APhHtCuDbq5c3zx/yBGZ+B+MHqEzUIGCVYp80EZDxH/z5F8YPUJHoacCqIrC3936uXl+PrzLSCwB+sZBCoCoiUHWQBwCEWVglYJoIZFX8lR3kAQDpLLQU2FfsIxHIs7ADEQCon4X3AlTZ2pN3kAcA5GPhApBV7FNWBJjPD1Cc3AJQ59z7OkQgNMgDEQDITy4BMCOx65zWkyYCagXOIjTIAxEAyE+mANgjsese2RUSga/fvuYK7IUGeeTpOwCADAEwRm/GY5UZ2ZVFqNhHgT0tDMkiNMiDjj6AbFIFQEU4WsNtE0MEQsU+WhiSJ/bAIA+AcuTqBrR7+w0xmnHktmuAiE3a+m/f4zn5AfKTKwhYx/DOPMh4tRzERi3FeTMQGD9AMXKnASUCmo1vk3d4ZxGGw4254R7jr7d8rQARKFQItLuzVzp3nxcFBV1vg4g+QBwKCUDVAp68DJ3hnpPJhK8fIAKFS4EXIQJ6DfsaUGecAQCeKNULsAgRYMgnQHxKNwPFFgH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC";if(!s())return(0,i.jsx)(b(n).Fragment,{});const o=!!t.focalBlur&&!!t.pattern,c=t.rotation||0,l=wi(c),g=Math.cos(l),h=-Math.sin(l);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("defs",{children:(n=>{const o=t.pattern?.x||0,c=t.pattern?.y||0,l=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(o):0,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(c):0,h=t.dataWidth||l||Fi,d=t.dataHeight||g||256,u=t.pattern?t.pattern.width*t.pattern.scaleX:Fi,w=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,i.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,i.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:Fi,height:t.pattern?1:Fi,"data-frame-width":t.pattern?h:void 0,"data-frame-height":t.pattern?d:void 0,id:e,children:(0,i.jsx)("image",{preserveAspectRatio:"none",x:o,y:c,width:u,height:w,xlinkHref:s()})}),n?(0,i.jsx)(Yi,{path:t.path,width:t.width,height:t.height,focalBlurStrength:t.focalBlurStrength||1,focalBlurRadius:t.focalBlurRadius||10,blurFilterId:A,focalMaskId:r,blurEdgeClipId:a}):null]})})(o)}),(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.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,i.jsx)("path",{filter:o?`url(#${A})`:void 0,mask:o?`url(#${a})`:void 0,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}),o?(0,i.jsx)("path",{mask:`url(#${r})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},Yi=t=>{const{path:e,width:n,height:A,focalBlurStrength:a,focalBlurRadius:r,blurFilterId:s,focalMaskId:o,blurEdgeClipId:c}=t;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("filter",{id:s,children:(0,i.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,i.jsx)("mask",{id:o,children:(0,i.jsx)("circle",{cx:n/2,cy:A/2,r:r||0,fill:"white",filter:`url(#${s})`})}),(0,i.jsx)("mask",{id:c,children:(0,i.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};He({},"Textbox",(()=>Yn));var Ni={};He(Ni,"fontSizeStep",(()=>mn)),He(Ni,"textWidth",(()=>En)),He(Ni,"charWidth",(()=>fn)),He(Ni,"lineWidth",(()=>Cn)),He(Ni,"applyTextTransformations",(()=>yn)),He(Ni,"zip",(()=>In)),He(Ni,"getTextAlignment",(()=>Dn)),He(Ni,"getAnchor",(()=>xn)),He(Ni,"recomputeTextOnElement",(()=>vn)),He(Ni,"defaultLineHeightFactor",(()=>Mn));var ki={};He(ki,"refitTextbox",(()=>Bn)),He(ki,"recalculateTextboxRegion",(()=>pn));var Ri={};He(Ri,"FontMetrics",(()=>sn)),He(Ri,"loadFontFromExternalUrl",(()=>on)),He(Ri,"getFontMetrics",(()=>ln)),He(Ri,"loadFontFromDataUrl",(()=>cn));var Hi={};He(Hi,"registerJSDOM",(()=>Oi)),He(Hi,"createElement",(()=>ji)),He(Hi,"createElementNS",(()=>Vi)),He(Hi,"domParser",(()=>Ki)),He(Hi,"fetchAsArrayBuffer",(()=>Wi)),He(Hi,"fetchAsString",(()=>Xi)),He(Hi,"loadFontFaceSet",(()=>qi)),He(Hi,"xmlSerializer",(()=>Zi)),He(Hi,"toBase64",(()=>$i)),He(Hi,"dataUrlFromExternalUrl",(()=>_i)),He(Hi,"arrayBufferToDataUrl",(()=>tn)),He(Hi,"arrayBufferToBuffer",(()=>nn)),He(Hi,"dataUrlToArrayBuffer",(()=>en));var Ui=a.Buffer;let Gi;const Ti=new Map;function Oi(t){Gi=t}function Ji(){if(!Gi)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new Gi}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 Li=new(b(s).Agent)({rejectUnauthorized:!("local"===Ue.process?.env?.ENVIRONMENT)}),zi=t=>t.every((t=>"undefined"!==t)),ji=t=>zi([typeof document])?document.createElement(t):Ji().window.document.createElement(t),Vi=(t,e)=>{if(zi([typeof document]))return document.createElementNS(t,e);const i=Ji().window.document.createElement(e);return i.setAttribute("xmlns",t),i},Ki=()=>zi([typeof DOMParser])?new DOMParser:new(Ji().window.DOMParser),Wi=t=>{if(zi([typeof fetch]))return new Promise(((e,i)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{i(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,i)=>{b(r).get(e,{responseType:"arraybuffer",httpsAgent:Li}).then((e=>{t(e.data)})).catch((t=>{i(t)}))}))}},Xi=t=>{if(zi([typeof fetch]))return new Promise(((e,i)=>{fetch(t).then((t=>{e(t.text())})).catch(i)}));{const e=t.replace("localhost","localstack");return new Promise(((t,i)=>{b(r).get(e,{responseType:"text",httpsAgent:Li}).then((e=>{t(e.data)})).catch(i)}))}},qi=async(t,e)=>{if(zi([typeof FontFace])){const i=t.names.fullName.en,n=new FontFace(i,`url(${e})`);return document.fonts.add(n),n.load()}},Zi=()=>zi([typeof XMLSerializer])?new XMLSerializer:new(Ji().window.XMLSerializer),$i=t=>zi([typeof btoa])?btoa(t):Ui.from(t).toString("base64"),_i=async t=>{if(zi([typeof fetch,typeof Blob,typeof FileReader])){const e=await(async t=>{const e=Ti.get(t);if(e)return e;const i=(await fetch(t)).blob();return Ti.set(t,i),i})(t);return await an(e)}const e=(await b(r).get(t,{responseType:"arraybuffer"})).data;return tn(e)},tn=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,${nn(t).toString("base64")}`},en=t=>{const e=t.replace(/\r?\n/g,""),i=e.indexOf(",");if(-1===i||i<=4)throw new TypeError("malformed data: URI");const n=e.substring(5,i).split(";");let A=!1;for(let t=1;t<n.length;t++)"base64"===n[t]&&(A=!0);const a=A?"base64":"ascii",r=unescape(e.substring(i+1)),s=Ui.from(r,a);return An(s)},nn=t=>Ui.from(t),An=t=>{const e=new ArrayBuffer(t.byteLength),i=new Uint8Array(e);for(let e=0;e<t.length;++e)i[e]=t[e];return e},an=t=>new Promise(((e,i)=>{const n=new FileReader;n.onload=function(t){const n=t.target;n&&n.result?e(n.result.toString()):i()},n.readAsDataURL(t)})),rn=new Map;class sn{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 i=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,i),i}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let i=0,n=0;return e.forEach((t=>{const e=t.getMetrics();i=Math.max(i,e.yMax),n=Math.min(n,e.yMin)})),i-n}getKerningValue(t,e){let i=this.kerningValues.get(t.name);i||(i=new Map,this.kerningValues.set(t.name,i));let n=i.get(e.name);return n||(n=this.font.getKerningValue(t,e),i.set(e.name,n)),n}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,i=0;return t.forEach((t=>{const n=t.getMetrics();e=Math.max(e,n.yMax),i=Math.min(i,n.yMin)})),e-i}}const on=async t=>{try{return ln(t).getFont()}catch{const e="data:"===t.substring(0,5).toLowerCase().trim()?cn(t):cn(await _i(t));return gn(t,e),await qi(e,t),e}},cn=t=>{try{return ln(t).getFont()}catch{const e=en(t),i=b(A).parse(e);return gn(t,i),i}},ln=t=>{const e=rn.get(t);if(e)return e;throw new Error("Font metrics unavailable for font")},gn=(t,e)=>{const i=new sn(e);return rn.set(t,i),i},hn=(t,e,i,n)=>Math.max(fn(t.join("\n"),i,n),e),dn=(t,e,i,n,A,a)=>{const r=(a||Mn)*A.getApproximateHeight(),s=e.split("\n");try{const e=s.flatMap((e=>un(e,t.width,n,A))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(n*r),fontSize:i,requiredWidth:hn(a,t.width,n,A)}}catch(a){const s=e.split("");return{lines:s,requiredHeight:s.length*(n*r),fontSize:i,requiredWidth:hn(s,t.width,n,A)}}},un=(t,e,i,n)=>{const A=En(t,i,n);if(A<=e)return{lines:[t],width:A};if(!(t.indexOf(" ")>-1)){if(t.length<=1)throw new Error(`Character ${t} is wider than region`);const A=Math.floor(t.length/2),a=un(t.slice(0,A),e,i,n),r=un(t.slice(A),e,i,n);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(En(t,i,n)>e){const A=un(t,e,i,n);r.push(...A.lines),s=Math.max(s,A.width),o++}else{const A=[t];s=Math.max(s,En(t,i,n));let c=o+1,l=!0;for(;c<a.length&&l;){const t=a[c],r=En(`${A.join(" ")} ${t}`,i,n);r<=e?(A.push(t),s=Math.max(s,r),c++):l=!1}r.push(A.join(" ")),o=c}}if(s<0)throw new Error(`No max width calculated for text: ${r}.`);return{lines:r,width:s}},wn=(t,e,i,n,A,a)=>{const r=(a??Mn)*e.getApproximateHeight(),s=1/i.unitsPerEm,o=n/Cn(t,s,e),c=A/(t.length*r*s);return Math.min(c,o)},Bn=(t,e,i,n)=>{const A=ln(e.fontData.assetUrl),a=A.getFont(),r=e.fontSize/a.unitsPerEm;if(!i)return dn(e,t,e.fontSize,r,A,n);let s;if(s=e.text?e.text.split("\n"):e.input?.split("\n")??[""],i.input===t&&e.width===i.width&&e.height===i.height&&e.lineHeight===i.lineHeight)return{lines:s,requiredHeight:e.height,requiredWidth:hn(s,e.width,r,A),fontSize:e.fontSize};const o=e.width!==i.width!=(e.height!==i.height);return e.lineHeight!==i.lineHeight||o||i.input!==t?dn(e,t,e.fontSize,r,A,n):{lines:s,requiredHeight:e.height,requiredWidth:hn(s,e.width,r,A),fontSize:wn(s,A,a,e.width,e.height,n)}},pn=(t,e,i,n,A)=>{const a=ln(e.assetUrl).getFont();let r={...t},s={...t},o=Cn(n,i/a.unitsPerEm,ln(e.assetUrl));return o&&o<r.width&&(s.width=o,"left"===A?(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"===A?r.width-o:(r.width-o)/2,n&&In(n,n).every((([t,e])=>t===e))&&(r=s)),r},mn=1,En=(t,e,i)=>{let n=0;const A=i.getGlyphs(t);return A.forEach(((t,e)=>{if(t.advanceWidth&&(n+=t.advanceWidth),e<A.length-1){const a=i.getKerningValue(t,A[e+1]);n+=a}})),n*=e,n},fn=(t,e,i)=>{let n=0;const A=i.getGlyphs(t);return A.forEach(((t,e)=>{if(t.advanceWidth&&(n=Math.max(n,t.advanceWidth)),e<A.length-1){const a=i.getKerningValue(t,A[e+1]);n=Math.max(n,a)}})),n*=e,n},Cn=(t,e,i)=>{let n=0;return t.forEach((t=>{n=Math.max(n,En(t,e,i))})),n},Qn={stripControlCharacters:!0,vertical:!1,uppercase:!1},yn=(t,e=Qn)=>{const i={...Qn,...e};let n=t||"";return i.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),i.uppercase&&(n=n.toUpperCase()),i.vertical&&(n=n.split("").join("\n")),n},In=(t,e)=>t.map(((t,i)=>[t,e[i]])),Dn=(t="center",e=!1)=>e?"center":t,xn=t=>"left"===t?"start":"right"===t?"end":"middle",vn=(t,e,i)=>t.fontData?{...t,...(()=>{if(t.algorithm===We.Traditional){const n=Bn(e,t,i,t.lineHeight);return{text:n.lines.join("\n"),height:n.requiredHeight,width:n.requiredWidth,fontSize:n.fontSize,input:e}}return{text:e}})()}:t,Mn=1.1;var Sn={};He(Sn,"colorDefinitionPrintValue",(()=>bn)),He(Sn,"spotColorDefinitionString",(()=>Fn)),He(Sn,"svgColorValueToDefinition",(()=>Pn));const bn=t=>{const e=Fn(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},Fn=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),i=e.lastIndexOf("/");return`icc-named-color(${e.slice(i+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},Pn=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const i=e[1].match(/\(([^)]+)\)/gm);if(!i)throw new Error("Unhandled state of color value in SVG");const n=i[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:n[0],namedColor:n[1]}}},Yn=t=>{const e=(t.rotation||0)*Math.PI/180,n=Math.cos(e),A=-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,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("defs",{children:[t.textFillImage&&(0,i.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,i.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,i.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,i.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,i.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsx)("g",{transform:`matrix(${n}, ${-A}, ${A}, ${n}, ${s}, ${o})`,children:(0,i.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} ${Fn(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,i.jsx)(kn,{text:t.text||"",curvedPathId:a,align:t.align}):c.map(((e,n)=>(0,i.jsx)(Nn,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:n,amountLines:c.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},n)))})})})]}):null},Nn=t=>(0,i.jsx)("tspan",{textAnchor:xn(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:Mn),i=t.textboxHeight/2;if("top"===t.verticalAlign)return-i+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const n=t.amountLines-1-t.thisLineIdx;return i-t.fontSize/4-n*e}const n=(t.amountLines-1)/2;return(t.thisLineIdx-n)*e+t.fontSize/4})()}px`,children:t.text}),kn=t=>{const e=`#${t.curvedPathId}`;return(0,i.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:xn(t.align),href:e,xlinkHref:e,children:t.text})};He({},"Illustration",(()=>Jn));var Rn={};He(Rn,"traverse",(()=>Un)),He(Rn,"sanitizeSvgTree",(()=>Gn)),He(Rn,"modifySVGWithElementProperties",(()=>Tn)),He(Rn,"generateSVGWithUnknownColors",(()=>On));const Hn=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],Un=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>Un(t,e)))},Gn=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const i=[];Un(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,l.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{i.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),Un(t,(t=>{i.forEach((e=>{e.selectors?.forEach((i=>{((t,e)=>{try{return t.matches(e)}catch(i){return t.classList.contains(e.substring(1))}})(t,i)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},Tn=(t,e,i,n,A)=>{const a=(t=>Ki().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,i)=>{t.setAttribute("height",`${i}px`),t.setAttribute("width",`${e}px`)})(a,e,i),((t,e,i)=>{Un(t,(t=>{const n=t.attributes.getNamedItem("fill");n&&"none"!==n.value&&t.classList.forEach((n=>{if(n.startsWith("spiff-fill")){const A=e[n];A&&t.setAttribute("fill",i?bn(A):A.browserValue)}}));const A=t.attributes.getNamedItem("stroke");A&&"none"!==A.value&&t.classList.forEach((n=>{if(n.startsWith("spiff-stroke")){const A=e[n];A&&t.setAttribute("stroke",i?bn(A):A.browserValue)}}))}))})(a,n,A),(t=>Zi().serializeToString(t))(a)},On=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],i=e?.length>0?e[0]:"",n=Ki().parseFromString(i,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");Gn(n);const A={};Un(n,(t=>{Hn.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const i=Pn(e.value),n=`spiff-fill-${i.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",i.browserValue),t.classList.add(n),A[n]=i}const i=t.attributes.getNamedItem("stroke");if(i&&"none"!==i.value){const e=Pn(i.value),n=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(n),t.setAttribute("stroke",e.browserValue),A[n]=e}}));const a=Zi().serializeToString(n);return{colors:A,svg:a}},Jn=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,i.jsx)(bi,{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,n=wi(e),A=Math.cos(n),a=-Math.sin(n),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(${A}, ${-a}, ${a}, ${A}, 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,i.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,i.jsx)("g",{transform:r,dangerouslySetInnerHTML:{__html:Tn(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class Ln{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 i=this.prevCommands.filter((e=>e.sequenceId===t)).pop();i&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),i?.overrideOldState(e),this.prevCommands.push(i))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],i=this.state.variation?.layouts?.[t],n=e?.layout||i?.layout;if(!n)throw new Error(`No layout: ${t}`);const A=[...e?.elements||[],...i?.elements||[]];return this.getLayoutDataWithState(n,A)}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:i=>jn(t,e,i)}}initialize(t,e){if(e)return void(this.state={transaction:e});let i={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{i=new AA(t).apply(i)})),this.runStateCallbacks(),this.state={transaction:i}}commandReducer(t,e){if(e.varying){const i={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(i)}}{const i=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(i)}}}}const zn=t=>"image"===t.type?(0,i.jsx)(bi,{...t},t.id):"frame"===t.type?(0,i.jsx)(Pi,{...t},t.id):"illustration"===t.type?(0,i.jsx)(Jn,{...t},t.id):"textbox"===t.type?(0,i.jsx)(Yn,{...t},t.id):null,jn=(t,e,n)=>{const A=n.renderingConfiguration,a=A?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,i.jsx)(gi,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:n.width||t.width,height:n.height||t.height,viewBox:A?.region?{x:A.region.left,y:A.region.top,width:A.region.width,height:A.region.height}:{x:0,y:0,width:t.width,height:t.height},configuration:A,outlineArea:n.outlineArea,maxHeight:n.maxHeight,maxWidth:n.maxWidth,position:n.position,borderRadius:n.borderRadius,outlineColor:n.outlineColor})};function Vn(t){return t.sort(((t,e)=>{const i=t.layer||0,n=e.layer||0;if(i<n)return-1;if(i>n)return 1;const A=t.layerIndex||0,a=e.layerIndex||0;return A<a?-1:A>a?1:0}))}class Kn extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,Kn.prototype)}}const Wn=(t,e)=>Xn(t,e).elements.find((e=>e.id===t)),Xn=(t,e)=>{const i=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!i)throw new Kn;return i},qn=(t,e)=>{const i=Vn([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:i,modificationID:Te()}},Zn=async(t,e)=>{const i=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],n=[...new Set(i)];for(let i=0;i<n.length;i++){const A=n[i],a=t.layouts[A],r=e?.layouts[A],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 Xi(e.src),i=await On(t);e.svg=Tn(i.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 $n{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class _n extends $n{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class tA extends $n{constructor(t,e,i){super(),this.id=t,this.x=e,this.y=i}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,x:this.x,y:this.y},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class eA extends $n{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,rotation:this.angle},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class iA extends $n{constructor(t,e,i){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(i)}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;let i={...e,width:this.width,height:this.height};if("frame"===e.type){const t=i;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=i,n=(t.algorithm&&t.algorithm!==We.Autosize?t.input:t.text)??"";i=vn(t,n,e)}const n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class nA extends $n{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class AA extends $n{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 aA extends $n{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()}})),i={};return e.forEach((t=>{i[t.layout.id]=t})),{...t,layouts:i}}}class rA extends $n{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 i=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,i)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:i,modificationID:Te()}}}}const i=e[e.length-1],n=i.productOverlay?i:null;let A;if(n&&e.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)A=[...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,A=[...e,this.element]}return n&&A.push(n),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:A,modificationID:Te()}}}}assignIndex(t,e){if(0===e.length)return 0;const i=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!==i?i+1:0}}class sA extends $n{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const i=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 n={};return i.forEach((t=>{n[t.layout.id]=t})),{...t,layouts:n}}}class oA extends $n{constructor(t,i){super(),this.el=b(e)(t),this.layout=i,this.el.id=Te(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new rA(this.el,this.layout).apply(t)}}class cA extends $n{constructor(t,e,i){super(),this.id=t,this.color=e,this.textFillSpotColor=i}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor,textFillImage:void 0},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class lA extends $n{constructor(t,e){super(),this.id=t,this.imageFill=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,textFillImage:this.imageFill},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class gA extends $n{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,fontSize:this.size},n=Xn(e.id,Object.values(t.layouts)),A=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=qn(vn(i,A),n);return{...t,layouts:{...t.layouts,[n.layout.id]:a}}}}class hA extends $n{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,algorithm:this.algorithm},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class dA extends $n{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,fontData:this.fontData},n=Xn(e.id,Object.values(t.layouts)),A=(e.algorithm&&e.algorithm!==We.Autosize?e.input:e.text)??"",a=qn(vn(i,A),n);return{...t,layouts:{...t.layouts,[n.layout.id]:a}}}}class uA extends $n{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,align:this.align},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class wA extends $n{constructor(t,e,i){super(),this.id=t,this.imageData=e,this.offsets=i}apply(t){this.oldState=t;const e=Xn(this.id,Object.values(t.layouts)),i=e.elements.findIndex((t=>t.id===this.id)),n=e.elements[i].pattern,A=[...e.elements];A.splice(i,1,{...e.elements[i],pattern:{...n,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:A,modificationID:Te()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class BA extends $n{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i=Xn(e.id,Object.values(t.layouts)),n=qn(vn(e,this.text,e),i);return{...t,layouts:{...t.layouts,[i.layout.id]:n}}}}class pA extends $n{constructor(t,e,i){super(),this.id=t,this.className=e,this.fill=i}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i=e.colors||{},n=i[this.className];i[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const A={...e,colors:i},a=Xn(e.id,Object.values(t.layouts)),r=qn(A,a);return{...t,layouts:{...t.layouts,[a.layout.id]:r}}}}class mA extends $n{constructor(t,e,i){super(),this.id=t,this.svgBody=e,this.objectURL=i}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},n=Xn(e.id,Object.values(t.layouts)),A=qn(i,n);return{...t,layouts:{...t.layouts,[n.layout.id]:A}}}}class EA extends $n{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Wn(this.id,Object.values(t.layouts)).id)throw new Kn;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 i=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(i,1)[0]);const n=[...e.elements];return n.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:n,modificationID:Te()}}}}}class fA extends $n{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!i)throw new Error("Layout missing from state!");const n=i.elements.findIndex((t=>t.id===this.id));i.elements.splice(n,1),i.elements.unshift(e);const A=[...i.elements],a=A.splice(n,1)[0];return A.splice(n,0,a),A.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[i.layout.id]:{...t.layouts[i.layout.id],elements:A,modificationID:Te()}}}}}class CA extends $n{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Wn(this.id,Object.values(t.layouts)).id)throw new Kn;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 i=e.elements.findIndex((t=>t.id===this.id)),n=i+1,A=[...e.elements],a=A.splice(i,1)[0];return A.splice(n,0,a),A.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:A,modificationID:Te()}}}}}class QA extends $n{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Wn(this.id,Object.values(t.layouts)).id)throw new Kn;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 i=e.elements.findIndex((t=>t.id===this.id)),n=i-1,A=[...e.elements],a=A.splice(i,1)[0];return A.splice(n,0,a),A.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:A,modificationID:Te()}}}}}class yA extends $n{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=Wn(this.id,Object.values(t.layouts));if(!e.id)throw new Kn;const i=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!i)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[i.layout.id]:qn({...e,layer:this.value},i)}}}}var IA={};He(IA,"patternImageDataCache",(()=>FA)),He(IA,"frameDataCache",(()=>PA)),He(IA,"generateFrameSVG",(()=>YA)),He(IA,"generateDefaultRectangleFrameSvg",(()=>NA)),He(IA,"getVariant",(()=>kA)),He(IA,"getFrameData",(()=>RA)),He(IA,"calculateOffsets",(()=>HA)),He(IA,"getPatternImageData",(()=>UA)),He(IA,"GetSVGDimensions",(()=>GA)),He(IA,"svgStringDimensions",(()=>TA));var DA={};He(DA,"getExifOrientation",(()=>vA)),He(DA,"canvasDims",(()=>MA)),He(DA,"getAttributesFromArrayBuffer",(()=>SA));let xA=null;const vA=t=>new Promise((e=>{const i=nn(t);(0,o.fromBuffer)(t).then((t=>{const n=t?.mime;if("image/jpeg"!==n)return e(1);(new(0,h.ExifImage)).loadImage(i,((t,i)=>e(t?1:i.image.Orientation||1)))}))})),MA=t=>{const e=8192,i=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[i*e,e]:[e,e/i]},SA=async t=>{const e=await(async t=>{const e=await tn(t),i=await(0,g.loadImage)(e),[n,A]=MA(i),a=await(async()=>{if(null!==xA)return!xA;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return xA=2===t.width&&3===t.height,!xA})();if(!a){const t=(0,g.createCanvas)(n,A);return t.getContext("2d").drawImage(i,0,0,n,A),t}const r=await vA(t),[s,o]=r>4?[A,n]:[n,A],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(i,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",(()=>bA));const bA=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))}},FA=new Map,PA=new Map,YA=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return NA(t)}return Xi(e)},NA=t=>{const e=t.width,i=e/t.height,n=Math.max(e,512),A=n/i;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${n} ${A}'>\n <path id="target-path" d='M0 0 h ${n} v ${A} h ${-n} Z' />\n </svg>\n `},kA=(t,e)=>{if(!e)return;const i=e.variants?.find((e=>e.id===t.frameVariantId))||bA(e);if(!i)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!i.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return i},RA=async t=>{const e=Ki().parseFromString(t,"image/svg+xml"),i=e.querySelector("svg");if(!i)throw new Error("Malformed frame SVG: <svg> tag not found");const n=i.getAttribute("viewBox");if(!n)throw new Error("SVG missing viewBox.");const A=n.split(" "),a=parseFloat(A[3])||1,r=parseFloat(A[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 PA.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 PA.set(t,e),e}throw new Error("Malformed frame SVG")},HA=(t,e,i)=>{const n=e.width>=e.height,A=t.width>=t.height,a=e.width/2,r=e.height/2,s=(n?e.height:e.width)/(A?t.width:t.height),o=i?.scale||s,c=a-t.width/2*o,l=i?.left||c,g=r-t.height/2*o;return{x:l,y:i?.top||g,zoom:o}},UA=async t=>{if(FA.has(t))return FA.get(t);if(t.endsWith("svg")){const e=await GA(t),i=e.width,n=e.height,A={src:t,width:i,height:n,aspect:i/n};return FA.set(t,A),A}{const e=await Wi(t),i=await SA(e),n={src:t,width:i.width,height:i.height,aspect:i.width/i.height};return FA.set(t,n),n}},GA=async t=>{const e=await Xi(t);return TA(e)},TA=t=>{const e=Ki().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const i=e.getAttribute("viewBox"),n=e.getAttribute("width"),A=e.getAttribute("height"),a=i?i?.split(" ").map((t=>Number(t))):[0,0,Number(n),Number(A)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var OA={};He(OA,"determineCorrectFontSizeAndLines",(()=>LA)),He(OA,"determineCorrectTextboxRegion",(()=>zA));const JA=(t,e,i,n,A)=>{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=>En(t,n,A)));const o=A.getApproximateHeight()*n;let c=!0;for(;c;){if(o+(r-1)*i>t.height)return[null,null];const e=Math.max(...s);if(e<=t.width)return[a,e];const l=s.reduce(((t,e,i,n)=>e>n[t]?i: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)],i=e.map((t=>En(t,n,A)));i[0]<=t.width&&(a=[...a.slice(0,l),...e,...a.slice(l+1)],s=[...s.slice(0,l),...i,...s.slice(l+1)],r+=1,h=!0)}h||(c=!1)}return[null,null]},LA=(t,e,i,n,A)=>{let a,r;const s=ln(e.assetUrl),o=s.getFont();if(A.size){const e=t/o.unitsPerEm;return[a,r]=JA(i,n,t,e,s),[A.size,a,r]}let c=6-mn;if(n.length>0){let t=n,e=0;for(;(!A.maxSize||c<=A.maxSize)&&t;)c+=mn,e=c/o.unitsPerEm,[t,r]=JA(i,n,c,e,s)}c>6&&(c-=mn),A.minSize&&c<A.minSize&&(c=A.minSize);const l=c/o.unitsPerEm;return[a,r]=JA(i,n,c,l,s),[c,a,r]},zA=(t,e,i,n,A)=>{let a={...t},r={...t},[s,o,c]=LA(i,e,r,n,{size:0,minSize:i,maxSize:i});var l,g;return c&&c<a.width&&(r.width=c,"left"===A?(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"===A?a.width-c:(a.width-c)/2,[s,o]=LA(i,e,r,n,{size:i}),s===i&&o&&(l=n,g=o,l.map(((t,e)=>[t,g[e]]))).every((([t,e])=>t===e))&&(a=r)),a};var jA={};He(jA,"svgObjectURL",(()=>WA)),He(jA,"LayoutElementFactory",(()=>qA));const VA=(t,e)=>{const i=t.layoutState.elements.filter((t=>t.layer===e)),n=Math.max(...i.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(n,0)+1},KA=async t=>new Promise((e=>{Xi(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),WA=async t=>{const e=Ki().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const i=(new XMLSerializer).serializeToString(e),n=document.createElement("canvas"),A=n.getContext("2d"),a=await Re.from(A,i,{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,i)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((i=>{if(!i){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(i))}))}catch(t){i(t)}})))(n)},XA=async(t,e,i,n)=>{const A=t.layoutState.layout.useEditableArea&&t.layoutState.layout.editableArea||{width:t.layoutState.layout.width,height:t.layoutState.layout.height,x:0,y:0},a=A.width<A.height?A.width:A.height,r=t.layoutState.layout.useEditableArea?a/1.3:a/2,s={top:A.y+A.height/2-r/2,left:A.x+A.width/2-r/2,width:r,height:r,rotation:0,panelId:t.layoutState.layout.panelId};if(i&&e===ze.Illustration){const t=await On(await KA(i)),e=Ki().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const n=s.height,A=e.split(" "),a=(parseFloat(A[2])||1)/(parseFloat(A[3])||1);s.height=s.width/a,s.top+=(n-s.height)/2}if(i&&e===ze.Image){const t=s.height,e=await Wi(i),n=await SA(e),A=n.width/n.height;s.height=s.width/A,s.top+=(t-s.height)/2}if(i&&e===ze.Textbox&&n?.text&&n?.fontScale){await on(i);const t=ln(i),e=En(n.text,n?.fontScale,t);s.width=Math.min(e,.85*A.width),s.left=A.x+A.width/2-s.width/2}return s};class qA{static async getFrame(t,e){const i=await YA(e.region,e.src),n=await RA(i),A=e.region||await XA(t,ze.Frame);return{id:Te(),x:A.left,y:A.top,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||VA(t,A.layer||0),rotation:A.rotation,scaleX:A.width/n.width,scaleY:A.height/n.height,path:n.path,dataWidth:n.width,dataHeight:n.height,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:A.immutable}}static async getImage(t,e){const i=e.region||await XA(t,ze.Image,e.src);return{id:Te(),src:e.src,type:ze.Image,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||VA(t,i.layer||0),immutable:i.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:i,fontSrc:n,designInputStep:A}=e,a=await on(n),r={assetUrl:n,name:a.names.fullName.en},s=A?.text||i.defaultText||"",o=i.replaceableText?i.replaceableText.replace("{{}}",s):s,c=yn(o,{vertical:i.vertical,uppercase:i.uppercase}),l=e.region||await XA(t,ze.Textbox,n,{text:c,fontScale:i.size?i.size/a.unitsPerEm:void 0}),g=vn({id:Te(),type:ze.Textbox,x:l.left,y:l.top,width:l.width,height:l.height,align:Dn(i.textAlign,i.vertical),curved:i.curved,fill:A?.color||i.colour||"#000000",fontData:r,layer:l.layer||0,layerIndex:l.layerIndex||VA(t,l.layer||0),paths:i.paths,rotation:l.rotation,vertical:i.vertical,verticalAlign:i.verticalAlign||"middle",algorithm:We.Traditional,fontSize:i.size||Math.max(Math.round(.025*l.height),1),text:c,input:s},c),h=pn({...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 i=`\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 `,n={};n["spiff-fill-shape"]={browserValue:e.color};const A=e.region||await XA(t,ze.Illustration),a=Te();return{stepRegion:e.region,colors:n,id:a,svg:i,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||VA(t,A.layer||0),immutable:A.immutable}}static async getIllustration(t,e){const i=e.region||await XA(t,ze.Illustration,e.src),n=await On(await KA(e.src)),A=await WA(n.svg),a=Te();return{cachedObjectURL:A,stepRegion:e.region,colors:n.colors,id:a,src:e.src,svg:n.svg,type:ze.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||VA(t,i.layer||0),immutable:i.immutable}}}function ZA(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class $A extends Error{constructor(t){super(t),this.name=this.constructor.name}}class _A extends $A{constructor(t){super(`ConfigurationError - ${t}`)}}class ta extends _A{constructor(t){super(`Option not Configured: ${t.stepTitle}`),ZA(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class ea extends _A{constructor(t){super(`Panel not Found: ${t.panelId}`),ZA(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class ia extends _A{constructor(t){super(`Asset not found for variant: ${t.name}`),ZA(this,"variant",void 0),this.variant=t}}class na extends _A{constructor(t){super(`Resource not found for asset: ${t.name}`),ZA(this,"asset",void 0),this.asset=t}}class Aa extends _A{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),ZA(this,"step",void 0),this.step=t}}class aa extends $A{constructor(t){super(`ImplementationError - ${t}`)}}class ra extends aa{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class sa extends aa{constructor(t){super(`Parsing Error: ${t}`)}}class oa extends aa{constructor(t){super(`Client Error: ${t}`)}}class ca extends aa{constructor(t){super(`Resource Generation Failed: ${t}`)}}function la(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ga{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 i=JSON.stringify([...e.entries()]);this.set(t,i)}}class ha{constructor(){la(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 i=JSON.stringify([...e.entries()]);this.set(t,i)}}const da=(()=>{try{return localStorage?new ga:new ha}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new ha}})();function ua(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const wa=new class{constructor(){ua(this,"defaultServerUrl","https://api.spiff.com.au"),ua(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ua(this,"defaultHubUrl","https://hub.spiff.com.au"),ua(this,"serverUrl",void 0),ua(this,"servicesApiUrl",void 0),ua(this,"hubUrl",void 0),ua(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 Ba(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let pa;const ma=t=>{pa=t};let Ea;const fa=t=>{Ea=t};let Ca;const Qa=t=>{Ca=t};let ya;const Ia=new class{constructor(){Ba(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),wa.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${wa.getServerUrl()}/graphql`,fetch:f.fetch}),i=(0,m.setContext)((async(t,e)=>{const{headers:i}=e,n=i||{},A=await(async()=>{const t={applicationKey:ya,bundleOwnerId:Ea,customerToken:Ca,transactionOwnerId:pa};return"undefined"!=typeof window&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await new Promise((t=>{const e=wa.getHubUrl(),i=n=>{n.origin===e&&(window.removeEventListener("message",i),t(n.data))};window.parent!==window&&(window.addEventListener("message",i,!1),window.parent.postMessage("ready",e))})),...t}:t})(),a=e.bearer??A.bearer,r=e.partnerId??A.partnerId,s=e.activeIntegration??A.activeIntegration,o=e.transactionOwnerId??A.transactionOwnerId,c=e.customerToken??A.customerToken,l=e.applicationKey??A.applicationKey,g=e.bundleOwnerId??A.bundleOwnerId;return a&&(n.Authorization=`Bearer ${a}`),r&&(n.partnerId=r),s&&(n.activeIntegration=s),o&&(n.transactionOwnerId=o),c&&(n.customerToken=c),l&&(n["X-Application-Key"]=l),g&&(n.bundleOwnerId=g),{headers:n}})),n=(0,E.onError)((({operation:t,graphQLErrors:e,networkError:i})=>{(e||[]).forEach((({message:e,locations:i,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+t.operationName),console.log("Query:"+JSON.stringify(t.query)),console.log(`Message: ${e}, Location: ${JSON.stringify(i,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(t.variables))})),i&&console.log("GraphQL Network error")}));const A=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)([n,i,e]),cache:A,name:"Core"})}};function Da(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const xa=t.gql`
2
2
  fragment AssetMetadataFields on Asset {
3
3
  metadata {
4
4
  key
@@ -576,7 +576,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
576
576
  id
577
577
  }
578
578
  }
579
- `;class Ro extends Po{constructor(t,e){super(t,e),Yo(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await Ia.getShadowGraphqlClient().mutate({mutation:ko,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 Ia.getShadowGraphqlClient().mutate({mutation:No,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 Ho extends Po{constructor(t,e){super(t,e)}async selectVariant(t){if(this.getCurrentVariant()!==t)return lo.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 Wn(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,e){const i=new Map;return i.set(t,e),lo.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),i)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?lo.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 Uo extends Po{constructor(t,e){super(t,e)}selectVariant(t){return go.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Go extends Po{constructor(t,e){super(t,e)}selectVariant(t){return ho.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class To extends Po{constructor(t,e){super(t,e)}selectVariant(t){return wo.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Oo extends Po{constructor(t,e){super(t,e)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await Bo.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.option?.displayType}}class Jo extends Po{constructor(t,e){super(t,e)}selectVariant(t){const e=t.getResource();return mo.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return mo.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return mo.availableColours(this.step)}setCustomColor(t){if("#custom"!==this.getCurrentVariant()?.getColor())throw new Error("Custom colors can only be set on a non-custom variant. Please add a custom variant to the step.");return mo.setCustomColor(t,this.step,this.manager)}getCustomColor(){const t=this.manager.getStepStorage(this.step.stepName)?.colour;if("#custom"!==this.getCurrentVariant()?.getColor())throw new Error("Custom colors can only be set on a non-custom variant. Please add a custom variant to the step.");if(!t)throw new Error("Color not available on step. Set a default on the workflow to fix this.");return t}}class Lo extends Po{constructor(t,e){super(t,e)}async selectVariant(t){yo.selectVariant(this.step,t.getResource(),this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Do.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?yo.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await yo.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return yo.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await yo.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||"",i=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",e):e,n=t?i:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:n,defaultCleared:!1});return this.setText(n)}setText(t){const e={input:t},i=yo.findLayoutElements(this.manager,this.step),n=yo.filterUnsupportedCharacters(t,i[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&n.length>this.step.data.maxLength||(e.input=n);const A=i.length<=0,a=A?{inputText:n,text:n}:{inputText:n};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:n}),A)return e;const{command:r,errors:s,helperText:o}=yo.updateInputText(n,i,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:Do.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 zo{static get(t,e){switch(e.type){case si.Question:return new Oo(t,e);case si.Text:return new Lo(t,e);case si.Illustration:return new Ho(t,e);case si.Picture:return new To(t,e);case si.Shape:return new Jo(t,e);case si.Material:return new Uo(t,e);case si.Model:return new Go(t,e);case si.Frame:return new ul(t,e);case si.Bulk:return new Ro(t,e);default:throw new ra(`Step type ${e.type} not yet supported in Core SDK`)}}}function jo(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Vo=t.gql`
579
+ `;class Ro extends Po{constructor(t,e){super(t,e),Yo(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await Ia.getShadowGraphqlClient().mutate({mutation:ko,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 Ia.getShadowGraphqlClient().mutate({mutation:No,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 Ho extends Po{constructor(t,e){super(t,e)}async selectVariant(t){if(this.getCurrentVariant()!==t)return lo.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 Wn(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,e){const i=new Map;return i.set(t,e),lo.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),i)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?lo.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 Uo extends Po{constructor(t,e){super(t,e)}selectVariant(t){return go.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Go extends Po{constructor(t,e){super(t,e)}selectVariant(t){return ho.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class To extends Po{constructor(t,e){super(t,e)}selectVariant(t){return wo.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Oo extends Po{constructor(t,e){super(t,e)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await Bo.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.option?.displayType}}class Jo extends Po{constructor(t,e){super(t,e)}selectVariant(t){const e=t.getResource();return mo.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return mo.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return mo.availableColours(this.step)}setCustomColor(t){if("#custom"!==this.getCurrentVariant()?.getColor())throw new Error("Custom colors can only be set on a non-custom variant. Please add a custom variant to the step.");return mo.setCustomColor(t,this.step,this.manager)}getCustomColor(){const t=this.manager.getStepStorage(this.step.stepName)?.colour;if("#custom"!==this.getCurrentVariant()?.getColor())throw new Error("Custom colors can only be set on a non-custom variant. Please add a custom variant to the step.");if(!t)throw new Error("Color not available on step. Set a default on the workflow to fix this.");return t}}class Lo extends Po{constructor(t,e){super(t,e)}async selectVariant(t){yo.selectVariant(this.step,t.getResource(),this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Do.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?yo.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await yo.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return yo.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await yo.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||"",i=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",e):e,n=t?i:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:n,defaultCleared:!1});return this.setText(n)}setText(t){const e={input:t},i=yo.findLayoutElements(this.manager,this.step),n=yo.filterUnsupportedCharacters(t,i[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&n.length>this.step.data.maxLength||(e.input=n);const A=i.length<=0,a=A?{inputText:n,text:n}:{inputText:n};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:n}),A)return e;const{command:r,errors:s,helperText:o}=yo.updateInputText(n,i,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:Do.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 zo extends Po{constructor(t,e){super(t,e)}async selectVariant(){}getContent(){return this.step.data.content}}class jo{static get(t,e){switch(e.type){case si.Information:return new zo(t,e);case si.Question:return new Oo(t,e);case si.Text:return new Lo(t,e);case si.Illustration:return new Ho(t,e);case si.Picture:return new To(t,e);case si.Shape:return new Jo(t,e);case si.Material:return new Uo(t,e);case si.Model:return new Go(t,e);case si.Frame:return new wl(t,e);case si.Bulk:return new Ro(t,e);default:throw new ra(`Step type ${e.type} not yet supported in Core SDK`)}}}function Vo(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Ko=t.gql`
580
580
  fragment CreateDesignTransaction on Transaction {
581
581
  id
582
582
  designName
@@ -592,8 +592,8 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
592
592
  lastSyncedAt
593
593
  bulkEmailAddress
594
594
  }
595
- `,Ko=t.gql`
596
- ${Vo}
595
+ `,Wo=t.gql`
596
+ ${Ko}
597
597
  mutation CreateDesign(
598
598
  $name: String!
599
599
  $layouts: [LayoutInput]!
@@ -624,8 +624,8 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
624
624
  }
625
625
  }
626
626
  }
627
- `,Wo=t.gql`
628
- ${Vo}
627
+ `,Xo=t.gql`
628
+ ${Ko}
629
629
  mutation CreateDesigns($inputs: [DesignCreateInput]!) {
630
630
  designCreateMany(inputs: $inputs) {
631
631
  id
@@ -638,7 +638,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
638
638
  }
639
639
  }
640
640
  }
641
- `,Xo=(t,e,i)=>{const n={};return e.steps.forEach((e=>{Object.assign(n,(e=>{const n={};if("Frame"===e.type){const A=t[e.stepName],a=e.data;if(!A||a.hideImageInCart&&i)return n;n[`${e.stepTitle} image`]=A.image}if("Illustration"===e.type){const A=t[e.stepName],a=e.data;if(!A||a.hideColorsInCart&&i||!A.colors)return n;if(A.colors.length>0){const t=A.colors.join(", ").toUpperCase();n[`${e.stepTitle} colors`]=t}}if("Module"===e.type){const A=t[e.stepName],a=e.data;if(!A||a.hideTextInCart&&i)return n;n[`${e.stepTitle} text`]=A.text}if("Text"===e.type){const A=t[e.stepName];if(!A)return n;const a=e.data;a.hideTextInCart&&i||(n[`${e.stepTitle} text`]=A.text),!A.color||a.hideColorInCart&&i||(n[`${e.stepTitle} color`]=A.color)}return n})(e))})),n},qo=(t,e,i,n,A,a,r,s,o,c)=>{const l=(da.getMap("transactionOwnerIds")||new Map).get(t.id),g={baseCost:i,designProductId:t.externalDesignProductId,designProductVariantId:t.externalDesignProductVariantId,event:"onComplete",exportedData:a,externalCartProductId:t.externalCartProductId,externalCartProductVariantId:t.externalCartProductVariantId,lineItemImageUrl:r||"",optionsCost:n,processExecutionId:c,transactionId:t.id,transactionOwnerId:l,weight:e.weight,workflowViewerLink:t.workflowViewerLink||"",workflowViewerReadOnlyLink:t.workflowViewerReadOnlyLink||""};return A&&(g.metadata=A),s&&(g.selectedVariants=s),o&&(g.sku=o),g},Zo=async(t,e,i,n,A,a,r,s)=>{const o=e.basePrice||0,c=t.priceModifierTotal||0,l=((t,e,i,n)=>{const A={};let a;if(i){a=Xo(i,e,!1);for(const t of Object.keys(a))A[t]={value:a[t],priceModifier:0}}else if(n){a=n;for(const t of Object.keys(a))A[t]={value:a[t],priceModifier:0}}for(const i of Object.keys(t)){const n=t[i],a=e.steps.find((t=>t.stepTitle===i));if(1===n.length)A[`${a?.stepTitle} selection`]={value:n[0].name,priceModifier:n[0].priceModifier};else if(n.length>1)for(let t=0;t<n.length;t++)A[`${a?.stepTitle} selection ${t+1}`]={value:n[t].name,priceModifier:n[t].priceModifier}}return A})(n,i,void 0,a);return qo(t,e,o,c,a,l,r,n,A,s)},$o=async(t,e,i,n,A,a,r,s,o)=>{await t.outstandingRequestsPromise();const c=Ia.getShadowGraphqlClient(),l=await c.query({query:zs,variables:{id:A.id},fetchPolicy:"no-cache",errorPolicy:"all"}),g=l.data?.transactions[0].workflowState;!l.errors&&g||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(n())),l.errors&&l.errors.forEach((t=>{l.errors&&console.log("Server Error:",t.message)})),await t.updateStateWithServerImmediate(n),console.log("Server state is undefined @ Workflow completion"));const h=t.getPreviewService(),d=e?.finalizeStepConfig?.lookAtAnimation,u=h&&100===h.getSceneInitializationProgress()&&e.showModelOnFinishStep&&!!d,w=o&&Xo(o,e,!0),B=o&&Xo(o,e,!1),p=async t=>{const i={};let n=0;if(Object.keys(a).length>0)for(const A of Object.keys(a)){const r=a[A],s=e.steps.find((t=>t.stepName===A));for(let e=0;e<r.selections.length;++e){const A=r.selections[e];if(s&&(!t||s.option&&(s.option.variants||[]).length>1&&!s.data.hideSelectionInCart&&!s.data.hideSelectionsInCart)){const t=s.stepTitle;i[t]?i[t].push({id:A.id||"",name:A.name,priceModifier:A.priceModifier}):i[t]=[{id:A.id||"",name:A.name,priceModifier:A.priceModifier}]}n+=A.priceModifier}}return[i,n]},[m]=await p(!0),E=Object.fromEntries(Object.keys(m).map((t=>[t,m[t].map((t=>t.id))]))),[f]=await p(!1),C=Object.fromEntries(Object.keys(f).map((t=>[t,f[t].map((t=>t.id))]))),Q=await s(u);return{designDetails:(()=>{const t={name:r,layouts:i.map((t=>({index:t.index,panelId:t.panelId}))),workflowId:e.id,transactionId:A.id,useThreeDimPreview:!!u,previewImage:Q};if(B){const e=[];for(const[t,i]of Object.entries(B))e.push({key:t,value:i});t.metadata=e}if(E){const e=[];for(const[t,i]of Object.entries(C))e.push({key:t,ids:i});t.selectedVariants=e}return t})(),cartSelectionsWithPrices:m,cartMetadata:w}},_o=async(t,e,i,n,A,a,r,s,o,c,l,g,h)=>{o("workflow.steps.finish.finalize.buildingLayouts");const{designDetails:d,cartSelectionsWithPrices:u,cartMetadata:w}=await $o(t,e,i,n,a,r,s,g,h);o("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(l);const B=await(async t=>(await Ia.getShadowGraphqlClient().mutate({mutation:Ko,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)(d),p=B?.transaction?.previewImageLink;if(!B?.transaction)throw new Error("Failed to create design");o("workflow.steps.finish.finalize.updatingTransaction");const m=B.transaction;return a.bulk?((t,e,i,n)=>{const A=(e.basePrice||0)*(t.variationsCount||0),a=t.priceModifierTotal||0,r={items:{value:t.variationsCount?`${t.variationsCount}`:"0",priceModifier:0}};return qo(t,e,A,a,void 0,r,i,void 0,void 0,n)})(m,A,p,B?.processExecution?.id):await Zo(m,A,e,u,B?.sku,w,p,B?.processExecution?.id)},tc=async(t,e)=>{e("workflow.steps.finish.finalize.buildingLayouts");const i=await Promise.all(t.map((async t=>await $o(t.workflowManager,t.workflow,t.layouts,t.getReducerState,t.transaction,t.workflowSelections,t.designName,(()=>Promise.resolve(void 0)),t.workflowMetadata))));e("workflow.steps.finish.finalize.creatingDesign");const n=await(async t=>(await Ia.getShadowGraphqlClient().mutate({mutation:Wo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{inputs:t.map((t=>({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?.designCreateMany)(i.map((t=>t.designDetails)));if(!n)throw new Error("Failed to create designs");return e("workflow.steps.finish.finalize.updatingTransaction"),Promise.all(n.map((async(e,n)=>{const A=t[n],a=i[n],r=e.transaction;return await Zo(r,A.product,A.workflow,a.cartSelectionsWithPrices,e.sku,a.cartMetadata,void 0,e.processExecution?.id)})))};let ec;var ic;(ic=ec||(ec={})).Local="Local",ic.Remote="Remote";const nc=new class{constructor(){jo(this,"localPersistenceKey","designTransactions"),jo(this,"storageMethod",ec.Local),jo(this,"designSavedListeners",[])}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter((e=>e!==t))}async getSavedDesigns(){if(this.storageMethod===ec.Local){const t=da.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new ra("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 i=await this.getSavedDesigns(),n=i.find((e=>e.transactionId===t));if(!n)throw new Error(`No saved design for transaction ${t}.`);n.title=e,await this.setDesigns(i)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter((e=>e.transactionId!==t)))}async setDesigns(t){if(this.storageMethod!==ec.Local)throw new ra("Unexpected storage method requested");da.set(this.localPersistenceKey,JSON.stringify(t))}};function Ac(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ac{constructor(t,e){if(Ac(this,"client",void 0),Ac(this,"commandContext",void 0),Ac(this,"workflowManager",void 0),Ac(this,"isReadOnly",void 0),Ac(this,"renderableScenes",[]),Ac(this,"renderableSceneCallbacks",[]),Ac(this,"debouncedSavedDesignUpdate",b(D)((async()=>{await nc.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),Ac(this,"getCanvasObjectURLAsync",(async t=>new Promise(((e,i)=>{try{t.toBlob((t=>{if(t){const i=URL.createObjectURL(t);e(i)}}))}catch(t){i(t)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const i=e.layouts;this.commandContext=new Ln,this.commandContext.initialize(i,e.reloadedState),this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.workflowManager=new Mo(e.workflow,e.product.profanities?.map((t=>t.word))||[],i,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 Ia.getShadowGraphqlClient().mutate({mutation:Ls,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 i=this.workflowManager.getWorkflow(),n=i?.finalizeStepConfig?.lookAtAnimation;if(t){if(!n)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,n))||""}const A=document.createElement("canvas");let a=2048;e&&e<=2048&&(a=e),A.width=a,A.height=a;const r=this.commandContext.getAllLayouts(),s=i.defaultPreviewPanelIndex||0,o=i.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=A.getContext("2d");if(!h)throw new ca("Failed to obtain 2D context for preview image creation");const d=jn(g.layoutState.layout,g.layoutState.elements,{renderingConfiguration:{purpose:Ve.Print,region:{left:l.x,top:l.y,width:l.width,height:l.height}}}),u=b(Q).renderToStaticMarkup(d),w=await Re.from(h,u,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await w.render();const B=await this.getCanvasObjectURLAsync(A);return A.toDataURL(B)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t));if(e&&this.stepHasHandle(e))return zo.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:si.Bulk,stepName:"Bulk",stepTitle:t?.stepTitle??"workflow.steps.bulk.title",helpText:t?.helpText,data:{aspects:js(this.getWorkflowManager().getWorkflow())},conditions:[]};return zo.get(this.getWorkflowManager(),e)}}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepTitle===t));if(e&&this.stepHasHandle(e))return zo.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter((e=>e.type===t)).map((t=>zo.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=>zo.get(this.getWorkflowManager(),t)))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){const e=(await Ia.getShadowGraphqlClient().mutate({mutation:No,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=da.getMap("transactionCustomerIds")||new Map;t.set(this.getWorkflowManager().getTransaction().id,e.customer.id),da.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 ra("State undefined!");const e={title:await(async()=>{if(t)return t;const e=this.getWorkflowManager().getTransaction().id,i=(await nc.getSavedDesigns()).find((t=>t.transactionId===e))?.title;return i||"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 nc.addDesign(e),e}async copy(){const t=b(e)(this.getCommandContext().getState());if(!t)throw new ra("Internal state is undefined! Cannot copy experience!");const i=JSON.stringify(t.transaction),n=this.getWorkflowManager().getWorkflow(),A=new ol({}),a=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!a)throw new ra("Integration product id is undefined!");await A.initFromIntegrationProduct(a);return await A.getWorkflowExperience(n.id,i,void 0)}async onDesignFinished(t,e=!0){return _o(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=>e?this.createPreviewImage(t):Promise.resolve(void 0)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==si.SilentIllustration&&t.type!==si.ProductOverlay}getExportedData(){const t=new Map,e=this.getWorkflowManager().getWorkflowMetadata(),i=this.getWorkflowManager().getWorkflowSelections();return Object.keys(e).forEach((i=>{const n=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===i));if(!n)return;t.has(n.stepTitle)||t.set(n.stepTitle,{});const A=e[i];Object.keys(A).forEach((e=>{t.get(n.stepTitle)[e]=A[e]}))})),Object.keys(i)?.forEach((e=>{const n=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===e));n&&(t.has(n.stepTitle)||t.set(n.stepTitle,{}),t.get(n.stepTitle).selection=i[e].selections[0].name)})),t}}const rc=v.gql`
641
+ `,qo=(t,e,i)=>{const n={};return e.steps.forEach((e=>{Object.assign(n,(e=>{const n={};if("Frame"===e.type){const A=t[e.stepName],a=e.data;if(!A||a.hideImageInCart&&i)return n;n[`${e.stepTitle} image`]=A.image}if("Illustration"===e.type){const A=t[e.stepName],a=e.data;if(!A||a.hideColorsInCart&&i||!A.colors)return n;if(A.colors.length>0){const t=A.colors.join(", ").toUpperCase();n[`${e.stepTitle} colors`]=t}}if("Module"===e.type){const A=t[e.stepName],a=e.data;if(!A||a.hideTextInCart&&i)return n;n[`${e.stepTitle} text`]=A.text}if("Text"===e.type){const A=t[e.stepName];if(!A)return n;const a=e.data;a.hideTextInCart&&i||(n[`${e.stepTitle} text`]=A.text),!A.color||a.hideColorInCart&&i||(n[`${e.stepTitle} color`]=A.color)}return n})(e))})),n},Zo=(t,e,i,n,A,a,r,s,o,c)=>{const l=(da.getMap("transactionOwnerIds")||new Map).get(t.id),g={baseCost:i,designProductId:t.externalDesignProductId,designProductVariantId:t.externalDesignProductVariantId,event:"onComplete",exportedData:a,externalCartProductId:t.externalCartProductId,externalCartProductVariantId:t.externalCartProductVariantId,lineItemImageUrl:r||"",optionsCost:n,processExecutionId:c,transactionId:t.id,transactionOwnerId:l,weight:e.weight,workflowViewerLink:t.workflowViewerLink||"",workflowViewerReadOnlyLink:t.workflowViewerReadOnlyLink||""};return A&&(g.metadata=A),s&&(g.selectedVariants=s),o&&(g.sku=o),g},$o=async(t,e,i,n,A,a,r,s)=>{const o=e.basePrice||0,c=t.priceModifierTotal||0,l=((t,e,i,n)=>{const A={};let a;if(i){a=qo(i,e,!1);for(const t of Object.keys(a))A[t]={value:a[t],priceModifier:0}}else if(n){a=n;for(const t of Object.keys(a))A[t]={value:a[t],priceModifier:0}}for(const i of Object.keys(t)){const n=t[i],a=e.steps.find((t=>t.stepTitle===i));if(1===n.length)A[`${a?.stepTitle} selection`]={value:n[0].name,priceModifier:n[0].priceModifier};else if(n.length>1)for(let t=0;t<n.length;t++)A[`${a?.stepTitle} selection ${t+1}`]={value:n[t].name,priceModifier:n[t].priceModifier}}return A})(n,i,void 0,a);return Zo(t,e,o,c,a,l,r,n,A,s)},_o=async(t,e,i,n,A,a,r,s,o)=>{await t.outstandingRequestsPromise();const c=Ia.getShadowGraphqlClient(),l=await c.query({query:zs,variables:{id:A.id},fetchPolicy:"no-cache",errorPolicy:"all"}),g=l.data?.transactions[0].workflowState;!l.errors&&g||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(n())),l.errors&&l.errors.forEach((t=>{l.errors&&console.log("Server Error:",t.message)})),await t.updateStateWithServerImmediate(n),console.log("Server state is undefined @ Workflow completion"));const h=t.getPreviewService(),d=e?.finalizeStepConfig?.lookAtAnimation,u=h&&100===h.getSceneInitializationProgress()&&e.showModelOnFinishStep&&!!d,w=o&&qo(o,e,!0),B=o&&qo(o,e,!1),p=async t=>{const i={};let n=0;if(Object.keys(a).length>0)for(const A of Object.keys(a)){const r=a[A],s=e.steps.find((t=>t.stepName===A));for(let e=0;e<r.selections.length;++e){const A=r.selections[e];if(s&&(!t||s.option&&(s.option.variants||[]).length>1&&!s.data.hideSelectionInCart&&!s.data.hideSelectionsInCart)){const t=s.stepTitle;i[t]?i[t].push({id:A.id||"",name:A.name,priceModifier:A.priceModifier}):i[t]=[{id:A.id||"",name:A.name,priceModifier:A.priceModifier}]}n+=A.priceModifier}}return[i,n]},[m]=await p(!0),E=Object.fromEntries(Object.keys(m).map((t=>[t,m[t].map((t=>t.id))]))),[f]=await p(!1),C=Object.fromEntries(Object.keys(f).map((t=>[t,f[t].map((t=>t.id))]))),Q=await s(u);return{designDetails:(()=>{const t={name:r,layouts:i.map((t=>({index:t.index,panelId:t.panelId}))),workflowId:e.id,transactionId:A.id,useThreeDimPreview:!!u,previewImage:Q};if(B){const e=[];for(const[t,i]of Object.entries(B))e.push({key:t,value:i});t.metadata=e}if(E){const e=[];for(const[t,i]of Object.entries(C))e.push({key:t,ids:i});t.selectedVariants=e}return t})(),cartSelectionsWithPrices:m,cartMetadata:w}},tc=async(t,e,i,n,A,a,r,s,o,c,l,g,h)=>{o("workflow.steps.finish.finalize.buildingLayouts");const{designDetails:d,cartSelectionsWithPrices:u,cartMetadata:w}=await _o(t,e,i,n,a,r,s,g,h);o("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(l);const B=await(async t=>(await Ia.getShadowGraphqlClient().mutate({mutation:Wo,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)(d),p=B?.transaction?.previewImageLink;if(!B?.transaction)throw new Error("Failed to create design");o("workflow.steps.finish.finalize.updatingTransaction");const m=B.transaction;return a.bulk?((t,e,i,n)=>{const A=(e.basePrice||0)*(t.variationsCount||0),a=t.priceModifierTotal||0,r={items:{value:t.variationsCount?`${t.variationsCount}`:"0",priceModifier:0}};return Zo(t,e,A,a,void 0,r,i,void 0,void 0,n)})(m,A,p,B?.processExecution?.id):await $o(m,A,e,u,B?.sku,w,p,B?.processExecution?.id)},ec=async(t,e)=>{e("workflow.steps.finish.finalize.buildingLayouts");const i=await Promise.all(t.map((async t=>await _o(t.workflowManager,t.workflow,t.layouts,t.getReducerState,t.transaction,t.workflowSelections,t.designName,(()=>Promise.resolve(void 0)),t.workflowMetadata))));e("workflow.steps.finish.finalize.creatingDesign");const n=await(async t=>(await Ia.getShadowGraphqlClient().mutate({mutation:Xo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{inputs:t.map((t=>({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?.designCreateMany)(i.map((t=>t.designDetails)));if(!n)throw new Error("Failed to create designs");return e("workflow.steps.finish.finalize.updatingTransaction"),Promise.all(n.map((async(e,n)=>{const A=t[n],a=i[n],r=e.transaction;return await $o(r,A.product,A.workflow,a.cartSelectionsWithPrices,e.sku,a.cartMetadata,void 0,e.processExecution?.id)})))};let ic;var nc;(nc=ic||(ic={})).Local="Local",nc.Remote="Remote";const Ac=new class{constructor(){Vo(this,"localPersistenceKey","designTransactions"),Vo(this,"storageMethod",ic.Local),Vo(this,"designSavedListeners",[])}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter((e=>e!==t))}async getSavedDesigns(){if(this.storageMethod===ic.Local){const t=da.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new ra("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 i=await this.getSavedDesigns(),n=i.find((e=>e.transactionId===t));if(!n)throw new Error(`No saved design for transaction ${t}.`);n.title=e,await this.setDesigns(i)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter((e=>e.transactionId!==t)))}async setDesigns(t){if(this.storageMethod!==ic.Local)throw new ra("Unexpected storage method requested");da.set(this.localPersistenceKey,JSON.stringify(t))}};function ac(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class rc{constructor(t,e){if(ac(this,"client",void 0),ac(this,"commandContext",void 0),ac(this,"workflowManager",void 0),ac(this,"isReadOnly",void 0),ac(this,"renderableScenes",[]),ac(this,"renderableSceneCallbacks",[]),ac(this,"debouncedSavedDesignUpdate",b(D)((async()=>{await Ac.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),ac(this,"getCanvasObjectURLAsync",(async t=>new Promise(((e,i)=>{try{t.toBlob((t=>{if(t){const i=URL.createObjectURL(t);e(i)}}))}catch(t){i(t)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const i=e.layouts;this.commandContext=new Ln,this.commandContext.initialize(i,e.reloadedState),this.isReadOnly=e.transaction.isOrdered||!!e.readOnly,this.workflowManager=new Mo(e.workflow,e.product.profanities?.map((t=>t.word))||[],i,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 Ia.getShadowGraphqlClient().mutate({mutation:Ls,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 i=this.workflowManager.getWorkflow(),n=i?.finalizeStepConfig?.lookAtAnimation;if(t){if(!n)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,n))||""}const A=document.createElement("canvas");let a=2048;e&&e<=2048&&(a=e),A.width=a,A.height=a;const r=this.commandContext.getAllLayouts(),s=i.defaultPreviewPanelIndex||0,o=i.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=A.getContext("2d");if(!h)throw new ca("Failed to obtain 2D context for preview image creation");const d=jn(g.layoutState.layout,g.layoutState.elements,{renderingConfiguration:{purpose:Ve.Print,region:{left:l.x,top:l.y,width:l.width,height:l.height}}}),u=b(Q).renderToStaticMarkup(d),w=await Re.from(h,u,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await w.render();const B=await this.getCanvasObjectURLAsync(A);return A.toDataURL(B)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t));if(e&&this.stepHasHandle(e))return jo.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:si.Bulk,stepName:"Bulk",stepTitle:t?.stepTitle??"workflow.steps.bulk.title",helpText:t?.helpText,data:{aspects:js(this.getWorkflowManager().getWorkflow())},conditions:[]};return jo.get(this.getWorkflowManager(),e)}}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepTitle===t));if(e&&this.stepHasHandle(e))return jo.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter((e=>e.type===t)).map((t=>jo.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=>jo.get(this.getWorkflowManager(),t)))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){const e=(await Ia.getShadowGraphqlClient().mutate({mutation:No,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=da.getMap("transactionCustomerIds")||new Map;t.set(this.getWorkflowManager().getTransaction().id,e.customer.id),da.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 ra("State undefined!");const e={title:await(async()=>{if(t)return t;const e=this.getWorkflowManager().getTransaction().id,i=(await Ac.getSavedDesigns()).find((t=>t.transactionId===e))?.title;return i||"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 Ac.addDesign(e),e}async copy(){const t=b(e)(this.getCommandContext().getState());if(!t)throw new ra("Internal state is undefined! Cannot copy experience!");const i=JSON.stringify(t.transaction),n=this.getWorkflowManager().getWorkflow(),A=new cl({}),a=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!a)throw new ra("Integration product id is undefined!");await A.initFromIntegrationProduct(a);return await A.getWorkflowExperience(n.id,i,void 0)}async onDesignFinished(t,e=!0){return tc(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=>e?this.createPreviewImage(t):Promise.resolve(void 0)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==si.SilentIllustration&&t.type!==si.ProductOverlay}getExportedData(){const t=new Map,e=this.getWorkflowManager().getWorkflowMetadata(),i=this.getWorkflowManager().getWorkflowSelections();return Object.keys(e).forEach((i=>{const n=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===i));if(!n)return;t.has(n.stepTitle)||t.set(n.stepTitle,{});const A=e[i];Object.keys(A).forEach((e=>{t.get(n.stepTitle)[e]=A[e]}))})),Object.keys(i)?.forEach((e=>{const n=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===e));n&&(t.has(n.stepTitle)||t.set(n.stepTitle,{}),t.get(n.stepTitle).selection=i[e].selections[0].name)})),t}}const sc=v.gql`
642
642
  fragment ProductCollectionProductFields on Product {
643
643
  id
644
644
  basePrice
@@ -673,8 +673,8 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
673
673
  name
674
674
  }
675
675
  }
676
- `,sc=v.gql`
677
- ${rc}
676
+ `,oc=v.gql`
677
+ ${sc}
678
678
  fragment ProductCollectionFields on ProductCollection {
679
679
  id
680
680
  name
@@ -720,8 +720,8 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
720
720
  }
721
721
  }
722
722
  }
723
- `,oc=v.gql`
724
- ${sc}
723
+ `,cc=v.gql`
724
+ ${oc}
725
725
  query GetBundle($id: String!) {
726
726
  bundles(ids: [$id]) {
727
727
  id
@@ -742,7 +742,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
742
742
  }
743
743
  }
744
744
  }
745
- `,cc=v.gql`
745
+ `,lc=v.gql`
746
746
  query GetBundleStakeholders($id: String!) {
747
747
  bundles(ids: [$id]) {
748
748
  id
@@ -754,12 +754,15 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
754
754
  firstName
755
755
  lastName
756
756
  phoneNumber
757
+ partner {
758
+ id
759
+ }
757
760
  }
758
761
  type
759
762
  }
760
763
  }
761
764
  }
762
- `,lc=v.gql`
765
+ `,gc=v.gql`
763
766
  query GetBundlesForCustomer($id: String!) {
764
767
  customers(ids: [$id]) {
765
768
  bundleStakeholders {
@@ -780,8 +783,8 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
780
783
  }
781
784
  }
782
785
  }
783
- `,gc=v.gql`
784
- ${sc}
786
+ `,hc=v.gql`
787
+ ${oc}
785
788
  mutation CreateBundle($collectionId: String) {
786
789
  bundleCreate(collectionId: $collectionId) {
787
790
  id
@@ -799,25 +802,25 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
799
802
  }
800
803
  }
801
804
  }
802
- `,hc=v.gql`
805
+ `,dc=v.gql`
803
806
  mutation UpdateBundle($id: String!, $name: String, $metadata: [MetadataInput!], $bundleStateData: String) {
804
807
  bundleUpdate(id: $id, name: $name, metadata: $metadata, bundleStateData: $bundleStateData) {
805
808
  id
806
809
  }
807
810
  }
808
- `,dc=v.gql`
811
+ `,uc=v.gql`
809
812
  mutation BundleAddTransaction($id: String!, $transactionId: String!) {
810
813
  bundleAddTransaction(id: $id, transactionId: $transactionId) {
811
814
  id
812
815
  }
813
816
  }
814
- `,uc=v.gql`
817
+ `,wc=v.gql`
815
818
  mutation BundleAddTransactions($id: String!, $transactionIds: [String!]!, $transactionOwnerIds: [String!]) {
816
819
  bundleAddTransactions(id: $id, transactionIds: $transactionIds, transactionOwnerIds: $transactionOwnerIds) {
817
820
  id
818
821
  }
819
822
  }
820
- `,wc=v.gql`
823
+ `,Bc=v.gql`
821
824
  mutation BundleRemoveTransaction(
822
825
  $id: String!
823
826
  $transactionId: String!
@@ -832,7 +835,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
832
835
  id
833
836
  }
834
837
  }
835
- `,Bc=v.gql`
838
+ `,pc=v.gql`
836
839
  mutation BundleRemoveTransactions(
837
840
  $id: String!
838
841
  $transactionIds: [String!]!
@@ -847,25 +850,53 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
847
850
  id
848
851
  }
849
852
  }
850
- `,pc=v.gql`
853
+ `,mc=v.gql`
851
854
  mutation BundleAddStakeholder($id: String!, $details: CustomerDetailsInput!, $type: String!) {
852
855
  bundleAddStakeholder(id: $id, details: $details, type: $type) {
853
856
  id
857
+ bundleStakeholders {
858
+ id
859
+ customer {
860
+ id
861
+ emailAddress
862
+ firstName
863
+ lastName
864
+ phoneNumber
865
+ partner {
866
+ id
867
+ }
868
+ }
869
+ type
870
+ }
854
871
  }
855
872
  }
856
- `,mc=v.gql`
873
+ `,Ec=v.gql`
857
874
  mutation BundleUpdateStakeholders($id: String!, $input: [BundleStakeholderInput!]!) {
858
875
  bundleUpdateStakeholders(id: $id, input: $input) {
859
876
  id
877
+ bundleStakeholders {
878
+ id
879
+ customer {
880
+ id
881
+ emailAddress
882
+ firstName
883
+ lastName
884
+ phoneNumber
885
+ partner {
886
+ id
887
+ }
888
+ }
889
+ type
890
+ }
860
891
  }
861
892
  }
862
- `,Ec=v.gql`
893
+ `,fc=v.gql`
863
894
  mutation BundleUpdateTransactionOrder($id: String!, $transactionIds: [String!]!) {
864
895
  bundleUpdateTransactionOrder(id: $id, transactionIds: $transactionIds) {
865
896
  id
866
897
  }
867
898
  }
868
- `;function fc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Cc{constructor(t){fc(this,"bundle",void 0),fc(this,"handleCache",{}),this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){if(!this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration)return[];const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map((t=>this.getHandle(t))))}applyConditionsFromState(t,e){return e?t.filter((t=>this.aspectConditionsSatisfied(t.getRawProperty(),e))):t}aspectConditionsSatisfied(t,e){return!t.conditions||0===t.conditions.length||t.conditions.some((t=>{const i=e.aspects.find((e=>e.name===t.targetAspectName));return!!i&&t.requiredVariantSelections.some((t=>t===i.value))}))}async createHandle(t){switch(t.type){case ei.FileUpload:return new yc(this.bundle,t);case ei.Option:{const e=t.entityId?await Ja.getOption(t.entityId):void 0;return"Color"===e?.type?new xc(this.bundle,t,e):new Dc(this.bundle,t,e)}case ei.Text:return new Ic(this.bundle,t)}}}class Qc{constructor(t,e){fc(this,"bundle",void 0),fc(this,"property",void 0),this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap((t=>t.getSteps().filter((t=>t.getRaw().globalPropertyAspectConfigurations?.some((t=>t.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&t.aspectName===this.property.name))))))}}class yc extends Qc{constructor(t,e){super(t,e)}async selectImage(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),this.applyImageSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const i=await ka.getLocalOrFromServer(e);return i?this.applyImageSelection(i,t):Promise.resolve()}async applyImageSelection(t,e){const i=this.getSharedSteps(e).map((e=>e.selectImage(t)));await Promise.all(i)}}class Ic extends Qc{constructor(t,e){super(t,e)}getText(){const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const i=this.getSharedSteps(e).map((e=>{e.setText(t)}));await Promise.all(i)}}class Dc extends Qc{constructor(t,e,i){super(t,e),fc(this,"optionResource",void 0),this.optionResource=i}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!t)return;const e=this.optionResource.variants?.find((e=>e.id===t));return e?new bo(e):void 0}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new bo(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new bo(t)))}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const i=this.optionResource?.variants?.find((t=>t.id===e));return i?this.applyVariantSelection(new bo(i),t):Promise.resolve()}async applyVariantSelection(t,e){const i=this.getSharedSteps(e).map((e=>e.selectVariant(t)));await Promise.all(i)}}class xc extends Dc{constructor(t,e,i){super(t,e,i)}setCustomColor(t){this.getSharedSteps().forEach((e=>e.setCustomColor(t)))}getCustomColor(){return this.getSharedSteps()[0].getCustomColor()}}const vc=v.gql`
899
+ `;function Cc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Qc{constructor(t){Cc(this,"bundle",void 0),Cc(this,"handleCache",{}),this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){if(!this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration)return[];const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map((t=>this.getHandle(t))))}applyConditionsFromState(t,e){return e?t.filter((t=>this.aspectConditionsSatisfied(t.getRawProperty(),e))):t}aspectConditionsSatisfied(t,e){return!t.conditions||0===t.conditions.length||t.conditions.some((t=>{const i=e.aspects.find((e=>e.name===t.targetAspectName));return!!i&&t.requiredVariantSelections.some((t=>t===i.value))}))}async createHandle(t){switch(t.type){case ei.FileUpload:return new Ic(this.bundle,t);case ei.Option:{const e=t.entityId?await Ja.getOption(t.entityId):void 0;return"Color"===e?.type?new vc(this.bundle,t,e):new xc(this.bundle,t,e)}case ei.Text:return new Dc(this.bundle,t)}}}class yc{constructor(t,e){Cc(this,"bundle",void 0),Cc(this,"property",void 0),this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap((t=>t.getSteps().filter((t=>t.getRaw().globalPropertyAspectConfigurations?.some((t=>t.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&t.aspectName===this.property.name))))))}}class Ic extends yc{constructor(t,e){super(t,e)}async selectImage(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),this.applyImageSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const i=await ka.getLocalOrFromServer(e);return i?this.applyImageSelection(i,t):Promise.resolve()}async applyImageSelection(t,e){const i=this.getSharedSteps(e).map((e=>e.selectImage(t)));await Promise.all(i)}}class Dc extends yc{constructor(t,e){super(t,e)}getText(){const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const i=this.getSharedSteps(e).map((e=>{e.setText(t)}));await Promise.all(i)}}class xc extends yc{constructor(t,e,i){super(t,e),Cc(this,"optionResource",void 0),this.optionResource=i}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!t)return;const e=this.optionResource.variants?.find((e=>e.id===t));return e?new bo(e):void 0}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new bo(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new bo(t)))}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const i=this.optionResource?.variants?.find((t=>t.id===e));return i?this.applyVariantSelection(new bo(i),t):Promise.resolve()}async applyVariantSelection(t,e){const i=this.getSharedSteps(e).map((e=>e.selectVariant(t)));await Promise.all(i)}}class vc extends xc{constructor(t,e,i){super(t,e,i)}setCustomColor(t){this.getSharedSteps().forEach((e=>e.setCustomColor(t)))}getCustomColor(){return this.getSharedSteps()[0].getCustomColor()}}const Mc=v.gql`
869
900
  mutation CreateGlobalPropertyState($bundleId: String!) {
870
901
  globalPropertyStateCreate(bundleId: $bundleId) {
871
902
  id
@@ -875,7 +906,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
875
906
  }
876
907
  }
877
908
  }
878
- `,Mc=v.gql`
909
+ `,Sc=v.gql`
879
910
  mutation UpdateGlobalPropertyState($id: String!, $aspects: [GlobalPropertyStateAspectInput]!) {
880
911
  globalPropertyStateUpdate(id: $id, aspects: $aspects) {
881
912
  id
@@ -885,7 +916,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
885
916
  }
886
917
  }
887
918
  }
888
- `,Sc=v.gql`
919
+ `,bc=v.gql`
889
920
  query GetGlobalPropertyState($bundleId: String!) {
890
921
  globalPropertyState(bundleId: $bundleId) {
891
922
  id
@@ -895,7 +926,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
895
926
  }
896
927
  }
897
928
  }
898
- `;function bc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Fc{constructor(t,e){bc(this,"bundleId",void 0),bc(this,"globalPropertyState",void 0),bc(this,"onGlobalPropertyStateChange",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t)),this.onGlobalPropertyStateChange=e}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((e=>e.name===t));if(e)return e.value}async setAspect(t,i){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const n=b(e)(this.globalPropertyState),A=this.globalPropertyState.aspects.find((e=>e.name===t));A?A.value=i:this.globalPropertyState.aspects.push({name:t,value:i}),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(n,this.globalPropertyState)}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await Ia.getShadowGraphqlClient().mutate({mutation:Mc,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await Ia.getShadowGraphqlClient().query({query:Sc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const e=await Ia.getShadowGraphqlClient().mutate({mutation:vc,variables:{bundleId:this.bundleId}});if(e.data?.globalPropertyStateCreate&&e.data.globalPropertyStateCreate.id)return e.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function Pc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Yc{constructor(t){Pc(this,"state",void 0),this.setState(t)}setState(t){t&&(this.state=JSON.parse(t))}applyStateToWorkflowExperience(t){if(!this.state||!t?.getWorkflowManager()?.getModelContainer())return;const e=this.state.transactions.find((e=>e.transactionId===t.getWorkflowManager().getTransaction().id&&e.transform))?.transform;if(!e)return;const i=t.getWorkflowManager().getModelContainer();i.position=e.position,i.rotation={x:e.rotation.x*Math.PI/180,y:e.rotation.y*Math.PI/180,z:e.rotation.z*Math.PI/180},i.scale=e.scale}setWorkflowExperienceTransform(t,e){if(!t?.getWorkflowManager()?.getModelContainer())return;const i=t.getWorkflowManager().getModelContainer();i.position=e.position,i.rotation={x:e.rotation.x*Math.PI/180,y:e.rotation.y*Math.PI/180,z:e.rotation.z*Math.PI/180},i.scale=e.scale;const n=t.getWorkflowManager().getTransaction().id;this.state?this.state.transactions||(this.state.transactions=[]):this.state={transactions:[]};const A=this.state.transactions.find((t=>t.transactionId===n));A?A.transform=e:this.state.transactions.push({transactionId:n,transform:e})}removeStateForTransaction(t){if(!this.state||!this.state.transactions)return;const e=this.state.transactions.findIndex((e=>e.transactionId===t));-1!==e&&this.state.transactions.splice(e,1)}getSerializedState(){if(this.state)return JSON.stringify(this.state)}}function Nc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class kc{constructor(t){Nc(this,"collection",void 0),this.collection=t}getId(){return this.collection.id}getName(){return this.collection.name}getProducts(){return this.collection.products.map((t=>new Rc(t)))}getResource(){return this.collection}}class Rc{constructor(t){Nc(this,"product",void 0),this.product=t}getId(){return this.product.id}getName(){return this.product.name}getIntegrationByType(t){const e=(this.product.integrationProducts||[]).find((e=>!!e.integration?.type&&e.integration?.type===t));if(!e)throw new Error("Failed to find requested integration type on product. This is generally due to a configuration error");return e}getIntegrations(){return this.product.integrationProducts||[]}getResource(){return this.product}}function Hc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Uc{constructor(t,e,i,n){Hc(this,"client",void 0),Hc(this,"id",void 0),Hc(this,"name",void 0),Hc(this,"metadata",void 0),Hc(this,"productCollection",void 0),Hc(this,"bundleStateManager",void 0),Hc(this,"globalConfiguration",void 0),Hc(this,"globalPropertyStateManager",void 0),Hc(this,"globalPropertyHandleService",void 0),Hc(this,"eventListeners",new Map),Hc(this,"initializationPromise",void 0),Hc(this,"workflowExperiences",[]),Hc(this,"previewService",void 0),this.client=t,this.id=e.id,this.name=e.name||"",this.metadata=new Map(e.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=e.productCollection,this.bundleStateManager=new Yc(e.bundleStateData),this.globalConfiguration=this.productCollection?.globalPropertyConfiguration,this.globalPropertyStateManager=new Fc(this.id,this.checkConditionalHandlesChanged.bind(this)),this.globalPropertyHandleService=new Cc(this),this.setPreviewService(i),this.initializationPromise=this.loadExistingBundles(e.transactions?.map((t=>t.id))||[],n)}getInitializationPromise(){return this.initializationPromise}addEventListener(t,e){this.eventListeners.set(t,[...this.eventListeners.get(t)||[],e])}removeEventListener(t,e){const i=this.eventListeners.get(t)||[],n=i.indexOf(e);n>-1&&i.splice(n,1)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,e){return this.name=t,this.metadata=new Map(e),this.updateBundle()}hasGlobalProperties(){return!!this.globalConfiguration&&this.globalConfiguration.aspects.length>0}async getGlobalProperties(){return this.globalPropertyHandleService.applyConditionsFromState(await this.globalPropertyHandleService.getHandles(),this.getGlobalPropertyStateManager().getGlobalPropertyState())}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}async getGlobalPropertyTotalSubunits(){return(await this.globalPropertyHandleService.getHandles()).filter((t=>t.getType()===ei.Option)).map((t=>t.getCurrentVariant()?.getPrice()||0)).reduce(((t,e)=>t+e),0)}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,e)=>t+e),0)}getProductCollection(){return this.productCollection?new kc(this.productCollection):void 0}async addWorkflowExperience(t){await this.appendWorkflowExperience(t),await this.injectExperienceIntoPreviewService(t);const e=await this.getGlobalProperties();await Promise.all(e.map((e=>e.applyGlobalState([t]))))}async addWorkflowExperiences(t){const e=t.map((t=>t.getWorkflowManager().getTransaction().id)),i=e.map((t=>this.workflowExperiences.find((e=>e.getWorkflowManager().getTransaction().id===t))));if(i.some((t=>!!t)))throw new Error("Unable to add transaction to bundle - Already Exists: "+i.filter((t=>!!t)).map((t=>t?.getWorkflowManager().getTransaction().id)).join(", "));const n=da.getMap("transactionOwnerIds")||new Map,A=e.map((t=>n.get(t)));await Ia.getShadowGraphqlClient().mutate({mutation:uc,variables:{id:this.id,transactionIds:e,transactionOwnerIds:A}}).catch((t=>{console.error(t)})),this.workflowExperiences.push(...t),await Promise.all([this.updateTransactionOrder(),(async()=>{for(const e of t)await this.injectExperienceIntoPreviewService(e);const e=await this.getGlobalProperties();await Promise.all(e.map((e=>e.applyGlobalState(t))))})()])}async appendWorkflowExperience(t,e=!0){const i=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===i)))throw new Error("Unable to add transaction to bundle - Already Exists!");const n=(da.getMap("transactionOwnerIds")||new Map).get(i);await Ia.getShadowGraphqlClient().mutate({mutation:dc,variables:{id:this.id,transactionId:i},context:{transactionOwnerId:n}}),e&&this.workflowExperiences.push(t)}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);await this.removeTransaction(e,this.workflowExperiences[e].getWorkflowManager().getTransaction())}async removeWorkflowExperiences(t){await this.removeTransactions(t.map((t=>t.getWorkflowManager().getTransaction())))}async removeWorkflowExperienceByTransaction(t){const e=this.workflowExperiences.findIndex((e=>e.getWorkflowManager().getTransaction().id===t.id));await this.removeTransaction(e,t)}async removeWorkflowExperiencesByTransactions(t){await this.removeTransactions(t)}async removeTransaction(t,e,i=!0){if(!(t>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found! - "+e.id);{const n=this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===e.id));this.previewService&&n.getWorkflowManager().ejectFromPreviewService(),this.bundleStateManager.removeStateForTransaction(e.id),await Ia.getShadowGraphqlClient().mutate({mutation:wc,variables:{id:this.id,transactionId:e.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,e])=>({key:t,value:e}))),bundleStateData:this.bundleStateManager.getSerializedState()}}),i&&(this.workflowExperiences.splice(t,1),await this.updateTransactionOrder())}}async removeTransactions(t){const e=t.map((t=>this.workflowExperiences.findIndex((e=>e.getWorkflowManager().getTransaction().id===t.id))));if(e.some((t=>-1===t)))throw new Error("Unable to remove workflow experience from bundle - The following aren't included in the bundle: "+t.filter(((t,i)=>-1===e[i])).map((t=>t.id)).join(", "));const i=t.map((t=>this.workflowExperiences.splice(this.workflowExperiences.findIndex((e=>e.getWorkflowManager().getTransaction().id===t.id)),1)[0]));this.previewService&&i.forEach((t=>t.getWorkflowManager().ejectFromPreviewService())),t.forEach((t=>this.bundleStateManager.removeStateForTransaction(t.id))),await Ia.getShadowGraphqlClient().mutate({mutation:Bc,variables:{id:this.id,transactionIds:t.map((t=>t.id)),name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,e])=>({key:t,value:e}))),bundleStateData:this.bundleStateManager.getSerializedState()}}),await this.updateTransactionOrder()}async insertWorkflowExperience(t,e){await this.appendWorkflowExperience(t,!1),this.workflowExperiences.splice(e,0,t),await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(t);const e=await this.getGlobalProperties();await Promise.all(e.map((e=>e.applyGlobalState([t]))))})()])}async replaceWorkflowExperience(t,e){if(t<0||t>=this.workflowExperiences.length)throw new Error("Unable to replace workflow experience in bundle - Index out of range!");const i=this.workflowExperiences[t];if(i.getWorkflowManager().getTransaction().id===e.getWorkflowManager().getTransaction().id)throw new Error("Unable to replace workflow experience in bundle - Same transaction!");await Promise.all([this.removeTransaction(t,i.getWorkflowManager().getTransaction(),!1),this.appendWorkflowExperience(e,!1)]),this.workflowExperiences[t]=e,await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(e);const t=await this.getGlobalProperties();await Promise.all(t.map((t=>t.applyGlobalState([e]))))})()])}async swapWorkflowExperiences(t,e){if(t<0||t>=this.workflowExperiences.length||e<0||e>=this.workflowExperiences.length)throw new Error("Unable to swap workflow experiences in bundle - Index out of range!");if(t===e)return;const i=this.workflowExperiences[t];this.workflowExperiences[t]=this.workflowExperiences[e],this.workflowExperiences[e]=i,await this.updateTransactionOrder()}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await this.updateTransactionOrder()}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,e){await Ia.getShadowGraphqlClient().mutate({mutation:pc,variables:{id:this.id,details:t,type:e||gr.Owner}})}async updateStakeholders(t){await Ia.getShadowGraphqlClient().mutate({mutation:mc,variables:{id:this.id,input:t}})}async getAllStakeholders(){const t=await Ia.getShadowGraphqlClient().query({query:cc,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");return t.data.bundles[0].bundleStakeholders||[]}async finish(t){return await tc(this.workflowExperiences.map((t=>({workflowManager:t.getWorkflowManager(),workflow:t.getWorkflowManager().getWorkflow(),layouts:t.getWorkflowManager().getLayouts(),getReducerState:()=>t.getCommandContext().getState(),product:t.getWorkflowManager().getProduct(),transaction:t.getWorkflowManager().getTransaction(),workflowSelections:t.getWorkflowManager().getWorkflowSelections(),designName:t.getWorkflowManager().getWorkflow().name,variationRecords:t.getWorkflowManager().getVariationRecords(),updateVariationRecords:e=>t.updateVariationRecords(e),workflowMetadata:t.getWorkflowManager().getWorkflowMetadata()}))),t??(()=>{}))}getPreviewService(){return this.previewService}async setPreviewService(t){if(this.workflowExperiences&&this.workflowExperiences.length>0&&(this.workflowExperiences.forEach((t=>t.getWorkflowManager().ejectFromPreviewService())),t))for(const t of this.workflowExperiences)await this.injectExperienceIntoPreviewService(t);t&&t.registerModelLoadEventListener&&t.registerModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService&&this.previewService!==t&&this.previewService.unregisterModelLoadEventListener&&this.previewService.unregisterModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService=t}setWorkflowExperienceTransform(t,e){return this.bundleStateManager.setWorkflowExperienceTransform(t,e),this.updateBundle()}onModelLoadEvent(t){"unload"!==t.eventType&&t.modelContainer&&(t.modelContainer.registerMaterialSelectedCallback((()=>this.onModelSelectedEvent(t.modelContainer,!0))),t.modelContainer.registerMaterialDeselectedCallback((()=>this.onModelSelectedEvent(t.modelContainer,!1))))}onModelSelectedEvent(t,e){if(t&&t.metadata&&t.metadata instanceof Map&&t.metadata.has("workflowManager")){const i=t.metadata.get("workflowManager").getTransaction(),n=this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===i.id));n&&this.fireEvent(e?"workflow-experience-hover-enter":"workflow-experience-hover-exit",{workflowExperience:n})}}async injectExperienceIntoPreviewService(t){if(this.previewService){const e=t.getWorkflowManager().injectIntoPreviewService(this.previewService);try{this.bundleStateManager.applyStateToWorkflowExperience(t)}catch(t){console.error(`Unable to apply state to workflow experience: ${t}`)}await e}}async loadExistingBundles(t,e){if(0===t.length)return;const i=await this.client.getWorkflowExperiences(t.map((t=>({type:"transaction",transactionId:t}))),e);if(this.workflowExperiences=i,this.previewService)for(const t of i)await this.injectExperienceIntoPreviewService(t)}async updateBundle(){if(!(await Ia.getShadowGraphqlClient().mutate({mutation:hc,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,e])=>({key:t,value:e}))),bundleStateData:this.bundleStateManager.getSerializedState()}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async updateTransactionOrder(){await Ia.getShadowGraphqlClient().mutate({mutation:Ec,variables:{id:this.id,transactionIds:this.workflowExperiences.map((t=>t.getWorkflowManager().getTransaction().id))}})}async checkConditionalHandlesChanged(t,e){const i=await this.globalPropertyHandleService.getHandles(),n=this.globalPropertyHandleService.applyConditionsFromState(i,t),A=this.globalPropertyHandleService.applyConditionsFromState(i,e);(()=>{if(n.length!==A.length)return!0;for(let t=0;t<n.length;t++)if(n[t].getName()!==A[t].getName())return!0;return!1})()&&this.fireEvent("conditional-global-properties-changed",{globalProperties:A})}fireEvent(t,e){(this.eventListeners.get(t)||[]).forEach((i=>i({bundle:this,event:t,data:e})))}}function Gc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Tc=t.gql`
929
+ `;function Fc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Pc{constructor(t,e){Fc(this,"bundleId",void 0),Fc(this,"globalPropertyState",void 0),Fc(this,"onGlobalPropertyStateChange",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t)),this.onGlobalPropertyStateChange=e}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((e=>e.name===t));if(e)return e.value}async setAspect(t,i){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const n=b(e)(this.globalPropertyState),A=this.globalPropertyState.aspects.find((e=>e.name===t));A?A.value=i:this.globalPropertyState.aspects.push({name:t,value:i}),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(n,this.globalPropertyState)}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await Ia.getShadowGraphqlClient().mutate({mutation:Sc,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await Ia.getShadowGraphqlClient().query({query:bc,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const e=await Ia.getShadowGraphqlClient().mutate({mutation:Mc,variables:{bundleId:this.bundleId}});if(e.data?.globalPropertyStateCreate&&e.data.globalPropertyStateCreate.id)return e.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function Yc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Nc{constructor(t){Yc(this,"state",void 0),this.setState(t)}setState(t){t&&(this.state=JSON.parse(t))}applyStateToWorkflowExperience(t){if(!this.state||!t?.getWorkflowManager()?.getModelContainer())return;const e=this.state.transactions.find((e=>e.transactionId===t.getWorkflowManager().getTransaction().id&&e.transform))?.transform;if(!e)return;const i=t.getWorkflowManager().getModelContainer();i.position=e.position,i.rotation={x:e.rotation.x*Math.PI/180,y:e.rotation.y*Math.PI/180,z:e.rotation.z*Math.PI/180},i.scale=e.scale}setWorkflowExperienceTransform(t,e){if(!t?.getWorkflowManager()?.getModelContainer())return;const i=t.getWorkflowManager().getModelContainer();i.position=e.position,i.rotation={x:e.rotation.x*Math.PI/180,y:e.rotation.y*Math.PI/180,z:e.rotation.z*Math.PI/180},i.scale=e.scale;const n=t.getWorkflowManager().getTransaction().id;this.state?this.state.transactions||(this.state.transactions=[]):this.state={transactions:[]};const A=this.state.transactions.find((t=>t.transactionId===n));A?A.transform=e:this.state.transactions.push({transactionId:n,transform:e})}removeStateForTransaction(t){if(!this.state||!this.state.transactions)return;const e=this.state.transactions.findIndex((e=>e.transactionId===t));-1!==e&&this.state.transactions.splice(e,1)}getSerializedState(){if(this.state)return JSON.stringify(this.state)}}function kc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Rc{constructor(t){kc(this,"collection",void 0),this.collection=t}getId(){return this.collection.id}getName(){return this.collection.name}getProducts(){return this.collection.products.map((t=>new Hc(t)))}getResource(){return this.collection}}class Hc{constructor(t){kc(this,"product",void 0),this.product=t}getId(){return this.product.id}getName(){return this.product.name}getIntegrationByType(t){const e=(this.product.integrationProducts||[]).find((e=>!!e.integration?.type&&e.integration?.type===t));if(!e)throw new Error("Failed to find requested integration type on product. This is generally due to a configuration error");return e}getIntegrations(){return this.product.integrationProducts||[]}getResource(){return this.product}}function Uc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Gc{constructor(t,e,i,n){Uc(this,"client",void 0),Uc(this,"id",void 0),Uc(this,"name",void 0),Uc(this,"metadata",void 0),Uc(this,"productCollection",void 0),Uc(this,"bundleStateManager",void 0),Uc(this,"globalConfiguration",void 0),Uc(this,"globalPropertyStateManager",void 0),Uc(this,"globalPropertyHandleService",void 0),Uc(this,"eventListeners",new Map),Uc(this,"initializationPromise",void 0),Uc(this,"workflowExperiences",[]),Uc(this,"previewService",void 0),this.client=t,this.id=e.id,this.name=e.name||"",this.metadata=new Map(e.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=e.productCollection,this.bundleStateManager=new Nc(e.bundleStateData),this.globalConfiguration=this.productCollection?.globalPropertyConfiguration,this.globalPropertyStateManager=new Pc(this.id,this.checkConditionalHandlesChanged.bind(this)),this.globalPropertyHandleService=new Qc(this),this.setPreviewService(i),this.initializationPromise=this.loadExistingBundles(e.transactions?.map((t=>t.id))||[],n)}getInitializationPromise(){return this.initializationPromise}addEventListener(t,e){this.eventListeners.set(t,[...this.eventListeners.get(t)||[],e])}removeEventListener(t,e){const i=this.eventListeners.get(t)||[],n=i.indexOf(e);n>-1&&i.splice(n,1)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,e){return this.name=t,this.metadata=new Map(e),this.updateBundle()}hasGlobalProperties(){return!!this.globalConfiguration&&this.globalConfiguration.aspects.length>0}async getGlobalProperties(){return this.globalPropertyHandleService.applyConditionsFromState(await this.globalPropertyHandleService.getHandles(),this.getGlobalPropertyStateManager().getGlobalPropertyState())}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}async getGlobalPropertyTotalSubunits(){return(await this.globalPropertyHandleService.getHandles()).filter((t=>t.getType()===ei.Option)).map((t=>t.getCurrentVariant()?.getPrice()||0)).reduce(((t,e)=>t+e),0)}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,e)=>t+e),0)}getProductCollection(){return this.productCollection?new Rc(this.productCollection):void 0}async addWorkflowExperience(t){await this.appendWorkflowExperience(t),await this.injectExperienceIntoPreviewService(t);const e=await this.getGlobalProperties();await Promise.all(e.map((e=>e.applyGlobalState([t]))))}async addWorkflowExperiences(t){const e=t.map((t=>t.getWorkflowManager().getTransaction().id)),i=e.map((t=>this.workflowExperiences.find((e=>e.getWorkflowManager().getTransaction().id===t))));if(i.some((t=>!!t)))throw new Error("Unable to add transaction to bundle - Already Exists: "+i.filter((t=>!!t)).map((t=>t?.getWorkflowManager().getTransaction().id)).join(", "));const n=da.getMap("transactionOwnerIds")||new Map,A=e.map((t=>n.get(t)));await Ia.getShadowGraphqlClient().mutate({mutation:wc,variables:{id:this.id,transactionIds:e,transactionOwnerIds:A}}).catch((t=>{console.error(t)})),this.workflowExperiences.push(...t),await Promise.all([this.updateTransactionOrder(),(async()=>{for(const e of t)await this.injectExperienceIntoPreviewService(e);const e=await this.getGlobalProperties();await Promise.all(e.map((e=>e.applyGlobalState(t))))})()])}async appendWorkflowExperience(t,e=!0){const i=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===i)))throw new Error("Unable to add transaction to bundle - Already Exists!");const n=(da.getMap("transactionOwnerIds")||new Map).get(i);await Ia.getShadowGraphqlClient().mutate({mutation:uc,variables:{id:this.id,transactionId:i},context:{transactionOwnerId:n}}),e&&this.workflowExperiences.push(t)}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);await this.removeTransaction(e,this.workflowExperiences[e].getWorkflowManager().getTransaction())}async removeWorkflowExperiences(t){await this.removeTransactions(t.map((t=>t.getWorkflowManager().getTransaction())))}async removeWorkflowExperienceByTransaction(t){const e=this.workflowExperiences.findIndex((e=>e.getWorkflowManager().getTransaction().id===t.id));await this.removeTransaction(e,t)}async removeWorkflowExperiencesByTransactions(t){await this.removeTransactions(t)}async removeTransaction(t,e,i=!0){if(!(t>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found! - "+e.id);{const n=this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===e.id));this.previewService&&n.getWorkflowManager().ejectFromPreviewService(),this.bundleStateManager.removeStateForTransaction(e.id),await Ia.getShadowGraphqlClient().mutate({mutation:Bc,variables:{id:this.id,transactionId:e.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,e])=>({key:t,value:e}))),bundleStateData:this.bundleStateManager.getSerializedState()}}),i&&(this.workflowExperiences.splice(t,1),await this.updateTransactionOrder())}}async removeTransactions(t){const e=t.map((t=>this.workflowExperiences.findIndex((e=>e.getWorkflowManager().getTransaction().id===t.id))));if(e.some((t=>-1===t)))throw new Error("Unable to remove workflow experience from bundle - The following aren't included in the bundle: "+t.filter(((t,i)=>-1===e[i])).map((t=>t.id)).join(", "));const i=t.map((t=>this.workflowExperiences.splice(this.workflowExperiences.findIndex((e=>e.getWorkflowManager().getTransaction().id===t.id)),1)[0]));this.previewService&&i.forEach((t=>t.getWorkflowManager().ejectFromPreviewService())),t.forEach((t=>this.bundleStateManager.removeStateForTransaction(t.id))),await Ia.getShadowGraphqlClient().mutate({mutation:pc,variables:{id:this.id,transactionIds:t.map((t=>t.id)),name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,e])=>({key:t,value:e}))),bundleStateData:this.bundleStateManager.getSerializedState()}}),await this.updateTransactionOrder()}async insertWorkflowExperience(t,e){await this.appendWorkflowExperience(t,!1),this.workflowExperiences.splice(e,0,t),await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(t);const e=await this.getGlobalProperties();await Promise.all(e.map((e=>e.applyGlobalState([t]))))})()])}async replaceWorkflowExperience(t,e){if(t<0||t>=this.workflowExperiences.length)throw new Error("Unable to replace workflow experience in bundle - Index out of range!");const i=this.workflowExperiences[t];if(i.getWorkflowManager().getTransaction().id===e.getWorkflowManager().getTransaction().id)throw new Error("Unable to replace workflow experience in bundle - Same transaction!");await Promise.all([this.removeTransaction(t,i.getWorkflowManager().getTransaction(),!1),this.appendWorkflowExperience(e,!1)]),this.workflowExperiences[t]=e,await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(e);const t=await this.getGlobalProperties();await Promise.all(t.map((t=>t.applyGlobalState([e]))))})()])}async swapWorkflowExperiences(t,e){if(t<0||t>=this.workflowExperiences.length||e<0||e>=this.workflowExperiences.length)throw new Error("Unable to swap workflow experiences in bundle - Index out of range!");if(t===e)return;const i=this.workflowExperiences[t];this.workflowExperiences[t]=this.workflowExperiences[e],this.workflowExperiences[e]=i,await this.updateTransactionOrder()}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await this.updateTransactionOrder()}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,e){const i=await Ia.getShadowGraphqlClient().mutate({mutation:mc,variables:{id:this.id,details:t,type:e||gr.Owner}});if(!i.data?.bundleAddStakeholder)throw new Error("Bundle not found!");const n=i.data.bundleAddStakeholder.bundleStakeholders||[];this.storeStakeholderCustomers(n)}async updateStakeholders(t){const e=await Ia.getShadowGraphqlClient().mutate({mutation:Ec,variables:{id:this.id,input:t}});if(!e.data?.bundleUpdateStakeholders)throw new Error("Bundle not found!");const i=e.data.bundleUpdateStakeholders.bundleStakeholders||[];this.storeStakeholderCustomers(i)}async getAllStakeholders(){const t=await Ia.getShadowGraphqlClient().query({query:lc,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");const e=t.data.bundles[0].bundleStakeholders||[];return this.storeStakeholderCustomers(e),e}storeStakeholderCustomers(t){t.forEach((t=>{t.customer&&this.client.storeCustomer(t.customer)}))}async finish(t){return await ec(this.workflowExperiences.map((t=>({workflowManager:t.getWorkflowManager(),workflow:t.getWorkflowManager().getWorkflow(),layouts:t.getWorkflowManager().getLayouts(),getReducerState:()=>t.getCommandContext().getState(),product:t.getWorkflowManager().getProduct(),transaction:t.getWorkflowManager().getTransaction(),workflowSelections:t.getWorkflowManager().getWorkflowSelections(),designName:t.getWorkflowManager().getWorkflow().name,variationRecords:t.getWorkflowManager().getVariationRecords(),updateVariationRecords:e=>t.updateVariationRecords(e),workflowMetadata:t.getWorkflowManager().getWorkflowMetadata()}))),t??(()=>{}))}getPreviewService(){return this.previewService}async setPreviewService(t){if(this.workflowExperiences&&this.workflowExperiences.length>0&&(this.workflowExperiences.forEach((t=>t.getWorkflowManager().ejectFromPreviewService())),t))for(const t of this.workflowExperiences)await this.injectExperienceIntoPreviewService(t);t&&t.registerModelLoadEventListener&&t.registerModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService&&this.previewService!==t&&this.previewService.unregisterModelLoadEventListener&&this.previewService.unregisterModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService=t}setWorkflowExperienceTransform(t,e){return this.bundleStateManager.setWorkflowExperienceTransform(t,e),this.updateBundle()}onModelLoadEvent(t){"unload"!==t.eventType&&t.modelContainer&&(t.modelContainer.registerMaterialSelectedCallback((()=>this.onModelSelectedEvent(t.modelContainer,!0))),t.modelContainer.registerMaterialDeselectedCallback((()=>this.onModelSelectedEvent(t.modelContainer,!1))))}onModelSelectedEvent(t,e){if(t&&t.metadata&&t.metadata instanceof Map&&t.metadata.has("workflowManager")){const i=t.metadata.get("workflowManager").getTransaction(),n=this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===i.id));n&&this.fireEvent(e?"workflow-experience-hover-enter":"workflow-experience-hover-exit",{workflowExperience:n})}}async injectExperienceIntoPreviewService(t){if(this.previewService){const e=t.getWorkflowManager().injectIntoPreviewService(this.previewService);try{this.bundleStateManager.applyStateToWorkflowExperience(t)}catch(t){console.error(`Unable to apply state to workflow experience: ${t}`)}await e}}async loadExistingBundles(t,e){if(0===t.length)return;const i=await this.client.getWorkflowExperiences(t.map((t=>({type:"transaction",transactionId:t}))),e);if(this.workflowExperiences=i,this.previewService)for(const t of i)await this.injectExperienceIntoPreviewService(t)}async updateBundle(){if(!(await Ia.getShadowGraphqlClient().mutate({mutation:dc,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,e])=>({key:t,value:e}))),bundleStateData:this.bundleStateManager.getSerializedState()}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async updateTransactionOrder(){await Ia.getShadowGraphqlClient().mutate({mutation:fc,variables:{id:this.id,transactionIds:this.workflowExperiences.map((t=>t.getWorkflowManager().getTransaction().id))}})}async checkConditionalHandlesChanged(t,e){const i=await this.globalPropertyHandleService.getHandles(),n=this.globalPropertyHandleService.applyConditionsFromState(i,t),A=this.globalPropertyHandleService.applyConditionsFromState(i,e);(()=>{if(n.length!==A.length)return!0;for(let t=0;t<n.length;t++)if(n[t].getName()!==A[t].getName())return!0;return!1})()&&this.fireEvent("conditional-global-properties-changed",{globalProperties:A})}fireEvent(t,e){(this.eventListeners.get(t)||[]).forEach((i=>i({bundle:this,event:t,data:e})))}}function Tc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Oc=t.gql`
899
930
  mutation processFlowCreate($processFlowId: String!, $inputs: [String]!) {
900
931
  processExecutionCreate(processFlowId: $processFlowId, inputs: $inputs) {
901
932
  id
@@ -905,7 +936,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
905
936
  }
906
937
  }
907
938
  }
908
- `;class Oc{async execute(e,i,n){if(!(await Ia.getShadowGraphqlClient().mutate({mutation:Tc,variables:{processFlowId:e,inputs:[...i.map((t=>t.getValueForTransmission()))]}})).data?.processExecutionCreate?.id)throw new Error("Failed to create process execution.");function A(t){return new Promise((e=>{setTimeout(e,t)}))}let a,r=!1,s=0;for(;!r;){if(await A(n?.sleepTime?Math.max(n.sleepTime,500):2e3),a=await Ia.getShadowGraphqlClient().query({query:t.gql`
939
+ `;class Jc{async execute(e,i,n){if(!(await Ia.getShadowGraphqlClient().mutate({mutation:Oc,variables:{processFlowId:e,inputs:[...i.map((t=>t.getValueForTransmission()))]}})).data?.processExecutionCreate?.id)throw new Error("Failed to create process execution.");function A(t){return new Promise((e=>{setTimeout(e,t)}))}let a,r=!1,s=0;for(;!r;){if(await A(n?.sleepTime?Math.max(n.sleepTime,500):2e3),a=await Ia.getShadowGraphqlClient().query({query:t.gql`
909
940
  query getProcessFlowExecution($ids: [String]!) {
910
941
  processExecutions(ids: $ids) {
911
942
  id
@@ -917,7 +948,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
917
948
  }
918
949
  }
919
950
  }
920
- `,variables:{ids:[e]}}),!a||!a.data?.getProcessFlowExecution)throw new Error("Failed to retrieve server response for execution.");const i=a.data?.getProcessFlowExecution?.completedAt;if(i){r=!0;break}if(a.data?.getProcessFlowExecution?.failedAt)throw new Error("Execution has failed to complete. See Executions tab in partner account on SpiffCommerce Hub.");if(s+=1,s>=5)throw new Error("Maximum wait time exceeded for execution result.")}return Promise.resolve(a.data?.getProcessFlowExecution)}}class Jc{constructor(t){Gc(this,"value",void 0),this.value=t}getRaw(){return this.value}getValueForTransmission(){const t=this.value;return t.startsWith("[")?JSON.stringify(JSON.parse(t)):JSON.stringify(t)}}let Lc;var zc;(zc=Lc||(Lc={})).Transaction="Transaction",zc.Bundle="Bundle",zc.Product="Product",zc.Variant="Variant",zc.Option="Option",zc.LineItem="LineItem",zc.Asset="Asset";class jc extends Jc{constructor(t,e){if("Asset"!==e&&!jc.validUUID(t))throw new Error("Invalid ID, must be a valid v4 UUID. https://www.uuidgenerator.net/");super(`{"isSpiffObject": true, "id": "${t}", "type": "${e}"}`)}static validUUID(t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}}class Vc extends Jc{constructor(t){super(t)}}function Kc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Wc=t.gql`
951
+ `,variables:{ids:[e]}}),!a||!a.data?.getProcessFlowExecution)throw new Error("Failed to retrieve server response for execution.");const i=a.data?.getProcessFlowExecution?.completedAt;if(i){r=!0;break}if(a.data?.getProcessFlowExecution?.failedAt)throw new Error("Execution has failed to complete. See Executions tab in partner account on SpiffCommerce Hub.");if(s+=1,s>=5)throw new Error("Maximum wait time exceeded for execution result.")}return Promise.resolve(a.data?.getProcessFlowExecution)}}class Lc{constructor(t){Tc(this,"value",void 0),this.value=t}getRaw(){return this.value}getValueForTransmission(){const t=this.value;return t.startsWith("[")?JSON.stringify(JSON.parse(t)):JSON.stringify(t)}}let zc;var jc;(jc=zc||(zc={})).Transaction="Transaction",jc.Bundle="Bundle",jc.Product="Product",jc.Variant="Variant",jc.Option="Option",jc.LineItem="LineItem",jc.Asset="Asset";class Vc extends Lc{constructor(t,e){if("Asset"!==e&&!Vc.validUUID(t))throw new Error("Invalid ID, must be a valid v4 UUID. https://www.uuidgenerator.net/");super(`{"isSpiffObject": true, "id": "${t}", "type": "${e}"}`)}static validUUID(t){return t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}}class Kc extends Lc{constructor(t){super(t)}}function Wc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Xc=t.gql`
921
952
  fragment RegionFields on Region {
922
953
  width
923
954
  top
@@ -935,7 +966,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
935
966
  height
936
967
  }
937
968
  }
938
- `,Xc=t.gql`
969
+ `,qc=t.gql`
939
970
  fragment LookAtAnimationFields on LookAtAnimation {
940
971
  latDeg
941
972
  lonDeg
@@ -946,7 +977,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
946
977
  z
947
978
  }
948
979
  }
949
- `,qc=t.gql`
980
+ `,Zc=t.gql`
950
981
  fragment RenderingPipelineConfigurationFields on RenderingPipelineConfiguration {
951
982
  antiAliasing {
952
983
  samples
@@ -1030,14 +1061,14 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1030
1061
  weight
1031
1062
  }
1032
1063
  }
1033
- `,Zc=t.gql`
1064
+ `,$c=t.gql`
1034
1065
  fragment ModelAnimationFields on ModelAnimation {
1035
1066
  from
1036
1067
  to
1037
1068
  loop
1038
1069
  name
1039
1070
  }
1040
- `,$c=t.gql`
1071
+ `,_c=t.gql`
1041
1072
  query GetTransactionForPartner($id: String!) {
1042
1073
  transactions(ids: [$id]) {
1043
1074
  id
@@ -1054,7 +1085,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1054
1085
  }
1055
1086
  }
1056
1087
  }
1057
- `,_c=t.gql`
1088
+ `,tl=t.gql`
1058
1089
  ${va(!1)}
1059
1090
  query GetWorkflowForTheme($id: String!) {
1060
1091
  workflow(id: $id) {
@@ -1076,7 +1107,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1076
1107
  }
1077
1108
  }
1078
1109
  }
1079
- `,tl=t.gql`
1110
+ `,el=t.gql`
1080
1111
  query GetCustomer($emailAddress: String!) {
1081
1112
  customer(emailAddress: $emailAddress) {
1082
1113
  id
@@ -1086,7 +1117,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1086
1117
  }
1087
1118
  }
1088
1119
  }
1089
- `,el=t.gql`
1120
+ `,il=t.gql`
1090
1121
  mutation CustomerCreate($details: CustomerDetailsInput!) {
1091
1122
  customerCreate(details: $details) {
1092
1123
  id
@@ -1096,7 +1127,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1096
1127
  }
1097
1128
  }
1098
1129
  }
1099
- `,il=t.gql`
1130
+ `,nl=t.gql`
1100
1131
  mutation CustomerAuthenticate($loginToken: String!) {
1101
1132
  customerAuthenticate(loginToken: $loginToken) {
1102
1133
  id
@@ -1123,11 +1154,11 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1123
1154
  }
1124
1155
  }
1125
1156
  }
1126
- `,nl=t.gql`
1157
+ `,Al=t.gql`
1127
1158
  mutation CustomerGenerateVerificationCode($emailAddress: String!) {
1128
1159
  customerGenerateVerificationCode(emailAddress: $emailAddress)
1129
1160
  }
1130
- `,Al=t.gql`
1161
+ `,al=t.gql`
1131
1162
  mutation CustomerVerifyCode($emailAddress: String!, $verificationCode: String!) {
1132
1163
  customerVerifyCode(emailAddress: $emailAddress, verificationCode: $verificationCode) {
1133
1164
  id
@@ -1155,14 +1186,14 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1155
1186
  }
1156
1187
  }
1157
1188
  }
1158
- `,al=async(e,i)=>{const n=e.map((t=>Ha.get({id:t,options:i}))),A=e.filter(((t,e)=>void 0===n[e]));if(0===A.length)return Promise.all(n);const a=(async(e,i)=>{const n=await Ia.getShadowGraphqlClient().query({query:(A=i?.assets?.metadata||!1,t.gql`
1189
+ `,rl=async(e,i)=>{const n=e.map((t=>Ha.get({id:t,options:i}))),A=e.filter(((t,e)=>void 0===n[e]));if(0===A.length)return Promise.all(n);const a=(async(e,i)=>{const n=await Ia.getShadowGraphqlClient().query({query:(A=i?.assets?.metadata||!1,t.gql`
1159
1190
  ${va(A)}
1160
1191
  ${Sa}
1161
1192
  ${Ga}
1162
- ${Wc}
1163
1193
  ${Xc}
1164
1194
  ${qc}
1165
1195
  ${Zc}
1196
+ ${$c}
1166
1197
  query GetWorkflows($ids: [String!]!) {
1167
1198
  workflows(ids: $ids) {
1168
1199
  allowProofDownload
@@ -1540,5 +1571,5 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
1540
1571
  }
1541
1572
  }
1542
1573
  }
1543
- `),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:e}});var A;const a=n.data.workflows;if(void 0===a||a.length!==e.length)throw new Error(`Unable to read workflows: ${n.errors??"Length mismatch in response"}`);return a.forEach((t=>{t.steps.forEach((t=>{delete t.data.__typename,t.option?.id&&(t.option.defaultVariant?.asset&&ka.cacheAsset(t.option.defaultVariant.asset),t.option.colorProfile&&ka.cacheAsset(t.option.colorProfile),t.option.variants?.forEach((t=>{t.asset&&ka.cacheAsset(t.asset),t.displayImage&&ka.cacheAsset(t.displayImage),t.thumbnail&&ka.cacheAsset(t.thumbnail),t.material&&ka.cacheMaterial(t.material)})),Ha.set({id:t.option.id},Promise.resolve(t.option)))}))})),a})(A,i),r=A.map((t=>Ha.set({id:t,options:i},(async(t,e)=>{const i=(await e).find((e=>e.id===t));if(!i)throw new Error(`Workflow not found: ${t}`);return i})(t,a)))),s=n.filter((t=>void 0!==t));return await Promise.all(s.concat(r))},rl=async(t,e)=>(await al([t],e))[0],sl=(t,e)=>{const i=t.workflowState,n=i?JSON.parse(i):void 0;return n?Object.values(n.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 ol{constructor(t){var e;Kc(this,"options",void 0),Kc(this,"initialized",void 0),Kc(this,"currencyCode",void 0),Kc(this,"customer",void 0),Kc(this,"experienceOptions",void 0),Kc(this,"updateTransactionState",(async t=>{try{return Ia.getShadowGraphqlClient().mutate({...t,mutation:Os})}catch(t){throw console.error(t),new oa("Critical - Unable to synchronize workflow state with server.")}})),Kc(this,"storeCustomer",(t=>{const e=da.getMap("partnerCustomerIds")||new Map;e.set(t.partner.id,t.id),da.setMap("partnerCustomerIds",e)})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,ya=e)}getAssetManager(){return ka}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new Oc}async authenticateBundleFromLocalStorage(t){const e=da.getMap("bundleOwnerIds");if(e?.has(t)){const i=e.get(t);return fa(i),Promise.resolve({success:!0,stakeholderType:gr.Owner})}const i=da.getMap("bundlePartnerIds")||new Map;if(i.has(t)){const e=i.get(t),n=(da.getMap("partnerCustomerIds")||new Map).get(e);if(n){if(await this.authenticateCustomerId(n)){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=Ia.getShadowGraphqlClient(),i=await e.query({query:$c,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!i.data.transactions||0===i.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=i.data.transactions[0],A=n.product?.partner?.id;if(!A)throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=da.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return ma(e),Promise.resolve({success:!0,stakeholderType:gr.Owner})}const r=da.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:_c,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=da.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),da.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=Ia.getShadowGraphqlClient(),i=(await e.query({query:tl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!i.id){const i=(await e.mutate({mutation:el,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!i)throw new Error("Unable to create customer.");return this.storeCustomer(i),this.customer=i,{customer:i,isAuthenticated:!1}}this.storeCustomer(i);const n=await this.authenticateCustomerId(i.id);return{customer:this.customer||i,isAuthenticated:n}}async authenticateCustomerId(t){const e=Ia.getShadowGraphqlClient(),i=da.getMap("customerTokens");if(!i?.has(t))return!1;const n=i.get(t);if(!n)return!1;const A=(await e.mutate({mutation:il,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!A&&(this.storeCustomer(A),Qa(n),this.customer=A,!0)}async generateVerificationCode(t){await Ia.getShadowGraphqlClient().mutate({mutation:nl,variables:{emailAddress:t}})}async verifyCode(t,e){const i=(await Ia.getShadowGraphqlClient().mutate({mutation:Al,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(i?.loginToken){if(!i.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=da.getMap("customerTokens")||new Map;return e.set(i.id,i.loginToken),da.setMap("customerTokens",e),this.storeCustomer(i),Qa(i.loginToken),this.customer={...i,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await Ia.getShadowGraphqlClient().mutate({mutation:gc,variables:{collectionId:t},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!e?.id)throw new Error("Unable to create bundle");const i=da.getMap("bundlePartnerIds")||new Map;i.set(e.id,e.partner.id),da.setMap("bundlePartnerIds",i),fa(e.bundleOwnerId);const n=da.getMap("bundleOwnerIds")||new Map;return n.set(e.id,e.bundleOwnerId),da.setMap("bundleOwnerIds",n),new Uc(this,e)}async getExistingBundle(t,e,i){const n=da.getMap("bundleOwnerIds")?.get(t);n&&fa(n);const A=await Ia.getShadowGraphqlClient().query({query:oc,variables:{id:t},fetchPolicy:"no-cache"});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const a=A.data?.bundles[0],r=da.getMap("bundlePartnerIds")||new Map;r.set(a.id,a.partner.id),da.setMap("bundlePartnerIds",r);const s=new Uc(this,a,e,i);return await s.getInitializationPromise(),s}async getBundleStakeholders(){if(!this.customer)throw new Error("Customer not authenticated.");const t=await Ia.getShadowGraphqlClient().query({query:lc,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!t.data?.customers||0===t.data.customers.length)throw new Error("Unable to find customer.");return t.data.customers[0].bundleStakeholders||[]}async getWorkflowExperience(t,e,i,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,e,i);const A=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await WA(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&on(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=Ia.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:e,readOnly:i}=n,A=await t.query({query:Ts,variables:{ids:[e]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!A.data?.transactions||0===A.data.transactions.length)throw new oa("Existing transaction not found.");const a=A.data?.transactions[0];if(!a.workflowId)throw new oa("Existing transaction has no workflow ID.");const r=await rl(a.workflowId);if(!a.product)throw new oa("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:i}}if("integration"===n.type||"external"===n.type){const e=async()=>{const e="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},i=await t.mutate({mutation:Hs,variables:{...e,bulk:n.bulk,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new oa("Failed to create transaction!");const A=i.data.transactionCreate;if(!A.product)throw new oa("Failed to create transaction, product not available.");return A},i=rl(n.workflowId,n?.graphql),[A,a]=await Promise.all([e(),i]);return{transaction:A,workflow:a}}throw new oa("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new ra("State mutation is forbidden in read only mode!")}:async t=>{const e=(da.getMap("transactionOwnerIds")||new Map).get(a.id)||void 0;return this.updateTransactionState({...t,context:{transactionOwnerId:e}})},readOnly:s,workflow:r};if("transaction"===n.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await A(t),o.reloadedState=t}else if(!s&&n.workflowState){const t=JSON.parse(n.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await A(t),o.reloadedState=t}else o.layouts=sl(o.transaction,o.workflow);if(o.renderableContextService=new Ms(o.layouts),n.previewService?(o.previewService=n.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=i&&i(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==n.type){const t=da.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),ma(a.transactionOwnerId||""),da.setMap("transactionOwnerIds",t)}else{const t=(da.getMap("transactionOwnerIds")||new Map).get(a.id);t&&ma(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new ac(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==n.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async getWorkflowExperiences(t,e){if(0===t.length)throw new oa("No options provided!");const i=Ia.getShadowGraphqlClient(),n=t.map(((t,e)=>({option:t,index:e}))),A=n.filter((t=>"transaction"===t.option.type)),a=n.filter((t=>"integration"===t.option.type||"external"===t.option.type)),r=(await Promise.all([(async()=>{if(0===A.length)return[];const t=A.map((t=>t.option.transactionId)),e=await i.query({query:Ts,variables:{ids:t},errorPolicy:"all",fetchPolicy:"no-cache"}),n=e.data.transactions;if(n.length!==A.length){const t=e.errors?.[0]?.message||"Unknown error";throw new oa(`Not all transactions were found: ${t}`)}return n.map(((t,e)=>({transaction:t,workflowId:t.workflowId,readOnly:A.find((e=>e.option.transactionId===t.id))?.option.readOnly??!1,index:A[e].index})))})(),(async()=>{if(0===a.length)return[];const t=await i.mutate({mutation:Us,variables:{inputs:a.map((t=>({integrationProductId:"integration"===t.option.type?t.option.integrationProductId:void 0,externalIntegrationId:"external"===t.option.type?t.option.externalIntegrationId:void 0,externalProductId:"external"===t.option.type?t.option.externalProductId:void 0,workflowId:t.option.workflowId,bulk:t.option.bulk,claim:!0})))},errorPolicy:"all",fetchPolicy:"no-cache"}),e=t.data?.transactionCreateMany;if(!e||0===e.length){const e=t.errors?.[0]?.message||"Unknown error";throw new oa(`Failed to create transactions: ${e}`)}return e.map(((t,e)=>({transaction:t,workflowId:t.workflowId,readOnly:!1,index:a[e].index})))})()])).flat(),s=[...new Set(r.map((t=>t.workflowId)))],o=await al(s,e),c=new Map(o.map((t=>[t.id,t]))),l=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await WA(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&on(e.fontData.assetUrl)}}},g=da.getMap("transactionOwnerIds")||new Map,h=r.map((async e=>{const{transaction:i,workflowId:n,readOnly:A,index:a}=e,r=c.get(n),s=t[a];!g.get(i.id)&&i.transactionOwnerId&&g.set(i.id,i.transactionOwnerId);const o=g.get(i.id)||void 0,h={product:i.product,transaction:i,layouts:[],stateMutationFunc:A?async()=>{throw new ra("State mutation is forbidden in read only mode!")}:async t=>this.updateTransactionState({...t,context:{transactionOwnerId:o}}),readOnly:A,workflow:r,isReloadedTransaction:"transaction"===s.type};if("transaction"===s.type&&i.workflowState){const t=JSON.parse(i.workflowState);h.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await l(t),h.reloadedState=t}else if(!A&&s.workflowState){const t=JSON.parse(s.workflowState);h.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await l(t),h.reloadedState=t}else h.layouts=sl(h.transaction,h.workflow);return h.renderableContextService=new Ms(h.layouts),this.initialized=!0,this.experienceOptions=h,{experienceOptions:h,index:a,options:s}}));da.setMap("transactionOwnerIds",g);const d=(await Promise.all(h)).sort(((t,e)=>t.index-e.index)).map((async t=>{const{experienceOptions:e,options:i}=t,n=new ac(this,e);return await n.getWorkflowManager().getInitializationPromise(),"transaction"!==i.type&&this.customer&&await n.attachCustomerDetails({email:this.customer.emailAddress}),n}));return await Promise.all(d)}async initFromIntegrationProduct(t){if(""===t)throw new oa("No integration product ID provided.");const e=Ia.getShadowGraphqlClient(),i=await e.mutate({mutation:Hs,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(!i.data||!i.data.transactionCreate)throw new oa("Failed to create transaction!");const n=i.data.transactionCreate;if(!n.product)throw new oa("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const A=da.getMap("transactionOwnerIds")||new Map;A.set(n.id,n.transactionOwnerId),ma(n.transactionOwnerId||""),da.setMap("transactionOwnerIds",A),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new oa("No transaction ID provided.");const i=Ia.getShadowGraphqlClient();if(e)return await(async()=>{const n=(await i.query({query:Ts,variables:{ids:[t]},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new oa("Failed to read transaction.");if(!n.product)throw new oa("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async()=>{throw new ra("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const n=da.getMap("transactionOwnerIds")||new Map,A=n.get(t);if(A){ma(A);const n=(await i.query({query:Ts,variables:{ids:[t]},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new oa("Failed to read transaction.");if(!n.product)throw new oa("Failed to load transaction, product not available.");return this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const A=(await i.mutate({mutation:Gs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!A)throw new oa("Failed to read transaction.");if(!A.product)throw new oa("Failed to load transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode,A.transactionOwnerId&&(n.set(A.id,A.transactionOwnerId),ma(A.transactionOwnerId),da.setMap("transactionOwnerIds",n)),this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new oa("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,i){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot launch experience: Not initialized.");const n=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await WA(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&on(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await rl(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 Zn(t),await n(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=i&&i(t),this.experienceOptions.renderableContextService=new Ms(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 ac(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const A=Ia.getShadowGraphqlClient().mutate({mutation:Js,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=rl(t);if(await Promise.all([A,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=sl(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=i&&i(await a),this.experienceOptions.renderableContextService=new Ms(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 ac(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new oa("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}}function cl(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class ll{constructor(){cl(this,"getProduct",void 0),cl(this,"getCommandContext",void 0),cl(this,"getAllLayoutData",void 0),cl(this,"getMetadata",void 0),cl(this,"getWorkflowMetadata",void 0),cl(this,"getStepStorage",void 0),cl(this,"setModelContainer",void 0),cl(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,i){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function gl(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let hl;var dl;(dl=hl||(hl={})).SelectFrame="SelectFrame",dl.SelectImage="SelectImage",dl.Position="Position";class ul extends Po{constructor(t,e){super(t,e),gl(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return co.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 co.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,i,n){return n&&n.length>1&&void 0===t?hl.SelectFrame:e||i||this.getImageData()?hl.Position:hl.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 wl=t=>{const e=(0,n.useRef)(null),A=(0,n.useRef)(void 0),[a,r]=(0,n.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=za(),[g,h]=(0,n.useState)(!1),[d,u]=(0,n.useState)(!1),{state:w,uiDispatcher:B}=tr(),p=(0,n.useCallback)((t=>{const e=t;B(new _a({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),m=(0,n.useCallback)((t=>{o(t),1===l.length&&(A.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]),E=(0,n.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new _a({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),f=(0,n.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,i=2===l.length&&"touch"===l[0].pointerType;if(g&&i){const[t,e]=l,i=Math.abs(t.clientX-e.clientX),n=a;n&&p(w.zoom-.0055*(n-i)),r(i)}if(d&&(e||i)&&t.isPrimary){const e=(A?.current?.x||t.screenX)-t.screenX,i=(A?.current?.y||t.screenY)-t.screenY;B(new _a({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-i/w.zoom}))}t.isPrimary&&(A.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),C=(0,n.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,n.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,i=e.current.hasPointerCapture(t);d&&!i&&e.current.setPointerCapture(t),!d&&i&&e.current.releasePointerCapture(t)}),[e,d,l]),jr([" "],(()=>{u(!0),B(new _a({selectedElement:void 0}))}),(()=>u(!1))),jr(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,n.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,i.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:C,onPointerDown:E,onPointerUp:m,onPointerCancel:m,onPointerLeave:m,onPointerMove:f,style:Q,children:t.children})};
1574
+ `),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:e}});var A;const a=n.data.workflows;if(void 0===a||a.length!==e.length)throw new Error(`Unable to read workflows: ${n.errors??"Length mismatch in response"}`);return a.forEach((t=>{t.steps.forEach((t=>{delete t.data.__typename,t.option?.id&&(t.option.defaultVariant?.asset&&ka.cacheAsset(t.option.defaultVariant.asset),t.option.colorProfile&&ka.cacheAsset(t.option.colorProfile),t.option.variants?.forEach((t=>{t.asset&&ka.cacheAsset(t.asset),t.displayImage&&ka.cacheAsset(t.displayImage),t.thumbnail&&ka.cacheAsset(t.thumbnail),t.material&&ka.cacheMaterial(t.material)})),Ha.set({id:t.option.id},Promise.resolve(t.option)))}))})),a})(A,i),r=A.map((t=>Ha.set({id:t,options:i},(async(t,e)=>{const i=(await e).find((e=>e.id===t));if(!i)throw new Error(`Workflow not found: ${t}`);return i})(t,a)))),s=n.filter((t=>void 0!==t));return await Promise.all(s.concat(r))},sl=async(t,e)=>(await rl([t],e))[0],ol=(t,e)=>{const i=t.workflowState,n=i?JSON.parse(i):void 0;return n?Object.values(n.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 cl{constructor(t){var e;Wc(this,"options",void 0),Wc(this,"initialized",void 0),Wc(this,"currencyCode",void 0),Wc(this,"customer",void 0),Wc(this,"experienceOptions",void 0),Wc(this,"updateTransactionState",(async t=>{try{return Ia.getShadowGraphqlClient().mutate({...t,mutation:Os})}catch(t){throw console.error(t),new oa("Critical - Unable to synchronize workflow state with server.")}})),this.initialized=!1,this.options=t,this.options.applicationKey&&(e=this.options.applicationKey,ya=e)}getAssetManager(){return ka}getCurrencyCode(){if(void 0===this.currencyCode)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!this.options.applicationKey)throw new Error("Application key required to use Flow Service.");return new Jc}async authenticateBundleFromLocalStorage(t){const e=da.getMap("bundleOwnerIds");if(e?.has(t)){const i=e.get(t);return fa(i),Promise.resolve({success:!0,stakeholderType:gr.Owner})}const i=da.getMap("bundlePartnerIds")||new Map;if(i.has(t)){const e=i.get(t),n=(da.getMap("partnerCustomerIds")||new Map).get(e);if(n){if(await this.authenticateCustomerId(n)){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=Ia.getShadowGraphqlClient(),i=await e.query({query:_c,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!i.data.transactions||0===i.data.transactions.length)throw new Error(`Transaction not found: ${t}`);const n=i.data.transactions[0],A=n.product?.partner?.id;if(!A)throw new Error(`Unable to read transaction: ${t}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const a=da.getMap("transactionOwnerIds");if(a?.has(t)){const e=a.get(t);return ma(e),Promise.resolve({success:!0,stakeholderType:gr.Owner})}const r=da.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:tl,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!s)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:s.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=da.getMap("transactionCustomerIds");e?.has(t)&&(e.delete(t),da.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=Ia.getShadowGraphqlClient(),i=(await e.query({query:el,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!i.id){const i=(await e.mutate({mutation:il,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data?.customerCreate;if(!i)throw new Error("Unable to create customer.");return this.storeCustomer(i),this.customer=i,{customer:i,isAuthenticated:!1}}this.storeCustomer(i);const n=await this.authenticateCustomerId(i.id);return{customer:this.customer||i,isAuthenticated:n}}async authenticateCustomerId(t){const e=Ia.getShadowGraphqlClient(),i=da.getMap("customerTokens");if(!i?.has(t))return!1;const n=i.get(t);if(!n)return!1;const A=(await e.mutate({mutation:nl,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data?.customerAuthenticate;return!!A&&(this.storeCustomer(A),Qa(n),this.customer=A,!0)}async generateVerificationCode(t){await Ia.getShadowGraphqlClient().mutate({mutation:Al,variables:{emailAddress:t}})}async verifyCode(t,e){const i=(await Ia.getShadowGraphqlClient().mutate({mutation:al,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data?.customerVerifyCode;if(i?.loginToken){if(!i.partner?.id)throw new Error(`Unable to find customer: ${t}`);const e=da.getMap("customerTokens")||new Map;return e.set(i.id,i.loginToken),da.setMap("customerTokens",e),this.storeCustomer(i),Qa(i.loginToken),this.customer={...i,loginToken:void 0},!0}return!1}async getNewBundle(t){const e=(await Ia.getShadowGraphqlClient().mutate({mutation:hc,variables:{collectionId:t},fetchPolicy:"no-cache"})).data?.bundleCreate;if(!e?.id)throw new Error("Unable to create bundle");const i=da.getMap("bundlePartnerIds")||new Map;i.set(e.id,e.partner.id),da.setMap("bundlePartnerIds",i),fa(e.bundleOwnerId);const n=da.getMap("bundleOwnerIds")||new Map;return n.set(e.id,e.bundleOwnerId),da.setMap("bundleOwnerIds",n),new Gc(this,e)}async getExistingBundle(t,e,i){const n=da.getMap("bundleOwnerIds")?.get(t);n&&fa(n);const A=await Ia.getShadowGraphqlClient().query({query:cc,variables:{id:t},fetchPolicy:"no-cache"});if(!A.data?.bundles||0===A.data?.bundles.length||!A.data?.bundles[0])throw new Error(`Unable to find bundle: ${t}`);const a=A.data?.bundles[0],r=da.getMap("bundlePartnerIds")||new Map;r.set(a.id,a.partner.id),da.setMap("bundlePartnerIds",r);const s=new Gc(this,a,e,i);return await s.getInitializationPromise(),s}async getBundleStakeholders(){if(!this.customer)throw new Error("Customer not authenticated.");const t=await Ia.getShadowGraphqlClient().query({query:gc,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!t.data?.customers||0===t.data.customers.length)throw new Error("Unable to find customer.");return t.data.customers[0].bundleStakeholders||[]}async getWorkflowExperience(t,e,i,n){if(!n)return await this.getWorkflowExperienceDeprecated(t,e,i);const A=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await WA(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&on(e.fontData.assetUrl)}}},{transaction:a,workflow:r,readOnly:s}=await(async()=>{const t=Ia.getShadowGraphqlClient();if("transaction"===n.type){const{transactionId:e,readOnly:i}=n,A=await t.query({query:Ts,variables:{ids:[e]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!A.data?.transactions||0===A.data.transactions.length)throw new oa("Existing transaction not found.");const a=A.data?.transactions[0];if(!a.workflowId)throw new oa("Existing transaction has no workflow ID.");const r=await sl(a.workflowId);if(!a.product)throw new oa("Failed to load transaction, product not available.");return{transaction:a,workflow:r,readOnly:i}}if("integration"===n.type||"external"===n.type){const e=async()=>{const e="integration"===n.type?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},i=await t.mutate({mutation:Hs,variables:{...e,bulk:n.bulk,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!i.data||!i.data.transactionCreate)throw new oa("Failed to create transaction!");const A=i.data.transactionCreate;if(!A.product)throw new oa("Failed to create transaction, product not available.");return A},i=sl(n.workflowId,n?.graphql),[A,a]=await Promise.all([e(),i]);return{transaction:A,workflow:a}}throw new oa("No workflow ID provided.")})();this.currencyCode=a.product.partner?.currencyCode;const o={product:a.product,transaction:a,layouts:[],stateMutationFunc:s?async()=>{throw new ra("State mutation is forbidden in read only mode!")}:async t=>{const e=(da.getMap("transactionOwnerIds")||new Map).get(a.id)||void 0;return this.updateTransactionState({...t,context:{transactionOwnerId:e}})},readOnly:s,workflow:r};if("transaction"===n.type&&a.workflowState){const t=JSON.parse(a.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await A(t),o.reloadedState=t}else if(!s&&n.workflowState){const t=JSON.parse(n.workflowState);o.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await A(t),o.reloadedState=t}else o.layouts=ol(o.transaction,o.workflow);if(o.renderableContextService=new Ms(o.layouts),n.previewService?(o.previewService=n.previewService,o.product?.modelUrl&&(o.modelContainer=o.previewService.loadModel({model:o.product.modelUrl,contextService:o.renderableContextService}))):(o.previewService=i&&i(r),o.product?.modelUrl&&(o.previewService?.initialize({model:o.product.modelUrl,contextService:o.renderableContextService}),o.modelContainer=o.previewService?.getAllModels()[0])),"transaction"!==n.type){const t=da.getMap("transactionOwnerIds")||new Map;t.set(a.id,a.transactionOwnerId),ma(a.transactionOwnerId||""),da.setMap("transactionOwnerIds",t)}else{const t=(da.getMap("transactionOwnerIds")||new Map).get(a.id);t&&ma(t),o.isReloadedTransaction=!0}this.initialized=!0,this.experienceOptions=o;const c=new rc(this,o);return await c.getWorkflowManager().getInitializationPromise(),"transaction"!==n.type&&this.customer&&await c.attachCustomerDetails({email:this.customer.emailAddress}),c}async getWorkflowExperiences(t,e){if(0===t.length)throw new oa("No options provided!");const i=Ia.getShadowGraphqlClient(),n=t.map(((t,e)=>({option:t,index:e}))),A=n.filter((t=>"transaction"===t.option.type)),a=n.filter((t=>"integration"===t.option.type||"external"===t.option.type)),r=(await Promise.all([(async()=>{if(0===A.length)return[];const t=A.map((t=>t.option.transactionId)),e=await i.query({query:Ts,variables:{ids:t},errorPolicy:"all",fetchPolicy:"no-cache"}),n=e.data.transactions;if(n.length!==A.length){const t=e.errors?.[0]?.message||"Unknown error";throw new oa(`Not all transactions were found: ${t}`)}return n.map(((t,e)=>({transaction:t,workflowId:t.workflowId,readOnly:A.find((e=>e.option.transactionId===t.id))?.option.readOnly??!1,index:A[e].index})))})(),(async()=>{if(0===a.length)return[];const t=await i.mutate({mutation:Us,variables:{inputs:a.map((t=>({integrationProductId:"integration"===t.option.type?t.option.integrationProductId:void 0,externalIntegrationId:"external"===t.option.type?t.option.externalIntegrationId:void 0,externalProductId:"external"===t.option.type?t.option.externalProductId:void 0,workflowId:t.option.workflowId,bulk:t.option.bulk,claim:!0})))},errorPolicy:"all",fetchPolicy:"no-cache"}),e=t.data?.transactionCreateMany;if(!e||0===e.length){const e=t.errors?.[0]?.message||"Unknown error";throw new oa(`Failed to create transactions: ${e}`)}return e.map(((t,e)=>({transaction:t,workflowId:t.workflowId,readOnly:!1,index:a[e].index})))})()])).flat(),s=[...new Set(r.map((t=>t.workflowId)))],o=await rl(s,e),c=new Map(o.map((t=>[t.id,t]))),l=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await WA(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&on(e.fontData.assetUrl)}}},g=da.getMap("transactionOwnerIds")||new Map,h=r.map((async e=>{const{transaction:i,workflowId:n,readOnly:A,index:a}=e,r=c.get(n),s=t[a];!g.get(i.id)&&i.transactionOwnerId&&g.set(i.id,i.transactionOwnerId);const o=g.get(i.id)||void 0,h={product:i.product,transaction:i,layouts:[],stateMutationFunc:A?async()=>{throw new ra("State mutation is forbidden in read only mode!")}:async t=>this.updateTransactionState({...t,context:{transactionOwnerId:o}}),readOnly:A,workflow:r,isReloadedTransaction:"transaction"===s.type};if("transaction"===s.type&&i.workflowState){const t=JSON.parse(i.workflowState);h.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await l(t),h.reloadedState=t}else if(!A&&s.workflowState){const t=JSON.parse(s.workflowState);h.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await l(t),h.reloadedState=t}else h.layouts=ol(h.transaction,h.workflow);return h.renderableContextService=new Ms(h.layouts),this.initialized=!0,this.experienceOptions=h,{experienceOptions:h,index:a,options:s}}));da.setMap("transactionOwnerIds",g);const d=(await Promise.all(h)).sort(((t,e)=>t.index-e.index)).map((async t=>{const{experienceOptions:e,options:i}=t,n=new rc(this,e);return await n.getWorkflowManager().getInitializationPromise(),"transaction"!==i.type&&this.customer&&await n.attachCustomerDetails({email:this.customer.emailAddress}),n}));return await Promise.all(d)}async initFromIntegrationProduct(t){if(""===t)throw new oa("No integration product ID provided.");const e=Ia.getShadowGraphqlClient(),i=await e.mutate({mutation:Hs,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(!i.data||!i.data.transactionCreate)throw new oa("Failed to create transaction!");const n=i.data.transactionCreate;if(!n.product)throw new oa("Failed to create transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode;const A=da.getMap("transactionOwnerIds")||new Map;A.set(n.id,n.transactionOwnerId),ma(n.transactionOwnerId||""),da.setMap("transactionOwnerIds",A),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState},this.initialized=!0}async initFromTransaction(t,e=!1){if(""===t)throw new oa("No transaction ID provided.");const i=Ia.getShadowGraphqlClient();if(e)return await(async()=>{const n=(await i.query({query:Ts,variables:{ids:[t]},fetchPolicy:"no-cache",errorPolicy:"all"})).data?.transactions[0];if(!n)throw new oa("Failed to read transaction.");if(!n.product)throw new oa("Failed to load transaction, product not available.");this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async()=>{throw new ra("State mutation is forbidden in read only mode!")},readOnly:e},this.initialized=!0})();const n=da.getMap("transactionOwnerIds")||new Map,A=n.get(t);if(A){ma(A);const n=(await i.query({query:Ts,variables:{ids:[t]},errorPolicy:"all"})).data?.transactions[0];if(!n)throw new oa("Failed to read transaction.");if(!n.product)throw new oa("Failed to load transaction, product not available.");return this.currencyCode=n.product.partner?.currencyCode,this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},void(this.initialized=!0)}try{const A=(await i.mutate({mutation:Gs,variables:{id:t},errorPolicy:"all"})).data?.transactionClaim;if(!A)throw new oa("Failed to read transaction.");if(!A.product)throw new oa("Failed to load transaction, product not available.");this.currencyCode=A.product.partner?.currencyCode,A.transactionOwnerId&&(n.set(A.id,A.transactionOwnerId),ma(A.transactionOwnerId),da.setMap("transactionOwnerIds",n)),this.experienceOptions={product:A.product,transaction:A,layouts:[],stateMutationFunc:this.updateTransactionState,readOnly:e},this.initialized=!0}catch{throw new oa("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(t,e,i){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot launch experience: Not initialized.");const n=async t=>{for(const e in t.layouts){const i=t.layouts[e].elements.filter((t=>t.type===ze.Illustration));for(let t=0;t<i.length;++t){const e=i[t];e.src&&e.svg&&(e.cachedObjectURL=await WA(e.svg))}const n=t.layouts[e].elements.filter((t=>t.type===ze.Textbox));for(let t=0;t<n.length;++t){const e=n[t];e.fontData?.assetUrl&&on(e.fontData.assetUrl)}}};if(this.experienceOptions.transaction.workflowId){const t=await sl(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 Zn(t),await n(t),this.experienceOptions.reloadedState=t}this.experienceOptions.previewService=i&&i(t),this.experienceOptions.renderableContextService=new Ms(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 rc(this,this.experienceOptions);return await e.getWorkflowManager().getInitializationPromise(),e}if(t){const A=Ia.getShadowGraphqlClient().mutate({mutation:Js,variables:{workflowId:t,id:this.experienceOptions.transaction.id}}),a=sl(t);if(await Promise.all([A,a]),this.experienceOptions.workflow=await a,e){const t=JSON.parse(e);this.experienceOptions.layouts=Object.values(t.layouts).map((t=>t.layout)),await Zn(t),await n(t),this.experienceOptions.reloadedState=t}else this.experienceOptions.layouts=ol(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=i&&i(await a),this.experienceOptions.renderableContextService=new Ms(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 rc(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}throw new oa("No workflow ID provided.")}getPreviewService(){return this.experienceOptions?.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new oa("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}storeCustomer(t){const e=da.getMap("partnerCustomerIds")||new Map;e.set(t.partner.id,t.id),da.setMap("partnerCustomerIds",e)}}function ll(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class gl{constructor(){ll(this,"getProduct",void 0),ll(this,"getCommandContext",void 0),ll(this,"getAllLayoutData",void 0),ll(this,"getMetadata",void 0),ll(this,"getWorkflowMetadata",void 0),ll(this,"getStepStorage",void 0),ll(this,"setModelContainer",void 0),ll(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,i){}setVariationRecords(t){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}}function hl(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;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:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let dl;var ul;(ul=dl||(dl={})).SelectFrame="SelectFrame",ul.SelectImage="SelectImage",ul.Position="Position";class wl extends Po{constructor(t,e){super(t,e),hl(this,"frameService",this.manager.getStepSpecificServices(this.getId())?.frameService)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return co.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 co.selectImage(this.step,t,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(t,e,i,n){return n&&n.length>1&&void 0===t?dl.SelectFrame:e||i||this.getImageData()?dl.Position:dl.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 Bl=t=>{const e=(0,n.useRef)(null),A=(0,n.useRef)(void 0),[a,r]=(0,n.useState)(void 0),{addEvent:s,removeEvent:o,updateEvent:c,eventCache:l}=za(),[g,h]=(0,n.useState)(!1),[d,u]=(0,n.useState)(!1),{state:w,uiDispatcher:B}=tr(),p=(0,n.useCallback)((t=>{const e=t;B(new _a({zoom:Math.max(.1,Math.min(e,w.maxZoom))}))}),[B,w.maxZoom]),m=(0,n.useCallback)((t=>{o(t),1===l.length&&(A.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]),E=(0,n.useCallback)((t=>{s(t);"touch"===t.pointerType&&1===l.length&&(B(new _a({selectedElement:void 0})),u(!0),h(!0))}),[s,l.length,B]),f=(0,n.useCallback)((t=>{c(t);const e=1===l.length&&"touch"!==l[0].pointerType,i=2===l.length&&"touch"===l[0].pointerType;if(g&&i){const[t,e]=l,i=Math.abs(t.clientX-e.clientX),n=a;n&&p(w.zoom-.0055*(n-i)),r(i)}if(d&&(e||i)&&t.isPrimary){const e=(A?.current?.x||t.screenX)-t.screenX,i=(A?.current?.y||t.screenY)-t.screenY;B(new _a({selectedElement:void 0,xTranslation:w.xTranslation-e/w.zoom,yTranslation:w.yTranslation-i/w.zoom}))}t.isPrimary&&(A.current={x:t.screenX,y:t.screenY})}),[c,l,g,d,a,p,w.zoom,w.xTranslation,w.yTranslation,B]),C=(0,n.useCallback)((t=>{g&&p(w.zoom-.035*Math.sign(t.deltaY))}),[p,w.zoom,g]);(0,n.useEffect)((()=>{if(!e.current||0===l.length)return;const t=l[0].pointerId,i=e.current.hasPointerCapture(t);d&&!i&&e.current.setPointerCapture(t),!d&&i&&e.current.releasePointerCapture(t)}),[e,d,l]),jr([" "],(()=>{u(!0),B(new _a({selectedElement:void 0}))}),(()=>u(!1))),jr(["Control"],(()=>h(!0)),(()=>h(!1)));const Q=(0,n.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,i.jsx)("div",{ref:e,className:"transform-wrapper",onWheel:C,onPointerDown:E,onPointerUp:m,onPointerCancel:m,onPointerLeave:m,onPointerMove:f,style:Q,children:t.children})};
1544
1575
  //# sourceMappingURL=main.js.map