@spiffcommerce/core 0.10.182 → 0.10.183

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +1 -1
  2. package/package.json +2 -2
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("buffer"),a=require("axios"),s=require("https"),r=require("file-type"),o=require("util"),c=require("css"),g=require("canvas"),l=require("exif"),B=require("canvg"),w=require("swagger-client"),d=require("@apollo/client"),h=require("@apollo/client/link/context"),E=require("@apollo/client/link/error"),C=require("cross-fetch"),Q=require("react"),u=require("lodash.isequal"),I=require("lodash.debounce"),D=require("qrcode"),m=require("svg-path-bbox");function p(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 y(A){return A&&A.__esModule?A.default:A}function M(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}p(module.exports,"SpiffCommerceClient",(()=>ns)),p(module.exports,"CommandContext",(()=>It)),p(module.exports,"spiffCoreConfiguration",(()=>Te)),p(module.exports,"PromiseQueue",(()=>Ei)),p(module.exports,"QueueablePromise",(()=>hi)),p(module.exports,"MockWorkflowManager",(()=>os)),p(module.exports,"InformationMessageType",(()=>ca)),p(module.exports,"StepHandle",(()=>da)),p(module.exports,"TextStepHandle",(()=>ya)),p(module.exports,"FrameStepHandle",(()=>Bs)),p(module.exports,"BulkStepHandle",(()=>Qa)),p(module.exports,"ShapeStepHandle",(()=>fa)),p(module.exports,"IllustrationStepHandle",(()=>ua)),p(module.exports,"MaterialStepHandle",(()=>Ia)),p(module.exports,"ModelStepHandle",(()=>Da)),p(module.exports,"PictureStepHandle",(()=>ma)),p(module.exports,"QuestionStepHandle",(()=>pa)),p(module.exports,"OptionNotFoundError",(()=>ve)),p(module.exports,"LayoutNotFoundError",(()=>Se)),p(module.exports,"AssetNotFoundError",(()=>Ne)),p(module.exports,"ResourceNotFoundError",(()=>Pe)),p(module.exports,"MisconfigurationError",(()=>Re)),p(module.exports,"ParseError",(()=>be)),p(module.exports,"UnhandledBehaviorError",(()=>Ue)),p(module.exports,"assetService",(()=>tn)),p(module.exports,"designService",(()=>Ra)),p(module.exports,"createDesign",(()=>Sa)),p(module.exports,"optionService",(()=>nn)),p(module.exports,"server",(()=>Ze)),p(module.exports,"persistenceService",(()=>ze)),p(module.exports,"graphQlManager",(()=>qe)),p(module.exports,"toast",(()=>bi)),p(module.exports,"FrameService",(()=>Ii)),p(module.exports,"frameStepService",(()=>Fi)),p(module.exports,"modelStepService",(()=>Si)),p(module.exports,"materialStepService",(()=>vi)),p(module.exports,"shapeStepService",(()=>Hi)),p(module.exports,"questionStepService",(()=>Ri)),p(module.exports,"digitalContentStepService",(()=>Mi)),p(module.exports,"moduleStepService",(()=>Ni)),p(module.exports,"pictureStepService",(()=>Pi)),p(module.exports,"textStepService",(()=>Oi)),p(module.exports,"illustrationStepService",(()=>Yi)),p(module.exports,"ProductCameraRig",(()=>Cn)),p(module.exports,"FrameStep",(()=>gs)),p(module.exports,"AssetType",(()=>T)),p(module.exports,"BringForwardCommand",(()=>qt)),p(module.exports,"BringToFrontCommand",(()=>Wt)),p(module.exports,"BringToBackCommand",(()=>Zt)),p(module.exports,"CanvasCommand",(()=>Yt)),p(module.exports,"CreateElementCommand",(()=>bt)),p(module.exports,"CreateLayoutCommand",(()=>Ht)),p(module.exports,"DeleteElementCommand",(()=>Gt)),p(module.exports,"FontAlignmentCommand",(()=>Lt)),p(module.exports,"FontColorCommand",(()=>Jt)),p(module.exports,"FontSizeCommand",(()=>Ot)),p(module.exports,"FontSourceCommand",(()=>zt)),p(module.exports,"GroupCommand",(()=>Rt)),p(module.exports,"LayoutElementFactory",(()=>Me)),p(module.exports,"LayoutElementType",(()=>P)),p(module.exports,"MoveCommand",(()=>St)),p(module.exports,"ResizeCommand",(()=>Pt)),p(module.exports,"RotateCommand",(()=>Nt)),p(module.exports,"SendBackwardsCommand",(()=>$t)),p(module.exports,"StepAspectType",(()=>W)),p(module.exports,"StepType",(()=>V)),p(module.exports,"TextChangeCommand",(()=>Kt)),p(module.exports,"UnitOfMeasurement",(()=>k)),p(module.exports,"dataUrlFromExternalUrl",(()=>UA)),p(module.exports,"findElement",(()=>yt)),p(module.exports,"frameDataCache",(()=>oe)),p(module.exports,"generate",(()=>Y)),p(module.exports,"getAxisAlignedBoundingBox",(()=>_)),p(module.exports,"generateSVGWithUnknownColors",(()=>Qt)),p(module.exports,"getAttributesFromArrayBuffer",(()=>ae)),p(module.exports,"rehydrateSerializedLayout",(()=>Ft)),p(module.exports,"getFrameData",(()=>Be)),p(module.exports,"getSvgString",(()=>mt)),p(module.exports,"loadFontFromDataUrl",(()=>KA)),p(module.exports,"loadFontFromExternalUrl",(()=>TA)),p(module.exports,"determineCorrectFontSizeAndLines",(()=>ue)),p(module.exports,"patternImageDataCache",(()=>re)),p(module.exports,"generateCommands",(()=>Va)),p(module.exports,"registerJSDOM",(()=>fA)),p(module.exports,"minZoom",(()=>Kn)),p(module.exports,"AdvancedEditor",(()=>$n)),p(module.exports,"TransformWrapper",(()=>ws)),p(module.exports,"EditorCore",(()=>qn)),p(module.exports,"useLayouts",(()=>rn)),p(module.exports,"useEditorState",(()=>En)),p(module.exports,"useEditorInteraction",(()=>Xn)),p(module.exports,"useShortcutCombination",(()=>Wn)),p(module.exports,"commandReducer",(()=>Bn)),p(module.exports,"getDefaultState",(()=>ln)),p(module.exports,"CommandContextContext",(()=>an)),p(module.exports,"AdvancedEditorStateProvider",(()=>dn)),p(module.exports,"AdvancedEditorContext",(()=>wn)),p(module.exports,"UICommand",(()=>hn)),p(module.exports,"EditorSubMenu",(()=>cn)),p(module.exports,"ElementEventType",(()=>Dn)),p(module.exports,"KeyEvent",(()=>pn)),p(module.exports,"gatherVaryingStepAspects",(()=>ri));var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==f?f:{},F={};M(F,"CanvasCommand",(()=>Yt)),M(F,"UpdateWorkflowStateCommand",(()=>vt)),M(F,"MoveCommand",(()=>St)),M(F,"RotateCommand",(()=>Nt)),M(F,"ResizeCommand",(()=>Pt)),M(F,"GroupCommand",(()=>Rt)),M(F,"CreateLayoutCommand",(()=>Ht)),M(F,"ClearLayoutCommand",(()=>Ut)),M(F,"CreateElementCommand",(()=>bt)),M(F,"DeleteElementCommand",(()=>Gt)),M(F,"CloneElementCommand",(()=>kt)),M(F,"FontColorCommand",(()=>Jt)),M(F,"FontSizeCommand",(()=>Ot)),M(F,"FontAlgorithmCommand",(()=>jt)),M(F,"FontSourceCommand",(()=>zt)),M(F,"FontAlignmentCommand",(()=>Lt)),M(F,"UpdateFramePattern",(()=>Tt)),M(F,"TextChangeCommand",(()=>Kt)),M(F,"IllustrationColorCommand",(()=>Vt)),M(F,"IllustrationCacheCommand",(()=>Xt)),M(F,"BringToFrontCommand",(()=>Wt)),M(F,"BringToBackCommand",(()=>Zt)),M(F,"BringForwardCommand",(()=>qt)),M(F,"SendBackwardsCommand",(()=>$t)),M(F,"LayerCommand",(()=>_t)),M({},"generate",(()=>Y));const Y=()=>{const A=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()};var v={};M(v,"ElementNotFoundError",(()=>ft)),M(v,"findElement",(()=>yt)),M(v,"findLayoutForElement",(()=>Mt)),M(v,"updatedLayoutForElement",(()=>xt)),M(v,"rehydrateSerializedLayout",(()=>Ft));var S={};M(S,"CommandContext",(()=>It)),M(S,"elementFactory",(()=>Dt)),M(S,"getSvgString",(()=>mt)),M(S,"sortElementsByLayersWithIndex",(()=>pt)),M({},"SVGLayout",(()=>q));var N={};let P;var R;let H;var U;let b;var G;let k;var J;let O;var j;let z;var L;let T;var K;let V;var X;let W;var Z;M(N,"LayoutElementType",(()=>P)),M(N,"LayoutRenderingPurpose",(()=>H)),M(N,"TextAlgorithm",(()=>b)),M(N,"UnitOfMeasurement",(()=>k)),M(N,"ScaleAxis",(()=>O)),M(N,"MaterialEffectMode",(()=>z)),M(N,"AssetType",(()=>T)),M(N,"StepType",(()=>V)),M(N,"StepAspectType",(()=>W)),(R=P||(P={})).Frame="frame",R.Image="image",R.Illustration="illustration",R.Textbox="textbox",(U=H||(H={}))[U.ThreeD=0]="ThreeD",U[U.FreeDesign=1]="FreeDesign",U[U.Print=2]="Print",(G=b||(b={})).Autosize="Autosize",G.Traditional="Traditional",(J=k||(k={})).Pixel="px",J.Millimeter="mm",J.Centimeter="cm",(j=O||(O={}))[j.North=0]="North",j[j.Northeast=1]="Northeast",j[j.East=2]="East",j[j.Southeast=3]="Southeast",j[j.South=4]="South",j[j.Southwest=5]="Southwest",j[j.West=6]="West",j[j.Northwest=7]="Northwest",(L=z||(z={})).None="None",L.RemoveWhenSelected="RemoveWhenSelected",L.ApplyWhenSelected="ApplyWhenSelected",(K=T||(T={})).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",(X=V||(V={})).Bulk="Bulk",X.DigitalContent="DigitalContent",X.Finish="Finish",X.Frame="Frame",X.Illustration="Illustration",X.Introduction="Introduction",X.Material="Material",X.Model="Model",X.Module="Module",X.Picture="Picture",X.Photo="Photo",X.ProductOverlay="ProductOverlay",X.Question="Question",X.Shape="Shape",X.SilentIllustration="SilentIllustration",X.Text="Text",(Z=W||(W={})).Color="Color",Z.Colors="Colors",Z.Selection="Selection",Z.Selections="Selections",Z.Text="Text",Z.Upload="Upload";const q=({backgroundColor:A,outlineColor:e,borderRadius:n,configuration:i,elements:a,height:s,maxHeight:r,maxWidth:o,outlineArea:c,position:g,preserveAspectRatio:l,viewBox:B,width:w})=>{const d=n||0,h=2*(c?.scale||1),E=B||{x:0,y:0,width:w,height:s},C=`${E.x} ${E.y} ${E.width} ${E.height}`,Q=Y(),u=i.purpose===H.FreeDesign&&(0,t.jsx)("defs",{children:(0,t.jsx)("clipPath",{id:"viewboxClip",children:(0,t.jsx)("rect",{width:E.width,height:E.height,rx:d})})}),I=i.colorProfiles?.map(((A,e)=>(0,t.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},e))),D=pt(a.map((A=>({...A,_renderingConfiguration:i,mask:c?`url(#viewmask-${Q})`:void 0}))));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:l,width:w,height:s,style:{gridColumn:1,gridRow:1,maxWidth:o,maxHeight:r,position:g},viewBox:C,children:[I,u,!!A&&(0,t.jsx)("rect",{id:"layout-background",width:E.width,height:E.height,fill:A,rx:d}),(0,t.jsx)("g",{id:"element-group",clipPath:i.purpose===H.FreeDesign?"url(#viewboxClip)":void 0,children:D.map((A=>Dt(A))).filter((A=>!!A))}),c&&(0,t.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:h/2,strokeDasharray:`${2*h} ${h}`}),c&&(0,t.jsxs)("mask",{id:`viewmask-${Q}`,children:[(0,t.jsx)("rect",{x:E.x,y:E.y,width:E.width,height:E.height,fill:"black"}),(0,t.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};M({},"Image",(()=>EA));var $={};M($,"getAxisAlignedBoundingBox",(()=>_)),M($,"degreesToRadians",(()=>tA)),M($,"findAngle",(()=>AA)),M($,"radiansToDegrees",(()=>eA)),M($,"isCloseToValue",(()=>nA)),M($,"getTrueCoordinates",(()=>iA)),M($,"getPointOfRotation",(()=>aA)),M($,"getNWPoint",(()=>sA)),M($,"getNEPoint",(()=>rA)),M($,"getSWPoint",(()=>oA)),M($,"getSEPoint",(()=>cA)),M($,"turnRightClockwise",(()=>gA)),M($,"currentDirection",(()=>lA)),M($,"getElementVertices",(()=>BA)),M($,"rotateAroundPoint",(()=>wA)),M($,"mmPerPixel",(()=>dA)),M($,"cmPerPixel",(()=>hA));const _=(A,t,e,n,i)=>{const a=tA(i),s=e/2,r=n/2,o=A+s,c=t+r,g=Math.sin(a),l=Math.cos(a),B=-r,w=s*l-B*g,d=s*l-r*g,h=s*g+B*l,E=s*g+r*l,C=Math.max(Math.abs(w),Math.abs(d)),Q=Math.max(Math.abs(h),Math.abs(E));return{minX:o-C,maxX:o+C,minY:c-Q,maxY:c+Q}},AA=(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)},tA=A=>A*(Math.PI/180),eA=A=>A*(180/Math.PI),nA=(A,t,e)=>Math.abs(A-t)<e,iA=(A,t,e)=>{const n=Math.sin(tA(e)),i=Math.cos(tA(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}},aA=(A,t)=>({x:(A.x+t.x)/2,y:(A.y+t.y)/2}),sA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+t?.y*n}),rA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+t?.y*n}),oA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+(t?.y+t?.height)*n}),cA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+(t?.y+t?.height)*n}),gA=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}},lA=(A,t)=>t>45&&t<=135?gA(A):t>135&&t<=225?gA(gA(A)):t>225&&t<=315?gA(gA(gA(A))):A,BA=(A,t={x:0,y:0},e={x:1,y:1})=>{const n=tA(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},r={x:t.x+A.x*e.x,y:t.y+(A.height+A.y)*e.y},o={x:(r.x+s.x)/2,y:r.y-A.height*e.y/2};return{a:wA(i,o,n),b:wA(a,o,n),c:wA(s,o,n),d:wA(r,o,n),center:o}},wA=(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}},dA=.352778,hA=.035277,EA=A=>{const e=A.rotation||0,n=tA(e),i=Math.cos(n),a=-Math.sin(n);return(0,t.jsx)("g",{mask:A.stepName||A.productOverlay?void 0:A.mask,children:(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})})})};M({},"Frame",(()=>CA));const CA=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,r=A.rotation||0,o=tA(r),c=Math.cos(o),g=-Math.sin(o);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("defs",{children:(s=>{const r=A.pattern?.x||0,o=A.pattern?.y||0,c=A.pattern?A.pattern.width*A.pattern.scaleX+Math.abs(r):256,g=A.pattern?A.pattern.height*A.pattern.scaleY+Math.abs(o):256,l=A.pattern?A.pattern.width*A.pattern.scaleX:256,B=A.pattern?A.pattern.height*A.pattern.scaleY:256;return(0,t.jsxs)("g",{mask:A.stepName?void 0:A.mask,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:r,y:o,width:l,height:B,xlinkHref:A.disablePlaceholder?"":A.pattern?A.pattern.src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsSAAALEgHS3X78AAAZL0lEQVR4nO2diVIbSRZFq/GCsZBZjRea6fn/r+oZGrMYBBhkLGwzE1cmTSqVWXuqVFXnRHREG6OlpX43X771j5O/7/+XAEAvWeFrB+gvCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAECPQQAAGuLnz5+Nf/QIAEADyPhHl+fJ5/PTRj/+53z5AItFxn9y+in5Nvn2+3Xf7r5r5FvAAwBYID7jH4/Hyfcf3xv5GhAAgAXhM/5nK8+SD+8/Ji+ev2jka0AAABZAmvGvrr5q7CsgBgAQGZ/x68R/t/e+UeNPEACAuPiM/9Xqq+T9u4/Js2fPGv/0uQIARGLZjT/BAwCIw2TyLTk9O5mJ7i+b8ScIAED9yPiPTz4lPx+eKv2W0fgTrgAA9VKn8esKcXx8NH3OWCAAADUhd981frG9tVPK+BU/+Prt6/Q5Y4kAAgBQE0rtDQaDuSdTLKCIAbvBQwnKaHQR5WtCAABqRDX9b4ZvZp5QBpz3FA9lDvb23kf5mhAAgJpJE4G0mv8m0oYIAEAEQiJwdnbinQPQVM0AAgAQ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gH71NfMfwCon0rdgEYE3NNaIlBlZJeM3xaA1dXV2v/DAaCGdmCJwLtAKW/ZQR1XV6OZPw+c9CMA1EMt8wDSBnWcnh0Xug64S0Xk/jP9FyAOtQ0ECYnA7fj291afLNRfcOq0Am9v72Q+DgDKUftmINM+bDoIbVTmqxy/rg0ucvsvLi9mfqoGnzoWfgKAnyirwdJEIHl069fW1qb/Ls/g7u5uzkOgqw8gPtF2A+bd7+ejSAcgAJQnmgAYfK59iOma7923yfpgyFcKsACiC0Dy6OZLCMbjsfdaIMPf3NgMxgcAIA4LEQAbpfkkCA8/fyYrjzX/9PEDNMPzRb+qjH2NLxtgKVj4YhAAWB4QAIAegwAA9BgEAKDHIAAAPQYBAOgxCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAEBfSZLk/xjo1hVZWiK0AAAAAElFTkSuQmCC"})}),s?(0,t.jsx)(QA,{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.jsx)("g",{mask:A.stepName?void 0:A.mask,children:(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]})})]})},QA=A=>{const{path:e,width:n,height:i,focalBlurStrength:a,focalBlurRadius:s,blurFilterId:r,focalMaskId:o,blurEdgeClipId:c}=A;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("filter",{id:r,children:(0,t.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,t.jsx)("mask",{id:o,children:(0,t.jsx)("circle",{cx:n/2,cy:i/2,r:s||0,fill:"white",filter:`url(#${r})`})}),(0,t.jsx)("mask",{id:c,children:(0,t.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};M({},"Textbox",(()=>gt));var uA={};M(uA,"fontSizeStep",(()=>qA)),M(uA,"textWidth",(()=>$A)),M(uA,"applyTextTransformations",(()=>At)),M(uA,"zip",(()=>tt)),M(uA,"getTextAlignment",(()=>et)),M(uA,"getAnchor",(()=>nt)),M(uA,"recomputeTextOnElement",(()=>it)),M(uA,"defaultLineHeightFactor",(()=>at)),M({},"calculateTextboxLines",(()=>ZA));var IA={};M(IA,"FontMetrics",(()=>zA)),M(IA,"loadFontFromExternalUrl",(()=>TA)),M(IA,"loadFontFromDataUrl",(()=>KA)),M(IA,"getFontMetrics",(()=>VA));var DA={};M(DA,"registerJSDOM",(()=>fA)),M(DA,"createElement",(()=>FA)),M(DA,"createElementNS",(()=>YA)),M(DA,"domParser",(()=>vA)),M(DA,"fetchAsArrayBuffer",(()=>SA)),M(DA,"fetchAsString",(()=>NA)),M(DA,"loadFontFaceSet",(()=>PA)),M(DA,"xmlSerializer",(()=>RA)),M(DA,"toBase64",(()=>HA)),M(DA,"dataUrlFromExternalUrl",(()=>UA)),M(DA,"arrayBufferToDataUrl",(()=>bA)),M(DA,"arrayBufferToBuffer",(()=>kA)),M(DA,"dataUrlToArrayBuffer",(()=>GA));var mA=i.Buffer;let pA;function fA(A){pA=A}function yA(){if(!pA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new pA}if(void 0===x.TextEncoder){const{TextEncoder:A}=o;x.TextEncoder=A}if(void 0===x.TextDecoder){const{TextDecoder:A}=o;x.TextDecoder=A}const MA=new(y(s).Agent)({rejectUnauthorized:!0}),xA=A=>A.every((A=>"undefined"!==A)),FA=A=>xA([typeof document])?document.createElement(A):yA().window.document.createElement(A),YA=(A,t)=>{if(xA([typeof document]))return document.createElementNS(A,t);const e=yA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},vA=()=>xA([typeof DOMParser])?new DOMParser:new(yA().window.DOMParser),SA=A=>{if(xA([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)=>{y(a).get(t,{responseType:"arraybuffer",httpsAgent:MA}).then((t=>{A(t.data)})).catch((A=>{e(A)}))}))}},NA=A=>{if(xA([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)=>{y(a).get(t,{responseType:"text",httpsAgent:MA}).then((t=>{A(t.data)})).catch(e)}))}},PA=async(A,t)=>{if(xA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},RA=()=>xA([typeof XMLSerializer])?new XMLSerializer:new(yA().window.XMLSerializer),HA=A=>xA([typeof btoa])?btoa(A):mA.from(A).toString("base64"),UA=async A=>{if(xA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await OA(e)}const t=(await y(a).get(A,{responseType:"arraybuffer"})).data;return bA(t)},bA=async A=>{const t=await(async A=>{const t=await(0,r.fromBuffer)(A);return t?t.mime:"image/svg+xml"})(A);return`data:${t};base64,${kA(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)),r=mA.from(s,a);return JA(r)},kA=A=>mA.from(A),JA=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},OA=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)})),jA=new Map;class zA{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 LA=A=>"data:"===A.substring(0,5).toLowerCase().trim(),TA=async A=>{const t=LA(A)?KA(A):KA(await UA(A));return XA(t,{assetUrl:LA(A)?A:await UA(A),name:t.names.fullName.en}),await PA(t,A),t},KA=A=>{const t=GA(A),e=y(n).parse(t);return XA(e,{assetUrl:A,name:e.names.fullName.en}),e},VA=A=>{const t=jA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},XA=(A,t)=>{const e=new zA(A);return jA.set(t.name,e),e},WA=(A,t,e,n)=>{const i=$A(A,e,n);if(i<=t)return{lines:[A],width:i};if(!(A.indexOf(" ")>-1)){if(A.length<=1)throw new Error(`Character ${A} is wider than region`);const i=Math.floor(A.length/2),a=WA(A.slice(0,i),t,e,n),s=WA(A.slice(i),t,e,n);return{lines:[...a.lines,...s.lines],width:Math.max(a.width,s.width)}}const a=A.split(" "),s=[];let r=-1/0,o=0;for(;o<a.length;){const A=a[o];if($A(A,e,n)>t){const i=WA(A,t,e,n);s.push(...i.lines),r=Math.max(r,i.width),o++}else{const i=[A];r=Math.max(r,$A(A,e,n));let c=o+1,g=!0;for(;c<a.length&&g;){const A=a[c],s=$A(`${i.join(" ")} ${A}`,e,n);s<=t?(i.push(A),r=Math.max(r,s),c++):g=!1}s.push(i.join(" ")),o=c}}if(r<0)throw new Error(`No max width calculated for text: ${s}.`);return{lines:s,width:r}},ZA=(A,t,e,n,i)=>{const a=VA(t),s=a.getFont();return((A,t,e,n,i,a)=>{const s=a||at,r=t.split("\n");try{const t=r.flatMap((t=>WA(t,A.width,n,i)));return{lines:t.flatMap((A=>A.lines)),requiredHeight:t.flatMap((A=>A.lines)).length*(e*s),requiredWidth:Math.max(...t.map((A=>A.width)))}}catch(A){return{lines:[],requiredHeight:NaN,requiredWidth:NaN}}})(e,At(n),A,A/s.unitsPerEm,a,i)},qA=1,$A=(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},_A={stripControlCharacters:!0,vertical:!1,uppercase:!1},At=(A,t=_A)=>{const e={..._A,...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},tt=(A,t)=>A.map(((A,e)=>[A,t[e]])),et=(A="center",t=!1)=>t?"center":A,nt=A=>"left"===A?"start":"right"===A?"end":"middle",it=(A,t)=>A.fontData?{...A,...(()=>{if(A.algorithm===b.Traditional){const e=ZA(A.fontSize,A.fontData,A,t,A.lineHeight);return{text:e.lines.join("\n"),height:e.requiredHeight,input:t}}return{text:t}})()}:A,at=1.1;var st={};M(st,"colorDefinitionPrintValue",(()=>rt)),M(st,"spotColorDefinitionString",(()=>ot)),M(st,"svgColorValueToDefinition",(()=>ct));const rt=A=>{const t=ot(A.spotColor);return t?`${A.browserValue} ${t}`:A.browserValue},ot=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})`},ct=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]}}},gt=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),r=A.y+(A.curved?0:A.height/2),o=(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",{mask:A.stepName?void 0:A.mask,children:(0,t.jsx)("g",{transform:`matrix(${n}, ${-i}, ${i}, ${n}, ${s}, ${r})`,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} ${ot(A.fillSpotColorDefinition)}`:A.fill,style:{whiteSpace:"pre",userSelect:"none"},children:A.curved?(0,t.jsx)(Bt,{text:A.text||"",curvedPathId:a,align:A.align}):o.map(((e,n)=>(0,t.jsx)(lt,{align:A.vertical?"center":A.align,fontSize:A.fontSize,thisLineIdx:n,amountLines:o.length,text:e,textboxHeight:A.height,textboxWidth:A.width,lineHeight:A.lineHeight,vertical:A.vertical,verticalAlign:A.verticalAlign},n)))})})})]}):null},lt=A=>(0,t.jsx)("tspan",{textAnchor:nt(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:at),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}),Bt=A=>{const e=`#${A.curvedPathId}`;return(0,t.jsx)("textPath",{startOffset:"left"===A.align?"0%":"right"===A.align?"100%":"50%",textAnchor:nt(A.align),href:e,xlinkHref:e,children:A.text})};M({},"Illustration",(()=>ut));var wt={};M(wt,"traverse",(()=>ht)),M(wt,"sanitizeSvgTree",(()=>Et)),M(wt,"modifySVGWithElementProperties",(()=>Ct)),M(wt,"generateSVGWithUnknownColors",(()=>Qt));const dt=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],ht=(A,t)=>{t(A),A.children.length>0&&Array.from(A.children).forEach((A=>ht(A,t)))},Et=(A,t=!1)=>{!t&&A.setAttribute("preserveAspectRatio","none");const e=[];ht(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()})),ht(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)}))}))}))}))},Ct=(A,t,e,n,i)=>{const a=(A=>vA().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)=>{ht(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?rt(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?rt(i):i.browserValue)}}))}))})(a,n,i),(A=>RA().serializeToString(A))(a)},Qt=async A=>{const t=A.match(/<svg.*?<\/svg>/s)||[],e=t?.length>0?t[0]:"",n=vA().parseFromString(e,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");Et(n);const i={};ht(n,(A=>{dt.includes(A.tagName)&&!A.attributes.getNamedItem("fill")&&A.setAttribute("fill","black");const t=A.attributes.getNamedItem("fill");if(t&&"none"!==t.value){const e=ct(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=ct(e.value),n=`spiff-stroke-${t.browserValue.replace(/\W/g,"")}`;A.classList.add(n),A.setAttribute("stroke",t.browserValue),i[n]=t}}));const a=RA().serializeToString(n);return{colors:i,svg:a}},ut=A=>{if(A.cachedObjectURL&&!A._renderingConfiguration?.omitCachedFields)return(0,t.jsx)(EA,{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,mask:A.stepName?void 0:A.mask});const e=A.rotation||0,n=tA(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",{mask:A.stepName?void 0:A.mask,children:(0,t.jsx)("g",{transform:s,dangerouslySetInnerHTML:{__html:Ct(A.svg,A.width,A.height,A.colors,A._renderingConfiguration?.spotColors)}})})};class It{constructor(){this.id=Y(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(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){return{layoutState:{layout:A,elements:e},getComponentWithProps:n=>(0,t.jsx)(q,{backgroundColor:A.transparentBackground?void 0:"white",elements:e,width:A.width,height:A.height,viewBox:{x:0,y:0,width:A.width,height:A.height},...n})}}initialize(A,t){if(t)return void(this.state={transaction:t});let e={serializableWorkflow:{steps:[]},layouts:{}};A.forEach((A=>{e=new Ht(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 Dt=A=>"image"===A.type?(0,t.jsx)(EA,{...A},A.id):"frame"===A.type?(0,t.jsx)(CA,{...A},A.id):"illustration"===A.type?(0,t.jsx)(ut,{...A},A.id):"textbox"===A.type?(0,t.jsx)(gt,{...A},A.id):null,mt=(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}},r=i?.removeExcludedElements?n.filter((A=>!A.excludeFromExport)):n;try{return y(e).renderToStaticMarkup((0,t.jsx)(q,{preserveAspectRatio:"none",...a,...s,elements:r,configuration:i}))}catch(A){return console.error("Error rendering to static markup"),console.error(A),""}};function pt(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 ft extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,ft.prototype)}}const yt=(A,t)=>Mt(A,t).elements.find((t=>t.id===A)),Mt=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new ft;return e},xt=(A,t)=>{const e=pt([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:Y()}},Ft=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],r=(a||s).elements.filter((A=>"illustration"===A.type));for(let A=0;A<r.length;++A){const t=r[A];if(t.src&&!t.svg){const A=await NA(t.src),e=await Qt(A);t.svg=Ct(e.svg,t.width,t.height,t.colors)}}}};class Yt{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(A){this.oldState=A}}class vt extends Yt{constructor(A){super(),this.serializableWorkflow=A}apply(A){return this.oldState=A,{...A,serializableWorkflow:this.serializableWorkflow}}}class St extends Yt{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,x:this.x,y:this.y},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Nt extends Yt{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,rotation:this.angle},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Pt extends Yt{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=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;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=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Rt extends Yt{constructor(A){super(),this.commands=A}apply(A){return this.oldState=A,this.commands.reduce(((A,t)=>t.apply(A)),A)}}class Ht extends Yt{constructor(A){super(),this.layout=A}apply(A){return this.oldState=A,{...A,layouts:{...A.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Y()}}}}}class Ut extends Yt{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:Y()}})),e={};return t.forEach((A=>{e[A.layout.id]=A})),{...A,layouts:e}}}class bt extends Yt{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:Y()}}}}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:Y()}}}}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 Yt{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:Y()})));t||console.log(`Failed to delete element ${this.id}`);const n={};return e.forEach((A=>{n[A.layout.id]=A})),{...A,layouts:n}}}class kt extends Yt{constructor(t,e){super(),this.el=y(A)(t),this.layout=e,this.el.id=Y(),this.el.x+=5,this.el.y+=5}apply(A){return this.oldState=A,new bt(this.el,this.layout).apply(A)}}class Jt extends Yt{constructor(A,t,e){super(),this.id=A,this.color=t,this.textFillSpotColor=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ot extends Yt{constructor(A,t){super(),this.id=A,this.size=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,fontSize:this.size},n=Mt(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==b.Autosize?e.input||"":e.text||"",a=xt(it(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class jt extends Yt{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,algorithm:this.algorithm},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class zt extends Yt{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,fontData:this.fontData},n=Mt(t.id,Object.values(A.layouts)),i=xt(it(e,e.input||""),n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Lt extends Yt{constructor(A,t){super(),this.id=A,this.align=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,align:this.align},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Tt extends Yt{constructor(A,t,e){super(),this.id=A,this.imageData=t,this.offsets=e}apply(A){this.oldState=A;const t=Mt(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:Y()};return{...A,layouts:{...A.layouts,[t.layout.id]:a}}}}class Kt extends Yt{constructor(A,t){super(),this.id=A,this.text=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e=Mt(t.id,Object.values(A.layouts)),n=xt(it(t,this.text),e);return{...A,layouts:{...A.layouts,[e.layout.id]:n}}}}class Vt extends Yt{constructor(A,t,e){super(),this.id=A,this.className=t,this.fill=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e=t.colors||{},n=e[this.className];e[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...t,colors:e},a=Mt(t.id,Object.values(A.layouts)),s=xt(i,a);return{...A,layouts:{...A.layouts,[a.layout.id]:s}}}}class Xt extends Yt{constructor(A,t,e){super(),this.id=A,this.svgBody=t,this.objectURL=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Wt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!yt(this.id,Object.values(A.layouts)).id)throw new ft;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));t.elements.push(t.elements.splice(e,1)[0]);const n=[...t.elements];return n.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:n,modificationID:Y()}}}}}class Zt extends Yt{constructor(A){super(),this.id=A}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;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!");const n=e.elements.findIndex((A=>A.id===this.id));e.elements.splice(n,1),e.elements.unshift(t);const i=[...e.elements],a=i.splice(n,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[e.layout.id]:{...A.layouts[e.layout.id],elements:i,modificationID:Y()}}}}}class qt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!yt(this.id,Object.values(A.layouts)).id)throw new ft;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:Y()}}}}}class $t extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!yt(this.id,Object.values(A.layouts)).id)throw new ft;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:Y()}}}}}class _t extends Yt{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;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]:xt({...t,layer:this.value},e)}}}}var Ae={};M(Ae,"patternImageDataCache",(()=>re)),M(Ae,"frameDataCache",(()=>oe)),M(Ae,"generateFrameSVG",(()=>ce)),M(Ae,"generateDefaultRectangleFrameSvg",(()=>ge)),M(Ae,"getVariant",(()=>le)),M(Ae,"getFrameData",(()=>Be)),M(Ae,"calculateOffsets",(()=>we)),M(Ae,"getPatternImageData",(()=>de)),M(Ae,"GetSVGDimensions",(()=>he)),M(Ae,"svgStringDimensions",(()=>Ee));var te={};M(te,"getExifOrientation",(()=>ne)),M(te,"canvasDims",(()=>ie)),M(te,"getAttributesFromArrayBuffer",(()=>ae));let ee=null;const ne=A=>new Promise((t=>{const e=kA(A);(0,r.fromBuffer)(A).then((A=>{const n=A?.mime;if("image/jpeg"!==n)return t(1);(new(0,l.ExifImage)).loadImage(e,((A,e)=>t(A?1:e.image.Orientation||1)))}))})),ie=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]},ae=async A=>{const t=await(async A=>{const t=await bA(A),e=await(0,g.loadImage)(t),[n,i]=ie(e),a=await(async()=>{if(null!==ee)return!ee;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return ee=2===A.width&&3===A.height,!ee})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const s=await ne(A),[r,o]=s>4?[i,n]:[n,i],c=(0,g.createCanvas)(r,o),l=c.getContext("2d");switch(s){case 2:l.translate(r,0),l.scale(-1,1);break;case 3:l.translate(r,o),l.rotate(Math.PI);break;case 4:l.translate(0,o),l.scale(1,-1);break;case 5:l.rotate(-.5*Math.PI),l.scale(-1,1);break;case 6:l.rotate(-.5*Math.PI),l.translate(-r,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-r,o),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-o)}return l.drawImage(e,0,0,r,o),c})(A);return"image/jpeg"===(await(0,r.fromBuffer)(A))?.mime?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}};M({},"getDefaultVariant",(()=>se));const se=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},re=new Map,oe=new Map,ce=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return ge(A)}return NA(t)},ge=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 `},le=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||se(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},Be=async A=>{const t=vA().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,r=t.getElementById("target-path"),o=t.getElementsByClassName("st0").item(0);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 oe.set(A,t),t}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 oe.set(A,t),t}throw new Error("Malformed frame SVG")},we=(A,t,e)=>{const n=t.width>=t.height,i=A.width>=A.height,a=t.width/2,s=t.height/2,r=(n?t.height:t.width)/(i?A.height:A.width),o=e?.scale||r,c=a-A.width/2*o,g=e?.left||c,l=s-A.height/2*o;return{x:g,y:e?.top||l,zoom:o}},de=async A=>{if(re.has(A))return re.get(A);if(A.endsWith("svg")){const t=await he(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return re.set(A,i),i}{const t=await SA(A),e=await ae(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return re.set(A,n),n}},he=async A=>{const t=await fetch(A),e=await t.text();return Ee(e)},Ee=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 Ce={};M(Ce,"determineCorrectFontSizeAndLines",(()=>ue)),M(Ce,"determineCorrectTextboxRegion",(()=>Ie));const Qe=(A,t,e,n,i)=>{let a=t.map((A=>A.split("\n"))).flat(),s=a.length,r=a.map((A=>$A(A,n,i)));const o=i.getApproximateHeight()*n;let c=!0;for(;c;){if(o+(s-1)*e>A.height)return[null,null];const t=Math.max(...r);if(t<=A.width)return[a,t];const g=r.reduce(((A,t,e,n)=>t>n[A]?e:A),0),l=a[g];let B=!1,w=l.length;for(;!B&&w>-1;){w=l.lastIndexOf(" ",w-1);const t=[l.slice(0,w),l.slice(w+1)],e=t.map((A=>$A(A,n,i)));e[0]<=A.width&&(a=[...a.slice(0,g),...t,...a.slice(g+1)],r=[...r.slice(0,g),...e,...r.slice(g+1)],s+=1,B=!0)}B||(c=!1)}return[null,null]},ue=(A,t,e,n,i)=>{let a,s;const r=VA(t),o=r.getFont();if(i.size){const t=A/o.unitsPerEm;return[a,s]=Qe(e,n,A,t,r),[i.size,a,s]}let c=6-qA;if(n.length>0){let A=n,t=0;for(;(!i.maxSize||c<=i.maxSize)&&A;)c+=qA,t=c/o.unitsPerEm,[A,s]=Qe(e,n,c,t,r)}c>6&&(c-=qA),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/o.unitsPerEm;return[a,s]=Qe(e,n,c,g,r),[c,a,s]},Ie=(A,t,e,n,i)=>{let a={...A},s={...A},[r,o,c]=ue(e,t,s,n,{size:0,minSize:e,maxSize:e});var g,l;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,[r,o]=ue(e,t,s,n,{size:e}),r===e&&o&&(g=n,l=o,g.map(((A,t)=>[A,l[t]]))).every((([A,t])=>A===t))&&(a=s)),a};var De={};M(De,"svgObjectURL",(()=>fe)),M(De,"LayoutElementFactory",(()=>Me));const me=(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},pe=async A=>new Promise((t=>{fetch(A).then((A=>{t(A.text())})).catch((A=>console.error(A)))})),fe=async A=>{const t=(new DOMParser).parseFromString(A,"image/svg+xml").firstElementChild;if(!t)throw new Error("Failed to read SVG");const e=(new XMLSerializer).serializeToString(t),n=document.createElement("canvas"),i=n.getContext("2d"),a=await B.Canvg.from(i,e,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),s=t.getAttribute("width"),r=t.getAttribute("height"),o=2048;if(r&&s){const A=parseFloat(r),t=parseFloat(s)/A;t>1?a.resize(o,o/t):a.resize(o*t,o)}else a.resize(o,o);return await a.render(),await(async A=>new Promise(((t,e)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");A.toBlob((e=>{if(!e){if(0===A.width||0===A.height)throw new Error(`Canvas dimensions are invalid (${A.width},${A.height})`);if(A.width*A.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${A.width},${A.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}t(URL.createObjectURL(e))}))}catch(A){e(A)}})))(n)},ye=async(A,t,e,n)=>{const i=A.layoutState.layout.useEditableArea&&A.layoutState.layout.editableArea||{width:A.layoutState.layout.width,height:A.layoutState.layout.height,x:0,y:0},a=i.width<i.height?i.width:i.height,s=A.layoutState.layout.useEditableArea?a/1.3:a/2,r={top:i.y+i.height/2-s/2,left:i.x+i.width/2-s/2,width:s,height:s,rotation:0,panelId:A.layoutState.layout.panelId};if(e&&t===P.Illustration){const A=await Qt(await pe(e)),t=(new DOMParser).parseFromString(A.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!t)throw new Error("SVG missing viewBox.");const n=r.height,i=t.split(" "),a=(parseFloat(i[2])||1)/(parseFloat(i[3])||1);r.height=r.width/a,r.top+=(n-r.height)/2}if(e&&t===P.Image){const A=r.height,t=await fetch(e),n=await t.arrayBuffer(),i=await ae(n),a=i.width/i.height;r.height=r.width/a,r.top+=(A-r.height)/2}if(e&&t===P.Textbox&&n?.text&&n?.fontScale){const A={assetUrl:e,name:(await TA(e)).names.fullName.en},t=VA(A),a=$A(n.text,n?.fontScale,t);r.width=Math.min(a,.85*i.width),r.left=i.x+i.width/2-r.width/2}return r};class Me{static async getFrame(A,t){const e=await ce(t.region,t.src),n=await Be(e),i=t.region||await ye(A,P.Frame);return{id:Y(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||me(A,i.layer||0),rotation:i.rotation,scaleX:i.width/n.width,scaleY:i.height/n.height,path:n.path,type:P.Frame,disablePlaceholder:t.configuration.disablePlaceholder,focalBlur:t.configuration.focalBlur,focalBlurStrength:t.configuration.focalBlurStrength,focalBlurRadius:t.configuration.focalBlurRadius,pattern:void 0,immutable:i.immutable}}static async getImage(A,t){const e=t.region||await ye(A,P.Image,t.src);return{id:Y(),src:t.src,type:P.Image,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||me(A,e.layer||0),immutable:e.immutable,preserveAspectRatio:"none"}}static async getTextbox(A,t){const{configuration:e,fontSrc:n,designInputStep:i}=t,a=await TA(n),s={assetUrl:n,name:a.names.fullName.en},r=i?.text||e.defaultText||"",o=e.replaceableText?e.replaceableText.replace("{{}}",r):r,c=At(o,{vertical:e.vertical,uppercase:e.uppercase}),g=t.region||await ye(A,P.Textbox,n,{text:c,fontScale:e.size?e.size/a.unitsPerEm:void 0}),l=it({id:Y(),type:P.Textbox,x:g.left,y:g.top,width:g.width,height:g.height,align:et(e.textAlign,e.vertical),curved:e.curved,fill:i?.color||e.colour||"#000000",fontData:s,layer:g.layer||0,layerIndex:g.layerIndex||me(A,g.layer||0),paths:e.paths,rotation:g.rotation,vertical:e.vertical,verticalAlign:e.verticalAlign||"middle",algorithm:b.Traditional,fontSize:e.size||Math.max(Math.round(.025*g.height),1),text:c,input:r},c),B=Ie({...g,height:l.height},s,l.fontSize,l?.text?.split("\n")||[],l.align);return{...l,x:B.left,y:B.top+(g.height-B.height)/2,width:B.width,height:B.height}}static async getShape(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=t.region||await ye(A,P.Illustration),a=Y();return{stepRegion:t.region,colors:n,id:a,svg:e,type:P.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||me(A,i.layer||0),immutable:i.immutable}}static async getIllustration(A,t){const e=t.region||await ye(A,P.Illustration,t.src),n=await Qt(await pe(t.src)),i=await fe(n.svg),a=Y();return{cachedObjectURL:i,stepRegion:t.region,colors:n.colors,id:a,svg:n.svg,type:P.Illustration,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||me(A,e.layer||0),immutable:e.immutable}}}function xe(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class Fe extends Error{constructor(A){super(A),this.name=this.constructor.name}}class Ye extends Fe{constructor(A){super(`ConfigurationError - ${A}`)}}class ve extends Ye{constructor(A){super(`Option not Configured: ${A.stepTitle}`),xe(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class Se extends Ye{constructor(A){super(`Panel not Found: ${A.panelId}`),xe(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class Ne extends Ye{constructor(A){super(`Asset not found for variant: ${A.name}`),xe(this,"variant",void 0),this.variant=A}}class Pe extends Ye{constructor(A){super(`Resource not found for asset: ${A.name}`),xe(this,"asset",void 0),this.asset=A}}class Re extends Ye{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),xe(this,"step",void 0),this.step=A}}class He extends Fe{constructor(A){super(`ImplementationError - ${A}`)}}class Ue extends He{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class be extends He{constructor(A){super(`Parsing Error: ${A}`)}}class Ge extends He{constructor(A){super(`Client Error: ${A}`)}}class ke extends He{constructor(A){super(`Resource Generation Failed: ${A}`)}}function Je(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class Oe{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 je{constructor(){Je(this,"storage",new Map)}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 ze=(()=>{try{return localStorage?new Oe:new je}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new je}})();function Le(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Te=new class{constructor(){Le(this,"defaultServerUrl","https://api.spiff.com.au"),Le(this,"defaultServicesApiUrl","https://services.spiff.com.au"),Le(this,"defaultHubUrl","https://hub.spiff.com.au"),Le(this,"serverUrl",void 0),Le(this,"servicesApiUrl",void 0),Le(this,"hubUrl",void 0),Le(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 Ke(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let Ve;const Xe=A=>{Ve=A},We=async()=>{const A={transactionOwnerId:Ve};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=Te.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 Ze=new class{constructor(){Ke(this,"client",void 0),Ke(this,"uncachedOperations",[]),Te.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 We();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 We(),t=Te.getServerUrl()+"/v2/api-docs";return await y(w)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const qe=new class{constructor(){Ke(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),Te.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,d.createHttpLink)({uri:`${Te.getServerUrl()}/graphql`,fetch:C.fetch}),t=(0,h.setContext)((async(A,{headers:t})=>{const e=t||{},n=await We();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,d.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,d.ApolloClient)({link:(0,d.from)([e,t,A]),cache:n,name:"Core"})}};function $e(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const _e="persistentAssets";class An{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=ze.getMap(_e);n&&n.forEach(((A,t)=>{e.set(t,A)})),ze.setMap(_e,e)}static remove(A){const t=ze.getMap(_e);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),ze.setMap(_e,t))}static list(){const A=ze.getMap(_e);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const tn=new class{constructor(){$e(this,"server",void 0),$e(this,"cache",new Map),$e(this,"materialCache",new Map),$e(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await ae(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)}})),$e(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await tn.getLocalOrFromServer(A.assetKey))),$e(this,"getMaterialFromVariant",(async A=>A.material?A.material:await tn.getMaterialLocalOrFromServer(A.materialId))),this.server=Ze}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new Ue("Failed to get asset from cache!");return t}const t=(async()=>(await Ze.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 Ze.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;An.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?T.Image:T.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 tn.uploadAssetWithProgress(e,n,t,!0)}}removePersistedAsset(A){An.remove(A)}getPersistedAssets(){return An.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 Ue("Unexpected mimetype: "+t)}}};function en(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const nn=new class{constructor(){en(this,"cache",new Map),en(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),en(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),en(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),en(this,"getOptionFromStep",(async(A,t)=>{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 nn.getOption(t,A.optionId)}))}async getOption(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(async()=>{const e=await A.execute("getOptionV2",{id:t});if(e.body.data)return e.body})();return this.cache.set(t,e),e}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await tn.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 tn.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}},an=(0,Q.createContext)(new It),sn=function(){const[A,t]=(0,Q.useState)([]);return{addEvent:(0,Q.useCallback)((A=>{t((t=>[...t,A]))}),[]),updateEvent:(0,Q.useCallback)((A=>{t((t=>{const e=t.findIndex((t=>t.pointerId===A.pointerId));if(-1===e)return t;const n=[...t];return n[e]=A,n}))}),[]),removeEvent:(0,Q.useCallback)((A=>{t((t=>t.filter((t=>t.pointerId!==A.pointerId))))}),[]),eventCache:A,curActiveEvents:A.length}},rn=()=>{const A=(0,Q.useContext)(an),[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)}}};function on(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let cn;var gn;(gn=cn||(cn={})).None="None",gn.FrameAdjustment="FrameAdjustment",gn.FinalizeDesign="FinalizeDesign",gn.SavedDesigns="SavedDesigns",gn.ThreeDPreview="ThreeDPreview",gn.Panels="Panels";const ln=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,xTranslation:0,yTranslation:0,maxZoom:5,units:k.Pixel,subMenu:cn.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Bn=(A,t)=>y(u)(A,t.apply(A))?A:t.apply(A),wn=(0,Q.createContext)({}),dn=A=>{const{getAllLayouts:e}=rn(),[n,i]=(0,Q.useReducer)(Bn,ln(e,A.defaultZoom||1)),a=(0,Q.useMemo)((()=>({state:n,uiDispatcher:i})),[n,i]);return(0,t.jsx)(wn.Provider,{value:a,children:A.children})};class hn{constructor(A){on(this,"changes",void 0),this.changes=A}apply(A){return{...A,...this.changes}}}const En=()=>(0,Q.useContext)(wn);let Cn;var Qn;(Qn=Cn||(Cn={}))[Qn.Orbit=0]="Orbit",Qn[Qn.Pan=1]="Pan";const un=3.75,In=(A,e,n,i)=>{const a=e.layout.useEditableArea&&e.layout.editableArea||{width:e.layout.width,height:e.layout.height,x:0,y:0},s=e.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),r=s.map((A=>_(A.x,A.y,A.width,A.height,A.rotation))),o=[],c=new Set;r.forEach((A=>c.add(A.minX))),r.forEach((A=>c.add(A.maxX))),[a.x,a.x+a.width/2,a.x+a.width].forEach((A=>c.add(A)));const g=new Set;r.forEach((A=>g.add(A.minY))),r.forEach((A=>g.add(A.maxY))),[a.y,a.y+a.height/2,a.y+a.height].forEach((A=>g.add(A)));const l=s.map((A=>A.y));for(let A=-315;A<=315;A+=45)l.push(A);const B=_(A.x,A.y,A.width,A.height,A.rotation),w=[{value:B.minX,anchor:-1},{value:B.minX+(B.maxX-B.minX)/2,anchor:0},{value:B.minX+(B.maxX-B.minX),anchor:1}],d=[{value:B.minY,anchor:-1},{value:B.minY+(B.maxY-B.minY)/2,anchor:0},{value:B.minY+(B.maxY-B.minY),anchor:1}],h=[{value:A.rotation,anchor:0}],E=(A,e,i,s)=>{const r=[];return e.forEach((e=>{const o=i.find((A=>nA(e,A.value,.3*n))),[c,g]=((A,t)=>[{x:"x"===A?t:a.x,y:"x"===A?a.y:t},{x:"x"===A?t:a.x+a.width,y:"x"===A?a.y+a.height:t}])(A,e),l="rotation"===A?null:(0,t.jsx)("line",{x1:c.x,y1:c.y,x2:g.x,y2:g.y,stroke:s||"#D61B5C",strokeWidth:1.2*n},`${A}-${e}-${c.x}-${c.y}-${g.x}-${g.y}`);void 0!==o&&r.push({type:A,value:e,anchorPoint:o.anchor,svgNode:l,guidelineCoordinates:[c,g]})})),r};return o.push(...E("x",Array.from(c),w,i),...E("y",Array.from(g),d,i),...E("rotation",l,h,i)),o};let Dn;var mn;let pn;var fn;(mn=Dn||(Dn={})).Translate="Translate",mn.Rotate="Rotate",mn.Resize="Resize",(fn=pn||(pn={})).ControlLeft="ControlLeft",fn.ControlRight="ControlRight",fn.Equal="Equal",fn.MetaLeft="MetaLeft",fn.MetaRight="MetaRight",fn.Minus="Minus",fn.ArrowLeft="ArrowLeft",fn.ArrowRight="ArrowRight",fn.ArrowUp="ArrowUp",fn.ArrowDown="ArrowDown",fn.AltLeft="AltLeft",fn.AltRight="AltRight",fn.Delete="Delete",fn.Backspace="Backspace";const yn=(A,t,e,n)=>{const i=()=>{switch(e){case k.Pixel:return 1;case k.Millimeter:return dA;case k.Centimeter:return hA;default:throw new Ue("Unknown unit of measurement")}};let a=t.x,s=t.y,r=t.x,o=t.y;switch(A){case pn.ArrowLeft:r=t.x-1/i();break;case pn.ArrowUp:o=t.y-1/i();break;case pn.ArrowRight:r=t.x+1/i();break;case pn.ArrowDown:o=t.y+1/i();break;default:throw new Ue("Unhandled element interaction!")}const c=_(r,o,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=r,s=o),new St(t.id,a,s)};let Mn=0,xn=0;var Fn=0;const Yn=(A,t,e,n,i,a)=>{const s=_(A,t,e,n,i),r=s.maxY-s.minY;return!a||s.maxY-.1*r>=a.top&&s.minY+.1*r<=a.top+a.height},vn=(A,t,e,n,i,a)=>{const s=_(A,t,e,n,i),r=s.maxX-s.minX;return!a||s.maxX-.1*r>=a.left&&s.minX+.1*r<=a.left+a.width},Sn=(A,t,e)=>({x:(A.x-t.x)*((e.maxX-e.minX)/t.width)+e.minX,y:(A.y-t.y)*((e.maxY-e.minY)/t.height)+e.minY}),Nn=A=>Math.abs(A)<.001?0:Math.abs(A-1)<.001?1:A;let Pn;var Rn;(Rn=Pn||(Pn={}))[Rn.Height=0]="Height",Rn[Rn.Width=1]="Width",Rn[Rn.Both=2]="Both";const Hn=(A,t,e)=>{const n=A.rotation*Math.PI/180,i=((A,t,e,n,i)=>{if(i<90){const a=i*Math.PI/180,s=Nn(Math.sin(a)),r=Nn(Math.cos(a));return{height:e*r+n*s,width:e*s+n*r,x:A-e*s,y:t}}if(i<180){const a=(i-90)*Math.PI/180,s=Nn(Math.sin(a)),r=Nn(Math.cos(a));return{width:e*r+n*s,height:e*s+n*r,x:A-(e*r+n*s),y:t-e*s}}if(i<270){const a=(i-180)*Math.PI/180,s=Nn(Math.sin(a)),r=Nn(Math.cos(a));return{height:e*r+n*s,width:e*s+n*r,x:A-n*r,y:t-(e*r+n*s)}}const a=(i-270)*Math.PI/180,s=Nn(Math.sin(a)),r=Nn(Math.cos(a));return{width:e*r+n*s,height:e*s+n*r,x:A,y:t-n*r}})(t.x,t.y,e===Pn.Both||e===Pn.Height?1:A.height,e===Pn.Both||e===Pn.Width?1:A.width,A.rotation),a=BA({x:i.x,y:i.y,width:i.width,height:i.height,rotation:A.rotation}).center;return wA(t,a,-n)},Un=(A,t,e,n,i,a,s)=>{const r=((A,t,e,n,i,a,s)=>{const r=n.width/t.width,o=n.height/t.height,c=A.deltaX/r,g=A.deltaY/o,l=e.rotation*Math.PI/180,B=Math.sin(l),w=Math.cos(l),d=e.type===P.Textbox?1:e.width/e.height;switch(i.type){case Dn.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},h=t;switch(i.screenAxis){case O.North:{const n=-c*B+g*w,i=e.y+n,a=Math.max(e.height-n,1),s=BA({...e}).center,r=BA({...e,y:i,height:a}).center,o=wA(r,s,l),d=o.x-e.width/2,E=o.y-a/2;h={...t,left:d,top:E,height:a};const C=180*l/Math.PI,Q=_(d,E,e.width,a,C),u=Sn({x:A.destX,y:A.destY},A.targetRect,Q),I=wA({x:u.x,y:u.y},s,-l);if(1===a||I.y>E+a){const A=Nn(Math.sin(l)),n=Nn(Math.cos(l)),i=BA({...e}).center,a=wA({x:e.x,y:e.y},i,l),s={x:a.x-(e.height-1)*A,y:a.y+(e.height-1)*n},r=Hn(e,s,Pn.Height);return{...t,height:1,top:r.y,left:r.x}}}break;case O.East:{const n=c*w+g*B,i=Math.max(e.width+n,1);let a=e.height;if(e.type===P.Textbox){const A=e,n=ZA(A.fontSize,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=n.requiredHeight,!a||!n.requiredWidth)return t}const s=BA({...e}).center,r=BA({...e,width:i,height:a}).center,o=wA(r,s,l),d=o.x-i/2,E=o.y-a/2;h={...t,left:d,top:E,width:i,height:a};const C=180*l/Math.PI,Q=_(d,E,e.width,a,C),u=Sn({x:A.destX,y:A.destY},A.targetRect,Q),I=wA({x:u.x,y:u.y},s,-l);if(1===i||I.x<d){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i=Hn(e,n,Pn.Width);return{...t,width:1,top:i.y,left:i.x}}}break;case O.West:{const n=c*w+g*B,i=e.x+n,a=Math.max(e.width-n,1);let s=e.height;if(e.type===P.Textbox){const A=e,n=ZA(A.fontSize,A.fontData,{...A,width:a},A.input||A.text||"",A.lineHeight);if(s=n.requiredHeight,!s||!n.requiredWidth)return t}const r=BA({...e}).center,o=BA({...e,width:a,height:s,x:i}).center,d=wA(o,r,l),E=d.x-a/2,C=d.y-s/2;h={...t,left:E,top:C,width:a,height:s};const Q=180*l/Math.PI,u=_(E,C,e.width,s,Q),I=Sn({x:A.destX,y:A.destY},A.targetRect,u),D=wA({x:I.x,y:I.y},r,-l);if(1===a||D.x>E+a){const A=Nn(Math.sin(l)),n=Nn(Math.cos(l)),i=BA({...e}).center,a=wA({x:e.x,y:e.y},i,l),s={x:a.x+(e.width-1)*n,y:a.y+(e.width-1)*A},r=Hn(e,s,Pn.Width);return{...t,width:1,top:r.y,left:r.x}}}break;case O.South:{const n=-c*B+g*w,i=Math.max(e.height+n,1),a=BA({...e}).center,s=BA({...e,height:i}).center,r=wA(s,a,l),o=r.x-e.width/2,d=r.y-i/2;h={...t,left:o,top:d,height:i};const E=180*l/Math.PI,C=_(o,d,e.width,i,E),Q=Sn({x:A.destX,y:A.destY},A.targetRect,C),u=wA({x:Q.x,y:Q.y},a,-l);if(1===i||u.y<d){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i=Hn(e,n,Pn.Height);return{...t,height:1,top:i.y,left:i.x}}}break;case O.Northeast:{const n=c*w+g*B,i=Math.max(e.width+n,1);let a=Math.max(e.height+n/d,1),s=e.y-n/d,r=e.fontSize;if(e.type===P.Textbox){const A=e;r=A.fontSize+n/8;const o=ZA(r,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);a=o.requiredHeight;const c=A.lineHeight||at;if(s=e.y-n*c/8,!a||!o.requiredWidth)return t}const o=BA({...e}).center,E=BA({...e,width:i,height:a,y:s}).center,C=wA(E,o,l),Q=C.x-i/2,u=C.y-a/2;h={...t,left:Q,top:u,width:i,height:a,fontSize:r};const I=180*l/Math.PI,D=_(Q,u,e.width,a,I),m=Sn({x:A.destX,y:A.destY},A.targetRect,D),p=wA({x:m.x,y:m.y},o,-l);if(1===i||1===a||p.x<Q||p.y>u+a){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i={x:n.x-(e.height-1)*B,y:n.y+(e.height-1)*w},a=Hn(e,i,Pn.Both);return{...t,height:1,width:1,top:a.y,left:a.x}}}break;case O.Northwest:{const n=-c*w+-g*B,i=e.x-n,a=Math.max(e.width+n,1);let s=e.y-n/d,r=Math.max(e.height+n/d,1),o=e.fontSize;if(e.type===P.Textbox){const A=e;o=A.fontSize+n/8;const i=ZA(o,A.fontData,{...A,width:a},A.input||A.text||"",A.lineHeight);r=i.requiredHeight;const c=A.lineHeight||at;if(s=e.y-n*c/8,!r||!i.requiredWidth)return t}const E=BA({...e}).center,C=BA({...e,x:i,y:s,width:a,height:r}).center,Q=wA(C,E,l),u=Q.x-a/2,I=Q.y-r/2;h={...t,left:u,top:I,width:a,height:r,fontSize:o};const D=180*l/Math.PI,m=_(u,I,e.width,r,D),p=Sn({x:A.destX,y:A.destY},A.targetRect,m),f=wA({x:p.x,y:p.y},E,-l);if(1===a||1===r||f.x>u+a||f.y>I+r){const A={x:e.x+e.width,y:e.y+e.height},n=wA(A,E,l),i={x:n.x-Math.SQRT2*Math.cos(l+Math.PI/4),y:n.y-Math.SQRT2*Math.sin(l+Math.PI/4)},a=Hn(e,i,Pn.Both);return{...t,height:1,width:1,top:a.y,left:a.x}}}break;case O.Southeast:{const n=c*w+g*B,i=Math.max(e.width+n,1);let a=Math.max(e.height+n/d,1),s=e.fontSize;if(e.type===P.Textbox){const A=e;s=A.fontSize+n/8;const r=ZA(s,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=r.requiredHeight,!a||!r.requiredWidth)return t}const r=BA({...e}).center,o=BA({...e,width:i,height:a}).center,E=wA(o,r,l),C=E.x-i/2,Q=E.y-a/2;h={...t,left:C,top:Q,width:i,height:a,fontSize:s};const u=180*l/Math.PI,I=_(C,Q,e.width,a,u),D=Sn({x:A.destX,y:A.destY},A.targetRect,I),m=wA({x:D.x,y:D.y},r,-l);if(1===i||1===a||m.x<C||m.y<Q){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i=Hn(e,n,Pn.Both);return{...t,height:1,width:1,top:i.y,left:i.x}}}break;case O.Southwest:{const n=-c*w+-g*B,i=Math.max(e.width+n,1);let a=e.x-n,s=Math.max(e.height+n/d,1),r=e.fontSize;if(e.type===P.Textbox){const A=e;r=A.fontSize+n/8;const a=ZA(r,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(s=a.requiredHeight,!s||!a.requiredWidth)return t}const o=BA({...e}).center,E=BA({...e,width:i,height:s,x:a}).center,C=wA(E,o,l),Q=C.x-i/2,u=C.y-s/2;h={...t,left:Q,top:u,width:i,height:s,fontSize:r};const I=180*l/Math.PI,D=_(Q,u,e.width,s,I),m=Sn({x:A.destX,y:A.destY},A.targetRect,D),p=wA({x:m.x,y:m.y},o,-l);if(1===i||1===s||p.x>Q+i||p.y<u){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i={x:n.x+(e.width-1)*w,y:n.y+(e.width-1)*B},a=Hn(e,i,Pn.Both);return{...t,height:1,width:1,top:a.y,left:a.x}}}}return Yn(h.left,h.top,h.width,h.height,h.rotation,s)&&vn(h.left,h.top,h.width,h.height,h.rotation,s)&&(t=h),t;case Dn.Rotate:const E={x:A.destX,y:A.destY};let C,Q=e.rotation;const u=BA(e,n,{x:r,y:o}),I=AA(E,u.c,u.d),D=AA(E,u.d,u.c);if(0===a.filter((A=>"rotation"===A.type)).length)Fn=0,C=(e.rotation+I-D)%360;else{Fn+=Math.sqrt(c**2+g**2);const A=Math.abs(Fn)>un*window.devicePixelRatio/r;C=A?(e.rotation+I-D)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Fn=0)}return Yn(e.x,e.y,e.width,e.height,C,s)&&vn(e.x,e.y,e.width,e.height,C,s)&&(Q=C),Q<0&&(Q+=360),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:Q};case Dn.Translate:let m,p,f=e.x,y=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)m=e.x+c,p=e.y+g;else{const A=a.find((A=>"x"===A.type)),t=a.find((A=>"y"===A.type)),n=A=>{switch(A){case-1:return 0;case 0:return e.height/2;case 1:return e.height;default:return 0}};Mn+=c,xn+=g;const i=A?(A=>{switch(A){case-1:return 0;case 0:return e.width/2;case 1:return e.width;default:return 0}})(A.anchorPoint):void 0,s=t?n(t.anchorPoint):void 0,r=void 0!==i&&Math.abs(Mn)<=un,o=void 0!==s&&Math.abs(xn)<=un;A&&r?m=e.x:(m=e.x+Mn,Mn=0),t&&o?p=e.y:(p=e.y+xn,xn=0)}return Yn(m,p,e.width,e.height,e.rotation,s)&&(y=p),vn(m,p,e.width,e.height,e.rotation,s)&&(f=m),{top:y,left:f,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,s),o=[];if(e.type===P.Textbox){const A=e;o.push(new Kt(A.id,A.input||A.text||""))}if(r.width>0&&r.height>0&&(o.push(new St(e.id,r.left,r.top),new Pt(e.id,r.width,r.height),new Nt(e.id,r.rotation)),e.type===P.Textbox)){const A=e;r.fontSize&&A.fontSize!==r.fontSize&&o.push(new Ot(A.id,r.fontSize))}return o},bn=A=>{const{onPointerDown:e,scaleFactor:n,elementWidth:i}=A,a=(0,Q.useCallback)((A=>{A.stopPropagation(),e&&e(A)}),[e]),s=13*n,r=30*n;return(0,t.jsxs)("g",{transform:`translate(${r})`,children:[(0,t.jsx)("circle",{cx:i/2,cy:-2.5*s,r:1.3*s,fill:"transparent",style:{cursor:"pointer"},onPointerDown:a}),(0,t.jsxs)("svg",{onPointerDown:a,x:i/2-s,y:-2.5*s-s,width:2*s,height:2*s,style:{cursor:"pointer"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("path",{d:"M10.3246 4.31731C10.751 2.5609 13.249 2.5609 13.6754 4.31731C13.9508 5.45193 15.2507 5.99038 16.2478 5.38285C17.7913 4.44239 19.5576 6.2087 18.6172 7.75218C18.0096 8.74925 18.5481 10.0492 19.6827 10.3246C21.4391 10.751 21.4391 13.249 19.6827 13.6754C18.5481 13.9508 18.0096 15.2507 18.6172 16.2478C19.5576 17.7913 17.7913 19.5576 16.2478 18.6172C15.2507 18.0096 13.9508 18.5481 13.6754 19.6827C13.249 21.4391 10.751 21.4391 10.3246 19.6827C10.0492 18.5481 8.74926 18.0096 7.75219 18.6172C6.2087 19.5576 4.44239 17.7913 5.38285 16.2478C5.99038 15.2507 5.45193 13.9508 4.31731 13.6754C2.5609 13.249 2.5609 10.751 4.31731 10.3246C5.45193 10.0492 5.99037 8.74926 5.38285 7.75218C4.44239 6.2087 6.2087 4.44239 7.75219 5.38285C8.74926 5.99037 10.0492 5.45193 10.3246 4.31731Z",stroke:"#111827",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z",stroke:"#111827",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})},Gn="#ffffff",kn=A=>{const{isMobile:e,outerRadius:n,x:i,y:a,cursorStyle:s,onPointerDown:r,handleClass:o,cornerRadius:c,color:g,strokeWidth:l}=A,[B,w]=(0,Q.useState)(!1);(0,Q.useEffect)((()=>{const A=()=>{w(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const d=(0,Q.useCallback)((A=>{w(!0),r(A)}),[r]);return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:i,cy:a,r:n,fill:B?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:s},onPointerDown:d}),(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Gn,style:{cursor:s,pointerEvents:"none"},stroke:g,strokeWidth:l})]}):(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Gn,style:{cursor:s},stroke:g,strokeWidth:l,onPointerDown:r})},Jn=A=>{const{isMobile:e,outerRadius:n,outerWidth:i,outerHeight:a,x:s,y:r,width:o,height:c,cursorStyle:g,onPointerDown:l,edgeHandleRadius:B,color:w,strokeWidth:d}=A,[h,E]=(0,Q.useState)(!1);(0,Q.useEffect)((()=>{const A=()=>{E(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const C=(0,Q.useCallback)((A=>{E(!0),l(A)}),[l]);return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:s-(i-o)/2,y:r-(a-c)/2,width:i,height:a,rx:n,fill:h?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:g},onPointerDown:C}),(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Gn,style:{cursor:g,pointerEvents:"none"},stroke:w,strokeWidth:d})]}):(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Gn,style:{cursor:g},stroke:w,strokeWidth:d,onPointerDown:l})},On=A=>{const{isMobile:e,color:n,elementHeight:i,elementWidth:a,onBeginResize:s,rotation:r,scaleFactor:o,disableX:c,disableY:g}=A,l=7.5*o,B=3*o,w=28*o,d=6*o,h=30*o,E=5*o,C=40*o,u=36*o,I=1.2*o,D=(0,Q.useCallback)(((A,t,e)=>{A.stopPropagation(),s(t,e)}),[s]),m=(0,Q.useCallback)((A=>D(A,lA(O.West,360-r),O.West)),[D,r]),p=(0,Q.useCallback)((A=>D(A,lA(O.East,360-r),O.East)),[D,r]),f=(0,Q.useCallback)((A=>D(A,lA(O.North,360-r),O.North)),[D,r]),y=(0,Q.useCallback)((A=>D(A,lA(O.South,360-r),O.South)),[D,r]),M=(0,Q.useCallback)((A=>D(A,O.Northwest,O.Northwest)),[D]),x=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Northeast)),[D]),F=(0,Q.useCallback)((A=>D(A,O.Southwest,O.Southwest)),[D]),Y=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Southeast)),[D]),v=(e?i-2*h-C:i-2*l-w)>0&&(e?a-2*h-C:a-2*l-w)>0;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(kn,{isMobile:e,outerRadius:h,x:0,y:0,cursorStyle:"nw-resize",onPointerDown:M,handleClass:"cornerNorthWest",cornerRadius:l,color:n,strokeWidth:I}),v?(0,t.jsx)(kn,{isMobile:e,outerRadius:h,x:a,y:0,cursorStyle:"ne-resize",onPointerDown:x,handleClass:"cornerNorthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(kn,{isMobile:e,outerRadius:h,x:a,y:i,cursorStyle:"se-resize",onPointerDown:Y,handleClass:"cornerSouthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(kn,{isMobile:e,outerRadius:h,x:0,y:i,cursorStyle:"sw-resize",onPointerDown:F,handleClass:"cornerSouthWest",cornerRadius:l,color:n,strokeWidth:I}):void 0,v&&!c?(0,t.jsx)(Jn,{isMobile:e,outerRadius:E,outerWidth:u,outerHeight:C,x:-d/2,y:i/2-w/2,width:d,height:w,onPointerDown:m,edgeHandleRadius:B,cursorStyle:"w-resize",color:n,strokeWidth:I}):void 0,v&&!g?(0,t.jsx)(Jn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:i-d/2,width:w,height:d,onPointerDown:y,edgeHandleRadius:B,cursorStyle:"s-resize",color:n,strokeWidth:I}):void 0,c?void 0:(0,t.jsx)(Jn,{isMobile:e,outerRadius:E,outerWidth:u,outerHeight:C,x:a-d/2,y:i/2-Math.min(w,.8*i)/2,width:d,height:Math.min(w,.8*i),onPointerDown:p,edgeHandleRadius:B,cursorStyle:"e-resize",color:n,strokeWidth:I}),v&&!g?(0,t.jsx)(Jn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:-d/2,width:w,height:d,onPointerDown:f,edgeHandleRadius:B,cursorStyle:"n-resize",color:n,strokeWidth:I}):void 0]})},jn=A=>{const{isMobile:e,color:n,elementWidth:i,onBeginRotate:a,scaleFactor:s}=A,r=(0,Q.useCallback)((A=>{A.stopPropagation(),a()}),[a]),o=13*s,c=30*s;return(0,t.jsxs)("g",{transform:e?`translate(${-c})`:void 0,children:[(0,t.jsx)("circle",{cx:i/2,cy:-2.5*o,r:1.3*o,fill:"transparent",style:{cursor:"ew-resize"},onPointerDown:r}),(0,t.jsxs)("svg",{x:i/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,stroke:n,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",onPointerDown:r,children:[" ",(0,t.jsx)("polyline",{points:"23 4 23 10 17 10"})," ",(0,t.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})]})},zn="spiffElementID",Ln=({color:A,height:e,highlighted:n,id:i,immutable:a,onBeginMove:s,onPointerEnter:r,onPointerLeave:o,onSelected:c,pressed:g,rotation:l,scaleFactor:B,selected:w,width:d,x:h,y:E})=>{const C=1.2*B,{addEvent:u,removeEvent:I,curActiveEvents:D}=sn(),m=(0,Q.useCallback)((A=>{u(A),A[zn]=i;0===D&&0===A.button&&(c(i,A),s())}),[i,w,D,c,s]),p=(0,Q.useCallback)((A=>{I(A)}),[]),f=(0,Q.useCallback)((A=>{r(i)}),[i,D,r]),y=(0,Q.useCallback)((A=>{I(A),o(i)}),[i,D,o]),M=a?void 0:w?g?"grabbing":"grab":"pointer",x=a?"none":"visibleFill";return(0,t.jsx)("g",{transform:`translate(${h}, ${E}) rotate(${l} ${d/2} ${e/2})`,children:(0,t.jsx)("rect",{className:"interactableInnerRect",width:d,height:e,stroke:w||n?A:"none",pointerEvents:x,fill:"none",strokeWidth:C,style:{cursor:M},onPointerDown:a?void 0:m,onPointerUp:a?void 0:p,onPointerEnter:a?void 0:f,onPointerLeave:a?void 0:y})})},Tn=A=>{const{isMobile:e,color:n,height:i,onBeginResize:a,onBeginRotate:s,onContextMenuHandlePointerDown:r,rotation:o,scaleFactor:c,width:g,x:l,y:B,disableX:w,disableY:d}=A;return(0,t.jsxs)("g",{transform:`translate(${l}, ${B}) rotate(${o} ${g/2} ${i/2})`,children:[(0,t.jsx)(jn,{isMobile:e&&!!r,color:n,elementWidth:g,onBeginRotate:s,scaleFactor:c}),e&&r&&(0,t.jsx)(bn,{onPointerDown:r,elementWidth:g,scaleFactor:c}),(0,t.jsx)(On,{isMobile:e,color:n,elementHeight:i,elementWidth:g,rotation:o,scaleFactor:c,onBeginResize:a,disableX:w,disableY:d})]})},Kn=.5,Vn=["TEXTAREA","INPUT"],Xn=(A,t,e,n,i,a,s,r)=>{const{state:o,uiDispatcher:c}=(0,Q.useContext)(wn),{getLayoutById:g,getReducerState:l,flattenSequence:B}=rn(),[w,d]=(0,Q.useState)(void 0),[h,E]=(0,Q.useState)(void 0),[C,u]=(0,Q.useState)(void 0),[I,D]=(0,Q.useState)(null),m=g(o.layoutId);(0,Q.useEffect)((()=>{if("adjustment"===i&&A?.current&&n){if(n<Kn)return void c(new hn({zoom:Kn}));if(n>o.maxZoom)return void c(new hn({zoom:o.maxZoom}));c(new hn({zoom:n}))}}),[n,c,A,i,o.maxZoom]);const p=(0,Q.useCallback)(((A,n)=>{c(new hn({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))}),[c,t,e,o.scrolledMovement,i]);(0,Q.useEffect)((()=>{o.zoom<=1&&c(new hn({scrolledMovement:!1}))}),[c,o.zoom]);const f=t?.current?.getBoundingClientRect(),y=((f?.width||1)+(f?.height||1))/2,M=(m.layoutState.layout.width+m.layoutState.layout.height)/2/y/o.zoom,x=(0,Q.useMemo)((()=>{const A=o.activeModifierKeys,t=o.elementEvent,e=A.includes(pn.ControlLeft)||A.includes(pn.MetaLeft)||A.includes(pn.ControlRight)||A.includes(pn.MetaRight);if(!o.selectedElement||!t||e)return[];const n=t&&t.type===Dn.Translate,i=t&&t.type===Dn.Rotate,a=m.layoutState.elements.find((A=>A.id===o.selectedElement));return(n||i)&&a?In(a,m.layoutState,M,s):[]}),[o.selectedElement,o.elementEvent,o.activeModifierKeys,m.layoutState,M]),F=(0,Q.useCallback)((()=>{const A=Y();d(A),E(l().transaction)}),[l]),v=(0,Q.useCallback)((A=>{D(A.target),A[zn]||(D(null),c(new hn({selectedElement:void 0})))}),[o,c]),S=(0,Q.useCallback)((()=>{c(new hn({scrolledMovement:!0}))}),[c]),N=(0,Q.useCallback)(((e,n)=>{const i=m.layoutState.elements.find((A=>A.id===o.selectedElement)),s=I?.getBoundingClientRect();if(!(o.elementEvent&&A.current&&t.current&&o.selectedElement&&i&&e.isPrimary))return void(t.current.hasPointerCapture(e.pointerId)&&t.current.releasePointerCapture(e.pointerId));t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const r=A.current.getBoundingClientRect(),c=new Rt(Un({deltaX:C?e.screenX-C.screenX:0,deltaY:C?e.screenY-C.screenY:0,destX:e.clientX,destY:e.clientY,targetRect:s},m.layoutState.layout,i,r,o.elementEvent,x,n));c.sequenceId=w,a(c,!1),u({screenX:e.screenX,screenY:e.screenY})}),[m.layoutState.elements,m.layoutState.layout,o.elementEvent,A,o.selectedElement,t,x,a,C]),P=(0,Q.useCallback)((A=>{c(new hn({elementEvent:A}))}),[c]),R=(0,Q.useCallback)((()=>{P(void 0),w&&h&&(B(w,h),d(void 0),E(void 0),r&&r()),u(void 0)}),[P,w,h,B,r]),H=(0,Q.useCallback)(((A,t)=>{let e=o.zoom;const n=o.maxZoom,s=o.selectedElement,r=o.activeModifierKeys;if((r.includes(pn.AltLeft)||r.includes(pn.AltRight))&&(A.code===pn.Equal||A.code===pn.Minus)){const t=.05*n;A.code===pn.Equal?c(new hn({zoom:e+t<=n?e+=t:e})):c(new hn({zoom:e-t>=Kn?e-t:e}))}const g=m.layoutState.elements.find((A=>A.id===s));if(s&&g){if(A.code===pn.MetaLeft||A.code===pn.ControlLeft||A.code===pn.MetaRight||A.code===pn.ControlRight){const t=A.code,e=o.activeModifierKeys;if(!e.includes(t))return c(new hn({activeModifierKeys:e.concat(t)}))}if(A.code===pn.ArrowDown||A.code===pn.ArrowUp||A.code===pn.ArrowLeft||A.code===pn.ArrowRight){c(new hn({elementEvent:{type:Dn.Translate}}));const e=yn(A.code,g,o.units,t);a(e,!1),c(new hn({elementEvent:void 0}))}A.code!==pn.Delete&&A.code!==pn.Backspace||"advanced"!==i||(c(new hn({selectedElement:void 0})),a(new Gt(g.id),!1))}}),[a,c,m.layoutState.elements,i,o.activeModifierKeys,o.maxZoom,o.selectedElement,o.units,o.zoom]),U=(0,Q.useCallback)((A=>{if(A.code===pn.MetaLeft||A.code===pn.ControlLeft||A.code===pn.MetaRight||A.code===pn.ControlRight){const t=o.activeModifierKeys,e=A.code;c(new hn({activeModifierKeys:t.filter((A=>A!==e))}))}}),[c,o.activeModifierKeys]);return{guidelines:x,scale:M,zoomableElementRef:e,setElementEvent:P,handleZoom:p,handleKeyDown:H,handleKeyUp:U,handlePointerPressedBackground:v,handlePointerReleased:R,handlePointerMove:N,handleScroll:S,handleSequenceStart:F}},Wn=(A,t,e)=>{const n=(0,Q.useMemo)((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),i=(0,Q.useRef)([]),a=(0,Q.useCallback)((()=>{const A=n.every((A=>i.current.includes(A))),t=i.current.length===n.length;return A&&t}),[]),s=(0,Q.useCallback)((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const n=A.target;return!(Vn.indexOf(n.tagName)>=0)&&(i.current=[...new Set([...i.current,e])],a()&&t(),A.preventDefault())}),[a,n,t,A]),r=(0,Q.useCallback)((A=>{const t=String(A.key).toLowerCase(),n=a();i.current=i.current.filter((A=>A!==t));const s=a();e&&n&&!s&&e()}),[n]);(0,Q.useEffect)((()=>(window.addEventListener("keydown",s),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",r)})),[s,r])},Zn=A=>{const{isMobile:e,primaryColor:n,customViewbox:i,editorRef:a,elementEvent:s,guidelines:r,layoutHeight:o,layoutWidth:c,targetedElements:g,scale:l,selectedElement:B,onElementEvent:w,onElementSelected:d,onSequenceStart:h,onMouseMove:E,onContextMenuHandlePointerDown:C}=A,{state:u}=En(),{getLayoutById:I}=rn(),D=I(u.layoutId),[m,p]=(0,Q.useState)(void 0),f=(0,Q.useCallback)((A=>{p(A)}),[]),y=(0,Q.useCallback)((A=>{m===A&&p(void 0)}),[m]),M=(0,Q.useCallback)((()=>{h(),w({type:Dn.Translate})}),[w]),x=(0,Q.useCallback)(((A,t)=>{h(),w({type:Dn.Resize,relativeAxis:A,screenAxis:t})}),[w]),F=(0,Q.useCallback)((()=>{h(),w({type:Dn.Rotate})}),[w]),Y=i||{x:0,y:0,width:c,height:o},v=D.layoutState.elements,S=v.find((A=>A.id===B));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%",overflow:"visible"},width:"auto",height:"auto",viewBox:`${Y.x} ${Y.y} ${Y.width} ${Y.height}`,children:[(0,t.jsx)("rect",{onMouseMove:E,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:a,width:c,height:o}),r.map((A=>A.svgNode)),v.map((A=>{const e=void 0!==B&&A.id===B,i=e&&void 0!==s,a=void 0!==m&&A.id===m;return(0,t.jsx)(Ln,{color:n,id:A.id,selected:e,highlighted:a,pressed:i,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,immutable:A.immutable||g&&!g.includes(A.id),onSelected:d,onBeginMove:M,onPointerEnter:f,onPointerLeave:y,scaleFactor:l},A.id)})),S&&(0,t.jsx)(Tn,{isMobile:e,color:n,x:S.x,y:S.y,disableX:S.type===P.Frame||S.type===P.Image,disableY:S.type===P.Textbox||S.type===P.Frame||S.type===P.Image,width:S.width,height:S.height,rotation:S.rotation,onBeginResize:x,onBeginRotate:F,scaleFactor:l,onContextMenuHandlePointerDown:C})]})},qn=({isMobile:A,color:e,outlineColor:n,editorRef:i,zoomableElementRef:a,interactionElementRef:s,guidelines:r,isMakingAdjustments:o,outlineArea:c,visibleLayoutId:g,xTranslation:l,yTranslation:B,targetedElements:w,borderRadius:d,canvasFilter:h,children:E,handleContextMenu:C,onMouseMove:u,onContextMenuHandlePointerDown:I,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:y,handleScroll:M,onSequenceStart:x,setElementEvent:F,onElementSelected:Y})=>{const{getLayoutById:v}=rn(),S=v(g),N=S.layoutState,{state:P}=En(),R=(0,Q.useCallback)((A=>{if(c){const t={left:c.x||0,top:c.y||0,width:c.width||1,height:c.height||1,panelId:"",rotation:0};return D(A,t)}return D(A)}),[D,c]),U=(0,Q.useCallback)((A=>{if(c){const t={left:c.x||0,top:c.y||0,width:c.width||1,height:c.height||1,panelId:"",rotation:0};return p(A,t)}return p(A)}),[p,c]),b=(0,Q.useMemo)((()=>{return{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:(A=window.chrome,t=window.navigator,e=t.vendor,n=void 0!==window.opr,t.userAgent.match("CriOS")||null==A||"Google Inc."!==e||!1!==n?void 0:"none")};var A,t,e,n}),[]),G=(0,Q.useMemo)((()=>({height:"100%",transform:`scale(${P.zoom}) translate(${l}px, ${B}px)`,display:"flex",justifyContent:"center",alignItems:"center",filter:h||"drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2))",overflow:"visible"})),[P.zoom,P.xTranslation,P.yTranslation]),k=10/P.zoom,J=N.layout.width,O=N.layout.height,j=a.current?.offsetHeight||1024,z=a.current?.offsetWidth||1024,L=k*(Math.sqrt(J*O)/1e3)*(100/Math.sqrt(j*z))*Math.sqrt((T=z/j,Math.exp(Math.abs(Math.log(T)))));var T;const K=(0,Q.useMemo)((()=>({configuration:{purpose:H.FreeDesign},height:o?"100%":"auto",width:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",outlineArea:c?{...c,scale:L}:void 0,borderRadius:d,outlineColor:n})),[o,L,d,n]);return(0,t.jsx)("div",{style:b,onContextMenu:C,onKeyDown:R,onKeyUp:m,onPointerDown:f,onMouseLeave:y,onPointerMoveCapture:U,onPointerUp:y,onWheelCapture:M,ref:s,tabIndex:-1,children:(0,t.jsxs)("div",{ref:a,style:G,children:[E,S.getComponentWithProps(K),(0,t.jsx)(Zn,{isMobile:A,primaryColor:e,editorRef:i,elementEvent:P.elementEvent,guidelines:r,layoutHeight:N.layout.height,layoutWidth:N.layout.width,onElementEvent:F,onSequenceStart:x,onElementSelected:Y,scale:L,selectedElement:P.selectedElement,targetedElements:w,onMouseMove:u,onContextMenuHandlePointerDown:I})]})})},$n=({isMobile:A,color:e,outlineColor:n,borderRadius:i,guidelineColor:a,canvasFilter:s,hideEditableAreaRect:r,handleContextMenu:o,onMouseMove:c,onContextMenuHandlePointerDown:g,onElementSelected:l,onDragEnd:B})=>{const{commandDispatcher:w,getLayoutById:d}=rn(),{state:h,uiDispatcher:E}=En(),C=(0,Q.useRef)(null),u=(0,Q.useRef)(null),I=(0,Q.useRef)(null),{guidelines:D,handleKeyDown:m,handleKeyUp:p,handlePointerMove:f,handlePointerPressedBackground:y,handlePointerReleased:M,handleScroll:x,handleSequenceStart:F,setElementEvent:Y}=Xn(C,u,I,void 0,"advanced",w,a,B),v=(0,Q.useMemo)((()=>d(h.layoutId)),[d,h.layoutId]),S=(0,Q.useCallback)(((A,t)=>{const e=v.layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===P.Textbox){const t=e.algorithm;(!t||t===b.Autosize)&&w(new jt(A,b.Traditional),!0)}l&&l(A,t),E(new hn({selectedElement:A}))}),[w,d,h.layoutId,E]),N=(0,Q.useMemo)((()=>{if(v.layoutState.layout.useEditableArea)return{...v.layoutState.layout.editableArea,hidden:r}}),[v.layoutState.layout.useEditableArea,v.layoutState.layout.editableArea,r]);return(0,t.jsx)(qn,{outlineArea:N,isMobile:A,color:e,outlineColor:n,editorRef:C,interactionElementRef:u,zoomableElementRef:I,guidelines:D,visibleLayoutId:h.layoutId,xTranslation:h.xTranslation,yTranslation:h.yTranslation,borderRadius:i,canvasFilter:s,handleContextMenu:o,onMouseMove:c,onContextMenuHandlePointerDown:g,handleKeyDown:m,handleKeyUp:p,handlePointerMove:f,handlePointerPressedBackground:y,handlePointerReleased:M,handleScroll:x,onSequenceStart:F,setElementEvent:Y,onElementSelected:S})},_n=d.gql`
1
+ var A=require("lodash.clonedeep"),t=require("react/jsx-runtime"),e=require("react-dom/server"),n=require("opentype.js"),i=require("buffer"),a=require("axios"),s=require("https"),r=require("file-type"),o=require("util"),c=require("css"),g=require("canvas"),l=require("exif"),B=require("canvg"),w=require("swagger-client"),d=require("@apollo/client"),h=require("@apollo/client/link/context"),E=require("@apollo/client/link/error"),C=require("cross-fetch"),Q=require("react"),u=require("lodash.isequal"),I=require("lodash.debounce"),D=require("qrcode"),m=require("svg-path-bbox");function p(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 y(A){return A&&A.__esModule?A.default:A}function M(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}p(module.exports,"SpiffCommerceClient",(()=>ns)),p(module.exports,"CommandContext",(()=>It)),p(module.exports,"spiffCoreConfiguration",(()=>Te)),p(module.exports,"PromiseQueue",(()=>Ei)),p(module.exports,"QueueablePromise",(()=>hi)),p(module.exports,"MockWorkflowManager",(()=>os)),p(module.exports,"InformationMessageType",(()=>ca)),p(module.exports,"StepHandle",(()=>da)),p(module.exports,"TextStepHandle",(()=>ya)),p(module.exports,"FrameStepHandle",(()=>Bs)),p(module.exports,"BulkStepHandle",(()=>Qa)),p(module.exports,"ShapeStepHandle",(()=>fa)),p(module.exports,"IllustrationStepHandle",(()=>ua)),p(module.exports,"MaterialStepHandle",(()=>Ia)),p(module.exports,"ModelStepHandle",(()=>Da)),p(module.exports,"PictureStepHandle",(()=>ma)),p(module.exports,"QuestionStepHandle",(()=>pa)),p(module.exports,"OptionNotFoundError",(()=>ve)),p(module.exports,"LayoutNotFoundError",(()=>Se)),p(module.exports,"AssetNotFoundError",(()=>Ne)),p(module.exports,"ResourceNotFoundError",(()=>Pe)),p(module.exports,"MisconfigurationError",(()=>Re)),p(module.exports,"ParseError",(()=>be)),p(module.exports,"UnhandledBehaviorError",(()=>Ue)),p(module.exports,"assetService",(()=>tn)),p(module.exports,"designService",(()=>Ra)),p(module.exports,"createDesign",(()=>Sa)),p(module.exports,"optionService",(()=>nn)),p(module.exports,"server",(()=>Ze)),p(module.exports,"persistenceService",(()=>ze)),p(module.exports,"graphQlManager",(()=>qe)),p(module.exports,"toast",(()=>bi)),p(module.exports,"FrameService",(()=>Ii)),p(module.exports,"frameStepService",(()=>Fi)),p(module.exports,"modelStepService",(()=>Si)),p(module.exports,"materialStepService",(()=>vi)),p(module.exports,"shapeStepService",(()=>Hi)),p(module.exports,"questionStepService",(()=>Ri)),p(module.exports,"digitalContentStepService",(()=>Mi)),p(module.exports,"moduleStepService",(()=>Ni)),p(module.exports,"pictureStepService",(()=>Pi)),p(module.exports,"textStepService",(()=>Oi)),p(module.exports,"illustrationStepService",(()=>Yi)),p(module.exports,"ProductCameraRig",(()=>Cn)),p(module.exports,"FrameStep",(()=>gs)),p(module.exports,"AssetType",(()=>T)),p(module.exports,"BringForwardCommand",(()=>qt)),p(module.exports,"BringToFrontCommand",(()=>Wt)),p(module.exports,"BringToBackCommand",(()=>Zt)),p(module.exports,"CanvasCommand",(()=>Yt)),p(module.exports,"CreateElementCommand",(()=>bt)),p(module.exports,"CreateLayoutCommand",(()=>Ht)),p(module.exports,"DeleteElementCommand",(()=>Gt)),p(module.exports,"FontAlignmentCommand",(()=>Lt)),p(module.exports,"FontColorCommand",(()=>Jt)),p(module.exports,"FontSizeCommand",(()=>Ot)),p(module.exports,"FontSourceCommand",(()=>zt)),p(module.exports,"GroupCommand",(()=>Rt)),p(module.exports,"LayoutElementFactory",(()=>Me)),p(module.exports,"LayoutElementType",(()=>P)),p(module.exports,"MoveCommand",(()=>St)),p(module.exports,"ResizeCommand",(()=>Pt)),p(module.exports,"RotateCommand",(()=>Nt)),p(module.exports,"SendBackwardsCommand",(()=>$t)),p(module.exports,"StepAspectType",(()=>W)),p(module.exports,"StepType",(()=>V)),p(module.exports,"TextChangeCommand",(()=>Kt)),p(module.exports,"UnitOfMeasurement",(()=>k)),p(module.exports,"dataUrlFromExternalUrl",(()=>UA)),p(module.exports,"findElement",(()=>yt)),p(module.exports,"frameDataCache",(()=>oe)),p(module.exports,"generate",(()=>Y)),p(module.exports,"getAxisAlignedBoundingBox",(()=>_)),p(module.exports,"generateSVGWithUnknownColors",(()=>Qt)),p(module.exports,"getAttributesFromArrayBuffer",(()=>ae)),p(module.exports,"rehydrateSerializedLayout",(()=>Ft)),p(module.exports,"getFrameData",(()=>Be)),p(module.exports,"getSvgString",(()=>mt)),p(module.exports,"loadFontFromDataUrl",(()=>KA)),p(module.exports,"loadFontFromExternalUrl",(()=>TA)),p(module.exports,"determineCorrectFontSizeAndLines",(()=>ue)),p(module.exports,"patternImageDataCache",(()=>re)),p(module.exports,"generateCommands",(()=>Va)),p(module.exports,"registerJSDOM",(()=>fA)),p(module.exports,"minZoom",(()=>Kn)),p(module.exports,"AdvancedEditor",(()=>$n)),p(module.exports,"TransformWrapper",(()=>ws)),p(module.exports,"EditorCore",(()=>qn)),p(module.exports,"useLayouts",(()=>rn)),p(module.exports,"useEditorState",(()=>En)),p(module.exports,"useEditorInteraction",(()=>Xn)),p(module.exports,"useShortcutCombination",(()=>Wn)),p(module.exports,"commandReducer",(()=>Bn)),p(module.exports,"getDefaultState",(()=>ln)),p(module.exports,"CommandContextContext",(()=>an)),p(module.exports,"AdvancedEditorStateProvider",(()=>dn)),p(module.exports,"AdvancedEditorContext",(()=>wn)),p(module.exports,"UICommand",(()=>hn)),p(module.exports,"EditorSubMenu",(()=>cn)),p(module.exports,"ElementEventType",(()=>Dn)),p(module.exports,"KeyEvent",(()=>pn)),p(module.exports,"gatherVaryingStepAspects",(()=>ri));var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==f?f:{},F={};M(F,"CanvasCommand",(()=>Yt)),M(F,"UpdateWorkflowStateCommand",(()=>vt)),M(F,"MoveCommand",(()=>St)),M(F,"RotateCommand",(()=>Nt)),M(F,"ResizeCommand",(()=>Pt)),M(F,"GroupCommand",(()=>Rt)),M(F,"CreateLayoutCommand",(()=>Ht)),M(F,"ClearLayoutCommand",(()=>Ut)),M(F,"CreateElementCommand",(()=>bt)),M(F,"DeleteElementCommand",(()=>Gt)),M(F,"CloneElementCommand",(()=>kt)),M(F,"FontColorCommand",(()=>Jt)),M(F,"FontSizeCommand",(()=>Ot)),M(F,"FontAlgorithmCommand",(()=>jt)),M(F,"FontSourceCommand",(()=>zt)),M(F,"FontAlignmentCommand",(()=>Lt)),M(F,"UpdateFramePattern",(()=>Tt)),M(F,"TextChangeCommand",(()=>Kt)),M(F,"IllustrationColorCommand",(()=>Vt)),M(F,"IllustrationCacheCommand",(()=>Xt)),M(F,"BringToFrontCommand",(()=>Wt)),M(F,"BringToBackCommand",(()=>Zt)),M(F,"BringForwardCommand",(()=>qt)),M(F,"SendBackwardsCommand",(()=>$t)),M(F,"LayerCommand",(()=>_t)),M({},"generate",(()=>Y));const Y=()=>{const A=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()};var v={};M(v,"ElementNotFoundError",(()=>ft)),M(v,"findElement",(()=>yt)),M(v,"findLayoutForElement",(()=>Mt)),M(v,"updatedLayoutForElement",(()=>xt)),M(v,"rehydrateSerializedLayout",(()=>Ft));var S={};M(S,"CommandContext",(()=>It)),M(S,"elementFactory",(()=>Dt)),M(S,"getSvgString",(()=>mt)),M(S,"sortElementsByLayersWithIndex",(()=>pt)),M({},"SVGLayout",(()=>q));var N={};let P;var R;let H;var U;let b;var G;let k;var J;let O;var j;let z;var L;let T;var K;let V;var X;let W;var Z;M(N,"LayoutElementType",(()=>P)),M(N,"LayoutRenderingPurpose",(()=>H)),M(N,"TextAlgorithm",(()=>b)),M(N,"UnitOfMeasurement",(()=>k)),M(N,"ScaleAxis",(()=>O)),M(N,"MaterialEffectMode",(()=>z)),M(N,"AssetType",(()=>T)),M(N,"StepType",(()=>V)),M(N,"StepAspectType",(()=>W)),(R=P||(P={})).Frame="frame",R.Image="image",R.Illustration="illustration",R.Textbox="textbox",(U=H||(H={}))[U.ThreeD=0]="ThreeD",U[U.FreeDesign=1]="FreeDesign",U[U.Print=2]="Print",(G=b||(b={})).Autosize="Autosize",G.Traditional="Traditional",(J=k||(k={})).Pixel="px",J.Millimeter="mm",J.Centimeter="cm",(j=O||(O={}))[j.North=0]="North",j[j.Northeast=1]="Northeast",j[j.East=2]="East",j[j.Southeast=3]="Southeast",j[j.South=4]="South",j[j.Southwest=5]="Southwest",j[j.West=6]="West",j[j.Northwest=7]="Northwest",(L=z||(z={})).None="None",L.RemoveWhenSelected="RemoveWhenSelected",L.ApplyWhenSelected="ApplyWhenSelected",(K=T||(T={})).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",(X=V||(V={})).Bulk="Bulk",X.DigitalContent="DigitalContent",X.Finish="Finish",X.Frame="Frame",X.Illustration="Illustration",X.Introduction="Introduction",X.Material="Material",X.Model="Model",X.Module="Module",X.Picture="Picture",X.Photo="Photo",X.ProductOverlay="ProductOverlay",X.Question="Question",X.Shape="Shape",X.SilentIllustration="SilentIllustration",X.Text="Text",(Z=W||(W={})).Color="Color",Z.Colors="Colors",Z.Selection="Selection",Z.Selections="Selections",Z.Text="Text",Z.Upload="Upload";const q=({backgroundColor:A,outlineColor:e,borderRadius:n,configuration:i,elements:a,height:s,maxHeight:r,maxWidth:o,outlineArea:c,position:g,preserveAspectRatio:l,viewBox:B,width:w})=>{const d=n||0,h=2*(c?.scale||1),E=B||{x:0,y:0,width:w,height:s},C=`${E.x} ${E.y} ${E.width} ${E.height}`,Q=Y(),u=i.purpose===H.FreeDesign&&(0,t.jsx)("defs",{children:(0,t.jsx)("clipPath",{id:"viewboxClip",children:(0,t.jsx)("rect",{width:E.width,height:E.height,rx:d})})}),I=i.colorProfiles?.map(((A,e)=>(0,t.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},e))),D=pt(a.map((A=>({...A,_renderingConfiguration:i,mask:c?`url(#viewmask-${Q})`:void 0}))));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:l,width:w,height:s,style:{gridColumn:1,gridRow:1,maxWidth:o,maxHeight:r,position:g},viewBox:C,children:[I,u,!!A&&(0,t.jsx)("rect",{id:"layout-background",width:E.width,height:E.height,fill:A,rx:d}),(0,t.jsx)("g",{id:"element-group",clipPath:i.purpose===H.FreeDesign?"url(#viewboxClip)":void 0,children:D.map((A=>Dt(A))).filter((A=>!!A))}),c&&(0,t.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"none",stroke:c.hidden?"none":e||"#aaaaaa",strokeWidth:h/2,strokeDasharray:`${2*h} ${h}`}),c&&(0,t.jsxs)("mask",{id:`viewmask-${Q}`,children:[(0,t.jsx)("rect",{x:E.x,y:E.y,width:E.width,height:E.height,fill:"black"}),(0,t.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height,fill:"white"})]})]})};M({},"Image",(()=>EA));var $={};M($,"getAxisAlignedBoundingBox",(()=>_)),M($,"degreesToRadians",(()=>tA)),M($,"findAngle",(()=>AA)),M($,"radiansToDegrees",(()=>eA)),M($,"isCloseToValue",(()=>nA)),M($,"getTrueCoordinates",(()=>iA)),M($,"getPointOfRotation",(()=>aA)),M($,"getNWPoint",(()=>sA)),M($,"getNEPoint",(()=>rA)),M($,"getSWPoint",(()=>oA)),M($,"getSEPoint",(()=>cA)),M($,"turnRightClockwise",(()=>gA)),M($,"currentDirection",(()=>lA)),M($,"getElementVertices",(()=>BA)),M($,"rotateAroundPoint",(()=>wA)),M($,"mmPerPixel",(()=>dA)),M($,"cmPerPixel",(()=>hA));const _=(A,t,e,n,i)=>{const a=tA(i),s=e/2,r=n/2,o=A+s,c=t+r,g=Math.sin(a),l=Math.cos(a),B=-r,w=s*l-B*g,d=s*l-r*g,h=s*g+B*l,E=s*g+r*l,C=Math.max(Math.abs(w),Math.abs(d)),Q=Math.max(Math.abs(h),Math.abs(E));return{minX:o-C,maxX:o+C,minY:c-Q,maxY:c+Q}},AA=(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)},tA=A=>A*(Math.PI/180),eA=A=>A*(180/Math.PI),nA=(A,t,e)=>Math.abs(A-t)<e,iA=(A,t,e)=>{const n=Math.sin(tA(e)),i=Math.cos(tA(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}},aA=(A,t)=>({x:(A.x+t.x)/2,y:(A.y+t.y)/2}),sA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+t?.y*n}),rA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+t?.y*n}),oA=(A,t,e,n)=>({x:A.x+t?.x*e,y:A.y+(t?.y+t?.height)*n}),cA=(A,t,e,n)=>({x:A.x+(t?.x+t?.width)*e,y:A.y+(t?.y+t?.height)*n}),gA=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}},lA=(A,t)=>t>45&&t<=135?gA(A):t>135&&t<=225?gA(gA(A)):t>225&&t<=315?gA(gA(gA(A))):A,BA=(A,t={x:0,y:0},e={x:1,y:1})=>{const n=tA(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},r={x:t.x+A.x*e.x,y:t.y+(A.height+A.y)*e.y},o={x:(r.x+s.x)/2,y:r.y-A.height*e.y/2};return{a:wA(i,o,n),b:wA(a,o,n),c:wA(s,o,n),d:wA(r,o,n),center:o}},wA=(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}},dA=.352778,hA=.035277,EA=A=>{const e=A.rotation||0,n=tA(e),i=Math.cos(n),a=-Math.sin(n);return(0,t.jsx)("g",{mask:A.stepName||A.productOverlay?void 0:A.mask,children:(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})})})};M({},"Frame",(()=>CA));const CA=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,r=A.rotation||0,o=tA(r),c=Math.cos(o),g=-Math.sin(o);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("defs",{children:(s=>{const r=A.pattern?.x||0,o=A.pattern?.y||0,c=A.pattern?A.pattern.width*A.pattern.scaleX+Math.abs(r):256,g=A.pattern?A.pattern.height*A.pattern.scaleY+Math.abs(o):256,l=A.pattern?A.pattern.width*A.pattern.scaleX:256,B=A.pattern?A.pattern.height*A.pattern.scaleY:256;return(0,t.jsxs)("g",{mask:A.stepName?void 0:A.mask,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:r,y:o,width:l,height:B,xlinkHref:A.disablePlaceholder?"":A.pattern?A.pattern.src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsSAAALEgHS3X78AAAZL0lEQVR4nO2diVIbSRZFq/GCsZBZjRea6fn/r+oZGrMYBBhkLGwzE1cmTSqVWXuqVFXnRHREG6OlpX43X771j5O/7/+XAEAvWeFrB+gvCABAj0EAAHoMAgDQYxAAgB6DAAD0GAQAoMcgAAA9BgEA6DEIAECPQQAAGuLnz5+Nf/QIAEADyPhHl+fJ5/PTRj/+53z5AItFxn9y+in5Nvn2+3Xf7r5r5FvAAwBYID7jH4/Hy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kQgNMgDEQDITy4BMCOx65zWkyYCagXOIjTIAxEAyE+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)(QA,{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.jsx)("g",{mask:A.stepName?void 0:A.mask,children:(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]})})]})},QA=A=>{const{path:e,width:n,height:i,focalBlurStrength:a,focalBlurRadius:s,blurFilterId:r,focalMaskId:o,blurEdgeClipId:c}=A;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("filter",{id:r,children:(0,t.jsx)("feGaussianBlur",{stdDeviation:a||0})}),(0,t.jsx)("mask",{id:o,children:(0,t.jsx)("circle",{cx:n/2,cy:i/2,r:s||0,fill:"white",filter:`url(#${r})`})}),(0,t.jsx)("mask",{id:c,children:(0,t.jsx)("path",{d:e,style:{fill:"white",opacity:1}})})]})};M({},"Textbox",(()=>gt));var uA={};M(uA,"fontSizeStep",(()=>qA)),M(uA,"textWidth",(()=>$A)),M(uA,"applyTextTransformations",(()=>At)),M(uA,"zip",(()=>tt)),M(uA,"getTextAlignment",(()=>et)),M(uA,"getAnchor",(()=>nt)),M(uA,"recomputeTextOnElement",(()=>it)),M(uA,"defaultLineHeightFactor",(()=>at)),M({},"calculateTextboxLines",(()=>ZA));var IA={};M(IA,"FontMetrics",(()=>zA)),M(IA,"loadFontFromExternalUrl",(()=>TA)),M(IA,"loadFontFromDataUrl",(()=>KA)),M(IA,"getFontMetrics",(()=>VA));var DA={};M(DA,"registerJSDOM",(()=>fA)),M(DA,"createElement",(()=>FA)),M(DA,"createElementNS",(()=>YA)),M(DA,"domParser",(()=>vA)),M(DA,"fetchAsArrayBuffer",(()=>SA)),M(DA,"fetchAsString",(()=>NA)),M(DA,"loadFontFaceSet",(()=>PA)),M(DA,"xmlSerializer",(()=>RA)),M(DA,"toBase64",(()=>HA)),M(DA,"dataUrlFromExternalUrl",(()=>UA)),M(DA,"arrayBufferToDataUrl",(()=>bA)),M(DA,"arrayBufferToBuffer",(()=>kA)),M(DA,"dataUrlToArrayBuffer",(()=>GA));var mA=i.Buffer;let pA;function fA(A){pA=A}function yA(){if(!pA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new pA}if(void 0===x.TextEncoder){const{TextEncoder:A}=o;x.TextEncoder=A}if(void 0===x.TextDecoder){const{TextDecoder:A}=o;x.TextDecoder=A}const MA=new(y(s).Agent)({rejectUnauthorized:!0}),xA=A=>A.every((A=>"undefined"!==A)),FA=A=>xA([typeof document])?document.createElement(A):yA().window.document.createElement(A),YA=(A,t)=>{if(xA([typeof document]))return document.createElementNS(A,t);const e=yA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},vA=()=>xA([typeof DOMParser])?new DOMParser:new(yA().window.DOMParser),SA=A=>{if(xA([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)=>{y(a).get(t,{responseType:"arraybuffer",httpsAgent:MA}).then((t=>{A(t.data)})).catch((A=>{e(A)}))}))}},NA=A=>{if(xA([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)=>{y(a).get(t,{responseType:"text",httpsAgent:MA}).then((t=>{A(t.data)})).catch(e)}))}},PA=async(A,t)=>{if(xA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},RA=()=>xA([typeof XMLSerializer])?new XMLSerializer:new(yA().window.XMLSerializer),HA=A=>xA([typeof btoa])?btoa(A):mA.from(A).toString("base64"),UA=async A=>{if(xA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await OA(e)}const t=(await y(a).get(A,{responseType:"arraybuffer"})).data;return bA(t)},bA=async A=>{const t=await(async A=>{const t=await(0,r.fromBuffer)(A);return t?t.mime:"image/svg+xml"})(A);return`data:${t};base64,${kA(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)),r=mA.from(s,a);return JA(r)},kA=A=>mA.from(A),JA=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},OA=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)})),jA=new Map;class zA{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 LA=A=>"data:"===A.substring(0,5).toLowerCase().trim(),TA=async A=>{const t=LA(A)?KA(A):KA(await UA(A));return XA(t,{assetUrl:LA(A)?A:await UA(A),name:t.names.fullName.en}),await PA(t,A),t},KA=A=>{const t=GA(A),e=y(n).parse(t);return XA(e,{assetUrl:A,name:e.names.fullName.en}),e},VA=A=>{const t=jA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},XA=(A,t)=>{const e=new zA(A);return jA.set(t.name,e),e},WA=(A,t,e,n)=>{const i=$A(A,e,n);if(i<=t)return{lines:[A],width:i};if(!(A.indexOf(" ")>-1)){if(A.length<=1)throw new Error(`Character ${A} is wider than region`);const i=Math.floor(A.length/2),a=WA(A.slice(0,i),t,e,n),s=WA(A.slice(i),t,e,n);return{lines:[...a.lines,...s.lines],width:Math.max(a.width,s.width)}}const a=A.split(" "),s=[];let r=-1/0,o=0;for(;o<a.length;){const A=a[o];if($A(A,e,n)>t){const i=WA(A,t,e,n);s.push(...i.lines),r=Math.max(r,i.width),o++}else{const i=[A];r=Math.max(r,$A(A,e,n));let c=o+1,g=!0;for(;c<a.length&&g;){const A=a[c],s=$A(`${i.join(" ")} ${A}`,e,n);s<=t?(i.push(A),r=Math.max(r,s),c++):g=!1}s.push(i.join(" ")),o=c}}if(r<0)throw new Error(`No max width calculated for text: ${s}.`);return{lines:s,width:r}},ZA=(A,t,e,n,i)=>{const a=VA(t),s=a.getFont();return((A,t,e,n,i,a)=>{const s=a||at,r=t.split("\n");try{const t=r.flatMap((t=>WA(t,A.width,n,i)));return{lines:t.flatMap((A=>A.lines)),requiredHeight:t.flatMap((A=>A.lines)).length*(e*s),requiredWidth:Math.max(...t.map((A=>A.width)))}}catch(A){return{lines:[],requiredHeight:NaN,requiredWidth:NaN}}})(e,At(n),A,A/s.unitsPerEm,a,i)},qA=1,$A=(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},_A={stripControlCharacters:!0,vertical:!1,uppercase:!1},At=(A,t=_A)=>{const e={..._A,...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},tt=(A,t)=>A.map(((A,e)=>[A,t[e]])),et=(A="center",t=!1)=>t?"center":A,nt=A=>"left"===A?"start":"right"===A?"end":"middle",it=(A,t)=>A.fontData?{...A,...(()=>{if(A.algorithm===b.Traditional){const e=ZA(A.fontSize,A.fontData,A,t,A.lineHeight);return{text:e.lines.join("\n"),height:e.requiredHeight,input:t}}return{text:t}})()}:A,at=1.1;var st={};M(st,"colorDefinitionPrintValue",(()=>rt)),M(st,"spotColorDefinitionString",(()=>ot)),M(st,"svgColorValueToDefinition",(()=>ct));const rt=A=>{const t=ot(A.spotColor);return t?`${A.browserValue} ${t}`:A.browserValue},ot=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})`},ct=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]}}},gt=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),r=A.y+(A.curved?0:A.height/2),o=(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",{mask:A.stepName?void 0:A.mask,children:(0,t.jsx)("g",{transform:`matrix(${n}, ${-i}, ${i}, ${n}, ${s}, ${r})`,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} ${ot(A.fillSpotColorDefinition)}`:A.fill,style:{whiteSpace:"pre",userSelect:"none"},children:A.curved?(0,t.jsx)(Bt,{text:A.text||"",curvedPathId:a,align:A.align}):o.map(((e,n)=>(0,t.jsx)(lt,{align:A.vertical?"center":A.align,fontSize:A.fontSize,thisLineIdx:n,amountLines:o.length,text:e,textboxHeight:A.height,textboxWidth:A.width,lineHeight:A.lineHeight,vertical:A.vertical,verticalAlign:A.verticalAlign},n)))})})})]}):null},lt=A=>(0,t.jsx)("tspan",{textAnchor:nt(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:at),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}),Bt=A=>{const e=`#${A.curvedPathId}`;return(0,t.jsx)("textPath",{startOffset:"left"===A.align?"0%":"right"===A.align?"100%":"50%",textAnchor:nt(A.align),href:e,xlinkHref:e,children:A.text})};M({},"Illustration",(()=>ut));var wt={};M(wt,"traverse",(()=>ht)),M(wt,"sanitizeSvgTree",(()=>Et)),M(wt,"modifySVGWithElementProperties",(()=>Ct)),M(wt,"generateSVGWithUnknownColors",(()=>Qt));const dt=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],ht=(A,t)=>{t(A),A.children.length>0&&Array.from(A.children).forEach((A=>ht(A,t)))},Et=(A,t=!1)=>{!t&&A.setAttribute("preserveAspectRatio","none");const e=[];ht(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()})),ht(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)}))}))}))}))},Ct=(A,t,e,n,i)=>{const a=(A=>vA().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)=>{ht(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?rt(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?rt(i):i.browserValue)}}))}))})(a,n,i),(A=>RA().serializeToString(A))(a)},Qt=async A=>{const t=A.match(/<svg.*?<\/svg>/s)||[],e=t?.length>0?t[0]:"",n=vA().parseFromString(e,"image/svg+xml").firstElementChild;if(!n)throw new Error("Failed to read SVG.");Et(n);const i={};ht(n,(A=>{dt.includes(A.tagName)&&!A.attributes.getNamedItem("fill")&&A.setAttribute("fill","black");const t=A.attributes.getNamedItem("fill");if(t&&"none"!==t.value){const e=ct(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=ct(e.value),n=`spiff-stroke-${t.browserValue.replace(/\W/g,"")}`;A.classList.add(n),A.setAttribute("stroke",t.browserValue),i[n]=t}}));const a=RA().serializeToString(n);return{colors:i,svg:a}},ut=A=>{if(A.cachedObjectURL&&!A._renderingConfiguration?.omitCachedFields)return(0,t.jsx)(EA,{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,mask:A.stepName?void 0:A.mask});const e=A.rotation||0,n=tA(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",{mask:A.stepName?void 0:A.mask,children:(0,t.jsx)("g",{transform:s,dangerouslySetInnerHTML:{__html:Ct(A.svg,A.width,A.height,A.colors,A._renderingConfiguration?.spotColors)}})})};class It{constructor(){this.id=Y(),this.stateCallbacks=[],this.prevCommands=[],this.nextCommands=[]}registerStateCallback(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){return{layoutState:{layout:A,elements:e},getComponentWithProps:n=>(0,t.jsx)(q,{backgroundColor:A.transparentBackground?void 0:"white",elements:e,width:A.width,height:A.height,viewBox:{x:0,y:0,width:A.width,height:A.height},...n})}}initialize(A,t){if(t)return void(this.state={transaction:t});let e={serializableWorkflow:{steps:[]},layouts:{}};A.forEach((A=>{e=new Ht(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 Dt=A=>"image"===A.type?(0,t.jsx)(EA,{...A},A.id):"frame"===A.type?(0,t.jsx)(CA,{...A},A.id):"illustration"===A.type?(0,t.jsx)(ut,{...A},A.id):"textbox"===A.type?(0,t.jsx)(gt,{...A},A.id):null,mt=(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}},r=i?.removeExcludedElements?n.filter((A=>!A.excludeFromExport)):n;try{return y(e).renderToStaticMarkup((0,t.jsx)(q,{preserveAspectRatio:"none",...a,...s,elements:r,configuration:i}))}catch(A){return console.error("Error rendering to static markup"),console.error(A),""}};function pt(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 ft extends Error{constructor(){super("Element not found!"),Object.setPrototypeOf(this,ft.prototype)}}const yt=(A,t)=>Mt(A,t).elements.find((t=>t.id===A)),Mt=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new ft;return e},xt=(A,t)=>{const e=pt([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:Y()}},Ft=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],r=(a||s).elements.filter((A=>"illustration"===A.type));for(let A=0;A<r.length;++A){const t=r[A];if(t.src&&!t.svg){const A=await NA(t.src),e=await Qt(A);t.svg=Ct(e.svg,t.width,t.height,t.colors)}}}};class Yt{undo(){if(!this.oldState)throw new Error("Cannot undo.");return this.oldState}overrideOldState(A){this.oldState=A}}class vt extends Yt{constructor(A){super(),this.serializableWorkflow=A}apply(A){return this.oldState=A,{...A,serializableWorkflow:this.serializableWorkflow}}}class St extends Yt{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,x:this.x,y:this.y},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Nt extends Yt{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,rotation:this.angle},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Pt extends Yt{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=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;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=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Rt extends Yt{constructor(A){super(),this.commands=A}apply(A){return this.oldState=A,this.commands.reduce(((A,t)=>t.apply(A)),A)}}class Ht extends Yt{constructor(A){super(),this.layout=A}apply(A){return this.oldState=A,{...A,layouts:{...A.layouts,[this.layout.id]:{elements:[],layout:{...this.layout},modificationID:Y()}}}}}class Ut extends Yt{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:Y()}})),e={};return t.forEach((A=>{e[A.layout.id]=A})),{...A,layouts:e}}}class bt extends Yt{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:Y()}}}}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:Y()}}}}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 Yt{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:Y()})));t||console.log(`Failed to delete element ${this.id}`);const n={};return e.forEach((A=>{n[A.layout.id]=A})),{...A,layouts:n}}}class kt extends Yt{constructor(t,e){super(),this.el=y(A)(t),this.layout=e,this.el.id=Y(),this.el.x+=5,this.el.y+=5}apply(A){return this.oldState=A,new bt(this.el,this.layout).apply(A)}}class Jt extends Yt{constructor(A,t,e){super(),this.id=A,this.color=t,this.textFillSpotColor=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Ot extends Yt{constructor(A,t){super(),this.id=A,this.size=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,fontSize:this.size},n=Mt(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==b.Autosize?e.input||"":e.text||"",a=xt(it(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class jt extends Yt{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,algorithm:this.algorithm},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class zt extends Yt{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,fontData:this.fontData},n=Mt(t.id,Object.values(A.layouts)),i=xt(it(e,e.input||""),n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Lt extends Yt{constructor(A,t){super(),this.id=A,this.align=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,align:this.align},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Tt extends Yt{constructor(A,t,e){super(),this.id=A,this.imageData=t,this.offsets=e}apply(A){this.oldState=A;const t=Mt(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:Y()};return{...A,layouts:{...A.layouts,[t.layout.id]:a}}}}class Kt extends Yt{constructor(A,t){super(),this.id=A,this.text=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e=Mt(t.id,Object.values(A.layouts)),n=xt(it(t,this.text),e);return{...A,layouts:{...A.layouts,[e.layout.id]:n}}}}class Vt extends Yt{constructor(A,t,e){super(),this.id=A,this.className=t,this.fill=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e=t.colors||{},n=e[this.className];e[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...t,colors:e},a=Mt(t.id,Object.values(A.layouts)),s=xt(i,a);return{...A,layouts:{...A.layouts,[a.layout.id]:s}}}}class Xt extends Yt{constructor(A,t,e){super(),this.id=A,this.svgBody=t,this.objectURL=e}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=Mt(t.id,Object.values(A.layouts)),i=xt(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class Wt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!yt(this.id,Object.values(A.layouts)).id)throw new ft;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));t.elements.push(t.elements.splice(e,1)[0]);const n=[...t.elements];return n.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:n,modificationID:Y()}}}}}class Zt extends Yt{constructor(A){super(),this.id=A}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;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!");const n=e.elements.findIndex((A=>A.id===this.id));e.elements.splice(n,1),e.elements.unshift(t);const i=[...e.elements],a=i.splice(n,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[e.layout.id]:{...A.layouts[e.layout.id],elements:i,modificationID:Y()}}}}}class qt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!yt(this.id,Object.values(A.layouts)).id)throw new ft;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:Y()}}}}}class $t extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!yt(this.id,Object.values(A.layouts)).id)throw new ft;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:Y()}}}}}class _t extends Yt{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=yt(this.id,Object.values(A.layouts));if(!t.id)throw new ft;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]:xt({...t,layer:this.value},e)}}}}var Ae={};M(Ae,"patternImageDataCache",(()=>re)),M(Ae,"frameDataCache",(()=>oe)),M(Ae,"generateFrameSVG",(()=>ce)),M(Ae,"generateDefaultRectangleFrameSvg",(()=>ge)),M(Ae,"getVariant",(()=>le)),M(Ae,"getFrameData",(()=>Be)),M(Ae,"calculateOffsets",(()=>we)),M(Ae,"getPatternImageData",(()=>de)),M(Ae,"GetSVGDimensions",(()=>he)),M(Ae,"svgStringDimensions",(()=>Ee));var te={};M(te,"getExifOrientation",(()=>ne)),M(te,"canvasDims",(()=>ie)),M(te,"getAttributesFromArrayBuffer",(()=>ae));let ee=null;const ne=A=>new Promise((t=>{const e=kA(A);(0,r.fromBuffer)(A).then((A=>{const n=A?.mime;if("image/jpeg"!==n)return t(1);(new(0,l.ExifImage)).loadImage(e,((A,e)=>t(A?1:e.image.Orientation||1)))}))})),ie=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]},ae=async A=>{const t=await(async A=>{const t=await bA(A),e=await(0,g.loadImage)(t),[n,i]=ie(e),a=await(async()=>{if(null!==ee)return!ee;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return ee=2===A.width&&3===A.height,!ee})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const s=await ne(A),[r,o]=s>4?[i,n]:[n,i],c=(0,g.createCanvas)(r,o),l=c.getContext("2d");switch(s){case 2:l.translate(r,0),l.scale(-1,1);break;case 3:l.translate(r,o),l.rotate(Math.PI);break;case 4:l.translate(0,o),l.scale(1,-1);break;case 5:l.rotate(-.5*Math.PI),l.scale(-1,1);break;case 6:l.rotate(-.5*Math.PI),l.translate(-r,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-r,o),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-o)}return l.drawImage(e,0,0,r,o),c})(A);return"image/jpeg"===(await(0,r.fromBuffer)(A))?.mime?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}};M({},"getDefaultVariant",(()=>se));const se=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},re=new Map,oe=new Map,ce=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return ge(A)}return NA(t)},ge=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 `},le=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||se(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},Be=async A=>{const t=vA().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,r=t.getElementById("target-path"),o=t.getElementsByClassName("st0").item(0);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 oe.set(A,t),t}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 oe.set(A,t),t}throw new Error("Malformed frame SVG")},we=(A,t,e)=>{const n=t.width>=t.height,i=A.width>=A.height,a=t.width/2,s=t.height/2,r=(n?t.height:t.width)/(i?A.height:A.width),o=e?.scale||r,c=a-A.width/2*o,g=e?.left||c,l=s-A.height/2*o;return{x:g,y:e?.top||l,zoom:o}},de=async A=>{if(re.has(A))return re.get(A);if(A.endsWith("svg")){const t=await he(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return re.set(A,i),i}{const t=await SA(A),e=await ae(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return re.set(A,n),n}},he=async A=>{const t=await fetch(A),e=await t.text();return Ee(e)},Ee=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 Ce={};M(Ce,"determineCorrectFontSizeAndLines",(()=>ue)),M(Ce,"determineCorrectTextboxRegion",(()=>Ie));const Qe=(A,t,e,n,i)=>{let a=t.map((A=>A.split("\n"))).flat(),s=a.length,r=a.map((A=>$A(A,n,i)));const o=i.getApproximateHeight()*n;let c=!0;for(;c;){if(o+(s-1)*e>A.height)return[null,null];const t=Math.max(...r);if(t<=A.width)return[a,t];const g=r.reduce(((A,t,e,n)=>t>n[A]?e:A),0),l=a[g];let B=!1,w=l.length;for(;!B&&w>-1;){w=l.lastIndexOf(" ",w-1);const t=[l.slice(0,w),l.slice(w+1)],e=t.map((A=>$A(A,n,i)));e[0]<=A.width&&(a=[...a.slice(0,g),...t,...a.slice(g+1)],r=[...r.slice(0,g),...e,...r.slice(g+1)],s+=1,B=!0)}B||(c=!1)}return[null,null]},ue=(A,t,e,n,i)=>{let a,s;const r=VA(t),o=r.getFont();if(i.size){const t=A/o.unitsPerEm;return[a,s]=Qe(e,n,A,t,r),[i.size,a,s]}let c=6-qA;if(n.length>0){let A=n,t=0;for(;(!i.maxSize||c<=i.maxSize)&&A;)c+=qA,t=c/o.unitsPerEm,[A,s]=Qe(e,n,c,t,r)}c>6&&(c-=qA),i.minSize&&c<i.minSize&&(c=i.minSize);const g=c/o.unitsPerEm;return[a,s]=Qe(e,n,c,g,r),[c,a,s]},Ie=(A,t,e,n,i)=>{let a={...A},s={...A},[r,o,c]=ue(e,t,s,n,{size:0,minSize:e,maxSize:e});var g,l;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,[r,o]=ue(e,t,s,n,{size:e}),r===e&&o&&(g=n,l=o,g.map(((A,t)=>[A,l[t]]))).every((([A,t])=>A===t))&&(a=s)),a};var De={};M(De,"svgObjectURL",(()=>fe)),M(De,"LayoutElementFactory",(()=>Me));const me=(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},pe=async A=>new Promise((t=>{fetch(A).then((A=>{t(A.text())})).catch((A=>console.error(A)))})),fe=async A=>{const t=(new DOMParser).parseFromString(A,"image/svg+xml").firstElementChild;if(!t)throw new Error("Failed to read SVG");const e=(new XMLSerializer).serializeToString(t),n=document.createElement("canvas"),i=n.getContext("2d"),a=await B.Canvg.from(i,e,{anonymousCrossOrigin:!0,ignoreDimensions:!1}),s=t.getAttribute("width"),r=t.getAttribute("height"),o=2048;if(r&&s){const A=parseFloat(r),t=parseFloat(s)/A;t>1?a.resize(o,o/t):a.resize(o*t,o)}else a.resize(o,o);return await a.render(),await(async A=>new Promise(((t,e)=>{try{if(!URL||!URL.createObjectURL)throw new Error("Environment incapable of generating ObjectURL");A.toBlob((e=>{if(!e){if(0===A.width||0===A.height)throw new Error(`Canvas dimensions are invalid (${A.width},${A.height})`);if(A.width*A.height>=268435456)throw new Error(`Canvas dimensions exceed device limit (${A.width},${A.height})`);throw new Error("Couldn't generate object URL for Illustration, the blob was undefined!")}t(URL.createObjectURL(e))}))}catch(A){e(A)}})))(n)},ye=async(A,t,e,n)=>{const i=A.layoutState.layout.useEditableArea&&A.layoutState.layout.editableArea||{width:A.layoutState.layout.width,height:A.layoutState.layout.height,x:0,y:0},a=i.width<i.height?i.width:i.height,s=A.layoutState.layout.useEditableArea?a/1.3:a/2,r={top:i.y+i.height/2-s/2,left:i.x+i.width/2-s/2,width:s,height:s,rotation:0,panelId:A.layoutState.layout.panelId};if(e&&t===P.Illustration){const A=await Qt(await pe(e)),t=(new DOMParser).parseFromString(A.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!t)throw new Error("SVG missing viewBox.");const n=r.height,i=t.split(" "),a=(parseFloat(i[2])||1)/(parseFloat(i[3])||1);r.height=r.width/a,r.top+=(n-r.height)/2}if(e&&t===P.Image){const A=r.height,t=await fetch(e),n=await t.arrayBuffer(),i=await ae(n),a=i.width/i.height;r.height=r.width/a,r.top+=(A-r.height)/2}if(e&&t===P.Textbox&&n?.text&&n?.fontScale){const A={assetUrl:e,name:(await TA(e)).names.fullName.en},t=VA(A),a=$A(n.text,n?.fontScale,t);r.width=Math.min(a,.85*i.width),r.left=i.x+i.width/2-r.width/2}return r};class Me{static async getFrame(A,t){const e=await ce(t.region,t.src),n=await Be(e),i=t.region||await ye(A,P.Frame);return{id:Y(),x:i.left,y:i.top,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||me(A,i.layer||0),rotation:i.rotation,scaleX:i.width/n.width,scaleY:i.height/n.height,path:n.path,type:P.Frame,disablePlaceholder:t.configuration.disablePlaceholder,focalBlur:t.configuration.focalBlur,focalBlurStrength:t.configuration.focalBlurStrength,focalBlurRadius:t.configuration.focalBlurRadius,pattern:void 0,immutable:i.immutable}}static async getImage(A,t){const e=t.region||await ye(A,P.Image,t.src);return{id:Y(),src:t.src,type:P.Image,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||me(A,e.layer||0),immutable:e.immutable,preserveAspectRatio:"none"}}static async getTextbox(A,t){const{configuration:e,fontSrc:n,designInputStep:i}=t,a=await TA(n),s={assetUrl:n,name:a.names.fullName.en},r=i?.text||e.defaultText||"",o=e.replaceableText?e.replaceableText.replace("{{}}",r):r,c=At(o,{vertical:e.vertical,uppercase:e.uppercase}),g=t.region||await ye(A,P.Textbox,n,{text:c,fontScale:e.size?e.size/a.unitsPerEm:void 0}),l=it({id:Y(),type:P.Textbox,x:g.left,y:g.top,width:g.width,height:g.height,align:et(e.textAlign,e.vertical),curved:e.curved,fill:i?.color||e.colour||"#000000",fontData:s,layer:g.layer||0,layerIndex:g.layerIndex||me(A,g.layer||0),paths:e.paths,rotation:g.rotation,vertical:e.vertical,verticalAlign:e.verticalAlign||"middle",algorithm:b.Traditional,fontSize:e.size||Math.max(Math.round(.025*g.height),1),text:c,input:r},c),B=Ie({...g,height:l.height},s,l.fontSize,l?.text?.split("\n")||[],l.align);return{...l,x:B.left,y:B.top+(g.height-B.height)/2,width:B.width,height:B.height}}static async getShape(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=t.region||await ye(A,P.Illustration),a=Y();return{stepRegion:t.region,colors:n,id:a,svg:e,type:P.Illustration,y:i.top,x:i.left,rotation:i.rotation,width:i.width,height:i.height,layer:i.layer||0,layerIndex:i.layerIndex||me(A,i.layer||0),immutable:i.immutable}}static async getIllustration(A,t){const e=t.region||await ye(A,P.Illustration,t.src),n=await Qt(await pe(t.src)),i=await fe(n.svg),a=Y();return{cachedObjectURL:i,stepRegion:t.region,colors:n.colors,id:a,svg:n.svg,type:P.Illustration,y:e.top,x:e.left,rotation:e.rotation,width:e.width,height:e.height,layer:e.layer||0,layerIndex:e.layerIndex||me(A,e.layer||0),immutable:e.immutable}}}function xe(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class Fe extends Error{constructor(A){super(A),this.name=this.constructor.name}}class Ye extends Fe{constructor(A){super(`ConfigurationError - ${A}`)}}class ve extends Ye{constructor(A){super(`Option not Configured: ${A.stepTitle}`),xe(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class Se extends Ye{constructor(A){super(`Panel not Found: ${A.panelId}`),xe(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class Ne extends Ye{constructor(A){super(`Asset not found for variant: ${A.name}`),xe(this,"variant",void 0),this.variant=A}}class Pe extends Ye{constructor(A){super(`Resource not found for asset: ${A.name}`),xe(this,"asset",void 0),this.asset=A}}class Re extends Ye{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),xe(this,"step",void 0),this.step=A}}class He extends Fe{constructor(A){super(`ImplementationError - ${A}`)}}class Ue extends He{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class be extends He{constructor(A){super(`Parsing Error: ${A}`)}}class Ge extends He{constructor(A){super(`Client Error: ${A}`)}}class ke extends He{constructor(A){super(`Resource Generation Failed: ${A}`)}}function Je(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}class Oe{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 je{constructor(){Je(this,"storage",new Map)}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 ze=(()=>{try{return localStorage?new Oe:new je}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new je}})();function Le(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const Te=new class{constructor(){Le(this,"defaultServerUrl","https://api.spiff.com.au"),Le(this,"defaultServicesApiUrl","https://services.spiff.com.au"),Le(this,"defaultHubUrl","https://hub.spiff.com.au"),Le(this,"serverUrl",void 0),Le(this,"servicesApiUrl",void 0),Le(this,"hubUrl",void 0),Le(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 Ke(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let Ve;const Xe=A=>{Ve=A},We=async()=>{const A={transactionOwnerId:Ve};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=Te.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 Ze=new class{constructor(){Ke(this,"client",void 0),Ke(this,"uncachedOperations",[]),Te.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 We();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 We(),t=Te.getServerUrl()+"/v2/api-docs";return await y(w)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const qe=new class{constructor(){Ke(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),Te.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,d.createHttpLink)({uri:`${Te.getServerUrl()}/graphql`,fetch:C.fetch}),t=(0,h.setContext)((async(A,{headers:t})=>{const e=t||{},n=await We();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,d.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,d.ApolloClient)({link:(0,d.from)([e,t,A]),cache:n,name:"Core"})}};function $e(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const _e="persistentAssets";class An{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=ze.getMap(_e);n&&n.forEach(((A,t)=>{e.set(t,A)})),ze.setMap(_e,e)}static remove(A){const t=ze.getMap(_e);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),ze.setMap(_e,t))}static list(){const A=ze.getMap(_e);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const tn=new class{constructor(){$e(this,"server",void 0),$e(this,"cache",new Map),$e(this,"materialCache",new Map),$e(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await ae(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)}})),$e(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await tn.getLocalOrFromServer(A.assetKey))),$e(this,"getMaterialFromVariant",(async A=>A.material?A.material:await tn.getMaterialLocalOrFromServer(A.materialId))),this.server=Ze}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new Ue("Failed to get asset from cache!");return t}const t=(async()=>(await Ze.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 Ze.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;An.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?T.Image:T.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 tn.uploadAssetWithProgress(e,n,t,!0)}}removePersistedAsset(A){An.remove(A)}getPersistedAssets(){return An.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 Ue("Unexpected mimetype: "+t)}}};function en(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}const nn=new class{constructor(){en(this,"cache",new Map),en(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),en(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),en(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),en(this,"getOptionFromStep",(async(A,t)=>{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 nn.getOption(t,A.optionId)}))}async getOption(A,t){if(this.cache.has(t))return this.cache.get(t);const e=(async()=>{const e=await A.execute("getOptionV2",{id:t});if(e.body.data)return e.body})();return this.cache.set(t,e),e}async getAssetTileImageForVariant(A){if(A.thumbnailKey){const t=await tn.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 tn.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}},an=(0,Q.createContext)(new It),sn=function(){const[A,t]=(0,Q.useState)([]);return{addEvent:(0,Q.useCallback)((A=>{t((t=>[...t,A]))}),[]),updateEvent:(0,Q.useCallback)((A=>{t((t=>{const e=t.findIndex((t=>t.pointerId===A.pointerId));if(-1===e)return t;const n=[...t];return n[e]=A,n}))}),[]),removeEvent:(0,Q.useCallback)((A=>{t((t=>t.filter((t=>t.pointerId!==A.pointerId))))}),[]),eventCache:A,curActiveEvents:A.length}},rn=()=>{const A=(0,Q.useContext)(an),[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)}}};function on(A,t,e){return(t=function(A){var t=function(A,t){if("object"!=typeof A||null===A)return A;var e=A[Symbol.toPrimitive];if(void 0!==e){var n=e.call(A,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(A)}(A,"string");return"symbol"==typeof t?t:String(t)}(t))in A?Object.defineProperty(A,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):A[t]=e,A}let cn;var gn;(gn=cn||(cn={})).None="None",gn.FrameAdjustment="FrameAdjustment",gn.FinalizeDesign="FinalizeDesign",gn.SavedDesigns="SavedDesigns",gn.ThreeDPreview="ThreeDPreview",gn.Panels="Panels";const ln=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,xTranslation:0,yTranslation:0,maxZoom:5,units:k.Pixel,subMenu:cn.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Bn=(A,t)=>y(u)(A,t.apply(A))?A:t.apply(A),wn=(0,Q.createContext)({}),dn=A=>{const{getAllLayouts:e}=rn(),[n,i]=(0,Q.useReducer)(Bn,ln(e,A.defaultZoom||1)),a=(0,Q.useMemo)((()=>({state:n,uiDispatcher:i})),[n,i]);return(0,t.jsx)(wn.Provider,{value:a,children:A.children})};class hn{constructor(A){on(this,"changes",void 0),this.changes=A}apply(A){return{...A,...this.changes}}}const En=()=>(0,Q.useContext)(wn);let Cn;var Qn;(Qn=Cn||(Cn={}))[Qn.Orbit=0]="Orbit",Qn[Qn.Pan=1]="Pan";const un=3.75,In=(A,e,n,i)=>{const a=e.layout.useEditableArea&&e.layout.editableArea||{width:e.layout.width,height:e.layout.height,x:0,y:0},s=e.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),r=s.map((A=>_(A.x,A.y,A.width,A.height,A.rotation))),o=[],c=new Set;r.forEach((A=>c.add(A.minX))),r.forEach((A=>c.add(A.maxX))),[a.x,a.x+a.width/2,a.x+a.width].forEach((A=>c.add(A)));const g=new Set;r.forEach((A=>g.add(A.minY))),r.forEach((A=>g.add(A.maxY))),[a.y,a.y+a.height/2,a.y+a.height].forEach((A=>g.add(A)));const l=s.map((A=>A.y));for(let A=-315;A<=315;A+=45)l.push(A);const B=_(A.x,A.y,A.width,A.height,A.rotation),w=[{value:B.minX,anchor:-1},{value:B.minX+(B.maxX-B.minX)/2,anchor:0},{value:B.minX+(B.maxX-B.minX),anchor:1}],d=[{value:B.minY,anchor:-1},{value:B.minY+(B.maxY-B.minY)/2,anchor:0},{value:B.minY+(B.maxY-B.minY),anchor:1}],h=[{value:A.rotation,anchor:0}],E=(A,e,i,s)=>{const r=[];return e.forEach((e=>{const o=i.find((A=>nA(e,A.value,.3*n))),[c,g]=((A,t)=>[{x:"x"===A?t:a.x,y:"x"===A?a.y:t},{x:"x"===A?t:a.x+a.width,y:"x"===A?a.y+a.height:t}])(A,e),l="rotation"===A?null:(0,t.jsx)("line",{x1:c.x,y1:c.y,x2:g.x,y2:g.y,stroke:s||"#D61B5C",strokeWidth:1.2*n},`${A}-${e}-${c.x}-${c.y}-${g.x}-${g.y}`);void 0!==o&&r.push({type:A,value:e,anchorPoint:o.anchor,svgNode:l,guidelineCoordinates:[c,g]})})),r};return o.push(...E("x",Array.from(c),w,i),...E("y",Array.from(g),d,i),...E("rotation",l,h,i)),o};let Dn;var mn;let pn;var fn;(mn=Dn||(Dn={})).Translate="Translate",mn.Rotate="Rotate",mn.Resize="Resize",(fn=pn||(pn={})).ControlLeft="ControlLeft",fn.ControlRight="ControlRight",fn.Equal="Equal",fn.MetaLeft="MetaLeft",fn.MetaRight="MetaRight",fn.Minus="Minus",fn.ArrowLeft="ArrowLeft",fn.ArrowRight="ArrowRight",fn.ArrowUp="ArrowUp",fn.ArrowDown="ArrowDown",fn.AltLeft="AltLeft",fn.AltRight="AltRight",fn.Delete="Delete",fn.Backspace="Backspace";const yn=(A,t,e,n)=>{const i=()=>{switch(e){case k.Pixel:return 1;case k.Millimeter:return dA;case k.Centimeter:return hA;default:throw new Ue("Unknown unit of measurement")}};let a=t.x,s=t.y,r=t.x,o=t.y;switch(A){case pn.ArrowLeft:r=t.x-1/i();break;case pn.ArrowUp:o=t.y-1/i();break;case pn.ArrowRight:r=t.x+1/i();break;case pn.ArrowDown:o=t.y+1/i();break;default:throw new Ue("Unhandled element interaction!")}const c=_(r,o,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=r,s=o),new St(t.id,a,s)};let Mn=0,xn=0;var Fn=0;const Yn=(A,t,e,n,i,a)=>{const s=_(A,t,e,n,i),r=s.maxY-s.minY;return!a||s.maxY-.1*r>=a.top&&s.minY+.1*r<=a.top+a.height},vn=(A,t,e,n,i,a)=>{const s=_(A,t,e,n,i),r=s.maxX-s.minX;return!a||s.maxX-.1*r>=a.left&&s.minX+.1*r<=a.left+a.width},Sn=(A,t,e)=>({x:(A.x-t.x)*((e.maxX-e.minX)/t.width)+e.minX,y:(A.y-t.y)*((e.maxY-e.minY)/t.height)+e.minY}),Nn=A=>Math.abs(A)<.001?0:Math.abs(A-1)<.001?1:A;let Pn;var Rn;(Rn=Pn||(Pn={}))[Rn.Height=0]="Height",Rn[Rn.Width=1]="Width",Rn[Rn.Both=2]="Both";const Hn=(A,t,e)=>{const n=A.rotation*Math.PI/180,i=((A,t,e,n,i)=>{if(i<90){const a=i*Math.PI/180,s=Nn(Math.sin(a)),r=Nn(Math.cos(a));return{height:e*r+n*s,width:e*s+n*r,x:A-e*s,y:t}}if(i<180){const a=(i-90)*Math.PI/180,s=Nn(Math.sin(a)),r=Nn(Math.cos(a));return{width:e*r+n*s,height:e*s+n*r,x:A-(e*r+n*s),y:t-e*s}}if(i<270){const a=(i-180)*Math.PI/180,s=Nn(Math.sin(a)),r=Nn(Math.cos(a));return{height:e*r+n*s,width:e*s+n*r,x:A-n*r,y:t-(e*r+n*s)}}const a=(i-270)*Math.PI/180,s=Nn(Math.sin(a)),r=Nn(Math.cos(a));return{width:e*r+n*s,height:e*s+n*r,x:A,y:t-n*r}})(t.x,t.y,e===Pn.Both||e===Pn.Height?1:A.height,e===Pn.Both||e===Pn.Width?1:A.width,A.rotation),a=BA({x:i.x,y:i.y,width:i.width,height:i.height,rotation:A.rotation}).center;return wA(t,a,-n)},Un=(A,t,e,n,i,a,s)=>{const r=((A,t,e,n,i,a,s)=>{const r=n.width/t.width,o=n.height/t.height,c=A.deltaX/r,g=A.deltaY/o,l=e.rotation*Math.PI/180,B=Math.sin(l),w=Math.cos(l),d=e.type===P.Textbox?1:e.width/e.height;switch(i.type){case Dn.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},h=t;switch(i.screenAxis){case O.North:{const n=-c*B+g*w,i=e.y+n,a=Math.max(e.height-n,1),s=BA({...e}).center,r=BA({...e,y:i,height:a}).center,o=wA(r,s,l),d=o.x-e.width/2,E=o.y-a/2;h={...t,left:d,top:E,height:a};const C=180*l/Math.PI,Q=_(d,E,e.width,a,C),u=Sn({x:A.destX,y:A.destY},A.targetRect,Q),I=wA({x:u.x,y:u.y},s,-l);if(1===a||I.y>E+a){const A=Nn(Math.sin(l)),n=Nn(Math.cos(l)),i=BA({...e}).center,a=wA({x:e.x,y:e.y},i,l),s={x:a.x-(e.height-1)*A,y:a.y+(e.height-1)*n},r=Hn(e,s,Pn.Height);return{...t,height:1,top:r.y,left:r.x}}}break;case O.East:{const n=c*w+g*B,i=Math.max(e.width+n,1);let a=e.height;if(e.type===P.Textbox){const A=e,n=ZA(A.fontSize,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=n.requiredHeight,!a||!n.requiredWidth)return t}const s=BA({...e}).center,r=BA({...e,width:i,height:a}).center,o=wA(r,s,l),d=o.x-i/2,E=o.y-a/2;h={...t,left:d,top:E,width:i,height:a};const C=180*l/Math.PI,Q=_(d,E,e.width,a,C),u=Sn({x:A.destX,y:A.destY},A.targetRect,Q),I=wA({x:u.x,y:u.y},s,-l);if(1===i||I.x<d){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i=Hn(e,n,Pn.Width);return{...t,width:1,top:i.y,left:i.x}}}break;case O.West:{const n=c*w+g*B,i=e.x+n,a=Math.max(e.width-n,1);let s=e.height;if(e.type===P.Textbox){const A=e,n=ZA(A.fontSize,A.fontData,{...A,width:a},A.input||A.text||"",A.lineHeight);if(s=n.requiredHeight,!s||!n.requiredWidth)return t}const r=BA({...e}).center,o=BA({...e,width:a,height:s,x:i}).center,d=wA(o,r,l),E=d.x-a/2,C=d.y-s/2;h={...t,left:E,top:C,width:a,height:s};const Q=180*l/Math.PI,u=_(E,C,e.width,s,Q),I=Sn({x:A.destX,y:A.destY},A.targetRect,u),D=wA({x:I.x,y:I.y},r,-l);if(1===a||D.x>E+a){const A=Nn(Math.sin(l)),n=Nn(Math.cos(l)),i=BA({...e}).center,a=wA({x:e.x,y:e.y},i,l),s={x:a.x+(e.width-1)*n,y:a.y+(e.width-1)*A},r=Hn(e,s,Pn.Width);return{...t,width:1,top:r.y,left:r.x}}}break;case O.South:{const n=-c*B+g*w,i=Math.max(e.height+n,1),a=BA({...e}).center,s=BA({...e,height:i}).center,r=wA(s,a,l),o=r.x-e.width/2,d=r.y-i/2;h={...t,left:o,top:d,height:i};const E=180*l/Math.PI,C=_(o,d,e.width,i,E),Q=Sn({x:A.destX,y:A.destY},A.targetRect,C),u=wA({x:Q.x,y:Q.y},a,-l);if(1===i||u.y<d){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i=Hn(e,n,Pn.Height);return{...t,height:1,top:i.y,left:i.x}}}break;case O.Northeast:{const n=c*w+g*B,i=Math.max(e.width+n,1);let a=Math.max(e.height+n/d,1),s=e.y-n/d,r=e.fontSize;if(e.type===P.Textbox){const A=e;r=A.fontSize+n/8;const o=ZA(r,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);a=o.requiredHeight;const c=A.lineHeight||at;if(s=e.y-n*c/8,!a||!o.requiredWidth)return t}const o=BA({...e}).center,E=BA({...e,width:i,height:a,y:s}).center,C=wA(E,o,l),Q=C.x-i/2,u=C.y-a/2;h={...t,left:Q,top:u,width:i,height:a,fontSize:r};const I=180*l/Math.PI,D=_(Q,u,e.width,a,I),m=Sn({x:A.destX,y:A.destY},A.targetRect,D),p=wA({x:m.x,y:m.y},o,-l);if(1===i||1===a||p.x<Q||p.y>u+a){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i={x:n.x-(e.height-1)*B,y:n.y+(e.height-1)*w},a=Hn(e,i,Pn.Both);return{...t,height:1,width:1,top:a.y,left:a.x}}}break;case O.Northwest:{const n=-c*w+-g*B,i=e.x-n,a=Math.max(e.width+n,1);let s=e.y-n/d,r=Math.max(e.height+n/d,1),o=e.fontSize;if(e.type===P.Textbox){const A=e;o=A.fontSize+n/8;const i=ZA(o,A.fontData,{...A,width:a},A.input||A.text||"",A.lineHeight);r=i.requiredHeight;const c=A.lineHeight||at;if(s=e.y-n*c/8,!r||!i.requiredWidth)return t}const E=BA({...e}).center,C=BA({...e,x:i,y:s,width:a,height:r}).center,Q=wA(C,E,l),u=Q.x-a/2,I=Q.y-r/2;h={...t,left:u,top:I,width:a,height:r,fontSize:o};const D=180*l/Math.PI,m=_(u,I,e.width,r,D),p=Sn({x:A.destX,y:A.destY},A.targetRect,m),f=wA({x:p.x,y:p.y},E,-l);if(1===a||1===r||f.x>u+a||f.y>I+r){const A={x:e.x+e.width,y:e.y+e.height},n=wA(A,E,l),i={x:n.x-Math.SQRT2*Math.cos(l+Math.PI/4),y:n.y-Math.SQRT2*Math.sin(l+Math.PI/4)},a=Hn(e,i,Pn.Both);return{...t,height:1,width:1,top:a.y,left:a.x}}}break;case O.Southeast:{const n=c*w+g*B,i=Math.max(e.width+n,1);let a=Math.max(e.height+n/d,1),s=e.fontSize;if(e.type===P.Textbox){const A=e;s=A.fontSize+n/8;const r=ZA(s,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=r.requiredHeight,!a||!r.requiredWidth)return t}const r=BA({...e}).center,o=BA({...e,width:i,height:a}).center,E=wA(o,r,l),C=E.x-i/2,Q=E.y-a/2;h={...t,left:C,top:Q,width:i,height:a,fontSize:s};const u=180*l/Math.PI,I=_(C,Q,e.width,a,u),D=Sn({x:A.destX,y:A.destY},A.targetRect,I),m=wA({x:D.x,y:D.y},r,-l);if(1===i||1===a||m.x<C||m.y<Q){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i=Hn(e,n,Pn.Both);return{...t,height:1,width:1,top:i.y,left:i.x}}}break;case O.Southwest:{const n=-c*w+-g*B,i=Math.max(e.width+n,1);let a=e.x-n,s=Math.max(e.height+n/d,1),r=e.fontSize;if(e.type===P.Textbox){const A=e;r=A.fontSize+n/8;const a=ZA(r,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(s=a.requiredHeight,!s||!a.requiredWidth)return t}const o=BA({...e}).center,E=BA({...e,width:i,height:s,x:a}).center,C=wA(E,o,l),Q=C.x-i/2,u=C.y-s/2;h={...t,left:Q,top:u,width:i,height:s,fontSize:r};const I=180*l/Math.PI,D=_(Q,u,e.width,s,I),m=Sn({x:A.destX,y:A.destY},A.targetRect,D),p=wA({x:m.x,y:m.y},o,-l);if(1===i||1===s||p.x>Q+i||p.y<u){const A=BA({...e}).center,n=wA({x:e.x,y:e.y},A,l),i={x:n.x+(e.width-1)*w,y:n.y+(e.width-1)*B},a=Hn(e,i,Pn.Both);return{...t,height:1,width:1,top:a.y,left:a.x}}}}return Yn(h.left,h.top,h.width,h.height,h.rotation,s)&&vn(h.left,h.top,h.width,h.height,h.rotation,s)&&(t=h),t;case Dn.Rotate:const E={x:A.destX,y:A.destY};let C,Q=e.rotation;const u=BA(e,n,{x:r,y:o}),I=AA(E,u.c,u.d),D=AA(E,u.d,u.c);if(0===a.filter((A=>"rotation"===A.type)).length)Fn=0,C=(e.rotation+I-D)%360;else{Fn+=Math.sqrt(c**2+g**2);const A=Math.abs(Fn)>un*window.devicePixelRatio/r;C=A?(e.rotation+I-D)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Fn=0)}return Yn(e.x,e.y,e.width,e.height,C,s)&&vn(e.x,e.y,e.width,e.height,C,s)&&(Q=C),Q<0&&(Q+=360),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:Q};case Dn.Translate:let m,p,f=e.x,y=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)m=e.x+c,p=e.y+g;else{const A=a.find((A=>"x"===A.type)),t=a.find((A=>"y"===A.type)),n=A=>{switch(A){case-1:return 0;case 0:return e.height/2;case 1:return e.height;default:return 0}};Mn+=c,xn+=g;const i=A?(A=>{switch(A){case-1:return 0;case 0:return e.width/2;case 1:return e.width;default:return 0}})(A.anchorPoint):void 0,s=t?n(t.anchorPoint):void 0,r=void 0!==i&&Math.abs(Mn)<=un,o=void 0!==s&&Math.abs(xn)<=un;A&&r?m=e.x:(m=e.x+Mn,Mn=0),t&&o?p=e.y:(p=e.y+xn,xn=0)}return Yn(m,p,e.width,e.height,e.rotation,s)&&(y=p),vn(m,p,e.width,e.height,e.rotation,s)&&(f=m),{top:y,left:f,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,s),o=[];if(e.type===P.Textbox){const A=e;o.push(new Kt(A.id,A.input||A.text||""))}if(r.width>0&&r.height>0&&(o.push(new St(e.id,r.left,r.top),new Pt(e.id,r.width,r.height),new Nt(e.id,r.rotation)),e.type===P.Textbox)){const A=e;r.fontSize&&A.fontSize!==r.fontSize&&o.push(new Ot(A.id,r.fontSize))}return o},bn=A=>{const{onPointerDown:e,scaleFactor:n,elementWidth:i}=A,a=(0,Q.useCallback)((A=>{A.stopPropagation(),e&&e(A)}),[e]),s=13*n,r=30*n;return(0,t.jsxs)("g",{transform:`translate(${r})`,children:[(0,t.jsx)("circle",{cx:i/2,cy:-2.5*s,r:1.3*s,fill:"transparent",style:{cursor:"pointer"},onPointerDown:a}),(0,t.jsxs)("svg",{onPointerDown:a,x:i/2-s,y:-2.5*s-s,width:2*s,height:2*s,style:{cursor:"pointer"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("path",{d:"M10.3246 4.31731C10.751 2.5609 13.249 2.5609 13.6754 4.31731C13.9508 5.45193 15.2507 5.99038 16.2478 5.38285C17.7913 4.44239 19.5576 6.2087 18.6172 7.75218C18.0096 8.74925 18.5481 10.0492 19.6827 10.3246C21.4391 10.751 21.4391 13.249 19.6827 13.6754C18.5481 13.9508 18.0096 15.2507 18.6172 16.2478C19.5576 17.7913 17.7913 19.5576 16.2478 18.6172C15.2507 18.0096 13.9508 18.5481 13.6754 19.6827C13.249 21.4391 10.751 21.4391 10.3246 19.6827C10.0492 18.5481 8.74926 18.0096 7.75219 18.6172C6.2087 19.5576 4.44239 17.7913 5.38285 16.2478C5.99038 15.2507 5.45193 13.9508 4.31731 13.6754C2.5609 13.249 2.5609 10.751 4.31731 10.3246C5.45193 10.0492 5.99037 8.74926 5.38285 7.75218C4.44239 6.2087 6.2087 4.44239 7.75219 5.38285C8.74926 5.99037 10.0492 5.45193 10.3246 4.31731Z",stroke:"#111827",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z",stroke:"#111827",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})},Gn="#ffffff",kn=A=>{const{isMobile:e,outerRadius:n,x:i,y:a,cursorStyle:s,onPointerDown:r,handleClass:o,cornerRadius:c,color:g,strokeWidth:l}=A,[B,w]=(0,Q.useState)(!1);(0,Q.useEffect)((()=>{const A=()=>{w(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const d=(0,Q.useCallback)((A=>{w(!0),r(A)}),[r]);return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("circle",{cx:i,cy:a,r:n,fill:B?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:s},onPointerDown:d}),(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Gn,style:{cursor:s,pointerEvents:"none"},stroke:g,strokeWidth:l})]}):(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Gn,style:{cursor:s},stroke:g,strokeWidth:l,onPointerDown:r})},Jn=A=>{const{isMobile:e,outerRadius:n,outerWidth:i,outerHeight:a,x:s,y:r,width:o,height:c,cursorStyle:g,onPointerDown:l,edgeHandleRadius:B,color:w,strokeWidth:d}=A,[h,E]=(0,Q.useState)(!1);(0,Q.useEffect)((()=>{const A=()=>{E(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const C=(0,Q.useCallback)((A=>{E(!0),l(A)}),[l]);return e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("rect",{x:s-(i-o)/2,y:r-(a-c)/2,width:i,height:a,rx:n,fill:h?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:g},onPointerDown:C}),(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Gn,style:{cursor:g,pointerEvents:"none"},stroke:w,strokeWidth:d})]}):(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Gn,style:{cursor:g},stroke:w,strokeWidth:d,onPointerDown:l})},On=A=>{const{isMobile:e,color:n,elementHeight:i,elementWidth:a,onBeginResize:s,rotation:r,scaleFactor:o,disableX:c,disableY:g}=A,l=7.5*o,B=3*o,w=28*o,d=6*o,h=30*o,E=5*o,C=40*o,u=36*o,I=1.2*o,D=(0,Q.useCallback)(((A,t,e)=>{A.stopPropagation(),s(t,e)}),[s]),m=(0,Q.useCallback)((A=>D(A,lA(O.West,360-r),O.West)),[D,r]),p=(0,Q.useCallback)((A=>D(A,lA(O.East,360-r),O.East)),[D,r]),f=(0,Q.useCallback)((A=>D(A,lA(O.North,360-r),O.North)),[D,r]),y=(0,Q.useCallback)((A=>D(A,lA(O.South,360-r),O.South)),[D,r]),M=(0,Q.useCallback)((A=>D(A,O.Northwest,O.Northwest)),[D]),x=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Northeast)),[D]),F=(0,Q.useCallback)((A=>D(A,O.Southwest,O.Southwest)),[D]),Y=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Southeast)),[D]),v=(e?i-2*h-C:i-2*l-w)>0&&(e?a-2*h-C:a-2*l-w)>0;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(kn,{isMobile:e,outerRadius:h,x:0,y:0,cursorStyle:"nw-resize",onPointerDown:M,handleClass:"cornerNorthWest",cornerRadius:l,color:n,strokeWidth:I}),v?(0,t.jsx)(kn,{isMobile:e,outerRadius:h,x:a,y:0,cursorStyle:"ne-resize",onPointerDown:x,handleClass:"cornerNorthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(kn,{isMobile:e,outerRadius:h,x:a,y:i,cursorStyle:"se-resize",onPointerDown:Y,handleClass:"cornerSouthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(kn,{isMobile:e,outerRadius:h,x:0,y:i,cursorStyle:"sw-resize",onPointerDown:F,handleClass:"cornerSouthWest",cornerRadius:l,color:n,strokeWidth:I}):void 0,v&&!c?(0,t.jsx)(Jn,{isMobile:e,outerRadius:E,outerWidth:u,outerHeight:C,x:-d/2,y:i/2-w/2,width:d,height:w,onPointerDown:m,edgeHandleRadius:B,cursorStyle:"w-resize",color:n,strokeWidth:I}):void 0,v&&!g?(0,t.jsx)(Jn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:i-d/2,width:w,height:d,onPointerDown:y,edgeHandleRadius:B,cursorStyle:"s-resize",color:n,strokeWidth:I}):void 0,c?void 0:(0,t.jsx)(Jn,{isMobile:e,outerRadius:E,outerWidth:u,outerHeight:C,x:a-d/2,y:i/2-Math.min(w,.8*i)/2,width:d,height:Math.min(w,.8*i),onPointerDown:p,edgeHandleRadius:B,cursorStyle:"e-resize",color:n,strokeWidth:I}),v&&!g?(0,t.jsx)(Jn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:-d/2,width:w,height:d,onPointerDown:f,edgeHandleRadius:B,cursorStyle:"n-resize",color:n,strokeWidth:I}):void 0]})},jn=A=>{const{isMobile:e,color:n,elementWidth:i,onBeginRotate:a,scaleFactor:s}=A,r=(0,Q.useCallback)((A=>{A.stopPropagation(),a()}),[a]),o=13*s,c=30*s;return(0,t.jsxs)("g",{transform:e?`translate(${-c})`:void 0,children:[(0,t.jsx)("circle",{cx:i/2,cy:-2.5*o,r:1.3*o,fill:"transparent",style:{cursor:"ew-resize"},onPointerDown:r}),(0,t.jsxs)("svg",{x:i/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,stroke:n,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",onPointerDown:r,children:[" ",(0,t.jsx)("polyline",{points:"23 4 23 10 17 10"})," ",(0,t.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})]})},zn="spiffElementID",Ln=({color:A,height:e,highlighted:n,id:i,immutable:a,onBeginMove:s,onPointerEnter:r,onPointerLeave:o,onSelected:c,pressed:g,rotation:l,scaleFactor:B,selected:w,width:d,x:h,y:E})=>{const C=1.2*B,{addEvent:u,removeEvent:I,curActiveEvents:D}=sn(),m=(0,Q.useCallback)((A=>{u(A),A[zn]=i;0===D&&0===A.button&&(c(i,A),s())}),[i,w,D,c,s]),p=(0,Q.useCallback)((A=>{I(A)}),[]),f=(0,Q.useCallback)((A=>{r(i)}),[i,D,r]),y=(0,Q.useCallback)((A=>{I(A),o(i)}),[i,D,o]),M=a?void 0:w?g?"grabbing":"grab":"pointer",x=a?"none":"visibleFill";return(0,t.jsx)("g",{transform:`translate(${h}, ${E}) rotate(${l} ${d/2} ${e/2})`,children:(0,t.jsx)("rect",{className:"interactableInnerRect",width:d,height:e,stroke:w||n?A:"none",pointerEvents:x,fill:"none",strokeWidth:C,style:{cursor:M},onPointerDown:a?void 0:m,onPointerUp:a?void 0:p,onPointerEnter:a?void 0:f,onPointerLeave:a?void 0:y})})},Tn=A=>{const{isMobile:e,color:n,height:i,onBeginResize:a,onBeginRotate:s,onContextMenuHandlePointerDown:r,rotation:o,scaleFactor:c,width:g,x:l,y:B,disableX:w,disableY:d}=A;return(0,t.jsxs)("g",{transform:`translate(${l}, ${B}) rotate(${o} ${g/2} ${i/2})`,children:[(0,t.jsx)(jn,{isMobile:e&&!!r,color:n,elementWidth:g,onBeginRotate:s,scaleFactor:c}),e&&r&&(0,t.jsx)(bn,{onPointerDown:r,elementWidth:g,scaleFactor:c}),(0,t.jsx)(On,{isMobile:e,color:n,elementHeight:i,elementWidth:g,rotation:o,scaleFactor:c,onBeginResize:a,disableX:w,disableY:d})]})},Kn=.5,Vn=["TEXTAREA","INPUT"],Xn=(A,t,e,n,i,a,s,r)=>{const{state:o,uiDispatcher:c}=(0,Q.useContext)(wn),{getLayoutById:g,getReducerState:l,flattenSequence:B}=rn(),[w,d]=(0,Q.useState)(void 0),[h,E]=(0,Q.useState)(void 0),[C,u]=(0,Q.useState)(void 0),[I,D]=(0,Q.useState)(null),m=g(o.layoutId);(0,Q.useEffect)((()=>{if("adjustment"===i&&A?.current&&n){if(n<Kn)return void c(new hn({zoom:Kn}));if(n>o.maxZoom)return void c(new hn({zoom:o.maxZoom}));c(new hn({zoom:n}))}}),[n,c,A,i,o.maxZoom]);const p=(0,Q.useCallback)(((A,n)=>{c(new hn({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))}),[c,t,e,o.scrolledMovement,i]);(0,Q.useEffect)((()=>{o.zoom<=1&&c(new hn({scrolledMovement:!1}))}),[c,o.zoom]);const f=t?.current?.getBoundingClientRect(),y=((f?.width||1)+(f?.height||1))/2,M=(m.layoutState.layout.width+m.layoutState.layout.height)/2/y/o.zoom,x=(0,Q.useMemo)((()=>{const A=o.activeModifierKeys,t=o.elementEvent,e=A.includes(pn.ControlLeft)||A.includes(pn.MetaLeft)||A.includes(pn.ControlRight)||A.includes(pn.MetaRight);if(!o.selectedElement||!t||e)return[];const n=t&&t.type===Dn.Translate,i=t&&t.type===Dn.Rotate,a=m.layoutState.elements.find((A=>A.id===o.selectedElement));return(n||i)&&a?In(a,m.layoutState,M,s):[]}),[o.selectedElement,o.elementEvent,o.activeModifierKeys,m.layoutState,M]),F=(0,Q.useCallback)((()=>{const A=Y();d(A),E(l().transaction)}),[l]),v=(0,Q.useCallback)((A=>{D(A.target),A[zn]||(D(null),c(new hn({selectedElement:void 0})))}),[o,c]),S=(0,Q.useCallback)((()=>{c(new hn({scrolledMovement:!0}))}),[c]),N=(0,Q.useCallback)(((e,n)=>{const i=m.layoutState.elements.find((A=>A.id===o.selectedElement)),s=I?.getBoundingClientRect();if(!(o.elementEvent&&A.current&&t.current&&o.selectedElement&&i&&e.isPrimary))return void(t.current.hasPointerCapture(e.pointerId)&&t.current.releasePointerCapture(e.pointerId));t.current.hasPointerCapture(e.pointerId)||t.current.setPointerCapture(e.pointerId);const r=A.current.getBoundingClientRect(),c=new Rt(Un({deltaX:C?e.screenX-C.screenX:0,deltaY:C?e.screenY-C.screenY:0,destX:e.clientX,destY:e.clientY,targetRect:s},m.layoutState.layout,i,r,o.elementEvent,x,n));c.sequenceId=w,a(c,!1),u({screenX:e.screenX,screenY:e.screenY})}),[m.layoutState.elements,m.layoutState.layout,o.elementEvent,A,o.selectedElement,t,x,a,C]),P=(0,Q.useCallback)((A=>{c(new hn({elementEvent:A}))}),[c]),R=(0,Q.useCallback)((()=>{P(void 0),w&&h&&(B(w,h),d(void 0),E(void 0),r&&r()),u(void 0)}),[P,w,h,B,r]),H=(0,Q.useCallback)(((A,t)=>{let e=o.zoom;const n=o.maxZoom,s=o.selectedElement,r=o.activeModifierKeys;if((r.includes(pn.AltLeft)||r.includes(pn.AltRight))&&(A.code===pn.Equal||A.code===pn.Minus)){const t=.05*n;A.code===pn.Equal?c(new hn({zoom:e+t<=n?e+=t:e})):c(new hn({zoom:e-t>=Kn?e-t:e}))}const g=m.layoutState.elements.find((A=>A.id===s));if(s&&g){if(A.code===pn.MetaLeft||A.code===pn.ControlLeft||A.code===pn.MetaRight||A.code===pn.ControlRight){const t=A.code,e=o.activeModifierKeys;if(!e.includes(t))return c(new hn({activeModifierKeys:e.concat(t)}))}if(A.code===pn.ArrowDown||A.code===pn.ArrowUp||A.code===pn.ArrowLeft||A.code===pn.ArrowRight){c(new hn({elementEvent:{type:Dn.Translate}}));const e=yn(A.code,g,o.units,t);a(e,!1),c(new hn({elementEvent:void 0}))}A.code!==pn.Delete&&A.code!==pn.Backspace||"advanced"!==i||(c(new hn({selectedElement:void 0})),a(new Gt(g.id),!1))}}),[a,c,m.layoutState.elements,i,o.activeModifierKeys,o.maxZoom,o.selectedElement,o.units,o.zoom]),U=(0,Q.useCallback)((A=>{if(A.code===pn.MetaLeft||A.code===pn.ControlLeft||A.code===pn.MetaRight||A.code===pn.ControlRight){const t=o.activeModifierKeys,e=A.code;c(new hn({activeModifierKeys:t.filter((A=>A!==e))}))}}),[c,o.activeModifierKeys]);return{guidelines:x,scale:M,zoomableElementRef:e,setElementEvent:P,handleZoom:p,handleKeyDown:H,handleKeyUp:U,handlePointerPressedBackground:v,handlePointerReleased:R,handlePointerMove:N,handleScroll:S,handleSequenceStart:F}},Wn=(A,t,e)=>{const n=(0,Q.useMemo)((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),i=(0,Q.useRef)([]),a=(0,Q.useCallback)((()=>{const A=n.every((A=>i.current.includes(A))),t=i.current.length===n.length;return A&&t}),[]),s=(0,Q.useCallback)((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const n=A.target;return!(Vn.indexOf(n.tagName)>=0)&&(i.current=[...new Set([...i.current,e])],a()&&t(),A.preventDefault())}),[a,n,t,A]),r=(0,Q.useCallback)((A=>{const t=String(A.key).toLowerCase(),n=a();i.current=i.current.filter((A=>A!==t));const s=a();e&&n&&!s&&e()}),[n]);(0,Q.useEffect)((()=>(window.addEventListener("keydown",s),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",r)})),[s,r])},Zn=A=>{const{isMobile:e,primaryColor:n,customViewbox:i,editorRef:a,elementEvent:s,guidelines:r,layoutHeight:o,layoutWidth:c,targetedElements:g,scale:l,selectedElement:B,onElementEvent:w,onElementSelected:d,onSequenceStart:h,onMouseMove:E,onContextMenuHandlePointerDown:C}=A,{state:u}=En(),{getLayoutById:I}=rn(),D=I(u.layoutId),[m,p]=(0,Q.useState)(void 0),f=(0,Q.useCallback)((A=>{p(A)}),[]),y=(0,Q.useCallback)((A=>{m===A&&p(void 0)}),[m]),M=(0,Q.useCallback)((()=>{h(),w({type:Dn.Translate})}),[w]),x=(0,Q.useCallback)(((A,t)=>{h(),w({type:Dn.Resize,relativeAxis:A,screenAxis:t})}),[w]),F=(0,Q.useCallback)((()=>{h(),w({type:Dn.Rotate})}),[w]),Y=i||{x:0,y:0,width:c,height:o},v=D.layoutState.elements,S=v.find((A=>A.id===B));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%",overflow:"visible"},width:"auto",height:"auto",viewBox:`${Y.x} ${Y.y} ${Y.width} ${Y.height}`,children:[(0,t.jsx)("rect",{onMouseMove:E,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:a,width:c,height:o}),r.map((A=>A.svgNode)),v.map((A=>{const e=void 0!==B&&A.id===B,i=e&&void 0!==s,a=void 0!==m&&A.id===m;return(0,t.jsx)(Ln,{color:n,id:A.id,selected:e,highlighted:a,pressed:i,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,immutable:A.immutable||g&&!g.includes(A.id),onSelected:d,onBeginMove:M,onPointerEnter:f,onPointerLeave:y,scaleFactor:l},A.id)})),S&&(0,t.jsx)(Tn,{isMobile:e,color:n,x:S.x,y:S.y,disableX:S.type===P.Frame||S.type===P.Image,disableY:S.type===P.Textbox||S.type===P.Frame||S.type===P.Image,width:S.width,height:S.height,rotation:S.rotation,onBeginResize:x,onBeginRotate:F,scaleFactor:l,onContextMenuHandlePointerDown:C})]})},qn=({isMobile:A,color:e,outlineColor:n,editorRef:i,zoomableElementRef:a,interactionElementRef:s,guidelines:r,isMakingAdjustments:o,outlineArea:c,visibleLayoutId:g,xTranslation:l,yTranslation:B,targetedElements:w,borderRadius:d,canvasFilter:h,children:E,handleContextMenu:C,onMouseMove:u,onContextMenuHandlePointerDown:I,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:y,handleScroll:M,onSequenceStart:x,setElementEvent:F,onElementSelected:Y})=>{const{getLayoutById:v}=rn(),S=v(g),N=S.layoutState,{state:P}=En(),R=(0,Q.useCallback)((A=>{if(c){const t={left:c.x||0,top:c.y||0,width:c.width||1,height:c.height||1,panelId:"",rotation:0};return D(A,t)}return D(A)}),[D,c]),U=(0,Q.useCallback)((A=>{if(c){const t={left:c.x||0,top:c.y||0,width:c.width||1,height:c.height||1,panelId:"",rotation:0};return p(A,t)}return p(A)}),[p,c]),b=(0,Q.useMemo)((()=>{return{justifyContent:"center",position:"relative",height:"100%",width:"100%",scrollbarWidth:"none",outline:(A=window.chrome,t=window.navigator,e=t.vendor,n=void 0!==window.opr,t.userAgent.match("CriOS")||null==A||"Google Inc."!==e||!1!==n?void 0:"none")};var A,t,e,n}),[]),G=(0,Q.useMemo)((()=>({height:"100%",transform:`scale(${P.zoom}) translate(${l}px, ${B}px)`,display:"flex",justifyContent:"center",alignItems:"center",filter:h||"drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2))",overflow:"visible"})),[P.zoom,P.xTranslation,P.yTranslation]),k=10/P.zoom,J=N.layout.width,O=N.layout.height,j=a.current?.offsetHeight||1024,z=a.current?.offsetWidth||1024,L=k*(Math.sqrt(J*O)/1e3)*(100/Math.sqrt(j*z))*Math.sqrt((T=z/j,Math.exp(Math.abs(Math.log(T)))));var T;const K=(0,Q.useMemo)((()=>({configuration:{purpose:H.FreeDesign},height:o?"100%":"auto",width:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",outlineArea:c?{...c,scale:L}:void 0,borderRadius:d,outlineColor:n})),[o,L,d,n]);return(0,t.jsx)("div",{style:b,onContextMenu:C,onKeyDown:R,onKeyUp:m,onPointerDown:f,onMouseLeave:y,onPointerMoveCapture:U,onPointerUp:y,onWheelCapture:M,ref:s,tabIndex:-1,children:(0,t.jsxs)("div",{ref:a,style:G,children:[E,S.getComponentWithProps(K),(0,t.jsx)(Zn,{isMobile:A,primaryColor:e,editorRef:i,elementEvent:P.elementEvent,guidelines:r,layoutHeight:N.layout.height,layoutWidth:N.layout.width,onElementEvent:F,onSequenceStart:x,onElementSelected:Y,scale:L,selectedElement:P.selectedElement,targetedElements:w,onMouseMove:u,onContextMenuHandlePointerDown:I})]})})},$n=({isMobile:A,color:e,outlineColor:n,borderRadius:i,guidelineColor:a,canvasFilter:s,hideEditableAreaRect:r,handleContextMenu:o,onMouseMove:c,onContextMenuHandlePointerDown:g,onElementSelected:l,onDragEnd:B})=>{const{commandDispatcher:w,getLayoutById:d}=rn(),{state:h,uiDispatcher:E}=En(),C=(0,Q.useRef)(null),u=(0,Q.useRef)(null),I=(0,Q.useRef)(null),{guidelines:D,handleKeyDown:m,handleKeyUp:p,handlePointerMove:f,handlePointerPressedBackground:y,handlePointerReleased:M,handleScroll:x,handleSequenceStart:F,setElementEvent:Y}=Xn(C,u,I,void 0,"advanced",w,a,B),v=(0,Q.useMemo)((()=>d(h.layoutId)),[d,h.layoutId]),S=(0,Q.useCallback)(((A,t)=>{const e=v.layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===P.Textbox){const t=e.algorithm;(!t||t===b.Autosize)&&w(new jt(A,b.Traditional),!0)}l&&l(A,t),E(new hn({selectedElement:A}))}),[w,d,h.layoutId,E]),N=(0,Q.useMemo)((()=>{if(v.layoutState.layout.useEditableArea)return{...v.layoutState.layout.editableArea,hidden:r}}),[v.layoutState.layout.useEditableArea,v.layoutState.layout.editableArea,r]);return(0,t.jsx)(qn,{outlineArea:N,isMobile:A,color:e,outlineColor:n,editorRef:C,interactionElementRef:u,zoomableElementRef:I,guidelines:D,visibleLayoutId:h.layoutId,xTranslation:h.xTranslation,yTranslation:h.yTranslation,borderRadius:i,canvasFilter:s,handleContextMenu:o,onMouseMove:c,onContextMenuHandlePointerDown:g,handleKeyDown:m,handleKeyUp:p,handlePointerMove:f,handlePointerPressedBackground:y,handlePointerReleased:M,handleScroll:x,onSequenceStart:F,setElementEvent:Y,onElementSelected:S})},_n=d.gql`
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.182",
3
+ "version": "0.10.183",
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",
@@ -79,7 +79,7 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@apollo/client": "^3.7.0",
82
- "@spiffcommerce/papyrus": "^1.5.57",
82
+ "@spiffcommerce/papyrus": "^1.5.58",
83
83
  "canvg": "https://github.com/spiffdev/canvg.git#03bcd151b12441e88ecb552bb658356f5bbe92c4",
84
84
  "cross-fetch": "^3.1.5",
85
85
  "graphql": "^16.6.0",