@spiffcommerce/core 5.0.1 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/jsx-runtime"),n=require("opentype.js"),i=require("buffer"),a=require("axios"),o=require("https"),r=require("file-type"),s=require("util"),c=require("css"),g=require("canvas"),l=require("exif"),B=require("canvg"),w=require("@apollo/client/link/context"),h=require("@apollo/client/link/error"),d=require("cross-fetch"),E=require("react"),u=require("lodash.isequal"),Q=require("react-dom/server"),C=require("qrcode"),m=require("svg-path-bbox"),p=require("lodash.debounce");function f(t,e,A,n){Object.defineProperty(t,e,{get:A,set:n,enumerable:!0,configurable:!0})}var D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function I(t){return t&&t.__esModule?t.default:t}function y(t,e,A,n){Object.defineProperty(t,e,{get:A,set:n,enumerable:!0,configurable:!0})}f(module.exports,"SpiffCommerceClient",(()=>Ro)),f(module.exports,"CommandContext",(()=>Me)),f(module.exports,"spiffCoreConfiguration",(()=>ZA)),f(module.exports,"PromiseQueue",(()=>Ci)),f(module.exports,"QueueablePromise",(()=>Qi)),f(module.exports,"MockWorkflowManager",(()=>Po)),f(module.exports,"InformationMessageType",(()=>Xa)),f(module.exports,"StepHandle",(()=>Ao)),f(module.exports,"TextStepHandle",(()=>wo)),f(module.exports,"FrameStepHandle",(()=>ko)),f(module.exports,"BulkStepHandle",(()=>oo)),f(module.exports,"ShapeStepHandle",(()=>Bo)),f(module.exports,"IllustrationStepHandle",(()=>ro)),f(module.exports,"MaterialStepHandle",(()=>so)),f(module.exports,"ModelStepHandle",(()=>co)),f(module.exports,"PictureStepHandle",(()=>go)),f(module.exports,"QuestionStepHandle",(()=>lo)),f(module.exports,"BulkPriceCalculationStrategy",(()=>Sn)),f(module.exports,"OptionNotFoundError",(()=>UA)),f(module.exports,"LayoutNotFoundError",(()=>GA)),f(module.exports,"AssetNotFoundError",(()=>bA)),f(module.exports,"ResourceNotFoundError",(()=>kA)),f(module.exports,"MisconfigurationError",(()=>JA)),f(module.exports,"ParseError",(()=>TA)),f(module.exports,"UnhandledBehaviorError",(()=>OA)),f(module.exports,"assetService",(()=>Bn)),f(module.exports,"designService",(()=>Io)),f(module.exports,"createDesign",(()=>po)),f(module.exports,"optionService",(()=>En)),f(module.exports,"persistenceService",(()=>XA)),f(module.exports,"graphQlManager",(()=>en)),f(module.exports,"toast",(()=>Oa)),f(module.exports,"FrameService",(()=>ya)),f(module.exports,"getBoundedOffsets",(()=>Da)),f(module.exports,"frameStepService",(()=>Ra)),f(module.exports,"modelStepService",(()=>Ua)),f(module.exports,"materialStepService",(()=>Pa)),f(module.exports,"shapeStepService",(()=>Ja)),f(module.exports,"questionStepService",(()=>ka)),f(module.exports,"digitalContentStepService",(()=>Sa)),f(module.exports,"moduleStepService",(()=>Ga)),f(module.exports,"pictureStepService",(()=>ba)),f(module.exports,"textStepService",(()=>Va)),f(module.exports,"illustrationStepService",(()=>Ha)),f(module.exports,"ProductCameraRig",(()=>Yn)),f(module.exports,"FrameStep",(()=>Go)),f(module.exports,"ConversionLocation",(()=>Rn)),f(module.exports,"ConversionDataType",(()=>Pn)),f(module.exports,"getWorkflow",(()=>So)),f(module.exports,"AssetType",(()=>z)),f(module.exports,"BringForwardCommand",(()=>nA)),f(module.exports,"BringToFrontCommand",(()=>eA)),f(module.exports,"BringToBackCommand",(()=>AA)),f(module.exports,"CanvasCommand",(()=>Pe)),f(module.exports,"CreateElementCommand",(()=>Te)),f(module.exports,"CreateLayoutCommand",(()=>Le)),f(module.exports,"DeleteElementCommand",(()=>ze)),f(module.exports,"FontAlignmentCommand",(()=>qe)),f(module.exports,"FontColorCommand",(()=>Ke)),f(module.exports,"FontSizeCommand",(()=>Ve)),f(module.exports,"FontSourceCommand",(()=>Xe)),f(module.exports,"GroupCommand",(()=>Je)),f(module.exports,"LayoutElementFactory",(()=>NA)),f(module.exports,"LayoutElementType",(()=>N)),f(module.exports,"MoveCommand",(()=>Ge)),f(module.exports,"ResizeCommand",(()=>ke)),f(module.exports,"RotateCommand",(()=>be)),f(module.exports,"SendBackwardsCommand",(()=>iA)),f(module.exports,"StepAspectType",(()=>W)),f(module.exports,"StepType",(()=>K)),f(module.exports,"TextChangeCommand",(()=>$e)),f(module.exports,"UnitOfMeasurement",(()=>b)),f(module.exports,"dataUrlFromExternalUrl",(()=>Ut)),f(module.exports,"findElement",(()=>Se)),f(module.exports,"frameDataCache",(()=>hA)),f(module.exports,"generate",(()=>F)),f(module.exports,"getAxisAlignedBoundingBox",(()=>$)),f(module.exports,"generateSVGWithUnknownColors",(()=>Ie)),f(module.exports,"getAttributesFromArrayBuffer",(()=>lA)),f(module.exports,"rehydrateSerializedLayout",(()=>He)),f(module.exports,"getFrameData",(()=>QA)),f(module.exports,"getSvgElement",(()=>Fe)),f(module.exports,"loadFontFromDataUrl",(()=>Kt)),f(module.exports,"loadFontFromExternalUrl",(()=>jt)),f(module.exports,"determineCorrectFontSizeAndLines",(()=>yA)),f(module.exports,"patternImageDataCache",(()=>wA)),f(module.exports,"generateCommands",(()=>qi)),f(module.exports,"registerJSDOM",(()=>It)),f(module.exports,"minZoom",(()=>Bi)),f(module.exports,"AdvancedEditor",(()=>oa)),f(module.exports,"TransformWrapper",(()=>Jo)),f(module.exports,"EditorCore",(()=>aa)),f(module.exports,"useLayouts",(()=>Cn)),f(module.exports,"useEditorState",(()=>Fn)),f(module.exports,"useEditorInteraction",(()=>hi)),f(module.exports,"useShortcutCombination",(()=>di)),f(module.exports,"commandReducer",(()=>In)),f(module.exports,"getDefaultState",(()=>Dn)),f(module.exports,"CommandContextContext",(()=>un)),f(module.exports,"AdvancedEditorStateProvider",(()=>Mn)),f(module.exports,"AdvancedEditorContext",(()=>yn)),f(module.exports,"UICommand",(()=>xn)),f(module.exports,"EditorSubMenu",(()=>pn)),f(module.exports,"ElementEventType",(()=>Ln)),f(module.exports,"KeyEvent",(()=>Tn)),f(module.exports,"gatherVaryingStepAspects",(()=>da));var M="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==D?D:{},x={};y(x,"CanvasCommand",(()=>Pe)),y(x,"UpdateWorkflowStateCommand",(()=>Ue)),y(x,"MoveCommand",(()=>Ge)),y(x,"RotateCommand",(()=>be)),y(x,"ResizeCommand",(()=>ke)),y(x,"GroupCommand",(()=>Je)),y(x,"CreateLayoutCommand",(()=>Le)),y(x,"ClearLayoutCommand",(()=>Oe)),y(x,"CreateElementCommand",(()=>Te)),y(x,"DeleteElementCommand",(()=>ze)),y(x,"CloneElementCommand",(()=>je)),y(x,"FontColorCommand",(()=>Ke)),y(x,"FontSizeCommand",(()=>Ve)),y(x,"FontAlgorithmCommand",(()=>We)),y(x,"FontSourceCommand",(()=>Xe)),y(x,"FontAlignmentCommand",(()=>qe)),y(x,"UpdateFramePattern",(()=>Ze)),y(x,"TextChangeCommand",(()=>$e)),y(x,"IllustrationColorCommand",(()=>_e)),y(x,"IllustrationCacheCommand",(()=>tA)),y(x,"BringToFrontCommand",(()=>eA)),y(x,"BringToBackCommand",(()=>AA)),y(x,"BringForwardCommand",(()=>nA)),y(x,"SendBackwardsCommand",(()=>iA)),y(x,"LayerCommand",(()=>aA)),y({},"generate",(()=>F));const F=()=>{const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()};var Y={};y(Y,"ElementNotFoundError",(()=>ve)),y(Y,"findElement",(()=>Se)),y(Y,"findLayoutForElement",(()=>Ne)),y(Y,"updatedLayoutForElement",(()=>Re)),y(Y,"rehydrateSerializedLayout",(()=>He));var v={};y(v,"CommandContext",(()=>Me)),y(v,"getSvgElement",(()=>Fe)),y(v,"elementFactory",(()=>xe)),y(v,"sortElementsByLayersWithIndex",(()=>Ye)),y({},"SVGLayout",(()=>q));var S={};let N;var R;let H;var P;let U;var G;let b;var k;let J;var L;let O;var T;let z;var j;let K;var V;let W;var X;y(S,"LayoutElementType",(()=>N)),y(S,"LayoutRenderingPurpose",(()=>H)),y(S,"TextAlgorithm",(()=>U)),y(S,"UnitOfMeasurement",(()=>b)),y(S,"ScaleAxis",(()=>J)),y(S,"MaterialEffectMode",(()=>O)),y(S,"AssetType",(()=>z)),y(S,"StepType",(()=>K)),y(S,"StepAspectType",(()=>W)),(R=N||(N={})).Frame="frame",R.Image="image",R.Illustration="illustration",R.Textbox="textbox",(P=H||(H={}))[P.ThreeD=0]="ThreeD",P[P.FreeDesign=1]="FreeDesign",P[P.Print=2]="Print",(G=U||(U={})).Autosize="Autosize",G.Traditional="Traditional",(k=b||(b={})).Pixel="px",k.Millimeter="mm",k.Centimeter="cm",(L=J||(J={}))[L.North=0]="North",L[L.Northeast=1]="Northeast",L[L.East=2]="East",L[L.Southeast=3]="Southeast",L[L.South=4]="South",L[L.Southwest=5]="Southwest",L[L.West=6]="West",L[L.Northwest=7]="Northwest",(T=O||(O={})).None="None",T.RemoveWhenSelected="RemoveWhenSelected",T.ApplyWhenSelected="ApplyWhenSelected",(j=z||(z={})).Font="Font",j.Frame="Frame",j.Illustration="Illustration",j.Image="Image",j.Model="Model",j.Material="Material",j.Color="Color",j.QuestionnaireCollateral="QuestionnaireCollateral",j.RequestCollateral="RequestCollateral",j.SignupCollateral="SignupCollateral",j.Video="Video",j.ColorProfile="ColorProfile",(V=K||(K={})).Bulk="Bulk",V.DigitalContent="DigitalContent",V.Finish="Finish",V.Frame="Frame",V.Illustration="Illustration",V.Introduction="Introduction",V.Material="Material",V.Model="Model",V.Module="Module",V.Picture="Picture",V.Photo="Photo",V.ProductOverlay="ProductOverlay",V.Question="Question",V.Shape="Shape",V.SilentIllustration="SilentIllustration",V.Text="Text",(X=W||(W={})).Color="Color",X.Colors="Colors",X.Selection="Selection",X.Selections="Selections",X.Text="Text",X.Upload="Upload";const q=({backgroundColor:t,outlineColor:e,borderRadius:n,configuration:i,elements:a,height:o,maxHeight:r,maxWidth:s,outlineArea:c,position:g,preserveAspectRatio:l,viewBox:B,width:w})=>{const h=n||0,d=2*(c?.scale||1),E=B||{x:0,y:0,width:w,height:o},u=`${E.x} ${E.y} ${E.width} ${E.height}`,Q=F(),C=i.purpose===H.FreeDesign&&(0,A.jsx)("defs",{children:(0,A.jsx)("clipPath",{id:"viewboxClip",children:(0,A.jsx)("rect",{width:E.width,height:E.height,rx:h})})}),m=i.colorProfiles?.map(((t,e)=>(0,A.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),p=Ye(a.map((t=>({...t,_renderingConfiguration:i,mask:c?`url(#viewmask-${Q})`:void 0}))));return(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:l,width:w,height:o,style:{gridColumn:1,gridRow:1,maxWidth:s,maxHeight:r,position:g},viewBox:u,children:[m,C,!!t&&(0,A.jsx)("rect",{id:"layout-background",width:E.width,height:E.height,fill:t,rx:h}),(0,A.jsx)("g",{id:"element-group",clipPath:i.purpose===H.FreeDesign?"url(#viewboxClip)":void 0,children:p.map((t=>xe(t))).filter((t=>!!t))}),c&&(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:d/2,strokeDasharray:`${2*d} ${d}`}),c&&(0,A.jsxs)("mask",{id:`viewmask-${Q}`,children:[(0,A.jsx)("rect",{x:E.x,y:E.y,width:E.width,height:E.height,fill:"black"}),(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};y({},"Image",(()=>dt));var Z={};y(Z,"getAxisAlignedBoundingBox",(()=>$)),y(Z,"degreesToRadians",(()=>tt)),y(Z,"findAngle",(()=>_)),y(Z,"radiansToDegrees",(()=>et)),y(Z,"isCloseToValue",(()=>At)),y(Z,"getTrueCoordinates",(()=>nt)),y(Z,"getPointOfRotation",(()=>it)),y(Z,"getNWPoint",(()=>at)),y(Z,"getNEPoint",(()=>ot)),y(Z,"getSWPoint",(()=>rt)),y(Z,"getSEPoint",(()=>st)),y(Z,"turnRightClockwise",(()=>ct)),y(Z,"currentDirection",(()=>gt)),y(Z,"getElementVertices",(()=>lt)),y(Z,"rotateAroundPoint",(()=>Bt)),y(Z,"mmPerPixel",(()=>wt)),y(Z,"cmPerPixel",(()=>ht));const $=(t,e,A,n,i)=>{const a=tt(i),o=A/2,r=n/2,s=t+o,c=e+r,g=Math.sin(a),l=Math.cos(a),B=-r,w=o*l-B*g,h=o*l-r*g,d=o*g+B*l,E=o*g+r*l,u=Math.max(Math.abs(w),Math.abs(h)),Q=Math.max(Math.abs(d),Math.abs(E));return{minX:s-u,maxX:s+u,minY:c-Q,maxY:c+Q}},_=(t,e,A)=>{const n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),i=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2)),a=Math.sqrt(Math.pow(A.x-t.x,2)+Math.pow(A.y-t.y,2));return Math.acos((i*i+n*n-a*a)/(2*i*n))*(180/Math.PI)},tt=t=>t*(Math.PI/180),et=t=>t*(180/Math.PI),At=(t,e,A)=>Math.abs(t-e)<A,nt=(t,e,A)=>{const n=Math.sin(tt(A)),i=Math.cos(tt(A));return{x:(t.x-e.x)*i-(t.y-e.y)*n+e.x,y:(t.x-e.x)*n+(t.y-e.y)*i+e.y}},it=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),at=(t,e,A,n)=>({x:t.x+e?.x*A,y:t.y+e?.y*n}),ot=(t,e,A,n)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+e?.y*n}),rt=(t,e,A,n)=>({x:t.x+e?.x*A,y:t.y+(e?.y+e?.height)*n}),st=(t,e,A,n)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+(e?.y+e?.height)*n}),ct=t=>{switch(t){case J.North:return J.East;case J.East:return J.South;case J.South:return J.West;case J.West:return J.North;case J.Northwest:return J.Northeast;case J.Northeast:return J.Southeast;case J.Southeast:return J.Southwest;case J.Southwest:return J.Northwest}},gt=(t,e)=>e>45&&e<=135?ct(t):e>135&&e<=225?ct(ct(t)):e>225&&e<=315?ct(ct(ct(t))):t,lt=(t,e={x:0,y:0},A={x:1,y:1})=>{const n=tt(t.rotation),i={x:e.x+t.x*A.x,y:e.x+t.y*A.y},a={x:t.x+t.width,y:t.y},o={x:e.x+(t.x+t.width)*A.x,y:e.y+(t.height+t.y)*A.y},r={x:e.x+t.x*A.x,y:e.y+(t.height+t.y)*A.y},s={x:(r.x+o.x)/2,y:r.y-t.height*A.y/2};return{a:Bt(i,s,n),b:Bt(a,s,n),c:Bt(o,s,n),d:Bt(r,s,n),center:s}},Bt=(t,e,A)=>{const n=Math.sin(A),i=Math.cos(A);return{x:(t.x-e.x)*i-(t.y-e.y)*n+e.x,y:(t.x-e.x)*n+(t.y-e.y)*i+e.y}},wt=.352778,ht=.035277,dt=t=>{const e=t.rotation||0,n=tt(e),i=Math.cos(n),a=-Math.sin(n);return(0,A.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,A.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `,children:(0,A.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};y({},"Frame",(()=>Et));const Et=t=>{const e=`spiff-frame-${t.id}`,n=`spiff-frame-blur-${t.id}`,i=`spiff-frame-blur-edge-${t.id}`,a=`spiff-frame-focal-mask-${t.id}`,o=!!t.focalBlur&&!!t.pattern,r=t.rotation||0,s=tt(r),c=Math.cos(s),g=-Math.sin(s);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("defs",{children:(o=>{const r=t.pattern?.x||0,s=t.pattern?.y||0,c=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(r):256,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(s):256,l=t.pattern?t.pattern.width*t.pattern.scaleX:256,B=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,A.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,A.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:c,height:t.pattern?1:g,"data-frame-width":t.pattern?c:void 0,"data-frame-height":t.pattern?g:void 0,id:e,children:(0,A.jsx)("image",{preserveAspectRatio:"none",x:r,y:s,width:l,height:B,xlinkHref: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/Q5Y4kAAgBQE0rtDQaDuSdTLKCIAbvBQwnKaHQR5WtCA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vg4g+QBwKCUDVAp68DJ3hnpPJhK8fIAKFS4EXIQJ6DfsaUGecAQCeKNULsAgRYMgnQHxKNwPFFgH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),o?(0,A.jsx)(ut,{path:t.path,width:t.width,height:t.height,focalBlurStrength:t.focalBlurStrength||1,focalBlurRadius:t.focalBlurRadius||10,blurFilterId:n,focalMaskId:a,blurEdgeClipId:i}):null]})})(o)}),(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${c}, ${-g}, ${g}, ${c}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n matrix(${t.scaleX}, 0, 0, ${t.scaleY}, 0, 0)\n `,children:[(0,A.jsx)("path",{filter:o?`url(#${n})`:void 0,mask:o?`url(#${i})`:void 0,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}),o?(0,A.jsx)("path",{mask:`url(#${a})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},ut=t=>{const{path:e,width:n,height:i,focalBlurStrength:a,focalBlurRadius:o,blurFilterId:r,focalMaskId:s,blurEdgeClipId:c}=t;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("filter",{id:r,children:(0,A.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,A.jsx)("mask",{id:s,children:(0,A.jsx)("circle",{cx:n/2,cy:i/2,r:o||0,fill:"white",filter:`url(#${r})`})}),(0,A.jsx)("mask",{id:c,children:(0,A.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};y({},"Textbox",(()=>Ee));var Qt={};y(Qt,"fontSizeStep",(()=>ee)),y(Qt,"textWidth",(()=>Ae)),y(Qt,"charWidth",(()=>ne)),y(Qt,"lineWidth",(()=>ie)),y(Qt,"applyTextTransformations",(()=>oe)),y(Qt,"zip",(()=>re)),y(Qt,"getTextAlignment",(()=>se)),y(Qt,"getAnchor",(()=>ce)),y(Qt,"recomputeTextOnElement",(()=>ge)),y(Qt,"defaultLineHeightFactor",(()=>le));var Ct={};y(Ct,"refitTextbox",(()=>_t)),y(Ct,"recalculateTextboxRegion",(()=>te));var mt={};y(mt,"FontMetrics",(()=>Tt)),y(mt,"loadFontFromExternalUrl",(()=>jt)),y(mt,"loadFontFromDataUrl",(()=>Kt)),y(mt,"getFontMetrics",(()=>Vt));var pt={};y(pt,"registerJSDOM",(()=>It)),y(pt,"createElement",(()=>Ft)),y(pt,"createElementNS",(()=>Yt)),y(pt,"domParser",(()=>vt)),y(pt,"fetchAsArrayBuffer",(()=>St)),y(pt,"fetchAsString",(()=>Nt)),y(pt,"loadFontFaceSet",(()=>Rt)),y(pt,"xmlSerializer",(()=>Ht)),y(pt,"toBase64",(()=>Pt)),y(pt,"dataUrlFromExternalUrl",(()=>Ut)),y(pt,"arrayBufferToDataUrl",(()=>Gt)),y(pt,"arrayBufferToBuffer",(()=>kt)),y(pt,"dataUrlToArrayBuffer",(()=>bt));var ft=i.Buffer;let Dt;function It(t){Dt=t}function yt(){if(!Dt)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new Dt}if(void 0===M.TextEncoder){const{TextEncoder:t}=s;M.TextEncoder=t}if(void 0===M.TextDecoder){const{TextDecoder:t}=s;M.TextDecoder=t}const Mt=new(I(o).Agent)({rejectUnauthorized:!0}),xt=t=>t.every((t=>"undefined"!==t)),Ft=t=>xt([typeof document])?document.createElement(t):yt().window.document.createElement(t),Yt=(t,e)=>{if(xt([typeof document]))return document.createElementNS(t,e);const A=yt().window.document.createElement(e);return A.setAttribute("xmlns",t),A},vt=()=>xt([typeof DOMParser])?new DOMParser:new(yt().window.DOMParser),St=t=>{if(xt([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{A(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{I(a).get(e,{responseType:"arraybuffer",httpsAgent:Mt}).then((e=>{t(e.data)})).catch((t=>{A(t)}))}))}},Nt=t=>{if(xt([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.text())})).catch(A)}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{I(a).get(e,{responseType:"text",httpsAgent:Mt}).then((e=>{t(e.data)})).catch(A)}))}},Rt=async(t,e)=>{if(xt([typeof FontFace])){const A=t.names.fullName.en,n=new FontFace(A,`url(${e})`);return document.fonts.add(n),n.load()}},Ht=()=>xt([typeof XMLSerializer])?new XMLSerializer:new(yt().window.XMLSerializer),Pt=t=>xt([typeof btoa])?btoa(t):ft.from(t).toString("base64"),Ut=async t=>{if(xt([typeof fetch,typeof Blob,typeof FileReader])){const e=await fetch(t),A=await e.blob();return await Lt(A)}const e=(await I(a).get(t,{responseType:"arraybuffer"})).data;return Gt(e)},Gt=async t=>{const e=await(async t=>{const e=await(0,r.fromBuffer)(t);return e?e.mime:"image/svg+xml"})(t);return`data:${e};base64,${kt(t).toString("base64")}`},bt=t=>{const e=t.replace(/\r?\n/g,""),A=e.indexOf(",");if(-1===A||A<=4)throw new TypeError("malformed data: URI");const n=e.substring(5,A).split(";");let i=!1;for(let t=1;t<n.length;t++)"base64"===n[t]&&(i=!0);const a=i?"base64":"ascii",o=unescape(e.substring(A+1)),r=ft.from(o,a);return Jt(r)},kt=t=>ft.from(t),Jt=t=>{const e=new ArrayBuffer(t.byteLength),A=new Uint8Array(e);for(let e=0;e<t.length;++e)A[e]=t[e];return e},Lt=t=>new Promise(((e,A)=>{const n=new FileReader;n.onload=function(t){const n=t.target;n&&n.result?e(n.result.toString()):A()},n.readAsDataURL(t)})),Ot=new Map;class Tt{constructor(t){this.font=t,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(t){const e=this.glyphsFromText.get(t);if(e)return e;const A=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,A),A}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let A=0,n=0;return e.forEach((t=>{const e=t.getMetrics();A=Math.max(A,e.yMax),n=Math.min(n,e.yMin)})),A-n}getKerningValue(t,e){let A=this.kerningValues.get(t.name);A||(A=new Map,this.kerningValues.set(t.name,A));let n=A.get(e.name);return n||(n=this.font.getKerningValue(t,e),A.set(e.name,n)),n}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,A=0;return t.forEach((t=>{const n=t.getMetrics();e=Math.max(e,n.yMax),A=Math.min(A,n.yMin)})),e-A}}const zt=t=>"data:"===t.substring(0,5).toLowerCase().trim(),jt=async t=>{const e=zt(t)?Kt(t):Kt(await Ut(t));return Wt(e,{assetUrl:zt(t)?t:await Ut(t),name:e.names.fullName.en}),await Rt(e,t),e},Kt=t=>{const e=bt(t),A=I(n).parse(e);return Wt(A,{assetUrl:t,name:A.names.fullName.en}),A},Vt=t=>{const e=Ot.get(t.name);if(e)return e;throw new Error("Font metrics unavailable for font")},Wt=(t,e)=>{const A=new Tt(t);return Ot.set(e.name,A),A},Xt=(t,e,A,n)=>Math.max(ne(t.join("\n"),A,n),e),qt=(t,e,A,n,i,a)=>{const o=(a||le)*i.getApproximateHeight(),r=e.split("\n");try{const e=r.flatMap((e=>Zt(e,t.width,n,i))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(n*o),fontSize:A,requiredWidth:Xt(a,t.width,n,i)}}catch(a){const r=e.split("");return{lines:r,requiredHeight:r.length*(n*o),fontSize:A,requiredWidth:Xt(r,t.width,n,i)}}},Zt=(t,e,A,n)=>{const i=Ae(t,A,n);if(i<=e)return{lines:[t],width:i};if(!(t.indexOf(" ")>-1)){if(t.length<=1)throw new Error(`Character ${t} is wider than region`);const i=Math.floor(t.length/2),a=Zt(t.slice(0,i),e,A,n),o=Zt(t.slice(i),e,A,n);return{lines:[...a.lines,...o.lines],width:Math.max(a.width,o.width)}}const a=t.split(" "),o=[];let r=-1/0,s=0;for(;s<a.length;){const t=a[s];if(Ae(t,A,n)>e){const i=Zt(t,e,A,n);o.push(...i.lines),r=Math.max(r,i.width),s++}else{const i=[t];r=Math.max(r,Ae(t,A,n));let c=s+1,g=!0;for(;c<a.length&&g;){const t=a[c],o=Ae(`${i.join(" ")} ${t}`,A,n);o<=e?(i.push(t),r=Math.max(r,o),c++):g=!1}o.push(i.join(" ")),s=c}}if(r<0)throw new Error(`No max width calculated for text: ${o}.`);return{lines:o,width:r}},$t=(t,e,A,n,i,a)=>{const o=(a??le)*e.getApproximateHeight(),r=1/A.unitsPerEm,s=n/ie(t,r,e),c=i/(t.length*o*r);return Math.min(c,s)},_t=(t,e,A,n)=>{const i=Vt(e.fontData),a=i.getFont(),o=e.fontSize/a.unitsPerEm;if(!A)return qt(e,t,e.fontSize,o,i,n);let r;if(r=e.text?e.text.split("\n"):e.input?.split("\n")??[""],A.input===t&&e.width===A.width&&e.height===A.height&&e.lineHeight===A.lineHeight)return{lines:r,requiredHeight:e.height,requiredWidth:Xt(r,e.width,o,i),fontSize:e.fontSize};const s=e.width!==A.width!=(e.height!==A.height);return e.lineHeight!==A.lineHeight||s||A.input!==t?qt(e,t,e.fontSize,o,i,n):{lines:r,requiredHeight:e.height,requiredWidth:Xt(r,e.width,o,i),fontSize:$t(r,i,a,e.width,e.height,n)}},te=(t,e,A,n,i)=>{const a=Vt(e).getFont();let o={...t},r={...t},s=ie(n,A/a.unitsPerEm,Vt(e));return s&&s<o.width&&(r.width=s,"left"===i?(r.left+=Math.sin(o.rotation*Math.PI/360)*(o.width-s),r.top+=Math.sin(o.rotation*Math.PI/180)*(s-o.width)/2):r.left+="right"===i?o.width-s:(o.width-s)/2,n&&re(n,n).every((([t,e])=>t===e))&&(o=r)),o},ee=1,Ae=(t,e,A)=>{let n=0;const i=A.getGlyphs(t);return i.forEach(((t,e)=>{if(t.advanceWidth&&(n+=t.advanceWidth),e<i.length-1){const a=A.getKerningValue(t,i[e+1]);n+=a}})),n*=e,n},ne=(t,e,A)=>{let n=0;const i=A.getGlyphs(t);return i.forEach(((t,e)=>{if(t.advanceWidth&&(n=Math.max(n,t.advanceWidth)),e<i.length-1){const a=A.getKerningValue(t,i[e+1]);n=Math.max(n,a)}})),n*=e,n},ie=(t,e,A)=>{let n=0;return t.forEach((t=>{n=Math.max(n,Ae(t,e,A))})),n},ae={stripControlCharacters:!0,vertical:!1,uppercase:!1},oe=(t,e=ae)=>{const A={...ae,...e};let n=t||"";return A.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),A.uppercase&&(n=n.toUpperCase()),A.vertical&&(n=n.split("").join("\n")),n},re=(t,e)=>t.map(((t,A)=>[t,e[A]])),se=(t="center",e=!1)=>e?"center":t,ce=t=>"left"===t?"start":"right"===t?"end":"middle",ge=(t,e,A)=>t.fontData?{...t,...(()=>{if(t.algorithm===U.Traditional){const n=_t(e,t,A,t.lineHeight);return{text:n.lines.join("\n"),height:n.requiredHeight,width:n.requiredWidth,fontSize:n.fontSize,input:e}}return{text:e}})()}:t,le=1.1;var Be={};y(Be,"colorDefinitionPrintValue",(()=>we)),y(Be,"spotColorDefinitionString",(()=>he)),y(Be,"svgColorValueToDefinition",(()=>de));const we=t=>{const e=he(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},he=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),A=e.lastIndexOf("/");return`icc-named-color(${e.slice(A+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},de=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const A=e[1].match(/\(([^)]+)\)/gm);if(!A)throw new Error("Unhandled state of color value in SVG");const n=A[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:n[0],namedColor:n[1]}}},Ee=t=>{const e=(t.rotation||0)*Math.PI/180,n=Math.cos(e),i=-Math.sin(e),a=`text-path-${t.id}`,o=t.x+(t.curved?0:t.width/2),r=t.y+(t.curved?0:t.height/2),s=(t.text||"").split("\n");return t.curved&&!t.paths?null:t.fontData?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("defs",{children:[(0,A.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${t.fontData.name}';\n src: url('${t.fontData.assetUrl}') format('truetype');\n }\n `}}),t.curved&&t.paths?(0,A.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,A.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:`matrix(${n}, ${-i}, ${i}, ${n}, ${o}, ${r})`,children:(0,A.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${t.fontData.name}'`,fontSize:t.fontSize,fontStyle:"normal",fontWeight:"normal",fill:t._renderingConfiguration?.spotColors&&t.fillSpotColorDefinition?`${t.fill} ${he(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,A.jsx)(Qe,{text:t.text||"",curvedPathId:a,align:t.align}):s.map(((e,n)=>(0,A.jsx)(ue,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:n,amountLines:s.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},n)))})})})]}):null},ue=t=>(0,A.jsx)("tspan",{textAnchor:ce(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:le),A=t.textboxHeight/2;if("top"===t.verticalAlign)return-A+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const n=t.amountLines-1-t.thisLineIdx;return A-t.fontSize/4-n*e}const n=(t.amountLines-1)/2;return(t.thisLineIdx-n)*e+t.fontSize/4})()}px`,children:t.text}),Qe=t=>{const e=`#${t.curvedPathId}`;return(0,A.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:ce(t.align),href:e,xlinkHref:e,children:t.text})};y({},"Illustration",(()=>ye));var Ce={};y(Ce,"traverse",(()=>pe)),y(Ce,"sanitizeSvgTree",(()=>fe)),y(Ce,"modifySVGWithElementProperties",(()=>De)),y(Ce,"generateSVGWithUnknownColors",(()=>Ie));const me=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],pe=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>pe(t,e)))},fe=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const A=[];pe(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,c.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{A.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),pe(t,(t=>{A.forEach((e=>{e.selectors?.forEach((A=>{((t,e)=>{try{return t.matches(e)}catch(A){return t.classList.contains(e.substring(1))}})(t,A)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},De=(t,e,A,n,i)=>{const a=(t=>vt().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,A)=>{t.setAttribute("height",`${A}px`),t.setAttribute("width",`${e}px`)})(a,e,A),((t,e,A)=>{pe(t,(t=>{const n=t.attributes.getNamedItem("fill");n&&"none"!==n.value&&t.classList.forEach((n=>{if(n.startsWith("spiff-fill")){const i=e[n];i&&t.setAttribute("fill",A?we(i):i.browserValue)}}));const i=t.attributes.getNamedItem("stroke");i&&"none"!==i.value&&t.classList.forEach((n=>{if(n.startsWith("spiff-stroke")){const i=e[n];i&&t.setAttribute("stroke",A?we(i):i.browserValue)}}))}))})(a,n,i),(t=>Ht().serializeToString(t))(a)},Ie=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],A=e?.length>0?e[0]:"",n=vt().parseFromString(A,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");fe(n);const i={};pe(n,(t=>{me.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const A=de(e.value),n=`spiff-fill-${A.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",A.browserValue),t.classList.add(n),i[n]=A}const A=t.attributes.getNamedItem("stroke");if(A&&"none"!==A.value){const e=de(A.value),n=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(n),t.setAttribute("stroke",e.browserValue),i[n]=e}}));const a=Ht().serializeToString(n);return{colors:i,svg:a}},ye=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,A.jsx)(dt,{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=tt(e),i=Math.cos(n),a=-Math.sin(n),o=`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `;if(!t.svg)throw new Error(`Illustration element ${t.id} (stepName ${t.stepName}) lacked svg from src ${t.src} at render time.`);return(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:o,dangerouslySetInnerHTML:{__html:De(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class Me{constructor(){this.id=F(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(t){this.stateCallbacks.push(t)}unregisterStateCallback(t){this.stateCallbacks.filter((e=>e!==t))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((t=>t()))}apply(t,e){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.nextCommands=[],e||this.prevCommands.push(t)}undo(){if(!this.state)return;const t=this.prevCommands.pop();if(!t)return;const e=t.undo();t.varying?this.state={...this.state,variation:e}:this.state={...this.state,transaction:e},this.nextCommands.push(t),this.runStateCallbacks()}redo(){if(!this.state)return;const t=this.nextCommands.pop();t&&(this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.prevCommands.push(t))}flattenSequence(t,e){const A=this.prevCommands.filter((e=>e.sequenceId===t)).pop();A&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),A?.overrideOldState(e),this.prevCommands.push(A))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],A=this.state.variation?.layouts?.[t],n=e?.layout||A?.layout;if(!n)throw new Error(`No layout: ${t}`);const i=[...e?.elements||[],...A?.elements||[]];return this.getLayoutDataWithState(n,i)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(t)].map((t=>this.getLayoutById(t)))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:A=>Fe(t,e,A)}}initialize(t,e){if(e)return void(this.state={transaction:e});let A={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{A=new Le(t).apply(A)})),this.runStateCallbacks(),this.state={transaction:A}}commandReducer(t,e){if(e.varying){const A={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(A)}}{const A=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(A)}}}}const xe=t=>"image"===t.type?(0,A.jsx)(dt,{...t},t.id):"frame"===t.type?(0,A.jsx)(Et,{...t},t.id):"illustration"===t.type?(0,A.jsx)(ye,{...t},t.id):"textbox"===t.type?(0,A.jsx)(Ee,{...t},t.id):null,Fe=(t,e,n)=>{const i=n.renderingConfiguration,a=i?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,A.jsx)(q,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:n.width||t.width,height:n.height||t.height,viewBox:i?.region?{x:i.region.left,y:i.region.top,width:i.region.width,height:i.region.height}:{x:0,y:0,width:t.width,height:t.height},configuration:i,outlineArea:n.outlineArea,maxHeight:n.maxHeight,maxWidth:n.maxWidth,position:n.position,borderRadius:n.borderRadius,outlineColor:n.outlineColor})};function Ye(t){return t.sort(((t,e)=>{const A=t.layer||0,n=e.layer||0;if(A<n)return-1;if(A>n)return 1;const i=t.layerIndex||0,a=e.layerIndex||0;return i<a?-1:i>a?1:0}))}class ve extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,ve.prototype)}}const Se=(t,e)=>Ne(t,e).elements.find((e=>e.id===t)),Ne=(t,e)=>{const A=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!A)throw new ve;return A},Re=(t,e)=>{const A=Ye([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:A,modificationID:F()}},He=async(t,e)=>{const A=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],n=[...new Set(A)];for(let A=0;A<n.length;A++){const i=n[A],a=t.layouts[i],o=e?.layouts[i],r=(a||o).elements.filter((t=>"illustration"===t.type));for(let t=0;t<r.length;++t){const e=r[t];if(e.src&&!e.svg){const t=await Nt(e.src),A=await Ie(t);e.svg=De(A.svg,e.width,e.height,e.colors)}}}};class Pe{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class Ue extends Pe{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class Ge extends Pe{constructor(t,e,A){super(),this.id=t,this.x=e,this.y=A}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,x:this.x,y:this.y},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class be extends Pe{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,rotation:this.angle},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class ke extends Pe{constructor(t,e,A){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(A)}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;let A={...e,width:this.width,height:this.height};if("frame"===e.type){const t=A;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=A,n=(t.algorithm&&t.algorithm!==U.Autosize?t.input:t.text)??"";A=ge(t,n,e)}const n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Je extends Pe{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class Le extends Pe{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:F()}}}}}class Oe extends Pe{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:F()}})),A={};return e.forEach((t=>{A[t.layout.id]=t})),{...t,layouts:A}}}class Te extends Pe{constructor(t,e){super(),this.element=t,this.layout=e}apply(t){this.oldState=t,t.layouts[this.layout.id]||(t.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const e=t.layouts[this.layout.id].elements;if(e.find((t=>t.id===this.element.id)))throw new Error(`Failed to apply new ${this.element.type} element because ID ${this.element.id} already taken`);if(this.element.productOverlay||0===e.length){const A=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,A)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:A,modificationID:F()}}}}const A=e[e.length-1],n=A.productOverlay?A:null;let i;if(n&&e.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)i=[...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,i=[...e,this.element]}return n&&i.push(n),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:i,modificationID:F()}}}}assignIndex(t,e){if(0===e.length)return 0;const A=e.filter((e=>(e.layer||0)===(t.layer||0))).sort(((t,e)=>(t.layerIndex||0)-(e.layerIndex||0)))[e.length-1]?.layerIndex;return void 0!==A?A+1:0}}class ze extends Pe{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const A=Object.values(t.layouts).map((t=>(t.elements.filter((t=>t.id!==this.id)).length!==t.elements.length&&(e=!0),{...t,elements:t.elements.filter((t=>t.id!==this.id)),modificationID:F()})));e||console.log(`Failed to delete element ${this.id}`);const n={};return A.forEach((t=>{n[t.layout.id]=t})),{...t,layouts:n}}}class je extends Pe{constructor(t,A){super(),this.el=I(e)(t),this.layout=A,this.el.id=F(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new Te(this.el,this.layout).apply(t)}}class Ke extends Pe{constructor(t,e,A){super(),this.id=t,this.color=e,this.textFillSpotColor=A}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Ve extends Pe{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,fontSize:this.size},n=Ne(e.id,Object.values(t.layouts)),i=(e.algorithm&&e.algorithm!==U.Autosize?e.input:e.text)??"",a=Re(ge(A,i),n);return{...t,layouts:{...t.layouts,[n.layout.id]:a}}}}class We extends Pe{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,algorithm:this.algorithm},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Xe extends Pe{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,fontData:this.fontData},n=Ne(e.id,Object.values(t.layouts)),i=(e.algorithm&&e.algorithm!==U.Autosize?e.input:e.text)??"",a=Re(ge(A,i),n);return{...t,layouts:{...t.layouts,[n.layout.id]:a}}}}class qe extends Pe{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,align:this.align},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Ze extends Pe{constructor(t,e,A){super(),this.id=t,this.imageData=e,this.offsets=A}apply(t){this.oldState=t;const e=Ne(this.id,Object.values(t.layouts)),A=e.elements.findIndex((t=>t.id===this.id)),n=e.elements[A].pattern,i=[...e.elements];i.splice(A,1,{...e.elements[A],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:i,modificationID:F()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class $e extends Pe{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A=Ne(e.id,Object.values(t.layouts)),n=Re(ge(e,this.text,e),A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class _e extends Pe{constructor(t,e,A){super(),this.id=t,this.className=e,this.fill=A}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A=e.colors||{},n=A[this.className];A[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...e,colors:A},a=Ne(e.id,Object.values(t.layouts)),o=Re(i,a);return{...t,layouts:{...t.layouts,[a.layout.id]:o}}}}class tA extends Pe{constructor(t,e,A){super(),this.id=t,this.svgBody=e,this.objectURL=A}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class eA extends Pe{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Se(this.id,Object.values(t.layouts)).id)throw new ve;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(A,1)[0]);const 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:F()}}}}}class AA extends Pe{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");const n=A.elements.findIndex((t=>t.id===this.id));A.elements.splice(n,1),A.elements.unshift(e);const i=[...A.elements],a=i.splice(n,1)[0];return i.splice(n,0,a),i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[A.layout.id]:{...t.layouts[A.layout.id],elements:i,modificationID:F()}}}}}class nA extends Pe{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Se(this.id,Object.values(t.layouts)).id)throw new ve;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id)),n=A+1,i=[...e.elements],a=i.splice(A,1)[0];return i.splice(n,0,a),i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:i,modificationID:F()}}}}}class iA extends Pe{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Se(this.id,Object.values(t.layouts)).id)throw new ve;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id)),n=A-1,i=[...e.elements],a=i.splice(A,1)[0];return i.splice(n,0,a),i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:i,modificationID:F()}}}}}class aA extends Pe{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[A.layout.id]:Re({...e,layer:this.value},A)}}}}var oA={};y(oA,"patternImageDataCache",(()=>wA)),y(oA,"frameDataCache",(()=>hA)),y(oA,"generateFrameSVG",(()=>dA)),y(oA,"generateDefaultRectangleFrameSvg",(()=>EA)),y(oA,"getVariant",(()=>uA)),y(oA,"getFrameData",(()=>QA)),y(oA,"calculateOffsets",(()=>CA)),y(oA,"getPatternImageData",(()=>mA)),y(oA,"GetSVGDimensions",(()=>pA)),y(oA,"svgStringDimensions",(()=>fA));var rA={};y(rA,"getExifOrientation",(()=>cA)),y(rA,"canvasDims",(()=>gA)),y(rA,"getAttributesFromArrayBuffer",(()=>lA));let sA=null;const cA=t=>new Promise((e=>{const A=kt(t);(0,r.fromBuffer)(t).then((t=>{const n=t?.mime;if("image/jpeg"!==n)return e(1);(new(0,l.ExifImage)).loadImage(A,((t,A)=>e(t?1:A.image.Orientation||1)))}))})),gA=t=>{const e=8192,A=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[A*e,e]:[e,e/A]},lA=async t=>{const e=await(async t=>{const e=await Gt(t),A=await(0,g.loadImage)(e),[n,i]=gA(A),a=await(async()=>{if(null!==sA)return!sA;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return sA=2===t.width&&3===t.height,!sA})();if(!a){const t=(0,g.createCanvas)(n,i);return t.getContext("2d").drawImage(A,0,0,n,i),t}const o=await cA(t),[r,s]=o>4?[i,n]:[n,i],c=(0,g.createCanvas)(r,s),l=c.getContext("2d");switch(o){case 2:l.translate(r,0),l.scale(-1,1);break;case 3:l.translate(r,s),l.rotate(Math.PI);break;case 4:l.translate(0,s),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(-r,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-r,s),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-s)}return l.drawImage(A,0,0,r,s),c})(t);return"image/jpeg"===(await(0,r.fromBuffer)(t))?.mime?{dataUrl:e.toDataURL("image/jpeg",1),height:e.height,width:e.width}:{dataUrl:e.toDataURL(),height:e.height,width:e.width}};y({},"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))}},wA=new Map,hA=new Map,dA=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return EA(t)}return Nt(e)},EA=t=>{const e=t.width,A=e/t.height,n=Math.max(e,512),i=n/A;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${n} ${i}'>\n <path id="target-path" d='M0 0 h ${n} v ${i} h ${-n} Z' />\n </svg>\n `},uA=(t,e)=>{if(!e)return;const A=e.variants?.find((e=>e.id===t.frameVariantId))||BA(e);if(!A)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!A.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return A},QA=async t=>{const e=vt().parseFromString(t,"image/svg+xml"),A=e.querySelector("svg");if(!A)throw new Error("Malformed frame SVG: <svg> tag not found");const n=A.getAttribute("viewBox");if(!n)throw new Error("SVG missing viewBox.");const i=n.split(" "),a=parseFloat(i[3])||1,o=parseFloat(i[2])||1,r=e.getElementById("target-path"),s=e.getElementsByClassName("st0").item(0);if(r){const t=r.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:o,height:a};return hA.set(t,e),e}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:o,height:a};return hA.set(t,e),e}throw new Error("Malformed frame SVG")},CA=(t,e,A)=>{const n=e.width>=e.height,i=t.width>=t.height,a=e.width/2,o=e.height/2,r=(n?e.height:e.width)/(i?t.width:t.height),s=A?.scale||r,c=a-t.width/2*s,g=A?.left||c,l=o-t.height/2*s;return{x:g,y:A?.top||l,zoom:s}},mA=async t=>{if(wA.has(t))return wA.get(t);if(t.endsWith("svg")){const e=await pA(t),A=e.width,n=e.height,i={src:t,width:A,height:n,aspect:A/n};return wA.set(t,i),i}{const e=await St(t),A=await lA(e),n={src:t,width:A.width,height:A.height,aspect:A.width/A.height};return wA.set(t,n),n}},pA=async t=>{const e=await Nt(t);return fA(e)},fA=t=>{const e=vt().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const A=e.getAttribute("viewBox"),n=e.getAttribute("width"),i=e.getAttribute("height"),a=A?A?.split(" ").map((t=>Number(t))):[0,0,Number(n),Number(i)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var DA={};y(DA,"determineCorrectFontSizeAndLines",(()=>yA)),y(DA,"determineCorrectTextboxRegion",(()=>MA));const IA=(t,e,A,n,i)=>{let a=e.map((t=>t.split("\n"))).flat(),o=a.length,r=a.map((t=>Ae(t,n,i)));const s=i.getApproximateHeight()*n;let c=!0;for(;c;){if(s+(o-1)*A>t.height)return[null,null];const e=Math.max(...r);if(e<=t.width)return[a,e];const g=r.reduce(((t,e,A,n)=>e>n[t]?A:t),0),l=a[g];let B=!1,w=l.length;for(;!B&&w>-1;){w=l.lastIndexOf(" ",w-1);const e=[l.slice(0,w),l.slice(w+1)],A=e.map((t=>Ae(t,n,i)));A[0]<=t.width&&(a=[...a.slice(0,g),...e,...a.slice(g+1)],r=[...r.slice(0,g),...A,...r.slice(g+1)],o+=1,B=!0)}B||(c=!1)}return[null,null]},yA=(t,e,A,n,i)=>{let a,o;const r=Vt(e),s=r.getFont();if(i.size){const e=t/s.unitsPerEm;return[a,o]=IA(A,n,t,e,r),[i.size,a,o]}let c=6-ee;if(n.length>0){let t=n,e=0;for(;(!i.maxSize||c<=i.maxSize)&&t;)c+=ee,e=c/s.unitsPerEm,[t,o]=IA(A,n,c,e,r)}c>6&&(c-=ee),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/s.unitsPerEm;return[a,o]=IA(A,n,c,g,r),[c,a,o]},MA=(t,e,A,n,i)=>{let a={...t},o={...t},[r,s,c]=yA(A,e,o,n,{size:0,minSize:A,maxSize:A});var g,l;return c&&c<a.width&&(o.width=c,"left"===i?(o.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),o.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):o.left+="right"===i?a.width-c:(a.width-c)/2,[r,s]=yA(A,e,o,n,{size:A}),r===A&&s&&(g=n,l=s,g.map(((t,e)=>[t,l[e]]))).every((([t,e])=>t===e))&&(a=o)),a};var xA={};y(xA,"svgObjectURL",(()=>vA)),y(xA,"LayoutElementFactory",(()=>NA));const FA=(t,e)=>{const A=t.layoutState.elements.filter((t=>t.layer===e)),n=Math.max(...A.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(n,0)+1},YA=async t=>new Promise((e=>{Nt(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),vA=async t=>{const e=vt().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const A=(new XMLSerializer).serializeToString(e),n=document.createElement("canvas"),i=n.getContext("2d"),a=await B.Canvg.from(i,A,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),o=e.getAttribute("width"),r=e.getAttribute("height"),s=2048;if(r&&o){const t=parseFloat(r),e=parseFloat(o)/t;e>1?a.resize(s,s/e):a.resize(s*e,s)}else a.resize(s,s);return await a.render(),await(async t=>new Promise(((e,A)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((A=>{if(!A){if(0===t.width||0===t.height)throw new Error(`Canvas dimensions are invalid (${t.width},${t.height})`);if(t.width*t.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${t.width},${t.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}e(URL.createObjectURL(A))}))}catch(t){A(t)}})))(n)},SA=async(t,e,A,n)=>{const i=t.layoutState.layout.useEditableArea&&t.layoutState.layout.editableArea||{width:t.layoutState.layout.width,height:t.layoutState.layout.height,x:0,y:0},a=i.width<i.height?i.width:i.height,o=t.layoutState.layout.useEditableArea?a/1.3:a/2,r={top:i.y+i.height/2-o/2,left:i.x+i.width/2-o/2,width:o,height:o,rotation:0,panelId:t.layoutState.layout.panelId};if(A&&e===N.Illustration){const t=await Ie(await YA(A)),e=vt().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const n=r.height,i=e.split(" "),a=(parseFloat(i[2])||1)/(parseFloat(i[3])||1);r.height=r.width/a,r.top+=(n-r.height)/2}if(A&&e===N.Image){const t=r.height,e=await St(A),n=await lA(e),i=n.width/n.height;r.height=r.width/i,r.top+=(t-r.height)/2}if(A&&e===N.Textbox&&n?.text&&n?.fontScale){const t={assetUrl:A,name:(await jt(A)).names.fullName.en},e=Vt(t),a=Ae(n.text,n?.fontScale,e);r.width=Math.min(a,.85*i.width),r.left=i.x+i.width/2-r.width/2}return r};class NA{static async getFrame(t,e){const A=await dA(e.region,e.src),n=await QA(A),i=e.region||await SA(t,N.Frame);return{id:F(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||FA(t,i.layer||0),rotation:i.rotation,scaleX:i.width/n.width,scaleY:i.height/n.height,path:n.path,type:N.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:i.immutable}}static async getImage(t,e){const A=e.region||await SA(t,N.Image,e.src);return{id:F(),src:e.src,type:N.Image,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||FA(t,A.layer||0),immutable:A.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:A,fontSrc:n,designInputStep:i}=e,a=await jt(n),o={assetUrl:n,name:a.names.fullName.en},r=i?.text||A.defaultText||"",s=A.replaceableText?A.replaceableText.replace("{{}}",r):r,c=oe(s,{vertical:A.vertical,uppercase:A.uppercase}),g=e.region||await SA(t,N.Textbox,n,{text:c,fontScale:A.size?A.size/a.unitsPerEm:void 0}),l=ge({id:F(),type:N.Textbox,x:g.left,y:g.top,width:g.width,height:g.height,align:se(A.textAlign,A.vertical),curved:A.curved,fill:i?.color||A.colour||"#000000",fontData:o,layer:g.layer||0,layerIndex:g.layerIndex||FA(t,g.layer||0),paths:A.paths,rotation:g.rotation,vertical:A.vertical,verticalAlign:A.verticalAlign||"middle",algorithm:U.Traditional,fontSize:A.size||Math.max(Math.round(.025*g.height),1),text:c,input:r},c),B=te({...g,height:l.height},o,l.fontSize,l?.text?.split("\n")||[],l.align);return{...l,x:B.left,y:B.top+(g.height-B.height)/2,width:B.width,height:B.height}}static async getShape(t,e){const A=`\n <svg\n xmlns="http://www.w3.org/2000/svg"\n xmlnsXlink="http://www.w3.org/1999/xlink"\n xmlSpace="preserve"\n preserveAspectRatio="none"\n version="1.1"\n width="1"\n height="1"\n viewBox="0 0 1 1"\n >\n <rect\n x="0"\n y="0"\n width="1"\n height="1"\n class="spiff-fill-shape"\n fill="${e.color}"\n />\n </svg>\n `,n={};n["spiff-fill-shape"]={browserValue:e.color};const i=e.region||await SA(t,N.Illustration),a=F();return{stepRegion:e.region,colors:n,id:a,svg:A,type:N.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||FA(t,i.layer||0),immutable:i.immutable}}static async getIllustration(t,e){const A=e.region||await SA(t,N.Illustration,e.src),n=await Ie(await YA(e.src)),i=await vA(n.svg),a=F();return{cachedObjectURL:i,stepRegion:e.region,colors:n.colors,id:a,src:e.src,svg:n.svg,type:N.Illustration,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||FA(t,A.layer||0),immutable:A.immutable}}}function RA(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class HA extends Error{constructor(t){super(t),this.name=this.constructor.name}}class PA extends HA{constructor(t){super(`ConfigurationError - ${t}`)}}class UA extends PA{constructor(t){super(`Option not Configured: ${t.stepTitle}`),RA(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class GA extends PA{constructor(t){super(`Panel not Found: ${t.panelId}`),RA(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class bA extends PA{constructor(t){super(`Asset not found for variant: ${t.name}`),RA(this,"variant",void 0),this.variant=t}}class kA extends PA{constructor(t){super(`Resource not found for asset: ${t.name}`),RA(this,"asset",void 0),this.asset=t}}class JA extends PA{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),RA(this,"step",void 0),this.step=t}}class LA extends HA{constructor(t){super(`ImplementationError - ${t}`)}}class OA extends LA{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class TA extends LA{constructor(t){super(`Parsing Error: ${t}`)}}class zA extends LA{constructor(t){super(`Client Error: ${t}`)}}class jA extends LA{constructor(t){super(`Resource Generation Failed: ${t}`)}}function KA(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class VA{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}class WA{constructor(){KA(this,"storage",new Map)}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}const XA=(()=>{try{return localStorage?new VA:new WA}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new WA}})();function qA(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const ZA=new class{constructor(){qA(this,"defaultServerUrl","https://api.spiff.com.au"),qA(this,"defaultServicesApiUrl","https://services.spiff.com.au"),qA(this,"defaultHubUrl","https://hub.spiff.com.au"),qA(this,"serverUrl",void 0),qA(this,"servicesApiUrl",void 0),qA(this,"hubUrl",void 0),qA(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 $A(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let _A;const tn=t=>{_A=t};const en=new class{constructor(){$A(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),ZA.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${ZA.getServerUrl()}/graphql`,fetch:d.fetch}),A=(0,w.setContext)((async(t,{headers:e})=>{const A=e||{},n=await(async()=>{const t={transactionOwnerId:_A};return"undefined"!=typeof window&&window.location.href.includes("/workflows/product/")?{...await new Promise((t=>{const e=ZA.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void t({});const A=n=>{n.origin===e&&(window.removeEventListener("message",A),t(n.data))};window.parent!==window&&(window.addEventListener("message",A,!1),window.parent.postMessage("ready",e))})),...t}:t})();return n.bearer&&(A.Authorization=`Bearer ${n.bearer}`),n.partnerId&&(A.partnerId=n.partnerId),n.activeIntegration&&(A.activeIntegration=n.activeIntegration),n.transactionOwnerId&&(A.transactionOwnerId=n.transactionOwnerId),{headers:A}})),n=(0,h.onError)((({operation:t,graphQLErrors:e,networkError:A})=>{(e||[]).forEach((({message:e,locations:A,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(A,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(t.variables))})),A&&console.log("GraphQL Network error")}));const i=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}}},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,A,e]),cache:i,name:"Core"})}};function An(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const nn=t.gql`
1
+ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/jsx-runtime"),n=require("opentype.js"),i=require("buffer"),a=require("axios"),o=require("https"),r=require("file-type"),s=require("util"),c=require("css"),g=require("canvas"),l=require("exif"),B=require("canvg"),w=require("@apollo/client/link/context"),h=require("@apollo/client/link/error"),d=require("cross-fetch"),E=require("react"),u=require("lodash.isequal"),Q=require("react-dom/server"),C=require("qrcode"),m=require("svg-path-bbox"),p=require("lodash.debounce");function f(t,e,A,n){Object.defineProperty(t,e,{get:A,set:n,enumerable:!0,configurable:!0})}var D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function I(t){return t&&t.__esModule?t.default:t}function y(t,e,A,n){Object.defineProperty(t,e,{get:A,set:n,enumerable:!0,configurable:!0})}f(module.exports,"SpiffCommerceClient",(()=>Ro)),f(module.exports,"CommandContext",(()=>Me)),f(module.exports,"spiffCoreConfiguration",(()=>ZA)),f(module.exports,"PromiseQueue",(()=>Ci)),f(module.exports,"QueueablePromise",(()=>Qi)),f(module.exports,"MockWorkflowManager",(()=>Po)),f(module.exports,"InformationMessageType",(()=>Xa)),f(module.exports,"StepHandle",(()=>Ao)),f(module.exports,"TextStepHandle",(()=>wo)),f(module.exports,"FrameStepHandle",(()=>ko)),f(module.exports,"BulkStepHandle",(()=>oo)),f(module.exports,"ShapeStepHandle",(()=>Bo)),f(module.exports,"IllustrationStepHandle",(()=>ro)),f(module.exports,"MaterialStepHandle",(()=>so)),f(module.exports,"ModelStepHandle",(()=>co)),f(module.exports,"PictureStepHandle",(()=>go)),f(module.exports,"QuestionStepHandle",(()=>lo)),f(module.exports,"BulkPriceCalculationStrategy",(()=>Sn)),f(module.exports,"OptionNotFoundError",(()=>UA)),f(module.exports,"LayoutNotFoundError",(()=>GA)),f(module.exports,"AssetNotFoundError",(()=>bA)),f(module.exports,"ResourceNotFoundError",(()=>kA)),f(module.exports,"MisconfigurationError",(()=>JA)),f(module.exports,"ParseError",(()=>TA)),f(module.exports,"UnhandledBehaviorError",(()=>OA)),f(module.exports,"assetService",(()=>Bn)),f(module.exports,"designService",(()=>Io)),f(module.exports,"createDesign",(()=>po)),f(module.exports,"optionService",(()=>En)),f(module.exports,"persistenceService",(()=>XA)),f(module.exports,"graphQlManager",(()=>en)),f(module.exports,"toast",(()=>Oa)),f(module.exports,"FrameService",(()=>ya)),f(module.exports,"getBoundedOffsets",(()=>Da)),f(module.exports,"frameStepService",(()=>Ra)),f(module.exports,"modelStepService",(()=>Ua)),f(module.exports,"materialStepService",(()=>Pa)),f(module.exports,"shapeStepService",(()=>Ja)),f(module.exports,"questionStepService",(()=>ka)),f(module.exports,"digitalContentStepService",(()=>Sa)),f(module.exports,"moduleStepService",(()=>Ga)),f(module.exports,"pictureStepService",(()=>ba)),f(module.exports,"textStepService",(()=>Va)),f(module.exports,"illustrationStepService",(()=>Ha)),f(module.exports,"ProductCameraRig",(()=>Yn)),f(module.exports,"FrameStep",(()=>Go)),f(module.exports,"ConversionLocation",(()=>Rn)),f(module.exports,"ConversionDataType",(()=>Pn)),f(module.exports,"getWorkflow",(()=>So)),f(module.exports,"AssetType",(()=>z)),f(module.exports,"BringForwardCommand",(()=>nA)),f(module.exports,"BringToFrontCommand",(()=>eA)),f(module.exports,"BringToBackCommand",(()=>AA)),f(module.exports,"CanvasCommand",(()=>Pe)),f(module.exports,"CreateElementCommand",(()=>Te)),f(module.exports,"CreateLayoutCommand",(()=>Le)),f(module.exports,"DeleteElementCommand",(()=>ze)),f(module.exports,"FontAlignmentCommand",(()=>qe)),f(module.exports,"FontColorCommand",(()=>Ke)),f(module.exports,"FontSizeCommand",(()=>Ve)),f(module.exports,"FontSourceCommand",(()=>Xe)),f(module.exports,"GroupCommand",(()=>Je)),f(module.exports,"LayoutElementFactory",(()=>NA)),f(module.exports,"LayoutElementType",(()=>N)),f(module.exports,"MoveCommand",(()=>Ge)),f(module.exports,"ResizeCommand",(()=>ke)),f(module.exports,"RotateCommand",(()=>be)),f(module.exports,"SendBackwardsCommand",(()=>iA)),f(module.exports,"StepAspectType",(()=>W)),f(module.exports,"StepType",(()=>K)),f(module.exports,"TextChangeCommand",(()=>$e)),f(module.exports,"UnitOfMeasurement",(()=>b)),f(module.exports,"dataUrlFromExternalUrl",(()=>Ut)),f(module.exports,"findElement",(()=>Se)),f(module.exports,"frameDataCache",(()=>hA)),f(module.exports,"generate",(()=>F)),f(module.exports,"getAxisAlignedBoundingBox",(()=>$)),f(module.exports,"generateSVGWithUnknownColors",(()=>Ie)),f(module.exports,"getAttributesFromArrayBuffer",(()=>lA)),f(module.exports,"rehydrateSerializedLayout",(()=>He)),f(module.exports,"getFrameData",(()=>QA)),f(module.exports,"getSvgElement",(()=>Fe)),f(module.exports,"loadFontFromDataUrl",(()=>Kt)),f(module.exports,"loadFontFromExternalUrl",(()=>jt)),f(module.exports,"determineCorrectFontSizeAndLines",(()=>yA)),f(module.exports,"patternImageDataCache",(()=>wA)),f(module.exports,"generateCommands",(()=>qi)),f(module.exports,"registerJSDOM",(()=>It)),f(module.exports,"minZoom",(()=>Bi)),f(module.exports,"AdvancedEditor",(()=>oa)),f(module.exports,"TransformWrapper",(()=>Jo)),f(module.exports,"EditorCore",(()=>aa)),f(module.exports,"useLayouts",(()=>Cn)),f(module.exports,"useEditorState",(()=>Fn)),f(module.exports,"useEditorInteraction",(()=>hi)),f(module.exports,"useShortcutCombination",(()=>di)),f(module.exports,"commandReducer",(()=>In)),f(module.exports,"getDefaultState",(()=>Dn)),f(module.exports,"CommandContextContext",(()=>un)),f(module.exports,"AdvancedEditorStateProvider",(()=>Mn)),f(module.exports,"AdvancedEditorContext",(()=>yn)),f(module.exports,"UICommand",(()=>xn)),f(module.exports,"EditorSubMenu",(()=>pn)),f(module.exports,"ElementEventType",(()=>Ln)),f(module.exports,"KeyEvent",(()=>Tn)),f(module.exports,"gatherVaryingStepAspects",(()=>da));var M="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==D?D:{},x={};y(x,"CanvasCommand",(()=>Pe)),y(x,"UpdateWorkflowStateCommand",(()=>Ue)),y(x,"MoveCommand",(()=>Ge)),y(x,"RotateCommand",(()=>be)),y(x,"ResizeCommand",(()=>ke)),y(x,"GroupCommand",(()=>Je)),y(x,"CreateLayoutCommand",(()=>Le)),y(x,"ClearLayoutCommand",(()=>Oe)),y(x,"CreateElementCommand",(()=>Te)),y(x,"DeleteElementCommand",(()=>ze)),y(x,"CloneElementCommand",(()=>je)),y(x,"FontColorCommand",(()=>Ke)),y(x,"FontSizeCommand",(()=>Ve)),y(x,"FontAlgorithmCommand",(()=>We)),y(x,"FontSourceCommand",(()=>Xe)),y(x,"FontAlignmentCommand",(()=>qe)),y(x,"UpdateFramePattern",(()=>Ze)),y(x,"TextChangeCommand",(()=>$e)),y(x,"IllustrationColorCommand",(()=>_e)),y(x,"IllustrationCacheCommand",(()=>tA)),y(x,"BringToFrontCommand",(()=>eA)),y(x,"BringToBackCommand",(()=>AA)),y(x,"BringForwardCommand",(()=>nA)),y(x,"SendBackwardsCommand",(()=>iA)),y(x,"LayerCommand",(()=>aA)),y({},"generate",(()=>F));const F=()=>{const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()};var Y={};y(Y,"ElementNotFoundError",(()=>ve)),y(Y,"findElement",(()=>Se)),y(Y,"findLayoutForElement",(()=>Ne)),y(Y,"updatedLayoutForElement",(()=>Re)),y(Y,"rehydrateSerializedLayout",(()=>He));var v={};y(v,"CommandContext",(()=>Me)),y(v,"getSvgElement",(()=>Fe)),y(v,"elementFactory",(()=>xe)),y(v,"sortElementsByLayersWithIndex",(()=>Ye)),y({},"SVGLayout",(()=>q));var S={};let N;var R;let H;var P;let U;var G;let b;var k;let J;var L;let O;var T;let z;var j;let K;var V;let W;var X;y(S,"LayoutElementType",(()=>N)),y(S,"LayoutRenderingPurpose",(()=>H)),y(S,"TextAlgorithm",(()=>U)),y(S,"UnitOfMeasurement",(()=>b)),y(S,"ScaleAxis",(()=>J)),y(S,"MaterialEffectMode",(()=>O)),y(S,"AssetType",(()=>z)),y(S,"StepType",(()=>K)),y(S,"StepAspectType",(()=>W)),(R=N||(N={})).Frame="frame",R.Image="image",R.Illustration="illustration",R.Textbox="textbox",(P=H||(H={})).ThreeD="ThreeD",P.FreeDesign="FreeDesign",P.Print="Print",(G=U||(U={})).Autosize="Autosize",G.Traditional="Traditional",(k=b||(b={})).Pixel="px",k.Millimeter="mm",k.Centimeter="cm",(L=J||(J={}))[L.North=0]="North",L[L.Northeast=1]="Northeast",L[L.East=2]="East",L[L.Southeast=3]="Southeast",L[L.South=4]="South",L[L.Southwest=5]="Southwest",L[L.West=6]="West",L[L.Northwest=7]="Northwest",(T=O||(O={})).None="None",T.RemoveWhenSelected="RemoveWhenSelected",T.ApplyWhenSelected="ApplyWhenSelected",(j=z||(z={})).Font="Font",j.Frame="Frame",j.Illustration="Illustration",j.Image="Image",j.Model="Model",j.Material="Material",j.Color="Color",j.QuestionnaireCollateral="QuestionnaireCollateral",j.RequestCollateral="RequestCollateral",j.SignupCollateral="SignupCollateral",j.Video="Video",j.ColorProfile="ColorProfile",(V=K||(K={})).Bulk="Bulk",V.DigitalContent="DigitalContent",V.Finish="Finish",V.Frame="Frame",V.Illustration="Illustration",V.Introduction="Introduction",V.Material="Material",V.Model="Model",V.Module="Module",V.Picture="Picture",V.Photo="Photo",V.ProductOverlay="ProductOverlay",V.Question="Question",V.Shape="Shape",V.SilentIllustration="SilentIllustration",V.Text="Text",(X=W||(W={})).Color="Color",X.Colors="Colors",X.Selection="Selection",X.Selections="Selections",X.Text="Text",X.Upload="Upload";const q=({backgroundColor:t,outlineColor:e,borderRadius:n,configuration:i,elements:a,height:o,maxHeight:r,maxWidth:s,outlineArea:c,position:g,preserveAspectRatio:l,viewBox:B,width:w})=>{const h=n||0,d=2*(c?.scale||1),E=B||{x:0,y:0,width:w,height:o},u=`${E.x} ${E.y} ${E.width} ${E.height}`,Q=F(),C=i.purpose===H.FreeDesign&&(0,A.jsx)("defs",{children:(0,A.jsx)("clipPath",{id:"viewboxClip",children:(0,A.jsx)("rect",{width:E.width,height:E.height,rx:h})})}),m=i.colorProfiles?.map(((t,e)=>(0,A.jsx)("color-profile",{name:t.name,xlinkHref:t.key,children:" "},e))),p=Ye(a.map((t=>({...t,_renderingConfiguration:i,mask:c?`url(#viewmask-${Q})`:void 0}))));return(0,A.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:l,width:w,height:o,style:{gridColumn:1,gridRow:1,maxWidth:s,maxHeight:r,position:g},viewBox:u,children:[m,C,!!t&&(0,A.jsx)("rect",{id:"layout-background",width:E.width,height:E.height,fill:t,rx:h}),(0,A.jsx)("g",{id:"element-group",clipPath:i.purpose===H.FreeDesign?"url(#viewboxClip)":void 0,children:p.map((t=>xe(t))).filter((t=>!!t))}),c&&(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:d/2,strokeDasharray:`${2*d} ${d}`}),c&&(0,A.jsxs)("mask",{id:`viewmask-${Q}`,children:[(0,A.jsx)("rect",{x:E.x,y:E.y,width:E.width,height:E.height,fill:"black"}),(0,A.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};y({},"Image",(()=>dt));var Z={};y(Z,"getAxisAlignedBoundingBox",(()=>$)),y(Z,"degreesToRadians",(()=>tt)),y(Z,"findAngle",(()=>_)),y(Z,"radiansToDegrees",(()=>et)),y(Z,"isCloseToValue",(()=>At)),y(Z,"getTrueCoordinates",(()=>nt)),y(Z,"getPointOfRotation",(()=>it)),y(Z,"getNWPoint",(()=>at)),y(Z,"getNEPoint",(()=>ot)),y(Z,"getSWPoint",(()=>rt)),y(Z,"getSEPoint",(()=>st)),y(Z,"turnRightClockwise",(()=>ct)),y(Z,"currentDirection",(()=>gt)),y(Z,"getElementVertices",(()=>lt)),y(Z,"rotateAroundPoint",(()=>Bt)),y(Z,"mmPerPixel",(()=>wt)),y(Z,"cmPerPixel",(()=>ht));const $=(t,e,A,n,i)=>{const a=tt(i),o=A/2,r=n/2,s=t+o,c=e+r,g=Math.sin(a),l=Math.cos(a),B=-r,w=o*l-B*g,h=o*l-r*g,d=o*g+B*l,E=o*g+r*l,u=Math.max(Math.abs(w),Math.abs(h)),Q=Math.max(Math.abs(d),Math.abs(E));return{minX:s-u,maxX:s+u,minY:c-Q,maxY:c+Q}},_=(t,e,A)=>{const n=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),i=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2)),a=Math.sqrt(Math.pow(A.x-t.x,2)+Math.pow(A.y-t.y,2));return Math.acos((i*i+n*n-a*a)/(2*i*n))*(180/Math.PI)},tt=t=>t*(Math.PI/180),et=t=>t*(180/Math.PI),At=(t,e,A)=>Math.abs(t-e)<A,nt=(t,e,A)=>{const n=Math.sin(tt(A)),i=Math.cos(tt(A));return{x:(t.x-e.x)*i-(t.y-e.y)*n+e.x,y:(t.x-e.x)*n+(t.y-e.y)*i+e.y}},it=(t,e)=>({x:(t.x+e.x)/2,y:(t.y+e.y)/2}),at=(t,e,A,n)=>({x:t.x+e?.x*A,y:t.y+e?.y*n}),ot=(t,e,A,n)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+e?.y*n}),rt=(t,e,A,n)=>({x:t.x+e?.x*A,y:t.y+(e?.y+e?.height)*n}),st=(t,e,A,n)=>({x:t.x+(e?.x+e?.width)*A,y:t.y+(e?.y+e?.height)*n}),ct=t=>{switch(t){case J.North:return J.East;case J.East:return J.South;case J.South:return J.West;case J.West:return J.North;case J.Northwest:return J.Northeast;case J.Northeast:return J.Southeast;case J.Southeast:return J.Southwest;case J.Southwest:return J.Northwest}},gt=(t,e)=>e>45&&e<=135?ct(t):e>135&&e<=225?ct(ct(t)):e>225&&e<=315?ct(ct(ct(t))):t,lt=(t,e={x:0,y:0},A={x:1,y:1})=>{const n=tt(t.rotation),i={x:e.x+t.x*A.x,y:e.x+t.y*A.y},a={x:t.x+t.width,y:t.y},o={x:e.x+(t.x+t.width)*A.x,y:e.y+(t.height+t.y)*A.y},r={x:e.x+t.x*A.x,y:e.y+(t.height+t.y)*A.y},s={x:(r.x+o.x)/2,y:r.y-t.height*A.y/2};return{a:Bt(i,s,n),b:Bt(a,s,n),c:Bt(o,s,n),d:Bt(r,s,n),center:s}},Bt=(t,e,A)=>{const n=Math.sin(A),i=Math.cos(A);return{x:(t.x-e.x)*i-(t.y-e.y)*n+e.x,y:(t.x-e.x)*n+(t.y-e.y)*i+e.y}},wt=.352778,ht=.035277,dt=t=>{const e=t.rotation||0,n=tt(e),i=Math.cos(n),a=-Math.sin(n);return(0,A.jsx)("g",{mask:t.stepName||t.productOverlay?void 0:t.mask,children:(0,A.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `,children:(0,A.jsx)("image",{xlinkHref:t.src,preserveAspectRatio:t.preserveAspectRatio,width:t.width,height:t.height})})})};y({},"Frame",(()=>Et));const Et=t=>{const e=`spiff-frame-${t.id}`,n=`spiff-frame-blur-${t.id}`,i=`spiff-frame-blur-edge-${t.id}`,a=`spiff-frame-focal-mask-${t.id}`,o=!!t.focalBlur&&!!t.pattern,r=t.rotation||0,s=tt(r),c=Math.cos(s),g=-Math.sin(s);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("defs",{children:(o=>{const r=t.pattern?.x||0,s=t.pattern?.y||0,c=t.pattern?t.pattern.width*t.pattern.scaleX+Math.abs(r):256,g=t.pattern?t.pattern.height*t.pattern.scaleY+Math.abs(s):256,l=t.pattern?t.pattern.width*t.pattern.scaleX:256,B=t.pattern?t.pattern.height*t.pattern.scaleY:256;return(0,A.jsxs)("g",{mask:t.stepName?void 0:t.mask,children:[(0,A.jsx)("pattern",{patternUnits:t.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:t.pattern?1:c,height:t.pattern?1:g,"data-frame-width":t.pattern?c:void 0,"data-frame-height":t.pattern?g:void 0,id:e,children:(0,A.jsx)("image",{preserveAspectRatio:"none",x:r,y:s,width:l,height:B,xlinkHref:t.disablePlaceholder&&!t.pattern?"":t.pattern?t.pattern.src:"data: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D0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),o?(0,A.jsx)(ut,{path:t.path,width:t.width,height:t.height,focalBlurStrength:t.focalBlurStrength||1,focalBlurRadius:t.focalBlurRadius||10,blurFilterId:n,focalMaskId:a,blurEdgeClipId:i}):null]})})(o)}),(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${c}, ${-g}, ${g}, ${c}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n matrix(${t.scaleX}, 0, 0, ${t.scaleY}, 0, 0)\n `,children:[(0,A.jsx)("path",{filter:o?`url(#${n})`:void 0,mask:o?`url(#${i})`:void 0,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}),o?(0,A.jsx)("path",{mask:`url(#${a})`,d:t.path,style:{fill:`url(#${e})`,opacity:t.opacity}}):void 0]})})]})},ut=t=>{const{path:e,width:n,height:i,focalBlurStrength:a,focalBlurRadius:o,blurFilterId:r,focalMaskId:s,blurEdgeClipId:c}=t;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("filter",{id:r,children:(0,A.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,A.jsx)("mask",{id:s,children:(0,A.jsx)("circle",{cx:n/2,cy:i/2,r:o||0,fill:"white",filter:`url(#${r})`})}),(0,A.jsx)("mask",{id:c,children:(0,A.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};y({},"Textbox",(()=>Ee));var Qt={};y(Qt,"fontSizeStep",(()=>ee)),y(Qt,"textWidth",(()=>Ae)),y(Qt,"charWidth",(()=>ne)),y(Qt,"lineWidth",(()=>ie)),y(Qt,"applyTextTransformations",(()=>oe)),y(Qt,"zip",(()=>re)),y(Qt,"getTextAlignment",(()=>se)),y(Qt,"getAnchor",(()=>ce)),y(Qt,"recomputeTextOnElement",(()=>ge)),y(Qt,"defaultLineHeightFactor",(()=>le));var Ct={};y(Ct,"refitTextbox",(()=>_t)),y(Ct,"recalculateTextboxRegion",(()=>te));var mt={};y(mt,"FontMetrics",(()=>Tt)),y(mt,"loadFontFromExternalUrl",(()=>jt)),y(mt,"loadFontFromDataUrl",(()=>Kt)),y(mt,"getFontMetrics",(()=>Vt));var pt={};y(pt,"registerJSDOM",(()=>It)),y(pt,"createElement",(()=>Ft)),y(pt,"createElementNS",(()=>Yt)),y(pt,"domParser",(()=>vt)),y(pt,"fetchAsArrayBuffer",(()=>St)),y(pt,"fetchAsString",(()=>Nt)),y(pt,"loadFontFaceSet",(()=>Rt)),y(pt,"xmlSerializer",(()=>Ht)),y(pt,"toBase64",(()=>Pt)),y(pt,"dataUrlFromExternalUrl",(()=>Ut)),y(pt,"arrayBufferToDataUrl",(()=>Gt)),y(pt,"arrayBufferToBuffer",(()=>kt)),y(pt,"dataUrlToArrayBuffer",(()=>bt));var ft=i.Buffer;let Dt;function It(t){Dt=t}function yt(){if(!Dt)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new Dt}if(void 0===M.TextEncoder){const{TextEncoder:t}=s;M.TextEncoder=t}if(void 0===M.TextDecoder){const{TextDecoder:t}=s;M.TextDecoder=t}const Mt=new(I(o).Agent)({rejectUnauthorized:!0}),xt=t=>t.every((t=>"undefined"!==t)),Ft=t=>xt([typeof document])?document.createElement(t):yt().window.document.createElement(t),Yt=(t,e)=>{if(xt([typeof document]))return document.createElementNS(t,e);const A=yt().window.document.createElement(e);return A.setAttribute("xmlns",t),A},vt=()=>xt([typeof DOMParser])?new DOMParser:new(yt().window.DOMParser),St=t=>{if(xt([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.arrayBuffer())})).catch((t=>{A(t)}))}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{I(a).get(e,{responseType:"arraybuffer",httpsAgent:Mt}).then((e=>{t(e.data)})).catch((t=>{A(t)}))}))}},Nt=t=>{if(xt([typeof fetch]))return new Promise(((e,A)=>{fetch(t).then((t=>{e(t.text())})).catch(A)}));{const e=t.replace("localhost","localstack");return new Promise(((t,A)=>{I(a).get(e,{responseType:"text",httpsAgent:Mt}).then((e=>{t(e.data)})).catch(A)}))}},Rt=async(t,e)=>{if(xt([typeof FontFace])){const A=t.names.fullName.en,n=new FontFace(A,`url(${e})`);return document.fonts.add(n),n.load()}},Ht=()=>xt([typeof XMLSerializer])?new XMLSerializer:new(yt().window.XMLSerializer),Pt=t=>xt([typeof btoa])?btoa(t):ft.from(t).toString("base64"),Ut=async t=>{if(xt([typeof fetch,typeof Blob,typeof FileReader])){const e=await fetch(t),A=await e.blob();return await Lt(A)}const e=(await I(a).get(t,{responseType:"arraybuffer"})).data;return Gt(e)},Gt=async t=>{const e=await(async t=>{const e=await(0,r.fromBuffer)(t);return e?e.mime:"image/svg+xml"})(t);return`data:${e};base64,${kt(t).toString("base64")}`},bt=t=>{const e=t.replace(/\r?\n/g,""),A=e.indexOf(",");if(-1===A||A<=4)throw new TypeError("malformed data: URI");const n=e.substring(5,A).split(";");let i=!1;for(let t=1;t<n.length;t++)"base64"===n[t]&&(i=!0);const a=i?"base64":"ascii",o=unescape(e.substring(A+1)),r=ft.from(o,a);return Jt(r)},kt=t=>ft.from(t),Jt=t=>{const e=new ArrayBuffer(t.byteLength),A=new Uint8Array(e);for(let e=0;e<t.length;++e)A[e]=t[e];return e},Lt=t=>new Promise(((e,A)=>{const n=new FileReader;n.onload=function(t){const n=t.target;n&&n.result?e(n.result.toString()):A()},n.readAsDataURL(t)})),Ot=new Map;class Tt{constructor(t){this.font=t,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(t){const e=this.glyphsFromText.get(t);if(e)return e;const A=this.font.stringToGlyphs(t);return this.glyphsFromText.set(t,A),A}getApproximateHeight(){return this.height}getExactHeight(t){const e=this.font.stringToGlyphs(t);let A=0,n=0;return e.forEach((t=>{const e=t.getMetrics();A=Math.max(A,e.yMax),n=Math.min(n,e.yMin)})),A-n}getKerningValue(t,e){let A=this.kerningValues.get(t.name);A||(A=new Map,this.kerningValues.set(t.name,A));let n=A.get(e.name);return n||(n=this.font.getKerningValue(t,e),A.set(e.name,n)),n}calculateApproximateHeight(){const t=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let e=0,A=0;return t.forEach((t=>{const n=t.getMetrics();e=Math.max(e,n.yMax),A=Math.min(A,n.yMin)})),e-A}}const zt=t=>"data:"===t.substring(0,5).toLowerCase().trim(),jt=async t=>{const e=zt(t)?Kt(t):Kt(await Ut(t));return Wt(e,{assetUrl:zt(t)?t:await Ut(t),name:e.names.fullName.en}),await Rt(e,t),e},Kt=t=>{const e=bt(t),A=I(n).parse(e);return Wt(A,{assetUrl:t,name:A.names.fullName.en}),A},Vt=t=>{const e=Ot.get(t.name);if(e)return e;throw new Error("Font metrics unavailable for font")},Wt=(t,e)=>{const A=new Tt(t);return Ot.set(e.name,A),A},Xt=(t,e,A,n)=>Math.max(ne(t.join("\n"),A,n),e),qt=(t,e,A,n,i,a)=>{const o=(a||le)*i.getApproximateHeight(),r=e.split("\n");try{const e=r.flatMap((e=>Zt(e,t.width,n,i))),a=e.flatMap((t=>t.lines));return{lines:a,requiredHeight:e.flatMap((t=>t.lines)).length*(n*o),fontSize:A,requiredWidth:Xt(a,t.width,n,i)}}catch(a){const r=e.split("");return{lines:r,requiredHeight:r.length*(n*o),fontSize:A,requiredWidth:Xt(r,t.width,n,i)}}},Zt=(t,e,A,n)=>{const i=Ae(t,A,n);if(i<=e)return{lines:[t],width:i};if(!(t.indexOf(" ")>-1)){if(t.length<=1)throw new Error(`Character ${t} is wider than region`);const i=Math.floor(t.length/2),a=Zt(t.slice(0,i),e,A,n),o=Zt(t.slice(i),e,A,n);return{lines:[...a.lines,...o.lines],width:Math.max(a.width,o.width)}}const a=t.split(" "),o=[];let r=-1/0,s=0;for(;s<a.length;){const t=a[s];if(Ae(t,A,n)>e){const i=Zt(t,e,A,n);o.push(...i.lines),r=Math.max(r,i.width),s++}else{const i=[t];r=Math.max(r,Ae(t,A,n));let c=s+1,g=!0;for(;c<a.length&&g;){const t=a[c],o=Ae(`${i.join(" ")} ${t}`,A,n);o<=e?(i.push(t),r=Math.max(r,o),c++):g=!1}o.push(i.join(" ")),s=c}}if(r<0)throw new Error(`No max width calculated for text: ${o}.`);return{lines:o,width:r}},$t=(t,e,A,n,i,a)=>{const o=(a??le)*e.getApproximateHeight(),r=1/A.unitsPerEm,s=n/ie(t,r,e),c=i/(t.length*o*r);return Math.min(c,s)},_t=(t,e,A,n)=>{const i=Vt(e.fontData),a=i.getFont(),o=e.fontSize/a.unitsPerEm;if(!A)return qt(e,t,e.fontSize,o,i,n);let r;if(r=e.text?e.text.split("\n"):e.input?.split("\n")??[""],A.input===t&&e.width===A.width&&e.height===A.height&&e.lineHeight===A.lineHeight)return{lines:r,requiredHeight:e.height,requiredWidth:Xt(r,e.width,o,i),fontSize:e.fontSize};const s=e.width!==A.width!=(e.height!==A.height);return e.lineHeight!==A.lineHeight||s||A.input!==t?qt(e,t,e.fontSize,o,i,n):{lines:r,requiredHeight:e.height,requiredWidth:Xt(r,e.width,o,i),fontSize:$t(r,i,a,e.width,e.height,n)}},te=(t,e,A,n,i)=>{const a=Vt(e).getFont();let o={...t},r={...t},s=ie(n,A/a.unitsPerEm,Vt(e));return s&&s<o.width&&(r.width=s,"left"===i?(r.left+=Math.sin(o.rotation*Math.PI/360)*(o.width-s),r.top+=Math.sin(o.rotation*Math.PI/180)*(s-o.width)/2):r.left+="right"===i?o.width-s:(o.width-s)/2,n&&re(n,n).every((([t,e])=>t===e))&&(o=r)),o},ee=1,Ae=(t,e,A)=>{let n=0;const i=A.getGlyphs(t);return i.forEach(((t,e)=>{if(t.advanceWidth&&(n+=t.advanceWidth),e<i.length-1){const a=A.getKerningValue(t,i[e+1]);n+=a}})),n*=e,n},ne=(t,e,A)=>{let n=0;const i=A.getGlyphs(t);return i.forEach(((t,e)=>{if(t.advanceWidth&&(n=Math.max(n,t.advanceWidth)),e<i.length-1){const a=A.getKerningValue(t,i[e+1]);n=Math.max(n,a)}})),n*=e,n},ie=(t,e,A)=>{let n=0;return t.forEach((t=>{n=Math.max(n,Ae(t,e,A))})),n},ae={stripControlCharacters:!0,vertical:!1,uppercase:!1},oe=(t,e=ae)=>{const A={...ae,...e};let n=t||"";return A.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),A.uppercase&&(n=n.toUpperCase()),A.vertical&&(n=n.split("").join("\n")),n},re=(t,e)=>t.map(((t,A)=>[t,e[A]])),se=(t="center",e=!1)=>e?"center":t,ce=t=>"left"===t?"start":"right"===t?"end":"middle",ge=(t,e,A)=>t.fontData?{...t,...(()=>{if(t.algorithm===U.Traditional){const n=_t(e,t,A,t.lineHeight);return{text:n.lines.join("\n"),height:n.requiredHeight,width:n.requiredWidth,fontSize:n.fontSize,input:e}}return{text:e}})()}:t,le=1.1;var Be={};y(Be,"colorDefinitionPrintValue",(()=>we)),y(Be,"spotColorDefinitionString",(()=>he)),y(Be,"svgColorValueToDefinition",(()=>de));const we=t=>{const e=he(t.spotColor);return e?`${t.browserValue} ${e}`:t.browserValue},he=t=>{if(!t)return"";if(t.profileName.includes("/")&&t.profileName.includes(".icc")){const e=t.profileName.replace(/\s/g,"-"),A=e.lastIndexOf("/");return`icc-named-color(${e.slice(A+1).slice(0,-4)}, ${t.namedColor})`}return`icc-named-color(${t.profileName}, ${t.namedColor})`},de=t=>{const e=t.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===e.length)return{browserValue:"#000000"};if(1===e.length)return{browserValue:e[0]};const A=e[1].match(/\(([^)]+)\)/gm);if(!A)throw new Error("Unhandled state of color value in SVG");const n=A[0].replace(/[() ]/g,"").split(",");return{browserValue:e[0],spotColor:{profileName:n[0],namedColor:n[1]}}},Ee=t=>{const e=(t.rotation||0)*Math.PI/180,n=Math.cos(e),i=-Math.sin(e),a=`text-path-${t.id}`,o=t.x+(t.curved?0:t.width/2),r=t.y+(t.curved?0:t.height/2),s=(t.text||"").split("\n");return t.curved&&!t.paths?null:t.fontData?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("defs",{children:[(0,A.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${t.fontData.name}';\n src: url('${t.fontData.assetUrl}') format('truetype');\n }\n `}}),t.curved&&t.paths?(0,A.jsx)("path",{id:a,d:t.paths[0]}):void 0]}),t._renderingConfiguration?.debug?(0,A.jsx)("rect",{stroke:"blue",fill:"none",x:t.x,y:t.y,width:t.width,height:t.height}):void 0,(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:`matrix(${n}, ${-i}, ${i}, ${n}, ${o}, ${r})`,children:(0,A.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${t.fontData.name}'`,fontSize:t.fontSize,fontStyle:"normal",fontWeight:"normal",fill:t._renderingConfiguration?.spotColors&&t.fillSpotColorDefinition?`${t.fill} ${he(t.fillSpotColorDefinition)}`:t.fill,style:{whiteSpace:"pre",userSelect:"none"},children:t.curved?(0,A.jsx)(Qe,{text:t.text||"",curvedPathId:a,align:t.align}):s.map(((e,n)=>(0,A.jsx)(ue,{align:t.vertical?"center":t.align,fontSize:t.fontSize,thisLineIdx:n,amountLines:s.length,text:e,textboxHeight:t.height,textboxWidth:t.width,lineHeight:t.lineHeight,vertical:t.vertical,verticalAlign:t.verticalAlign},n)))})})})]}):null},ue=t=>(0,A.jsx)("tspan",{textAnchor:ce(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:le),A=t.textboxHeight/2;if("top"===t.verticalAlign)return-A+3*t.fontSize/4+t.thisLineIdx*e;if("bottom"===t.verticalAlign){const n=t.amountLines-1-t.thisLineIdx;return A-t.fontSize/4-n*e}const n=(t.amountLines-1)/2;return(t.thisLineIdx-n)*e+t.fontSize/4})()}px`,children:t.text}),Qe=t=>{const e=`#${t.curvedPathId}`;return(0,A.jsx)("textPath",{startOffset:"left"===t.align?"0%":"right"===t.align?"100%":"50%",textAnchor:ce(t.align),href:e,xlinkHref:e,children:t.text})};y({},"Illustration",(()=>ye));var Ce={};y(Ce,"traverse",(()=>pe)),y(Ce,"sanitizeSvgTree",(()=>fe)),y(Ce,"modifySVGWithElementProperties",(()=>De)),y(Ce,"generateSVGWithUnknownColors",(()=>Ie));const me=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],pe=(t,e)=>{e(t),t.children.length>0&&Array.from(t.children).forEach((t=>pe(t,e)))},fe=(t,e=!1)=>{!e&&t.setAttribute("preserveAspectRatio","none");const A=[];pe(t,(t=>{if("script"!==t.tagName)if("style"!==t.tagName);else try{(0,c.parse)(t.innerHTML).stylesheet?.rules.forEach((t=>{A.push(t)})),t.remove()}catch(t){console.error(t)}else t.remove()})),pe(t,(t=>{A.forEach((e=>{e.selectors?.forEach((A=>{((t,e)=>{try{return t.matches(e)}catch(A){return t.classList.contains(e.substring(1))}})(t,A)&&e.declarations?.forEach((e=>{e.property&&e.value&&t.setAttribute(e.property,e.value)}))}))}))}))},De=(t,e,A,n,i)=>{const a=(t=>vt().parseFromString(t,"image/svg+xml").firstElementChild)(t);if(!a)throw new Error("Failed to read SVG.");return((t,e,A)=>{t.setAttribute("height",`${A}px`),t.setAttribute("width",`${e}px`)})(a,e,A),((t,e,A)=>{pe(t,(t=>{const n=t.attributes.getNamedItem("fill");n&&"none"!==n.value&&t.classList.forEach((n=>{if(n.startsWith("spiff-fill")){const i=e[n];i&&t.setAttribute("fill",A?we(i):i.browserValue)}}));const i=t.attributes.getNamedItem("stroke");i&&"none"!==i.value&&t.classList.forEach((n=>{if(n.startsWith("spiff-stroke")){const i=e[n];i&&t.setAttribute("stroke",A?we(i):i.browserValue)}}))}))})(a,n,i),(t=>Ht().serializeToString(t))(a)},Ie=async t=>{const e=t.match(/<svg.*?<\/svg>/s)||[],A=e?.length>0?e[0]:"",n=vt().parseFromString(A,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");fe(n);const i={};pe(n,(t=>{me.includes(t.tagName)&&!t.attributes.getNamedItem("fill")&&t.setAttribute("fill","black");const e=t.attributes.getNamedItem("fill");if(e&&"none"!==e.value){const A=de(e.value),n=`spiff-fill-${A.browserValue.replace(/\W/g,"")}`;t.setAttribute("fill",A.browserValue),t.classList.add(n),i[n]=A}const A=t.attributes.getNamedItem("stroke");if(A&&"none"!==A.value){const e=de(A.value),n=`spiff-stroke-${e.browserValue.replace(/\W/g,"")}`;t.classList.add(n),t.setAttribute("stroke",e.browserValue),i[n]=e}}));const a=Ht().serializeToString(n);return{colors:i,svg:a}},ye=t=>{if(t.cachedObjectURL&&!t._renderingConfiguration?.omitCachedFields)return(0,A.jsx)(dt,{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=tt(e),i=Math.cos(n),a=-Math.sin(n),o=`\n matrix(1, 0, 0, 1, ${t.x}, ${t.y})\n matrix(1, 0, 0, 1, ${t.width/2}, ${t.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-t.width/2}, ${-t.height/2})\n `;if(!t.svg)throw new Error(`Illustration element ${t.id} (stepName ${t.stepName}) lacked svg from src ${t.src} at render time.`);return(0,A.jsx)("g",{mask:t.stepName?void 0:t.mask,children:(0,A.jsx)("g",{transform:o,dangerouslySetInnerHTML:{__html:De(t.svg,t.width,t.height,t.colors,t._renderingConfiguration?.spotColors)}})})};class Me{constructor(){this.id=F(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(t){this.stateCallbacks.push(t)}unregisterStateCallback(t){this.stateCallbacks.filter((e=>e!==t))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((t=>t()))}apply(t,e){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.nextCommands=[],e||this.prevCommands.push(t)}undo(){if(!this.state)return;const t=this.prevCommands.pop();if(!t)return;const e=t.undo();t.varying?this.state={...this.state,variation:e}:this.state={...this.state,transaction:e},this.nextCommands.push(t),this.runStateCallbacks()}redo(){if(!this.state)return;const t=this.nextCommands.pop();t&&(this.state=this.commandReducer(this.state,t),this.runStateCallbacks(),this.prevCommands.push(t))}flattenSequence(t,e){const A=this.prevCommands.filter((e=>e.sequenceId===t)).pop();A&&(this.prevCommands=this.prevCommands.filter((e=>e.sequenceId!==t)),A?.overrideOldState(e),this.prevCommands.push(A))}getLayoutById(t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const e=this.state.transaction?.layouts?.[t],A=this.state.variation?.layouts?.[t],n=e?.layout||A?.layout;if(!n)throw new Error(`No layout: ${t}`);const i=[...e?.elements||[],...A?.elements||[]];return this.getLayoutDataWithState(n,i)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(t)].map((t=>this.getLayoutById(t)))}getLayoutDataWithState(t,e){return{layoutState:{layout:t,elements:e},getComponentWithProps:A=>Fe(t,e,A)}}initialize(t,e){if(e)return void(this.state={transaction:e});let A={serializableWorkflow:{steps:[]},layouts:{}};t.forEach((t=>{A=new Le(t).apply(A)})),this.runStateCallbacks(),this.state={transaction:A}}commandReducer(t,e){if(e.varying){const A={layouts:{},serializableWorkflow:{steps:[]},...t.variation};return{...t,variation:e.apply(A)}}{const A=t.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...t,transaction:e.apply(A)}}}}const xe=t=>"image"===t.type?(0,A.jsx)(dt,{...t},t.id):"frame"===t.type?(0,A.jsx)(Et,{...t},t.id):"illustration"===t.type?(0,A.jsx)(ye,{...t},t.id):"textbox"===t.type?(0,A.jsx)(Ee,{...t},t.id):null,Fe=(t,e,n)=>{const i=n.renderingConfiguration,a=i?.removeExcludedElements?e.filter((t=>!t.excludeFromExport)):e;return(0,A.jsx)(q,{preserveAspectRatio:void 0,elements:a,backgroundColor:t.transparentBackground?void 0:"white",width:n.width||t.width,height:n.height||t.height,viewBox:i?.region?{x:i.region.left,y:i.region.top,width:i.region.width,height:i.region.height}:{x:0,y:0,width:t.width,height:t.height},configuration:i,outlineArea:n.outlineArea,maxHeight:n.maxHeight,maxWidth:n.maxWidth,position:n.position,borderRadius:n.borderRadius,outlineColor:n.outlineColor})};function Ye(t){return t.sort(((t,e)=>{const A=t.layer||0,n=e.layer||0;if(A<n)return-1;if(A>n)return 1;const i=t.layerIndex||0,a=e.layerIndex||0;return i<a?-1:i>a?1:0}))}class ve extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,ve.prototype)}}const Se=(t,e)=>Ne(t,e).elements.find((e=>e.id===t)),Ne=(t,e)=>{const A=Object.values(e).find((e=>e.elements.some((e=>e.id===t))));if(!A)throw new ve;return A},Re=(t,e)=>{const A=Ye([...e.elements.filter((e=>e.id!==t.id)),t]);return{layout:e.layout,elements:A,modificationID:F()}},He=async(t,e)=>{const A=[...Object.keys(t.layouts),...Object.keys(e?.layouts||{})],n=[...new Set(A)];for(let A=0;A<n.length;A++){const i=n[A],a=t.layouts[i],o=e?.layouts[i],r=(a||o).elements.filter((t=>"illustration"===t.type));for(let t=0;t<r.length;++t){const e=r[t];if(e.src&&!e.svg){const t=await Nt(e.src),A=await Ie(t);e.svg=De(A.svg,e.width,e.height,e.colors)}}}};class Pe{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(t){this.oldState=t}}class Ue extends Pe{constructor(t){super(),this.serializableWorkflow=t}apply(t){return this.oldState=t,{...t,serializableWorkflow:this.serializableWorkflow}}}class Ge extends Pe{constructor(t,e,A){super(),this.id=t,this.x=e,this.y=A}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,x:this.x,y:this.y},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class be extends Pe{constructor(t,e){super(),this.id=t,this.angle=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,rotation:this.angle},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class ke extends Pe{constructor(t,e,A){super(),this.id=t,this.width=Math.abs(e),this.height=Math.abs(A)}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;let A={...e,width:this.width,height:this.height};if("frame"===e.type){const t=A;t.scaleX=t.scaleX*this.width/e.width,t.scaleY=t.scaleY*this.height/e.height}else if("textbox"===e.type){const t=A,n=(t.algorithm&&t.algorithm!==U.Autosize?t.input:t.text)??"";A=ge(t,n,e)}const n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Je extends Pe{constructor(t){super(),this.commands=t}apply(t){return this.oldState=t,this.commands.reduce(((t,e)=>e.apply(t)),t)}}class Le extends Pe{constructor(t){super(),this.layout=t}apply(t){return this.oldState=t,{...t,layouts:{...t.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:F()}}}}}class Oe extends Pe{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:F()}})),A={};return e.forEach((t=>{A[t.layout.id]=t})),{...t,layouts:A}}}class Te extends Pe{constructor(t,e){super(),this.element=t,this.layout=e}apply(t){this.oldState=t,t.layouts[this.layout.id]||(t.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const e=t.layouts[this.layout.id].elements;if(e.find((t=>t.id===this.element.id)))throw new Error(`Failed to apply new ${this.element.type} element because ID ${this.element.id} already taken`);if(this.element.productOverlay||0===e.length){const A=[...e,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,A)),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:A,modificationID:F()}}}}const A=e[e.length-1],n=A.productOverlay?A:null;let i;if(n&&e.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)i=[...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,i=[...e,this.element]}return n&&i.push(n),{...t,layouts:{...t.layouts,[this.layout.id]:{...t.layouts[this.layout.id],elements:i,modificationID:F()}}}}assignIndex(t,e){if(0===e.length)return 0;const A=e.filter((e=>(e.layer||0)===(t.layer||0))).sort(((t,e)=>(t.layerIndex||0)-(e.layerIndex||0)))[e.length-1]?.layerIndex;return void 0!==A?A+1:0}}class ze extends Pe{constructor(t){super(),this.id=t}apply(t){this.oldState=t;let e=!1;const A=Object.values(t.layouts).map((t=>(t.elements.filter((t=>t.id!==this.id)).length!==t.elements.length&&(e=!0),{...t,elements:t.elements.filter((t=>t.id!==this.id)),modificationID:F()})));e||console.log(`Failed to delete element ${this.id}`);const n={};return A.forEach((t=>{n[t.layout.id]=t})),{...t,layouts:n}}}class je extends Pe{constructor(t,A){super(),this.el=I(e)(t),this.layout=A,this.el.id=F(),this.el.x+=5,this.el.y+=5}apply(t){return this.oldState=t,new Te(this.el,this.layout).apply(t)}}class Ke extends Pe{constructor(t,e,A){super(),this.id=t,this.color=e,this.textFillSpotColor=A}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Ve extends Pe{constructor(t,e){super(),this.id=t,this.size=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,fontSize:this.size},n=Ne(e.id,Object.values(t.layouts)),i=(e.algorithm&&e.algorithm!==U.Autosize?e.input:e.text)??"",a=Re(ge(A,i),n);return{...t,layouts:{...t.layouts,[n.layout.id]:a}}}}class We extends Pe{constructor(t,e){super(),this.id=t,this.algorithm=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,algorithm:this.algorithm},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Xe extends Pe{constructor(t,e){super(),this.id=t,this.fontData=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,fontData:this.fontData},n=Ne(e.id,Object.values(t.layouts)),i=(e.algorithm&&e.algorithm!==U.Autosize?e.input:e.text)??"",a=Re(ge(A,i),n);return{...t,layouts:{...t.layouts,[n.layout.id]:a}}}}class qe extends Pe{constructor(t,e){super(),this.id=t,this.align=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,align:this.align},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class Ze extends Pe{constructor(t,e,A){super(),this.id=t,this.imageData=e,this.offsets=A}apply(t){this.oldState=t;const e=Ne(this.id,Object.values(t.layouts)),A=e.elements.findIndex((t=>t.id===this.id)),n=e.elements[A].pattern,i=[...e.elements];i.splice(A,1,{...e.elements[A],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:i,modificationID:F()};return{...t,layouts:{...t.layouts,[e.layout.id]:a}}}}class $e extends Pe{constructor(t,e){super(),this.id=t,this.text=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A=Ne(e.id,Object.values(t.layouts)),n=Re(ge(e,this.text,e),A);return{...t,layouts:{...t.layouts,[A.layout.id]:n}}}}class _e extends Pe{constructor(t,e,A){super(),this.id=t,this.className=e,this.fill=A}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A=e.colors||{},n=A[this.className];A[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...e,colors:A},a=Ne(e.id,Object.values(t.layouts)),o=Re(i,a);return{...t,layouts:{...t.layouts,[a.layout.id]:o}}}}class tA extends Pe{constructor(t,e,A){super(),this.id=t,this.svgBody=e,this.objectURL=A}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A={...e,svg:this.svgBody,cachedObjectURL:this.objectURL},n=Ne(e.id,Object.values(t.layouts)),i=Re(A,n);return{...t,layouts:{...t.layouts,[n.layout.id]:i}}}}class eA extends Pe{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Se(this.id,Object.values(t.layouts)).id)throw new ve;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id));e.elements.push(e.elements.splice(A,1)[0]);const 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:F()}}}}}class AA extends Pe{constructor(t){super(),this.id=t}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");const n=A.elements.findIndex((t=>t.id===this.id));A.elements.splice(n,1),A.elements.unshift(e);const i=[...A.elements],a=i.splice(n,1)[0];return i.splice(n,0,a),i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[A.layout.id]:{...t.layouts[A.layout.id],elements:i,modificationID:F()}}}}}class nA extends Pe{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Se(this.id,Object.values(t.layouts)).id)throw new ve;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id)),n=A+1,i=[...e.elements],a=i.splice(A,1)[0];return i.splice(n,0,a),i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:i,modificationID:F()}}}}}class iA extends Pe{constructor(t){super(),this.id=t}apply(t){if(this.oldState=t,!Se(this.id,Object.values(t.layouts)).id)throw new ve;const e=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!e)throw new Error("Layout missing from state!");const A=e.elements.findIndex((t=>t.id===this.id)),n=A-1,i=[...e.elements],a=i.splice(A,1)[0];return i.splice(n,0,a),i.forEach(((t,e)=>t.layerIndex=e)),{...t,layouts:{...t.layouts,[e.layout.id]:{...t.layouts[e.layout.id],elements:i,modificationID:F()}}}}}class aA extends Pe{constructor(t,e){super(),this.id=t,this.value=e}apply(t){this.oldState=t;const e=Se(this.id,Object.values(t.layouts));if(!e.id)throw new ve;const A=Object.values(t.layouts).find((t=>t.elements.find((t=>t.id===this.id))));if(!A)throw new Error("Layout missing from state!");return{...t,layouts:{...t.layouts,[A.layout.id]:Re({...e,layer:this.value},A)}}}}var oA={};y(oA,"patternImageDataCache",(()=>wA)),y(oA,"frameDataCache",(()=>hA)),y(oA,"generateFrameSVG",(()=>dA)),y(oA,"generateDefaultRectangleFrameSvg",(()=>EA)),y(oA,"getVariant",(()=>uA)),y(oA,"getFrameData",(()=>QA)),y(oA,"calculateOffsets",(()=>CA)),y(oA,"getPatternImageData",(()=>mA)),y(oA,"GetSVGDimensions",(()=>pA)),y(oA,"svgStringDimensions",(()=>fA));var rA={};y(rA,"getExifOrientation",(()=>cA)),y(rA,"canvasDims",(()=>gA)),y(rA,"getAttributesFromArrayBuffer",(()=>lA));let sA=null;const cA=t=>new Promise((e=>{const A=kt(t);(0,r.fromBuffer)(t).then((t=>{const n=t?.mime;if("image/jpeg"!==n)return e(1);(new(0,l.ExifImage)).loadImage(A,((t,A)=>e(t?1:A.image.Orientation||1)))}))})),gA=t=>{const e=8192,A=t.naturalWidth/t.naturalHeight;return t.naturalHeight<=e&&t.naturalWidth<=e?[t.naturalWidth,t.naturalHeight]:t.naturalHeight>t.naturalWidth?[A*e,e]:[e,e/A]},lA=async t=>{const e=await(async t=>{const e=await Gt(t),A=await(0,g.loadImage)(e),[n,i]=gA(A),a=await(async()=>{if(null!==sA)return!sA;const t=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return sA=2===t.width&&3===t.height,!sA})();if(!a){const t=(0,g.createCanvas)(n,i);return t.getContext("2d").drawImage(A,0,0,n,i),t}const o=await cA(t),[r,s]=o>4?[i,n]:[n,i],c=(0,g.createCanvas)(r,s),l=c.getContext("2d");switch(o){case 2:l.translate(r,0),l.scale(-1,1);break;case 3:l.translate(r,s),l.rotate(Math.PI);break;case 4:l.translate(0,s),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(-r,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-r,s),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-s)}return l.drawImage(A,0,0,r,s),c})(t);return"image/jpeg"===(await(0,r.fromBuffer)(t))?.mime?{dataUrl:e.toDataURL("image/jpeg",1),height:e.height,width:e.width}:{dataUrl:e.toDataURL(),height:e.height,width:e.width}};y({},"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))}},wA=new Map,hA=new Map,dA=async(t,e)=>{if(!e){if(!t)throw new Error("No region or src supplied. Cannot construct frame!");return EA(t)}return Nt(e)},EA=t=>{const e=t.width,A=e/t.height,n=Math.max(e,512),i=n/A;return`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${n} ${i}'>\n <path id="target-path" d='M0 0 h ${n} v ${i} h ${-n} Z' />\n </svg>\n `},uA=(t,e)=>{if(!e)return;const A=e.variants?.find((e=>e.id===t.frameVariantId))||BA(e);if(!A)throw new Error(`No variant with ID: ${t.frameVariantId}`);if(!A.asset)throw new Error(`No asset for variant with ID: ${t.frameVariantId}`);return A},QA=async t=>{const e=vt().parseFromString(t,"image/svg+xml"),A=e.querySelector("svg");if(!A)throw new Error("Malformed frame SVG: <svg> tag not found");const n=A.getAttribute("viewBox");if(!n)throw new Error("SVG missing viewBox.");const i=n.split(" "),a=parseFloat(i[3])||1,o=parseFloat(i[2])||1,r=e.getElementById("target-path"),s=e.getElementsByClassName("st0").item(0);if(r){const t=r.getAttribute("d");if(!t)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const e={path:t,width:o,height:a};return hA.set(t,e),e}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:o,height:a};return hA.set(t,e),e}throw new Error("Malformed frame SVG")},CA=(t,e,A)=>{const n=e.width>=e.height,i=t.width>=t.height,a=e.width/2,o=e.height/2,r=(n?e.height:e.width)/(i?t.width:t.height),s=A?.scale||r,c=a-t.width/2*s,g=A?.left||c,l=o-t.height/2*s;return{x:g,y:A?.top||l,zoom:s}},mA=async t=>{if(wA.has(t))return wA.get(t);if(t.endsWith("svg")){const e=await pA(t),A=e.width,n=e.height,i={src:t,width:A,height:n,aspect:A/n};return wA.set(t,i),i}{const e=await St(t),A=await lA(e),n={src:t,width:A.width,height:A.height,aspect:A.width/A.height};return wA.set(t,n),n}},pA=async t=>{const e=await Nt(t);return fA(e)},fA=t=>{const e=vt().parseFromString(t,"image/svg+xml").querySelector("svg");if(!e)throw new Error("No svg tag found, this svg must be malformed!");const A=e.getAttribute("viewBox"),n=e.getAttribute("width"),i=e.getAttribute("height"),a=A?A?.split(" ").map((t=>Number(t))):[0,0,Number(n),Number(i)];if(!a)throw new Error("No viewbox or width/height values detected on SVG file!");return{width:a[2],height:a[3]}};var DA={};y(DA,"determineCorrectFontSizeAndLines",(()=>yA)),y(DA,"determineCorrectTextboxRegion",(()=>MA));const IA=(t,e,A,n,i)=>{let a=e.map((t=>t.split("\n"))).flat(),o=a.length,r=a.map((t=>Ae(t,n,i)));const s=i.getApproximateHeight()*n;let c=!0;for(;c;){if(s+(o-1)*A>t.height)return[null,null];const e=Math.max(...r);if(e<=t.width)return[a,e];const g=r.reduce(((t,e,A,n)=>e>n[t]?A:t),0),l=a[g];let B=!1,w=l.length;for(;!B&&w>-1;){w=l.lastIndexOf(" ",w-1);const e=[l.slice(0,w),l.slice(w+1)],A=e.map((t=>Ae(t,n,i)));A[0]<=t.width&&(a=[...a.slice(0,g),...e,...a.slice(g+1)],r=[...r.slice(0,g),...A,...r.slice(g+1)],o+=1,B=!0)}B||(c=!1)}return[null,null]},yA=(t,e,A,n,i)=>{let a,o;const r=Vt(e),s=r.getFont();if(i.size){const e=t/s.unitsPerEm;return[a,o]=IA(A,n,t,e,r),[i.size,a,o]}let c=6-ee;if(n.length>0){let t=n,e=0;for(;(!i.maxSize||c<=i.maxSize)&&t;)c+=ee,e=c/s.unitsPerEm,[t,o]=IA(A,n,c,e,r)}c>6&&(c-=ee),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/s.unitsPerEm;return[a,o]=IA(A,n,c,g,r),[c,a,o]},MA=(t,e,A,n,i)=>{let a={...t},o={...t},[r,s,c]=yA(A,e,o,n,{size:0,minSize:A,maxSize:A});var g,l;return c&&c<a.width&&(o.width=c,"left"===i?(o.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),o.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):o.left+="right"===i?a.width-c:(a.width-c)/2,[r,s]=yA(A,e,o,n,{size:A}),r===A&&s&&(g=n,l=s,g.map(((t,e)=>[t,l[e]]))).every((([t,e])=>t===e))&&(a=o)),a};var xA={};y(xA,"svgObjectURL",(()=>vA)),y(xA,"LayoutElementFactory",(()=>NA));const FA=(t,e)=>{const A=t.layoutState.elements.filter((t=>t.layer===e)),n=Math.max(...A.map((t=>t.layerIndex)).filter((t=>void 0!==t)));return Math.max(n,0)+1},YA=async t=>new Promise((e=>{Nt(t).then((t=>{e(t)})).catch((t=>console.error(t)))})),vA=async t=>{const e=vt().parseFromString(t,"image/svg+xml").firstElementChild;if(!e)throw new Error("Failed to read SVG");const A=(new XMLSerializer).serializeToString(e),n=document.createElement("canvas"),i=n.getContext("2d"),a=await B.Canvg.from(i,A,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),o=e.getAttribute("width"),r=e.getAttribute("height"),s=2048;if(r&&o){const t=parseFloat(r),e=parseFloat(o)/t;e>1?a.resize(s,s/e):a.resize(s*e,s)}else a.resize(s,s);return await a.render(),await(async t=>new Promise(((e,A)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");t.toBlob((A=>{if(!A){if(0===t.width||0===t.height)throw new Error(`Canvas dimensions are invalid (${t.width},${t.height})`);if(t.width*t.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${t.width},${t.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}e(URL.createObjectURL(A))}))}catch(t){A(t)}})))(n)},SA=async(t,e,A,n)=>{const i=t.layoutState.layout.useEditableArea&&t.layoutState.layout.editableArea||{width:t.layoutState.layout.width,height:t.layoutState.layout.height,x:0,y:0},a=i.width<i.height?i.width:i.height,o=t.layoutState.layout.useEditableArea?a/1.3:a/2,r={top:i.y+i.height/2-o/2,left:i.x+i.width/2-o/2,width:o,height:o,rotation:0,panelId:t.layoutState.layout.panelId};if(A&&e===N.Illustration){const t=await Ie(await YA(A)),e=vt().parseFromString(t.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!e)throw new Error("SVG missing viewBox.");const n=r.height,i=e.split(" "),a=(parseFloat(i[2])||1)/(parseFloat(i[3])||1);r.height=r.width/a,r.top+=(n-r.height)/2}if(A&&e===N.Image){const t=r.height,e=await St(A),n=await lA(e),i=n.width/n.height;r.height=r.width/i,r.top+=(t-r.height)/2}if(A&&e===N.Textbox&&n?.text&&n?.fontScale){const t={assetUrl:A,name:(await jt(A)).names.fullName.en},e=Vt(t),a=Ae(n.text,n?.fontScale,e);r.width=Math.min(a,.85*i.width),r.left=i.x+i.width/2-r.width/2}return r};class NA{static async getFrame(t,e){const A=await dA(e.region,e.src),n=await QA(A),i=e.region||await SA(t,N.Frame);return{id:F(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||FA(t,i.layer||0),rotation:i.rotation,scaleX:i.width/n.width,scaleY:i.height/n.height,path:n.path,type:N.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:i.immutable}}static async getImage(t,e){const A=e.region||await SA(t,N.Image,e.src);return{id:F(),src:e.src,type:N.Image,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||FA(t,A.layer||0),immutable:A.immutable,preserveAspectRatio:"none"}}static async getTextbox(t,e){const{configuration:A,fontSrc:n,designInputStep:i}=e,a=await jt(n),o={assetUrl:n,name:a.names.fullName.en},r=i?.text||A.defaultText||"",s=A.replaceableText?A.replaceableText.replace("{{}}",r):r,c=oe(s,{vertical:A.vertical,uppercase:A.uppercase}),g=e.region||await SA(t,N.Textbox,n,{text:c,fontScale:A.size?A.size/a.unitsPerEm:void 0}),l=ge({id:F(),type:N.Textbox,x:g.left,y:g.top,width:g.width,height:g.height,align:se(A.textAlign,A.vertical),curved:A.curved,fill:i?.color||A.colour||"#000000",fontData:o,layer:g.layer||0,layerIndex:g.layerIndex||FA(t,g.layer||0),paths:A.paths,rotation:g.rotation,vertical:A.vertical,verticalAlign:A.verticalAlign||"middle",algorithm:U.Traditional,fontSize:A.size||Math.max(Math.round(.025*g.height),1),text:c,input:r},c),B=te({...g,height:l.height},o,l.fontSize,l?.text?.split("\n")||[],l.align);return{...l,x:B.left,y:B.top+(g.height-B.height)/2,width:B.width,height:B.height}}static async getShape(t,e){const A=`\n <svg\n xmlns="http://www.w3.org/2000/svg"\n xmlnsXlink="http://www.w3.org/1999/xlink"\n xmlSpace="preserve"\n preserveAspectRatio="none"\n version="1.1"\n width="1"\n height="1"\n viewBox="0 0 1 1"\n >\n <rect\n x="0"\n y="0"\n width="1"\n height="1"\n class="spiff-fill-shape"\n fill="${e.color}"\n />\n </svg>\n `,n={};n["spiff-fill-shape"]={browserValue:e.color};const i=e.region||await SA(t,N.Illustration),a=F();return{stepRegion:e.region,colors:n,id:a,svg:A,type:N.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||FA(t,i.layer||0),immutable:i.immutable}}static async getIllustration(t,e){const A=e.region||await SA(t,N.Illustration,e.src),n=await Ie(await YA(e.src)),i=await vA(n.svg),a=F();return{cachedObjectURL:i,stepRegion:e.region,colors:n.colors,id:a,src:e.src,svg:n.svg,type:N.Illustration,y:A.top,x:A.left,rotation:A.rotation,width:A.width,height:A.height,layer:A.layer||0,layerIndex:A.layerIndex||FA(t,A.layer||0),immutable:A.immutable}}}function RA(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class HA extends Error{constructor(t){super(t),this.name=this.constructor.name}}class PA extends HA{constructor(t){super(`ConfigurationError - ${t}`)}}class UA extends PA{constructor(t){super(`Option not Configured: ${t.stepTitle}`),RA(this,"optionId",void 0),this.optionId=t?.optionId||"N/A"}}class GA extends PA{constructor(t){super(`Panel not Found: ${t.panelId}`),RA(this,"panelId",void 0),this.panelId=t?.panelId||"N/A"}}class bA extends PA{constructor(t){super(`Asset not found for variant: ${t.name}`),RA(this,"variant",void 0),this.variant=t}}class kA extends PA{constructor(t){super(`Resource not found for asset: ${t.name}`),RA(this,"asset",void 0),this.asset=t}}class JA extends PA{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),RA(this,"step",void 0),this.step=t}}class LA extends HA{constructor(t){super(`ImplementationError - ${t}`)}}class OA extends LA{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class TA extends LA{constructor(t){super(`Parsing Error: ${t}`)}}class zA extends LA{constructor(t){super(`Client Error: ${t}`)}}class jA extends LA{constructor(t){super(`Resource Generation Failed: ${t}`)}}function KA(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class VA{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}class WA{constructor(){KA(this,"storage",new Map)}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}const XA=(()=>{try{return localStorage?new VA:new WA}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new WA}})();function qA(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const ZA=new class{constructor(){qA(this,"defaultServerUrl","https://api.spiff.com.au"),qA(this,"defaultServicesApiUrl","https://services.spiff.com.au"),qA(this,"defaultHubUrl","https://hub.spiff.com.au"),qA(this,"serverUrl",void 0),qA(this,"servicesApiUrl",void 0),qA(this,"hubUrl",void 0),qA(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 $A(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}let _A;const tn=t=>{_A=t};const en=new class{constructor(){$A(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),ZA.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const e=(0,t.createHttpLink)({uri:`${ZA.getServerUrl()}/graphql`,fetch:d.fetch}),A=(0,w.setContext)((async(t,{headers:e})=>{const A=e||{},n=await(async()=>{const t={transactionOwnerId:_A};return"undefined"!=typeof window&&window.location.href.includes("/workflows/product/")?{...await new Promise((t=>{const e=ZA.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void t({});const A=n=>{n.origin===e&&(window.removeEventListener("message",A),t(n.data))};window.parent!==window&&(window.addEventListener("message",A,!1),window.parent.postMessage("ready",e))})),...t}:t})();return n.bearer&&(A.Authorization=`Bearer ${n.bearer}`),n.partnerId&&(A.partnerId=n.partnerId),n.activeIntegration&&(A.activeIntegration=n.activeIntegration),n.transactionOwnerId&&(A.transactionOwnerId=n.transactionOwnerId),{headers:A}})),n=(0,h.onError)((({operation:t,graphQLErrors:e,networkError:A})=>{(e||[]).forEach((({message:e,locations:A,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(A,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(t.variables))})),A&&console.log("GraphQL Network error")}));const i=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}}},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,A,e]),cache:i,name:"Core"})}};function An(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const nn=t.gql`
2
2
  fragment AssetFields on Asset {
3
3
  name
4
4
  key
@@ -69,7 +69,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
69
69
  `,sn=t.gql`
70
70
  mutation CreateAsset($name: String!, $type: String!, $mimeType: String!, $anonymous: Boolean) {
71
71
  assetCreate(name: $name, type: $type, mimeType: $mimeType, anonymous: $anonymous) {
72
- uploadUrl,
72
+ uploadUrl
73
73
  asset {
74
74
  name
75
75
  key
@@ -80,7 +80,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
80
80
  }
81
81
  }
82
82
  }
83
- `,cn=async t=>(await en.getShadowGraphqlClient().query({query:an,errorPolicy:"all",fetchPolicy:"no-cache",variables:{keys:t}})).data.assets;const gn="persistentAssets";class ln{static add(t){if(!t.fileLink)return void console.error("Failed to find cdn link on asset, cannot persist!");const e=new Map;e.set(t.key||"",t.fileLink);const A=XA.getMap(gn);A&&A.forEach(((t,A)=>{e.set(A,t)})),XA.setMap(gn,e)}static remove(t){const e=XA.getMap(gn);if(!e)return;const A=Array.from(e.entries()).find((e=>e[0]===t));A&&(e.delete(A[0]),XA.setMap(gn,e))}static list(){const t=XA.getMap(gn);return t?Array.from(t.entries()).map((t=>({assetKey:t[0],src:t[1]}))):[]}}const Bn=new class{constructor(){An(this,"cache",new Map),An(this,"materialCache",new Map),An(this,"loadImageAsFileInfo",(async t=>{const e=await t.arrayBuffer(),A=await lA(e);return{name:t.name.substring(t.name.lastIndexOf("/")+1),blob:((t,e)=>{let A=atob(t.split(",")[1]),n=[];for(let t=0;t<A.length;t++)n.push(A.charCodeAt(t));return new Blob([new Uint8Array(n)],{type:e})})(A.dataUrl,t.type)}}))}async getLocalOrFromServer(t){if(this.cache.has(t)){const e=this.cache.get(t);if(!e)throw new OA("Failed to get asset from cache!");return e}const e=(async()=>(await cn([t]))[0])();return this.cache.set(t,e),e}async getMaterialLocalOrFromServer(t){if(this.materialCache.has(t))return this.materialCache.get(t);const e=(async()=>(await(async t=>(await en.getShadowGraphqlClient().query({query:rn,errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:t}})).data.materials)([t]))[0])();return this.materialCache.set(t,e),e}async uploadAssetWithProgress(t,e,A,n){const i=await this.dispatchCreateAssetRequest(t,e,n);if(!i)throw new Error("Failed to create asset.");return await new Promise(((e,n)=>{var a=new XMLHttpRequest;a.open("PUT",i.assetResponse.uploadUrl,!0),a.setRequestHeader("Content-Type",i.mimeType),a.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),a.upload.onprogress=t=>{t.lengthComputable&&A(100*t.loaded/t.total)},a.onload=()=>{const t=i.assetResponse.asset;ln.add(i.assetResponse.asset),e(t)},a.onerror=n,a.send(t.blob)})),i.assetResponse.asset}async uploadFile(t,e){const A=!("image/svg+xml"===t.type||"application/pdf"===t.type),n=A?z.Image:z.Illustration;if(A){const A=await this.loadImageAsFileInfo(t);return await this.uploadAssetWithProgress(A,n,e,!0)}{const A={name:t.name,blob:new Blob([t],{type:t.type})};return await Bn.uploadAssetWithProgress(A,n,e,!0)}}removePersistedAsset(t){ln.remove(t)}getPersistedAssets(){return ln.list()}async dispatchCreateAssetRequest(t,e,A){const n=t.blob.type?t.blob.type:this.guessMIME(t.name),i=await(async(t,e,A,n)=>(await en.getShadowGraphqlClient().mutate({mutation:sn,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:t,type:e,mimeType:A,anonymous:n}})).data?.assetCreate)(t.name,e,n,A);if(i)return{assetResponse:i,mimeType:n}}guessMIME(t){const e=t.split(".").pop();switch(e){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new OA("Unexpected mimetype: "+e)}}};function wn(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const hn=t.gql`
83
+ `,cn=async t=>(await en.getShadowGraphqlClient().query({query:an,errorPolicy:"all",fetchPolicy:"no-cache",variables:{keys:t}})).data.assets;const gn="persistentAssets";class ln{static add(t){if(!t.fileLink)return void console.error("Failed to find cdn link on asset, cannot persist!");const e=new Map;e.set(t.key||"",t.fileLink);const A=XA.getMap(gn);A&&A.forEach(((t,A)=>{e.set(A,t)})),XA.setMap(gn,e)}static remove(t){const e=XA.getMap(gn);if(!e)return;const A=Array.from(e.entries()).find((e=>e[0]===t));A&&(e.delete(A[0]),XA.setMap(gn,e))}static list(){const t=XA.getMap(gn);return t?Array.from(t.entries()).map((t=>({assetKey:t[0],src:t[1]}))):[]}}const Bn=new class{constructor(){An(this,"cache",new Map),An(this,"materialCache",new Map),An(this,"loadImageAsFileInfo",(async t=>{const e=await t.arrayBuffer(),A=await lA(e);return{name:t.name.substring(t.name.lastIndexOf("/")+1),blob:((t,e)=>{const A=atob(t.split(",")[1]),n=[];for(let t=0;t<A.length;t++)n.push(A.charCodeAt(t));return new Blob([new Uint8Array(n)],{type:e})})(A.dataUrl,t.type)}}))}async getLocalOrFromServer(t){if(this.cache.has(t)){const e=this.cache.get(t);if(!e)throw new OA("Failed to get asset from cache!");return e}const e=(async()=>(await cn([t]))[0])();return this.cache.set(t,e),e}async getMaterialLocalOrFromServer(t){if(this.materialCache.has(t))return this.materialCache.get(t);const e=(async()=>(await(async t=>(await en.getShadowGraphqlClient().query({query:rn,errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:t}})).data.materials)([t]))[0])();return this.materialCache.set(t,e),e}async uploadAssetWithProgress(t,e,A,n){const i=await this.dispatchCreateAssetRequest(t,e,n);if(!i)throw new Error("Failed to create asset.");return await new Promise(((e,n)=>{const a=new XMLHttpRequest;a.open("PUT",i.assetResponse.uploadUrl,!0),a.setRequestHeader("Content-Type",i.mimeType),a.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),a.upload.onprogress=t=>{t.lengthComputable&&A(100*t.loaded/t.total)},a.onload=()=>{const t=i.assetResponse.asset;ln.add(i.assetResponse.asset),e(t)},a.onerror=n,a.send(t.blob)})),i.assetResponse.asset}async uploadFile(t,e){const A=!("image/svg+xml"===t.type||"application/pdf"===t.type),n=A?z.Image:z.Illustration;if(A){const A=await this.loadImageAsFileInfo(t);return await this.uploadAssetWithProgress(A,n,e,!0)}{const A={name:t.name,blob:new Blob([t],{type:t.type})};return await Bn.uploadAssetWithProgress(A,n,e,!0)}}removePersistedAsset(t){ln.remove(t)}getPersistedAssets(){return ln.list()}async dispatchCreateAssetRequest(t,e,A){const n=t.blob.type?t.blob.type:this.guessMIME(t.name),i=await(async(t,e,A,n)=>(await en.getShadowGraphqlClient().mutate({mutation:sn,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:t,type:e,mimeType:A,anonymous:n}})).data?.assetCreate)(t.name,e,n,A);if(i)return{assetResponse:i,mimeType:n}}guessMIME(t){const e=t.split(".").pop();switch(e){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new OA("Unexpected mimetype: "+e)}}};function wn(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const hn=t.gql`
84
84
  fragment OptionFields on Option {
85
85
  id
86
86
  name
@@ -463,7 +463,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),A=require("react/j
463
463
  }
464
464
  }
465
465
  }
466
- `,Qo=(t,e,A)=>{const n={};return e.steps.forEach((e=>{Object.assign(n,(e=>{const n={};if("Frame"===e.type){const i=t[e.stepName],a=e.data;if(!i||a.hideImageInCart&&A)return n;n[`${e.stepTitle} image`]=i.image}if("Illustration"===e.type){const i=t[e.stepName],a=e.data;if(!i||a.hideColorsInCart&&A||!i.colors)return n;if(i.colors.length>0){const t=i.colors.join(", ").toUpperCase();n[`${e.stepTitle} colors`]=t}}if("Module"===e.type){const i=t[e.stepName],a=e.data;if(!i||a.hideTextInCart&&A)return n;n[`${e.stepTitle} text`]=i.text}if("Text"===e.type){const i=t[e.stepName];if(!i)return n;const a=e.data;a.hideTextInCart&&A||(n[`${e.stepTitle} text`]=i.text),!i.color||a.hideColorInCart&&A||(n[`${e.stepTitle} color`]=i.color)}return n})(e))})),n},Co=(t,e,A,n,i,a,o,r,s)=>{const c={event:"onComplete",lineItemImageUrl:o||"",transactionId:t.id,designProductVariantId:t.externalDesignProductVariantId,designProductId:t.externalDesignProductId,externalCartProductId:t.externalCartProductId,externalCartProductVariantId:t.externalCartProductVariantId,baseCost:A,weight:e.weight,optionsCost:n,exportedData:a,workflowViewerLink:t.workflowViewerLink||"",workflowViewerReadOnlyLink:t.workflowViewerReadOnlyLink||""};return i&&(c.metadata=i),r&&(c.selectedVariants=r),s&&(c.sku=s),c},mo=async(t,e,A,n,i,a,o)=>{const r=t.product?.basePrice||0,s=t.priceModifierTotal||0,c=((t,e,A,n)=>{const i={};let a;if(A){a=Qo(A,e,!1);for(const t of Object.keys(a))i[t]={value:a[t],priceModifier:0}}else if(n){a=n;for(const t of Object.keys(a))i[t]={value:a[t],priceModifier:0}}for(const A of Object.keys(t)){const n=t[A],a=e.steps.find((t=>t.stepTitle===A));if(1===n.length)i[`${a?.stepTitle} selection`]={value:n[0].name,priceModifier:n[0].priceModifier};else if(n.length>1)for(let t=0;t<n.length;t++)i[`${a?.stepTitle} selection ${t+1}`]={value:n[t].name,priceModifier:n[t].priceModifier}}return i})(n,A,void 0,a);return Co(t,e,r,s,a,c,o,n,i)},po=async(t,e,A,n,i,a,o,r,s,c,g,l,B)=>{s("workflow.steps.finish.finalize.buildingLayouts"),await t.outstandingRequestsPromise();const w=en.getShadowGraphqlClient();await w.resetStore();const h=await w.query({query:ha,variables:{id:a.id},errorPolicy:"all"}),d=h.data?.transactions[0].workflowState;!h.errors&&d||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(n())),h.errors&&h.errors.forEach((t=>{h.errors&&console.log("Server Error:",t.message)})),await t.updateStateWithServerImmediate(n),console.log("Server state is undefined @ Workflow completion"));const E=t.getPreviewService(),u=e?.finalizeStepConfig?.lookAtAnimation,Q=E&&100===E.getSceneInitializationProgress()&&e.showModelOnFinishStep&&!!u,C=B&&Qo(B,e,!0),m=B&&Qo(B,e,!1),p=async t=>{const A={};let n=0;if(Object.keys(o).length>0)for(const i of Object.keys(o)){const a=o[i],r=e.steps.find((t=>t.stepName===i));for(let e=0;e<a.selections.length;++e){const i=a.selections[e];if(r&&(!t||r.option&&(r.option.variants||[]).length>1&&!r.data.hideSelectionInCart&&!r.data.hideSelectionsInCart)){const t=r.stepTitle;A[t]?A[t].push({id:i.id||"",name:i.name,priceModifier:i.priceModifier}):A[t]=[{id:i.id||"",name:i.name,priceModifier:i.priceModifier}]}n+=i.priceModifier}}return[A,n]},[f]=await p(!0),D=Object.fromEntries(Object.keys(f).map((t=>[t,f[t].map((t=>t.id))]))),[I]=await p(!1),y=Object.fromEntries(Object.keys(I).map((t=>[t,I[t].map((t=>t.id))]))),M=await l(Q);s("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(g);const x=await(async t=>(await en.getShadowGraphqlClient().mutate({mutation:uo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:t.name,layouts:t.layouts,workflowId:t.workflowId,transactionId:t.transactionId,previewImage:t.previewImage,useThreeDimPreview:t.useThreeDimPreview,metadata:t.metadata,selectedVariants:t.selectedVariants}})).data?.designCreate)((()=>{const t={name:r,layouts:A.map((t=>({index:t.index,panelId:t.panelId}))),workflowId:e.id,transactionId:a.id,useThreeDimPreview:Q,previewImage:M};if(m){const e=[];for(const[t,A]of Object.entries(m))e.push({key:t,value:A});t.metadata=e}if(D){const e=[];for(const[t,A]of Object.entries(y))e.push({key:t,ids:A});t.selectedVariants=e}return t})()),F=x?.transaction?.previewImageLink;s("workflow.steps.finish.finalize.updatingTransaction");const Y=(await en.getShadowGraphqlClient().query({query:wa,variables:{id:a.id}})).data.transactions[0];return a.bulk?((t,e,A)=>{const n=(t.product?.basePrice||0)*(t.variationsCount||0),i=t.priceModifierTotal||0,a={items:{value:t.variationsCount?`${t.variationsCount}`:"0",priceModifier:0}};return Co(t,e,n,i,void 0,a,A)})(Y,i,F):await mo(Y,i,e,f,x?.sku,C,F)};let fo;var Do;(Do=fo||(fo={})).Local="Local",Do.Remote="Remote";const Io=new class{constructor(){Eo(this,"localPersistenceKey","designTransactions"),Eo(this,"storageMethod",fo.Local),Eo(this,"designSavedListeners",[])}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter((e=>e!==t))}async getSavedDesigns(){return await this.getDesigns()}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.notifyDesignSaved(t)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter((e=>e.transactionId!==t)))}async setDesigns(t){if(this.storageMethod!==fo.Local)throw new OA("Unexpected storage method requested");XA.set(this.localPersistenceKey,JSON.stringify(t))}async getDesigns(){if(this.storageMethod===fo.Local){const t=XA.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new OA("Unexpected storage method requested")}notifyDesignSaved(t){this.designSavedListeners.forEach((e=>e(t)))}};function yo(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Mo{constructor(t,e){if(yo(this,"client",void 0),yo(this,"commandContext",void 0),yo(this,"workflowManager",void 0),yo(this,"isReadOnly",void 0),yo(this,"renderableScenes",[]),yo(this,"renderableSceneCallbacks",[]),yo(this,"debouncedSavedDesignUpdate",I(p)((async()=>{await Io.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),yo(this,"getCanvasObjectURLAsync",(async t=>new Promise(((e,A)=>{try{t.toBlob((t=>{if(t){const A=URL.createObjectURL(t);e(A)}}))}catch(t){A(t)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const A=e.layouts;this.commandContext=new Me,this.commandContext.initialize(A,e.reloadedState),this.isReadOnly=!!e.transaction.lineItem?.id||!XA.getMap("transactionOwnerIds")?.get(e.transaction.id)||!!e.readOnly,this.workflowManager=new $a(e.workflow,e.product.profanities?.map((t=>t.word))||[],A,this.commandContext,(t=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(t)}),e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly),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 en.getShadowGraphqlClient().mutate({mutation:Ba,variables:{transactionId:this.workflowManager.getTransaction().id,updates:t.map((t=>({recordNumber:t.recordNumber,values:t.values.map((t=>({aspect:t.aspect,stepName:t.stepName,value:t.value})))})))}})}async createPreviewImage(t,e){const A=this.workflowManager.getWorkflow(),n=A?.finalizeStepConfig?.lookAtAnimation;if(t){if(!n)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,n))||""}const i=document.createElement("canvas");let a=2048;e&&e<=2048&&(a=e),i.width=a,i.height=a;const o=this.commandContext.getAllLayouts(),r=A.defaultPreviewPanelIndex||0,s=A.panels[r],c=o.find((t=>t.layoutState?.layout.panelId===s?.name))||o[0],g=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},l=this.commandContext.getLayoutById(c.layoutState.layout.id),w=i.getContext("2d");if(!w)throw new jA("Failed to obtain 2D context for preview image creation");const h=Fe(l.layoutState.layout,l.layoutState.elements,{renderingConfiguration:{purpose:H.Print,region:{left:g.x,top:g.y,width:g.width,height:g.height}}}),d=I(Q).renderToStaticMarkup(h),E=await B.Canvg.from(w,d,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await E.render();const u=await this.getCanvasObjectURLAsync(i);return i.toDataURL(u)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t));if(e&&this.stepHasHandle(e))return ho.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})))}getBulkStep(){if(this.getWorkflowManager().getTransaction().bulk){const t=this.getWorkflowManager().getProduct().bulkConfiguration,e={type:K.Bulk,stepName:"Bulk",stepTitle:t?.stepTitle??"workflow.steps.bulk.title",helpText:t?.helpText,data:{aspects:da(this.getWorkflowManager().getWorkflow())},conditions:[]};return ho.get(this.getWorkflowManager(),e)}}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepTitle===t));if(e&&this.stepHasHandle(e))return ho.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter((e=>e.type===t)).map((t=>ho.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=>ho.get(this.getWorkflowManager(),t)))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){await en.getShadowGraphqlClient().mutate({mutation:io,variables:{id:this.getWorkflowManager().getTransaction().id,details:t,type:"Owner"}}),this.getWorkflowManager().setTransactionCustomer(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 OA("State undefined!");const e={title:await(async()=>{if(t)return t;const e=this.getWorkflowManager().getTransaction().id,A=(await Io.getSavedDesigns()).find((t=>t.transactionId===e))?.title;return A||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await Io.addDesign(e),e}async copy(){const t=I(e)(this.getCommandContext().getState());if(!t)throw new OA("Internal state is undefined! Cannot copy experience!");const A=JSON.stringify(t.transaction),n=this.getWorkflowManager().getWorkflow(),i=new Ro({}),a=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!a)throw new OA("Integration product id is undefined!");await i.initFromIntegrationProduct(a);return await i.getWorkflowExperience(n.id,A,void 0)}async onDesignFinished(t){return po(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),(()=>this.commandContext.getState()),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,t||(()=>{}),(t=>this.updateVariationRecords(t)),this.workflowManager.getVariationRecords(),(t=>this.createPreviewImage(t)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==K.SilentIllustration&&t.type!==K.ProductOverlay}getExportedData(){const t=new Map,e=this.getWorkflowManager().getWorkflowMetadata(),A=this.getWorkflowManager().getWorkflowSelections();return Object.keys(e).forEach((A=>{const n=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===A));if(!n)return;t.has(n.stepTitle)||t.set(n.stepTitle,{});const i=e[A];Object.keys(i).forEach((e=>{t.get(n.stepTitle)[e]=i[e]}))})),Object.keys(A)?.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=A[e].selections[0].name)})),t}}function xo(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Fo=t.gql`
466
+ `,Qo=(t,e,A)=>{const n={};return e.steps.forEach((e=>{Object.assign(n,(e=>{const n={};if("Frame"===e.type){const i=t[e.stepName],a=e.data;if(!i||a.hideImageInCart&&A)return n;n[`${e.stepTitle} image`]=i.image}if("Illustration"===e.type){const i=t[e.stepName],a=e.data;if(!i||a.hideColorsInCart&&A||!i.colors)return n;if(i.colors.length>0){const t=i.colors.join(", ").toUpperCase();n[`${e.stepTitle} colors`]=t}}if("Module"===e.type){const i=t[e.stepName],a=e.data;if(!i||a.hideTextInCart&&A)return n;n[`${e.stepTitle} text`]=i.text}if("Text"===e.type){const i=t[e.stepName];if(!i)return n;const a=e.data;a.hideTextInCart&&A||(n[`${e.stepTitle} text`]=i.text),!i.color||a.hideColorInCart&&A||(n[`${e.stepTitle} color`]=i.color)}return n})(e))})),n},Co=(t,e,A,n,i,a,o,r,s)=>{const c=(XA.getMap("transactionOwnerIds")||new Map).get(t.id),g={event:"onComplete",lineItemImageUrl:o||"",transactionId:t.id,designProductVariantId:t.externalDesignProductVariantId,designProductId:t.externalDesignProductId,externalCartProductId:t.externalCartProductId,externalCartProductVariantId:t.externalCartProductVariantId,baseCost:A,weight:e.weight,optionsCost:n,exportedData:a,workflowViewerLink:t.workflowViewerLink||"",workflowViewerReadOnlyLink:t.workflowViewerReadOnlyLink||"",transactionOwnerId:c};return i&&(g.metadata=i),r&&(g.selectedVariants=r),s&&(g.sku=s),g},mo=async(t,e,A,n,i,a,o)=>{const r=t.product?.basePrice||0,s=t.priceModifierTotal||0,c=((t,e,A,n)=>{const i={};let a;if(A){a=Qo(A,e,!1);for(const t of Object.keys(a))i[t]={value:a[t],priceModifier:0}}else if(n){a=n;for(const t of Object.keys(a))i[t]={value:a[t],priceModifier:0}}for(const A of Object.keys(t)){const n=t[A],a=e.steps.find((t=>t.stepTitle===A));if(1===n.length)i[`${a?.stepTitle} selection`]={value:n[0].name,priceModifier:n[0].priceModifier};else if(n.length>1)for(let t=0;t<n.length;t++)i[`${a?.stepTitle} selection ${t+1}`]={value:n[t].name,priceModifier:n[t].priceModifier}}return i})(n,A,void 0,a);return Co(t,e,r,s,a,c,o,n,i)},po=async(t,e,A,n,i,a,o,r,s,c,g,l,B)=>{s("workflow.steps.finish.finalize.buildingLayouts"),await t.outstandingRequestsPromise();const w=en.getShadowGraphqlClient();await w.resetStore();const h=await w.query({query:ha,variables:{id:a.id},errorPolicy:"all"}),d=h.data?.transactions[0].workflowState;!h.errors&&d||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(n())),h.errors&&h.errors.forEach((t=>{h.errors&&console.log("Server Error:",t.message)})),await t.updateStateWithServerImmediate(n),console.log("Server state is undefined @ Workflow completion"));const E=t.getPreviewService(),u=e?.finalizeStepConfig?.lookAtAnimation,Q=E&&100===E.getSceneInitializationProgress()&&e.showModelOnFinishStep&&!!u,C=B&&Qo(B,e,!0),m=B&&Qo(B,e,!1),p=async t=>{const A={};let n=0;if(Object.keys(o).length>0)for(const i of Object.keys(o)){const a=o[i],r=e.steps.find((t=>t.stepName===i));for(let e=0;e<a.selections.length;++e){const i=a.selections[e];if(r&&(!t||r.option&&(r.option.variants||[]).length>1&&!r.data.hideSelectionInCart&&!r.data.hideSelectionsInCart)){const t=r.stepTitle;A[t]?A[t].push({id:i.id||"",name:i.name,priceModifier:i.priceModifier}):A[t]=[{id:i.id||"",name:i.name,priceModifier:i.priceModifier}]}n+=i.priceModifier}}return[A,n]},[f]=await p(!0),D=Object.fromEntries(Object.keys(f).map((t=>[t,f[t].map((t=>t.id))]))),[I]=await p(!1),y=Object.fromEntries(Object.keys(I).map((t=>[t,I[t].map((t=>t.id))]))),M=await l(Q);s("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(g);const x=await(async t=>(await en.getShadowGraphqlClient().mutate({mutation:uo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:t.name,layouts:t.layouts,workflowId:t.workflowId,transactionId:t.transactionId,previewImage:t.previewImage,useThreeDimPreview:t.useThreeDimPreview,metadata:t.metadata,selectedVariants:t.selectedVariants}})).data?.designCreate)((()=>{const t={name:r,layouts:A.map((t=>({index:t.index,panelId:t.panelId}))),workflowId:e.id,transactionId:a.id,useThreeDimPreview:Q,previewImage:M};if(m){const e=[];for(const[t,A]of Object.entries(m))e.push({key:t,value:A});t.metadata=e}if(D){const e=[];for(const[t,A]of Object.entries(y))e.push({key:t,ids:A});t.selectedVariants=e}return t})()),F=x?.transaction?.previewImageLink;s("workflow.steps.finish.finalize.updatingTransaction");const Y=(await en.getShadowGraphqlClient().query({query:wa,variables:{id:a.id}})).data.transactions[0];return a.bulk?((t,e,A)=>{const n=(t.product?.basePrice||0)*(t.variationsCount||0),i=t.priceModifierTotal||0,a={items:{value:t.variationsCount?`${t.variationsCount}`:"0",priceModifier:0}};return Co(t,e,n,i,void 0,a,A)})(Y,i,F):await mo(Y,i,e,f,x?.sku,C,F)};let fo;var Do;(Do=fo||(fo={})).Local="Local",Do.Remote="Remote";const Io=new class{constructor(){Eo(this,"localPersistenceKey","designTransactions"),Eo(this,"storageMethod",fo.Local),Eo(this,"designSavedListeners",[])}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter((e=>e!==t))}async getSavedDesigns(){return await this.getDesigns()}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.notifyDesignSaved(t)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter((e=>e.transactionId!==t)))}async setDesigns(t){if(this.storageMethod!==fo.Local)throw new OA("Unexpected storage method requested");XA.set(this.localPersistenceKey,JSON.stringify(t))}async getDesigns(){if(this.storageMethod===fo.Local){const t=XA.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new OA("Unexpected storage method requested")}notifyDesignSaved(t){this.designSavedListeners.forEach((e=>e(t)))}};function yo(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class Mo{constructor(t,e){if(yo(this,"client",void 0),yo(this,"commandContext",void 0),yo(this,"workflowManager",void 0),yo(this,"isReadOnly",void 0),yo(this,"renderableScenes",[]),yo(this,"renderableSceneCallbacks",[]),yo(this,"debouncedSavedDesignUpdate",I(p)((async()=>{await Io.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),yo(this,"getCanvasObjectURLAsync",(async t=>new Promise(((e,A)=>{try{t.toBlob((t=>{if(t){const A=URL.createObjectURL(t);e(A)}}))}catch(t){A(t)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const A=e.layouts;this.commandContext=new Me,this.commandContext.initialize(A,e.reloadedState),this.isReadOnly=!!e.transaction.lineItem?.id||!XA.getMap("transactionOwnerIds")?.get(e.transaction.id)||!!e.readOnly,this.workflowManager=new $a(e.workflow,e.product.profanities?.map((t=>t.word))||[],A,this.commandContext,(t=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(t)}),e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly),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 en.getShadowGraphqlClient().mutate({mutation:Ba,variables:{transactionId:this.workflowManager.getTransaction().id,updates:t.map((t=>({recordNumber:t.recordNumber,values:t.values.map((t=>({aspect:t.aspect,stepName:t.stepName,value:t.value})))})))}})}async createPreviewImage(t,e){const A=this.workflowManager.getWorkflow(),n=A?.finalizeStepConfig?.lookAtAnimation;if(t){if(!n)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,n))||""}const i=document.createElement("canvas");let a=2048;e&&e<=2048&&(a=e),i.width=a,i.height=a;const o=this.commandContext.getAllLayouts(),r=A.defaultPreviewPanelIndex||0,s=A.panels[r],c=o.find((t=>t.layoutState?.layout.panelId===s?.name))||o[0],g=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},l=this.commandContext.getLayoutById(c.layoutState.layout.id),w=i.getContext("2d");if(!w)throw new jA("Failed to obtain 2D context for preview image creation");const h=Fe(l.layoutState.layout,l.layoutState.elements,{renderingConfiguration:{purpose:H.Print,region:{left:g.x,top:g.y,width:g.width,height:g.height}}}),d=I(Q).renderToStaticMarkup(h),E=await B.Canvg.from(w,d,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await E.render();const u=await this.getCanvasObjectURLAsync(i);return i.toDataURL(u)}getStepById(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepName===t));if(e&&this.stepHasHandle(e))return ho.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})))}getBulkStep(){if(this.getWorkflowManager().getTransaction().bulk){const t=this.getWorkflowManager().getProduct().bulkConfiguration,e={type:K.Bulk,stepName:"Bulk",stepTitle:t?.stepTitle??"workflow.steps.bulk.title",helpText:t?.helpText,data:{aspects:da(this.getWorkflowManager().getWorkflow())},conditions:[]};return ho.get(this.getWorkflowManager(),e)}}getStepByName(t){const e=this.getWorkflowManager().getWorkflow().steps.find((e=>e.stepTitle===t));if(e&&this.stepHasHandle(e))return ho.get(this.getWorkflowManager(),e)}getStepsByType(t){return this.getWorkflowManager().getWorkflow().steps.filter((e=>e.type===t)).map((t=>ho.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=>ho.get(this.getWorkflowManager(),t)))}async attachCustomerDetails(t){return this.assignCustomerDetails({emailAddress:t.email})}async assignCustomerDetails(t){await en.getShadowGraphqlClient().mutate({mutation:io,variables:{id:this.getWorkflowManager().getTransaction().id,details:t,type:"Owner"}}),this.getWorkflowManager().setTransactionCustomer(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 OA("State undefined!");const e={title:await(async()=>{if(t)return t;const e=this.getWorkflowManager().getTransaction().id,A=(await Io.getSavedDesigns()).find((t=>t.transactionId===e))?.title;return A||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await Io.addDesign(e),e}async copy(){const t=I(e)(this.getCommandContext().getState());if(!t)throw new OA("Internal state is undefined! Cannot copy experience!");const A=JSON.stringify(t.transaction),n=this.getWorkflowManager().getWorkflow(),i=new Ro({}),a=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!a)throw new OA("Integration product id is undefined!");await i.initFromIntegrationProduct(a);return await i.getWorkflowExperience(n.id,A,void 0)}async onDesignFinished(t){return po(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),(()=>this.commandContext.getState()),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,t||(()=>{}),(t=>this.updateVariationRecords(t)),this.workflowManager.getVariationRecords(),(t=>this.createPreviewImage(t)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(t){return t.type!==K.SilentIllustration&&t.type!==K.ProductOverlay}getExportedData(){const t=new Map,e=this.getWorkflowManager().getWorkflowMetadata(),A=this.getWorkflowManager().getWorkflowSelections();return Object.keys(e).forEach((A=>{const n=this.workflowManager.getWorkflow().steps.find((t=>t.stepName===A));if(!n)return;t.has(n.stepTitle)||t.set(n.stepTitle,{});const i=e[A];Object.keys(i).forEach((e=>{t.get(n.stepTitle)[e]=i[e]}))})),Object.keys(A)?.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=A[e].selections[0].name)})),t}}function xo(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.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:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Fo=t.gql`
467
467
  fragment RegionFields on Region {
468
468
  width
469
469
  top
package/dist/module.js CHANGED
@@ -69,7 +69,7 @@ import{CommandContext as A,AssetType as t,BringForwardCommand as e,BringToFrontC
69
69
  `,pt=pA`
70
70
  mutation CreateAsset($name: String!, $type: String!, $mimeType: String!, $anonymous: Boolean) {
71
71
  assetCreate(name: $name, type: $type, mimeType: $mimeType, anonymous: $anonymous) {
72
- uploadUrl,
72
+ uploadUrl
73
73
  asset {
74
74
  name
75
75
  key
@@ -80,7 +80,7 @@ import{CommandContext as A,AssetType as t,BringForwardCommand as e,BringToFrontC
80
80
  }
81
81
  }
82
82
  }
83
- `,It=async A=>(await ht.getShadowGraphqlClient().query({query:ut,errorPolicy:"all",fetchPolicy:"no-cache",variables:{keys:A}})).data.assets;const ft="persistentAssets";class Mt{static add(A){if(!A.fileLink)return void console.error("Failed to find cdn link on asset, cannot persist!");const t=new Map;t.set(A.key||"",A.fileLink);const e=gt.getMap(ft);e&&e.forEach(((A,e)=>{t.set(e,A)})),gt.setMap(ft,t)}static remove(A){const t=gt.getMap(ft);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),gt.setMap(ft,t))}static list(){const A=gt.getMap(ft);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const yt=new class{constructor(){Qt(this,"cache",new Map),Qt(this,"materialCache",new Map),Qt(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await S(t);return{name:A.name.substring(A.name.lastIndexOf("/")+1),blob:((A,t)=>{let e=atob(A.split(",")[1]),n=[];for(let A=0;A<e.length;A++)n.push(e.charCodeAt(A));return new Blob([new Uint8Array(n)],{type:t})})(e.dataUrl,A.type)}}))}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new nt("Failed to get asset from cache!");return t}const t=(async()=>(await It([A]))[0])();return this.cache.set(A,t),t}async getMaterialLocalOrFromServer(A){if(this.materialCache.has(A))return this.materialCache.get(A);const t=(async()=>(await(async A=>(await ht.getShadowGraphqlClient().query({query:mt,errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:A}})).data.materials)([A]))[0])();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n){const i=await this.dispatchCreateAssetRequest(A,t,n);if(!i)throw new Error("Failed to create asset.");return await new Promise(((t,n)=>{var a=new XMLHttpRequest;a.open("PUT",i.assetResponse.uploadUrl,!0),a.setRequestHeader("Content-Type",i.mimeType),a.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),a.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},a.onload=()=>{const A=i.assetResponse.asset;Mt.add(i.assetResponse.asset),t(A)},a.onerror=n,a.send(A.blob)})),i.assetResponse.asset}async uploadFile(A,e){const n=!("image/svg+xml"===A.type||"application/pdf"===A.type),i=n?t.Image:t.Illustration;if(n){const t=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(t,i,e,!0)}{const t={name:A.name,blob:new Blob([A],{type:A.type})};return await yt.uploadAssetWithProgress(t,i,e,!0)}}removePersistedAsset(A){Mt.remove(A)}getPersistedAssets(){return Mt.list()}async dispatchCreateAssetRequest(A,t,e){const n=A.blob.type?A.blob.type:this.guessMIME(A.name),i=await(async(A,t,e,n)=>(await ht.getShadowGraphqlClient().mutate({mutation:pt,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:A,type:t,mimeType:e,anonymous:n}})).data?.assetCreate)(A.name,t,n,e);if(i)return{assetResponse:i,mimeType:n}}guessMIME(A){const t=A.split(".").pop();switch(t){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new nt("Unexpected mimetype: "+t)}}};function Ft(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Yt=pA`
83
+ `,It=async A=>(await ht.getShadowGraphqlClient().query({query:ut,errorPolicy:"all",fetchPolicy:"no-cache",variables:{keys:A}})).data.assets;const ft="persistentAssets";class Mt{static add(A){if(!A.fileLink)return void console.error("Failed to find cdn link on asset, cannot persist!");const t=new Map;t.set(A.key||"",A.fileLink);const e=gt.getMap(ft);e&&e.forEach(((A,e)=>{t.set(e,A)})),gt.setMap(ft,t)}static remove(A){const t=gt.getMap(ft);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),gt.setMap(ft,t))}static list(){const A=gt.getMap(ft);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const yt=new class{constructor(){Qt(this,"cache",new Map),Qt(this,"materialCache",new Map),Qt(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await S(t);return{name:A.name.substring(A.name.lastIndexOf("/")+1),blob:((A,t)=>{const e=atob(A.split(",")[1]),n=[];for(let A=0;A<e.length;A++)n.push(e.charCodeAt(A));return new Blob([new Uint8Array(n)],{type:t})})(e.dataUrl,A.type)}}))}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new nt("Failed to get asset from cache!");return t}const t=(async()=>(await It([A]))[0])();return this.cache.set(A,t),t}async getMaterialLocalOrFromServer(A){if(this.materialCache.has(A))return this.materialCache.get(A);const t=(async()=>(await(async A=>(await ht.getShadowGraphqlClient().query({query:mt,errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:A}})).data.materials)([A]))[0])();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n){const i=await this.dispatchCreateAssetRequest(A,t,n);if(!i)throw new Error("Failed to create asset.");return await new Promise(((t,n)=>{const a=new XMLHttpRequest;a.open("PUT",i.assetResponse.uploadUrl,!0),a.setRequestHeader("Content-Type",i.mimeType),a.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),a.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},a.onload=()=>{const A=i.assetResponse.asset;Mt.add(i.assetResponse.asset),t(A)},a.onerror=n,a.send(A.blob)})),i.assetResponse.asset}async uploadFile(A,e){const n=!("image/svg+xml"===A.type||"application/pdf"===A.type),i=n?t.Image:t.Illustration;if(n){const t=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(t,i,e,!0)}{const t={name:A.name,blob:new Blob([A],{type:A.type})};return await yt.uploadAssetWithProgress(t,i,e,!0)}}removePersistedAsset(A){Mt.remove(A)}getPersistedAssets(){return Mt.list()}async dispatchCreateAssetRequest(A,t,e){const n=A.blob.type?A.blob.type:this.guessMIME(A.name),i=await(async(A,t,e,n)=>(await ht.getShadowGraphqlClient().mutate({mutation:pt,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:A,type:t,mimeType:e,anonymous:n}})).data?.assetCreate)(A.name,t,n,e);if(i)return{assetResponse:i,mimeType:n}}guessMIME(A){const t=A.split(".").pop();switch(t){case"glb":return"model/gltf-binary";case"ttf":return"font/ttf";case"mkv":return"video/x-matroska";default:throw new nt("Unexpected mimetype: "+t)}}};function Ft(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Yt=pA`
84
84
  fragment OptionFields on Option {
85
85
  id
86
86
  name
@@ -463,7 +463,7 @@ import{CommandContext as A,AssetType as t,BringForwardCommand as e,BringToFrontC
463
463
  }
464
464
  }
465
465
  }
466
- `,Ni=(A,t,e)=>{const n={};return t.steps.forEach((t=>{Object.assign(n,(t=>{const n={};if("Frame"===t.type){const i=A[t.stepName],a=t.data;if(!i||a.hideImageInCart&&e)return n;n[`${t.stepTitle} image`]=i.image}if("Illustration"===t.type){const i=A[t.stepName],a=t.data;if(!i||a.hideColorsInCart&&e||!i.colors)return n;if(i.colors.length>0){const A=i.colors.join(", ").toUpperCase();n[`${t.stepTitle} colors`]=A}}if("Module"===t.type){const i=A[t.stepName],a=t.data;if(!i||a.hideTextInCart&&e)return n;n[`${t.stepTitle} text`]=i.text}if("Text"===t.type){const i=A[t.stepName];if(!i)return n;const a=t.data;a.hideTextInCart&&e||(n[`${t.stepTitle} text`]=i.text),!i.color||a.hideColorInCart&&e||(n[`${t.stepTitle} color`]=i.color)}return n})(t))})),n},Ri=(A,t,e,n,i,a,o,r,s)=>{const c={event:"onComplete",lineItemImageUrl:o||"",transactionId:A.id,designProductVariantId:A.externalDesignProductVariantId,designProductId:A.externalDesignProductId,externalCartProductId:A.externalCartProductId,externalCartProductVariantId:A.externalCartProductVariantId,baseCost:e,weight:t.weight,optionsCost:n,exportedData:a,workflowViewerLink:A.workflowViewerLink||"",workflowViewerReadOnlyLink:A.workflowViewerReadOnlyLink||""};return i&&(c.metadata=i),r&&(c.selectedVariants=r),s&&(c.sku=s),c},Hi=async(A,t,e,n,i,a,o)=>{const r=A.product?.basePrice||0,s=A.priceModifierTotal||0,c=((A,t,e,n)=>{const i={};let a;if(e){a=Ni(e,t,!1);for(const A of Object.keys(a))i[A]={value:a[A],priceModifier:0}}else if(n){a=n;for(const A of Object.keys(a))i[A]={value:a[A],priceModifier:0}}for(const e of Object.keys(A)){const n=A[e],a=t.steps.find((A=>A.stepTitle===e));if(1===n.length)i[`${a?.stepTitle} selection`]={value:n[0].name,priceModifier:n[0].priceModifier};else if(n.length>1)for(let A=0;A<n.length;A++)i[`${a?.stepTitle} selection ${A+1}`]={value:n[A].name,priceModifier:n[A].priceModifier}}return i})(n,e,void 0,a);return Ri(A,t,r,s,a,c,o,n,i)},Ui=async(A,t,e,n,i,a,o,r,s,c,g,B,l)=>{s("workflow.steps.finish.finalize.buildingLayouts"),await A.outstandingRequestsPromise();const w=ht.getShadowGraphqlClient();await w.resetStore();const E=await w.query({query:xn,variables:{id:a.id},errorPolicy:"all"}),d=E.data?.transactions[0].workflowState;!E.errors&&d||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(n())),E.errors&&E.errors.forEach((A=>{E.errors&&console.log("Server Error:",A.message)})),await A.updateStateWithServerImmediate(n),console.log("Server state is undefined @ Workflow completion"));const h=A.getPreviewService(),Q=t?.finalizeStepConfig?.lookAtAnimation,C=h&&100===h.getSceneInitializationProgress()&&t.showModelOnFinishStep&&!!Q,u=l&&Ni(l,t,!0),D=l&&Ni(l,t,!1),m=async A=>{const e={};let n=0;if(Object.keys(o).length>0)for(const i of Object.keys(o)){const a=o[i],r=t.steps.find((A=>A.stepName===i));for(let t=0;t<a.selections.length;++t){const i=a.selections[t];if(r&&(!A||r.option&&(r.option.variants||[]).length>1&&!r.data.hideSelectionInCart&&!r.data.hideSelectionsInCart)){const A=r.stepTitle;e[A]?e[A].push({id:i.id||"",name:i.name,priceModifier:i.priceModifier}):e[A]=[{id:i.id||"",name:i.name,priceModifier:i.priceModifier}]}n+=i.priceModifier}}return[e,n]},[p]=await m(!0),I=Object.fromEntries(Object.keys(p).map((A=>[A,p[A].map((A=>A.id))]))),[f]=await m(!1),M=Object.fromEntries(Object.keys(f).map((A=>[A,f[A].map((A=>A.id))]))),y=await B(C);s("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(g);const F=await(async A=>(await ht.getShadowGraphqlClient().mutate({mutation:vi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:A.name,layouts:A.layouts,workflowId:A.workflowId,transactionId:A.transactionId,previewImage:A.previewImage,useThreeDimPreview:A.useThreeDimPreview,metadata:A.metadata,selectedVariants:A.selectedVariants}})).data?.designCreate)((()=>{const A={name:r,layouts:e.map((A=>({index:A.index,panelId:A.panelId}))),workflowId:t.id,transactionId:a.id,useThreeDimPreview:C,previewImage:y};if(D){const t=[];for(const[A,e]of Object.entries(D))t.push({key:A,value:e});A.metadata=t}if(I){const t=[];for(const[A,e]of Object.entries(M))t.push({key:A,ids:e});A.selectedVariants=t}return A})()),Y=F?.transaction?.previewImageLink;s("workflow.steps.finish.finalize.updatingTransaction");const x=(await ht.getShadowGraphqlClient().query({query:Yn,variables:{id:a.id}})).data.transactions[0];return a.bulk?((A,t,e)=>{const n=(A.product?.basePrice||0)*(A.variationsCount||0),i=A.priceModifierTotal||0,a={items:{value:A.variationsCount?`${A.variationsCount}`:"0",priceModifier:0}};return Ri(A,t,n,i,void 0,a,e)})(x,i,Y):await Hi(x,i,t,p,F?.sku,u,Y)};let Pi;var Gi;(Gi=Pi||(Pi={})).Local="Local",Gi.Remote="Remote";const ki=new class{constructor(){Si(this,"localPersistenceKey","designTransactions"),Si(this,"storageMethod",Pi.Local),Si(this,"designSavedListeners",[])}attachSaveListener(A){this.designSavedListeners.push(A)}detachSaveListener(A){this.designSavedListeners=this.designSavedListeners.filter((t=>t!==A))}async getSavedDesigns(){return await this.getDesigns()}async getSavedDesignByTransaction(A){return(await this.getSavedDesigns()).find((t=>t.transactionId===A))}async addDesign(A){const t=(await this.getSavedDesigns()).filter((t=>t.transactionId!==A.transactionId));t.unshift(A),await this.setDesigns(t),this.notifyDesignSaved(A)}async removeDesign(A){const t=await this.getSavedDesigns();await this.setDesigns(t.filter((t=>t.transactionId!==A)))}async setDesigns(A){if(this.storageMethod!==Pi.Local)throw new nt("Unexpected storage method requested");gt.set(this.localPersistenceKey,JSON.stringify(A))}async getDesigns(){if(this.storageMethod===Pi.Local){const A=gt.get(this.localPersistenceKey);return A?JSON.parse(A):[]}throw new nt("Unexpected storage method requested")}notifyDesignSaved(A){this.designSavedListeners.forEach((t=>t(A)))}};function Ji(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class bi{constructor(t,e){if(Ji(this,"client",void 0),Ji(this,"commandContext",void 0),Ji(this,"workflowManager",void 0),Ji(this,"isReadOnly",void 0),Ji(this,"renderableScenes",[]),Ji(this,"renderableSceneCallbacks",[]),Ji(this,"debouncedSavedDesignUpdate",VA((async()=>{await ki.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),Ji(this,"getCanvasObjectURLAsync",(async A=>new Promise(((t,e)=>{try{A.toBlob((A=>{if(A){const e=URL.createObjectURL(A);t(e)}}))}catch(A){e(A)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const n=e.layouts;this.commandContext=new A,this.commandContext.initialize(n,e.reloadedState),this.isReadOnly=!!e.transaction.lineItem?.id||!gt.getMap("transactionOwnerIds")?.get(e.transaction.id)||!!e.readOnly,this.workflowManager=new wi(e.workflow,e.product.profanities?.map((A=>A.word))||[],n,this.commandContext,(A=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(A)}),e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly),this.workflowManager.addSelectionCallback((A=>{const t=A.traversableScenes.map((A=>{const t=A.renderableSteps.map((A=>A.stepName));return{id:A.name,title:A.title,renderableSteps:t}}));this.renderableScenes=t,this.renderableSceneCallbacks.forEach((A=>A(t)))}))}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async updateVariationRecords(A){await ht.getShadowGraphqlClient().mutate({mutation:Fn,variables:{transactionId:this.workflowManager.getTransaction().id,updates:A.map((A=>({recordNumber:A.recordNumber,values:A.values.map((A=>({aspect:A.aspect,stepName:A.stepName,value:A.value})))})))}})}async createPreviewImage(A,t){const e=this.workflowManager.getWorkflow(),n=e?.finalizeStepConfig?.lookAtAnimation;if(A){if(!n)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,n))||""}const i=document.createElement("canvas");let a=2048;t&&t<=2048&&(a=t),i.width=a,i.height=a;const o=this.commandContext.getAllLayouts(),r=e.defaultPreviewPanelIndex||0,s=e.panels[r],c=o.find((A=>A.layoutState?.layout.panelId===s?.name))||o[0],g=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},B=this.commandContext.getLayoutById(c.layoutState.layout.id),l=i.getContext("2d");if(!l)throw new ot("Failed to obtain 2D context for preview image creation");const w=R(B.layoutState.layout,B.layoutState.elements,{renderingConfiguration:{purpose:W.Print,region:{left:g.x,top:g.y,width:g.width,height:g.height}}}),E=zA.renderToStaticMarkup(w),d=await OA.from(l,E,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await d.render();const h=await this.getCanvasObjectURLAsync(i);return i.toDataURL(h)}getStepById(A){const t=this.getWorkflowManager().getWorkflow().steps.find((t=>t.stepName===A));if(t&&this.stepHasHandle(t))return xi.get(this.getWorkflowManager(),t)}getSteps(){return this.getScenes().flatMap((A=>this.getStepsByScene(A)))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map((A=>({id:A.id,name:A.name,stepIds:A.stepNames})))}getBulkStep(){if(this.getWorkflowManager().getTransaction().bulk){const A=this.getWorkflowManager().getProduct().bulkConfiguration,t={type:m.Bulk,stepName:"Bulk",stepTitle:A?.stepTitle??"workflow.steps.bulk.title",helpText:A?.helpText,data:{aspects:Sn(this.getWorkflowManager().getWorkflow())},conditions:[]};return xi.get(this.getWorkflowManager(),t)}}getStepByName(A){const t=this.getWorkflowManager().getWorkflow().steps.find((t=>t.stepTitle===A));if(t&&this.stepHasHandle(t))return xi.get(this.getWorkflowManager(),t)}getStepsByType(A){return this.getWorkflowManager().getWorkflow().steps.filter((t=>t.type===A)).map((A=>xi.get(this.getWorkflowManager(),A)))}getStepsByScene(A){if(!this.getWorkflowManager().getWorkflow().stepGroups.find((t=>t.name===A.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 A.stepIds.map((A=>this.getWorkflowManager().getWorkflow().steps.find((t=>t.stepName===A)))).filter((A=>this.stepHasHandle(A))).map((A=>xi.get(this.getWorkflowManager(),A)))}async attachCustomerDetails(A){return this.assignCustomerDetails({emailAddress:A.email})}async assignCustomerDetails(A){await ht.getShadowGraphqlClient().mutate({mutation:ui,variables:{id:this.getWorkflowManager().getTransaction().id,details:A,type:"Owner"}}),this.getWorkflowManager().setTransactionCustomer(A)}attachRenderableSceneListener(A){this.renderableSceneCallbacks.push(A),A(this.renderableScenes)}detachRenderableSceneListener(A){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter((t=>t!==A))}async save(A){if(!this.getCommandContext().getState())throw new nt("State undefined!");const t={title:await(async()=>{if(A)return A;const t=this.getWorkflowManager().getTransaction().id,e=(await ki.getSavedDesigns()).find((A=>A.transactionId===t))?.title;return e||"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 ki.addDesign(t),t}async copy(){const A=TA(this.getCommandContext().getState());if(!A)throw new nt("Internal state is undefined! Cannot copy experience!");const t=JSON.stringify(A.transaction),e=this.getWorkflowManager().getWorkflow(),n=new ji({}),i=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!i)throw new nt("Integration product id is undefined!");await n.initFromIntegrationProduct(i);return await n.getWorkflowExperience(e.id,t,void 0)}async onDesignFinished(A){return Ui(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),(()=>this.commandContext.getState()),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,A||(()=>{}),(A=>this.updateVariationRecords(A)),this.workflowManager.getVariationRecords(),(A=>this.createPreviewImage(A)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(A){return A.type!==m.SilentIllustration&&A.type!==m.ProductOverlay}getExportedData(){const A=new Map,t=this.getWorkflowManager().getWorkflowMetadata(),e=this.getWorkflowManager().getWorkflowSelections();return Object.keys(t).forEach((e=>{const n=this.workflowManager.getWorkflow().steps.find((A=>A.stepName===e));if(!n)return;A.has(n.stepTitle)||A.set(n.stepTitle,{});const i=t[e];Object.keys(i).forEach((t=>{A.get(n.stepTitle)[t]=i[t]}))})),Object.keys(e)?.forEach((t=>{const n=this.workflowManager.getWorkflow().steps.find((A=>A.stepName===t));n&&(A.has(n.stepTitle)||A.set(n.stepTitle,{}),A.get(n.stepTitle).selection=e[t].selections[0].name)})),A}}function Li(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ti=pA`
466
+ `,Ni=(A,t,e)=>{const n={};return t.steps.forEach((t=>{Object.assign(n,(t=>{const n={};if("Frame"===t.type){const i=A[t.stepName],a=t.data;if(!i||a.hideImageInCart&&e)return n;n[`${t.stepTitle} image`]=i.image}if("Illustration"===t.type){const i=A[t.stepName],a=t.data;if(!i||a.hideColorsInCart&&e||!i.colors)return n;if(i.colors.length>0){const A=i.colors.join(", ").toUpperCase();n[`${t.stepTitle} colors`]=A}}if("Module"===t.type){const i=A[t.stepName],a=t.data;if(!i||a.hideTextInCart&&e)return n;n[`${t.stepTitle} text`]=i.text}if("Text"===t.type){const i=A[t.stepName];if(!i)return n;const a=t.data;a.hideTextInCart&&e||(n[`${t.stepTitle} text`]=i.text),!i.color||a.hideColorInCart&&e||(n[`${t.stepTitle} color`]=i.color)}return n})(t))})),n},Ri=(A,t,e,n,i,a,o,r,s)=>{const c=(gt.getMap("transactionOwnerIds")||new Map).get(A.id),g={event:"onComplete",lineItemImageUrl:o||"",transactionId:A.id,designProductVariantId:A.externalDesignProductVariantId,designProductId:A.externalDesignProductId,externalCartProductId:A.externalCartProductId,externalCartProductVariantId:A.externalCartProductVariantId,baseCost:e,weight:t.weight,optionsCost:n,exportedData:a,workflowViewerLink:A.workflowViewerLink||"",workflowViewerReadOnlyLink:A.workflowViewerReadOnlyLink||"",transactionOwnerId:c};return i&&(g.metadata=i),r&&(g.selectedVariants=r),s&&(g.sku=s),g},Hi=async(A,t,e,n,i,a,o)=>{const r=A.product?.basePrice||0,s=A.priceModifierTotal||0,c=((A,t,e,n)=>{const i={};let a;if(e){a=Ni(e,t,!1);for(const A of Object.keys(a))i[A]={value:a[A],priceModifier:0}}else if(n){a=n;for(const A of Object.keys(a))i[A]={value:a[A],priceModifier:0}}for(const e of Object.keys(A)){const n=A[e],a=t.steps.find((A=>A.stepTitle===e));if(1===n.length)i[`${a?.stepTitle} selection`]={value:n[0].name,priceModifier:n[0].priceModifier};else if(n.length>1)for(let A=0;A<n.length;A++)i[`${a?.stepTitle} selection ${A+1}`]={value:n[A].name,priceModifier:n[A].priceModifier}}return i})(n,e,void 0,a);return Ri(A,t,r,s,a,c,o,n,i)},Ui=async(A,t,e,n,i,a,o,r,s,c,g,B,l)=>{s("workflow.steps.finish.finalize.buildingLayouts"),await A.outstandingRequestsPromise();const w=ht.getShadowGraphqlClient();await w.resetStore();const E=await w.query({query:xn,variables:{id:a.id},errorPolicy:"all"}),d=E.data?.transactions[0].workflowState;!E.errors&&d||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(n())),E.errors&&E.errors.forEach((A=>{E.errors&&console.log("Server Error:",A.message)})),await A.updateStateWithServerImmediate(n),console.log("Server state is undefined @ Workflow completion"));const h=A.getPreviewService(),Q=t?.finalizeStepConfig?.lookAtAnimation,C=h&&100===h.getSceneInitializationProgress()&&t.showModelOnFinishStep&&!!Q,u=l&&Ni(l,t,!0),D=l&&Ni(l,t,!1),m=async A=>{const e={};let n=0;if(Object.keys(o).length>0)for(const i of Object.keys(o)){const a=o[i],r=t.steps.find((A=>A.stepName===i));for(let t=0;t<a.selections.length;++t){const i=a.selections[t];if(r&&(!A||r.option&&(r.option.variants||[]).length>1&&!r.data.hideSelectionInCart&&!r.data.hideSelectionsInCart)){const A=r.stepTitle;e[A]?e[A].push({id:i.id||"",name:i.name,priceModifier:i.priceModifier}):e[A]=[{id:i.id||"",name:i.name,priceModifier:i.priceModifier}]}n+=i.priceModifier}}return[e,n]},[p]=await m(!0),I=Object.fromEntries(Object.keys(p).map((A=>[A,p[A].map((A=>A.id))]))),[f]=await m(!1),M=Object.fromEntries(Object.keys(f).map((A=>[A,f[A].map((A=>A.id))]))),y=await B(C);s("workflow.steps.finish.finalize.creatingDesign"),a.bulk&&await c(g);const F=await(async A=>(await ht.getShadowGraphqlClient().mutate({mutation:vi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:A.name,layouts:A.layouts,workflowId:A.workflowId,transactionId:A.transactionId,previewImage:A.previewImage,useThreeDimPreview:A.useThreeDimPreview,metadata:A.metadata,selectedVariants:A.selectedVariants}})).data?.designCreate)((()=>{const A={name:r,layouts:e.map((A=>({index:A.index,panelId:A.panelId}))),workflowId:t.id,transactionId:a.id,useThreeDimPreview:C,previewImage:y};if(D){const t=[];for(const[A,e]of Object.entries(D))t.push({key:A,value:e});A.metadata=t}if(I){const t=[];for(const[A,e]of Object.entries(M))t.push({key:A,ids:e});A.selectedVariants=t}return A})()),Y=F?.transaction?.previewImageLink;s("workflow.steps.finish.finalize.updatingTransaction");const x=(await ht.getShadowGraphqlClient().query({query:Yn,variables:{id:a.id}})).data.transactions[0];return a.bulk?((A,t,e)=>{const n=(A.product?.basePrice||0)*(A.variationsCount||0),i=A.priceModifierTotal||0,a={items:{value:A.variationsCount?`${A.variationsCount}`:"0",priceModifier:0}};return Ri(A,t,n,i,void 0,a,e)})(x,i,Y):await Hi(x,i,t,p,F?.sku,u,Y)};let Pi;var Gi;(Gi=Pi||(Pi={})).Local="Local",Gi.Remote="Remote";const ki=new class{constructor(){Si(this,"localPersistenceKey","designTransactions"),Si(this,"storageMethod",Pi.Local),Si(this,"designSavedListeners",[])}attachSaveListener(A){this.designSavedListeners.push(A)}detachSaveListener(A){this.designSavedListeners=this.designSavedListeners.filter((t=>t!==A))}async getSavedDesigns(){return await this.getDesigns()}async getSavedDesignByTransaction(A){return(await this.getSavedDesigns()).find((t=>t.transactionId===A))}async addDesign(A){const t=(await this.getSavedDesigns()).filter((t=>t.transactionId!==A.transactionId));t.unshift(A),await this.setDesigns(t),this.notifyDesignSaved(A)}async removeDesign(A){const t=await this.getSavedDesigns();await this.setDesigns(t.filter((t=>t.transactionId!==A)))}async setDesigns(A){if(this.storageMethod!==Pi.Local)throw new nt("Unexpected storage method requested");gt.set(this.localPersistenceKey,JSON.stringify(A))}async getDesigns(){if(this.storageMethod===Pi.Local){const A=gt.get(this.localPersistenceKey);return A?JSON.parse(A):[]}throw new nt("Unexpected storage method requested")}notifyDesignSaved(A){this.designSavedListeners.forEach((t=>t(A)))}};function Ji(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class bi{constructor(t,e){if(Ji(this,"client",void 0),Ji(this,"commandContext",void 0),Ji(this,"workflowManager",void 0),Ji(this,"isReadOnly",void 0),Ji(this,"renderableScenes",[]),Ji(this,"renderableSceneCallbacks",[]),Ji(this,"debouncedSavedDesignUpdate",VA((async()=>{await ki.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()}),2500)),Ji(this,"getCanvasObjectURLAsync",(async A=>new Promise(((t,e)=>{try{A.toBlob((A=>{if(A){const e=URL.createObjectURL(A);t(e)}}))}catch(A){e(A)}})))),!e.workflow)throw new Error("No Workflow ID provided.");this.client=t;const n=e.layouts;this.commandContext=new A,this.commandContext.initialize(n,e.reloadedState),this.isReadOnly=!!e.transaction.lineItem?.id||!gt.getMap("transactionOwnerIds")?.get(e.transaction.id)||!!e.readOnly,this.workflowManager=new wi(e.workflow,e.product.profanities?.map((A=>A.word))||[],n,this.commandContext,(A=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return e.stateMutationFunc(A)}),e.transaction,e.product,e.previewService,e.renderableContextService,e.reloadedState,e.readOnly),this.workflowManager.addSelectionCallback((A=>{const t=A.traversableScenes.map((A=>{const t=A.renderableSteps.map((A=>A.stepName));return{id:A.name,title:A.title,renderableSteps:t}}));this.renderableScenes=t,this.renderableSceneCallbacks.forEach((A=>A(t)))}))}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async updateVariationRecords(A){await ht.getShadowGraphqlClient().mutate({mutation:Fn,variables:{transactionId:this.workflowManager.getTransaction().id,updates:A.map((A=>({recordNumber:A.recordNumber,values:A.values.map((A=>({aspect:A.aspect,stepName:A.stepName,value:A.value})))})))}})}async createPreviewImage(A,t){const e=this.workflowManager.getWorkflow(),n=e?.finalizeStepConfig?.lookAtAnimation;if(A){if(!n)throw new Error("Failed to generate cart preview image!");return await(this.workflowManager.getPreviewService()?.renderSceneScreenshot(512,n))||""}const i=document.createElement("canvas");let a=2048;t&&t<=2048&&(a=t),i.width=a,i.height=a;const o=this.commandContext.getAllLayouts(),r=e.defaultPreviewPanelIndex||0,s=e.panels[r],c=o.find((A=>A.layoutState?.layout.panelId===s?.name))||o[0],g=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},B=this.commandContext.getLayoutById(c.layoutState.layout.id),l=i.getContext("2d");if(!l)throw new ot("Failed to obtain 2D context for preview image creation");const w=R(B.layoutState.layout,B.layoutState.elements,{renderingConfiguration:{purpose:W.Print,region:{left:g.x,top:g.y,width:g.width,height:g.height}}}),E=zA.renderToStaticMarkup(w),d=await OA.from(l,E,{anonymousCrossOrigin:!0,ignoreDimensions:!1});await d.render();const h=await this.getCanvasObjectURLAsync(i);return i.toDataURL(h)}getStepById(A){const t=this.getWorkflowManager().getWorkflow().steps.find((t=>t.stepName===A));if(t&&this.stepHasHandle(t))return xi.get(this.getWorkflowManager(),t)}getSteps(){return this.getScenes().flatMap((A=>this.getStepsByScene(A)))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map((A=>({id:A.id,name:A.name,stepIds:A.stepNames})))}getBulkStep(){if(this.getWorkflowManager().getTransaction().bulk){const A=this.getWorkflowManager().getProduct().bulkConfiguration,t={type:m.Bulk,stepName:"Bulk",stepTitle:A?.stepTitle??"workflow.steps.bulk.title",helpText:A?.helpText,data:{aspects:Sn(this.getWorkflowManager().getWorkflow())},conditions:[]};return xi.get(this.getWorkflowManager(),t)}}getStepByName(A){const t=this.getWorkflowManager().getWorkflow().steps.find((t=>t.stepTitle===A));if(t&&this.stepHasHandle(t))return xi.get(this.getWorkflowManager(),t)}getStepsByType(A){return this.getWorkflowManager().getWorkflow().steps.filter((t=>t.type===A)).map((A=>xi.get(this.getWorkflowManager(),A)))}getStepsByScene(A){if(!this.getWorkflowManager().getWorkflow().stepGroups.find((t=>t.name===A.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 A.stepIds.map((A=>this.getWorkflowManager().getWorkflow().steps.find((t=>t.stepName===A)))).filter((A=>this.stepHasHandle(A))).map((A=>xi.get(this.getWorkflowManager(),A)))}async attachCustomerDetails(A){return this.assignCustomerDetails({emailAddress:A.email})}async assignCustomerDetails(A){await ht.getShadowGraphqlClient().mutate({mutation:ui,variables:{id:this.getWorkflowManager().getTransaction().id,details:A,type:"Owner"}}),this.getWorkflowManager().setTransactionCustomer(A)}attachRenderableSceneListener(A){this.renderableSceneCallbacks.push(A),A(this.renderableScenes)}detachRenderableSceneListener(A){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter((t=>t!==A))}async save(A){if(!this.getCommandContext().getState())throw new nt("State undefined!");const t={title:await(async()=>{if(A)return A;const t=this.getWorkflowManager().getTransaction().id,e=(await ki.getSavedDesigns()).find((A=>A.transactionId===t))?.title;return e||"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 ki.addDesign(t),t}async copy(){const A=TA(this.getCommandContext().getState());if(!A)throw new nt("Internal state is undefined! Cannot copy experience!");const t=JSON.stringify(A.transaction),e=this.getWorkflowManager().getWorkflow(),n=new ji({}),i=this.getWorkflowManager().getTransaction().integrationProduct?.id;if(!i)throw new nt("Integration product id is undefined!");await n.initFromIntegrationProduct(i);return await n.getWorkflowExperience(e.id,t,void 0)}async onDesignFinished(A){return Ui(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),(()=>this.commandContext.getState()),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,A||(()=>{}),(A=>this.updateVariationRecords(A)),this.workflowManager.getVariationRecords(),(A=>this.createPreviewImage(A)),this.workflowManager.getWorkflowMetadata())}stepHasHandle(A){return A.type!==m.SilentIllustration&&A.type!==m.ProductOverlay}getExportedData(){const A=new Map,t=this.getWorkflowManager().getWorkflowMetadata(),e=this.getWorkflowManager().getWorkflowSelections();return Object.keys(t).forEach((e=>{const n=this.workflowManager.getWorkflow().steps.find((A=>A.stepName===e));if(!n)return;A.has(n.stepTitle)||A.set(n.stepTitle,{});const i=t[e];Object.keys(i).forEach((t=>{A.get(n.stepTitle)[t]=i[t]}))})),Object.keys(e)?.forEach((t=>{const n=this.workflowManager.getWorkflow().steps.find((A=>A.stepName===t));n&&(A.has(n.stepTitle)||A.set(n.stepTitle,{}),A.get(n.stepTitle).selection=e[t].selections[0].name)})),A}}function Li(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ti=pA`
467
467
  ${Ct}
468
468
  ${Dt}
469
469
  ${Yt}
package/dist/types.d.ts CHANGED
@@ -595,6 +595,7 @@ export interface DesignCreationMessage {
595
595
  sku?: string;
596
596
  workflowViewerLink: string;
597
597
  workflowViewerReadOnlyLink: string;
598
+ transactionOwnerId?: string;
598
599
  }
599
600
  /**
600
601
  * Represents a transaction.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",
@@ -86,7 +86,7 @@
86
86
  },
87
87
  "dependencies": {
88
88
  "@apollo/client": "^3.7.0",
89
- "@spiffcommerce/papyrus": "1.5.72",
89
+ "@spiffcommerce/papyrus": "1.5.73",
90
90
  "canvg": "https://github.com/spiffdev/canvg.git#03bcd151b12441e88ecb552bb658356f5bbe92c4",
91
91
  "cross-fetch": "^3.1.5",
92
92
  "graphql": "^16.6.0",