@spiffcommerce/core 0.10.103 → 0.10.104

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 A=require("lodash.clonedeep"),t=require("react/jsx-runtime"),e=require("react-dom/server"),n=require("opentype.js"),i=require("axios"),a=require("https"),s=require("file-type"),o=require("buffer"),r=require("util"),c=require("css"),g=require("canvas"),B=require("exif"),l=require("swagger-client"),w=require("@apollo/client"),h=require("@apollo/client/link/context"),E=require("@apollo/client/link/error"),d=require("cross-fetch"),Q=require("react"),C=require("lodash.isequal"),u=require("canvg"),D=require("lodash.debounce"),I=require("qrcode"),p=require("svg-path-bbox");function m(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function M(A){return A&&A.__esModule?A.default:A}function y(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}m(module.exports,"SpiffCommerceClient",(()=>ya)),m(module.exports,"CommandContext",(()=>Ct)),m(module.exports,"spiffCoreConfiguration",(()=>Ge)),m(module.exports,"PromiseQueue",(()=>ni)),m(module.exports,"QueueablePromise",(()=>ei)),m(module.exports,"MockWorkflowManager",(()=>Ya)),m(module.exports,"InformationMessageType",(()=>Ti)),m(module.exports,"StepHandle",(()=>Xi)),m(module.exports,"TextStepHandle",(()=>ea)),m(module.exports,"FrameStepHandle",(()=>Sa)),m(module.exports,"IllustrationStepHandle",(()=>qi)),m(module.exports,"ModelStepHandle",(()=>$i)),m(module.exports,"PictureStepHandle",(()=>_i)),m(module.exports,"OptionNotFoundError",(()=>pe)),m(module.exports,"LayoutNotFoundError",(()=>me)),m(module.exports,"AssetNotFoundError",(()=>fe)),m(module.exports,"ResourceNotFoundError",(()=>Me)),m(module.exports,"MisconfigurationError",(()=>ye)),m(module.exports,"ParseError",(()=>xe)),m(module.exports,"UnhandledBehaviorError",(()=>Ye)),m(module.exports,"assetService",(()=>je)),m(module.exports,"createDesign",(()=>zn)),m(module.exports,"optionService",(()=>Ve)),m(module.exports,"server",(()=>Oe)),m(module.exports,"persistenceService",(()=>ve)),m(module.exports,"graphQlManager",(()=>ze)),m(module.exports,"toast",(()=>pi)),m(module.exports,"FrameService",(()=>oi)),m(module.exports,"frameStepService",(()=>hi)),m(module.exports,"modelStepService",(()=>di)),m(module.exports,"materialStepService",(()=>Ei)),m(module.exports,"shapeStepService",(()=>Di)),m(module.exports,"questionStepService",(()=>ui)),m(module.exports,"digitalContentStepService",(()=>wi)),m(module.exports,"moduleStepService",(()=>Qi)),m(module.exports,"pictureStepService",(()=>Ci)),m(module.exports,"textStepService",(()=>yi)),m(module.exports,"illustrationStepService",(()=>Vn)),m(module.exports,"svgObjectURL",(()=>Kn)),m(module.exports,"ProductCameraRig",(()=>an)),m(module.exports,"FrameStep",(()=>xa)),m(module.exports,"AssetType",(()=>j)),m(module.exports,"BringForwardCommand",(()=>Vt)),m(module.exports,"CanvasCommand",(()=>Ft)),m(module.exports,"CreateElementCommand",(()=>Ut)),m(module.exports,"CreateLayoutCommand",(()=>Rt)),m(module.exports,"DeleteElementCommand",(()=>Gt)),m(module.exports,"FontAlignmentCommand",(()=>zt)),m(module.exports,"FontColorCommand",(()=>kt)),m(module.exports,"FontSizeCommand",(()=>Jt)),m(module.exports,"FontSourceCommand",(()=>Ot)),m(module.exports,"GroupCommand",(()=>Ht)),m(module.exports,"LayoutElementFactory",(()=>Ce)),m(module.exports,"LayoutElementType",(()=>U)),m(module.exports,"MoveCommand",(()=>xt)),m(module.exports,"ResizeCommand",(()=>St)),m(module.exports,"RotateCommand",(()=>Nt)),m(module.exports,"SendBackwardsCommand",(()=>Wt)),m(module.exports,"StepAspectType",(()=>X)),m(module.exports,"StepType",(()=>V)),m(module.exports,"TextChangeCommand",(()=>Tt)),m(module.exports,"UnitOfMeasurement",(()=>J)),m(module.exports,"dataUrlFromExternalUrl",(()=>vA)),m(module.exports,"findElement",(()=>mt)),m(module.exports,"frameDataCache",(()=>ie)),m(module.exports,"generate",(()=>x)),m(module.exports,"generateSVGWithUnknownColors",(()=>dt)),m(module.exports,"getAttributesFromArrayBuffer",(()=>te)),m(module.exports,"rehydrateSerializedLayout",(()=>yt)),m(module.exports,"getFrameData",(()=>re)),m(module.exports,"getSvgString",(()=>Dt)),m(module.exports,"loadFontFromDataUrl",(()=>TA)),m(module.exports,"loadFontFromExternalUrl",(()=>LA)),m(module.exports,"determineCorrectFontSizeAndLines",(()=>Ee)),m(module.exports,"patternImageDataCache",(()=>ne)),m(module.exports,"generateCommands",(()=>da)),m(module.exports,"registerJSDOM",(()=>pA)),m(module.exports,"minZoom",(()=>Qn)),m(module.exports,"AdvancedEditor",(()=>xn)),m(module.exports,"EditorCore",(()=>Yn)),m(module.exports,"useLayouts",(()=>Xe)),m(module.exports,"useEditorState",(()=>nn)),m(module.exports,"useEditorInteraction",(()=>un)),m(module.exports,"useShortcutCombination",(()=>Dn)),m(module.exports,"commandReducer",(()=>_e)),m(module.exports,"getDefaultState",(()=>$e)),m(module.exports,"CommandContextContext",(()=>We)),m(module.exports,"AdvancedEditorStateProvider",(()=>tn)),m(module.exports,"AdvancedEditorContext",(()=>An)),m(module.exports,"UICommand",(()=>en)),m(module.exports,"EditorSubMenu",(()=>qe)),m(module.exports,"ElementEventType",(()=>rn)),m(module.exports,"KeyEvent",(()=>gn)),m(module.exports,"gatherVaryingStepAspects",(()=>Wn));var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==f?f:{},Y={};y(Y,"CanvasCommand",(()=>Ft)),y(Y,"UpdateWorkflowStateCommand",(()=>Yt)),y(Y,"MoveCommand",(()=>xt)),y(Y,"RotateCommand",(()=>Nt)),y(Y,"ResizeCommand",(()=>St)),y(Y,"GroupCommand",(()=>Ht)),y(Y,"CreateLayoutCommand",(()=>Rt)),y(Y,"ClearLayoutCommand",(()=>vt)),y(Y,"CreateElementCommand",(()=>Ut)),y(Y,"DeleteElementCommand",(()=>Gt)),y(Y,"CloneElementCommand",(()=>Pt)),y(Y,"FontColorCommand",(()=>kt)),y(Y,"FontSizeCommand",(()=>Jt)),y(Y,"FontAlgorithmCommand",(()=>bt)),y(Y,"FontSourceCommand",(()=>Ot)),y(Y,"FontAlignmentCommand",(()=>zt)),y(Y,"UpdateFramePattern",(()=>Lt)),y(Y,"TextChangeCommand",(()=>Tt)),y(Y,"IllustrationColorCommand",(()=>jt)),y(Y,"IllustrationCacheCommand",(()=>Kt)),y(Y,"BringForwardCommand",(()=>Vt)),y(Y,"SendBackwardsCommand",(()=>Wt)),y(Y,"LayerCommand",(()=>Xt)),y({},"generate",(()=>x));const x=()=>{const A=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()};var N={};y(N,"ElementNotFoundError",(()=>pt)),y(N,"findElement",(()=>mt)),y(N,"findLayoutForElement",(()=>ft)),y(N,"updatedLayoutForElement",(()=>Mt)),y(N,"rehydrateSerializedLayout",(()=>yt));var S={};y(S,"CommandContext",(()=>Ct)),y(S,"sortElementsByLayersWithIndex",(()=>It)),y(S,"getSvgString",(()=>Dt)),y({},"SVGLayout",(()=>H));const H=({viewmask:A,viewBox:e,width:n,height:i,position:a,maxWidth:s,maxHeight:o,elements:r,preserveAspectRatio:c,backgroundColor:g,omitBoundClipping:B,borderRadius:l,colorProfiles:w})=>{const h=x(),E=A?`url(#viewmask-${h})`:void 0,d=e||{x:0,y:0,width:n,height:i},Q=`${d.x} ${d.y} ${d.width} ${d.height}`,C=l||0,u=B?void 0:(0,t.jsxs)("defs",{children:[(0,t.jsx)("clipPath",{id:"viewboxClip",children:(0,t.jsx)("rect",{width:d.width,height:d.height,rx:C})}),A&&(0,t.jsxs)("mask",{id:`viewmask-${h}`,children:[(0,t.jsx)("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"black"}),(0,t.jsx)("rect",{x:A.x,y:A.y,width:A.width,height:A.height,fill:"white"})]})]}),D=w?.map(((A,e)=>(0,t.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},e)));return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:c,width:n,height:i,style:{gridColumn:1,gridRow:1,maxWidth:s,maxHeight:o,position:a},viewBox:Q,children:[D,u,!!g&&(0,t.jsx)("rect",{id:"layout-background",width:d.width,height:d.height,fill:g,mask:E,rx:C}),(0,t.jsx)("g",{id:"element-group",clipPath:B?void 0:"url(#viewboxClip)",mask:E,children:r})]})};y({},"Image",(()=>hA));var R={};y(R,"getAxisAlignedBoundingBox",(()=>Z)),y(R,"degreesToRadians",(()=>_)),y(R,"findAngle",(()=>$)),y(R,"radiansToDegrees",(()=>AA)),y(R,"isCloseToValue",(()=>tA)),y(R,"getTrueCoordinates",(()=>eA)),y(R,"getPointOfRotation",(()=>nA)),y(R,"getNWPoint",(()=>iA)),y(R,"getNEPoint",(()=>aA)),y(R,"getSWPoint",(()=>sA)),y(R,"getSEPoint",(()=>oA)),y(R,"turnRightClockwise",(()=>rA)),y(R,"currentDirection",(()=>cA)),y(R,"getElementVertices",(()=>gA)),y(R,"rotateAroundPoint",(()=>BA)),y(R,"mmPerPixel",(()=>lA)),y(R,"cmPerPixel",(()=>wA));var v={};let U;var G;let P;var k;let J;var b;let O;var z;let L;var T;let j;var K;let V;var W;let X;var q;y(v,"LayoutElementType",(()=>U)),y(v,"TextAlgorithm",(()=>P)),y(v,"UnitOfMeasurement",(()=>J)),y(v,"ScaleAxis",(()=>O)),y(v,"MaterialEffectMode",(()=>L)),y(v,"AssetType",(()=>j)),y(v,"StepType",(()=>V)),y(v,"StepAspectType",(()=>X)),(G=U||(U={})).Frame="frame",G.Image="image",G.Illustration="illustration",G.Textbox="textbox",(k=P||(P={})).Autosize="Autosize",k.Traditional="Traditional",(b=J||(J={})).Pixel="px",b.Millimeter="mm",b.Centimeter="cm",(z=O||(O={}))[z.North=0]="North",z[z.Northeast=1]="Northeast",z[z.East=2]="East",z[z.Southeast=3]="Southeast",z[z.South=4]="South",z[z.Southwest=5]="Southwest",z[z.West=6]="West",z[z.Northwest=7]="Northwest",(T=L||(L={})).None="None",T.RemoveWhenSelected="RemoveWhenSelected",T.ApplyWhenSelected="ApplyWhenSelected",(K=j||(j={})).Font="Font",K.Frame="Frame",K.Illustration="Illustration",K.Image="Image",K.Model="Model",K.Material="Material",K.Color="Color",K.QuestionnaireCollateral="QuestionnaireCollateral",K.RequestCollateral="RequestCollateral",K.SignupCollateral="SignupCollateral",K.Video="Video",K.ColorProfile="ColorProfile",(W=V||(V={})).Bulk="Bulk",W.DigitalContent="DigitalContent",W.Finish="Finish",W.Frame="Frame",W.Illustration="Illustration",W.Introduction="Introduction",W.Material="Material",W.Model="Model",W.Module="Module",W.Picture="Picture",W.Photo="Photo",W.ProductOverlay="ProductOverlay",W.Question="Question",W.Shape="Shape",W.SilentIllustration="SilentIllustration",W.Text="Text",(q=X||(X={})).Color="Color",q.Colors="Colors",q.Selection="Selection",q.Selections="Selections",q.Text="Text",q.Upload="Upload";const Z=(A,t,e,n,i)=>{const a=_(i),s=e/2,o=n/2,r=A+s,c=t+o,g=Math.sin(a),B=Math.cos(a),l=-o,w=s*B-l*g,h=s*B-o*g,E=s*g+l*B,d=s*g+o*B,Q=Math.max(Math.abs(w),Math.abs(h)),C=Math.max(Math.abs(E),Math.abs(d));return{minX:r-Q,maxX:r+Q,minY:c-C,maxY:c+C}},$=(A,t,e)=>{const n=Math.sqrt(Math.pow(t.x-A.x,2)+Math.pow(t.y-A.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2));return Math.acos((i*i+n*n-a*a)/(2*i*n))*(180/Math.PI)},_=A=>A*(Math.PI/180),AA=A=>A*(180/Math.PI),tA=(A,t,e)=>Math.abs(A-t)<e,eA=(A,t,e)=>{const n=Math.sin(_(e)),i=Math.cos(_(e));return{x:(A.x-t.x)*i-(A.y-t.y)*n+t.x,y:(A.x-t.x)*n+(A.y-t.y)*i+t.y}},nA=(A,t)=>({x:(A.x+t.x)/2,y:(A.y+t.y)/2}),iA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+t?.y*n}),aA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+t?.y*n}),sA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+(t?.y+t?.height)*n}),oA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+(t?.y+t?.height)*n}),rA=A=>{switch(A){case O.North:return O.East;case O.East:return O.South;case O.South:return O.West;case O.West:return O.North;case O.Northwest:return O.Northeast;case O.Northeast:return O.Southeast;case O.Southeast:return O.Southwest;case O.Southwest:return O.Northwest}},cA=(A,t)=>t>45&&t<=135?rA(A):t>135&&t<=225?rA(rA(A)):t>225&&t<=315?rA(rA(rA(A))):A,gA=(A,t={x:0,y:0},e={x:1,y:1})=>{const n=_(A.rotation),i={x:t.x+A.x*e.x,y:t.x+A.y*e.y},a={x:A.x+A.width,y:A.y},s={x:t.x+(A.x+A.width)*e.x,y:t.y+(A.height+A.y)*e.y},o={x:t.x+A.x*e.x,y:t.y+(A.height+A.y)*e.y},r={x:(o.x+s.x)/2,y:o.y-A.height*e.y/2};return{a:BA(i,r,n),b:BA(a,r,n),c:BA(s,r,n),d:BA(o,r,n),center:r}},BA=(A,t,e)=>{const n=Math.sin(e),i=Math.cos(e);return{x:(A.x-t.x)*i-(A.y-t.y)*n+t.x,y:(A.x-t.x)*n+(A.y-t.y)*i+t.y}},lA=.352778,wA=.035277,hA=A=>{const e=A.rotation||0,n=_(e),i=Math.cos(n),a=-Math.sin(n);return(0,t.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `,children:(0,t.jsx)("image",{xlinkHref:A.src,preserveAspectRatio:A.preserveAspectRatio,width:A.width,height:A.height})})};y({},"Frame",(()=>EA));const EA=A=>{const e=`spiff-frame-${A.id}`,n=`spiff-frame-blur-${A.id}`,i=`spiff-frame-blur-edge-${A.id}`,a=`spiff-frame-focal-mask-${A.id}`,s=!!A.focalBlur&&!!A.pattern,o=A.rotation||0,r=_(o),c=Math.cos(r),g=-Math.sin(r);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("defs",{children:(s=>{const o=A.pattern?.x||0,r=A.pattern?.y||0,c=A.pattern?A.pattern.width*A.pattern.scaleX+Math.abs(o):256,g=A.pattern?A.pattern.height*A.pattern.scaleY+Math.abs(r):256,B=A.pattern?A.pattern.width*A.pattern.scaleX:256,l=A.pattern?A.pattern.height*A.pattern.scaleY:256;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("pattern",{patternUnits:A.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:A.pattern?1:c,height:A.pattern?1:g,"data-frame-width":A.pattern?c:void 0,"data-frame-height":A.pattern?g:void 0,id:e,children:(0,t.jsx)("image",{preserveAspectRatio:"none",x:o,y:r,width:B,height:l,xlinkHref:A.disablePlaceholder?"":A.pattern?A.pattern.src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsSAAALEgHS3X78AAAZL0lEQVR4nO2diVIbSRZFq/GCsZBZjRea6fn/r+oZGrMYBBhkLGwzE1cmTSqVWXuqVFXnRHREG6OlpX43X771j5O/7/+XAEAvWeFrB+gvCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAECPQQAAGuLnz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R3kAQDpLLQU2FfsIxHIs7ADEQCon4X3AlTZ2pN3kAcA5GPhApBV7FNWBJjPD1Cc3AJQ59z7OkQgNMgDEQDITy4BMCOx65zWkyYCagXOIjTIAxEAyE+mANgjsese2RUSga/fvuYK7IUGeeTpOwCADAEwRm/GY5UZ2ZVFqNhHgT0tDMkiNMiDjj6AbFIFQEU4WsNtE0MEQsU+WhiSJ/bAIA+AcuTqBrR7+w0xmnHktmuAiE3a+m/f4zn5AfKTKwhYx/DOPMh4tRzERi3FeTMQGD9AMXKnASUCmo1vk3d4ZxGGw4254R7jr7d8rQARKFQItLuzVzp3nxcFBV1vg4g+QBwKCUDVAp68DJ3hnpPJhK8fIAKFS4EXIQJ6DfsaUGecAQCeKNULsAgRYMgnQHxKNwPFFgH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),s?(0,t.jsx)(dA,{path:A.path,width:A.width,height:A.height,focalBlurStrength:A.focalBlurStrength||1,focalBlurRadius:A.focalBlurRadius||10,blurFilterId:n,focalMaskId:a,blurEdgeClipId:i}):null]})})(s)}),(0,t.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${c}, ${-g}, ${g}, ${c}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n matrix(${A.scaleX}, 0, 0, ${A.scaleY}, 0, 0)\n `,children:[(0,t.jsx)("path",{filter:s?`url(#${n})`:void 0,mask:s?`url(#${i})`:void 0,d:A.path,style:{fill:`url(#${e})`,opacity:A.opacity}}),s?(0,t.jsx)("path",{mask:`url(#${a})`,d:A.path,style:{fill:`url(#${e})`,opacity:A.opacity}}):void 0]})]})},dA=A=>{const{path:e,width:n,height:i,focalBlurStrength:a,focalBlurRadius:s,blurFilterId:o,focalMaskId:r,blurEdgeClipId:c}=A;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("filter",{id:o,children:(0,t.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,t.jsx)("mask",{id:r,children:(0,t.jsx)("circle",{cx:n/2,cy:i/2,r:s||0,fill:"white",filter:`url(#${o})`})}),(0,t.jsx)("mask",{id:c,children:(0,t.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};y({},"Textbox",(()=>rt));var QA={};y(QA,"fontSizeStep",(()=>XA)),y(QA,"textWidth",(()=>qA)),y(QA,"applyTextTransformations",(()=>$A)),y(QA,"zip",(()=>_A)),y(QA,"getTextAlignment",(()=>At)),y(QA,"getAnchor",(()=>tt)),y(QA,"recomputeTextOnElement",(()=>et)),y(QA,"defaultLineHeightFactor",(()=>nt)),y({},"calculateTextboxLines",(()=>WA));var CA={};y(CA,"FontMetrics",(()=>OA)),y(CA,"loadFontFromExternalUrl",(()=>LA)),y(CA,"loadFontFromDataUrl",(()=>TA)),y(CA,"getFontMetrics",(()=>jA));var uA={};y(uA,"registerJSDOM",(()=>pA)),y(uA,"createElement",(()=>yA)),y(uA,"createElementNS",(()=>FA)),y(uA,"domParser",(()=>YA)),y(uA,"fetchAsArrayBuffer",(()=>xA)),y(uA,"fetchAsString",(()=>NA)),y(uA,"loadFontFaceSet",(()=>SA)),y(uA,"xmlSerializer",(()=>HA)),y(uA,"toBase64",(()=>RA)),y(uA,"dataUrlFromExternalUrl",(()=>vA)),y(uA,"arrayBufferToDataUrl",(()=>UA)),y(uA,"arrayBufferToBuffer",(()=>PA)),y(uA,"dataUrlToArrayBuffer",(()=>GA));var DA=o.Buffer;let IA;function pA(A){IA=A}function mA(){if(!IA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new IA}if(void 0===F.TextEncoder){const{TextEncoder:A}=r;F.TextEncoder=A}if(void 0===F.TextDecoder){const{TextDecoder:A}=r;F.TextDecoder=A}const fA=new(M(a).Agent)({rejectUnauthorized:!0}),MA=A=>A.every((A=>"undefined"!==A)),yA=A=>MA([typeof document])?document.createElement(A):mA().window.document.createElement(A),FA=(A,t)=>{if(MA([typeof document]))return document.createElementNS(A,t);const e=mA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},YA=()=>MA([typeof DOMParser])?new DOMParser:new(mA().window.DOMParser),xA=A=>{if(MA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.arrayBuffer())})).catch((A=>{e(A)}))}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(i).get(t,{responseType:"arraybuffer",httpsAgent:fA}).then((t=>{A(t.data)})).catch((A=>{e(A)}))}))}},NA=A=>{if(MA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.text())})).catch(e)}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(i).get(t,{responseType:"text",httpsAgent:fA}).then((t=>{A(t.data)})).catch(e)}))}},SA=async(A,t)=>{if(MA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},HA=()=>MA([typeof XMLSerializer])?new XMLSerializer:new(mA().window.XMLSerializer),RA=A=>MA([typeof btoa])?btoa(A):DA.from(A).toString("base64"),vA=async A=>{if(MA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await JA(e)}const t=(await M(i).get(A,{responseType:"arraybuffer"})).data;return UA(t)},UA=async A=>{const t=await(async A=>{const t=await(0,s.fromBuffer)(A);return t?t.mime:"image/svg+xml"})(A);return`data:${t};base64,${PA(A).toString("base64")}`},GA=A=>{const t=A.replace(/\r?\n/g,""),e=t.indexOf(",");if(-1===e||e<=4)throw new TypeError("malformed data: URI");const n=t.substring(5,e).split(";");let i=!1;for(let A=1;A<n.length;A++)"base64"===n[A]&&(i=!0);const a=i?"base64":"ascii",s=unescape(t.substring(e+1)),o=DA.from(s,a);return kA(o)},PA=A=>DA.from(A),kA=A=>{const t=new ArrayBuffer(A.byteLength),e=new Uint8Array(t);for(let t=0;t<A.length;++t)e[t]=A[t];return t},JA=A=>new Promise(((t,e)=>{const n=new FileReader;n.onload=function(A){const n=A.target;n&&n.result?t(n.result.toString()):e()},n.readAsDataURL(A)})),bA=new Map;class OA{constructor(A){this.font=A,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(A){const t=this.glyphsFromText.get(A);if(t)return t;const e=this.font.stringToGlyphs(A);return this.glyphsFromText.set(A,e),e}getApproximateHeight(){return this.height}getExactHeight(A){const t=this.font.stringToGlyphs(A);let e=0,n=0;return t.forEach((A=>{const t=A.getMetrics();e=Math.max(e,t.yMax),n=Math.min(n,t.yMin)})),e-n}getKerningValue(A,t){let e=this.kerningValues.get(A.name);e||(e=new Map,this.kerningValues.set(A.name,e));let n=e.get(t.name);return n||(n=this.font.getKerningValue(A,t),e.set(t.name,n)),n}calculateApproximateHeight(){const A=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let t=0,e=0;return A.forEach((A=>{const n=A.getMetrics();t=Math.max(t,n.yMax),e=Math.min(e,n.yMin)})),t-e}}const zA=A=>"data:"===A.substring(0,5).toLowerCase().trim(),LA=async A=>{const t=zA(A)?TA(A):TA(await vA(A));return KA(t,{assetUrl:zA(A)?A:await vA(A),name:t.names.fullName.en}),await SA(t,A),t},TA=A=>{const t=GA(A),e=M(n).parse(t);return KA(e,{assetUrl:A,name:e.names.fullName.en}),e},jA=A=>{const t=bA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},KA=(A,t)=>{const e=new OA(A);return bA.set(t.name,e),e},VA=(A,t,e,n)=>{if(qA(A,e,n)<=t)return[A];if(!(A.indexOf(" ")>-1)){if(A.length<=1)throw new Error(`Character ${A} is wider than region`);const t=Math.floor(A.length/2);return[A.slice(0,t),A.slice(t)]}const i=A.split(" "),a=[];let s=0;for(;s<i.length;){const A=i[s];if(qA(A,e,n)>t)a.push(...VA(A,t,e,n)),s++;else{const o=[A];let r=s+1,c=!0;for(;r<i.length&&c;){const A=i[r];qA(`${o.join(" ")} ${A}`,e,n)<=t?(o.push(A),r++):c=!1}a.push(o.join(" ")),s=r}}return a},WA=(A,t,e,n,i)=>{const a=jA(t),s=a.getFont();return((A,t,e,n,i,a)=>{const s=a||nt,o=t.split("\n");try{const t=o.flatMap((t=>VA(t,A.width,n,i)));return{lines:t,requiredHeight:t.length*(e*s)}}catch(A){return console.error(A),{lines:[],requiredHeight:0}}})(e,$A(n),A,A/s.unitsPerEm,a,i)},XA=1,qA=(A,t,e)=>{let n=0;const i=e.getGlyphs(A);return i.forEach(((A,t)=>{if(A.advanceWidth&&(n+=A.advanceWidth),t<i.length-1){const a=e.getKerningValue(A,i[t+1]);n+=a}})),n*=t,n},ZA={stripControlCharacters:!0,vertical:!1,uppercase:!1},$A=(A,t=ZA)=>{const e={...ZA,...t};let n=A;return e.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),e.uppercase&&(n=n.toUpperCase()),e.vertical&&(n=n.split("").join("\n")),n},_A=(A,t)=>A.map(((A,e)=>[A,t[e]])),At=(A="center",t=!1)=>t?"center":A,tt=A=>"left"===A?"start":"right"===A?"end":"middle",et=(A,t)=>A.fontData?{...A,...(()=>{if(A.algorithm===P.Traditional){const e=WA(A.fontSize,A.fontData,A,t,A.lineHeight);return{text:e.lines.join("\n"),height:e.requiredHeight,input:t}}return{text:t}})()}:A,nt=1.1;var it={};y(it,"colorDefinitionPrintValue",(()=>at)),y(it,"spotColorDefinitionString",(()=>st)),y(it,"svgColorValueToDefinition",(()=>ot));const at=A=>{const t=st(A.spotColor);return t?`${A.browserValue} ${t}`:A.browserValue},st=A=>{if(!A)return"";if(A.profileName.includes("/")&&A.profileName.includes(".icc")){const t=A.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${A.namedColor})`}return`icc-named-color(${A.profileName}, ${A.namedColor})`},ot=A=>{const t=A.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===t.length)return{browserValue:"#000000"};if(1===t.length)return{browserValue:t[0]};const e=t[1].match(/\(([^)]+)\)/gm);if(!e)throw new Error("Unhandled state of color value in SVG");const n=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:n[0],namedColor:n[1]}}},rt=A=>{const e=(A.rotation||0)*Math.PI/180,n=Math.cos(e),i=-Math.sin(e),a=`text-path-${A.id}`,s=A.x+(A.curved?0:A.width/2),o=A.y+(A.curved?0:A.height/2),r=(A.text||"").split("\n");return A.curved&&!A.paths?null:A.fontData?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("defs",{children:[(0,t.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${A.fontData.name}';\n src: url('${A.fontData.assetUrl}') format('truetype');\n }\n `}}),A.curved&&A.paths?(0,t.jsx)("path",{id:a,d:A.paths[0]}):void 0]}),A._renderingConfiguration?.debug?(0,t.jsx)("rect",{stroke:"blue",fill:"none",x:A.x,y:A.y,width:A.width,height:A.height}):void 0,(0,t.jsx)("g",{transform:`matrix(${n}, ${-i}, ${i}, ${n}, ${s}, ${o})`,children:(0,t.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${A.fontData.name}'`,fontSize:A.fontSize,fontStyle:"normal",fontWeight:"normal",fill:A._renderingConfiguration?.spotColors&&A.fillSpotColorDefinition?`${A.fill} ${st(A.fillSpotColorDefinition)}`:A.fill,style:{whiteSpace:"pre",userSelect:"none"},children:A.curved?(0,t.jsx)(gt,{text:A.text||"",curvedPathId:a,align:A.align}):r.map(((e,n)=>(0,t.jsx)(ct,{align:A.vertical?"center":A.align,fontSize:A.fontSize,thisLineIdx:n,amountLines:r.length,text:e,textboxHeight:A.height,textboxWidth:A.width,lineHeight:A.lineHeight,vertical:A.vertical,verticalAlign:A.verticalAlign},n)))})})]}):null},ct=A=>(0,t.jsx)("tspan",{textAnchor:tt(A.align),x:"left"===A.align?-A.textboxWidth/2:"right"===A.align?A.textboxWidth/2:0,y:`${(()=>{const t=A.fontSize*(void 0!==A.lineHeight?A.lineHeight:nt),e=A.textboxHeight/2;if("top"===A.verticalAlign)return-e+3*A.fontSize/4+A.thisLineIdx*t;if("bottom"===A.verticalAlign){const n=A.amountLines-1-A.thisLineIdx;return e-A.fontSize/4-n*t}const n=(A.amountLines-1)/2;return(A.thisLineIdx-n)*t+A.fontSize/4})()}px`,children:A.text}),gt=A=>{const e=`#${A.curvedPathId}`;return(0,t.jsx)("textPath",{startOffset:"left"===A.align?"0%":"right"===A.align?"100%":"50%",textAnchor:tt(A.align),href:e,xlinkHref:e,children:A.text})};y({},"Illustration",(()=>Qt));var Bt={};y(Bt,"traverse",(()=>wt)),y(Bt,"sanitizeSvgTree",(()=>ht)),y(Bt,"modifySVGWithElementProperties",(()=>Et)),y(Bt,"generateSVGWithUnknownColors",(()=>dt));const lt=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],wt=(A,t)=>{t(A),A.children.length>0&&Array.from(A.children).forEach((A=>wt(A,t)))},ht=(A,t=!1)=>{!t&&A.setAttribute("preserveAspectRatio","none");const e=[];wt(A,(A=>{if("script"!==A.tagName)if("style"!==A.tagName);else try{(0,c.parse)(A.innerHTML).stylesheet?.rules.forEach((A=>{e.push(A)})),A.remove()}catch(A){console.error(A)}else A.remove()})),wt(A,(A=>{e.forEach((t=>{t.selectors?.forEach((e=>{((A,t)=>{try{return A.matches(t)}catch(e){return A.classList.contains(t.substring(1))}})(A,e)&&t.declarations?.forEach((t=>{t.property&&t.value&&A.setAttribute(t.property,t.value)}))}))}))}))},Et=(A,t,e,n,i)=>{const a=(A=>YA().parseFromString(A,"image/svg+xml").firstElementChild)(A);if(!a)throw new Error("Failed to read SVG.");return((A,t,e)=>{A.setAttribute("height",`${e}px`),A.setAttribute("width",`${t}px`)})(a,t,e),((A,t,e)=>{wt(A,(A=>{const n=A.attributes.getNamedItem("fill");n&&"none"!==n.value&&A.classList.forEach((n=>{if(n.startsWith("spiff-fill")){const i=t[n];i&&A.setAttribute("fill",e?at(i):i.browserValue)}}));const i=A.attributes.getNamedItem("stroke");i&&"none"!==i.value&&A.classList.forEach((n=>{if(n.startsWith("spiff-stroke")){const i=t[n];i&&A.setAttribute("stroke",e?at(i):i.browserValue)}}))}))})(a,n,i),(A=>HA().serializeToString(A))(a)},dt=async A=>{const t=A.match(/<svg.*?<\/svg>/s)||[],e=t?.length>0?t[0]:"",n=YA().parseFromString(e,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");ht(n);const i={};wt(n,(A=>{lt.includes(A.tagName)&&!A.attributes.getNamedItem("fill")&&A.setAttribute("fill","black");const t=A.attributes.getNamedItem("fill");if(t&&"none"!==t.value){const e=ot(t.value),n=`spiff-fill-${e.browserValue.replace(/\W/g,"")}`;A.setAttribute("fill",e.browserValue),A.classList.add(n),i[n]=e}const e=A.attributes.getNamedItem("stroke");if(e&&"none"!==e.value){const t=ot(e.value),n=`spiff-stroke-${t.browserValue.replace(/\W/g,"")}`;A.classList.add(n),A.setAttribute("stroke",t.browserValue),i[n]=t}}));const a=HA().serializeToString(n);return{colors:i,svg:a}},Qt=A=>{if(A.cachedObjectURL&&!A._renderingConfiguration?.omitCachedFields)return(0,t.jsx)(hA,{id:A.id,src:A.cachedObjectURL,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,preserveAspectRatio:"none",immutable:A.immutable});const e=A.rotation||0,n=_(e),i=Math.cos(n),a=-Math.sin(n),s=`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `;if(!A.svg)throw new Error(`Illustration element ${A.id} (stepName ${A.stepName}) lacked svg from src ${A.src} at render time.`);return(0,t.jsx)("g",{transform:s,dangerouslySetInnerHTML:{__html:Et(A.svg,A.width,A.height,A.colors,A._renderingConfiguration?.spotColors)}})};class Ct{constructor(){this.id=x(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(A){A(),this.stateCallbacks.push(A)}unregisterStateCallback(A){this.stateCallbacks.filter((t=>t!==A))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((A=>A()))}apply(A,t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.nextCommands=[],t||this.prevCommands.push(A)}undo(){if(!this.state)return;const A=this.prevCommands.pop();if(!A)return;const t=A.undo();A.varying?this.state={...this.state,variation:t}:this.state={...this.state,transaction:t},this.nextCommands.push(A),this.runStateCallbacks()}redo(){if(!this.state)return;const A=this.nextCommands.pop();A&&(this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.prevCommands.push(A))}flattenSequence(A,t){const e=this.prevCommands.filter((t=>t.sequenceId===A)).pop();e&&(this.prevCommands=this.prevCommands.filter((t=>t.sequenceId!==A)),e?.overrideOldState(t),this.prevCommands.push(e))}getLayoutById(A){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=this.state.transaction?.layouts?.[A],e=this.state.variation?.layouts?.[A],n=t?.layout||e?.layout;if(!n)throw new Error(`No layout: ${A}`);const i=[...t?.elements||[],...e?.elements||[]];return this.getLayoutDataWithState(n,i)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const A=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(A)].map((A=>this.getLayoutById(A)))}getLayoutDataWithState(A,e){const n=It([...e]).map((A=>ut(A))),i={width:A.width,height:A.height,viewBox:{x:0,y:0,width:A.width,height:A.height}},a={backgroundColor:A.transparentBackground?void 0:"white",elements:n};return{layoutState:{layout:A,elements:e},Component:(0,t.jsx)(H,{...a,...i}),getComponentWithProps:A=>(0,t.jsx)(H,{...a,...i,...A})}}initialize(A,t){if(t)return void(this.state={transaction:t});let e={serializableWorkflow:{steps:[]},layouts:{}};A.forEach((A=>{e=new Rt(A).apply(e)})),this.runStateCallbacks(),this.state={transaction:e}}commandReducer(A,t){if(t.varying){const e={layouts:{},serializableWorkflow:{steps:[]},...A.variation};return{...A,variation:t.apply(e)}}{const e=A.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...A,transaction:t.apply(e)}}}}const ut=A=>"image"===A.type?(0,t.jsx)(hA,{...A},A.id):"frame"===A.type?(0,t.jsx)(EA,{...A},A.id):"illustration"===A.type?(0,t.jsx)(Qt,{...A},A.id):"textbox"===A.type?(0,t.jsx)(rt,{...A},A.id):null,Dt=(A,n,i)=>{const a={backgroundColor:A.transparentBackground?void 0:"white"},s={width:i?.region?i.region.width:A.width,height:i?.region?i.region.height:A.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:A.width,height:A.height}},o=It((i?.removeExcludedElements?n.filter((A=>!A.excludeFromExport)):n).map((A=>({...A,_renderingConfiguration:i}))));try{return M(e).renderToStaticMarkup((0,t.jsx)(H,{preserveAspectRatio:"none",...a,...s,elements:o.map((A=>ut(A))).filter((A=>!!A)),omitBoundClipping:i?.omitClipMask,colorProfiles:i?.colorProfiles?i.colorProfiles:void 0}))}catch(A){return console.error("Error rendering to static markup"),console.error(A),""}};function It(A){return A.sort(((A,t)=>{const e=A.layer||0,n=t.layer||0;if(e<n)return-1;if(e>n)return 1;const i=A.layerIndex||0,a=t.layerIndex||0;return i<a?-1:i>a?1:0}))}class pt extends Error{constructor(A){super("No element found with ID: "+A),Object.setPrototypeOf(this,pt.prototype)}}const mt=(A,t)=>ft(A,t).elements.find((t=>t.id===A)),ft=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new pt(A);return e},Mt=(A,t)=>{const e=It([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:x()}},yt=async(A,t)=>{const e=[...Object.keys(A.layouts),...Object.keys(t?.layouts||{})],n=[...new Set(e)];for(let e=0;e<n.length;e++){const i=n[e],a=A.layouts[i],s=t?.layouts[i],o=(a||s).elements.filter((A=>"illustration"===A.type));for(let A=0;A<o.length;++A){const t=o[A];if(t.src&&!t.svg){const A=await NA(t.src),e=await dt(A);t.svg=Et(e.svg,t.width,t.height,t.colors)}}}};class Ft{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(A){this.oldState=A}}class Yt extends Ft{constructor(A){super(),this.serializableWorkflow=A}apply(A){return this.oldState=A,{...A,serializableWorkflow:this.serializableWorkflow}}}class xt extends Ft{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,x:this.x,y:this.y},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Nt extends Ft{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,rotation:this.angle},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class St extends Ft{constructor(A,t,e){super(),this.id=A,this.width=Math.abs(t),this.height=Math.abs(e)}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,width:this.width,height:this.height};if("frame"===t.type){const A=e;A.scaleX=A.scaleX*this.width/t.width,A.scaleY=A.scaleY*this.height/t.height}const n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ht extends Ft{constructor(A){super(),this.commands=A}apply(A){return this.oldState=A,this.commands.reduce(((A,t)=>t.apply(A)),A)}}class Rt extends Ft{constructor(A){super(),this.layout=A}apply(A){return this.oldState=A,{...A,layouts:{...A.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:x()}}}}}class vt extends Ft{constructor(A){super(),this.panelName=A}apply(A){this.oldState=A;const t=Object.values(A.layouts).map((A=>{const t=A.layout.panelId===this.panelName;return{...A,elements:t?[]:[...A.elements],modificationID:x()}})),e={};return t.forEach((A=>{e[A.layout.id]=A})),{...A,layouts:e}}}class Ut extends Ft{constructor(A,t){super(),this.element=A,this.layout=t}apply(A){this.oldState=A,A.layouts[this.layout.id]||(A.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const t=A.layouts[this.layout.id].elements;if(t.find((A=>A.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===t.length){const e=[...t,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,e)),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:e,modificationID:x()}}}}const e=t[t.length-1],n=e.productOverlay?e:null;let i;if(n&&t.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)i=[...t,this.element].sort(((A,t)=>void 0!==A.layerIndex&&void 0!==t.layerIndex?A.layerIndex-t.layerIndex:0));else{const A=this.assignIndex(this.element,t);this.element.layerIndex=void 0!==A?A:0,i=[...t,this.element]}return n&&i.push(n),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:i,modificationID:x()}}}}assignIndex(A,t){if(0===t.length)return 0;const e=t.filter((t=>(t.layer||0)===(A.layer||0))).sort(((A,t)=>(A.layerIndex||0)-(t.layerIndex||0)))[t.length-1]?.layerIndex;return void 0!==e?e+1:0}}class Gt extends Ft{constructor(A){super(),this.id=A}apply(A){this.oldState=A;let t=!1;const e=Object.values(A.layouts).map((A=>(A.elements.filter((A=>A.id!==this.id)).length!==A.elements.length&&(t=!0),{...A,elements:A.elements.filter((A=>A.id!==this.id)),modificationID:x()})));t||console.log(`Failed to delete element ${this.id}`);const n={};return e.forEach((A=>{n[A.layout.id]=A})),{...A,layouts:n}}}class Pt extends Ft{constructor(t,e){super(),this.el=M(A)(t),this.layout=e,this.el.id=x(),this.el.x+=5,this.el.y+=5}apply(A){return this.oldState=A,new Ut(this.el,this.layout).apply(A)}}class kt extends Ft{constructor(A,t,e){super(),this.id=A,this.color=t,this.textFillSpotColor=e}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Jt extends Ft{constructor(A,t){super(),this.id=A,this.size=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,fontSize:this.size},n=ft(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==P.Autosize?e.input||"":e.text||"",a=Mt(et(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class bt extends Ft{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,algorithm:this.algorithm},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ot extends Ft{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,fontData:this.fontData},n=ft(t.id,Object.values(A.layouts)),i=Mt(et(e,e.input||""),n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class zt extends Ft{constructor(A,t){super(),this.id=A,this.align=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,align:this.align},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Lt extends Ft{constructor(A,t,e){super(),this.id=A,this.imageData=t,this.offsets=e}apply(A){this.oldState=A;const t=ft(this.id,Object.values(A.layouts)),e=t.elements.findIndex((A=>A.id===this.id)),n=t.elements[e].pattern,i=[...t.elements];i.splice(e,1,{...t.elements[e],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={...t,elements:i,modificationID:x()};return{...A,layouts:{...A.layouts,[t.layout.id]:a}}}}class Tt extends Ft{constructor(A,t){super(),this.id=A,this.text=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e=ft(t.id,Object.values(A.layouts)),n=Mt(et(t,this.text),e);return{...A,layouts:{...A.layouts,[e.layout.id]:n}}}}class jt extends Ft{constructor(A,t,e){super(),this.id=A,this.className=t,this.fill=e}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e=t.colors||{},n=e[this.className];e[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...t,colors:e},a=ft(t.id,Object.values(A.layouts)),s=Mt(i,a);return{...A,layouts:{...A.layouts,[a.layout.id]:s}}}}class Kt extends Ft{constructor(A,t,e){super(),this.id=A,this.svgBody=t,this.objectURL=e}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Vt extends Ft{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!mt(this.id,Object.values(A.layouts)).id)throw new pt(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e+1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:x()}}}}}class Wt extends Ft{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!mt(this.id,Object.values(A.layouts)).id)throw new pt(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e-1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:x()}}}}}class Xt extends Ft{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!e)throw new Error("Layout missing from state!");return{...A,layouts:{...A.layouts,[e.layout.id]:Mt({...t,layer:this.value},e)}}}}var qt={};y(qt,"patternImageDataCache",(()=>ne)),y(qt,"frameDataCache",(()=>ie)),y(qt,"generateFrameSVG",(()=>ae)),y(qt,"generateDefaultRectangleFrameSvg",(()=>se)),y(qt,"getVariant",(()=>oe)),y(qt,"getFrameData",(()=>re)),y(qt,"calculateOffsets",(()=>ce)),y(qt,"getPatternImageData",(()=>ge)),y(qt,"GetSVGDimensions",(()=>Be)),y(qt,"svgStringDimensions",(()=>le));var Zt={};y(Zt,"getExifOrientation",(()=>_t)),y(Zt,"canvasDims",(()=>Ae)),y(Zt,"getAttributesFromArrayBuffer",(()=>te));let $t=null;const _t=A=>new Promise((t=>{const e=PA(A);(0,s.fromBuffer)(A).then((A=>{const n=A?.mime;if("image/jpeg"!==n)return t(1);(new(0,B.ExifImage)).loadImage(e,((A,e)=>t(A?1:e.image.Orientation||1)))}))})),Ae=A=>{const t=8192,e=A.naturalWidth/A.naturalHeight;return A.naturalHeight<=t&&A.naturalWidth<=t?[A.naturalWidth,A.naturalHeight]:A.naturalHeight>A.naturalWidth?[e*t,t]:[t,t/e]},te=async A=>{const t=await(async A=>{const t=await UA(A),e=await(0,g.loadImage)(t),[n,i]=Ae(e),a=await(async()=>{if(null!==$t)return!$t;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return $t=2===A.width&&3===A.height,!$t})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const s=await _t(A),[o,r]=s>4?[i,n]:[n,i],c=(0,g.createCanvas)(o,r),B=c.getContext("2d");switch(s){case 2:B.translate(o,0),B.scale(-1,1);break;case 3:B.translate(o,r),B.rotate(Math.PI);break;case 4:B.translate(0,r),B.scale(1,-1);break;case 5:B.rotate(-.5*Math.PI),B.scale(-1,1);break;case 6:B.rotate(-.5*Math.PI),B.translate(-o,0);break;case 7:B.rotate(-.5*Math.PI),B.translate(-o,r),B.scale(1,-1);break;case 8:B.rotate(.5*Math.PI),B.translate(0,-r)}return B.drawImage(e,0,0,o,r),c})(A);return"image/jpeg"===(await(0,s.fromBuffer)(A))?.mime?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}};y({},"getDefaultVariant",(()=>ee));const ee=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},ne=new Map,ie=new Map,ae=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return se(A)}return NA(t)},se=A=>{const t=A.width,e=t/A.height,n=Math.max(t,512),i=n/e;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 `},oe=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||ee(t.data);if(!e)throw new Error(`No variant with ID: ${A.frameVariantId}`);if(!e.asset)throw new Error(`No asset for variant with ID: ${A.frameVariantId}`);return e},re=async A=>{const t=YA().parseFromString(A,"image/svg+xml"),e=t.querySelector("svg");if(!e)throw new Error("Malformed frame SVG: <svg> tag not found");const n=e.getAttribute("viewBox");if(!n)throw new Error("SVG missing viewBox.");const i=n.split(" "),a=parseFloat(i[3])||1,s=parseFloat(i[2])||1,o=t.getElementById("target-path"),r=t.getElementsByClassName("st0").item(0);if(o){const A=o.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:s,height:a};return ie.set(A,t),t}if(r){const A=r.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:s,height:a};return ie.set(A,t),t}throw new Error("Malformed frame SVG")},ce=(A,t,e)=>{const n=t.width>=t.height,i=A.width>=A.height,a=t.width/2,s=t.height/2,o=(n?t.height:t.width)/(i?A.height:A.width),r=e?.scale||o,c=a-A.width/2*r,g=e?.left||c,B=s-A.height/2*r;return{x:g,y:e?.top||B,zoom:r}},ge=async A=>{if(ne.has(A))return ne.get(A);if(A.endsWith("svg")){const t=await Be(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return ne.set(A,i),i}{const t=await xA(A),e=await te(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return ne.set(A,n),n}},Be=async A=>{const t=await fetch(A),e=await t.text();return le(e)},le=A=>{const t=(new DOMParser).parseFromString(A,"image/svg+xml").querySelector("svg");if(!t)throw new Error("No svg tag found, this svg must be malformed!");const e=t.getAttribute("viewBox"),n=t.getAttribute("width"),i=t.getAttribute("height"),a=e?e?.split(" ").map((A=>Number(A))):[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 we={};y(we,"determineCorrectFontSizeAndLines",(()=>Ee)),y(we,"determineCorrectTextboxRegion",(()=>de));const he=(A,t,e,n,i)=>{let a=t.map((A=>A.split("\n"))).flat(),s=a.length,o=a.map((A=>qA(A,n,i)));const r=i.getApproximateHeight()*n;let c=!0;for(;c;){if(r+(s-1)*e>A.height)return[null,null];const t=Math.max(...o);if(t<=A.width)return[a,t];const g=o.reduce(((A,t,e,n)=>t>n[A]?e:A),0),B=a[g];let l=!1,w=B.length;for(;!l&&w>-1;){w=B.lastIndexOf(" ",w-1);const t=[B.slice(0,w),B.slice(w+1)],e=t.map((A=>qA(A,n,i)));e[0]<=A.width&&(a=[...a.slice(0,g),...t,...a.slice(g+1)],o=[...o.slice(0,g),...e,...o.slice(g+1)],s+=1,l=!0)}l||(c=!1)}return[null,null]},Ee=(A,t,e,n,i)=>{let a,s;const o=jA(t),r=o.getFont();if(i.size){const t=A/r.unitsPerEm;return[a,s]=he(e,n,A,t,o),[i.size,a,s]}let c=6-XA;if(n.length>0){let A=n,t=0;for(;(!i.maxSize||c<=i.maxSize)&&A;)c+=XA,t=c/r.unitsPerEm,[A,s]=he(e,n,c,t,o)}c>6&&(c-=XA),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/r.unitsPerEm;return[a,s]=he(e,n,c,g,o),[c,a,s]},de=(A,t,e,n,i)=>{let a={...A},s={...A},[o,r,c]=Ee(e,t,s,n,{size:0,minSize:e,maxSize:e});var g,B;return c&&c<a.width&&(s.width=c,"left"===i?(s.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),s.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):s.left+="right"===i?a.width-c:(a.width-c)/2,[o,r]=Ee(e,t,s,n,{size:e}),o===e&&r&&(g=n,B=r,g.map(((A,t)=>[A,B[t]]))).every((([A,t])=>A===t))&&(a=s)),a};y({},"LayoutElementFactory",(()=>Ce));const Qe=(A,t)=>{const e=A.layoutState.elements.filter((A=>A.layer===t)),n=Math.max(...e.map((A=>A.layerIndex)).filter((A=>void 0!==A)));return Math.max(n,0)+1};class Ce{static async getFrame(A,t){const e=await ae(t.region,t.src),n=await re(e);return{id:x(),x:t.region.left,y:t.region.top,width:t.region.width,height:t.region.height,layer:t.region.layer||0,layerIndex:t.region.layerIndex||Qe(A,t.region.layer||0),rotation:t.region.rotation,scaleX:t.region.width/n.width,scaleY:t.region.height/n.height,path:n.path,type:U.Frame,disablePlaceholder:t.configuration.disablePlaceholder,focalBlur:t.configuration.focalBlur,focalBlurStrength:t.configuration.focalBlurStrength,focalBlurRadius:t.configuration.focalBlurRadius,pattern:void 0,immutable:t.region.immutable}}static async getImage(A,t){let e;if(t.layout){const A=(A=>{const t=(A.layoutState.layout.width<A.layoutState.layout.height?A.layoutState.layout.width:A.layoutState.layout.height)/2;return{top:A.layoutState.layout.height/2-t/2,left:A.layoutState.layout.width/2-t/2,width:t,height:t,rotation:0,panelId:A.layoutState.layout.panelId}})(t.layout),n=A.height,i=await fetch(t.src),a=await i.arrayBuffer(),s=await te(a),o=s.width/s.height;A.height=A.width/o,A.top+=(n-A.height)/2,e=A}else e=t.region;return e||(e={left:0,top:0,width:100,height:100,layer:0,layerIndex:1,rotation:0,panelId:"",immutable:!1}),{id:x(),src:t.src,type:U.Image,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||Qe(A,e.layer||0),immutable:e.immutable,preserveAspectRatio:"none"}}static async getTextbox(A,t){const{region:e,configuration:n,fontSrc:i,designInputStep:a}=t,s={assetUrl:i,name:(await LA(i)).names.fullName.en},o=a?.text||n.defaultText||"",r=n.replaceableText?n.replaceableText.replace("{{}}",o):o,c=$A(r,{vertical:n.vertical,uppercase:n.uppercase}),g=et({id:x(),type:U.Textbox,x:e.left,y:e.top,width:e.width,height:e.height,align:At(n.textAlign,n.vertical),curved:n.curved,fill:a?.color||n.colour||"#000000",fontData:s,layer:e.layer||0,layerIndex:e.layerIndex||Qe(A,t.region.layer||0),paths:n.paths,rotation:e.rotation,vertical:n.vertical,verticalAlign:n.verticalAlign||"middle",algorithm:P.Traditional,fontSize:n.size||18,text:c,input:o},c),B=de({...e,height:g.height},s,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:B.left,y:B.top,width:B.width,height:B.height}}static async getShape(A,t){const e=`\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="${t.color}"\n />\n </svg>\n `,n={};n["spiff-fill-shape"]={browserValue:t.color};const i=x();return{stepRegion:t.region,colors:n,id:i,svg:e,type:U.Illustration,y:t.region.top,x:t.region.left,rotation:t.region.rotation,width:t.region.width,height:t.region.height,layer:t.region.layer||0,layerIndex:t.region.layerIndex||Qe(A,t.region.layer||0),immutable:t.region.immutable}}}function ue(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class De extends Error{constructor(A){super(A),this.name=this.constructor.name}}class Ie extends De{constructor(A){super(`ConfigurationError - ${A}`)}}class pe extends Ie{constructor(A){super(`Option not Configured: ${A.stepTitle}`),ue(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class me extends Ie{constructor(A){super(`Panel not Found: ${A.panelId}`),ue(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class fe extends Ie{constructor(A){super(`Asset not found for variant: ${A.name}`),ue(this,"variant",void 0),this.variant=A}}class Me extends Ie{constructor(A){super(`Resource not found for asset: ${A.name}`),ue(this,"asset",void 0),this.asset=A}}class ye extends Ie{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),ue(this,"step",void 0),this.step=A}}class Fe extends De{constructor(A){super(`ImplementationError - ${A}`)}}class Ye extends Fe{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class xe extends Fe{constructor(A){super(`Parsing Error: ${A}`)}}class Ne extends Fe{constructor(A){super(`Client Error: ${A}`)}}class Se extends Fe{constructor(A){super(`Resource Generation Failed: ${A}`)}}class He{get(A){return localStorage.getItem(A)||void 0}set(A,t){localStorage.setItem(A,t)}remove(A){localStorage.removeItem(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}class Re{constructor(){var A,t,e;A=this,t="storage",e=new Map,t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e}get(A){return this.storage.get(A)||void 0}set(A,t){this.storage.set(A,t)}remove(A){this.storage.delete(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}const ve=(()=>{try{return localStorage?new He:new Re}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Re}})();function Ue(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ge=new class{constructor(){Ue(this,"defaultServerUrl","https://api.spiff.com.au"),Ue(this,"defaultServicesApiUrl","https://services.spiff.com.au"),Ue(this,"defaultHubUrl","https://hub.spiff.com.au"),Ue(this,"serverUrl",void 0),Ue(this,"servicesApiUrl",void 0),Ue(this,"hubUrl",void 0),Ue(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(A){this.serverUrl=A,this.serverUrlCallbacks.forEach((A=>A()))}setServicesApiUrl(A){this.servicesApiUrl=A}setHubUrl(A){this.hubUrl=A}addServerUrlCallback(A){this.serverUrlCallbacks.push(A)}};function Pe(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let ke;const Je=A=>{ke=A},be=async()=>{const A={transactionOwnerId:ke};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=Ge.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void A({});const e=n=>{n.origin===t&&(window.removeEventListener("message",e),A(n.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))})),...A}:A};const Oe=new class{constructor(){Pe(this,"client",void 0),Pe(this,"uncachedOperations",[]),Ge.addServerUrlCallback((async()=>{this.client=void 0,this.client=await this.constructClient()}))}setUncachedOperations(A){this.uncachedOperations=A}async execute(A,t){const e=this.uncachedOperations.includes(A)?A+"_private":A;return new Promise(((A,n)=>{this.getClient().then((i=>{i.execute({operationId:e,parameters:t}).then((t=>A(t))).catch((A=>{A.response&&A.response.status&&A.response.status>=500||(!A.response&&n(new Error(A)),A.response&&n(new Error(`${A.response.status} ${A.response.url}`)))}))})).catch((A=>{n(A)}))}))}async syncAuth(A){const t=await be();if(t.bearer?A.authorizations={...A.authorizations,OAuth2:{token:{access_token:t.bearer,token_type:"Bearer"}}}:A.authorizations={...A.authorizations,OAuth2:{token:{access_token:"",token_type:"Bearer"}}},t.activeIntegration)A.authorizations={...A.authorizations,ActiveIntegration:t.activeIntegration};else{const t={...A.authorizations};delete t.ActiveIntegration,A.authorizations=t}if(t.partnerId)A.authorizations={...A.authorizations,PartnerId:t.partnerId};else{const t={...A.authorizations};delete t.PartnerId,A.authorizations=t}}async getClient(){return this.client||(this.client=await this.constructClient()),this.syncAuth(this.client),Promise.resolve(this.client)}async constructClient(){const A=await be(),t=Ge.getServerUrl()+"/v2/api-docs";return await M(l)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const ze=new class{constructor(){Pe(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),Ge.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,w.createHttpLink)({uri:`${Ge.getServerUrl()}/graphql`,fetch:d.fetch}),t=(0,h.setContext)((async(A,{headers:t})=>{const e=t||{},n=await be();return n.bearer&&(e.Authorization=`Bearer ${n.bearer}`),n.partnerId&&(e.partnerId=n.partnerId),n.activeIntegration&&(e.activeIntegration=n.activeIntegration),n.transactionOwnerId&&(e.transactionOwnerId=n.transactionOwnerId),{headers:e}})),e=(0,E.onError)((({operation:A,graphQLErrors:t,networkError:e})=>{(t||[]).forEach((({message:t,locations:e,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+A.operationName),console.log("Query:"+JSON.stringify(A.query)),console.log(`Message: ${t}, Location: ${JSON.stringify(e,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(A.variables))})),e&&console.log("GraphQL Network error")}));const n=new(0,w.InMemoryCache)({typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(A=null)=>A},transactionOwnerId:{read:(A=null)=>A},customLogoLink:{read:(A=null)=>A},workflowFooterLogoLink:{read:(A=null)=>A},workflowState:{read:(A=null)=>A},bulkSourceUrl:{read:(A=null)=>A},externalDesignProductId:{read:(A=null)=>A},externalDesignProductVariantId:{read:(A=null)=>A},lastSyncedAt:{read:(A=null)=>A}}},Workflow:{fields:{isPresent:{read:(A=null)=>A}}},Product:{fields:{imageUrl:{read:(A=null)=>A},overlayImageUrl:{read:(A=null)=>A},preloadImageUrl:{read:(A=null)=>A},weight:{read:(A=null)=>A}}}}});return new(0,w.ApolloClient)({link:(0,w.from)([e,t,A]),cache:n,name:"Core"})}};function Le(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class Te{static add(A){const t=A?.links.find((A=>"cdn"===A.rel));if(!t)return void console.error("Failed to find cdn link on asset, cannot persist!");const e=new Map;e.set(A.data.key,t.href);const n=ve.getMap("persistentAssets");n&&n.forEach(((A,t)=>{e.set(t,A)})),ve.setMap("persistentAssets",e)}static remove(A){const t=ve.getMap("persistentAssets");if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),ve.setMap("persistentAssets",t))}static list(){const A=ve.getMap("persistentAssets");return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const je=new class{constructor(){Le(this,"server",void 0),Le(this,"cache",new Map),Le(this,"materialCache",new Map),Le(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await te(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)}})),Le(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await je.getLocalOrFromServer(A.assetKey))),Le(this,"getMaterialFromVariant",(async A=>A.material?A.material:await je.getMaterialLocalOrFromServer(A.materialId))),this.server=Oe}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new Ye("Failed to get asset from cache!");return t}const t=(async()=>(await Oe.execute("getAssetByKeyV2",{assetKey:A.replace(/\//g,"_")})).body)();return this.cache.set(A,t),t}async getMaterialLocalOrFromServer(A){if(this.materialCache.has(A))return this.materialCache.get(A);const t=(async()=>(await Oe.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,i){const a=await this.dispatchCreateAssetRequest(A,t,n,i);return await new Promise(((t,n)=>{var i=new XMLHttpRequest;i.open("PUT",a.assetResponse.uploadUrl,!0),i.setRequestHeader("Content-Type",a.mimeType),i.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),i.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},i.onload=()=>{const A=a.assetResponse.asset;Te.add(a.assetResponse.asset),t(A)},i.onerror=n,i.send(A.blob)})),a.assetResponse.asset}async uploadFile(A,t){const e=!("image/svg+xml"===A.type||"application/pdf"===A.type),n=e?j.Image:j.Illustration;if(e){const e=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(e,n,t,!0)}{const e={name:A.name,blob:new Blob([A],{type:A.type})};return await je.uploadAssetWithProgress(e,n,t,!0)}}removePersistedAsset(A){Te.remove(A)}getPersistedAssets(){return Te.list()}async dispatchCreateAssetRequest(A,t,e,n){const i=A.blob.type?A.blob.type:this.guessMIME(A.name);return{assetResponse:(await this.server.execute("createAsset",{assetDetails:{name:A.name,type:t,mimeType:i,storageOwnerId:n,userAnonymous:!0}},e)).body,mimeType:i}}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 Ye("Unexpected mimetype: "+t)}}};function Ke(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ve=new class{constructor(){Ke(this,"cache",new Map),Ke(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),Ke(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),Ke(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),Ke(this,"getOptionFromStep",(async A=>{if(A.option){const t=A.option.data.id;return t&&!this.cache.has(t)&&this.cache.set(t,Promise.resolve(A.option)),A.option}return await Ve.getOption(Oe,A.optionId)}))}async getOption(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(async()=>(await A.execute("getOptionV2",{id:t})).body)();return this.cache.set(t,e),e}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await je.getLocalOrFromServer(A.thumbnailKey),e=t.links.find((A=>"thumbnail"===A.rel)),n=t.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}const t=A.assetKey;if(t){const A=await je.getLocalOrFromServer(t),e=A.links.find((A=>"thumbnail"===A.rel)),n=A.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}return A.materialId?A.materialId:""}getDefaultVariant(A){const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0}},We=(0,Q.createContext)(new Ct),Xe=()=>{const A=(0,Q.useContext)(We),[t,e]=(0,Q.useState)(new Date);(0,Q.useEffect)((()=>{const t=()=>{e(new Date)};return A.registerStateCallback(t),()=>{A.unregisterStateCallback(t)}}),[A]);return{commandDispatcher:(t,e)=>{A.apply(t,e)},getLayoutById:t=>A.getLayoutById(t),getAllLayouts:()=>A.getAllLayouts(),getReducerState:()=>{const t=A.getState();return t||{transaction:{layouts:{},serializableWorkflow:{steps:[]}}}},lastUpdated:t,flattenSequence:(t,e)=>{A.flattenSequence(t,e)}}};let qe;var Ze;(Ze=qe||(qe={})).None="None",Ze.FrameAdjustment="FrameAdjustment",Ze.FinalizeDesign="FinalizeDesign";const $e=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,maxZoom:5,units:J.Pixel,subMenu:qe.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),_e=(A,t)=>M(C)(A,t.apply(A))?A:t.apply(A),An=(0,Q.createContext)({}),tn=A=>{const{getAllLayouts:e}=Xe(),[n,i]=(0,Q.useReducer)(_e,$e(e,A.defaultZoom||1)),a=(0,Q.useMemo)((()=>({state:n,uiDispatcher:i})),[n,i]);return(0,t.jsx)(An.Provider,{value:a,children:A.children})};class en{constructor(A){var t,e,n;n=void 0,(e="changes")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.changes=A}apply(A){return{...A,...this.changes}}}const nn=()=>(0,Q.useContext)(An);let an;var sn;(sn=an||(an={}))[sn.Orbit=0]="Orbit",sn[sn.Pan=1]="Pan";const on=(A,e,n,i)=>{const a=e.layout.width,s=e.layout.height,o=e.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),r=o.map((A=>Z(A.x,A.y,A.width,A.height,A.rotation))),c=[],g=new Set;r.forEach((A=>g.add(A.minX))),r.forEach((A=>g.add(A.maxX))),[0,a/2,a].forEach((A=>g.add(A)));const B=new Set;r.forEach((A=>B.add(A.minY))),r.forEach((A=>B.add(A.maxY))),[0,s/2,s].forEach((A=>B.add(A)));const l=o.map((A=>A.y));for(let A=-315;A<=315;A+=45)l.push(A);const w=Z(A.x,A.y,A.width,A.height,A.rotation),h=[{value:w.minX,anchor:-1},{value:w.minX+(w.maxX-w.minX)/2,anchor:0},{value:w.minX+(w.maxX-w.minX),anchor:1}],E=[{value:w.minY,anchor:-1},{value:w.minY+(w.maxY-w.minY)/2,anchor:0},{value:w.minY+(w.maxY-w.minY),anchor:1}],d=[{value:A.rotation,anchor:0}],Q=(A,e,i,o)=>{const r=[];return e.forEach((e=>{const c=i.find((A=>tA(e,A.value,.5*n))),[g,B]=((A,t)=>[{x:"x"===A?t:0,y:"x"===A?0:t},{x:"x"===A?t:a,y:"x"===A?s:t}])(A,e),l="rotation"===A?null:(0,t.jsx)("line",{x1:g.x,y1:g.y,x2:B.x,y2:B.y,stroke:o||"#D61B5C",strokeWidth:1.2*n},`${A}-${e}-${g.x}-${g.y}-${B.x}-${B.y}`);void 0!==c&&r.push({type:A,value:e,anchorPoint:c.anchor,svgNode:l,guidelineCoordinates:[g,B]})})),r};return c.push(...Q("x",Array.from(g),h,i),...Q("y",Array.from(B),E,i),...Q("rotation",l,d,i)),c};let rn;var cn;let gn;var Bn;(cn=rn||(rn={})).Translate="Translate",cn.Rotate="Rotate",cn.Resize="Resize",(Bn=gn||(gn={})).ControlLeft="ControlLeft",Bn.ControlRight="ControlRight",Bn.Equal="Equal",Bn.MetaLeft="MetaLeft",Bn.MetaRight="MetaRight",Bn.Minus="Minus",Bn.ArrowLeft="ArrowLeft",Bn.ArrowRight="ArrowRight",Bn.ArrowUp="ArrowUp",Bn.ArrowDown="ArrowDown",Bn.AltLeft="AltLeft",Bn.AltRight="AltRight",Bn.Delete="Delete",Bn.Backspace="Backspace";const ln=(A,t,e,n)=>{const i=()=>{switch(e){case J.Pixel:return 1;case J.Millimeter:return lA;case J.Centimeter:return wA;default:throw new Ye("Unknown unit of measurement")}};let a=t.x,s=t.y,o=t.x,r=t.y;switch(A){case gn.ArrowLeft:o=t.x-1/i();break;case gn.ArrowUp:r=t.y-1/i();break;case gn.ArrowRight:o=t.x+1/i();break;case gn.ArrowDown:r=t.y+1/i();break;default:throw new Ye("Unhandled element interaction!")}const c=Z(o,r,t.width,t.height,t.rotation);return(!n||c.minX>=n.left&&c.maxX<=n.left+n.width&&c.minY>=n.top&&c.maxY<=n.top+n.height)&&(a=o,s=r),new xt(t.id,a,s)};var wn=0,hn=0,En=0;const dn=(A,t,e,n,i,a,s)=>{const o=((A,t,e,n,i,a,s)=>{const o=n.width/t.width,r=n.height/t.height,c=A.mX/o,g=A.mY/r,B=e.rotation*Math.PI/180,l=Math.sin(B),w=Math.cos(B),h=e.type===U.Textbox?1:e.width/e.height;let E;switch(i.type){case rn.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},d=t;switch(i.screenAxis){case O.North:{const A=-c*l+g*w,n=e.y+A,i=e.height-A,a=gA({...e}).center,s=gA({...e,y:n,height:i}).center,o=BA(s,a,B),r=o.x-e.width/2,h=o.y-i/2;d={...t,left:r,top:h,height:i}}break;case O.East:{const A=c*w+g*l,n=e.width+A;let i=e.height;if(e.type===U.Textbox){const A=e;i=WA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const a=gA({...e}).center,s=gA({...e,width:n,height:i}).center,o=BA(s,a,B),r=o.x-n/2,h=o.y-i/2;d={...t,left:r,top:h,width:n,height:i}}break;case O.West:{const A=c*w+g*l,n=e.x+A,i=e.width-A;let a=e.height;if(e.type===U.Textbox){const A=e;a=WA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const s=gA({...e}).center,o=gA({...e,width:i,height:a,x:n}).center,r=BA(o,s,B),h=r.x-i/2,E=r.y-a/2;d={...t,left:h,top:E,width:i,height:a}}break;case O.South:{const A=-c*l+g*w,n=e.height+A,i=gA({...e}).center,a=gA({...e,height:n}).center,s=BA(a,i,B),o=s.x-e.width/2,r=s.y-n/2;d={...t,left:o,top:r,height:n}}break;case O.Northeast:{const A=c*w+g*l,n=e.width+A*h;let i=e.height+A,a=e.y-A,s=e.fontSize;if(e.type===U.Textbox){const t=e;s=t.fontSize+A/8,i=WA(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||nt;a=e.y-A*n/8}const o=gA({...e}).center,r=gA({...e,width:n,height:i,y:a}).center,E=BA(r,o,B),Q=E.x-n/2,C=E.y-i/2;d={...t,left:Q,top:C,width:n,height:i,fontSize:s}}break;case O.Northwest:{const A=-c*w+-g*l,n=e.x-A*h,i=e.width+A*h;let a=e.y-A,s=e.height+A,o=e.fontSize;if(e.type===U.Textbox){const t=e;o=t.fontSize+A/8,s=WA(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||nt;a=e.y-A*n/8}const r=gA({...e}).center,E=gA({...e,x:n,y:a,width:i,height:s}).center,Q=BA(E,r,B),C=Q.x-i/2,u=Q.y-s/2;d={...t,left:C,top:u,width:i,height:s,fontSize:o}}break;case O.Southeast:{const A=c*w+g*l,n=e.width+A*h;let i=e.height+A,a=e.fontSize;if(e.type===U.Textbox){const t=e;a=t.fontSize+A/8,i=WA(a,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=gA({...e}).center,o=gA({...e,width:n,height:i}).center,r=BA(o,s,B),E=r.x-n/2,Q=r.y-i/2;d={...t,left:E,top:Q,width:n,height:i,fontSize:a}}break;case O.Southwest:{const A=-c*w+-g*l,n=e.width+A*h;let i=e.x-A*h,a=e.height+A,s=e.fontSize;if(e.type===U.Textbox){const t=e;s=t.fontSize+A/8,a=WA(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const o=gA({...e}).center,r=gA({...e,width:n,height:a,x:i}).center,E=BA(r,o,B),Q=E.x-n/2,C=E.y-a/2;d={...t,left:Q,top:C,width:n,height:a,fontSize:s}}}return E=Z(d.left,d.top,d.width,d.height,d.rotation),(!s||E.minX>=s.left&&E.maxX<=s.left+s.width&&E.minY>=s.top&&E.maxY<=s.top+s.height)&&(t=d),t;case rn.Rotate:const Q={x:A.clientX,y:A.clientY};let C,u=e.rotation;const D=gA(e,n,{x:o,y:r}),I=$(Q,D.c,D.d),p=$(Q,D.d,D.c);if(0===a.filter((A=>"rotation"===A.type)).length)En=0,C=(e.rotation+I-p)%360;else{En+=Math.sqrt(c**2+g**2);const A=Math.abs(En)>.5*window.devicePixelRatio/o;C=A?(e.rotation+I-p)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(En=0)}return E=Z(e.x,e.y,e.width,e.height,C),(!s||E.minX>=s.left&&E.maxX<=s.left+s.width&&E.minY>=s.top&&E.maxY<=s.top+s.height)&&(u=C),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:u};case rn.Translate:let m,f,M=e.x,y=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)wn=0,hn=0,m=e.x+c,f=e.y+g;else{const A=a.find((A=>"x"===A.type)),t=a.find((A=>"y"===A.type));A||(wn=0),t||(hn=0);const n=Math.abs(wn)>.5*window.devicePixelRatio/o,i=Math.abs(hn)>.5*window.devicePixelRatio/r,s=A=>{switch(A){case-1:return 0;case 0:return e.width/2;case 1:return e.width;default:return 0}},B=A=>{switch(A){case-1:return 0;case 0:return e.height/2;case 1:return e.height;default:return 0}};if(0!==e.rotation)m=A?n?e.x+wn:e.x:e.x+c,f=t?i?e.y+hn:e.y:e.y+g;else{if(A){const t=A.value-s(A.anchorPoint);m=n?t+wn:t}else m=e.x+c;if(t){const A=t.value-B(t.anchorPoint);f=i?A+hn:A}else f=e.y+g}wn=n?0:wn+c,hn=i?0:hn+g}return E=Z(m,f,e.width,e.height,e.rotation),(!s||E.minX>=s.left&&E.maxX<=s.left+s.width&&E.minY>=s.top&&E.maxY<=s.top+s.height)&&(M=m,y=f),{top:y,left:M,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,s),r=[];if(e.type===U.Textbox){const A=e;r.push(new Tt(A.id,A.input||""))}if(o.width>0&&o.height>0&&(r.push(new xt(e.id,o.left,o.top),new St(e.id,o.width,o.height),new Nt(e.id,o.rotation)),e.type===U.Textbox)){const A=e;o.fontSize&&A.fontSize!==o.fontSize&&r.push(new Jt(A.id,o.fontSize))}return r},Qn=.5,Cn=["TEXTAREA","INPUT"],un=(A,t,e,n,i,a,s)=>{const{state:o,uiDispatcher:r}=(0,Q.useContext)(An),{getLayoutById:c,getReducerState:g,flattenSequence:B}=Xe(),[l,w]=(0,Q.useState)(void 0),[h,E]=(0,Q.useState)(void 0),[d,C]=(0,Q.useState)(void 0),u=c(o.layoutId);(0,Q.useEffect)((()=>{if("adjustment"===i&&A?.current&&n){if(n<Qn)return void r(new en({zoom:Qn}));if(n>o.maxZoom)return void r(new en({zoom:o.maxZoom}));r(new en({zoom:n}))}}),[n,r,A,i,o.maxZoom]);const D=(0,Q.useCallback)(((A,n)=>{r(new en({zoom:n}));const a=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!o.scrolledMovement&&"advanced"===i&&(s&&(t.current.scrollTop=e.current.offsetTop+(t.current.scrollHeight-t.current.clientHeight)/2),a&&(t.current.scrollLeft=(e.current.offsetLeft+t.current.scrollWidth-t.current.clientWidth)/2))}),[r,t,e,o.scrolledMovement,i]);(0,Q.useEffect)((()=>{o.zoom<=1&&r(new en({scrolledMovement:!1}))}),[r,o.zoom]);const I=t?.current?.getBoundingClientRect(),p=((I?.width||1)+(I?.height||1))/2,m=(u.layoutState.layout.width+u.layoutState.layout.height)/2/p/o.zoom,f=(0,Q.useMemo)((()=>{const A=o.activeModifierKeys,t=o.elementEvent,e=A.includes(gn.ControlLeft)||A.includes(gn.MetaLeft)||A.includes(gn.ControlRight)||A.includes(gn.MetaRight);if(!o.selectedElement||!t||e)return[];const n=t&&t.type===rn.Translate,i=t&&t.type===rn.Rotate,a=u.layoutState.elements.find((A=>A.id===o.selectedElement));return(n||i)&&a?on(a,u.layoutState,m,s):[]}),[o.selectedElement,o.elementEvent,o.activeModifierKeys,u.layoutState,m]),M=(0,Q.useCallback)((()=>{const A=x();w(A),E(g().transaction)}),[g]),y=(0,Q.useCallback)((()=>{r(new en({selectedElement:void 0}))}),[r]),F=(0,Q.useCallback)((()=>{r(new en({scrolledMovement:!0}))}),[r]),Y=(0,Q.useCallback)(((e,n)=>{const i=u.layoutState.elements.find((A=>A.id===o.selectedElement));if(!(o.elementEvent&&A.current&&t.current&&o.selectedElement&&i))return;t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const s=A.current.getBoundingClientRect(),r=new Ht(dn({mX:d?e.screenX-d.screenX:0,mY:d?e.screenY-d.screenY:0,clientX:e.clientX,clientY:e.clientY},u.layoutState.layout,i,s,o.elementEvent,f,n));r.sequenceId=l,a(r,!1),C({screenX:e.screenX,screenY:e.screenY})}),[u.layoutState.elements,u.layoutState.layout,o.elementEvent,A,o.selectedElement,t,f,a,d]),N=(0,Q.useCallback)((A=>{r(new en({elementEvent:A}))}),[r]),S=(0,Q.useCallback)((()=>{r(new en({elementEvent:void 0})),l&&h&&(B(l,h),w(void 0),E(void 0)),C(void 0)}),[r,l,h,B]),H=(0,Q.useCallback)(((A,t)=>{let e=o.zoom;const n=o.maxZoom,s=o.selectedElement,c=o.activeModifierKeys;if((c.includes(gn.AltLeft)||c.includes(gn.AltRight))&&(A.code===gn.Equal||A.code===gn.Minus)){const t=.05*n;A.code===gn.Equal?r(new en({zoom:e+t<=n?e+=t:e})):r(new en({zoom:e-t>=Qn?e-t:e}))}const g=u.layoutState.elements.find((A=>A.id===s));if(s&&g){if(A.code===gn.MetaLeft||A.code===gn.ControlLeft||A.code===gn.MetaRight||A.code===gn.ControlRight){const t=A.code,e=o.activeModifierKeys;if(!e.includes(t))return r(new en({activeModifierKeys:e.concat(t)}))}if(A.code===gn.ArrowDown||A.code===gn.ArrowUp||A.code===gn.ArrowLeft||A.code===gn.ArrowRight){r(new en({elementEvent:{type:rn.Translate}}));const e=ln(A.code,g,o.units,t);a(e,!1),r(new en({elementEvent:void 0}))}A.code!==gn.Delete&&A.code!==gn.Backspace||"advanced"!==i||(r(new en({selectedElement:void 0})),a(new Gt(g.id),!1))}}),[a,r,u.layoutState.elements,i,o.activeModifierKeys,o.maxZoom,o.selectedElement,o.units,o.zoom]),R=(0,Q.useCallback)((A=>{if(A.code===gn.MetaLeft||A.code===gn.ControlLeft||A.code===gn.MetaRight||A.code===gn.ControlRight){const t=o.activeModifierKeys,e=A.code;r(new en({activeModifierKeys:t.filter((A=>A!==e))}))}}),[r,o.activeModifierKeys]);return{guidelines:f,scale:m,zoomableElementRef:e,setElementEvent:N,handleZoom:D,handleKeyDown:H,handleKeyUp:R,handlePointerPressedBackground:y,handlePointerReleased:S,handlePointerMove:Y,handleScroll:F,handleSequenceStart:M}},Dn=(A,t)=>{const e=(0,Q.useMemo)((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),n=(0,Q.useRef)([]),i=(0,Q.useCallback)((()=>{const A=e.every((A=>n.current.includes(A))),t=n.current.length===e.length;return A&&t}),[]),a=(0,Q.useCallback)((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const a=A.target;return!(Cn.indexOf(a.tagName)>=0)&&(n.current=[...new Set([...n.current,e])],i()&&t(),A.preventDefault())}),[i,e,t,A]),s=(0,Q.useCallback)((A=>{const t=String(A.key).toLowerCase();return n.current=n.current.filter((A=>A!==t)),A.preventDefault()}),[e]);(0,Q.useEffect)((()=>(window.addEventListener("keydown",a),window.addEventListener("keyup",s),()=>{window.removeEventListener("keydown",a),window.removeEventListener("keyup",s)})),[a,s])},In=A=>{const{x:e,y:n,cursorStyle:i,onPointerDown:a,handleClass:s,cornerRadius:o,color:r,strokeWidth:c}=A;return(0,t.jsx)("circle",{className:s,cx:e,cy:n,r:o,fill:"#ffffff",style:{cursor:i},stroke:r,strokeWidth:c,onPointerDown:a})},pn=A=>{const{x:e,y:n,width:i,height:a,cursorStyle:s,onPointerDown:o,edgeHandleRadius:r,color:c,strokeWidth:g}=A;return(0,t.jsx)("rect",{x:e,y:n,width:i,height:a,rx:r,fill:"#ffffff",style:{cursor:s},stroke:c,strokeWidth:g,onPointerDown:o})},mn=A=>{const{color:e,elementHeight:n,elementWidth:i,onBeginResize:a,rotation:s,scaleFactor:o,disableX:r,disableY:c}=A,g=10*o,B=5*o,l=40*o,w=12*o,h=1.2*o,E=n-2*g,d=(0,Q.useCallback)(((A,t,e)=>{A.stopPropagation(),a(t,e)}),[a]),C=(0,Q.useCallback)((A=>d(A,cA(O.West,360-s),O.West)),[d,s]),u=(0,Q.useCallback)((A=>d(A,cA(O.East,360-s),O.East)),[d,s]),D=(0,Q.useCallback)((A=>d(A,cA(O.North,360-s),O.North)),[d,s]),I=(0,Q.useCallback)((A=>d(A,cA(O.South,360-s),O.South)),[d,s]),p=(0,Q.useCallback)((A=>d(A,O.Northwest,O.Northwest)),[d]),m=(0,Q.useCallback)((A=>d(A,O.Northeast,O.Northeast)),[d]),f=(0,Q.useCallback)((A=>d(A,O.Southwest,O.Southwest)),[d]),M=(0,Q.useCallback)((A=>d(A,O.Northeast,O.Southeast)),[d]),y=l<=E;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(In,{x:0,y:0,cursorStyle:"nw-resize",onPointerDown:p,handleClass:"cornerNorthWest",cornerRadius:g,color:e,strokeWidth:h}),y?(0,t.jsx)(In,{x:i,y:0,cursorStyle:"ne-resize",onPointerDown:m,handleClass:"cornerNorthEast",cornerRadius:g,color:e,strokeWidth:h}):void 0,y?(0,t.jsx)(In,{x:i,y:n,cursorStyle:"se-resize",onPointerDown:M,handleClass:"cornerSouthEast",cornerRadius:g,color:e,strokeWidth:h}):void 0,y?(0,t.jsx)(In,{x:0,y:n,cursorStyle:"sw-resize",onPointerDown:f,handleClass:"cornerSouthWest",cornerRadius:g,color:e,strokeWidth:h}):void 0,y&&!r?(0,t.jsx)(pn,{x:-w/2,y:n/2-l/2,width:w,height:l,onPointerDown:C,edgeHandleRadius:B,cursorStyle:"w-resize",color:e,strokeWidth:h}):void 0,y&&!c?(0,t.jsx)(pn,{x:i/2-l/2,y:n-w/2,width:l,height:w,onPointerDown:I,edgeHandleRadius:B,cursorStyle:"s-resize",color:e,strokeWidth:h}):void 0,r?void 0:(0,t.jsx)(pn,{x:i-w/2,y:n/2-Math.min(l,.8*n)/2,width:w,height:Math.min(l,.8*n),onPointerDown:u,edgeHandleRadius:B,cursorStyle:"e-resize",color:e,strokeWidth:h}),y&&!c?(0,t.jsx)(pn,{x:i/2-l/2,y:-w/2,width:l,height:w,onPointerDown:D,edgeHandleRadius:B,cursorStyle:"n-resize",color:e,strokeWidth:h}):void 0]})},fn=A=>{const{color:e,elementWidth:n,onBeginRotate:i,scaleFactor:a}=A,s=(0,Q.useCallback)((A=>{A.stopPropagation(),i()}),[i]),o=10*a,r=1.2*a;return(0,t.jsxs)("g",{children:[(0,t.jsx)("circle",{cx:n/2,cy:-2.5*o,r:1.3*o,fill:"rgba(0, 0, 0, 0.5)",opacity:.4,style:{cursor:"ew-resize"},onPointerDown:s}),(0,t.jsx)("circle",{cx:n/2,cy:-2.5*o,r:o,fill:"#fff",style:{cursor:"ew-resize"},stroke:e,strokeWidth:r,onPointerDown:s}),(0,t.jsxs)("svg",{x:n/2-o,y:-2.5*o-o,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*o,viewBox:"0 0 24 24",width:2*o,fill:e,onPointerDown:s,children:[(0,t.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,t.jsx)("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})]})]})},Mn=({color:A,height:e,highlighted:n,id:i,immutable:a,onBeginMove:s,onPointerEnter:o,onPointerLeave:r,onSelected:c,pressed:g,rotation:B,scaleFactor:l,selected:w,width:h,x:E,y:d})=>{const C=1.2*l,u=(0,Q.useCallback)((A=>{2===A.button&&(A.stopPropagation(),c(i,A)),0===A.button&&(A.stopPropagation(),!w&&c(i,A),s())}),[i,w,c,s]),D=(0,Q.useCallback)((()=>{o(i)}),[i,o]),I=(0,Q.useCallback)((()=>{r(i)}),[i,r]),p=a?void 0:w?g?"grabbing":"grab":"pointer",m=a?"none":"visibleFill";return(0,t.jsx)("g",{transform:`translate(${E}, ${d}) rotate(${B} ${h/2} ${e/2})`,children:(0,t.jsx)("rect",{className:"interactableInnerRect",width:h,height:e,stroke:w||n?A:"none",pointerEvents:m,fill:"none",strokeWidth:C,style:{cursor:p},onPointerDown:a?void 0:u,onPointerEnter:a?void 0:D,onPointerLeave:a?void 0:I})})},yn=({color:A,height:e,onBeginResize:n,onBeginRotate:i,rotation:a,scaleFactor:s,width:o,x:r,y:c,disableX:g,disableY:B})=>(0,t.jsxs)("g",{transform:`translate(${r}, ${c}) rotate(${a} ${o/2} ${e/2})`,children:[(0,t.jsx)(fn,{color:A,elementWidth:o,onBeginRotate:i,scaleFactor:s}),(0,t.jsx)(mn,{color:A,elementHeight:e,elementWidth:o,rotation:a,scaleFactor:s,onBeginResize:n,disableX:g,disableY:B})]}),Fn=({primaryColor:A,containerHeight:e,containerWidth:n,customViewbox:i,editorRef:a,elementEvent:s,guidelines:o,layoutHeight:r,layoutWidth:c,targetedElements:g,scale:B,selectedElement:l,onElementEvent:w,onElementSelected:h,onSequenceStart:E,onMouseMove:d})=>{const{state:C}=nn(),{getLayoutById:u}=Xe(),D=u(C.layoutId),[I,p]=(0,Q.useState)(void 0),m=(0,Q.useCallback)((A=>{p(A)}),[]),f=(0,Q.useCallback)((A=>{I===A&&p(void 0)}),[I]),M=(0,Q.useCallback)((()=>{E(),w({type:rn.Translate})}),[w]),y=(0,Q.useCallback)(((A,t)=>{E(),w({type:rn.Resize,relativeAxis:A,screenAxis:t})}),[w]),F=(0,Q.useCallback)((()=>{E(),w({type:rn.Rotate})}),[w]),Y=i||{x:0,y:0,width:c,height:r},x=B*(Math.sqrt(Y.width*Y.height)/1e3)*(100/Math.sqrt(e*n))*Math.sqrt((N=n/e,Math.exp(Math.abs(Math.log(N)))));var N;const S=D.layoutState.elements,H=S.find((A=>A.id===l));return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",style:{touchAction:"none",position:"absolute",maxWidth:"100%",maxHeight:"100%"},width:"auto",height:"auto",viewBox:`${Y.x} ${Y.y} ${Y.width} ${Y.height}`,overflow:"overlay",children:[(0,t.jsx)("rect",{onMouseMove:d,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:a,width:c,height:r}),o.map((A=>A.svgNode)),S.map((e=>{const n=void 0!==l&&e.id===l,i=n&&void 0!==s,a=void 0!==I&&e.id===I;return(0,t.jsx)(Mn,{color:A,id:e.id,selected:n,highlighted:a,pressed:i,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation,immutable:e.immutable||g&&!g.includes(e.id),onSelected:h,onBeginMove:M,onPointerEnter:m,onPointerLeave:f,scaleFactor:x},e.id)})),H&&(0,t.jsx)(yn,{color:A,x:H.x,y:H.y,disableX:H.type===U.Frame,disableY:H.type===U.Textbox||H.type===U.Frame,width:H.width,height:H.height,rotation:H.rotation,onBeginResize:y,onBeginRotate:F,scaleFactor:x})]})},Yn=A=>{const{color:e,editorRef:n,zoomableElementRef:i,interactionElementRef:a,guidelines:s,isMakingAdjustments:o,viewmask:r,visibleLayoutId:c,xTranslation:g,yTranslation:B,targetedElements:l,borderRadius:w,handleContextMenu:h,onMouseMove:E,handleKeyDown:d,handleKeyUp:C,handlePointerMove:u,handlePointerPressedBackground:D,handlePointerReleased:I,handleScroll:p,onSequenceStart:m,setElementEvent:f,onElementSelected:M}=A,{getLayoutById:y}=Xe(),F=y(c),Y=F.layoutState,{state:x}=nn(),N=(0,Q.useCallback)((A=>{if(r){const t={left:r.x,top:r.y,width:r.width,height:r.height,panelId:"",rotation:0};return d(A,t)}return d(A)}),[d,r]),S=(0,Q.useCallback)((A=>{if(r){const t={left:r.x,top:r.y,width:r.width,height:r.height,panelId:"",rotation:0};return u(A,t)}return u(A)}),[u,r]);return(0,t.jsx)("div",{style:{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:"none"},onContextMenu:h,onKeyDown:N,onKeyUp:C,onPointerDown:D,onPointerMoveCapture:S,onPointerUp:I,onWheelCapture:p,ref:a,tabIndex:-1,children:(0,t.jsxs)("div",{ref:i,style:{height:"100%",transform:`scale(${x.zoom}) translate(${g}px, ${B}px)`,display:"flex",justifyContent:"center",filter:"drop-shadow(rgba(0, 0, 0, 0.2) 0px 0px 6px)"},children:[A.children,F.getComponentWithProps({height:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",viewmask:r,width:o?"100%":"auto",borderRadius:w}),(0,t.jsx)(Fn,{primaryColor:e,containerHeight:i.current?.offsetHeight||1024,containerWidth:i.current?.offsetWidth||1024,editorRef:n,elementEvent:x.elementEvent,guidelines:s,layoutHeight:Y.layout.height,layoutWidth:Y.layout.width,onElementEvent:f,onSequenceStart:m,onElementSelected:M,scale:10/x.zoom,selectedElement:x.selectedElement,targetedElements:l,onMouseMove:E})]})})},xn=({color:A,borderRadius:e,guidelineColor:n,handleContextMenu:i,onMouseMove:a,onElementSelected:s})=>{const{commandDispatcher:o,getLayoutById:r}=Xe(),{state:c,uiDispatcher:g}=nn(),B=(0,Q.useRef)(null),l=(0,Q.useRef)(null),w=(0,Q.useRef)(null),{guidelines:h,handleKeyDown:E,handleKeyUp:d,handlePointerMove:C,handlePointerPressedBackground:u,handlePointerReleased:D,handleScroll:I,handleSequenceStart:p,setElementEvent:m}=un(B,l,w,void 0,"advanced",o,n),f=(0,Q.useCallback)(((A,t)=>{const e=r(c.layoutId).layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===U.Textbox){const t=e.algorithm;(!t||t===P.Autosize)&&o(new bt(A,P.Traditional),!0)}s&&s(A,t),g(new en({selectedElement:A}))}),[o,r,c.layoutId,g]);return(0,t.jsx)(Yn,{color:A,editorRef:B,interactionElementRef:l,zoomableElementRef:w,guidelines:h,visibleLayoutId:c.layoutId,xTranslation:0,yTranslation:0,borderRadius:e,handleContextMenu:i,onMouseMove:a,handleKeyDown:E,handleKeyUp:d,handlePointerMove:C,handlePointerPressedBackground:u,handlePointerReleased:D,handleScroll:I,onSequenceStart:p,setElementEvent:m,onElementSelected:f})},Nn=w.gql`
1
+ var A=require("lodash.clonedeep"),t=require("react/jsx-runtime"),e=require("react-dom/server"),n=require("opentype.js"),i=require("axios"),a=require("https"),s=require("file-type"),o=require("buffer"),r=require("util"),c=require("css"),g=require("canvas"),B=require("exif"),l=require("swagger-client"),w=require("@apollo/client"),h=require("@apollo/client/link/context"),E=require("@apollo/client/link/error"),d=require("cross-fetch"),Q=require("react"),C=require("lodash.isequal"),u=require("canvg"),D=require("lodash.debounce"),I=require("qrcode"),p=require("svg-path-bbox");function m(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function M(A){return A&&A.__esModule?A.default:A}function y(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}m(module.exports,"SpiffCommerceClient",(()=>ya)),m(module.exports,"CommandContext",(()=>Ct)),m(module.exports,"spiffCoreConfiguration",(()=>Ge)),m(module.exports,"PromiseQueue",(()=>ni)),m(module.exports,"QueueablePromise",(()=>ei)),m(module.exports,"MockWorkflowManager",(()=>Ya)),m(module.exports,"InformationMessageType",(()=>Ti)),m(module.exports,"StepHandle",(()=>Xi)),m(module.exports,"TextStepHandle",(()=>ea)),m(module.exports,"FrameStepHandle",(()=>Sa)),m(module.exports,"IllustrationStepHandle",(()=>qi)),m(module.exports,"ModelStepHandle",(()=>$i)),m(module.exports,"PictureStepHandle",(()=>_i)),m(module.exports,"OptionNotFoundError",(()=>pe)),m(module.exports,"LayoutNotFoundError",(()=>me)),m(module.exports,"AssetNotFoundError",(()=>fe)),m(module.exports,"ResourceNotFoundError",(()=>Me)),m(module.exports,"MisconfigurationError",(()=>ye)),m(module.exports,"ParseError",(()=>xe)),m(module.exports,"UnhandledBehaviorError",(()=>Ye)),m(module.exports,"assetService",(()=>je)),m(module.exports,"createDesign",(()=>zn)),m(module.exports,"optionService",(()=>Ve)),m(module.exports,"server",(()=>Oe)),m(module.exports,"persistenceService",(()=>ve)),m(module.exports,"graphQlManager",(()=>ze)),m(module.exports,"toast",(()=>pi)),m(module.exports,"FrameService",(()=>oi)),m(module.exports,"frameStepService",(()=>hi)),m(module.exports,"modelStepService",(()=>di)),m(module.exports,"materialStepService",(()=>Ei)),m(module.exports,"shapeStepService",(()=>Di)),m(module.exports,"questionStepService",(()=>ui)),m(module.exports,"digitalContentStepService",(()=>wi)),m(module.exports,"moduleStepService",(()=>Qi)),m(module.exports,"pictureStepService",(()=>Ci)),m(module.exports,"textStepService",(()=>yi)),m(module.exports,"illustrationStepService",(()=>Vn)),m(module.exports,"svgObjectURL",(()=>Kn)),m(module.exports,"ProductCameraRig",(()=>an)),m(module.exports,"FrameStep",(()=>xa)),m(module.exports,"AssetType",(()=>j)),m(module.exports,"BringForwardCommand",(()=>Vt)),m(module.exports,"CanvasCommand",(()=>Ft)),m(module.exports,"CreateElementCommand",(()=>Ut)),m(module.exports,"CreateLayoutCommand",(()=>Rt)),m(module.exports,"DeleteElementCommand",(()=>Gt)),m(module.exports,"FontAlignmentCommand",(()=>zt)),m(module.exports,"FontColorCommand",(()=>kt)),m(module.exports,"FontSizeCommand",(()=>Jt)),m(module.exports,"FontSourceCommand",(()=>Ot)),m(module.exports,"GroupCommand",(()=>Ht)),m(module.exports,"LayoutElementFactory",(()=>Ce)),m(module.exports,"LayoutElementType",(()=>U)),m(module.exports,"MoveCommand",(()=>xt)),m(module.exports,"ResizeCommand",(()=>St)),m(module.exports,"RotateCommand",(()=>Nt)),m(module.exports,"SendBackwardsCommand",(()=>Wt)),m(module.exports,"StepAspectType",(()=>X)),m(module.exports,"StepType",(()=>V)),m(module.exports,"TextChangeCommand",(()=>Tt)),m(module.exports,"UnitOfMeasurement",(()=>J)),m(module.exports,"dataUrlFromExternalUrl",(()=>vA)),m(module.exports,"findElement",(()=>mt)),m(module.exports,"frameDataCache",(()=>ie)),m(module.exports,"generate",(()=>x)),m(module.exports,"generateSVGWithUnknownColors",(()=>dt)),m(module.exports,"getAttributesFromArrayBuffer",(()=>te)),m(module.exports,"rehydrateSerializedLayout",(()=>yt)),m(module.exports,"getFrameData",(()=>re)),m(module.exports,"getSvgString",(()=>Dt)),m(module.exports,"loadFontFromDataUrl",(()=>TA)),m(module.exports,"loadFontFromExternalUrl",(()=>LA)),m(module.exports,"determineCorrectFontSizeAndLines",(()=>Ee)),m(module.exports,"patternImageDataCache",(()=>ne)),m(module.exports,"generateCommands",(()=>da)),m(module.exports,"registerJSDOM",(()=>pA)),m(module.exports,"minZoom",(()=>Qn)),m(module.exports,"AdvancedEditor",(()=>xn)),m(module.exports,"EditorCore",(()=>Yn)),m(module.exports,"useLayouts",(()=>Xe)),m(module.exports,"useEditorState",(()=>nn)),m(module.exports,"useEditorInteraction",(()=>un)),m(module.exports,"useShortcutCombination",(()=>Dn)),m(module.exports,"commandReducer",(()=>_e)),m(module.exports,"getDefaultState",(()=>$e)),m(module.exports,"CommandContextContext",(()=>We)),m(module.exports,"AdvancedEditorStateProvider",(()=>tn)),m(module.exports,"AdvancedEditorContext",(()=>An)),m(module.exports,"UICommand",(()=>en)),m(module.exports,"EditorSubMenu",(()=>qe)),m(module.exports,"ElementEventType",(()=>rn)),m(module.exports,"KeyEvent",(()=>gn)),m(module.exports,"gatherVaryingStepAspects",(()=>Wn));var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==f?f:{},Y={};y(Y,"CanvasCommand",(()=>Ft)),y(Y,"UpdateWorkflowStateCommand",(()=>Yt)),y(Y,"MoveCommand",(()=>xt)),y(Y,"RotateCommand",(()=>Nt)),y(Y,"ResizeCommand",(()=>St)),y(Y,"GroupCommand",(()=>Ht)),y(Y,"CreateLayoutCommand",(()=>Rt)),y(Y,"ClearLayoutCommand",(()=>vt)),y(Y,"CreateElementCommand",(()=>Ut)),y(Y,"DeleteElementCommand",(()=>Gt)),y(Y,"CloneElementCommand",(()=>Pt)),y(Y,"FontColorCommand",(()=>kt)),y(Y,"FontSizeCommand",(()=>Jt)),y(Y,"FontAlgorithmCommand",(()=>bt)),y(Y,"FontSourceCommand",(()=>Ot)),y(Y,"FontAlignmentCommand",(()=>zt)),y(Y,"UpdateFramePattern",(()=>Lt)),y(Y,"TextChangeCommand",(()=>Tt)),y(Y,"IllustrationColorCommand",(()=>jt)),y(Y,"IllustrationCacheCommand",(()=>Kt)),y(Y,"BringForwardCommand",(()=>Vt)),y(Y,"SendBackwardsCommand",(()=>Wt)),y(Y,"LayerCommand",(()=>Xt)),y({},"generate",(()=>x));const x=()=>{const A=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()};var N={};y(N,"ElementNotFoundError",(()=>pt)),y(N,"findElement",(()=>mt)),y(N,"findLayoutForElement",(()=>ft)),y(N,"updatedLayoutForElement",(()=>Mt)),y(N,"rehydrateSerializedLayout",(()=>yt));var S={};y(S,"CommandContext",(()=>Ct)),y(S,"sortElementsByLayersWithIndex",(()=>It)),y(S,"getSvgString",(()=>Dt)),y({},"SVGLayout",(()=>H));const H=({viewmask:A,viewBox:e,width:n,height:i,position:a,maxWidth:s,maxHeight:o,elements:r,preserveAspectRatio:c,backgroundColor:g,omitBoundClipping:B,borderRadius:l,colorProfiles:w})=>{const h=x(),E=A?`url(#viewmask-${h})`:void 0,d=e||{x:0,y:0,width:n,height:i},Q=`${d.x} ${d.y} ${d.width} ${d.height}`,C=l||0,u=B?void 0:(0,t.jsxs)("defs",{children:[(0,t.jsx)("clipPath",{id:"viewboxClip",children:(0,t.jsx)("rect",{width:d.width,height:d.height,rx:C})}),A&&(0,t.jsxs)("mask",{id:`viewmask-${h}`,children:[(0,t.jsx)("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:"black"}),(0,t.jsx)("rect",{x:A.x,y:A.y,width:A.width,height:A.height,fill:"white"})]})]}),D=w?.map(((A,e)=>(0,t.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},e)));return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",preserveAspectRatio:c,width:n,height:i,style:{gridColumn:1,gridRow:1,maxWidth:s,maxHeight:o,position:a},viewBox:Q,children:[D,u,!!g&&(0,t.jsx)("rect",{id:"layout-background",width:d.width,height:d.height,fill:g,mask:E,rx:C}),(0,t.jsx)("g",{id:"element-group",clipPath:B?void 0:"url(#viewboxClip)",mask:E,children:r})]})};y({},"Image",(()=>hA));var R={};y(R,"getAxisAlignedBoundingBox",(()=>Z)),y(R,"degreesToRadians",(()=>_)),y(R,"findAngle",(()=>$)),y(R,"radiansToDegrees",(()=>AA)),y(R,"isCloseToValue",(()=>tA)),y(R,"getTrueCoordinates",(()=>eA)),y(R,"getPointOfRotation",(()=>nA)),y(R,"getNWPoint",(()=>iA)),y(R,"getNEPoint",(()=>aA)),y(R,"getSWPoint",(()=>sA)),y(R,"getSEPoint",(()=>oA)),y(R,"turnRightClockwise",(()=>rA)),y(R,"currentDirection",(()=>cA)),y(R,"getElementVertices",(()=>gA)),y(R,"rotateAroundPoint",(()=>BA)),y(R,"mmPerPixel",(()=>lA)),y(R,"cmPerPixel",(()=>wA));var v={};let U;var G;let P;var k;let J;var b;let O;var z;let L;var T;let j;var K;let V;var W;let X;var q;y(v,"LayoutElementType",(()=>U)),y(v,"TextAlgorithm",(()=>P)),y(v,"UnitOfMeasurement",(()=>J)),y(v,"ScaleAxis",(()=>O)),y(v,"MaterialEffectMode",(()=>L)),y(v,"AssetType",(()=>j)),y(v,"StepType",(()=>V)),y(v,"StepAspectType",(()=>X)),(G=U||(U={})).Frame="frame",G.Image="image",G.Illustration="illustration",G.Textbox="textbox",(k=P||(P={})).Autosize="Autosize",k.Traditional="Traditional",(b=J||(J={})).Pixel="px",b.Millimeter="mm",b.Centimeter="cm",(z=O||(O={}))[z.North=0]="North",z[z.Northeast=1]="Northeast",z[z.East=2]="East",z[z.Southeast=3]="Southeast",z[z.South=4]="South",z[z.Southwest=5]="Southwest",z[z.West=6]="West",z[z.Northwest=7]="Northwest",(T=L||(L={})).None="None",T.RemoveWhenSelected="RemoveWhenSelected",T.ApplyWhenSelected="ApplyWhenSelected",(K=j||(j={})).Font="Font",K.Frame="Frame",K.Illustration="Illustration",K.Image="Image",K.Model="Model",K.Material="Material",K.Color="Color",K.QuestionnaireCollateral="QuestionnaireCollateral",K.RequestCollateral="RequestCollateral",K.SignupCollateral="SignupCollateral",K.Video="Video",K.ColorProfile="ColorProfile",(W=V||(V={})).Bulk="Bulk",W.DigitalContent="DigitalContent",W.Finish="Finish",W.Frame="Frame",W.Illustration="Illustration",W.Introduction="Introduction",W.Material="Material",W.Model="Model",W.Module="Module",W.Picture="Picture",W.Photo="Photo",W.ProductOverlay="ProductOverlay",W.Question="Question",W.Shape="Shape",W.SilentIllustration="SilentIllustration",W.Text="Text",(q=X||(X={})).Color="Color",q.Colors="Colors",q.Selection="Selection",q.Selections="Selections",q.Text="Text",q.Upload="Upload";const Z=(A,t,e,n,i)=>{const a=_(i),s=e/2,o=n/2,r=A+s,c=t+o,g=Math.sin(a),B=Math.cos(a),l=-o,w=s*B-l*g,h=s*B-o*g,E=s*g+l*B,d=s*g+o*B,Q=Math.max(Math.abs(w),Math.abs(h)),C=Math.max(Math.abs(E),Math.abs(d));return{minX:r-Q,maxX:r+Q,minY:c-C,maxY:c+C}},$=(A,t,e)=>{const n=Math.sqrt(Math.pow(t.x-A.x,2)+Math.pow(t.y-A.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=Math.sqrt(Math.pow(e.x-A.x,2)+Math.pow(e.y-A.y,2));return Math.acos((i*i+n*n-a*a)/(2*i*n))*(180/Math.PI)},_=A=>A*(Math.PI/180),AA=A=>A*(180/Math.PI),tA=(A,t,e)=>Math.abs(A-t)<e,eA=(A,t,e)=>{const n=Math.sin(_(e)),i=Math.cos(_(e));return{x:(A.x-t.x)*i-(A.y-t.y)*n+t.x,y:(A.x-t.x)*n+(A.y-t.y)*i+t.y}},nA=(A,t)=>({x:(A.x+t.x)/2,y:(A.y+t.y)/2}),iA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+t?.y*n}),aA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+t?.y*n}),sA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+(t?.y+t?.height)*n}),oA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+(t?.y+t?.height)*n}),rA=A=>{switch(A){case O.North:return O.East;case O.East:return O.South;case O.South:return O.West;case O.West:return O.North;case O.Northwest:return O.Northeast;case O.Northeast:return O.Southeast;case O.Southeast:return O.Southwest;case O.Southwest:return O.Northwest}},cA=(A,t)=>t>45&&t<=135?rA(A):t>135&&t<=225?rA(rA(A)):t>225&&t<=315?rA(rA(rA(A))):A,gA=(A,t={x:0,y:0},e={x:1,y:1})=>{const n=_(A.rotation),i={x:t.x+A.x*e.x,y:t.x+A.y*e.y},a={x:A.x+A.width,y:A.y},s={x:t.x+(A.x+A.width)*e.x,y:t.y+(A.height+A.y)*e.y},o={x:t.x+A.x*e.x,y:t.y+(A.height+A.y)*e.y},r={x:(o.x+s.x)/2,y:o.y-A.height*e.y/2};return{a:BA(i,r,n),b:BA(a,r,n),c:BA(s,r,n),d:BA(o,r,n),center:r}},BA=(A,t,e)=>{const n=Math.sin(e),i=Math.cos(e);return{x:(A.x-t.x)*i-(A.y-t.y)*n+t.x,y:(A.x-t.x)*n+(A.y-t.y)*i+t.y}},lA=.352778,wA=.035277,hA=A=>{const e=A.rotation||0,n=_(e),i=Math.cos(n),a=-Math.sin(n);return(0,t.jsx)("g",{transform:`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `,children:(0,t.jsx)("image",{xlinkHref:A.src,preserveAspectRatio:A.preserveAspectRatio,width:A.width,height:A.height})})};y({},"Frame",(()=>EA));const EA=A=>{const e=`spiff-frame-${A.id}`,n=`spiff-frame-blur-${A.id}`,i=`spiff-frame-blur-edge-${A.id}`,a=`spiff-frame-focal-mask-${A.id}`,s=!!A.focalBlur&&!!A.pattern,o=A.rotation||0,r=_(o),c=Math.cos(r),g=-Math.sin(r);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("defs",{children:(s=>{const o=A.pattern?.x||0,r=A.pattern?.y||0,c=A.pattern?A.pattern.width*A.pattern.scaleX+Math.abs(o):256,g=A.pattern?A.pattern.height*A.pattern.scaleY+Math.abs(r):256,B=A.pattern?A.pattern.width*A.pattern.scaleX:256,l=A.pattern?A.pattern.height*A.pattern.scaleY:256;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("pattern",{patternUnits:A.pattern?void 0:"userSpaceOnUse",x:0,y:0,width:A.pattern?1:c,height:A.pattern?1:g,"data-frame-width":A.pattern?c:void 0,"data-frame-height":A.pattern?g:void 0,id:e,children:(0,t.jsx)("image",{preserveAspectRatio:"none",x:o,y:r,width:B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EAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),s?(0,t.jsx)(dA,{path:A.path,width:A.width,height:A.height,focalBlurStrength:A.focalBlurStrength||1,focalBlurRadius:A.focalBlurRadius||10,blurFilterId:n,focalMaskId:a,blurEdgeClipId:i}):null]})})(s)}),(0,t.jsxs)("g",{transform:`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${c}, ${-g}, ${g}, ${c}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n matrix(${A.scaleX}, 0, 0, ${A.scaleY}, 0, 0)\n `,children:[(0,t.jsx)("path",{filter:s?`url(#${n})`:void 0,mask:s?`url(#${i})`:void 0,d:A.path,style:{fill:`url(#${e})`,opacity:A.opacity}}),s?(0,t.jsx)("path",{mask:`url(#${a})`,d:A.path,style:{fill:`url(#${e})`,opacity:A.opacity}}):void 0]})]})},dA=A=>{const{path:e,width:n,height:i,focalBlurStrength:a,focalBlurRadius:s,blurFilterId:o,focalMaskId:r,blurEdgeClipId:c}=A;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("filter",{id:o,children:(0,t.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,t.jsx)("mask",{id:r,children:(0,t.jsx)("circle",{cx:n/2,cy:i/2,r:s||0,fill:"white",filter:`url(#${o})`})}),(0,t.jsx)("mask",{id:c,children:(0,t.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};y({},"Textbox",(()=>rt));var QA={};y(QA,"fontSizeStep",(()=>XA)),y(QA,"textWidth",(()=>qA)),y(QA,"applyTextTransformations",(()=>$A)),y(QA,"zip",(()=>_A)),y(QA,"getTextAlignment",(()=>At)),y(QA,"getAnchor",(()=>tt)),y(QA,"recomputeTextOnElement",(()=>et)),y(QA,"defaultLineHeightFactor",(()=>nt)),y({},"calculateTextboxLines",(()=>WA));var CA={};y(CA,"FontMetrics",(()=>OA)),y(CA,"loadFontFromExternalUrl",(()=>LA)),y(CA,"loadFontFromDataUrl",(()=>TA)),y(CA,"getFontMetrics",(()=>jA));var uA={};y(uA,"registerJSDOM",(()=>pA)),y(uA,"createElement",(()=>yA)),y(uA,"createElementNS",(()=>FA)),y(uA,"domParser",(()=>YA)),y(uA,"fetchAsArrayBuffer",(()=>xA)),y(uA,"fetchAsString",(()=>NA)),y(uA,"loadFontFaceSet",(()=>SA)),y(uA,"xmlSerializer",(()=>HA)),y(uA,"toBase64",(()=>RA)),y(uA,"dataUrlFromExternalUrl",(()=>vA)),y(uA,"arrayBufferToDataUrl",(()=>UA)),y(uA,"arrayBufferToBuffer",(()=>PA)),y(uA,"dataUrlToArrayBuffer",(()=>GA));var DA=o.Buffer;let IA;function pA(A){IA=A}function mA(){if(!IA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new IA}if(void 0===F.TextEncoder){const{TextEncoder:A}=r;F.TextEncoder=A}if(void 0===F.TextDecoder){const{TextDecoder:A}=r;F.TextDecoder=A}const fA=new(M(a).Agent)({rejectUnauthorized:!0}),MA=A=>A.every((A=>"undefined"!==A)),yA=A=>MA([typeof document])?document.createElement(A):mA().window.document.createElement(A),FA=(A,t)=>{if(MA([typeof document]))return document.createElementNS(A,t);const e=mA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},YA=()=>MA([typeof DOMParser])?new DOMParser:new(mA().window.DOMParser),xA=A=>{if(MA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.arrayBuffer())})).catch((A=>{e(A)}))}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(i).get(t,{responseType:"arraybuffer",httpsAgent:fA}).then((t=>{A(t.data)})).catch((A=>{e(A)}))}))}},NA=A=>{if(MA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.text())})).catch(e)}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(i).get(t,{responseType:"text",httpsAgent:fA}).then((t=>{A(t.data)})).catch(e)}))}},SA=async(A,t)=>{if(MA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},HA=()=>MA([typeof XMLSerializer])?new XMLSerializer:new(mA().window.XMLSerializer),RA=A=>MA([typeof btoa])?btoa(A):DA.from(A).toString("base64"),vA=async A=>{if(MA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await JA(e)}const t=(await M(i).get(A,{responseType:"arraybuffer"})).data;return UA(t)},UA=async A=>{const t=await(async A=>{const t=await(0,s.fromBuffer)(A);return t?t.mime:"image/svg+xml"})(A);return`data:${t};base64,${PA(A).toString("base64")}`},GA=A=>{const t=A.replace(/\r?\n/g,""),e=t.indexOf(",");if(-1===e||e<=4)throw new TypeError("malformed data: URI");const n=t.substring(5,e).split(";");let i=!1;for(let A=1;A<n.length;A++)"base64"===n[A]&&(i=!0);const a=i?"base64":"ascii",s=unescape(t.substring(e+1)),o=DA.from(s,a);return kA(o)},PA=A=>DA.from(A),kA=A=>{const t=new ArrayBuffer(A.byteLength),e=new Uint8Array(t);for(let t=0;t<A.length;++t)e[t]=A[t];return t},JA=A=>new Promise(((t,e)=>{const n=new FileReader;n.onload=function(A){const n=A.target;n&&n.result?t(n.result.toString()):e()},n.readAsDataURL(A)})),bA=new Map;class OA{constructor(A){this.font=A,this.glyphsFromText=new Map,this.kerningValues=new Map,this.height=this.calculateApproximateHeight()}getFont(){return this.font}getGlyphs(A){const t=this.glyphsFromText.get(A);if(t)return t;const e=this.font.stringToGlyphs(A);return this.glyphsFromText.set(A,e),e}getApproximateHeight(){return this.height}getExactHeight(A){const t=this.font.stringToGlyphs(A);let e=0,n=0;return t.forEach((A=>{const t=A.getMetrics();e=Math.max(e,t.yMax),n=Math.min(n,t.yMin)})),e-n}getKerningValue(A,t){let e=this.kerningValues.get(A.name);e||(e=new Map,this.kerningValues.set(A.name,e));let n=e.get(t.name);return n||(n=this.font.getKerningValue(A,t),e.set(t.name,n)),n}calculateApproximateHeight(){const A=this.font.stringToGlyphs("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");let t=0,e=0;return A.forEach((A=>{const n=A.getMetrics();t=Math.max(t,n.yMax),e=Math.min(e,n.yMin)})),t-e}}const zA=A=>"data:"===A.substring(0,5).toLowerCase().trim(),LA=async A=>{const t=zA(A)?TA(A):TA(await vA(A));return KA(t,{assetUrl:zA(A)?A:await vA(A),name:t.names.fullName.en}),await SA(t,A),t},TA=A=>{const t=GA(A),e=M(n).parse(t);return KA(e,{assetUrl:A,name:e.names.fullName.en}),e},jA=A=>{const t=bA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},KA=(A,t)=>{const e=new OA(A);return bA.set(t.name,e),e},VA=(A,t,e,n)=>{if(qA(A,e,n)<=t)return[A];if(!(A.indexOf(" ")>-1)){if(A.length<=1)throw new Error(`Character ${A} is wider than region`);const t=Math.floor(A.length/2);return[A.slice(0,t),A.slice(t)]}const i=A.split(" "),a=[];let s=0;for(;s<i.length;){const A=i[s];if(qA(A,e,n)>t)a.push(...VA(A,t,e,n)),s++;else{const o=[A];let r=s+1,c=!0;for(;r<i.length&&c;){const A=i[r];qA(`${o.join(" ")} ${A}`,e,n)<=t?(o.push(A),r++):c=!1}a.push(o.join(" ")),s=r}}return a},WA=(A,t,e,n,i)=>{const a=jA(t),s=a.getFont();return((A,t,e,n,i,a)=>{const s=a||nt,o=t.split("\n");try{const t=o.flatMap((t=>VA(t,A.width,n,i)));return{lines:t,requiredHeight:t.length*(e*s)}}catch(A){return console.error(A),{lines:[],requiredHeight:0}}})(e,$A(n),A,A/s.unitsPerEm,a,i)},XA=1,qA=(A,t,e)=>{let n=0;const i=e.getGlyphs(A);return i.forEach(((A,t)=>{if(A.advanceWidth&&(n+=A.advanceWidth),t<i.length-1){const a=e.getKerningValue(A,i[t+1]);n+=a}})),n*=t,n},ZA={stripControlCharacters:!0,vertical:!1,uppercase:!1},$A=(A,t=ZA)=>{const e={...ZA,...t};let n=A;return e.stripControlCharacters&&(n=n.replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g,"")),e.uppercase&&(n=n.toUpperCase()),e.vertical&&(n=n.split("").join("\n")),n},_A=(A,t)=>A.map(((A,e)=>[A,t[e]])),At=(A="center",t=!1)=>t?"center":A,tt=A=>"left"===A?"start":"right"===A?"end":"middle",et=(A,t)=>A.fontData?{...A,...(()=>{if(A.algorithm===P.Traditional){const e=WA(A.fontSize,A.fontData,A,t,A.lineHeight);return{text:e.lines.join("\n"),height:e.requiredHeight,input:t}}return{text:t}})()}:A,nt=1.1;var it={};y(it,"colorDefinitionPrintValue",(()=>at)),y(it,"spotColorDefinitionString",(()=>st)),y(it,"svgColorValueToDefinition",(()=>ot));const at=A=>{const t=st(A.spotColor);return t?`${A.browserValue} ${t}`:A.browserValue},st=A=>{if(!A)return"";if(A.profileName.includes("/")&&A.profileName.includes(".icc")){const t=A.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${A.namedColor})`}return`icc-named-color(${A.profileName}, ${A.namedColor})`},ot=A=>{const t=A.split(/[ ](?=[^)]*?(?:\(|$))/);if(0===t.length)return{browserValue:"#000000"};if(1===t.length)return{browserValue:t[0]};const e=t[1].match(/\(([^)]+)\)/gm);if(!e)throw new Error("Unhandled state of color value in SVG");const n=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:n[0],namedColor:n[1]}}},rt=A=>{const e=(A.rotation||0)*Math.PI/180,n=Math.cos(e),i=-Math.sin(e),a=`text-path-${A.id}`,s=A.x+(A.curved?0:A.width/2),o=A.y+(A.curved?0:A.height/2),r=(A.text||"").split("\n");return A.curved&&!A.paths?null:A.fontData?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("defs",{children:[(0,t.jsx)("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`\n @font-face {\n font-family: '${A.fontData.name}';\n src: url('${A.fontData.assetUrl}') format('truetype');\n }\n `}}),A.curved&&A.paths?(0,t.jsx)("path",{id:a,d:A.paths[0]}):void 0]}),A._renderingConfiguration?.debug?(0,t.jsx)("rect",{stroke:"blue",fill:"none",x:A.x,y:A.y,width:A.width,height:A.height}):void 0,(0,t.jsx)("g",{transform:`matrix(${n}, ${-i}, ${i}, ${n}, ${s}, ${o})`,children:(0,t.jsx)("text",{xmlSpace:"preserve",fontFamily:`'${A.fontData.name}'`,fontSize:A.fontSize,fontStyle:"normal",fontWeight:"normal",fill:A._renderingConfiguration?.spotColors&&A.fillSpotColorDefinition?`${A.fill} ${st(A.fillSpotColorDefinition)}`:A.fill,style:{whiteSpace:"pre",userSelect:"none"},children:A.curved?(0,t.jsx)(gt,{text:A.text||"",curvedPathId:a,align:A.align}):r.map(((e,n)=>(0,t.jsx)(ct,{align:A.vertical?"center":A.align,fontSize:A.fontSize,thisLineIdx:n,amountLines:r.length,text:e,textboxHeight:A.height,textboxWidth:A.width,lineHeight:A.lineHeight,vertical:A.vertical,verticalAlign:A.verticalAlign},n)))})})]}):null},ct=A=>(0,t.jsx)("tspan",{textAnchor:tt(A.align),x:"left"===A.align?-A.textboxWidth/2:"right"===A.align?A.textboxWidth/2:0,y:`${(()=>{const t=A.fontSize*(void 0!==A.lineHeight?A.lineHeight:nt),e=A.textboxHeight/2;if("top"===A.verticalAlign)return-e+3*A.fontSize/4+A.thisLineIdx*t;if("bottom"===A.verticalAlign){const n=A.amountLines-1-A.thisLineIdx;return e-A.fontSize/4-n*t}const n=(A.amountLines-1)/2;return(A.thisLineIdx-n)*t+A.fontSize/4})()}px`,children:A.text}),gt=A=>{const e=`#${A.curvedPathId}`;return(0,t.jsx)("textPath",{startOffset:"left"===A.align?"0%":"right"===A.align?"100%":"50%",textAnchor:tt(A.align),href:e,xlinkHref:e,children:A.text})};y({},"Illustration",(()=>Qt));var Bt={};y(Bt,"traverse",(()=>wt)),y(Bt,"sanitizeSvgTree",(()=>ht)),y(Bt,"modifySVGWithElementProperties",(()=>Et)),y(Bt,"generateSVGWithUnknownColors",(()=>dt));const lt=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],wt=(A,t)=>{t(A),A.children.length>0&&Array.from(A.children).forEach((A=>wt(A,t)))},ht=(A,t=!1)=>{!t&&A.setAttribute("preserveAspectRatio","none");const e=[];wt(A,(A=>{if("script"!==A.tagName)if("style"!==A.tagName);else try{(0,c.parse)(A.innerHTML).stylesheet?.rules.forEach((A=>{e.push(A)})),A.remove()}catch(A){console.error(A)}else A.remove()})),wt(A,(A=>{e.forEach((t=>{t.selectors?.forEach((e=>{((A,t)=>{try{return A.matches(t)}catch(e){return A.classList.contains(t.substring(1))}})(A,e)&&t.declarations?.forEach((t=>{t.property&&t.value&&A.setAttribute(t.property,t.value)}))}))}))}))},Et=(A,t,e,n,i)=>{const a=(A=>YA().parseFromString(A,"image/svg+xml").firstElementChild)(A);if(!a)throw new Error("Failed to read SVG.");return((A,t,e)=>{A.setAttribute("height",`${e}px`),A.setAttribute("width",`${t}px`)})(a,t,e),((A,t,e)=>{wt(A,(A=>{const n=A.attributes.getNamedItem("fill");n&&"none"!==n.value&&A.classList.forEach((n=>{if(n.startsWith("spiff-fill")){const i=t[n];i&&A.setAttribute("fill",e?at(i):i.browserValue)}}));const i=A.attributes.getNamedItem("stroke");i&&"none"!==i.value&&A.classList.forEach((n=>{if(n.startsWith("spiff-stroke")){const i=t[n];i&&A.setAttribute("stroke",e?at(i):i.browserValue)}}))}))})(a,n,i),(A=>HA().serializeToString(A))(a)},dt=async A=>{const t=A.match(/<svg.*?<\/svg>/s)||[],e=t?.length>0?t[0]:"",n=YA().parseFromString(e,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");ht(n);const i={};wt(n,(A=>{lt.includes(A.tagName)&&!A.attributes.getNamedItem("fill")&&A.setAttribute("fill","black");const t=A.attributes.getNamedItem("fill");if(t&&"none"!==t.value){const e=ot(t.value),n=`spiff-fill-${e.browserValue.replace(/\W/g,"")}`;A.setAttribute("fill",e.browserValue),A.classList.add(n),i[n]=e}const e=A.attributes.getNamedItem("stroke");if(e&&"none"!==e.value){const t=ot(e.value),n=`spiff-stroke-${t.browserValue.replace(/\W/g,"")}`;A.classList.add(n),A.setAttribute("stroke",t.browserValue),i[n]=t}}));const a=HA().serializeToString(n);return{colors:i,svg:a}},Qt=A=>{if(A.cachedObjectURL&&!A._renderingConfiguration?.omitCachedFields)return(0,t.jsx)(hA,{id:A.id,src:A.cachedObjectURL,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,preserveAspectRatio:"none",immutable:A.immutable});const e=A.rotation||0,n=_(e),i=Math.cos(n),a=-Math.sin(n),s=`\n matrix(1, 0, 0, 1, ${A.x}, ${A.y})\n matrix(1, 0, 0, 1, ${A.width/2}, ${A.height/2})\n matrix(${i}, ${-a}, ${a}, ${i}, 0, 0)\n matrix(1, 0, 0, 1, ${-A.width/2}, ${-A.height/2})\n `;if(!A.svg)throw new Error(`Illustration element ${A.id} (stepName ${A.stepName}) lacked svg from src ${A.src} at render time.`);return(0,t.jsx)("g",{transform:s,dangerouslySetInnerHTML:{__html:Et(A.svg,A.width,A.height,A.colors,A._renderingConfiguration?.spotColors)}})};class Ct{constructor(){this.id=x(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(A){A(),this.stateCallbacks.push(A)}unregisterStateCallback(A){this.stateCallbacks.filter((t=>t!==A))}getState(){return this.state}runStateCallbacks(){this.stateCallbacks.forEach((A=>A()))}apply(A,t){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.nextCommands=[],t||this.prevCommands.push(A)}undo(){if(!this.state)return;const A=this.prevCommands.pop();if(!A)return;const t=A.undo();A.varying?this.state={...this.state,variation:t}:this.state={...this.state,transaction:t},this.nextCommands.push(A),this.runStateCallbacks()}redo(){if(!this.state)return;const A=this.nextCommands.pop();A&&(this.state=this.commandReducer(this.state,A),this.runStateCallbacks(),this.prevCommands.push(A))}flattenSequence(A,t){const e=this.prevCommands.filter((t=>t.sequenceId===A)).pop();e&&(this.prevCommands=this.prevCommands.filter((t=>t.sequenceId!==A)),e?.overrideOldState(t),this.prevCommands.push(e))}getLayoutById(A){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const t=this.state.transaction?.layouts?.[A],e=this.state.variation?.layouts?.[A],n=t?.layout||e?.layout;if(!n)throw new Error(`No layout: ${A}`);const i=[...t?.elements||[],...e?.elements||[]];return this.getLayoutDataWithState(n,i)}getAllLayouts(){if(!this.state)throw new Error(`State not initialized for cc ${this.id}!`);const A=[...Object.keys(this.state.transaction?.layouts),...Object.keys(this.state.variation?.layouts||{})];return[...new Set(A)].map((A=>this.getLayoutById(A)))}getLayoutDataWithState(A,e){const n=It([...e]).map((A=>ut(A))),i={width:A.width,height:A.height,viewBox:{x:0,y:0,width:A.width,height:A.height}},a={backgroundColor:A.transparentBackground?void 0:"white",elements:n};return{layoutState:{layout:A,elements:e},Component:(0,t.jsx)(H,{...a,...i}),getComponentWithProps:A=>(0,t.jsx)(H,{...a,...i,...A})}}initialize(A,t){if(t)return void(this.state={transaction:t});let e={serializableWorkflow:{steps:[]},layouts:{}};A.forEach((A=>{e=new Rt(A).apply(e)})),this.runStateCallbacks(),this.state={transaction:e}}commandReducer(A,t){if(t.varying){const e={layouts:{},serializableWorkflow:{steps:[]},...A.variation};return{...A,variation:t.apply(e)}}{const e=A.transaction||{layouts:{},serializableWorkflow:{steps:[]}};return{...A,transaction:t.apply(e)}}}}const ut=A=>"image"===A.type?(0,t.jsx)(hA,{...A},A.id):"frame"===A.type?(0,t.jsx)(EA,{...A},A.id):"illustration"===A.type?(0,t.jsx)(Qt,{...A},A.id):"textbox"===A.type?(0,t.jsx)(rt,{...A},A.id):null,Dt=(A,n,i)=>{const a={backgroundColor:A.transparentBackground?void 0:"white"},s={width:i?.region?i.region.width:A.width,height:i?.region?i.region.height:A.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:A.width,height:A.height}},o=It((i?.removeExcludedElements?n.filter((A=>!A.excludeFromExport)):n).map((A=>({...A,_renderingConfiguration:i}))));try{return M(e).renderToStaticMarkup((0,t.jsx)(H,{preserveAspectRatio:"none",...a,...s,elements:o.map((A=>ut(A))).filter((A=>!!A)),omitBoundClipping:i?.omitClipMask,colorProfiles:i?.colorProfiles?i.colorProfiles:void 0}))}catch(A){return console.error("Error rendering to static markup"),console.error(A),""}};function It(A){return A.sort(((A,t)=>{const e=A.layer||0,n=t.layer||0;if(e<n)return-1;if(e>n)return 1;const i=A.layerIndex||0,a=t.layerIndex||0;return i<a?-1:i>a?1:0}))}class pt extends Error{constructor(A){super("No element found with ID: "+A),Object.setPrototypeOf(this,pt.prototype)}}const mt=(A,t)=>ft(A,t).elements.find((t=>t.id===A)),ft=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new pt(A);return e},Mt=(A,t)=>{const e=It([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:x()}},yt=async(A,t)=>{const e=[...Object.keys(A.layouts),...Object.keys(t?.layouts||{})],n=[...new Set(e)];for(let e=0;e<n.length;e++){const i=n[e],a=A.layouts[i],s=t?.layouts[i],o=(a||s).elements.filter((A=>"illustration"===A.type));for(let A=0;A<o.length;++A){const t=o[A];if(t.src&&!t.svg){const A=await NA(t.src),e=await dt(A);t.svg=Et(e.svg,t.width,t.height,t.colors)}}}};class Ft{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(A){this.oldState=A}}class Yt extends Ft{constructor(A){super(),this.serializableWorkflow=A}apply(A){return this.oldState=A,{...A,serializableWorkflow:this.serializableWorkflow}}}class xt extends Ft{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,x:this.x,y:this.y},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Nt extends Ft{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,rotation:this.angle},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class St extends Ft{constructor(A,t,e){super(),this.id=A,this.width=Math.abs(t),this.height=Math.abs(e)}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,width:this.width,height:this.height};if("frame"===t.type){const A=e;A.scaleX=A.scaleX*this.width/t.width,A.scaleY=A.scaleY*this.height/t.height}const n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ht extends Ft{constructor(A){super(),this.commands=A}apply(A){return this.oldState=A,this.commands.reduce(((A,t)=>t.apply(A)),A)}}class Rt extends Ft{constructor(A){super(),this.layout=A}apply(A){return this.oldState=A,{...A,layouts:{...A.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:x()}}}}}class vt extends Ft{constructor(A){super(),this.panelName=A}apply(A){this.oldState=A;const t=Object.values(A.layouts).map((A=>{const t=A.layout.panelId===this.panelName;return{...A,elements:t?[]:[...A.elements],modificationID:x()}})),e={};return t.forEach((A=>{e[A.layout.id]=A})),{...A,layouts:e}}}class Ut extends Ft{constructor(A,t){super(),this.element=A,this.layout=t}apply(A){this.oldState=A,A.layouts[this.layout.id]||(A.layouts[this.layout.id]={layout:this.layout,elements:[],modificationID:""});const t=A.layouts[this.layout.id].elements;if(t.find((A=>A.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===t.length){const e=[...t,this.element];return void 0===this.element.layerIndex&&(this.element.layerIndex=this.assignIndex(this.element,e)),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:e,modificationID:x()}}}}const e=t[t.length-1],n=e.productOverlay?e:null;let i;if(n&&t.pop(),null!==this.element.layerIndex&&void 0!==this.element.layerIndex)i=[...t,this.element].sort(((A,t)=>void 0!==A.layerIndex&&void 0!==t.layerIndex?A.layerIndex-t.layerIndex:0));else{const A=this.assignIndex(this.element,t);this.element.layerIndex=void 0!==A?A:0,i=[...t,this.element]}return n&&i.push(n),{...A,layouts:{...A.layouts,[this.layout.id]:{...A.layouts[this.layout.id],elements:i,modificationID:x()}}}}assignIndex(A,t){if(0===t.length)return 0;const e=t.filter((t=>(t.layer||0)===(A.layer||0))).sort(((A,t)=>(A.layerIndex||0)-(t.layerIndex||0)))[t.length-1]?.layerIndex;return void 0!==e?e+1:0}}class Gt extends Ft{constructor(A){super(),this.id=A}apply(A){this.oldState=A;let t=!1;const e=Object.values(A.layouts).map((A=>(A.elements.filter((A=>A.id!==this.id)).length!==A.elements.length&&(t=!0),{...A,elements:A.elements.filter((A=>A.id!==this.id)),modificationID:x()})));t||console.log(`Failed to delete element ${this.id}`);const n={};return e.forEach((A=>{n[A.layout.id]=A})),{...A,layouts:n}}}class Pt extends Ft{constructor(t,e){super(),this.el=M(A)(t),this.layout=e,this.el.id=x(),this.el.x+=5,this.el.y+=5}apply(A){return this.oldState=A,new Ut(this.el,this.layout).apply(A)}}class kt extends Ft{constructor(A,t,e){super(),this.id=A,this.color=t,this.textFillSpotColor=e}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Jt extends Ft{constructor(A,t){super(),this.id=A,this.size=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,fontSize:this.size},n=ft(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==P.Autosize?e.input||"":e.text||"",a=Mt(et(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class bt extends Ft{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,algorithm:this.algorithm},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ot extends Ft{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,fontData:this.fontData},n=ft(t.id,Object.values(A.layouts)),i=Mt(et(e,e.input||""),n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class zt extends Ft{constructor(A,t){super(),this.id=A,this.align=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,align:this.align},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Lt extends Ft{constructor(A,t,e){super(),this.id=A,this.imageData=t,this.offsets=e}apply(A){this.oldState=A;const t=ft(this.id,Object.values(A.layouts)),e=t.elements.findIndex((A=>A.id===this.id)),n=t.elements[e].pattern,i=[...t.elements];i.splice(e,1,{...t.elements[e],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={...t,elements:i,modificationID:x()};return{...A,layouts:{...A.layouts,[t.layout.id]:a}}}}class Tt extends Ft{constructor(A,t){super(),this.id=A,this.text=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e=ft(t.id,Object.values(A.layouts)),n=Mt(et(t,this.text),e);return{...A,layouts:{...A.layouts,[e.layout.id]:n}}}}class jt extends Ft{constructor(A,t,e){super(),this.id=A,this.className=t,this.fill=e}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e=t.colors||{},n=e[this.className];e[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...t,colors:e},a=ft(t.id,Object.values(A.layouts)),s=Mt(i,a);return{...A,layouts:{...A.layouts,[a.layout.id]:s}}}}class Kt extends Ft{constructor(A,t,e){super(),this.id=A,this.svgBody=t,this.objectURL=e}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=ft(t.id,Object.values(A.layouts)),i=Mt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Vt extends Ft{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!mt(this.id,Object.values(A.layouts)).id)throw new pt(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e+1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:x()}}}}}class Wt extends Ft{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!mt(this.id,Object.values(A.layouts)).id)throw new pt(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e-1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:x()}}}}}class Xt extends Ft{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=mt(this.id,Object.values(A.layouts));if(!t.id)throw new pt(this.id);const e=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!e)throw new Error("Layout missing from state!");return{...A,layouts:{...A.layouts,[e.layout.id]:Mt({...t,layer:this.value},e)}}}}var qt={};y(qt,"patternImageDataCache",(()=>ne)),y(qt,"frameDataCache",(()=>ie)),y(qt,"generateFrameSVG",(()=>ae)),y(qt,"generateDefaultRectangleFrameSvg",(()=>se)),y(qt,"getVariant",(()=>oe)),y(qt,"getFrameData",(()=>re)),y(qt,"calculateOffsets",(()=>ce)),y(qt,"getPatternImageData",(()=>ge)),y(qt,"GetSVGDimensions",(()=>Be)),y(qt,"svgStringDimensions",(()=>le));var Zt={};y(Zt,"getExifOrientation",(()=>_t)),y(Zt,"canvasDims",(()=>Ae)),y(Zt,"getAttributesFromArrayBuffer",(()=>te));let $t=null;const _t=A=>new Promise((t=>{const e=PA(A);(0,s.fromBuffer)(A).then((A=>{const n=A?.mime;if("image/jpeg"!==n)return t(1);(new(0,B.ExifImage)).loadImage(e,((A,e)=>t(A?1:e.image.Orientation||1)))}))})),Ae=A=>{const t=8192,e=A.naturalWidth/A.naturalHeight;return A.naturalHeight<=t&&A.naturalWidth<=t?[A.naturalWidth,A.naturalHeight]:A.naturalHeight>A.naturalWidth?[e*t,t]:[t,t/e]},te=async A=>{const t=await(async A=>{const t=await UA(A),e=await(0,g.loadImage)(t),[n,i]=Ae(e),a=await(async()=>{if(null!==$t)return!$t;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return $t=2===A.width&&3===A.height,!$t})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const s=await _t(A),[o,r]=s>4?[i,n]:[n,i],c=(0,g.createCanvas)(o,r),B=c.getContext("2d");switch(s){case 2:B.translate(o,0),B.scale(-1,1);break;case 3:B.translate(o,r),B.rotate(Math.PI);break;case 4:B.translate(0,r),B.scale(1,-1);break;case 5:B.rotate(-.5*Math.PI),B.scale(-1,1);break;case 6:B.rotate(-.5*Math.PI),B.translate(-o,0);break;case 7:B.rotate(-.5*Math.PI),B.translate(-o,r),B.scale(1,-1);break;case 8:B.rotate(.5*Math.PI),B.translate(0,-r)}return B.drawImage(e,0,0,o,r),c})(A);return"image/jpeg"===(await(0,s.fromBuffer)(A))?.mime?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}};y({},"getDefaultVariant",(()=>ee));const ee=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},ne=new Map,ie=new Map,ae=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return se(A)}return NA(t)},se=A=>{const t=A.width,e=t/A.height,n=Math.max(t,512),i=n/e;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 `},oe=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||ee(t.data);if(!e)throw new Error(`No variant with ID: ${A.frameVariantId}`);if(!e.asset)throw new Error(`No asset for variant with ID: ${A.frameVariantId}`);return e},re=async A=>{const t=YA().parseFromString(A,"image/svg+xml"),e=t.querySelector("svg");if(!e)throw new Error("Malformed frame SVG: <svg> tag not found");const n=e.getAttribute("viewBox");if(!n)throw new Error("SVG missing viewBox.");const i=n.split(" "),a=parseFloat(i[3])||1,s=parseFloat(i[2])||1,o=t.getElementById("target-path"),r=t.getElementsByClassName("st0").item(0);if(o){const A=o.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:s,height:a};return ie.set(A,t),t}if(r){const A=r.getAttribute("d");if(!A)throw new Error("Malformed frame SVG: 'd' attribute not found on target element");const t={path:A,width:s,height:a};return ie.set(A,t),t}throw new Error("Malformed frame SVG")},ce=(A,t,e)=>{const n=t.width>=t.height,i=A.width>=A.height,a=t.width/2,s=t.height/2,o=(n?t.height:t.width)/(i?A.height:A.width),r=e?.scale||o,c=a-A.width/2*r,g=e?.left||c,B=s-A.height/2*r;return{x:g,y:e?.top||B,zoom:r}},ge=async A=>{if(ne.has(A))return ne.get(A);if(A.endsWith("svg")){const t=await Be(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return ne.set(A,i),i}{const t=await xA(A),e=await te(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return ne.set(A,n),n}},Be=async A=>{const t=await fetch(A),e=await t.text();return le(e)},le=A=>{const t=(new DOMParser).parseFromString(A,"image/svg+xml").querySelector("svg");if(!t)throw new Error("No svg tag found, this svg must be malformed!");const e=t.getAttribute("viewBox"),n=t.getAttribute("width"),i=t.getAttribute("height"),a=e?e?.split(" ").map((A=>Number(A))):[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 we={};y(we,"determineCorrectFontSizeAndLines",(()=>Ee)),y(we,"determineCorrectTextboxRegion",(()=>de));const he=(A,t,e,n,i)=>{let a=t.map((A=>A.split("\n"))).flat(),s=a.length,o=a.map((A=>qA(A,n,i)));const r=i.getApproximateHeight()*n;let c=!0;for(;c;){if(r+(s-1)*e>A.height)return[null,null];const t=Math.max(...o);if(t<=A.width)return[a,t];const g=o.reduce(((A,t,e,n)=>t>n[A]?e:A),0),B=a[g];let l=!1,w=B.length;for(;!l&&w>-1;){w=B.lastIndexOf(" ",w-1);const t=[B.slice(0,w),B.slice(w+1)],e=t.map((A=>qA(A,n,i)));e[0]<=A.width&&(a=[...a.slice(0,g),...t,...a.slice(g+1)],o=[...o.slice(0,g),...e,...o.slice(g+1)],s+=1,l=!0)}l||(c=!1)}return[null,null]},Ee=(A,t,e,n,i)=>{let a,s;const o=jA(t),r=o.getFont();if(i.size){const t=A/r.unitsPerEm;return[a,s]=he(e,n,A,t,o),[i.size,a,s]}let c=6-XA;if(n.length>0){let A=n,t=0;for(;(!i.maxSize||c<=i.maxSize)&&A;)c+=XA,t=c/r.unitsPerEm,[A,s]=he(e,n,c,t,o)}c>6&&(c-=XA),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/r.unitsPerEm;return[a,s]=he(e,n,c,g,o),[c,a,s]},de=(A,t,e,n,i)=>{let a={...A},s={...A},[o,r,c]=Ee(e,t,s,n,{size:0,minSize:e,maxSize:e});var g,B;return c&&c<a.width&&(s.width=c,"left"===i?(s.left+=Math.sin(a.rotation*Math.PI/360)*(a.width-c),s.top+=Math.sin(a.rotation*Math.PI/180)*(c-a.width)/2):s.left+="right"===i?a.width-c:(a.width-c)/2,[o,r]=Ee(e,t,s,n,{size:e}),o===e&&r&&(g=n,B=r,g.map(((A,t)=>[A,B[t]]))).every((([A,t])=>A===t))&&(a=s)),a};y({},"LayoutElementFactory",(()=>Ce));const Qe=(A,t)=>{const e=A.layoutState.elements.filter((A=>A.layer===t)),n=Math.max(...e.map((A=>A.layerIndex)).filter((A=>void 0!==A)));return Math.max(n,0)+1};class Ce{static async getFrame(A,t){const e=await ae(t.region,t.src),n=await re(e);return{id:x(),x:t.region.left,y:t.region.top,width:t.region.width,height:t.region.height,layer:t.region.layer||0,layerIndex:t.region.layerIndex||Qe(A,t.region.layer||0),rotation:t.region.rotation,scaleX:t.region.width/n.width,scaleY:t.region.height/n.height,path:n.path,type:U.Frame,disablePlaceholder:t.configuration.disablePlaceholder,focalBlur:t.configuration.focalBlur,focalBlurStrength:t.configuration.focalBlurStrength,focalBlurRadius:t.configuration.focalBlurRadius,pattern:void 0,immutable:t.region.immutable}}static async getImage(A,t){let e;if(t.layout){const A=(A=>{const t=(A.layoutState.layout.width<A.layoutState.layout.height?A.layoutState.layout.width:A.layoutState.layout.height)/2;return{top:A.layoutState.layout.height/2-t/2,left:A.layoutState.layout.width/2-t/2,width:t,height:t,rotation:0,panelId:A.layoutState.layout.panelId}})(t.layout),n=A.height,i=await fetch(t.src),a=await i.arrayBuffer(),s=await te(a),o=s.width/s.height;A.height=A.width/o,A.top+=(n-A.height)/2,e=A}else e=t.region;return e||(e={left:0,top:0,width:100,height:100,layer:0,layerIndex:1,rotation:0,panelId:"",immutable:!1}),{id:x(),src:t.src,type:U.Image,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||Qe(A,e.layer||0),immutable:e.immutable,preserveAspectRatio:"none"}}static async getTextbox(A,t){const{region:e,configuration:n,fontSrc:i,designInputStep:a}=t,s={assetUrl:i,name:(await LA(i)).names.fullName.en},o=a?.text||n.defaultText||"",r=n.replaceableText?n.replaceableText.replace("{{}}",o):o,c=$A(r,{vertical:n.vertical,uppercase:n.uppercase}),g=et({id:x(),type:U.Textbox,x:e.left,y:e.top,width:e.width,height:e.height,align:At(n.textAlign,n.vertical),curved:n.curved,fill:a?.color||n.colour||"#000000",fontData:s,layer:e.layer||0,layerIndex:e.layerIndex||Qe(A,t.region.layer||0),paths:n.paths,rotation:e.rotation,vertical:n.vertical,verticalAlign:n.verticalAlign||"middle",algorithm:P.Traditional,fontSize:n.size||18,text:c,input:o},c),B=de({...e,height:g.height},s,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:B.left,y:B.top,width:B.width,height:B.height}}static async getShape(A,t){const e=`\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="${t.color}"\n />\n </svg>\n `,n={};n["spiff-fill-shape"]={browserValue:t.color};const i=x();return{stepRegion:t.region,colors:n,id:i,svg:e,type:U.Illustration,y:t.region.top,x:t.region.left,rotation:t.region.rotation,width:t.region.width,height:t.region.height,layer:t.region.layer||0,layerIndex:t.region.layerIndex||Qe(A,t.region.layer||0),immutable:t.region.immutable}}}function ue(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class De extends Error{constructor(A){super(A),this.name=this.constructor.name}}class Ie extends De{constructor(A){super(`ConfigurationError - ${A}`)}}class pe extends Ie{constructor(A){super(`Option not Configured: ${A.stepTitle}`),ue(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class me extends Ie{constructor(A){super(`Panel not Found: ${A.panelId}`),ue(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class fe extends Ie{constructor(A){super(`Asset not found for variant: ${A.name}`),ue(this,"variant",void 0),this.variant=A}}class Me extends Ie{constructor(A){super(`Resource not found for asset: ${A.name}`),ue(this,"asset",void 0),this.asset=A}}class ye extends Ie{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),ue(this,"step",void 0),this.step=A}}class Fe extends De{constructor(A){super(`ImplementationError - ${A}`)}}class Ye extends Fe{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class xe extends Fe{constructor(A){super(`Parsing Error: ${A}`)}}class Ne extends Fe{constructor(A){super(`Client Error: ${A}`)}}class Se extends Fe{constructor(A){super(`Resource Generation Failed: ${A}`)}}class He{get(A){return localStorage.getItem(A)||void 0}set(A,t){localStorage.setItem(A,t)}remove(A){localStorage.removeItem(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}class Re{constructor(){var A,t,e;A=this,t="storage",e=new Map,t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e}get(A){return this.storage.get(A)||void 0}set(A,t){this.storage.set(A,t)}remove(A){this.storage.delete(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}const ve=(()=>{try{return localStorage?new He:new Re}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Re}})();function Ue(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ge=new class{constructor(){Ue(this,"defaultServerUrl","https://api.spiff.com.au"),Ue(this,"defaultServicesApiUrl","https://services.spiff.com.au"),Ue(this,"defaultHubUrl","https://hub.spiff.com.au"),Ue(this,"serverUrl",void 0),Ue(this,"servicesApiUrl",void 0),Ue(this,"hubUrl",void 0),Ue(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(A){this.serverUrl=A,this.serverUrlCallbacks.forEach((A=>A()))}setServicesApiUrl(A){this.servicesApiUrl=A}setHubUrl(A){this.hubUrl=A}addServerUrlCallback(A){this.serverUrlCallbacks.push(A)}};function Pe(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let ke;const Je=A=>{ke=A},be=async()=>{const A={transactionOwnerId:ke};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=Ge.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void A({});const e=n=>{n.origin===t&&(window.removeEventListener("message",e),A(n.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))})),...A}:A};const Oe=new class{constructor(){Pe(this,"client",void 0),Pe(this,"uncachedOperations",[]),Ge.addServerUrlCallback((async()=>{this.client=void 0,this.client=await this.constructClient()}))}setUncachedOperations(A){this.uncachedOperations=A}async execute(A,t){const e=this.uncachedOperations.includes(A)?A+"_private":A;return new Promise(((A,n)=>{this.getClient().then((i=>{i.execute({operationId:e,parameters:t}).then((t=>A(t))).catch((A=>{A.response&&A.response.status&&A.response.status>=500||(!A.response&&n(new Error(A)),A.response&&n(new Error(`${A.response.status} ${A.response.url}`)))}))})).catch((A=>{n(A)}))}))}async syncAuth(A){const t=await be();if(t.bearer?A.authorizations={...A.authorizations,OAuth2:{token:{access_token:t.bearer,token_type:"Bearer"}}}:A.authorizations={...A.authorizations,OAuth2:{token:{access_token:"",token_type:"Bearer"}}},t.activeIntegration)A.authorizations={...A.authorizations,ActiveIntegration:t.activeIntegration};else{const t={...A.authorizations};delete t.ActiveIntegration,A.authorizations=t}if(t.partnerId)A.authorizations={...A.authorizations,PartnerId:t.partnerId};else{const t={...A.authorizations};delete t.PartnerId,A.authorizations=t}}async getClient(){return this.client||(this.client=await this.constructClient()),this.syncAuth(this.client),Promise.resolve(this.client)}async constructClient(){const A=await be(),t=Ge.getServerUrl()+"/v2/api-docs";return await M(l)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const ze=new class{constructor(){Pe(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),Ge.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,w.createHttpLink)({uri:`${Ge.getServerUrl()}/graphql`,fetch:d.fetch}),t=(0,h.setContext)((async(A,{headers:t})=>{const e=t||{},n=await be();return n.bearer&&(e.Authorization=`Bearer ${n.bearer}`),n.partnerId&&(e.partnerId=n.partnerId),n.activeIntegration&&(e.activeIntegration=n.activeIntegration),n.transactionOwnerId&&(e.transactionOwnerId=n.transactionOwnerId),{headers:e}})),e=(0,E.onError)((({operation:A,graphQLErrors:t,networkError:e})=>{(t||[]).forEach((({message:t,locations:e,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+A.operationName),console.log("Query:"+JSON.stringify(A.query)),console.log(`Message: ${t}, Location: ${JSON.stringify(e,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(A.variables))})),e&&console.log("GraphQL Network error")}));const n=new(0,w.InMemoryCache)({typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(A=null)=>A},transactionOwnerId:{read:(A=null)=>A},customLogoLink:{read:(A=null)=>A},workflowFooterLogoLink:{read:(A=null)=>A},workflowState:{read:(A=null)=>A},bulkSourceUrl:{read:(A=null)=>A},externalDesignProductId:{read:(A=null)=>A},externalDesignProductVariantId:{read:(A=null)=>A},lastSyncedAt:{read:(A=null)=>A}}},Workflow:{fields:{isPresent:{read:(A=null)=>A}}},Product:{fields:{imageUrl:{read:(A=null)=>A},overlayImageUrl:{read:(A=null)=>A},preloadImageUrl:{read:(A=null)=>A},weight:{read:(A=null)=>A}}}}});return new(0,w.ApolloClient)({link:(0,w.from)([e,t,A]),cache:n,name:"Core"})}};function Le(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class Te{static add(A){const t=A?.links.find((A=>"cdn"===A.rel));if(!t)return void console.error("Failed to find cdn link on asset, cannot persist!");const e=new Map;e.set(A.data.key,t.href);const n=ve.getMap("persistentAssets");n&&n.forEach(((A,t)=>{e.set(t,A)})),ve.setMap("persistentAssets",e)}static remove(A){const t=ve.getMap("persistentAssets");if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),ve.setMap("persistentAssets",t))}static list(){const A=ve.getMap("persistentAssets");return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const je=new class{constructor(){Le(this,"server",void 0),Le(this,"cache",new Map),Le(this,"materialCache",new Map),Le(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await te(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)}})),Le(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await je.getLocalOrFromServer(A.assetKey))),Le(this,"getMaterialFromVariant",(async A=>A.material?A.material:await je.getMaterialLocalOrFromServer(A.materialId))),this.server=Oe}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new Ye("Failed to get asset from cache!");return t}const t=(async()=>(await Oe.execute("getAssetByKeyV2",{assetKey:A.replace(/\//g,"_")})).body)();return this.cache.set(A,t),t}async getMaterialLocalOrFromServer(A){if(this.materialCache.has(A))return this.materialCache.get(A);const t=(async()=>(await Oe.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,i){const a=await this.dispatchCreateAssetRequest(A,t,n,i);return await new Promise(((t,n)=>{var i=new XMLHttpRequest;i.open("PUT",a.assetResponse.uploadUrl,!0),i.setRequestHeader("Content-Type",a.mimeType),i.setRequestHeader("Cache-Control","public,max-age=31536000,immutable"),i.upload.onprogress=A=>{A.lengthComputable&&e(100*A.loaded/A.total)},i.onload=()=>{const A=a.assetResponse.asset;Te.add(a.assetResponse.asset),t(A)},i.onerror=n,i.send(A.blob)})),a.assetResponse.asset}async uploadFile(A,t){const e=!("image/svg+xml"===A.type||"application/pdf"===A.type),n=e?j.Image:j.Illustration;if(e){const e=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(e,n,t,!0)}{const e={name:A.name,blob:new Blob([A],{type:A.type})};return await je.uploadAssetWithProgress(e,n,t,!0)}}removePersistedAsset(A){Te.remove(A)}getPersistedAssets(){return Te.list()}async dispatchCreateAssetRequest(A,t,e,n){const i=A.blob.type?A.blob.type:this.guessMIME(A.name);return{assetResponse:(await this.server.execute("createAsset",{assetDetails:{name:A.name,type:t,mimeType:i,storageOwnerId:n,userAnonymous:!0}},e)).body,mimeType:i}}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 Ye("Unexpected mimetype: "+t)}}};function Ke(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Ve=new class{constructor(){Ke(this,"cache",new Map),Ke(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),Ke(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),Ke(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),Ke(this,"getOptionFromStep",(async A=>{if(A.option){const t=A.option.data.id;return t&&!this.cache.has(t)&&this.cache.set(t,Promise.resolve(A.option)),A.option}return await Ve.getOption(Oe,A.optionId)}))}async getOption(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(async()=>(await A.execute("getOptionV2",{id:t})).body)();return this.cache.set(t,e),e}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await je.getLocalOrFromServer(A.thumbnailKey),e=t.links.find((A=>"thumbnail"===A.rel)),n=t.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}const t=A.assetKey;if(t){const A=await je.getLocalOrFromServer(t),e=A.links.find((A=>"thumbnail"===A.rel)),n=A.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}return A.materialId?A.materialId:""}getDefaultVariant(A){const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0}},We=(0,Q.createContext)(new Ct),Xe=()=>{const A=(0,Q.useContext)(We),[t,e]=(0,Q.useState)(new Date);(0,Q.useEffect)((()=>{const t=()=>{e(new Date)};return A.registerStateCallback(t),()=>{A.unregisterStateCallback(t)}}),[A]);return{commandDispatcher:(t,e)=>{A.apply(t,e)},getLayoutById:t=>A.getLayoutById(t),getAllLayouts:()=>A.getAllLayouts(),getReducerState:()=>{const t=A.getState();return t||{transaction:{layouts:{},serializableWorkflow:{steps:[]}}}},lastUpdated:t,flattenSequence:(t,e)=>{A.flattenSequence(t,e)}}};let qe;var Ze;(Ze=qe||(qe={})).None="None",Ze.FrameAdjustment="FrameAdjustment",Ze.FinalizeDesign="FinalizeDesign";const $e=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,maxZoom:5,units:J.Pixel,subMenu:qe.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),_e=(A,t)=>M(C)(A,t.apply(A))?A:t.apply(A),An=(0,Q.createContext)({}),tn=A=>{const{getAllLayouts:e}=Xe(),[n,i]=(0,Q.useReducer)(_e,$e(e,A.defaultZoom||1)),a=(0,Q.useMemo)((()=>({state:n,uiDispatcher:i})),[n,i]);return(0,t.jsx)(An.Provider,{value:a,children:A.children})};class en{constructor(A){var t,e,n;n=void 0,(e="changes")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.changes=A}apply(A){return{...A,...this.changes}}}const nn=()=>(0,Q.useContext)(An);let an;var sn;(sn=an||(an={}))[sn.Orbit=0]="Orbit",sn[sn.Pan=1]="Pan";const on=(A,e,n,i)=>{const a=e.layout.width,s=e.layout.height,o=e.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),r=o.map((A=>Z(A.x,A.y,A.width,A.height,A.rotation))),c=[],g=new Set;r.forEach((A=>g.add(A.minX))),r.forEach((A=>g.add(A.maxX))),[0,a/2,a].forEach((A=>g.add(A)));const B=new Set;r.forEach((A=>B.add(A.minY))),r.forEach((A=>B.add(A.maxY))),[0,s/2,s].forEach((A=>B.add(A)));const l=o.map((A=>A.y));for(let A=-315;A<=315;A+=45)l.push(A);const w=Z(A.x,A.y,A.width,A.height,A.rotation),h=[{value:w.minX,anchor:-1},{value:w.minX+(w.maxX-w.minX)/2,anchor:0},{value:w.minX+(w.maxX-w.minX),anchor:1}],E=[{value:w.minY,anchor:-1},{value:w.minY+(w.maxY-w.minY)/2,anchor:0},{value:w.minY+(w.maxY-w.minY),anchor:1}],d=[{value:A.rotation,anchor:0}],Q=(A,e,i,o)=>{const r=[];return e.forEach((e=>{const c=i.find((A=>tA(e,A.value,.5*n))),[g,B]=((A,t)=>[{x:"x"===A?t:0,y:"x"===A?0:t},{x:"x"===A?t:a,y:"x"===A?s:t}])(A,e),l="rotation"===A?null:(0,t.jsx)("line",{x1:g.x,y1:g.y,x2:B.x,y2:B.y,stroke:o||"#D61B5C",strokeWidth:1.2*n},`${A}-${e}-${g.x}-${g.y}-${B.x}-${B.y}`);void 0!==c&&r.push({type:A,value:e,anchorPoint:c.anchor,svgNode:l,guidelineCoordinates:[g,B]})})),r};return c.push(...Q("x",Array.from(g),h,i),...Q("y",Array.from(B),E,i),...Q("rotation",l,d,i)),c};let rn;var cn;let gn;var Bn;(cn=rn||(rn={})).Translate="Translate",cn.Rotate="Rotate",cn.Resize="Resize",(Bn=gn||(gn={})).ControlLeft="ControlLeft",Bn.ControlRight="ControlRight",Bn.Equal="Equal",Bn.MetaLeft="MetaLeft",Bn.MetaRight="MetaRight",Bn.Minus="Minus",Bn.ArrowLeft="ArrowLeft",Bn.ArrowRight="ArrowRight",Bn.ArrowUp="ArrowUp",Bn.ArrowDown="ArrowDown",Bn.AltLeft="AltLeft",Bn.AltRight="AltRight",Bn.Delete="Delete",Bn.Backspace="Backspace";const ln=(A,t,e,n)=>{const i=()=>{switch(e){case J.Pixel:return 1;case J.Millimeter:return lA;case J.Centimeter:return wA;default:throw new Ye("Unknown unit of measurement")}};let a=t.x,s=t.y,o=t.x,r=t.y;switch(A){case gn.ArrowLeft:o=t.x-1/i();break;case gn.ArrowUp:r=t.y-1/i();break;case gn.ArrowRight:o=t.x+1/i();break;case gn.ArrowDown:r=t.y+1/i();break;default:throw new Ye("Unhandled element interaction!")}const c=Z(o,r,t.width,t.height,t.rotation);return(!n||c.minX>=n.left&&c.maxX<=n.left+n.width&&c.minY>=n.top&&c.maxY<=n.top+n.height)&&(a=o,s=r),new xt(t.id,a,s)};var wn=0,hn=0,En=0;const dn=(A,t,e,n,i,a,s)=>{const o=((A,t,e,n,i,a,s)=>{const o=n.width/t.width,r=n.height/t.height,c=A.mX/o,g=A.mY/r,B=e.rotation*Math.PI/180,l=Math.sin(B),w=Math.cos(B),h=e.type===U.Textbox?1:e.width/e.height;let E;switch(i.type){case rn.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},d=t;switch(i.screenAxis){case O.North:{const A=-c*l+g*w,n=e.y+A,i=e.height-A,a=gA({...e}).center,s=gA({...e,y:n,height:i}).center,o=BA(s,a,B),r=o.x-e.width/2,h=o.y-i/2;d={...t,left:r,top:h,height:i}}break;case O.East:{const A=c*w+g*l,n=e.width+A;let i=e.height;if(e.type===U.Textbox){const A=e;i=WA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const a=gA({...e}).center,s=gA({...e,width:n,height:i}).center,o=BA(s,a,B),r=o.x-n/2,h=o.y-i/2;d={...t,left:r,top:h,width:n,height:i}}break;case O.West:{const A=c*w+g*l,n=e.x+A,i=e.width-A;let a=e.height;if(e.type===U.Textbox){const A=e;a=WA(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const s=gA({...e}).center,o=gA({...e,width:i,height:a,x:n}).center,r=BA(o,s,B),h=r.x-i/2,E=r.y-a/2;d={...t,left:h,top:E,width:i,height:a}}break;case O.South:{const A=-c*l+g*w,n=e.height+A,i=gA({...e}).center,a=gA({...e,height:n}).center,s=BA(a,i,B),o=s.x-e.width/2,r=s.y-n/2;d={...t,left:o,top:r,height:n}}break;case O.Northeast:{const A=c*w+g*l,n=e.width+A;let i=e.height+A/h,a=e.y-A,s=e.fontSize;if(e.type===U.Textbox){const t=e;s=t.fontSize+A/8,i=WA(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||nt;a=e.y-A*n/8}const o=gA({...e}).center,r=gA({...e,width:n,height:i,y:a}).center,E=BA(r,o,B),Q=E.x-n/2,C=E.y-i/2;d={...t,left:Q,top:C,width:n,height:i,fontSize:s}}break;case O.Northwest:{const A=-c*w+-g*l,n=e.x-A,i=e.width+A*h;let a=e.y-A,s=e.height+A,o=e.fontSize;if(e.type===U.Textbox){const t=e;o=t.fontSize+A/8,s=WA(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||nt;a=e.y-A*n/8}const r=gA({...e}).center,E=gA({...e,x:n,y:a,width:i,height:s}).center,Q=BA(E,r,B),C=Q.x-i/2,u=Q.y-s/2;d={...t,left:C,top:u,width:i,height:s,fontSize:o}}break;case O.Southeast:{const A=c*w+g*l,n=e.width+A;let i=e.height+A/h,a=e.fontSize;if(e.type===U.Textbox){const t=e;a=t.fontSize+A/8,i=WA(a,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=gA({...e}).center,o=gA({...e,width:n,height:i}).center,r=BA(o,s,B),E=r.x-n/2,Q=r.y-i/2;d={...t,left:E,top:Q,width:n,height:i,fontSize:a}}break;case O.Southwest:{const A=-c*w+-g*l,n=e.width+A*h;let i=e.x-A,a=e.height+A,s=e.fontSize;if(e.type===U.Textbox){const t=e;s=t.fontSize+A/8,a=WA(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const o=gA({...e}).center,r=gA({...e,width:n,height:a,x:i}).center,E=BA(r,o,B),Q=E.x-n/2,C=E.y-a/2;d={...t,left:Q,top:C,width:n,height:a,fontSize:s}}}return E=Z(d.left,d.top,d.width,d.height,d.rotation),(!s||E.minX>=s.left&&E.maxX<=s.left+s.width&&E.minY>=s.top&&E.maxY<=s.top+s.height)&&(t=d),t;case rn.Rotate:const Q={x:A.clientX,y:A.clientY};let C,u=e.rotation;const D=gA(e,n,{x:o,y:r}),I=$(Q,D.c,D.d),p=$(Q,D.d,D.c);if(0===a.filter((A=>"rotation"===A.type)).length)En=0,C=(e.rotation+I-p)%360;else{En+=Math.sqrt(c**2+g**2);const A=Math.abs(En)>.5*window.devicePixelRatio/o;C=A?(e.rotation+I-p)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(En=0)}return E=Z(e.x,e.y,e.width,e.height,C),(!s||E.minX>=s.left&&E.maxX<=s.left+s.width&&E.minY>=s.top&&E.maxY<=s.top+s.height)&&(u=C),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:u};case rn.Translate:let m,f,M=e.x,y=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)wn=0,hn=0,m=e.x+c,f=e.y+g;else{const A=a.find((A=>"x"===A.type)),t=a.find((A=>"y"===A.type));A||(wn=0),t||(hn=0);const n=Math.abs(wn)>.5*window.devicePixelRatio/o,i=Math.abs(hn)>.5*window.devicePixelRatio/r,s=A=>{switch(A){case-1:return 0;case 0:return e.width/2;case 1:return e.width;default:return 0}},B=A=>{switch(A){case-1:return 0;case 0:return e.height/2;case 1:return e.height;default:return 0}};if(0!==e.rotation)m=A?n?e.x+wn:e.x:e.x+c,f=t?i?e.y+hn:e.y:e.y+g;else{if(A){const t=A.value-s(A.anchorPoint);m=n?t+wn:t}else m=e.x+c;if(t){const A=t.value-B(t.anchorPoint);f=i?A+hn:A}else f=e.y+g}wn=n?0:wn+c,hn=i?0:hn+g}return E=Z(m,f,e.width,e.height,e.rotation),(!s||E.minX>=s.left&&E.maxX<=s.left+s.width&&E.minY>=s.top&&E.maxY<=s.top+s.height)&&(M=m,y=f),{top:y,left:M,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,s),r=[];if(e.type===U.Textbox){const A=e;r.push(new Tt(A.id,A.input||""))}if(o.width>0&&o.height>0&&(r.push(new xt(e.id,o.left,o.top),new St(e.id,o.width,o.height),new Nt(e.id,o.rotation)),e.type===U.Textbox)){const A=e;o.fontSize&&A.fontSize!==o.fontSize&&r.push(new Jt(A.id,o.fontSize))}return r},Qn=.5,Cn=["TEXTAREA","INPUT"],un=(A,t,e,n,i,a,s)=>{const{state:o,uiDispatcher:r}=(0,Q.useContext)(An),{getLayoutById:c,getReducerState:g,flattenSequence:B}=Xe(),[l,w]=(0,Q.useState)(void 0),[h,E]=(0,Q.useState)(void 0),[d,C]=(0,Q.useState)(void 0),u=c(o.layoutId);(0,Q.useEffect)((()=>{if("adjustment"===i&&A?.current&&n){if(n<Qn)return void r(new en({zoom:Qn}));if(n>o.maxZoom)return void r(new en({zoom:o.maxZoom}));r(new en({zoom:n}))}}),[n,r,A,i,o.maxZoom]);const D=(0,Q.useCallback)(((A,n)=>{r(new en({zoom:n}));const a=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!o.scrolledMovement&&"advanced"===i&&(s&&(t.current.scrollTop=e.current.offsetTop+(t.current.scrollHeight-t.current.clientHeight)/2),a&&(t.current.scrollLeft=(e.current.offsetLeft+t.current.scrollWidth-t.current.clientWidth)/2))}),[r,t,e,o.scrolledMovement,i]);(0,Q.useEffect)((()=>{o.zoom<=1&&r(new en({scrolledMovement:!1}))}),[r,o.zoom]);const I=t?.current?.getBoundingClientRect(),p=((I?.width||1)+(I?.height||1))/2,m=(u.layoutState.layout.width+u.layoutState.layout.height)/2/p/o.zoom,f=(0,Q.useMemo)((()=>{const A=o.activeModifierKeys,t=o.elementEvent,e=A.includes(gn.ControlLeft)||A.includes(gn.MetaLeft)||A.includes(gn.ControlRight)||A.includes(gn.MetaRight);if(!o.selectedElement||!t||e)return[];const n=t&&t.type===rn.Translate,i=t&&t.type===rn.Rotate,a=u.layoutState.elements.find((A=>A.id===o.selectedElement));return(n||i)&&a?on(a,u.layoutState,m,s):[]}),[o.selectedElement,o.elementEvent,o.activeModifierKeys,u.layoutState,m]),M=(0,Q.useCallback)((()=>{const A=x();w(A),E(g().transaction)}),[g]),y=(0,Q.useCallback)((()=>{r(new en({selectedElement:void 0}))}),[r]),F=(0,Q.useCallback)((()=>{r(new en({scrolledMovement:!0}))}),[r]),Y=(0,Q.useCallback)(((e,n)=>{const i=u.layoutState.elements.find((A=>A.id===o.selectedElement));if(!(o.elementEvent&&A.current&&t.current&&o.selectedElement&&i))return;t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const s=A.current.getBoundingClientRect(),r=new Ht(dn({mX:d?e.screenX-d.screenX:0,mY:d?e.screenY-d.screenY:0,clientX:e.clientX,clientY:e.clientY},u.layoutState.layout,i,s,o.elementEvent,f,n));r.sequenceId=l,a(r,!1),C({screenX:e.screenX,screenY:e.screenY})}),[u.layoutState.elements,u.layoutState.layout,o.elementEvent,A,o.selectedElement,t,f,a,d]),N=(0,Q.useCallback)((A=>{r(new en({elementEvent:A}))}),[r]),S=(0,Q.useCallback)((()=>{r(new en({elementEvent:void 0})),l&&h&&(B(l,h),w(void 0),E(void 0)),C(void 0)}),[r,l,h,B]),H=(0,Q.useCallback)(((A,t)=>{let e=o.zoom;const n=o.maxZoom,s=o.selectedElement,c=o.activeModifierKeys;if((c.includes(gn.AltLeft)||c.includes(gn.AltRight))&&(A.code===gn.Equal||A.code===gn.Minus)){const t=.05*n;A.code===gn.Equal?r(new en({zoom:e+t<=n?e+=t:e})):r(new en({zoom:e-t>=Qn?e-t:e}))}const g=u.layoutState.elements.find((A=>A.id===s));if(s&&g){if(A.code===gn.MetaLeft||A.code===gn.ControlLeft||A.code===gn.MetaRight||A.code===gn.ControlRight){const t=A.code,e=o.activeModifierKeys;if(!e.includes(t))return r(new en({activeModifierKeys:e.concat(t)}))}if(A.code===gn.ArrowDown||A.code===gn.ArrowUp||A.code===gn.ArrowLeft||A.code===gn.ArrowRight){r(new en({elementEvent:{type:rn.Translate}}));const e=ln(A.code,g,o.units,t);a(e,!1),r(new en({elementEvent:void 0}))}A.code!==gn.Delete&&A.code!==gn.Backspace||"advanced"!==i||(r(new en({selectedElement:void 0})),a(new Gt(g.id),!1))}}),[a,r,u.layoutState.elements,i,o.activeModifierKeys,o.maxZoom,o.selectedElement,o.units,o.zoom]),R=(0,Q.useCallback)((A=>{if(A.code===gn.MetaLeft||A.code===gn.ControlLeft||A.code===gn.MetaRight||A.code===gn.ControlRight){const t=o.activeModifierKeys,e=A.code;r(new en({activeModifierKeys:t.filter((A=>A!==e))}))}}),[r,o.activeModifierKeys]);return{guidelines:f,scale:m,zoomableElementRef:e,setElementEvent:N,handleZoom:D,handleKeyDown:H,handleKeyUp:R,handlePointerPressedBackground:y,handlePointerReleased:S,handlePointerMove:Y,handleScroll:F,handleSequenceStart:M}},Dn=(A,t)=>{const e=(0,Q.useMemo)((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),n=(0,Q.useRef)([]),i=(0,Q.useCallback)((()=>{const A=e.every((A=>n.current.includes(A))),t=n.current.length===e.length;return A&&t}),[]),a=(0,Q.useCallback)((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const a=A.target;return!(Cn.indexOf(a.tagName)>=0)&&(n.current=[...new Set([...n.current,e])],i()&&t(),A.preventDefault())}),[i,e,t,A]),s=(0,Q.useCallback)((A=>{const t=String(A.key).toLowerCase();return n.current=n.current.filter((A=>A!==t)),A.preventDefault()}),[e]);(0,Q.useEffect)((()=>(window.addEventListener("keydown",a),window.addEventListener("keyup",s),()=>{window.removeEventListener("keydown",a),window.removeEventListener("keyup",s)})),[a,s])},In=A=>{const{x:e,y:n,cursorStyle:i,onPointerDown:a,handleClass:s,cornerRadius:o,color:r,strokeWidth:c}=A;return(0,t.jsx)("circle",{className:s,cx:e,cy:n,r:o,fill:"#ffffff",style:{cursor:i},stroke:r,strokeWidth:c,onPointerDown:a})},pn=A=>{const{x:e,y:n,width:i,height:a,cursorStyle:s,onPointerDown:o,edgeHandleRadius:r,color:c,strokeWidth:g}=A;return(0,t.jsx)("rect",{x:e,y:n,width:i,height:a,rx:r,fill:"#ffffff",style:{cursor:s},stroke:c,strokeWidth:g,onPointerDown:o})},mn=A=>{const{color:e,elementHeight:n,elementWidth:i,onBeginResize:a,rotation:s,scaleFactor:o,disableX:r,disableY:c}=A,g=10*o,B=5*o,l=40*o,w=12*o,h=1.2*o,E=n-2*g,d=(0,Q.useCallback)(((A,t,e)=>{A.stopPropagation(),a(t,e)}),[a]),C=(0,Q.useCallback)((A=>d(A,cA(O.West,360-s),O.West)),[d,s]),u=(0,Q.useCallback)((A=>d(A,cA(O.East,360-s),O.East)),[d,s]),D=(0,Q.useCallback)((A=>d(A,cA(O.North,360-s),O.North)),[d,s]),I=(0,Q.useCallback)((A=>d(A,cA(O.South,360-s),O.South)),[d,s]),p=(0,Q.useCallback)((A=>d(A,O.Northwest,O.Northwest)),[d]),m=(0,Q.useCallback)((A=>d(A,O.Northeast,O.Northeast)),[d]),f=(0,Q.useCallback)((A=>d(A,O.Southwest,O.Southwest)),[d]),M=(0,Q.useCallback)((A=>d(A,O.Northeast,O.Southeast)),[d]),y=l<=E;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(In,{x:0,y:0,cursorStyle:"nw-resize",onPointerDown:p,handleClass:"cornerNorthWest",cornerRadius:g,color:e,strokeWidth:h}),y?(0,t.jsx)(In,{x:i,y:0,cursorStyle:"ne-resize",onPointerDown:m,handleClass:"cornerNorthEast",cornerRadius:g,color:e,strokeWidth:h}):void 0,y?(0,t.jsx)(In,{x:i,y:n,cursorStyle:"se-resize",onPointerDown:M,handleClass:"cornerSouthEast",cornerRadius:g,color:e,strokeWidth:h}):void 0,y?(0,t.jsx)(In,{x:0,y:n,cursorStyle:"sw-resize",onPointerDown:f,handleClass:"cornerSouthWest",cornerRadius:g,color:e,strokeWidth:h}):void 0,y&&!r?(0,t.jsx)(pn,{x:-w/2,y:n/2-l/2,width:w,height:l,onPointerDown:C,edgeHandleRadius:B,cursorStyle:"w-resize",color:e,strokeWidth:h}):void 0,y&&!c?(0,t.jsx)(pn,{x:i/2-l/2,y:n-w/2,width:l,height:w,onPointerDown:I,edgeHandleRadius:B,cursorStyle:"s-resize",color:e,strokeWidth:h}):void 0,r?void 0:(0,t.jsx)(pn,{x:i-w/2,y:n/2-Math.min(l,.8*n)/2,width:w,height:Math.min(l,.8*n),onPointerDown:u,edgeHandleRadius:B,cursorStyle:"e-resize",color:e,strokeWidth:h}),y&&!c?(0,t.jsx)(pn,{x:i/2-l/2,y:-w/2,width:l,height:w,onPointerDown:D,edgeHandleRadius:B,cursorStyle:"n-resize",color:e,strokeWidth:h}):void 0]})},fn=A=>{const{color:e,elementWidth:n,onBeginRotate:i,scaleFactor:a}=A,s=(0,Q.useCallback)((A=>{A.stopPropagation(),i()}),[i]),o=10*a,r=1.2*a;return(0,t.jsxs)("g",{children:[(0,t.jsx)("circle",{cx:n/2,cy:-2.5*o,r:1.3*o,fill:"rgba(0, 0, 0, 0.5)",opacity:.4,style:{cursor:"ew-resize"},onPointerDown:s}),(0,t.jsx)("circle",{cx:n/2,cy:-2.5*o,r:o,fill:"#fff",style:{cursor:"ew-resize"},stroke:e,strokeWidth:r,onPointerDown:s}),(0,t.jsxs)("svg",{x:n/2-o,y:-2.5*o-o,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*o,viewBox:"0 0 24 24",width:2*o,fill:e,onPointerDown:s,children:[(0,t.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,t.jsx)("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})]})]})},Mn=({color:A,height:e,highlighted:n,id:i,immutable:a,onBeginMove:s,onPointerEnter:o,onPointerLeave:r,onSelected:c,pressed:g,rotation:B,scaleFactor:l,selected:w,width:h,x:E,y:d})=>{const C=1.2*l,u=(0,Q.useCallback)((A=>{2===A.button&&(A.stopPropagation(),c(i,A)),0===A.button&&(A.stopPropagation(),!w&&c(i,A),s())}),[i,w,c,s]),D=(0,Q.useCallback)((()=>{o(i)}),[i,o]),I=(0,Q.useCallback)((()=>{r(i)}),[i,r]),p=a?void 0:w?g?"grabbing":"grab":"pointer",m=a?"none":"visibleFill";return(0,t.jsx)("g",{transform:`translate(${E}, ${d}) rotate(${B} ${h/2} ${e/2})`,children:(0,t.jsx)("rect",{className:"interactableInnerRect",width:h,height:e,stroke:w||n?A:"none",pointerEvents:m,fill:"none",strokeWidth:C,style:{cursor:p},onPointerDown:a?void 0:u,onPointerEnter:a?void 0:D,onPointerLeave:a?void 0:I})})},yn=({color:A,height:e,onBeginResize:n,onBeginRotate:i,rotation:a,scaleFactor:s,width:o,x:r,y:c,disableX:g,disableY:B})=>(0,t.jsxs)("g",{transform:`translate(${r}, ${c}) rotate(${a} ${o/2} ${e/2})`,children:[(0,t.jsx)(fn,{color:A,elementWidth:o,onBeginRotate:i,scaleFactor:s}),(0,t.jsx)(mn,{color:A,elementHeight:e,elementWidth:o,rotation:a,scaleFactor:s,onBeginResize:n,disableX:g,disableY:B})]}),Fn=({primaryColor:A,containerHeight:e,containerWidth:n,customViewbox:i,editorRef:a,elementEvent:s,guidelines:o,layoutHeight:r,layoutWidth:c,targetedElements:g,scale:B,selectedElement:l,onElementEvent:w,onElementSelected:h,onSequenceStart:E,onMouseMove:d})=>{const{state:C}=nn(),{getLayoutById:u}=Xe(),D=u(C.layoutId),[I,p]=(0,Q.useState)(void 0),m=(0,Q.useCallback)((A=>{p(A)}),[]),f=(0,Q.useCallback)((A=>{I===A&&p(void 0)}),[I]),M=(0,Q.useCallback)((()=>{E(),w({type:rn.Translate})}),[w]),y=(0,Q.useCallback)(((A,t)=>{E(),w({type:rn.Resize,relativeAxis:A,screenAxis:t})}),[w]),F=(0,Q.useCallback)((()=>{E(),w({type:rn.Rotate})}),[w]),Y=i||{x:0,y:0,width:c,height:r},x=B*(Math.sqrt(Y.width*Y.height)/1e3)*(100/Math.sqrt(e*n))*Math.sqrt((N=n/e,Math.exp(Math.abs(Math.log(N)))));var N;const S=D.layoutState.elements,H=S.find((A=>A.id===l));return(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",style:{touchAction:"none",position:"absolute",maxWidth:"100%",maxHeight:"100%"},width:"auto",height:"auto",viewBox:`${Y.x} ${Y.y} ${Y.width} ${Y.height}`,overflow:"overlay",children:[(0,t.jsx)("rect",{onMouseMove:d,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:a,width:c,height:r}),o.map((A=>A.svgNode)),S.map((e=>{const n=void 0!==l&&e.id===l,i=n&&void 0!==s,a=void 0!==I&&e.id===I;return(0,t.jsx)(Mn,{color:A,id:e.id,selected:n,highlighted:a,pressed:i,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation,immutable:e.immutable||g&&!g.includes(e.id),onSelected:h,onBeginMove:M,onPointerEnter:m,onPointerLeave:f,scaleFactor:x},e.id)})),H&&(0,t.jsx)(yn,{color:A,x:H.x,y:H.y,disableX:H.type===U.Frame,disableY:H.type===U.Textbox||H.type===U.Frame,width:H.width,height:H.height,rotation:H.rotation,onBeginResize:y,onBeginRotate:F,scaleFactor:x})]})},Yn=A=>{const{color:e,editorRef:n,zoomableElementRef:i,interactionElementRef:a,guidelines:s,isMakingAdjustments:o,viewmask:r,visibleLayoutId:c,xTranslation:g,yTranslation:B,targetedElements:l,borderRadius:w,handleContextMenu:h,onMouseMove:E,handleKeyDown:d,handleKeyUp:C,handlePointerMove:u,handlePointerPressedBackground:D,handlePointerReleased:I,handleScroll:p,onSequenceStart:m,setElementEvent:f,onElementSelected:M}=A,{getLayoutById:y}=Xe(),F=y(c),Y=F.layoutState,{state:x}=nn(),N=(0,Q.useCallback)((A=>{if(r){const t={left:r.x,top:r.y,width:r.width,height:r.height,panelId:"",rotation:0};return d(A,t)}return d(A)}),[d,r]),S=(0,Q.useCallback)((A=>{if(r){const t={left:r.x,top:r.y,width:r.width,height:r.height,panelId:"",rotation:0};return u(A,t)}return u(A)}),[u,r]);return(0,t.jsx)("div",{style:{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:"none"},onContextMenu:h,onKeyDown:N,onKeyUp:C,onPointerDown:D,onPointerMoveCapture:S,onPointerUp:I,onWheelCapture:p,ref:a,tabIndex:-1,children:(0,t.jsxs)("div",{ref:i,style:{height:"100%",transform:`scale(${x.zoom}) translate(${g}px, ${B}px)`,display:"flex",justifyContent:"center",filter:"drop-shadow(rgba(0, 0, 0, 0.2) 0px 0px 6px)"},children:[A.children,F.getComponentWithProps({height:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",viewmask:r,width:o?"100%":"auto",borderRadius:w}),(0,t.jsx)(Fn,{primaryColor:e,containerHeight:i.current?.offsetHeight||1024,containerWidth:i.current?.offsetWidth||1024,editorRef:n,elementEvent:x.elementEvent,guidelines:s,layoutHeight:Y.layout.height,layoutWidth:Y.layout.width,onElementEvent:f,onSequenceStart:m,onElementSelected:M,scale:10/x.zoom,selectedElement:x.selectedElement,targetedElements:l,onMouseMove:E})]})})},xn=({color:A,borderRadius:e,guidelineColor:n,handleContextMenu:i,onMouseMove:a,onElementSelected:s})=>{const{commandDispatcher:o,getLayoutById:r}=Xe(),{state:c,uiDispatcher:g}=nn(),B=(0,Q.useRef)(null),l=(0,Q.useRef)(null),w=(0,Q.useRef)(null),{guidelines:h,handleKeyDown:E,handleKeyUp:d,handlePointerMove:C,handlePointerPressedBackground:u,handlePointerReleased:D,handleScroll:I,handleSequenceStart:p,setElementEvent:m}=un(B,l,w,void 0,"advanced",o,n),f=(0,Q.useCallback)(((A,t)=>{const e=r(c.layoutId).layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===U.Textbox){const t=e.algorithm;(!t||t===P.Autosize)&&o(new bt(A,P.Traditional),!0)}s&&s(A,t),g(new en({selectedElement:A}))}),[o,r,c.layoutId,g]);return(0,t.jsx)(Yn,{color:A,editorRef:B,interactionElementRef:l,zoomableElementRef:w,guidelines:h,visibleLayoutId:c.layoutId,xTranslation:0,yTranslation:0,borderRadius:e,handleContextMenu:i,onMouseMove:a,handleKeyDown:E,handleKeyUp:d,handlePointerMove:C,handlePointerPressedBackground:u,handlePointerReleased:D,handleScroll:I,onSequenceStart:p,setElementEvent:m,onElementSelected:f})},Nn=w.gql`
2
2
  mutation CreateTransaction($integrationProductId: String!, $bulk: Boolean) {
3
3
  transactionCreate(integrationProductId: $integrationProductId, bulk: $bulk) {
4
4
  id
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import{CommandContext as A,AssetType as t,BringForwardCommand as e,CanvasCommand as n,CreateElementCommand as a,CreateLayoutCommand as i,DeleteElementCommand as s,FontAlignmentCommand as o,FontColorCommand as c,FontSizeCommand as r,FontSourceCommand as g,GroupCommand as B,LayoutElementFactory as w,LayoutElementType as l,MoveCommand as E,ResizeCommand as Q,RotateCommand as h,SendBackwardsCommand as C,StepAspectType as d,StepType as D,TextChangeCommand as I,UnitOfMeasurement as u,dataUrlFromExternalUrl as p,findElement as m,frameDataCache as f,generate as M,generateSVGWithUnknownColors as F,getAttributesFromArrayBuffer as Y,rehydrateSerializedLayout as y,getFrameData as x,getSvgString as N,loadFontFromDataUrl as H,loadFontFromExternalUrl as R,determineCorrectFontSizeAndLines as S,patternImageDataCache as U,registerJSDOM as G,TextAlgorithm as v,FontAlgorithmCommand as P,getAxisAlignedBoundingBox as J,isCloseToValue as k,mmPerPixel as O,cmPerPixel as b,ScaleAxis as L,getElementVertices as z,rotateAroundPoint as T,calculateTextboxLines as K,defaultLineHeightFactor as j,findAngle as V,currentDirection as W,modifySVGWithElementProperties as X,IllustrationColorCommand as q,IllustrationCacheCommand as Z,UpdateWorkflowStateCommand as $,calculateOffsets as _,UpdateFramePattern as AA,generateDefaultRectangleFrameSvg as tA,fetchAsString as eA,GetSVGDimensions as nA,getFontMetrics as aA,applyTextTransformations as iA,createElementNS as sA,createElement as oA,sortElementsByLayersWithIndex as cA,toBase64 as rA,getPatternImageData as gA,getVariant as BA,generateFrameSVG as wA,getDefaultVariant as lA,domParser as EA,sanitizeSvgTree as QA,traverse as hA,xmlSerializer as CA,fetchAsArrayBuffer as dA,arrayBufferToDataUrl as DA,loadFontFaceSet as IA}from"@spiffcommerce/papyrus";import uA from"swagger-client";import{createHttpLink as pA,InMemoryCache as mA,ApolloClient as fA,from as MA,gql as FA}from"@apollo/client";import{setContext as YA}from"@apollo/client/link/context";import{onError as yA}from"@apollo/client/link/error";import{fetch as xA}from"cross-fetch";import{createContext as NA,useContext as HA,useState as RA,useEffect as SA,useReducer as UA,useMemo as GA,useRef as vA,useCallback as PA}from"react";import{jsx as JA,jsxs as kA,Fragment as OA}from"react/jsx-runtime";import bA from"lodash.isequal";import{Canvg as LA}from"canvg";import zA from"lodash.clonedeep";import TA from"lodash.debounce";import{toString as KA}from"qrcode";import jA from"svg-path-bbox";function VA(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class WA extends Error{constructor(A){super(A),this.name=this.constructor.name}}class XA extends WA{constructor(A){super(`ConfigurationError - ${A}`)}}class qA extends XA{constructor(A){super(`Option not Configured: ${A.stepTitle}`),VA(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class ZA extends XA{constructor(A){super(`Panel not Found: ${A.panelId}`),VA(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class $A extends XA{constructor(A){super(`Asset not found for variant: ${A.name}`),VA(this,"variant",void 0),this.variant=A}}class _A extends XA{constructor(A){super(`Resource not found for asset: ${A.name}`),VA(this,"asset",void 0),this.asset=A}}class At extends XA{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),VA(this,"step",void 0),this.step=A}}class tt extends WA{constructor(A){super(`ImplementationError - ${A}`)}}class et extends tt{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class nt extends tt{constructor(A){super(`Parsing Error: ${A}`)}}class at extends tt{constructor(A){super(`Client Error: ${A}`)}}class it extends tt{constructor(A){super(`Resource Generation Failed: ${A}`)}}class st{get(A){return localStorage.getItem(A)||void 0}set(A,t){localStorage.setItem(A,t)}remove(A){localStorage.removeItem(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}class ot{constructor(){var A,t,e;A=this,t="storage",e=new Map,t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e}get(A){return this.storage.get(A)||void 0}set(A,t){this.storage.set(A,t)}remove(A){this.storage.delete(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}const ct=(()=>{try{return localStorage?new st:new ot}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new ot}})();function rt(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const gt=new class{constructor(){rt(this,"defaultServerUrl","https://api.spiff.com.au"),rt(this,"defaultServicesApiUrl","https://services.spiff.com.au"),rt(this,"defaultHubUrl","https://hub.spiff.com.au"),rt(this,"serverUrl",void 0),rt(this,"servicesApiUrl",void 0),rt(this,"hubUrl",void 0),rt(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(A){this.serverUrl=A,this.serverUrlCallbacks.forEach((A=>A()))}setServicesApiUrl(A){this.servicesApiUrl=A}setHubUrl(A){this.hubUrl=A}addServerUrlCallback(A){this.serverUrlCallbacks.push(A)}};function Bt(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let wt;const lt=A=>{wt=A},Et=async()=>{const A={transactionOwnerId:wt};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=gt.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void A({});const e=n=>{n.origin===t&&(window.removeEventListener("message",e),A(n.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))})),...A}:A};const Qt=new class{constructor(){Bt(this,"client",void 0),Bt(this,"uncachedOperations",[]),gt.addServerUrlCallback((async()=>{this.client=void 0,this.client=await this.constructClient()}))}setUncachedOperations(A){this.uncachedOperations=A}async execute(A,t){const e=this.uncachedOperations.includes(A)?A+"_private":A;return new Promise(((A,n)=>{this.getClient().then((a=>{a.execute({operationId:e,parameters:t}).then((t=>A(t))).catch((A=>{A.response&&A.response.status&&A.response.status>=500||(!A.response&&n(new Error(A)),A.response&&n(new Error(`${A.response.status} ${A.response.url}`)))}))})).catch((A=>{n(A)}))}))}async syncAuth(A){const t=await Et();if(t.bearer?A.authorizations={...A.authorizations,OAuth2:{token:{access_token:t.bearer,token_type:"Bearer"}}}:A.authorizations={...A.authorizations,OAuth2:{token:{access_token:"",token_type:"Bearer"}}},t.activeIntegration)A.authorizations={...A.authorizations,ActiveIntegration:t.activeIntegration};else{const t={...A.authorizations};delete t.ActiveIntegration,A.authorizations=t}if(t.partnerId)A.authorizations={...A.authorizations,PartnerId:t.partnerId};else{const t={...A.authorizations};delete t.PartnerId,A.authorizations=t}}async getClient(){return this.client||(this.client=await this.constructClient()),this.syncAuth(this.client),Promise.resolve(this.client)}async constructClient(){const A=await Et(),t=gt.getServerUrl()+"/v2/api-docs";return await uA(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const ht=new class{constructor(){Bt(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),gt.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=pA({uri:`${gt.getServerUrl()}/graphql`,fetch:xA}),t=YA((async(A,{headers:t})=>{const e=t||{},n=await Et();return n.bearer&&(e.Authorization=`Bearer ${n.bearer}`),n.partnerId&&(e.partnerId=n.partnerId),n.activeIntegration&&(e.activeIntegration=n.activeIntegration),n.transactionOwnerId&&(e.transactionOwnerId=n.transactionOwnerId),{headers:e}})),e=yA((({operation:A,graphQLErrors:t,networkError:e})=>{(t||[]).forEach((({message:t,locations:e,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+A.operationName),console.log("Query:"+JSON.stringify(A.query)),console.log(`Message: ${t}, Location: ${JSON.stringify(e,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(A.variables))})),e&&console.log("GraphQL Network error")}));const n=new mA({typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(A=null)=>A},transactionOwnerId:{read:(A=null)=>A},customLogoLink:{read:(A=null)=>A},workflowFooterLogoLink:{read:(A=null)=>A},workflowState:{read:(A=null)=>A},bulkSourceUrl:{read:(A=null)=>A},externalDesignProductId:{read:(A=null)=>A},externalDesignProductVariantId:{read:(A=null)=>A},lastSyncedAt:{read:(A=null)=>A}}},Workflow:{fields:{isPresent:{read:(A=null)=>A}}},Product:{fields:{imageUrl:{read:(A=null)=>A},overlayImageUrl:{read:(A=null)=>A},preloadImageUrl:{read:(A=null)=>A},weight:{read:(A=null)=>A}}}}});return new fA({link:MA([e,t,A]),cache:n,name:"Core"})}};function Ct(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class dt{static add(A){const t=A?.links.find((A=>"cdn"===A.rel));if(!t)return void console.error("Failed to find cdn link on asset, cannot persist!");const e=new Map;e.set(A.data.key,t.href);const n=ct.getMap("persistentAssets");n&&n.forEach(((A,t)=>{e.set(t,A)})),ct.setMap("persistentAssets",e)}static remove(A){const t=ct.getMap("persistentAssets");if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),ct.setMap("persistentAssets",t))}static list(){const A=ct.getMap("persistentAssets");return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const Dt=new class{constructor(){Ct(this,"server",void 0),Ct(this,"cache",new Map),Ct(this,"materialCache",new Map),Ct(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await Y(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)}})),Ct(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await Dt.getLocalOrFromServer(A.assetKey))),Ct(this,"getMaterialFromVariant",(async A=>A.material?A.material:await Dt.getMaterialLocalOrFromServer(A.materialId))),this.server=Qt}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new et("Failed to get asset from cache!");return t}const t=(async()=>(await Qt.execute("getAssetByKeyV2",{assetKey:A.replace(/\//g,"_")})).body)();return this.cache.set(A,t),t}async getMaterialLocalOrFromServer(A){if(this.materialCache.has(A))return this.materialCache.get(A);const t=(async()=>(await Qt.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,a){const i=await this.dispatchCreateAssetRequest(A,t,n,a);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;dt.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),a=n?t.Image:t.Illustration;if(n){const t=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(t,a,e,!0)}{const t={name:A.name,blob:new Blob([A],{type:A.type})};return await Dt.uploadAssetWithProgress(t,a,e,!0)}}removePersistedAsset(A){dt.remove(A)}getPersistedAssets(){return dt.list()}async dispatchCreateAssetRequest(A,t,e,n){const a=A.blob.type?A.blob.type:this.guessMIME(A.name);return{assetResponse:(await this.server.execute("createAsset",{assetDetails:{name:A.name,type:t,mimeType:a,storageOwnerId:n,userAnonymous:!0}},e)).body,mimeType:a}}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 et("Unexpected mimetype: "+t)}}};function It(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const ut=new class{constructor(){It(this,"cache",new Map),It(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),It(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),It(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),It(this,"getOptionFromStep",(async A=>{if(A.option){const t=A.option.data.id;return t&&!this.cache.has(t)&&this.cache.set(t,Promise.resolve(A.option)),A.option}return await ut.getOption(Qt,A.optionId)}))}async getOption(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(async()=>(await A.execute("getOptionV2",{id:t})).body)();return this.cache.set(t,e),e}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await Dt.getLocalOrFromServer(A.thumbnailKey),e=t.links.find((A=>"thumbnail"===A.rel)),n=t.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}const t=A.assetKey;if(t){const A=await Dt.getLocalOrFromServer(t),e=A.links.find((A=>"thumbnail"===A.rel)),n=A.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}return A.materialId?A.materialId:""}getDefaultVariant(A){const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0}},pt=NA(new A),mt=()=>{const A=HA(pt),[t,e]=RA(new Date);SA((()=>{const t=()=>{e(new Date)};return A.registerStateCallback(t),()=>{A.unregisterStateCallback(t)}}),[A]);return{commandDispatcher:(t,e)=>{A.apply(t,e)},getLayoutById:t=>A.getLayoutById(t),getAllLayouts:()=>A.getAllLayouts(),getReducerState:()=>{const t=A.getState();return t||{transaction:{layouts:{},serializableWorkflow:{steps:[]}}}},lastUpdated:t,flattenSequence:(t,e)=>{A.flattenSequence(t,e)}}};let ft;var Mt;(Mt=ft||(ft={})).None="None",Mt.FrameAdjustment="FrameAdjustment",Mt.FinalizeDesign="FinalizeDesign";const Ft=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,maxZoom:5,units:u.Pixel,subMenu:ft.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Yt=(A,t)=>bA(A,t.apply(A))?A:t.apply(A),yt=NA({}),xt=A=>{const{getAllLayouts:t}=mt(),[e,n]=UA(Yt,Ft(t,A.defaultZoom||1)),a=GA((()=>({state:e,uiDispatcher:n})),[e,n]);return JA(yt.Provider,{value:a,children:A.children})};class Nt{constructor(A){var t,e,n;n=void 0,(e="changes")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.changes=A}apply(A){return{...A,...this.changes}}}const Ht=()=>HA(yt);let Rt;var St;(St=Rt||(Rt={}))[St.Orbit=0]="Orbit",St[St.Pan=1]="Pan";const Ut=(A,t,e,n)=>{const a=t.layout.width,i=t.layout.height,s=t.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),o=s.map((A=>J(A.x,A.y,A.width,A.height,A.rotation))),c=[],r=new Set;o.forEach((A=>r.add(A.minX))),o.forEach((A=>r.add(A.maxX))),[0,a/2,a].forEach((A=>r.add(A)));const g=new Set;o.forEach((A=>g.add(A.minY))),o.forEach((A=>g.add(A.maxY))),[0,i/2,i].forEach((A=>g.add(A)));const B=s.map((A=>A.y));for(let A=-315;A<=315;A+=45)B.push(A);const w=J(A.x,A.y,A.width,A.height,A.rotation),l=[{value:w.minX,anchor:-1},{value:w.minX+(w.maxX-w.minX)/2,anchor:0},{value:w.minX+(w.maxX-w.minX),anchor:1}],E=[{value:w.minY,anchor:-1},{value:w.minY+(w.maxY-w.minY)/2,anchor:0},{value:w.minY+(w.maxY-w.minY),anchor:1}],Q=[{value:A.rotation,anchor:0}],h=(A,t,n,s)=>{const o=[];return t.forEach((t=>{const c=n.find((A=>k(t,A.value,.5*e))),[r,g]=((A,t)=>[{x:"x"===A?t:0,y:"x"===A?0:t},{x:"x"===A?t:a,y:"x"===A?i:t}])(A,t),B="rotation"===A?null:JA("line",{x1:r.x,y1:r.y,x2:g.x,y2:g.y,stroke:s||"#D61B5C",strokeWidth:1.2*e},`${A}-${t}-${r.x}-${r.y}-${g.x}-${g.y}`);void 0!==c&&o.push({type:A,value:t,anchorPoint:c.anchor,svgNode:B,guidelineCoordinates:[r,g]})})),o};return c.push(...h("x",Array.from(r),l,n),...h("y",Array.from(g),E,n),...h("rotation",B,Q,n)),c};let Gt;var vt;let Pt;var Jt;(vt=Gt||(Gt={})).Translate="Translate",vt.Rotate="Rotate",vt.Resize="Resize",(Jt=Pt||(Pt={})).ControlLeft="ControlLeft",Jt.ControlRight="ControlRight",Jt.Equal="Equal",Jt.MetaLeft="MetaLeft",Jt.MetaRight="MetaRight",Jt.Minus="Minus",Jt.ArrowLeft="ArrowLeft",Jt.ArrowRight="ArrowRight",Jt.ArrowUp="ArrowUp",Jt.ArrowDown="ArrowDown",Jt.AltLeft="AltLeft",Jt.AltRight="AltRight",Jt.Delete="Delete",Jt.Backspace="Backspace";const kt=(A,t,e,n)=>{const a=()=>{switch(e){case u.Pixel:return 1;case u.Millimeter:return O;case u.Centimeter:return b;default:throw new et("Unknown unit of measurement")}};let i=t.x,s=t.y,o=t.x,c=t.y;switch(A){case Pt.ArrowLeft:o=t.x-1/a();break;case Pt.ArrowUp:c=t.y-1/a();break;case Pt.ArrowRight:o=t.x+1/a();break;case Pt.ArrowDown:c=t.y+1/a();break;default:throw new et("Unhandled element interaction!")}const r=J(o,c,t.width,t.height,t.rotation);return(!n||r.minX>=n.left&&r.maxX<=n.left+n.width&&r.minY>=n.top&&r.maxY<=n.top+n.height)&&(i=o,s=c),new E(t.id,i,s)};var Ot=0,bt=0,Lt=0;const zt=(A,t,e,n,a,i,s)=>{const o=((A,t,e,n,a,i,s)=>{const o=n.width/t.width,c=n.height/t.height,r=A.mX/o,g=A.mY/c,B=e.rotation*Math.PI/180,w=Math.sin(B),E=Math.cos(B),Q=e.type===l.Textbox?1:e.width/e.height;let h;switch(a.type){case Gt.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},C=t;switch(a.screenAxis){case L.North:{const A=-r*w+g*E,n=e.y+A,a=e.height-A,i=z({...e}).center,s=z({...e,y:n,height:a}).center,o=T(s,i,B),c=o.x-e.width/2,l=o.y-a/2;C={...t,left:c,top:l,height:a}}break;case L.East:{const A=r*E+g*w,n=e.width+A;let a=e.height;if(e.type===l.Textbox){const A=e;a=K(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const i=z({...e}).center,s=z({...e,width:n,height:a}).center,o=T(s,i,B),c=o.x-n/2,Q=o.y-a/2;C={...t,left:c,top:Q,width:n,height:a}}break;case L.West:{const A=r*E+g*w,n=e.x+A,a=e.width-A;let i=e.height;if(e.type===l.Textbox){const A=e;i=K(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const s=z({...e}).center,o=z({...e,width:a,height:i,x:n}).center,c=T(o,s,B),Q=c.x-a/2,h=c.y-i/2;C={...t,left:Q,top:h,width:a,height:i}}break;case L.South:{const A=-r*w+g*E,n=e.height+A,a=z({...e}).center,i=z({...e,height:n}).center,s=T(i,a,B),o=s.x-e.width/2,c=s.y-n/2;C={...t,left:o,top:c,height:n}}break;case L.Northeast:{const A=r*E+g*w,n=e.width+A*Q;let a=e.height+A,i=e.y-A,s=e.fontSize;if(e.type===l.Textbox){const t=e;s=t.fontSize+A/8,a=K(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||j;i=e.y-A*n/8}const o=z({...e}).center,c=z({...e,width:n,height:a,y:i}).center,h=T(c,o,B),d=h.x-n/2,D=h.y-a/2;C={...t,left:d,top:D,width:n,height:a,fontSize:s}}break;case L.Northwest:{const A=-r*E+-g*w,n=e.x-A*Q,a=e.width+A*Q;let i=e.y-A,s=e.height+A,o=e.fontSize;if(e.type===l.Textbox){const t=e;o=t.fontSize+A/8,s=K(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||j;i=e.y-A*n/8}const c=z({...e}).center,h=z({...e,x:n,y:i,width:a,height:s}).center,d=T(h,c,B),D=d.x-a/2,I=d.y-s/2;C={...t,left:D,top:I,width:a,height:s,fontSize:o}}break;case L.Southeast:{const A=r*E+g*w,n=e.width+A*Q;let a=e.height+A,i=e.fontSize;if(e.type===l.Textbox){const t=e;i=t.fontSize+A/8,a=K(i,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=z({...e}).center,o=z({...e,width:n,height:a}).center,c=T(o,s,B),h=c.x-n/2,d=c.y-a/2;C={...t,left:h,top:d,width:n,height:a,fontSize:i}}break;case L.Southwest:{const A=-r*E+-g*w,n=e.width+A*Q;let a=e.x-A*Q,i=e.height+A,s=e.fontSize;if(e.type===l.Textbox){const t=e;s=t.fontSize+A/8,i=K(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const o=z({...e}).center,c=z({...e,width:n,height:i,x:a}).center,h=T(c,o,B),d=h.x-n/2,D=h.y-i/2;C={...t,left:d,top:D,width:n,height:i,fontSize:s}}}return h=J(C.left,C.top,C.width,C.height,C.rotation),(!s||h.minX>=s.left&&h.maxX<=s.left+s.width&&h.minY>=s.top&&h.maxY<=s.top+s.height)&&(t=C),t;case Gt.Rotate:const d={x:A.clientX,y:A.clientY};let D,I=e.rotation;const u=z(e,n,{x:o,y:c}),p=V(d,u.c,u.d),m=V(d,u.d,u.c);if(0===i.filter((A=>"rotation"===A.type)).length)Lt=0,D=(e.rotation+p-m)%360;else{Lt+=Math.sqrt(r**2+g**2);const A=Math.abs(Lt)>.5*window.devicePixelRatio/o;D=A?(e.rotation+p-m)%360:i.find((A=>"rotation"===A.type))?.value||0,A&&(Lt=0)}return h=J(e.x,e.y,e.width,e.height,D),(!s||h.minX>=s.left&&h.maxX<=s.left+s.width&&h.minY>=s.top&&h.maxY<=s.top+s.height)&&(I=D),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:I};case Gt.Translate:let f,M,F=e.x,Y=e.y;if(0===i.filter((A=>"rotation"!==A.type)).length)Ot=0,bt=0,f=e.x+r,M=e.y+g;else{const A=i.find((A=>"x"===A.type)),t=i.find((A=>"y"===A.type));A||(Ot=0),t||(bt=0);const n=Math.abs(Ot)>.5*window.devicePixelRatio/o,a=Math.abs(bt)>.5*window.devicePixelRatio/c,s=A=>{switch(A){case-1:return 0;case 0:return e.width/2;case 1:return e.width;default:return 0}},B=A=>{switch(A){case-1:return 0;case 0:return e.height/2;case 1:return e.height;default:return 0}};if(0!==e.rotation)f=A?n?e.x+Ot:e.x:e.x+r,M=t?a?e.y+bt:e.y:e.y+g;else{if(A){const t=A.value-s(A.anchorPoint);f=n?t+Ot:t}else f=e.x+r;if(t){const A=t.value-B(t.anchorPoint);M=a?A+bt:A}else M=e.y+g}Ot=n?0:Ot+r,bt=a?0:bt+g}return h=J(f,M,e.width,e.height,e.rotation),(!s||h.minX>=s.left&&h.maxX<=s.left+s.width&&h.minY>=s.top&&h.maxY<=s.top+s.height)&&(F=f,Y=M),{top:Y,left:F,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,a,i,s),c=[];if(e.type===l.Textbox){const A=e;c.push(new I(A.id,A.input||""))}if(o.width>0&&o.height>0&&(c.push(new E(e.id,o.left,o.top),new Q(e.id,o.width,o.height),new h(e.id,o.rotation)),e.type===l.Textbox)){const A=e;o.fontSize&&A.fontSize!==o.fontSize&&c.push(new r(A.id,o.fontSize))}return c},Tt=.5,Kt=["TEXTAREA","INPUT"],jt=(A,t,e,n,a,i,o)=>{const{state:c,uiDispatcher:r}=HA(yt),{getLayoutById:g,getReducerState:w,flattenSequence:l}=mt(),[E,Q]=RA(void 0),[h,C]=RA(void 0),[d,D]=RA(void 0),I=g(c.layoutId);SA((()=>{if("adjustment"===a&&A?.current&&n){if(n<.5)return void r(new Nt({zoom:.5}));if(n>c.maxZoom)return void r(new Nt({zoom:c.maxZoom}));r(new Nt({zoom:n}))}}),[n,r,A,a,c.maxZoom]);const u=PA(((A,n)=>{r(new Nt({zoom:n}));const i=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!c.scrolledMovement&&"advanced"===a&&(s&&(t.current.scrollTop=e.current.offsetTop+(t.current.scrollHeight-t.current.clientHeight)/2),i&&(t.current.scrollLeft=(e.current.offsetLeft+t.current.scrollWidth-t.current.clientWidth)/2))}),[r,t,e,c.scrolledMovement,a]);SA((()=>{c.zoom<=1&&r(new Nt({scrolledMovement:!1}))}),[r,c.zoom]);const p=t?.current?.getBoundingClientRect(),m=((p?.width||1)+(p?.height||1))/2,f=(I.layoutState.layout.width+I.layoutState.layout.height)/2/m/c.zoom,F=GA((()=>{const A=c.activeModifierKeys,t=c.elementEvent,e=A.includes(Pt.ControlLeft)||A.includes(Pt.MetaLeft)||A.includes(Pt.ControlRight)||A.includes(Pt.MetaRight);if(!c.selectedElement||!t||e)return[];const n=t&&t.type===Gt.Translate,a=t&&t.type===Gt.Rotate,i=I.layoutState.elements.find((A=>A.id===c.selectedElement));return(n||a)&&i?Ut(i,I.layoutState,f,o):[]}),[c.selectedElement,c.elementEvent,c.activeModifierKeys,I.layoutState,f]),Y=PA((()=>{const A=M();Q(A),C(w().transaction)}),[w]),y=PA((()=>{r(new Nt({selectedElement:void 0}))}),[r]),x=PA((()=>{r(new Nt({scrolledMovement:!0}))}),[r]),N=PA(((e,n)=>{const a=I.layoutState.elements.find((A=>A.id===c.selectedElement));if(!(c.elementEvent&&A.current&&t.current&&c.selectedElement&&a))return;t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const s=A.current.getBoundingClientRect(),o=new B(zt({mX:d?e.screenX-d.screenX:0,mY:d?e.screenY-d.screenY:0,clientX:e.clientX,clientY:e.clientY},I.layoutState.layout,a,s,c.elementEvent,F,n));o.sequenceId=E,i(o,!1),D({screenX:e.screenX,screenY:e.screenY})}),[I.layoutState.elements,I.layoutState.layout,c.elementEvent,A,c.selectedElement,t,F,i,d]),H=PA((A=>{r(new Nt({elementEvent:A}))}),[r]),R=PA((()=>{r(new Nt({elementEvent:void 0})),E&&h&&(l(E,h),Q(void 0),C(void 0)),D(void 0)}),[r,E,h,l]),S=PA(((A,t)=>{let e=c.zoom;const n=c.maxZoom,o=c.selectedElement,g=c.activeModifierKeys;if((g.includes(Pt.AltLeft)||g.includes(Pt.AltRight))&&(A.code===Pt.Equal||A.code===Pt.Minus)){const t=.05*n;A.code===Pt.Equal?r(new Nt({zoom:e+t<=n?e+=t:e})):r(new Nt({zoom:e-t>=.5?e-t:e}))}const B=I.layoutState.elements.find((A=>A.id===o));if(o&&B){if(A.code===Pt.MetaLeft||A.code===Pt.ControlLeft||A.code===Pt.MetaRight||A.code===Pt.ControlRight){const t=A.code,e=c.activeModifierKeys;if(!e.includes(t))return r(new Nt({activeModifierKeys:e.concat(t)}))}if(A.code===Pt.ArrowDown||A.code===Pt.ArrowUp||A.code===Pt.ArrowLeft||A.code===Pt.ArrowRight){r(new Nt({elementEvent:{type:Gt.Translate}}));const e=kt(A.code,B,c.units,t);i(e,!1),r(new Nt({elementEvent:void 0}))}A.code!==Pt.Delete&&A.code!==Pt.Backspace||"advanced"!==a||(r(new Nt({selectedElement:void 0})),i(new s(B.id),!1))}}),[i,r,I.layoutState.elements,a,c.activeModifierKeys,c.maxZoom,c.selectedElement,c.units,c.zoom]),U=PA((A=>{if(A.code===Pt.MetaLeft||A.code===Pt.ControlLeft||A.code===Pt.MetaRight||A.code===Pt.ControlRight){const t=c.activeModifierKeys,e=A.code;r(new Nt({activeModifierKeys:t.filter((A=>A!==e))}))}}),[r,c.activeModifierKeys]);return{guidelines:F,scale:f,zoomableElementRef:e,setElementEvent:H,handleZoom:u,handleKeyDown:S,handleKeyUp:U,handlePointerPressedBackground:y,handlePointerReleased:R,handlePointerMove:N,handleScroll:x,handleSequenceStart:Y}},Vt=(A,t)=>{const e=GA((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),n=vA([]),a=PA((()=>{const A=e.every((A=>n.current.includes(A))),t=n.current.length===e.length;return A&&t}),[]),i=PA((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const i=A.target;return!(Kt.indexOf(i.tagName)>=0)&&(n.current=[...new Set([...n.current,e])],a()&&t(),A.preventDefault())}),[a,e,t,A]),s=PA((A=>{const t=String(A.key).toLowerCase();return n.current=n.current.filter((A=>A!==t)),A.preventDefault()}),[e]);SA((()=>(window.addEventListener("keydown",i),window.addEventListener("keyup",s),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",s)})),[i,s])},Wt=A=>{const{x:t,y:e,cursorStyle:n,onPointerDown:a,handleClass:i,cornerRadius:s,color:o,strokeWidth:c}=A;return JA("circle",{className:i,cx:t,cy:e,r:s,fill:"#ffffff",style:{cursor:n},stroke:o,strokeWidth:c,onPointerDown:a})},Xt=A=>{const{x:t,y:e,width:n,height:a,cursorStyle:i,onPointerDown:s,edgeHandleRadius:o,color:c,strokeWidth:r}=A;return JA("rect",{x:t,y:e,width:n,height:a,rx:o,fill:"#ffffff",style:{cursor:i},stroke:c,strokeWidth:r,onPointerDown:s})},qt=A=>{const{color:t,elementHeight:e,elementWidth:n,onBeginResize:a,rotation:i,scaleFactor:s,disableX:o,disableY:c}=A,r=10*s,g=5*s,B=40*s,w=12*s,l=1.2*s,E=e-2*r,Q=PA(((A,t,e)=>{A.stopPropagation(),a(t,e)}),[a]),h=PA((A=>Q(A,W(L.West,360-i),L.West)),[Q,i]),C=PA((A=>Q(A,W(L.East,360-i),L.East)),[Q,i]),d=PA((A=>Q(A,W(L.North,360-i),L.North)),[Q,i]),D=PA((A=>Q(A,W(L.South,360-i),L.South)),[Q,i]),I=PA((A=>Q(A,L.Northwest,L.Northwest)),[Q]),u=PA((A=>Q(A,L.Northeast,L.Northeast)),[Q]),p=PA((A=>Q(A,L.Southwest,L.Southwest)),[Q]),m=PA((A=>Q(A,L.Northeast,L.Southeast)),[Q]),f=B<=E;return kA(OA,{children:[JA(Wt,{x:0,y:0,cursorStyle:"nw-resize",onPointerDown:I,handleClass:"cornerNorthWest",cornerRadius:r,color:t,strokeWidth:l}),f?JA(Wt,{x:n,y:0,cursorStyle:"ne-resize",onPointerDown:u,handleClass:"cornerNorthEast",cornerRadius:r,color:t,strokeWidth:l}):void 0,f?JA(Wt,{x:n,y:e,cursorStyle:"se-resize",onPointerDown:m,handleClass:"cornerSouthEast",cornerRadius:r,color:t,strokeWidth:l}):void 0,f?JA(Wt,{x:0,y:e,cursorStyle:"sw-resize",onPointerDown:p,handleClass:"cornerSouthWest",cornerRadius:r,color:t,strokeWidth:l}):void 0,f&&!o?JA(Xt,{x:-w/2,y:e/2-B/2,width:w,height:B,onPointerDown:h,edgeHandleRadius:g,cursorStyle:"w-resize",color:t,strokeWidth:l}):void 0,f&&!c?JA(Xt,{x:n/2-B/2,y:e-w/2,width:B,height:w,onPointerDown:D,edgeHandleRadius:g,cursorStyle:"s-resize",color:t,strokeWidth:l}):void 0,o?void 0:JA(Xt,{x:n-w/2,y:e/2-Math.min(B,.8*e)/2,width:w,height:Math.min(B,.8*e),onPointerDown:C,edgeHandleRadius:g,cursorStyle:"e-resize",color:t,strokeWidth:l}),f&&!c?JA(Xt,{x:n/2-B/2,y:-w/2,width:B,height:w,onPointerDown:d,edgeHandleRadius:g,cursorStyle:"n-resize",color:t,strokeWidth:l}):void 0]})},Zt=A=>{const{color:t,elementWidth:e,onBeginRotate:n,scaleFactor:a}=A,i=PA((A=>{A.stopPropagation(),n()}),[n]),s=10*a,o=1.2*a;return kA("g",{children:[JA("circle",{cx:e/2,cy:-2.5*s,r:1.3*s,fill:"rgba(0, 0, 0, 0.5)",opacity:.4,style:{cursor:"ew-resize"},onPointerDown:i}),JA("circle",{cx:e/2,cy:-2.5*s,r:s,fill:"#fff",style:{cursor:"ew-resize"},stroke:t,strokeWidth:o,onPointerDown:i}),kA("svg",{x:e/2-s,y:-2.5*s-s,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*s,viewBox:"0 0 24 24",width:2*s,fill:t,onPointerDown:i,children:[JA("path",{d:"M0 0h24v24H0z",fill:"none"}),JA("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})]})]})},$t=({color:A,height:t,highlighted:e,id:n,immutable:a,onBeginMove:i,onPointerEnter:s,onPointerLeave:o,onSelected:c,pressed:r,rotation:g,scaleFactor:B,selected:w,width:l,x:E,y:Q})=>{const h=1.2*B,C=PA((A=>{2===A.button&&(A.stopPropagation(),c(n,A)),0===A.button&&(A.stopPropagation(),!w&&c(n,A),i())}),[n,w,c,i]),d=PA((()=>{s(n)}),[n,s]),D=PA((()=>{o(n)}),[n,o]);return JA("g",{transform:`translate(${E}, ${Q}) rotate(${g} ${l/2} ${t/2})`,children:JA("rect",{className:"interactableInnerRect",width:l,height:t,stroke:w||e?A:"none",pointerEvents:a?"none":"visibleFill",fill:"none",strokeWidth:h,style:{cursor:a?void 0:w?r?"grabbing":"grab":"pointer"},onPointerDown:a?void 0:C,onPointerEnter:a?void 0:d,onPointerLeave:a?void 0:D})})},_t=({color:A,height:t,onBeginResize:e,onBeginRotate:n,rotation:a,scaleFactor:i,width:s,x:o,y:c,disableX:r,disableY:g})=>kA("g",{transform:`translate(${o}, ${c}) rotate(${a} ${s/2} ${t/2})`,children:[JA(Zt,{color:A,elementWidth:s,onBeginRotate:n,scaleFactor:i}),JA(qt,{color:A,elementHeight:t,elementWidth:s,rotation:a,scaleFactor:i,onBeginResize:e,disableX:r,disableY:g})]}),Ae=({primaryColor:A,containerHeight:t,containerWidth:e,customViewbox:n,editorRef:a,elementEvent:i,guidelines:s,layoutHeight:o,layoutWidth:c,targetedElements:r,scale:g,selectedElement:B,onElementEvent:w,onElementSelected:E,onSequenceStart:Q,onMouseMove:h})=>{const{state:C}=Ht(),{getLayoutById:d}=mt(),D=d(C.layoutId),[I,u]=RA(void 0),p=PA((A=>{u(A)}),[]),m=PA((A=>{I===A&&u(void 0)}),[I]),f=PA((()=>{Q(),w({type:Gt.Translate})}),[w]),M=PA(((A,t)=>{Q(),w({type:Gt.Resize,relativeAxis:A,screenAxis:t})}),[w]),F=PA((()=>{Q(),w({type:Gt.Rotate})}),[w]),Y=n||{x:0,y:0,width:c,height:o},y=g*(Math.sqrt(Y.width*Y.height)/1e3)*(100/Math.sqrt(t*e))*Math.sqrt((x=e/t,Math.exp(Math.abs(Math.log(x)))));var x;const N=D.layoutState.elements,H=N.find((A=>A.id===B));return kA("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",style:{touchAction:"none",position:"absolute",maxWidth:"100%",maxHeight:"100%"},width:"auto",height:"auto",viewBox:`${Y.x} ${Y.y} ${Y.width} ${Y.height}`,overflow:"overlay",children:[JA("rect",{onMouseMove:h,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:a,width:c,height:o}),s.map((A=>A.svgNode)),N.map((t=>{const e=void 0!==B&&t.id===B,n=e&&void 0!==i,a=void 0!==I&&t.id===I;return JA($t,{color:A,id:t.id,selected:e,highlighted:a,pressed:n,x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation,immutable:t.immutable||r&&!r.includes(t.id),onSelected:E,onBeginMove:f,onPointerEnter:p,onPointerLeave:m,scaleFactor:y},t.id)})),H&&JA(_t,{color:A,x:H.x,y:H.y,disableX:H.type===l.Frame,disableY:H.type===l.Textbox||H.type===l.Frame,width:H.width,height:H.height,rotation:H.rotation,onBeginResize:M,onBeginRotate:F,scaleFactor:y})]})},te=A=>{const{color:t,editorRef:e,zoomableElementRef:n,interactionElementRef:a,guidelines:i,isMakingAdjustments:s,viewmask:o,visibleLayoutId:c,xTranslation:r,yTranslation:g,targetedElements:B,borderRadius:w,handleContextMenu:l,onMouseMove:E,handleKeyDown:Q,handleKeyUp:h,handlePointerMove:C,handlePointerPressedBackground:d,handlePointerReleased:D,handleScroll:I,onSequenceStart:u,setElementEvent:p,onElementSelected:m}=A,{getLayoutById:f}=mt(),M=f(c),F=M.layoutState,{state:Y}=Ht(),y=PA((A=>{if(o){const t={left:o.x,top:o.y,width:o.width,height:o.height,panelId:"",rotation:0};return Q(A,t)}return Q(A)}),[Q,o]),x=PA((A=>{if(o){const t={left:o.x,top:o.y,width:o.width,height:o.height,panelId:"",rotation:0};return C(A,t)}return C(A)}),[C,o]);return JA("div",{style:{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:"none"},onContextMenu:l,onKeyDown:y,onKeyUp:h,onPointerDown:d,onPointerMoveCapture:x,onPointerUp:D,onWheelCapture:I,ref:a,tabIndex:-1,children:kA("div",{ref:n,style:{height:"100%",transform:`scale(${Y.zoom}) translate(${r}px, ${g}px)`,display:"flex",justifyContent:"center",filter:"drop-shadow(rgba(0, 0, 0, 0.2) 0px 0px 6px)"},children:[A.children,M.getComponentWithProps({height:s?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",viewmask:o,width:s?"100%":"auto",borderRadius:w}),JA(Ae,{primaryColor:t,containerHeight:n.current?.offsetHeight||1024,containerWidth:n.current?.offsetWidth||1024,editorRef:e,elementEvent:Y.elementEvent,guidelines:i,layoutHeight:F.layout.height,layoutWidth:F.layout.width,onElementEvent:p,onSequenceStart:u,onElementSelected:m,scale:10/Y.zoom,selectedElement:Y.selectedElement,targetedElements:B,onMouseMove:E})]})})},ee=({color:A,borderRadius:t,guidelineColor:e,handleContextMenu:n,onMouseMove:a,onElementSelected:i})=>{const{commandDispatcher:s,getLayoutById:o}=mt(),{state:c,uiDispatcher:r}=Ht(),g=vA(null),B=vA(null),w=vA(null),{guidelines:E,handleKeyDown:Q,handleKeyUp:h,handlePointerMove:C,handlePointerPressedBackground:d,handlePointerReleased:D,handleScroll:I,handleSequenceStart:u,setElementEvent:p}=jt(g,B,w,void 0,"advanced",s,e),m=PA(((A,t)=>{const e=o(c.layoutId).layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===l.Textbox){const t=e.algorithm;(!t||t===v.Autosize)&&s(new P(A,v.Traditional),!0)}i&&i(A,t),r(new Nt({selectedElement:A}))}),[s,o,c.layoutId,r]);return JA(te,{color:A,editorRef:g,interactionElementRef:B,zoomableElementRef:w,guidelines:E,visibleLayoutId:c.layoutId,xTranslation:0,yTranslation:0,borderRadius:t,handleContextMenu:n,onMouseMove:a,handleKeyDown:Q,handleKeyUp:h,handlePointerMove:C,handlePointerPressedBackground:d,handlePointerReleased:D,handleScroll:I,onSequenceStart:u,setElementEvent:p,onElementSelected:m})},ne=FA`
1
+ import{CommandContext as A,AssetType as t,BringForwardCommand as e,CanvasCommand as n,CreateElementCommand as a,CreateLayoutCommand as i,DeleteElementCommand as s,FontAlignmentCommand as o,FontColorCommand as c,FontSizeCommand as r,FontSourceCommand as g,GroupCommand as B,LayoutElementFactory as w,LayoutElementType as l,MoveCommand as E,ResizeCommand as Q,RotateCommand as h,SendBackwardsCommand as C,StepAspectType as d,StepType as D,TextChangeCommand as I,UnitOfMeasurement as u,dataUrlFromExternalUrl as p,findElement as m,frameDataCache as f,generate as M,generateSVGWithUnknownColors as F,getAttributesFromArrayBuffer as Y,rehydrateSerializedLayout as y,getFrameData as x,getSvgString as N,loadFontFromDataUrl as H,loadFontFromExternalUrl as R,determineCorrectFontSizeAndLines as S,patternImageDataCache as U,registerJSDOM as G,TextAlgorithm as v,FontAlgorithmCommand as P,getAxisAlignedBoundingBox as J,isCloseToValue as k,mmPerPixel as O,cmPerPixel as b,ScaleAxis as L,getElementVertices as z,rotateAroundPoint as T,calculateTextboxLines as K,defaultLineHeightFactor as j,findAngle as V,currentDirection as W,modifySVGWithElementProperties as X,IllustrationColorCommand as q,IllustrationCacheCommand as Z,UpdateWorkflowStateCommand as $,calculateOffsets as _,UpdateFramePattern as AA,generateDefaultRectangleFrameSvg as tA,fetchAsString as eA,GetSVGDimensions as nA,getFontMetrics as aA,applyTextTransformations as iA,createElementNS as sA,createElement as oA,sortElementsByLayersWithIndex as cA,toBase64 as rA,getPatternImageData as gA,getVariant as BA,generateFrameSVG as wA,getDefaultVariant as lA,domParser as EA,sanitizeSvgTree as QA,traverse as hA,xmlSerializer as CA,fetchAsArrayBuffer as dA,arrayBufferToDataUrl as DA,loadFontFaceSet as IA}from"@spiffcommerce/papyrus";import uA from"swagger-client";import{createHttpLink as pA,InMemoryCache as mA,ApolloClient as fA,from as MA,gql as FA}from"@apollo/client";import{setContext as YA}from"@apollo/client/link/context";import{onError as yA}from"@apollo/client/link/error";import{fetch as xA}from"cross-fetch";import{createContext as NA,useContext as HA,useState as RA,useEffect as SA,useReducer as UA,useMemo as GA,useRef as vA,useCallback as PA}from"react";import{jsx as JA,jsxs as kA,Fragment as OA}from"react/jsx-runtime";import bA from"lodash.isequal";import{Canvg as LA}from"canvg";import zA from"lodash.clonedeep";import TA from"lodash.debounce";import{toString as KA}from"qrcode";import jA from"svg-path-bbox";function VA(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class WA extends Error{constructor(A){super(A),this.name=this.constructor.name}}class XA extends WA{constructor(A){super(`ConfigurationError - ${A}`)}}class qA extends XA{constructor(A){super(`Option not Configured: ${A.stepTitle}`),VA(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class ZA extends XA{constructor(A){super(`Panel not Found: ${A.panelId}`),VA(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class $A extends XA{constructor(A){super(`Asset not found for variant: ${A.name}`),VA(this,"variant",void 0),this.variant=A}}class _A extends XA{constructor(A){super(`Resource not found for asset: ${A.name}`),VA(this,"asset",void 0),this.asset=A}}class At extends XA{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),VA(this,"step",void 0),this.step=A}}class tt extends WA{constructor(A){super(`ImplementationError - ${A}`)}}class et extends tt{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class nt extends tt{constructor(A){super(`Parsing Error: ${A}`)}}class at extends tt{constructor(A){super(`Client Error: ${A}`)}}class it extends tt{constructor(A){super(`Resource Generation Failed: ${A}`)}}class st{get(A){return localStorage.getItem(A)||void 0}set(A,t){localStorage.setItem(A,t)}remove(A){localStorage.removeItem(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}class ot{constructor(){var A,t,e;A=this,t="storage",e=new Map,t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e}get(A){return this.storage.get(A)||void 0}set(A,t){this.storage.set(A,t)}remove(A){this.storage.delete(A)}getMap(A){const t=this.get(A);if(t)return new Map(JSON.parse(t))}setMap(A,t){const e=JSON.stringify([...t.entries()]);this.set(A,e)}}const ct=(()=>{try{return localStorage?new st:new ot}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new ot}})();function rt(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const gt=new class{constructor(){rt(this,"defaultServerUrl","https://api.spiff.com.au"),rt(this,"defaultServicesApiUrl","https://services.spiff.com.au"),rt(this,"defaultHubUrl","https://hub.spiff.com.au"),rt(this,"serverUrl",void 0),rt(this,"servicesApiUrl",void 0),rt(this,"hubUrl",void 0),rt(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(A){this.serverUrl=A,this.serverUrlCallbacks.forEach((A=>A()))}setServicesApiUrl(A){this.servicesApiUrl=A}setHubUrl(A){this.hubUrl=A}addServerUrlCallback(A){this.serverUrlCallbacks.push(A)}};function Bt(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let wt;const lt=A=>{wt=A},Et=async()=>{const A={transactionOwnerId:wt};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=gt.getHubUrl();if(window.location.href.includes("localhost")||window.location.href.includes("ngrok"))return void A({});const e=n=>{n.origin===t&&(window.removeEventListener("message",e),A(n.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))})),...A}:A};const Qt=new class{constructor(){Bt(this,"client",void 0),Bt(this,"uncachedOperations",[]),gt.addServerUrlCallback((async()=>{this.client=void 0,this.client=await this.constructClient()}))}setUncachedOperations(A){this.uncachedOperations=A}async execute(A,t){const e=this.uncachedOperations.includes(A)?A+"_private":A;return new Promise(((A,n)=>{this.getClient().then((a=>{a.execute({operationId:e,parameters:t}).then((t=>A(t))).catch((A=>{A.response&&A.response.status&&A.response.status>=500||(!A.response&&n(new Error(A)),A.response&&n(new Error(`${A.response.status} ${A.response.url}`)))}))})).catch((A=>{n(A)}))}))}async syncAuth(A){const t=await Et();if(t.bearer?A.authorizations={...A.authorizations,OAuth2:{token:{access_token:t.bearer,token_type:"Bearer"}}}:A.authorizations={...A.authorizations,OAuth2:{token:{access_token:"",token_type:"Bearer"}}},t.activeIntegration)A.authorizations={...A.authorizations,ActiveIntegration:t.activeIntegration};else{const t={...A.authorizations};delete t.ActiveIntegration,A.authorizations=t}if(t.partnerId)A.authorizations={...A.authorizations,PartnerId:t.partnerId};else{const t={...A.authorizations};delete t.PartnerId,A.authorizations=t}}async getClient(){return this.client||(this.client=await this.constructClient()),this.syncAuth(this.client),Promise.resolve(this.client)}async constructClient(){const A=await Et(),t=gt.getServerUrl()+"/v2/api-docs";return await uA(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const ht=new class{constructor(){Bt(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),gt.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=pA({uri:`${gt.getServerUrl()}/graphql`,fetch:xA}),t=YA((async(A,{headers:t})=>{const e=t||{},n=await Et();return n.bearer&&(e.Authorization=`Bearer ${n.bearer}`),n.partnerId&&(e.partnerId=n.partnerId),n.activeIntegration&&(e.activeIntegration=n.activeIntegration),n.transactionOwnerId&&(e.transactionOwnerId=n.transactionOwnerId),{headers:e}})),e=yA((({operation:A,graphQLErrors:t,networkError:e})=>{(t||[]).forEach((({message:t,locations:e,path:n})=>{console.log("[GraphQL Operation Error]"),console.log("Name:"+A.operationName),console.log("Query:"+JSON.stringify(A.query)),console.log(`Message: ${t}, Location: ${JSON.stringify(e,null,2)}, Path: ${n}`),console.log("Variables:"+JSON.stringify(A.variables))})),e&&console.log("GraphQL Network error")}));const n=new mA({typePolicies:{Transaction:{fields:{bulkEmailAddress:{read:(A=null)=>A},transactionOwnerId:{read:(A=null)=>A},customLogoLink:{read:(A=null)=>A},workflowFooterLogoLink:{read:(A=null)=>A},workflowState:{read:(A=null)=>A},bulkSourceUrl:{read:(A=null)=>A},externalDesignProductId:{read:(A=null)=>A},externalDesignProductVariantId:{read:(A=null)=>A},lastSyncedAt:{read:(A=null)=>A}}},Workflow:{fields:{isPresent:{read:(A=null)=>A}}},Product:{fields:{imageUrl:{read:(A=null)=>A},overlayImageUrl:{read:(A=null)=>A},preloadImageUrl:{read:(A=null)=>A},weight:{read:(A=null)=>A}}}}});return new fA({link:MA([e,t,A]),cache:n,name:"Core"})}};function Ct(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class dt{static add(A){const t=A?.links.find((A=>"cdn"===A.rel));if(!t)return void console.error("Failed to find cdn link on asset, cannot persist!");const e=new Map;e.set(A.data.key,t.href);const n=ct.getMap("persistentAssets");n&&n.forEach(((A,t)=>{e.set(t,A)})),ct.setMap("persistentAssets",e)}static remove(A){const t=ct.getMap("persistentAssets");if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),ct.setMap("persistentAssets",t))}static list(){const A=ct.getMap("persistentAssets");return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const Dt=new class{constructor(){Ct(this,"server",void 0),Ct(this,"cache",new Map),Ct(this,"materialCache",new Map),Ct(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await Y(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)}})),Ct(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await Dt.getLocalOrFromServer(A.assetKey))),Ct(this,"getMaterialFromVariant",(async A=>A.material?A.material:await Dt.getMaterialLocalOrFromServer(A.materialId))),this.server=Qt}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new et("Failed to get asset from cache!");return t}const t=(async()=>(await Qt.execute("getAssetByKeyV2",{assetKey:A.replace(/\//g,"_")})).body)();return this.cache.set(A,t),t}async getMaterialLocalOrFromServer(A){if(this.materialCache.has(A))return this.materialCache.get(A);const t=(async()=>(await Qt.execute("getMaterialV2",{id:A})).body)();return this.materialCache.set(A,t),t}async uploadAssetWithProgress(A,t,e,n,a){const i=await this.dispatchCreateAssetRequest(A,t,n,a);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;dt.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),a=n?t.Image:t.Illustration;if(n){const t=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(t,a,e,!0)}{const t={name:A.name,blob:new Blob([A],{type:A.type})};return await Dt.uploadAssetWithProgress(t,a,e,!0)}}removePersistedAsset(A){dt.remove(A)}getPersistedAssets(){return dt.list()}async dispatchCreateAssetRequest(A,t,e,n){const a=A.blob.type?A.blob.type:this.guessMIME(A.name);return{assetResponse:(await this.server.execute("createAsset",{assetDetails:{name:A.name,type:t,mimeType:a,storageOwnerId:n,userAnonymous:!0}},e)).body,mimeType:a}}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 et("Unexpected mimetype: "+t)}}};function It(A,t,e){return t in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const ut=new class{constructor(){It(this,"cache",new Map),It(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),It(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),It(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),It(this,"getOptionFromStep",(async A=>{if(A.option){const t=A.option.data.id;return t&&!this.cache.has(t)&&this.cache.set(t,Promise.resolve(A.option)),A.option}return await ut.getOption(Qt,A.optionId)}))}async getOption(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(async()=>(await A.execute("getOptionV2",{id:t})).body)();return this.cache.set(t,e),e}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await Dt.getLocalOrFromServer(A.thumbnailKey),e=t.links.find((A=>"thumbnail"===A.rel)),n=t.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}const t=A.assetKey;if(t){const A=await Dt.getLocalOrFromServer(t),e=A.links.find((A=>"thumbnail"===A.rel)),n=A.links.find((A=>"cdn"===A.rel));return e?.href||n?.href}return A.materialId?A.materialId:""}getDefaultVariant(A){const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0}},pt=NA(new A),mt=()=>{const A=HA(pt),[t,e]=RA(new Date);SA((()=>{const t=()=>{e(new Date)};return A.registerStateCallback(t),()=>{A.unregisterStateCallback(t)}}),[A]);return{commandDispatcher:(t,e)=>{A.apply(t,e)},getLayoutById:t=>A.getLayoutById(t),getAllLayouts:()=>A.getAllLayouts(),getReducerState:()=>{const t=A.getState();return t||{transaction:{layouts:{},serializableWorkflow:{steps:[]}}}},lastUpdated:t,flattenSequence:(t,e)=>{A.flattenSequence(t,e)}}};let ft;var Mt;(Mt=ft||(ft={})).None="None",Mt.FrameAdjustment="FrameAdjustment",Mt.FinalizeDesign="FinalizeDesign";const Ft=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,maxZoom:5,units:u.Pixel,subMenu:ft.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Yt=(A,t)=>bA(A,t.apply(A))?A:t.apply(A),yt=NA({}),xt=A=>{const{getAllLayouts:t}=mt(),[e,n]=UA(Yt,Ft(t,A.defaultZoom||1)),a=GA((()=>({state:e,uiDispatcher:n})),[e,n]);return JA(yt.Provider,{value:a,children:A.children})};class Nt{constructor(A){var t,e,n;n=void 0,(e="changes")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.changes=A}apply(A){return{...A,...this.changes}}}const Ht=()=>HA(yt);let Rt;var St;(St=Rt||(Rt={}))[St.Orbit=0]="Orbit",St[St.Pan=1]="Pan";const Ut=(A,t,e,n)=>{const a=t.layout.width,i=t.layout.height,s=t.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),o=s.map((A=>J(A.x,A.y,A.width,A.height,A.rotation))),c=[],r=new Set;o.forEach((A=>r.add(A.minX))),o.forEach((A=>r.add(A.maxX))),[0,a/2,a].forEach((A=>r.add(A)));const g=new Set;o.forEach((A=>g.add(A.minY))),o.forEach((A=>g.add(A.maxY))),[0,i/2,i].forEach((A=>g.add(A)));const B=s.map((A=>A.y));for(let A=-315;A<=315;A+=45)B.push(A);const w=J(A.x,A.y,A.width,A.height,A.rotation),l=[{value:w.minX,anchor:-1},{value:w.minX+(w.maxX-w.minX)/2,anchor:0},{value:w.minX+(w.maxX-w.minX),anchor:1}],E=[{value:w.minY,anchor:-1},{value:w.minY+(w.maxY-w.minY)/2,anchor:0},{value:w.minY+(w.maxY-w.minY),anchor:1}],Q=[{value:A.rotation,anchor:0}],h=(A,t,n,s)=>{const o=[];return t.forEach((t=>{const c=n.find((A=>k(t,A.value,.5*e))),[r,g]=((A,t)=>[{x:"x"===A?t:0,y:"x"===A?0:t},{x:"x"===A?t:a,y:"x"===A?i:t}])(A,t),B="rotation"===A?null:JA("line",{x1:r.x,y1:r.y,x2:g.x,y2:g.y,stroke:s||"#D61B5C",strokeWidth:1.2*e},`${A}-${t}-${r.x}-${r.y}-${g.x}-${g.y}`);void 0!==c&&o.push({type:A,value:t,anchorPoint:c.anchor,svgNode:B,guidelineCoordinates:[r,g]})})),o};return c.push(...h("x",Array.from(r),l,n),...h("y",Array.from(g),E,n),...h("rotation",B,Q,n)),c};let Gt;var vt;let Pt;var Jt;(vt=Gt||(Gt={})).Translate="Translate",vt.Rotate="Rotate",vt.Resize="Resize",(Jt=Pt||(Pt={})).ControlLeft="ControlLeft",Jt.ControlRight="ControlRight",Jt.Equal="Equal",Jt.MetaLeft="MetaLeft",Jt.MetaRight="MetaRight",Jt.Minus="Minus",Jt.ArrowLeft="ArrowLeft",Jt.ArrowRight="ArrowRight",Jt.ArrowUp="ArrowUp",Jt.ArrowDown="ArrowDown",Jt.AltLeft="AltLeft",Jt.AltRight="AltRight",Jt.Delete="Delete",Jt.Backspace="Backspace";const kt=(A,t,e,n)=>{const a=()=>{switch(e){case u.Pixel:return 1;case u.Millimeter:return O;case u.Centimeter:return b;default:throw new et("Unknown unit of measurement")}};let i=t.x,s=t.y,o=t.x,c=t.y;switch(A){case Pt.ArrowLeft:o=t.x-1/a();break;case Pt.ArrowUp:c=t.y-1/a();break;case Pt.ArrowRight:o=t.x+1/a();break;case Pt.ArrowDown:c=t.y+1/a();break;default:throw new et("Unhandled element interaction!")}const r=J(o,c,t.width,t.height,t.rotation);return(!n||r.minX>=n.left&&r.maxX<=n.left+n.width&&r.minY>=n.top&&r.maxY<=n.top+n.height)&&(i=o,s=c),new E(t.id,i,s)};var Ot=0,bt=0,Lt=0;const zt=(A,t,e,n,a,i,s)=>{const o=((A,t,e,n,a,i,s)=>{const o=n.width/t.width,c=n.height/t.height,r=A.mX/o,g=A.mY/c,B=e.rotation*Math.PI/180,w=Math.sin(B),E=Math.cos(B),Q=e.type===l.Textbox?1:e.width/e.height;let h;switch(a.type){case Gt.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},C=t;switch(a.screenAxis){case L.North:{const A=-r*w+g*E,n=e.y+A,a=e.height-A,i=z({...e}).center,s=z({...e,y:n,height:a}).center,o=T(s,i,B),c=o.x-e.width/2,l=o.y-a/2;C={...t,left:c,top:l,height:a}}break;case L.East:{const A=r*E+g*w,n=e.width+A;let a=e.height;if(e.type===l.Textbox){const A=e;a=K(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const i=z({...e}).center,s=z({...e,width:n,height:a}).center,o=T(s,i,B),c=o.x-n/2,Q=o.y-a/2;C={...t,left:c,top:Q,width:n,height:a}}break;case L.West:{const A=r*E+g*w,n=e.x+A,a=e.width-A;let i=e.height;if(e.type===l.Textbox){const A=e;i=K(A.fontSize,A.fontData,A,A.input||A.text||"",A.lineHeight).requiredHeight}const s=z({...e}).center,o=z({...e,width:a,height:i,x:n}).center,c=T(o,s,B),Q=c.x-a/2,h=c.y-i/2;C={...t,left:Q,top:h,width:a,height:i}}break;case L.South:{const A=-r*w+g*E,n=e.height+A,a=z({...e}).center,i=z({...e,height:n}).center,s=T(i,a,B),o=s.x-e.width/2,c=s.y-n/2;C={...t,left:o,top:c,height:n}}break;case L.Northeast:{const A=r*E+g*w,n=e.width+A;let a=e.height+A/Q,i=e.y-A,s=e.fontSize;if(e.type===l.Textbox){const t=e;s=t.fontSize+A/8,a=K(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||j;i=e.y-A*n/8}const o=z({...e}).center,c=z({...e,width:n,height:a,y:i}).center,h=T(c,o,B),d=h.x-n/2,D=h.y-a/2;C={...t,left:d,top:D,width:n,height:a,fontSize:s}}break;case L.Northwest:{const A=-r*E+-g*w,n=e.x-A,a=e.width+A*Q;let i=e.y-A,s=e.height+A,o=e.fontSize;if(e.type===l.Textbox){const t=e;o=t.fontSize+A/8,s=K(o,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight;const n=t.lineHeight||j;i=e.y-A*n/8}const c=z({...e}).center,h=z({...e,x:n,y:i,width:a,height:s}).center,d=T(h,c,B),D=d.x-a/2,I=d.y-s/2;C={...t,left:D,top:I,width:a,height:s,fontSize:o}}break;case L.Southeast:{const A=r*E+g*w,n=e.width+A;let a=e.height+A/Q,i=e.fontSize;if(e.type===l.Textbox){const t=e;i=t.fontSize+A/8,a=K(i,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const s=z({...e}).center,o=z({...e,width:n,height:a}).center,c=T(o,s,B),h=c.x-n/2,d=c.y-a/2;C={...t,left:h,top:d,width:n,height:a,fontSize:i}}break;case L.Southwest:{const A=-r*E+-g*w,n=e.width+A*Q;let a=e.x-A,i=e.height+A,s=e.fontSize;if(e.type===l.Textbox){const t=e;s=t.fontSize+A/8,i=K(s,t.fontData,t,t.input||t.text||"",t.lineHeight).requiredHeight}const o=z({...e}).center,c=z({...e,width:n,height:i,x:a}).center,h=T(c,o,B),d=h.x-n/2,D=h.y-i/2;C={...t,left:d,top:D,width:n,height:i,fontSize:s}}}return h=J(C.left,C.top,C.width,C.height,C.rotation),(!s||h.minX>=s.left&&h.maxX<=s.left+s.width&&h.minY>=s.top&&h.maxY<=s.top+s.height)&&(t=C),t;case Gt.Rotate:const d={x:A.clientX,y:A.clientY};let D,I=e.rotation;const u=z(e,n,{x:o,y:c}),p=V(d,u.c,u.d),m=V(d,u.d,u.c);if(0===i.filter((A=>"rotation"===A.type)).length)Lt=0,D=(e.rotation+p-m)%360;else{Lt+=Math.sqrt(r**2+g**2);const A=Math.abs(Lt)>.5*window.devicePixelRatio/o;D=A?(e.rotation+p-m)%360:i.find((A=>"rotation"===A.type))?.value||0,A&&(Lt=0)}return h=J(e.x,e.y,e.width,e.height,D),(!s||h.minX>=s.left&&h.maxX<=s.left+s.width&&h.minY>=s.top&&h.maxY<=s.top+s.height)&&(I=D),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:I};case Gt.Translate:let f,M,F=e.x,Y=e.y;if(0===i.filter((A=>"rotation"!==A.type)).length)Ot=0,bt=0,f=e.x+r,M=e.y+g;else{const A=i.find((A=>"x"===A.type)),t=i.find((A=>"y"===A.type));A||(Ot=0),t||(bt=0);const n=Math.abs(Ot)>.5*window.devicePixelRatio/o,a=Math.abs(bt)>.5*window.devicePixelRatio/c,s=A=>{switch(A){case-1:return 0;case 0:return e.width/2;case 1:return e.width;default:return 0}},B=A=>{switch(A){case-1:return 0;case 0:return e.height/2;case 1:return e.height;default:return 0}};if(0!==e.rotation)f=A?n?e.x+Ot:e.x:e.x+r,M=t?a?e.y+bt:e.y:e.y+g;else{if(A){const t=A.value-s(A.anchorPoint);f=n?t+Ot:t}else f=e.x+r;if(t){const A=t.value-B(t.anchorPoint);M=a?A+bt:A}else M=e.y+g}Ot=n?0:Ot+r,bt=a?0:bt+g}return h=J(f,M,e.width,e.height,e.rotation),(!s||h.minX>=s.left&&h.maxX<=s.left+s.width&&h.minY>=s.top&&h.maxY<=s.top+s.height)&&(F=f,Y=M),{top:Y,left:F,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,a,i,s),c=[];if(e.type===l.Textbox){const A=e;c.push(new I(A.id,A.input||""))}if(o.width>0&&o.height>0&&(c.push(new E(e.id,o.left,o.top),new Q(e.id,o.width,o.height),new h(e.id,o.rotation)),e.type===l.Textbox)){const A=e;o.fontSize&&A.fontSize!==o.fontSize&&c.push(new r(A.id,o.fontSize))}return c},Tt=.5,Kt=["TEXTAREA","INPUT"],jt=(A,t,e,n,a,i,o)=>{const{state:c,uiDispatcher:r}=HA(yt),{getLayoutById:g,getReducerState:w,flattenSequence:l}=mt(),[E,Q]=RA(void 0),[h,C]=RA(void 0),[d,D]=RA(void 0),I=g(c.layoutId);SA((()=>{if("adjustment"===a&&A?.current&&n){if(n<.5)return void r(new Nt({zoom:.5}));if(n>c.maxZoom)return void r(new Nt({zoom:c.maxZoom}));r(new Nt({zoom:n}))}}),[n,r,A,a,c.maxZoom]);const u=PA(((A,n)=>{r(new Nt({zoom:n}));const i=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!c.scrolledMovement&&"advanced"===a&&(s&&(t.current.scrollTop=e.current.offsetTop+(t.current.scrollHeight-t.current.clientHeight)/2),i&&(t.current.scrollLeft=(e.current.offsetLeft+t.current.scrollWidth-t.current.clientWidth)/2))}),[r,t,e,c.scrolledMovement,a]);SA((()=>{c.zoom<=1&&r(new Nt({scrolledMovement:!1}))}),[r,c.zoom]);const p=t?.current?.getBoundingClientRect(),m=((p?.width||1)+(p?.height||1))/2,f=(I.layoutState.layout.width+I.layoutState.layout.height)/2/m/c.zoom,F=GA((()=>{const A=c.activeModifierKeys,t=c.elementEvent,e=A.includes(Pt.ControlLeft)||A.includes(Pt.MetaLeft)||A.includes(Pt.ControlRight)||A.includes(Pt.MetaRight);if(!c.selectedElement||!t||e)return[];const n=t&&t.type===Gt.Translate,a=t&&t.type===Gt.Rotate,i=I.layoutState.elements.find((A=>A.id===c.selectedElement));return(n||a)&&i?Ut(i,I.layoutState,f,o):[]}),[c.selectedElement,c.elementEvent,c.activeModifierKeys,I.layoutState,f]),Y=PA((()=>{const A=M();Q(A),C(w().transaction)}),[w]),y=PA((()=>{r(new Nt({selectedElement:void 0}))}),[r]),x=PA((()=>{r(new Nt({scrolledMovement:!0}))}),[r]),N=PA(((e,n)=>{const a=I.layoutState.elements.find((A=>A.id===c.selectedElement));if(!(c.elementEvent&&A.current&&t.current&&c.selectedElement&&a))return;t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const s=A.current.getBoundingClientRect(),o=new B(zt({mX:d?e.screenX-d.screenX:0,mY:d?e.screenY-d.screenY:0,clientX:e.clientX,clientY:e.clientY},I.layoutState.layout,a,s,c.elementEvent,F,n));o.sequenceId=E,i(o,!1),D({screenX:e.screenX,screenY:e.screenY})}),[I.layoutState.elements,I.layoutState.layout,c.elementEvent,A,c.selectedElement,t,F,i,d]),H=PA((A=>{r(new Nt({elementEvent:A}))}),[r]),R=PA((()=>{r(new Nt({elementEvent:void 0})),E&&h&&(l(E,h),Q(void 0),C(void 0)),D(void 0)}),[r,E,h,l]),S=PA(((A,t)=>{let e=c.zoom;const n=c.maxZoom,o=c.selectedElement,g=c.activeModifierKeys;if((g.includes(Pt.AltLeft)||g.includes(Pt.AltRight))&&(A.code===Pt.Equal||A.code===Pt.Minus)){const t=.05*n;A.code===Pt.Equal?r(new Nt({zoom:e+t<=n?e+=t:e})):r(new Nt({zoom:e-t>=.5?e-t:e}))}const B=I.layoutState.elements.find((A=>A.id===o));if(o&&B){if(A.code===Pt.MetaLeft||A.code===Pt.ControlLeft||A.code===Pt.MetaRight||A.code===Pt.ControlRight){const t=A.code,e=c.activeModifierKeys;if(!e.includes(t))return r(new Nt({activeModifierKeys:e.concat(t)}))}if(A.code===Pt.ArrowDown||A.code===Pt.ArrowUp||A.code===Pt.ArrowLeft||A.code===Pt.ArrowRight){r(new Nt({elementEvent:{type:Gt.Translate}}));const e=kt(A.code,B,c.units,t);i(e,!1),r(new Nt({elementEvent:void 0}))}A.code!==Pt.Delete&&A.code!==Pt.Backspace||"advanced"!==a||(r(new Nt({selectedElement:void 0})),i(new s(B.id),!1))}}),[i,r,I.layoutState.elements,a,c.activeModifierKeys,c.maxZoom,c.selectedElement,c.units,c.zoom]),U=PA((A=>{if(A.code===Pt.MetaLeft||A.code===Pt.ControlLeft||A.code===Pt.MetaRight||A.code===Pt.ControlRight){const t=c.activeModifierKeys,e=A.code;r(new Nt({activeModifierKeys:t.filter((A=>A!==e))}))}}),[r,c.activeModifierKeys]);return{guidelines:F,scale:f,zoomableElementRef:e,setElementEvent:H,handleZoom:u,handleKeyDown:S,handleKeyUp:U,handlePointerPressedBackground:y,handlePointerReleased:R,handlePointerMove:N,handleScroll:x,handleSequenceStart:Y}},Vt=(A,t)=>{const e=GA((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),n=vA([]),a=PA((()=>{const A=e.every((A=>n.current.includes(A))),t=n.current.length===e.length;return A&&t}),[]),i=PA((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const i=A.target;return!(Kt.indexOf(i.tagName)>=0)&&(n.current=[...new Set([...n.current,e])],a()&&t(),A.preventDefault())}),[a,e,t,A]),s=PA((A=>{const t=String(A.key).toLowerCase();return n.current=n.current.filter((A=>A!==t)),A.preventDefault()}),[e]);SA((()=>(window.addEventListener("keydown",i),window.addEventListener("keyup",s),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",s)})),[i,s])},Wt=A=>{const{x:t,y:e,cursorStyle:n,onPointerDown:a,handleClass:i,cornerRadius:s,color:o,strokeWidth:c}=A;return JA("circle",{className:i,cx:t,cy:e,r:s,fill:"#ffffff",style:{cursor:n},stroke:o,strokeWidth:c,onPointerDown:a})},Xt=A=>{const{x:t,y:e,width:n,height:a,cursorStyle:i,onPointerDown:s,edgeHandleRadius:o,color:c,strokeWidth:r}=A;return JA("rect",{x:t,y:e,width:n,height:a,rx:o,fill:"#ffffff",style:{cursor:i},stroke:c,strokeWidth:r,onPointerDown:s})},qt=A=>{const{color:t,elementHeight:e,elementWidth:n,onBeginResize:a,rotation:i,scaleFactor:s,disableX:o,disableY:c}=A,r=10*s,g=5*s,B=40*s,w=12*s,l=1.2*s,E=e-2*r,Q=PA(((A,t,e)=>{A.stopPropagation(),a(t,e)}),[a]),h=PA((A=>Q(A,W(L.West,360-i),L.West)),[Q,i]),C=PA((A=>Q(A,W(L.East,360-i),L.East)),[Q,i]),d=PA((A=>Q(A,W(L.North,360-i),L.North)),[Q,i]),D=PA((A=>Q(A,W(L.South,360-i),L.South)),[Q,i]),I=PA((A=>Q(A,L.Northwest,L.Northwest)),[Q]),u=PA((A=>Q(A,L.Northeast,L.Northeast)),[Q]),p=PA((A=>Q(A,L.Southwest,L.Southwest)),[Q]),m=PA((A=>Q(A,L.Northeast,L.Southeast)),[Q]),f=B<=E;return kA(OA,{children:[JA(Wt,{x:0,y:0,cursorStyle:"nw-resize",onPointerDown:I,handleClass:"cornerNorthWest",cornerRadius:r,color:t,strokeWidth:l}),f?JA(Wt,{x:n,y:0,cursorStyle:"ne-resize",onPointerDown:u,handleClass:"cornerNorthEast",cornerRadius:r,color:t,strokeWidth:l}):void 0,f?JA(Wt,{x:n,y:e,cursorStyle:"se-resize",onPointerDown:m,handleClass:"cornerSouthEast",cornerRadius:r,color:t,strokeWidth:l}):void 0,f?JA(Wt,{x:0,y:e,cursorStyle:"sw-resize",onPointerDown:p,handleClass:"cornerSouthWest",cornerRadius:r,color:t,strokeWidth:l}):void 0,f&&!o?JA(Xt,{x:-w/2,y:e/2-B/2,width:w,height:B,onPointerDown:h,edgeHandleRadius:g,cursorStyle:"w-resize",color:t,strokeWidth:l}):void 0,f&&!c?JA(Xt,{x:n/2-B/2,y:e-w/2,width:B,height:w,onPointerDown:D,edgeHandleRadius:g,cursorStyle:"s-resize",color:t,strokeWidth:l}):void 0,o?void 0:JA(Xt,{x:n-w/2,y:e/2-Math.min(B,.8*e)/2,width:w,height:Math.min(B,.8*e),onPointerDown:C,edgeHandleRadius:g,cursorStyle:"e-resize",color:t,strokeWidth:l}),f&&!c?JA(Xt,{x:n/2-B/2,y:-w/2,width:B,height:w,onPointerDown:d,edgeHandleRadius:g,cursorStyle:"n-resize",color:t,strokeWidth:l}):void 0]})},Zt=A=>{const{color:t,elementWidth:e,onBeginRotate:n,scaleFactor:a}=A,i=PA((A=>{A.stopPropagation(),n()}),[n]),s=10*a,o=1.2*a;return kA("g",{children:[JA("circle",{cx:e/2,cy:-2.5*s,r:1.3*s,fill:"rgba(0, 0, 0, 0.5)",opacity:.4,style:{cursor:"ew-resize"},onPointerDown:i}),JA("circle",{cx:e/2,cy:-2.5*s,r:s,fill:"#fff",style:{cursor:"ew-resize"},stroke:t,strokeWidth:o,onPointerDown:i}),kA("svg",{x:e/2-s,y:-2.5*s-s,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*s,viewBox:"0 0 24 24",width:2*s,fill:t,onPointerDown:i,children:[JA("path",{d:"M0 0h24v24H0z",fill:"none"}),JA("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z"})]})]})},$t=({color:A,height:t,highlighted:e,id:n,immutable:a,onBeginMove:i,onPointerEnter:s,onPointerLeave:o,onSelected:c,pressed:r,rotation:g,scaleFactor:B,selected:w,width:l,x:E,y:Q})=>{const h=1.2*B,C=PA((A=>{2===A.button&&(A.stopPropagation(),c(n,A)),0===A.button&&(A.stopPropagation(),!w&&c(n,A),i())}),[n,w,c,i]),d=PA((()=>{s(n)}),[n,s]),D=PA((()=>{o(n)}),[n,o]);return JA("g",{transform:`translate(${E}, ${Q}) rotate(${g} ${l/2} ${t/2})`,children:JA("rect",{className:"interactableInnerRect",width:l,height:t,stroke:w||e?A:"none",pointerEvents:a?"none":"visibleFill",fill:"none",strokeWidth:h,style:{cursor:a?void 0:w?r?"grabbing":"grab":"pointer"},onPointerDown:a?void 0:C,onPointerEnter:a?void 0:d,onPointerLeave:a?void 0:D})})},_t=({color:A,height:t,onBeginResize:e,onBeginRotate:n,rotation:a,scaleFactor:i,width:s,x:o,y:c,disableX:r,disableY:g})=>kA("g",{transform:`translate(${o}, ${c}) rotate(${a} ${s/2} ${t/2})`,children:[JA(Zt,{color:A,elementWidth:s,onBeginRotate:n,scaleFactor:i}),JA(qt,{color:A,elementHeight:t,elementWidth:s,rotation:a,scaleFactor:i,onBeginResize:e,disableX:r,disableY:g})]}),Ae=({primaryColor:A,containerHeight:t,containerWidth:e,customViewbox:n,editorRef:a,elementEvent:i,guidelines:s,layoutHeight:o,layoutWidth:c,targetedElements:r,scale:g,selectedElement:B,onElementEvent:w,onElementSelected:E,onSequenceStart:Q,onMouseMove:h})=>{const{state:C}=Ht(),{getLayoutById:d}=mt(),D=d(C.layoutId),[I,u]=RA(void 0),p=PA((A=>{u(A)}),[]),m=PA((A=>{I===A&&u(void 0)}),[I]),f=PA((()=>{Q(),w({type:Gt.Translate})}),[w]),M=PA(((A,t)=>{Q(),w({type:Gt.Resize,relativeAxis:A,screenAxis:t})}),[w]),F=PA((()=>{Q(),w({type:Gt.Rotate})}),[w]),Y=n||{x:0,y:0,width:c,height:o},y=g*(Math.sqrt(Y.width*Y.height)/1e3)*(100/Math.sqrt(t*e))*Math.sqrt((x=e/t,Math.exp(Math.abs(Math.log(x)))));var x;const N=D.layoutState.elements,H=N.find((A=>A.id===B));return kA("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",xmlSpace:"preserve",version:"1.1",style:{touchAction:"none",position:"absolute",maxWidth:"100%",maxHeight:"100%"},width:"auto",height:"auto",viewBox:`${Y.x} ${Y.y} ${Y.width} ${Y.height}`,overflow:"overlay",children:[JA("rect",{onMouseMove:h,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:a,width:c,height:o}),s.map((A=>A.svgNode)),N.map((t=>{const e=void 0!==B&&t.id===B,n=e&&void 0!==i,a=void 0!==I&&t.id===I;return JA($t,{color:A,id:t.id,selected:e,highlighted:a,pressed:n,x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation,immutable:t.immutable||r&&!r.includes(t.id),onSelected:E,onBeginMove:f,onPointerEnter:p,onPointerLeave:m,scaleFactor:y},t.id)})),H&&JA(_t,{color:A,x:H.x,y:H.y,disableX:H.type===l.Frame,disableY:H.type===l.Textbox||H.type===l.Frame,width:H.width,height:H.height,rotation:H.rotation,onBeginResize:M,onBeginRotate:F,scaleFactor:y})]})},te=A=>{const{color:t,editorRef:e,zoomableElementRef:n,interactionElementRef:a,guidelines:i,isMakingAdjustments:s,viewmask:o,visibleLayoutId:c,xTranslation:r,yTranslation:g,targetedElements:B,borderRadius:w,handleContextMenu:l,onMouseMove:E,handleKeyDown:Q,handleKeyUp:h,handlePointerMove:C,handlePointerPressedBackground:d,handlePointerReleased:D,handleScroll:I,onSequenceStart:u,setElementEvent:p,onElementSelected:m}=A,{getLayoutById:f}=mt(),M=f(c),F=M.layoutState,{state:Y}=Ht(),y=PA((A=>{if(o){const t={left:o.x,top:o.y,width:o.width,height:o.height,panelId:"",rotation:0};return Q(A,t)}return Q(A)}),[Q,o]),x=PA((A=>{if(o){const t={left:o.x,top:o.y,width:o.width,height:o.height,panelId:"",rotation:0};return C(A,t)}return C(A)}),[C,o]);return JA("div",{style:{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:"none"},onContextMenu:l,onKeyDown:y,onKeyUp:h,onPointerDown:d,onPointerMoveCapture:x,onPointerUp:D,onWheelCapture:I,ref:a,tabIndex:-1,children:kA("div",{ref:n,style:{height:"100%",transform:`scale(${Y.zoom}) translate(${r}px, ${g}px)`,display:"flex",justifyContent:"center",filter:"drop-shadow(rgba(0, 0, 0, 0.2) 0px 0px 6px)"},children:[A.children,M.getComponentWithProps({height:s?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",viewmask:o,width:s?"100%":"auto",borderRadius:w}),JA(Ae,{primaryColor:t,containerHeight:n.current?.offsetHeight||1024,containerWidth:n.current?.offsetWidth||1024,editorRef:e,elementEvent:Y.elementEvent,guidelines:i,layoutHeight:F.layout.height,layoutWidth:F.layout.width,onElementEvent:p,onSequenceStart:u,onElementSelected:m,scale:10/Y.zoom,selectedElement:Y.selectedElement,targetedElements:B,onMouseMove:E})]})})},ee=({color:A,borderRadius:t,guidelineColor:e,handleContextMenu:n,onMouseMove:a,onElementSelected:i})=>{const{commandDispatcher:s,getLayoutById:o}=mt(),{state:c,uiDispatcher:r}=Ht(),g=vA(null),B=vA(null),w=vA(null),{guidelines:E,handleKeyDown:Q,handleKeyUp:h,handlePointerMove:C,handlePointerPressedBackground:d,handlePointerReleased:D,handleScroll:I,handleSequenceStart:u,setElementEvent:p}=jt(g,B,w,void 0,"advanced",s,e),m=PA(((A,t)=>{const e=o(c.layoutId).layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===l.Textbox){const t=e.algorithm;(!t||t===v.Autosize)&&s(new P(A,v.Traditional),!0)}i&&i(A,t),r(new Nt({selectedElement:A}))}),[s,o,c.layoutId,r]);return JA(te,{color:A,editorRef:g,interactionElementRef:B,zoomableElementRef:w,guidelines:E,visibleLayoutId:c.layoutId,xTranslation:0,yTranslation:0,borderRadius:t,handleContextMenu:n,onMouseMove:a,handleKeyDown:Q,handleKeyUp:h,handlePointerMove:C,handlePointerPressedBackground:d,handlePointerReleased:D,handleScroll:I,onSequenceStart:u,setElementEvent:p,onElementSelected:m})},ne=FA`
2
2
  mutation CreateTransaction($integrationProductId: String!, $bulk: Boolean) {
3
3
  transactionCreate(integrationProductId: $integrationProductId, bulk: $bulk) {
4
4
  id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "0.10.103",
3
+ "version": "0.10.104",
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",