@spiffcommerce/core 0.10.166 → 0.10.167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- var A=require("lodash.clonedeep"),t=require("react/jsx-runtime"),e=require("react-dom/server"),n=require("opentype.js"),i=require("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 M(A){return A&&A.__esModule?A.default:A}function y(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}p(module.exports,"SpiffCommerceClient",(()=>Wa)),p(module.exports,"CommandContext",(()=>It)),p(module.exports,"spiffCoreConfiguration",(()=>je)),p(module.exports,"PromiseQueue",(()=>ci)),p(module.exports,"QueueablePromise",(()=>oi)),p(module.exports,"MockWorkflowManager",(()=>As)),p(module.exports,"InformationMessageType",(()=>ea)),p(module.exports,"StepHandle",(()=>ra)),p(module.exports,"TextStepHandle",(()=>Ca)),p(module.exports,"FrameStepHandle",(()=>is)),p(module.exports,"BulkStepHandle",(()=>ga)),p(module.exports,"ShapeStepHandle",(()=>Ea)),p(module.exports,"IllustrationStepHandle",(()=>la)),p(module.exports,"MaterialStepHandle",(()=>Ba)),p(module.exports,"ModelStepHandle",(()=>wa)),p(module.exports,"PictureStepHandle",(()=>da)),p(module.exports,"QuestionStepHandle",(()=>ha)),p(module.exports,"OptionNotFoundError",(()=>xe)),p(module.exports,"LayoutNotFoundError",(()=>Ye)),p(module.exports,"AssetNotFoundError",(()=>ve)),p(module.exports,"ResourceNotFoundError",(()=>Ne)),p(module.exports,"MisconfigurationError",(()=>Se)),p(module.exports,"ParseError",(()=>He)),p(module.exports,"UnhandledBehaviorError",(()=>Re)),p(module.exports,"assetService",(()=>_e)),p(module.exports,"designService",(()=>ya)),p(module.exports,"createDesign",(()=>pa)),p(module.exports,"optionService",(()=>tn)),p(module.exports,"server",(()=>Xe)),p(module.exports,"persistenceService",(()=>Oe)),p(module.exports,"graphQlManager",(()=>We)),p(module.exports,"toast",(()=>vi)),p(module.exports,"FrameService",(()=>wi)),p(module.exports,"frameStepService",(()=>Di)),p(module.exports,"modelStepService",(()=>fi)),p(module.exports,"materialStepService",(()=>pi)),p(module.exports,"shapeStepService",(()=>xi)),p(module.exports,"questionStepService",(()=>Fi)),p(module.exports,"digitalContentStepService",(()=>ui)),p(module.exports,"moduleStepService",(()=>Mi)),p(module.exports,"pictureStepService",(()=>yi)),p(module.exports,"textStepService",(()=>Ri)),p(module.exports,"illustrationStepService",(()=>mi)),p(module.exports,"ProductCameraRig",(()=>hn)),p(module.exports,"FrameStep",(()=>es)),p(module.exports,"AssetType",(()=>T)),p(module.exports,"BringForwardCommand",(()=>Wt)),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",(()=>jt)),p(module.exports,"GroupCommand",(()=>Rt)),p(module.exports,"LayoutElementFactory",(()=>fe)),p(module.exports,"LayoutElementType",(()=>P)),p(module.exports,"MoveCommand",(()=>Nt)),p(module.exports,"ResizeCommand",(()=>Pt)),p(module.exports,"RotateCommand",(()=>St)),p(module.exports,"SendBackwardsCommand",(()=>Zt)),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",(()=>Mt)),p(module.exports,"frameDataCache",(()=>se)),p(module.exports,"generate",(()=>Y)),p(module.exports,"getAxisAlignedBoundingBox",(()=>_)),p(module.exports,"generateSVGWithUnknownColors",(()=>Qt)),p(module.exports,"getAttributesFromArrayBuffer",(()=>ne)),p(module.exports,"rehydrateSerializedLayout",(()=>xt)),p(module.exports,"getFrameData",(()=>ge)),p(module.exports,"getSvgString",(()=>mt)),p(module.exports,"loadFontFromDataUrl",(()=>KA)),p(module.exports,"loadFontFromExternalUrl",(()=>TA)),p(module.exports,"determineCorrectFontSizeAndLines",(()=>Ce)),p(module.exports,"patternImageDataCache",(()=>ae)),p(module.exports,"generateCommands",(()=>ka)),p(module.exports,"registerJSDOM",(()=>fA)),p(module.exports,"minZoom",(()=>kn)),p(module.exports,"AdvancedEditor",(()=>Tn)),p(module.exports,"TransformWrapper",(()=>as)),p(module.exports,"EditorCore",(()=>Ln)),p(module.exports,"useLayouts",(()=>an)),p(module.exports,"useEditorState",(()=>dn)),p(module.exports,"useEditorInteraction",(()=>On)),p(module.exports,"useShortcutCombination",(()=>zn)),p(module.exports,"commandReducer",(()=>gn)),p(module.exports,"getDefaultState",(()=>cn)),p(module.exports,"CommandContextContext",(()=>en)),p(module.exports,"AdvancedEditorStateProvider",(()=>Bn)),p(module.exports,"AdvancedEditorContext",(()=>ln)),p(module.exports,"UICommand",(()=>wn)),p(module.exports,"EditorSubMenu",(()=>rn)),p(module.exports,"ElementEventType",(()=>Qn)),p(module.exports,"KeyEvent",(()=>In)),p(module.exports,"gatherVaryingStepAspects",(()=>Ai));var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==f?f:{},x={};y(x,"CanvasCommand",(()=>Yt)),y(x,"UpdateWorkflowStateCommand",(()=>vt)),y(x,"MoveCommand",(()=>Nt)),y(x,"RotateCommand",(()=>St)),y(x,"ResizeCommand",(()=>Pt)),y(x,"GroupCommand",(()=>Rt)),y(x,"CreateLayoutCommand",(()=>Ht)),y(x,"ClearLayoutCommand",(()=>Ut)),y(x,"CreateElementCommand",(()=>bt)),y(x,"DeleteElementCommand",(()=>Gt)),y(x,"CloneElementCommand",(()=>kt)),y(x,"FontColorCommand",(()=>Jt)),y(x,"FontSizeCommand",(()=>Ot)),y(x,"FontAlgorithmCommand",(()=>zt)),y(x,"FontSourceCommand",(()=>jt)),y(x,"FontAlignmentCommand",(()=>Lt)),y(x,"UpdateFramePattern",(()=>Tt)),y(x,"TextChangeCommand",(()=>Kt)),y(x,"IllustrationColorCommand",(()=>Vt)),y(x,"IllustrationCacheCommand",(()=>Xt)),y(x,"BringForwardCommand",(()=>Wt)),y(x,"SendBackwardsCommand",(()=>Zt)),y(x,"LayerCommand",(()=>qt)),y({},"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={};y(v,"ElementNotFoundError",(()=>ft)),y(v,"findElement",(()=>Mt)),y(v,"findLayoutForElement",(()=>yt)),y(v,"updatedLayoutForElement",(()=>Ft)),y(v,"rehydrateSerializedLayout",(()=>xt));var N={};y(N,"CommandContext",(()=>It)),y(N,"elementFactory",(()=>Dt)),y(N,"getSvgString",(()=>mt)),y(N,"sortElementsByLayersWithIndex",(()=>pt)),y({},"SVGLayout",(()=>q));var S={};let P;var R;let H;var U;let b;var G;let k;var J;let O;var z;let j;var L;let T;var K;let V;var X;let W;var Z;y(S,"LayoutElementType",(()=>P)),y(S,"LayoutRenderingPurpose",(()=>H)),y(S,"TextAlgorithm",(()=>b)),y(S,"UnitOfMeasurement",(()=>k)),y(S,"ScaleAxis",(()=>O)),y(S,"MaterialEffectMode",(()=>j)),y(S,"AssetType",(()=>T)),y(S,"StepType",(()=>V)),y(S,"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",(z=O||(O={}))[z.North=0]="North",z[z.Northeast=1]="Northeast",z[z.East=2]="East",z[z.Southeast=3]="Southeast",z[z.South=4]="South",z[z.Southwest=5]="Southwest",z[z.West=6]="West",z[z.Northwest=7]="Northwest",(L=j||(j={})).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,borderRadius:e,configuration:n,elements:i,height:a,maxHeight:s,maxWidth:r,outlineArea:o,position:c,preserveAspectRatio:g,viewBox:l,width:B})=>{const w=e||0,d=2*(o?.scale||1),h=l||{x:0,y:0,width:B,height:a},E=`${h.x} ${h.y} ${h.width} ${h.height}`,C=Y(),Q=n.purpose===H.FreeDesign&&(0,t.jsx)("defs",{children:(0,t.jsx)("clipPath",{id:"viewboxClip",children:(0,t.jsx)("rect",{width:h.width,height:h.height,rx:w})})}),u=n.colorProfiles?.map(((A,e)=>(0,t.jsx)("color-profile",{name:A.name,xlinkHref:A.key,children:" "},e))),I=pt(i.map((A=>({...A,_renderingConfiguration:n,mask:o?`url(#viewmask-${C})`: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:g,width:B,height:a,style:{gridColumn:1,gridRow:1,maxWidth:r,maxHeight:s,position:c},viewBox:E,children:[u,Q,!!A&&(0,t.jsx)("rect",{id:"layout-background",width:h.width,height:h.height,fill:A,rx:w}),(0,t.jsx)("g",{id:"element-group",clipPath:n.purpose===H.FreeDesign?"url(#viewboxClip)":void 0,children:I.map((A=>Dt(A))).filter((A=>!!A))}),o&&(0,t.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,fill:"none",stroke:o.hidden?"none":"#aaaaaa",strokeWidth:d/2,strokeDasharray:`${2*d} ${d}`}),o&&(0,t.jsxs)("mask",{id:`viewmask-${C}`,children:[(0,t.jsx)("rect",{x:h.x,y:h.y,width:h.width,height:h.height,fill:"black"}),(0,t.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,fill:"white"})]})]})};y({},"Image",(()=>EA));var $={};y($,"getAxisAlignedBoundingBox",(()=>_)),y($,"degreesToRadians",(()=>tA)),y($,"findAngle",(()=>AA)),y($,"radiansToDegrees",(()=>eA)),y($,"isCloseToValue",(()=>nA)),y($,"getTrueCoordinates",(()=>iA)),y($,"getPointOfRotation",(()=>aA)),y($,"getNWPoint",(()=>sA)),y($,"getNEPoint",(()=>rA)),y($,"getSWPoint",(()=>oA)),y($,"getSEPoint",(()=>cA)),y($,"turnRightClockwise",(()=>gA)),y($,"currentDirection",(()=>lA)),y($,"getElementVertices",(()=>BA)),y($,"rotateAroundPoint",(()=>wA)),y($,"mmPerPixel",(()=>dA)),y($,"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})})})};y({},"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,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"})}),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}})})]})};y({},"Textbox",(()=>gt));var uA={};y(uA,"fontSizeStep",(()=>qA)),y(uA,"textWidth",(()=>$A)),y(uA,"applyTextTransformations",(()=>At)),y(uA,"zip",(()=>tt)),y(uA,"getTextAlignment",(()=>et)),y(uA,"getAnchor",(()=>nt)),y(uA,"recomputeTextOnElement",(()=>it)),y(uA,"defaultLineHeightFactor",(()=>at)),y({},"calculateTextboxLines",(()=>ZA));var IA={};y(IA,"FontMetrics",(()=>jA)),y(IA,"loadFontFromExternalUrl",(()=>TA)),y(IA,"loadFontFromDataUrl",(()=>KA)),y(IA,"getFontMetrics",(()=>VA));var DA={};y(DA,"registerJSDOM",(()=>fA)),y(DA,"createElement",(()=>xA)),y(DA,"createElementNS",(()=>YA)),y(DA,"domParser",(()=>vA)),y(DA,"fetchAsArrayBuffer",(()=>NA)),y(DA,"fetchAsString",(()=>SA)),y(DA,"loadFontFaceSet",(()=>PA)),y(DA,"xmlSerializer",(()=>RA)),y(DA,"toBase64",(()=>HA)),y(DA,"dataUrlFromExternalUrl",(()=>UA)),y(DA,"arrayBufferToDataUrl",(()=>bA)),y(DA,"arrayBufferToBuffer",(()=>kA)),y(DA,"dataUrlToArrayBuffer",(()=>GA));var mA=i.Buffer;let pA;function fA(A){pA=A}function MA(){if(!pA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new pA}if(void 0===F.TextEncoder){const{TextEncoder:A}=o;F.TextEncoder=A}if(void 0===F.TextDecoder){const{TextDecoder:A}=o;F.TextDecoder=A}const yA=new(M(s).Agent)({rejectUnauthorized:!0}),FA=A=>A.every((A=>"undefined"!==A)),xA=A=>FA([typeof document])?document.createElement(A):MA().window.document.createElement(A),YA=(A,t)=>{if(FA([typeof document]))return document.createElementNS(A,t);const e=MA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},vA=()=>FA([typeof DOMParser])?new DOMParser:new(MA().window.DOMParser),NA=A=>{if(FA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.arrayBuffer())})).catch((A=>{e(A)}))}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(a).get(t,{responseType:"arraybuffer",httpsAgent:yA}).then((t=>{A(t.data)})).catch((A=>{e(A)}))}))}},SA=A=>{if(FA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.text())})).catch(e)}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(a).get(t,{responseType:"text",httpsAgent:yA}).then((t=>{A(t.data)})).catch(e)}))}},PA=async(A,t)=>{if(FA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},RA=()=>FA([typeof XMLSerializer])?new XMLSerializer:new(MA().window.XMLSerializer),HA=A=>FA([typeof btoa])?btoa(A):mA.from(A).toString("base64"),UA=async A=>{if(FA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await OA(e)}const t=(await M(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)})),zA=new Map;class jA{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=M(n).parse(t);return XA(e,{assetUrl:A,name:e.names.fullName.en}),e},VA=A=>{const t=zA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},XA=(A,t)=>{const e=new jA(A);return zA.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={};y(st,"colorDefinitionPrintValue",(()=>rt)),y(st,"spotColorDefinitionString",(()=>ot)),y(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})};y({},"Illustration",(()=>ut));var wt={};y(wt,"traverse",(()=>ht)),y(wt,"sanitizeSvgTree",(()=>Et)),y(wt,"modifySVGWithElementProperties",(()=>Ct)),y(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 M(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(A){super("No element found with ID: "+A),Object.setPrototypeOf(this,ft.prototype)}}const Mt=(A,t)=>yt(A,t).elements.find((t=>t.id===A)),yt=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new ft(A);return e},Ft=(A,t)=>{const e=pt([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:Y()}},xt=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 SA(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 Nt extends Yt{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,x:this.x,y:this.y},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class St extends Yt{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,rotation:this.angle},n=yt(t.id,Object.values(A.layouts)),i=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,width:this.width,height:this.height};if("frame"===t.type){const A=e;A.scaleX=A.scaleX*this.width/t.width,A.scaleY=A.scaleY*this.height/t.height}const n=yt(t.id,Object.values(A.layouts)),i=Ft(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=M(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=yt(t.id,Object.values(A.layouts)),i=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fontSize:this.size},n=yt(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==b.Autosize?e.input||"":e.text||"",a=Ft(it(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class zt extends Yt{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,algorithm:this.algorithm},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class jt extends Yt{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fontData:this.fontData},n=yt(t.id,Object.values(A.layouts)),i=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,align:this.align},n=yt(t.id,Object.values(A.layouts)),i=Ft(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=yt(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=yt(t.id,Object.values(A.layouts)),n=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=t.colors||{},n=e[this.className];e[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...t,colors:e},a=yt(t.id,Object.values(A.layouts)),s=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=yt(t.id,Object.values(A.layouts)),i=Ft(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,!Mt(this.id,Object.values(A.layouts)).id)throw new ft(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e+1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:Y()}}}}}class Zt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!Mt(this.id,Object.values(A.layouts)).id)throw new ft(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e-1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:Y()}}}}}class qt extends Yt{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!e)throw new Error("Layout missing from state!");return{...A,layouts:{...A.layouts,[e.layout.id]:Ft({...t,layer:this.value},e)}}}}var $t={};y($t,"patternImageDataCache",(()=>ae)),y($t,"frameDataCache",(()=>se)),y($t,"generateFrameSVG",(()=>re)),y($t,"generateDefaultRectangleFrameSvg",(()=>oe)),y($t,"getVariant",(()=>ce)),y($t,"getFrameData",(()=>ge)),y($t,"calculateOffsets",(()=>le)),y($t,"getPatternImageData",(()=>Be)),y($t,"GetSVGDimensions",(()=>we)),y($t,"svgStringDimensions",(()=>de));var _t={};y(_t,"getExifOrientation",(()=>te)),y(_t,"canvasDims",(()=>ee)),y(_t,"getAttributesFromArrayBuffer",(()=>ne));let Ae=null;const te=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)))}))})),ee=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]},ne=async A=>{const t=await(async A=>{const t=await bA(A),e=await(0,g.loadImage)(t),[n,i]=ee(e),a=await(async()=>{if(null!==Ae)return!Ae;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Ae=2===A.width&&3===A.height,!Ae})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const s=await te(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}};y({},"getDefaultVariant",(()=>ie));const ie=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},ae=new Map,se=new Map,re=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return oe(A)}return SA(t)},oe=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 `},ce=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||ie(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},ge=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 se.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 se.set(A,t),t}throw new Error("Malformed frame SVG")},le=(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}},Be=async A=>{if(ae.has(A))return ae.get(A);if(A.endsWith("svg")){const t=await we(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return ae.set(A,i),i}{const t=await NA(A),e=await ne(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return ae.set(A,n),n}},we=async A=>{const t=await fetch(A),e=await t.text();return de(e)},de=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 he={};y(he,"determineCorrectFontSizeAndLines",(()=>Ce)),y(he,"determineCorrectTextboxRegion",(()=>Qe));const Ee=(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]},Ce=(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]=Ee(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]=Ee(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]=Ee(e,n,c,g,r),[c,a,s]},Qe=(A,t,e,n,i)=>{let a={...A},s={...A},[r,o,c]=Ce(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]=Ce(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 ue={};y(ue,"svgObjectURL",(()=>me)),y(ue,"LayoutElementFactory",(()=>fe));const Ie=(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},De=async A=>new Promise((t=>{fetch(A).then((A=>{t(A.text())})).catch((A=>console.error(A)))})),me=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)},pe=async(A,t,e)=>{const n=A.layoutState.layout.useEditableArea&&A.layoutState.layout.editableArea||{width:A.layoutState.layout.width,height:A.layoutState.layout.height,x:0,y:0},i=(n.width<n.height?n.width:n.height)/2,a={top:n.y+n.height/2-i/2,left:n.x+n.width/2-i/2,width:i,height:i,rotation:0,panelId:A.layoutState.layout.panelId};if(e&&t===P.Illustration){const A=await Qt(await De(e)),t=(new DOMParser).parseFromString(A.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!t)throw new Error("SVG missing viewBox.");const n=a.height,i=t.split(" "),s=(parseFloat(i[2])||1)/(parseFloat(i[3])||1);a.height=a.width/s,a.top+=(n-a.height)/2}if(e&&t===P.Image){const A=a.height,t=await fetch(e),n=await t.arrayBuffer(),i=await ne(n),s=i.width/i.height;a.height=a.width/s,a.top+=(A-a.height)/2}return a};class fe{static async getFrame(A,t){const e=await re(t.region,t.src),n=await ge(e),i=t.region||await pe(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||Ie(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 pe(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||Ie(A,e.layer||0),immutable:e.immutable,preserveAspectRatio:"none"}}static async getTextbox(A,t){const{configuration:e,fontSrc:n,designInputStep:i}=t,a=t.region||await pe(A,P.Textbox),s={assetUrl:n,name:(await TA(n)).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=it({id:Y(),type:P.Textbox,x:a.left,y:a.top,width:a.width,height:a.height,align:et(e.textAlign,e.vertical),curved:e.curved,fill:i?.color||e.colour||"#000000",fontData:s,layer:a.layer||0,layerIndex:a.layerIndex||Ie(A,a.layer||0),paths:e.paths,rotation:a.rotation,vertical:e.vertical,verticalAlign:e.verticalAlign||"middle",algorithm:b.Traditional,fontSize:e.size||Math.max(Math.round(.025*a.height),1),text:c,input:r},c),l=Qe({...a,height:g.height},s,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:l.left,y:l.top+(a.height-l.height)/2,width:l.width,height:l.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 pe(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||Ie(A,i.layer||0),immutable:i.immutable}}static async getIllustration(A,t){const e=t.region||await pe(A,P.Illustration,t.src),n=await Qt(await De(t.src)),i=await me(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||Ie(A,e.layer||0),immutable:e.immutable}}}function Me(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 ye extends Error{constructor(A){super(A),this.name=this.constructor.name}}class Fe extends ye{constructor(A){super(`ConfigurationError - ${A}`)}}class xe extends Fe{constructor(A){super(`Option not Configured: ${A.stepTitle}`),Me(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class Ye extends Fe{constructor(A){super(`Panel not Found: ${A.panelId}`),Me(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class ve extends Fe{constructor(A){super(`Asset not found for variant: ${A.name}`),Me(this,"variant",void 0),this.variant=A}}class Ne extends Fe{constructor(A){super(`Resource not found for asset: ${A.name}`),Me(this,"asset",void 0),this.asset=A}}class Se extends Fe{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),Me(this,"step",void 0),this.step=A}}class Pe extends ye{constructor(A){super(`ImplementationError - ${A}`)}}class Re extends Pe{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class He extends Pe{constructor(A){super(`Parsing Error: ${A}`)}}class Ue extends Pe{constructor(A){super(`Client Error: ${A}`)}}class be extends Pe{constructor(A){super(`Resource Generation Failed: ${A}`)}}function Ge(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 ke{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(){Ge(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 Oe=(()=>{try{return localStorage?new ke:new Je}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Je}})();function ze(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 je=new class{constructor(){ze(this,"defaultServerUrl","https://api.spiff.com.au"),ze(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ze(this,"defaultHubUrl","https://hub.spiff.com.au"),ze(this,"serverUrl",void 0),ze(this,"servicesApiUrl",void 0),ze(this,"hubUrl",void 0),ze(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 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}let Te;const Ke=A=>{Te=A},Ve=async()=>{const A={transactionOwnerId:Te};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=je.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 Xe=new class{constructor(){Le(this,"client",void 0),Le(this,"uncachedOperations",[]),je.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 Ve();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 Ve(),t=je.getServerUrl()+"/v2/api-docs";return await M(w)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const We=new class{constructor(){Le(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),je.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,d.createHttpLink)({uri:`${je.getServerUrl()}/graphql`,fetch:C.fetch}),t=(0,h.setContext)((async(A,{headers:t})=>{const e=t||{},n=await Ve();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 Ze(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 qe="persistentAssets";class $e{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=Oe.getMap(qe);n&&n.forEach(((A,t)=>{e.set(t,A)})),Oe.setMap(qe,e)}static remove(A){const t=Oe.getMap(qe);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),Oe.setMap(qe,t))}static list(){const A=Oe.getMap(qe);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const _e=new class{constructor(){Ze(this,"server",void 0),Ze(this,"cache",new Map),Ze(this,"materialCache",new Map),Ze(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await ne(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)}})),Ze(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await _e.getLocalOrFromServer(A.assetKey))),Ze(this,"getMaterialFromVariant",(async A=>A.material?A.material:await _e.getMaterialLocalOrFromServer(A.materialId))),this.server=Xe}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new Re("Failed to get asset from cache!");return t}const t=(async()=>(await Xe.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 Xe.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;$e.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 _e.uploadAssetWithProgress(e,n,t,!0)}}removePersistedAsset(A){$e.remove(A)}getPersistedAssets(){return $e.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 Re("Unexpected mimetype: "+t)}}};function An(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 tn=new class{constructor(){An(this,"cache",new Map),An(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),An(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),An(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),An(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 tn.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 _e.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 _e.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}},en=(0,Q.createContext)(new It),nn=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}},an=()=>{const A=(0,Q.useContext)(en),[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 sn(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 rn;var on;(on=rn||(rn={})).None="None",on.FrameAdjustment="FrameAdjustment",on.FinalizeDesign="FinalizeDesign",on.SavedDesigns="SavedDesigns",on.ThreeDPreview="ThreeDPreview",on.Panels="Panels";const cn=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,xTranslation:0,yTranslation:0,maxZoom:5,units:k.Pixel,subMenu:rn.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),gn=(A,t)=>M(u)(A,t.apply(A))?A:t.apply(A),ln=(0,Q.createContext)({}),Bn=A=>{const{getAllLayouts:e}=an(),[n,i]=(0,Q.useReducer)(gn,cn(e,A.defaultZoom||1)),a=(0,Q.useMemo)((()=>({state:n,uiDispatcher:i})),[n,i]);return(0,t.jsx)(ln.Provider,{value:a,children:A.children})};class wn{constructor(A){sn(this,"changes",void 0),this.changes=A}apply(A){return{...A,...this.changes}}}const dn=()=>(0,Q.useContext)(ln);let hn;var En;(En=hn||(hn={}))[En.Orbit=0]="Orbit",En[En.Pan=1]="Pan";const Cn=(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,1.7*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 Qn;var un;let In;var Dn;(un=Qn||(Qn={})).Translate="Translate",un.Rotate="Rotate",un.Resize="Resize",(Dn=In||(In={})).ControlLeft="ControlLeft",Dn.ControlRight="ControlRight",Dn.Equal="Equal",Dn.MetaLeft="MetaLeft",Dn.MetaRight="MetaRight",Dn.Minus="Minus",Dn.ArrowLeft="ArrowLeft",Dn.ArrowRight="ArrowRight",Dn.ArrowUp="ArrowUp",Dn.ArrowDown="ArrowDown",Dn.AltLeft="AltLeft",Dn.AltRight="AltRight",Dn.Delete="Delete",Dn.Backspace="Backspace";const mn=(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 Re("Unknown unit of measurement")}};let a=t.x,s=t.y,r=t.x,o=t.y;switch(A){case In.ArrowLeft:r=t.x-1/i();break;case In.ArrowUp:o=t.y-1/i();break;case In.ArrowRight:r=t.x+1/i();break;case In.ArrowDown:o=t.y+1/i();break;default:throw new Re("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 Nt(t.id,a,s)};let pn=0,fn=0;var Mn=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},Fn=(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},xn=(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}),Yn=(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 Qn.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=e.height-n,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=xn({x:A.destX,y:A.destY},A.targetRect,Q);if(wA({x:u.x,y:u.y},s,-l).y>E+a)return{...t,height:1}}break;case O.East:{const n=c*w+g*B,i=e.width+n;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=xn({x:A.destX,y:A.destY},A.targetRect,Q);if(wA({x:u.x,y:u.y},s,-l).x<d)return{...t,width:1}}break;case O.West:{const n=c*w+g*B,i=e.x+n,a=e.width-n;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=xn({x:A.destX,y:A.destY},A.targetRect,u);if(wA({x:I.x,y:I.y},r,-l).x>E+a)return{...t,width:1}}break;case O.South:{const n=-c*B+g*w,i=e.height+n,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=xn({x:A.destX,y:A.destY},A.targetRect,C);if(wA({x:Q.x,y:Q.y},a,-l).y<d)return{...t,height:1}}break;case O.Northeast:{const n=c*w+g*B,i=e.width+n;let a=e.height+n/d,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=xn({x:A.destX,y:A.destY},A.targetRect,D),p=wA({x:m.x,y:m.y},o,-l);if(p.x<Q||p.y>u+a)return{...t,height:1,width:1}}break;case O.Northwest:{const n=-c*w+-g*B,i=e.x-n,a=e.width+n;let s=e.y-n/d,r=e.height+n/d,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=xn({x:A.destX,y:A.destY},A.targetRect,m),f=wA({x:p.x,y:p.y},E,-l);if(f.x>u+a||f.y>I+r)return{...t,height:1,width:1}}break;case O.Southeast:{const n=c*w+g*B,i=e.width+n;let a=e.height+n/d,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=xn({x:A.destX,y:A.destY},A.targetRect,I),m=wA({x:D.x,y:D.y},r,-l);if(m.x<C||m.y<Q)return{...t,height:1,width:1}}break;case O.Southwest:{const n=-c*w+-g*B,i=e.width+n;let a=e.x-n,s=e.height+n/d,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=xn({x:A.destX,y:A.destY},A.targetRect,D),p=wA({x:m.x,y:m.y},o,-l);if(p.x>Q+i||p.y<u)return{...t,height:1,width:1}}}return yn(h.left,h.top,h.width,h.height,h.rotation,s)&&Fn(h.left,h.top,h.width,h.height,h.rotation,s)&&(t=h),t;case Qn.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)Mn=0,C=(e.rotation+I-D)%360;else{Mn+=Math.sqrt(c**2+g**2);const A=Math.abs(Mn)>8*window.devicePixelRatio/r;C=A?(e.rotation+I-D)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Mn=0)}return yn(e.x,e.y,e.width,e.height,C,s)&&Fn(e.x,e.y,e.width,e.height,C,s)&&(Q=C),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:Q};case Qn.Translate:let m,p,f=e.x,M=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}};pn+=c,fn+=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,l=void 0!==i&&Math.abs(e.x+pn-i)<=8/r,B=void 0!==s&&Math.abs(e.y+fn-s)<=8/o;A&&l?m=e.x:(m=e.x+pn,pn=0),t&&B?p=e.y:(p=e.y+fn,fn=0)}return yn(m,p,e.width,e.height,e.rotation,s)&&(M=p),Fn(m,p,e.width,e.height,e.rotation,s)&&(f=m),{top:M,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 Nt(e.id,r.left,r.top),new Pt(e.id,r.width,r.height),new St(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},vn=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"})]})]})},Nn="#ffffff",Sn=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:Nn,style:{cursor:s,pointerEvents:"none"},stroke:g,strokeWidth:l})]}):(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Nn,style:{cursor:s},stroke:g,strokeWidth:l,onPointerDown:r})},Pn=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:Nn,style:{cursor:g,pointerEvents:"none"},stroke:w,strokeWidth:d})]}):(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Nn,style:{cursor:g},stroke:w,strokeWidth:d,onPointerDown:l})},Rn=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]),M=(0,Q.useCallback)((A=>D(A,lA(O.South,360-r),O.South)),[D,r]),y=(0,Q.useCallback)((A=>D(A,O.Northwest,O.Northwest)),[D]),F=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Northeast)),[D]),x=(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)(Sn,{isMobile:e,outerRadius:h,x:0,y:0,cursorStyle:"nw-resize",onPointerDown:y,handleClass:"cornerNorthWest",cornerRadius:l,color:n,strokeWidth:I}),v?(0,t.jsx)(Sn,{isMobile:e,outerRadius:h,x:a,y:0,cursorStyle:"ne-resize",onPointerDown:F,handleClass:"cornerNorthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(Sn,{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)(Sn,{isMobile:e,outerRadius:h,x:0,y:i,cursorStyle:"sw-resize",onPointerDown:x,handleClass:"cornerSouthWest",cornerRadius:l,color:n,strokeWidth:I}):void 0,v&&!c?(0,t.jsx)(Pn,{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)(Pn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:i-d/2,width:w,height:d,onPointerDown:M,edgeHandleRadius:B,cursorStyle:"s-resize",color:n,strokeWidth:I}):void 0,c?void 0:(0,t.jsx)(Pn,{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)(Pn,{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]})},Hn=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"})]})]})},Un="spiffElementID",bn=({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}=nn(),m=(0,Q.useCallback)((A=>{u(A),A[Un]=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]),M=(0,Q.useCallback)((A=>{I(A),o(i)}),[i,D,o]),y=a?void 0:w?g?"grabbing":"grab":"pointer",F=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:F,fill:"none",strokeWidth:C,style:{cursor:y},onPointerDown:a?void 0:m,onPointerUp:a?void 0:p,onPointerEnter:a?void 0:f,onPointerLeave:a?void 0:M})})},Gn=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)(Hn,{isMobile:e&&!!r,color:n,elementWidth:g,onBeginRotate:s,scaleFactor:c}),e&&r&&(0,t.jsx)(vn,{onPointerDown:r,elementWidth:g,scaleFactor:c}),(0,t.jsx)(Rn,{isMobile:e,color:n,elementHeight:i,elementWidth:g,rotation:o,scaleFactor:c,onBeginResize:a,disableX:w,disableY:d})]})},kn=.5,Jn=["TEXTAREA","INPUT"],On=(A,t,e,n,i,a,s,r)=>{const{state:o,uiDispatcher:c}=(0,Q.useContext)(ln),{getLayoutById:g,getReducerState:l,flattenSequence:B}=an(),[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 wn({zoom:kn}));if(n>o.maxZoom)return void c(new wn({zoom:o.maxZoom}));c(new wn({zoom:n}))}}),[n,c,A,i,o.maxZoom]);const p=(0,Q.useCallback)(((A,n)=>{c(new wn({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 wn({scrolledMovement:!1}))}),[c,o.zoom]);const f=t?.current?.getBoundingClientRect(),M=((f?.width||1)+(f?.height||1))/2,y=(m.layoutState.layout.width+m.layoutState.layout.height)/2/M/o.zoom,F=(0,Q.useMemo)((()=>{const A=o.activeModifierKeys,t=o.elementEvent,e=A.includes(In.ControlLeft)||A.includes(In.MetaLeft)||A.includes(In.ControlRight)||A.includes(In.MetaRight);if(!o.selectedElement||!t||e)return[];const n=t&&t.type===Qn.Translate,i=t&&t.type===Qn.Rotate,a=m.layoutState.elements.find((A=>A.id===o.selectedElement));return(n||i)&&a?Cn(a,m.layoutState,y,s):[]}),[o.selectedElement,o.elementEvent,o.activeModifierKeys,m.layoutState,y]),x=(0,Q.useCallback)((()=>{const A=Y();d(A),E(l().transaction)}),[l]),v=(0,Q.useCallback)((A=>{D(A.target),A[Un]||(D(null),c(new wn({selectedElement:void 0})))}),[o,c]),N=(0,Q.useCallback)((()=>{c(new wn({scrolledMovement:!0}))}),[c]),S=(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(Yn({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,F,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,F,a,C]),P=(0,Q.useCallback)((A=>{c(new wn({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(In.AltLeft)||r.includes(In.AltRight))&&(A.code===In.Equal||A.code===In.Minus)){const t=.05*n;A.code===In.Equal?c(new wn({zoom:e+t<=n?e+=t:e})):c(new wn({zoom:e-t>=kn?e-t:e}))}const g=m.layoutState.elements.find((A=>A.id===s));if(s&&g){if(A.code===In.MetaLeft||A.code===In.ControlLeft||A.code===In.MetaRight||A.code===In.ControlRight){const t=A.code,e=o.activeModifierKeys;if(!e.includes(t))return c(new wn({activeModifierKeys:e.concat(t)}))}if(A.code===In.ArrowDown||A.code===In.ArrowUp||A.code===In.ArrowLeft||A.code===In.ArrowRight){c(new wn({elementEvent:{type:Qn.Translate}}));const e=mn(A.code,g,o.units,t);a(e,!1),c(new wn({elementEvent:void 0}))}A.code!==In.Delete&&A.code!==In.Backspace||"advanced"!==i||(c(new wn({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===In.MetaLeft||A.code===In.ControlLeft||A.code===In.MetaRight||A.code===In.ControlRight){const t=o.activeModifierKeys,e=A.code;c(new wn({activeModifierKeys:t.filter((A=>A!==e))}))}}),[c,o.activeModifierKeys]);return{guidelines:F,scale:y,zoomableElementRef:e,setElementEvent:P,handleZoom:p,handleKeyDown:H,handleKeyUp:U,handlePointerPressedBackground:v,handlePointerReleased:R,handlePointerMove:S,handleScroll:N,handleSequenceStart:x}},zn=(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!(Jn.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])},jn=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}=dn(),{getLayoutById:I}=an(),D=I(u.layoutId),[m,p]=(0,Q.useState)(void 0),f=(0,Q.useCallback)((A=>{p(A)}),[]),M=(0,Q.useCallback)((A=>{m===A&&p(void 0)}),[m]),y=(0,Q.useCallback)((()=>{h(),w({type:Qn.Translate})}),[w]),F=(0,Q.useCallback)(((A,t)=>{h(),w({type:Qn.Resize,relativeAxis:A,screenAxis:t})}),[w]),x=(0,Q.useCallback)((()=>{h(),w({type:Qn.Rotate})}),[w]),Y=i||{x:0,y:0,width:c,height:o},v=D.layoutState.elements,N=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)(bn,{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:y,onPointerEnter:f,onPointerLeave:M,scaleFactor:l},A.id)})),N&&(0,t.jsx)(Gn,{isMobile:e,color:n,x:N.x,y:N.y,disableX:N.type===P.Frame||N.type===P.Image,disableY:N.type===P.Textbox||N.type===P.Frame||N.type===P.Image,width:N.width,height:N.height,rotation:N.rotation,onBeginResize:F,onBeginRotate:x,scaleFactor:l,onContextMenuHandlePointerDown:C})]})},Ln=A=>{const{isMobile:e,color: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,handleContextMenu:E,onMouseMove:C,onContextMenuHandlePointerDown:u,handleKeyDown:I,handleKeyUp:D,handlePointerMove:m,handlePointerPressedBackground:p,handlePointerReleased:f,handleScroll:M,onSequenceStart:y,setElementEvent:F,onElementSelected:x}=A,{getLayoutById:Y}=an(),v=Y(g),N=v.layoutState,{state:S}=dn(),P=(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 I(A,t)}return I(A)}),[I,c]),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 m(A,t)}return m(A)}),[m,c]),U=(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}),[]),b=(0,Q.useMemo)((()=>({height:"100%",transform:`scale(${S.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"})),[S.zoom,S.xTranslation,S.yTranslation]),G=10/S.zoom,k=N.layout.width,J=N.layout.height,O=a.current?.offsetHeight||1024,z=a.current?.offsetWidth||1024,j=G*(Math.sqrt(k*J)/1e3)*(100/Math.sqrt(O*z))*Math.sqrt((L=z/O,Math.exp(Math.abs(Math.log(L)))));var L;const T=(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:j}:void 0,borderRadius:d})),[o,j]);return(0,t.jsx)("div",{style:U,onContextMenu:E,onKeyDown:P,onKeyUp:D,onPointerDown:p,onMouseLeave:f,onPointerMoveCapture:R,onPointerUp:f,onWheelCapture:M,ref:s,tabIndex:-1,children:(0,t.jsxs)("div",{ref:a,style:b,children:[A.children,v.getComponentWithProps(T),(0,t.jsx)(jn,{isMobile:e,primaryColor:n,editorRef:i,elementEvent:S.elementEvent,guidelines:r,layoutHeight:N.layout.height,layoutWidth:N.layout.width,onElementEvent:F,onSequenceStart:y,onElementSelected:x,scale:j,selectedElement:S.selectedElement,targetedElements:w,onMouseMove:C,onContextMenuHandlePointerDown:u})]})})},Tn=({isMobile:A,color:e,borderRadius:n,guidelineColor:i,canvasFilter:a,hideEditableAreaRect:s,handleContextMenu:r,onMouseMove:o,onContextMenuHandlePointerDown:c,onElementSelected:g,onDragEnd:l})=>{const{commandDispatcher:B,getLayoutById:w}=an(),{state:d,uiDispatcher:h}=dn(),E=(0,Q.useRef)(null),C=(0,Q.useRef)(null),u=(0,Q.useRef)(null),{guidelines:I,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:y,handleSequenceStart:F,setElementEvent:x}=On(E,C,u,void 0,"advanced",B,i,l),Y=(0,Q.useMemo)((()=>w(d.layoutId)),[w,d.layoutId]),v=(0,Q.useCallback)(((A,t)=>{const e=Y.layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===P.Textbox){const t=e.algorithm;(!t||t===b.Autosize)&&B(new zt(A,b.Traditional),!0)}g&&g(A,t),h(new wn({selectedElement:A}))}),[B,w,d.layoutId,h]),N=(0,Q.useMemo)((()=>{if(Y.layoutState.layout.useEditableArea)return{...Y.layoutState.layout.editableArea,hidden:s}}),[Y.layoutState.layout.useEditableArea,Y.layoutState.layout.editableArea,s]);return(0,t.jsx)(Ln,{outlineArea:N,isMobile:A,color:e,editorRef:E,interactionElementRef:C,zoomableElementRef:u,guidelines:I,visibleLayoutId:d.layoutId,xTranslation:d.xTranslation,yTranslation:d.yTranslation,borderRadius:n,canvasFilter:a,handleContextMenu:r,onMouseMove:o,onContextMenuHandlePointerDown:c,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:y,onSequenceStart:F,setElementEvent:x,onElementSelected:v})},Kn=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 M(A){return A&&A.__esModule?A.default:A}function y(A,t,e,n){Object.defineProperty(A,t,{get:e,set:n,enumerable:!0,configurable:!0})}p(module.exports,"SpiffCommerceClient",(()=>Wa)),p(module.exports,"CommandContext",(()=>It)),p(module.exports,"spiffCoreConfiguration",(()=>je)),p(module.exports,"PromiseQueue",(()=>ci)),p(module.exports,"QueueablePromise",(()=>oi)),p(module.exports,"MockWorkflowManager",(()=>As)),p(module.exports,"InformationMessageType",(()=>ea)),p(module.exports,"StepHandle",(()=>ra)),p(module.exports,"TextStepHandle",(()=>Ca)),p(module.exports,"FrameStepHandle",(()=>is)),p(module.exports,"BulkStepHandle",(()=>ga)),p(module.exports,"ShapeStepHandle",(()=>Ea)),p(module.exports,"IllustrationStepHandle",(()=>la)),p(module.exports,"MaterialStepHandle",(()=>Ba)),p(module.exports,"ModelStepHandle",(()=>wa)),p(module.exports,"PictureStepHandle",(()=>da)),p(module.exports,"QuestionStepHandle",(()=>ha)),p(module.exports,"OptionNotFoundError",(()=>xe)),p(module.exports,"LayoutNotFoundError",(()=>Ye)),p(module.exports,"AssetNotFoundError",(()=>ve)),p(module.exports,"ResourceNotFoundError",(()=>Ne)),p(module.exports,"MisconfigurationError",(()=>Se)),p(module.exports,"ParseError",(()=>He)),p(module.exports,"UnhandledBehaviorError",(()=>Re)),p(module.exports,"assetService",(()=>_e)),p(module.exports,"designService",(()=>ya)),p(module.exports,"createDesign",(()=>pa)),p(module.exports,"optionService",(()=>tn)),p(module.exports,"server",(()=>Xe)),p(module.exports,"persistenceService",(()=>Oe)),p(module.exports,"graphQlManager",(()=>We)),p(module.exports,"toast",(()=>vi)),p(module.exports,"FrameService",(()=>wi)),p(module.exports,"frameStepService",(()=>Di)),p(module.exports,"modelStepService",(()=>fi)),p(module.exports,"materialStepService",(()=>pi)),p(module.exports,"shapeStepService",(()=>xi)),p(module.exports,"questionStepService",(()=>Fi)),p(module.exports,"digitalContentStepService",(()=>ui)),p(module.exports,"moduleStepService",(()=>Mi)),p(module.exports,"pictureStepService",(()=>yi)),p(module.exports,"textStepService",(()=>Ri)),p(module.exports,"illustrationStepService",(()=>mi)),p(module.exports,"ProductCameraRig",(()=>hn)),p(module.exports,"FrameStep",(()=>es)),p(module.exports,"AssetType",(()=>T)),p(module.exports,"BringForwardCommand",(()=>Wt)),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",(()=>jt)),p(module.exports,"GroupCommand",(()=>Rt)),p(module.exports,"LayoutElementFactory",(()=>fe)),p(module.exports,"LayoutElementType",(()=>P)),p(module.exports,"MoveCommand",(()=>Nt)),p(module.exports,"ResizeCommand",(()=>Pt)),p(module.exports,"RotateCommand",(()=>St)),p(module.exports,"SendBackwardsCommand",(()=>Zt)),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",(()=>Mt)),p(module.exports,"frameDataCache",(()=>se)),p(module.exports,"generate",(()=>Y)),p(module.exports,"getAxisAlignedBoundingBox",(()=>_)),p(module.exports,"generateSVGWithUnknownColors",(()=>Qt)),p(module.exports,"getAttributesFromArrayBuffer",(()=>ne)),p(module.exports,"rehydrateSerializedLayout",(()=>xt)),p(module.exports,"getFrameData",(()=>ge)),p(module.exports,"getSvgString",(()=>mt)),p(module.exports,"loadFontFromDataUrl",(()=>KA)),p(module.exports,"loadFontFromExternalUrl",(()=>TA)),p(module.exports,"determineCorrectFontSizeAndLines",(()=>Ce)),p(module.exports,"patternImageDataCache",(()=>ae)),p(module.exports,"generateCommands",(()=>ka)),p(module.exports,"registerJSDOM",(()=>fA)),p(module.exports,"minZoom",(()=>kn)),p(module.exports,"AdvancedEditor",(()=>Tn)),p(module.exports,"TransformWrapper",(()=>as)),p(module.exports,"EditorCore",(()=>Ln)),p(module.exports,"useLayouts",(()=>an)),p(module.exports,"useEditorState",(()=>dn)),p(module.exports,"useEditorInteraction",(()=>On)),p(module.exports,"useShortcutCombination",(()=>zn)),p(module.exports,"commandReducer",(()=>gn)),p(module.exports,"getDefaultState",(()=>cn)),p(module.exports,"CommandContextContext",(()=>en)),p(module.exports,"AdvancedEditorStateProvider",(()=>Bn)),p(module.exports,"AdvancedEditorContext",(()=>ln)),p(module.exports,"UICommand",(()=>wn)),p(module.exports,"EditorSubMenu",(()=>rn)),p(module.exports,"ElementEventType",(()=>Qn)),p(module.exports,"KeyEvent",(()=>In)),p(module.exports,"gatherVaryingStepAspects",(()=>Ai));var F="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==f?f:{},x={};y(x,"CanvasCommand",(()=>Yt)),y(x,"UpdateWorkflowStateCommand",(()=>vt)),y(x,"MoveCommand",(()=>Nt)),y(x,"RotateCommand",(()=>St)),y(x,"ResizeCommand",(()=>Pt)),y(x,"GroupCommand",(()=>Rt)),y(x,"CreateLayoutCommand",(()=>Ht)),y(x,"ClearLayoutCommand",(()=>Ut)),y(x,"CreateElementCommand",(()=>bt)),y(x,"DeleteElementCommand",(()=>Gt)),y(x,"CloneElementCommand",(()=>kt)),y(x,"FontColorCommand",(()=>Jt)),y(x,"FontSizeCommand",(()=>Ot)),y(x,"FontAlgorithmCommand",(()=>zt)),y(x,"FontSourceCommand",(()=>jt)),y(x,"FontAlignmentCommand",(()=>Lt)),y(x,"UpdateFramePattern",(()=>Tt)),y(x,"TextChangeCommand",(()=>Kt)),y(x,"IllustrationColorCommand",(()=>Vt)),y(x,"IllustrationCacheCommand",(()=>Xt)),y(x,"BringForwardCommand",(()=>Wt)),y(x,"SendBackwardsCommand",(()=>Zt)),y(x,"LayerCommand",(()=>qt)),y({},"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={};y(v,"ElementNotFoundError",(()=>ft)),y(v,"findElement",(()=>Mt)),y(v,"findLayoutForElement",(()=>yt)),y(v,"updatedLayoutForElement",(()=>Ft)),y(v,"rehydrateSerializedLayout",(()=>xt));var N={};y(N,"CommandContext",(()=>It)),y(N,"elementFactory",(()=>Dt)),y(N,"getSvgString",(()=>mt)),y(N,"sortElementsByLayersWithIndex",(()=>pt)),y({},"SVGLayout",(()=>q));var S={};let P;var R;let H;var U;let b;var G;let k;var J;let O;var z;let j;var L;let T;var K;let V;var X;let W;var Z;y(S,"LayoutElementType",(()=>P)),y(S,"LayoutRenderingPurpose",(()=>H)),y(S,"TextAlgorithm",(()=>b)),y(S,"UnitOfMeasurement",(()=>k)),y(S,"ScaleAxis",(()=>O)),y(S,"MaterialEffectMode",(()=>j)),y(S,"AssetType",(()=>T)),y(S,"StepType",(()=>V)),y(S,"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",(z=O||(O={}))[z.North=0]="North",z[z.Northeast=1]="Northeast",z[z.East=2]="East",z[z.Southeast=3]="Southeast",z[z.South=4]="South",z[z.Southwest=5]="Southwest",z[z.West=6]="West",z[z.Northwest=7]="Northwest",(L=j||(j={})).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,outlineAreaColor: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})))),m=e||"#aaaaaa";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":m,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"})]})]})};y({},"Image",(()=>EA));var $={};y($,"getAxisAlignedBoundingBox",(()=>_)),y($,"degreesToRadians",(()=>tA)),y($,"findAngle",(()=>AA)),y($,"radiansToDegrees",(()=>eA)),y($,"isCloseToValue",(()=>nA)),y($,"getTrueCoordinates",(()=>iA)),y($,"getPointOfRotation",(()=>aA)),y($,"getNWPoint",(()=>sA)),y($,"getNEPoint",(()=>rA)),y($,"getSWPoint",(()=>oA)),y($,"getSEPoint",(()=>cA)),y($,"turnRightClockwise",(()=>gA)),y($,"currentDirection",(()=>lA)),y($,"getElementVertices",(()=>BA)),y($,"rotateAroundPoint",(()=>wA)),y($,"mmPerPixel",(()=>dA)),y($,"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})})})};y({},"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,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"})}),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}})})]})};y({},"Textbox",(()=>gt));var uA={};y(uA,"fontSizeStep",(()=>qA)),y(uA,"textWidth",(()=>$A)),y(uA,"applyTextTransformations",(()=>At)),y(uA,"zip",(()=>tt)),y(uA,"getTextAlignment",(()=>et)),y(uA,"getAnchor",(()=>nt)),y(uA,"recomputeTextOnElement",(()=>it)),y(uA,"defaultLineHeightFactor",(()=>at)),y({},"calculateTextboxLines",(()=>ZA));var IA={};y(IA,"FontMetrics",(()=>jA)),y(IA,"loadFontFromExternalUrl",(()=>TA)),y(IA,"loadFontFromDataUrl",(()=>KA)),y(IA,"getFontMetrics",(()=>VA));var DA={};y(DA,"registerJSDOM",(()=>fA)),y(DA,"createElement",(()=>xA)),y(DA,"createElementNS",(()=>YA)),y(DA,"domParser",(()=>vA)),y(DA,"fetchAsArrayBuffer",(()=>NA)),y(DA,"fetchAsString",(()=>SA)),y(DA,"loadFontFaceSet",(()=>PA)),y(DA,"xmlSerializer",(()=>RA)),y(DA,"toBase64",(()=>HA)),y(DA,"dataUrlFromExternalUrl",(()=>UA)),y(DA,"arrayBufferToDataUrl",(()=>bA)),y(DA,"arrayBufferToBuffer",(()=>kA)),y(DA,"dataUrlToArrayBuffer",(()=>GA));var mA=i.Buffer;let pA;function fA(A){pA=A}function MA(){if(!pA)throw new Error("JSDOM is not registered. Please register it before calling this function.");return new pA}if(void 0===F.TextEncoder){const{TextEncoder:A}=o;F.TextEncoder=A}if(void 0===F.TextDecoder){const{TextDecoder:A}=o;F.TextDecoder=A}const yA=new(M(s).Agent)({rejectUnauthorized:!0}),FA=A=>A.every((A=>"undefined"!==A)),xA=A=>FA([typeof document])?document.createElement(A):MA().window.document.createElement(A),YA=(A,t)=>{if(FA([typeof document]))return document.createElementNS(A,t);const e=MA().window.document.createElement(t);return e.setAttribute("xmlns",A),e},vA=()=>FA([typeof DOMParser])?new DOMParser:new(MA().window.DOMParser),NA=A=>{if(FA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.arrayBuffer())})).catch((A=>{e(A)}))}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(a).get(t,{responseType:"arraybuffer",httpsAgent:yA}).then((t=>{A(t.data)})).catch((A=>{e(A)}))}))}},SA=A=>{if(FA([typeof fetch]))return new Promise(((t,e)=>{fetch(A).then((A=>{t(A.text())})).catch(e)}));{const t=A.replace("localhost","localstack");return new Promise(((A,e)=>{M(a).get(t,{responseType:"text",httpsAgent:yA}).then((t=>{A(t.data)})).catch(e)}))}},PA=async(A,t)=>{if(FA([typeof FontFace])){const e=A.names.fullName.en,n=new FontFace(e,`url(${t})`);return document.fonts.add(n),n.load()}},RA=()=>FA([typeof XMLSerializer])?new XMLSerializer:new(MA().window.XMLSerializer),HA=A=>FA([typeof btoa])?btoa(A):mA.from(A).toString("base64"),UA=async A=>{if(FA([typeof fetch,typeof Blob,typeof FileReader])){const t=await fetch(A),e=await t.blob();return await OA(e)}const t=(await M(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)})),zA=new Map;class jA{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=M(n).parse(t);return XA(e,{assetUrl:A,name:e.names.fullName.en}),e},VA=A=>{const t=zA.get(A.name);if(t)return t;throw new Error("Font metrics unavailable for font")},XA=(A,t)=>{const e=new jA(A);return zA.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={};y(st,"colorDefinitionPrintValue",(()=>rt)),y(st,"spotColorDefinitionString",(()=>ot)),y(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})};y({},"Illustration",(()=>ut));var wt={};y(wt,"traverse",(()=>ht)),y(wt,"sanitizeSvgTree",(()=>Et)),y(wt,"modifySVGWithElementProperties",(()=>Ct)),y(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 M(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(A){super("No element found with ID: "+A),Object.setPrototypeOf(this,ft.prototype)}}const Mt=(A,t)=>yt(A,t).elements.find((t=>t.id===A)),yt=(A,t)=>{const e=Object.values(t).find((t=>t.elements.some((t=>t.id===A))));if(!e)throw new ft(A);return e},Ft=(A,t)=>{const e=pt([...t.elements.filter((t=>t.id!==A.id)),A]);return{layout:t.layout,elements:e,modificationID:Y()}},xt=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 SA(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 Nt extends Yt{constructor(A,t,e){super(),this.id=A,this.x=t,this.y=e}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,x:this.x,y:this.y},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class St extends Yt{constructor(A,t){super(),this.id=A,this.angle=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,rotation:this.angle},n=yt(t.id,Object.values(A.layouts)),i=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,width:this.width,height:this.height};if("frame"===t.type){const A=e;A.scaleX=A.scaleX*this.width/t.width,A.scaleY=A.scaleY*this.height/t.height}const n=yt(t.id,Object.values(A.layouts)),i=Ft(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=M(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fill:this.color,fillSpotColorDefinition:this.textFillSpotColor},n=yt(t.id,Object.values(A.layouts)),i=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fontSize:this.size},n=yt(t.id,Object.values(A.layouts)),i=e.algorithm&&e.algorithm!==b.Autosize?e.input||"":e.text||"",a=Ft(it(e,i),n);return{...A,layouts:{...A.layouts,[n.layout.id]:a}}}}class zt extends Yt{constructor(A,t){super(),this.id=A,this.algorithm=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,algorithm:this.algorithm},n=yt(t.id,Object.values(A.layouts)),i=Ft(e,n);return{...A,layouts:{...A.layouts,[n.layout.id]:i}}}}class jt extends Yt{constructor(A,t){super(),this.id=A,this.fontData=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,fontData:this.fontData},n=yt(t.id,Object.values(A.layouts)),i=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,align:this.align},n=yt(t.id,Object.values(A.layouts)),i=Ft(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=yt(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=yt(t.id,Object.values(A.layouts)),n=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=t.colors||{},n=e[this.className];e[this.className]={browserValue:this.fill,spotColor:n?.spotColor};const i={...t,colors:e},a=yt(t.id,Object.values(A.layouts)),s=Ft(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=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e={...t,svg:this.svgBody,cachedObjectURL:this.objectURL},n=yt(t.id,Object.values(A.layouts)),i=Ft(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,!Mt(this.id,Object.values(A.layouts)).id)throw new ft(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e+1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:Y()}}}}}class Zt extends Yt{constructor(A){super(),this.id=A}apply(A){if(this.oldState=A,!Mt(this.id,Object.values(A.layouts)).id)throw new ft(this.id);const t=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!t)throw new Error("Layout missing from state!");const e=t.elements.findIndex((A=>A.id===this.id)),n=e-1,i=[...t.elements],a=i.splice(e,1)[0];return i.splice(n,0,a),i.forEach(((A,t)=>A.layerIndex=t)),{...A,layouts:{...A.layouts,[t.layout.id]:{...A.layouts[t.layout.id],elements:i,modificationID:Y()}}}}}class qt extends Yt{constructor(A,t){super(),this.id=A,this.value=t}apply(A){this.oldState=A;const t=Mt(this.id,Object.values(A.layouts));if(!t.id)throw new ft(this.id);const e=Object.values(A.layouts).find((A=>A.elements.find((A=>A.id===this.id))));if(!e)throw new Error("Layout missing from state!");return{...A,layouts:{...A.layouts,[e.layout.id]:Ft({...t,layer:this.value},e)}}}}var $t={};y($t,"patternImageDataCache",(()=>ae)),y($t,"frameDataCache",(()=>se)),y($t,"generateFrameSVG",(()=>re)),y($t,"generateDefaultRectangleFrameSvg",(()=>oe)),y($t,"getVariant",(()=>ce)),y($t,"getFrameData",(()=>ge)),y($t,"calculateOffsets",(()=>le)),y($t,"getPatternImageData",(()=>Be)),y($t,"GetSVGDimensions",(()=>we)),y($t,"svgStringDimensions",(()=>de));var _t={};y(_t,"getExifOrientation",(()=>te)),y(_t,"canvasDims",(()=>ee)),y(_t,"getAttributesFromArrayBuffer",(()=>ne));let Ae=null;const te=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)))}))})),ee=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]},ne=async A=>{const t=await(async A=>{const t=await bA(A),e=await(0,g.loadImage)(t),[n,i]=ee(e),a=await(async()=>{if(null!==Ae)return!Ae;const A=await(0,g.loadImage)("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return Ae=2===A.width&&3===A.height,!Ae})();if(!a){const A=(0,g.createCanvas)(n,i);return A.getContext("2d").drawImage(e,0,0,n,i),A}const s=await te(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}};y({},"getDefaultVariant",(()=>ie));const ie=A=>{const t=A.variants;return 1===t.length?t[0]:void 0!==A.defaultVariant?t.find((t=>t.id===A.defaultVariant)):void 0},ae=new Map,se=new Map,re=async(A,t)=>{if(!t){if(!A)throw new Error("No region or src supplied. Cannot construct frame!");return oe(A)}return SA(t)},oe=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 `},ce=(A,t)=>{if(!t)return;const e=t.data.variants.find((t=>t.id===A.frameVariantId))||ie(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},ge=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 se.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 se.set(A,t),t}throw new Error("Malformed frame SVG")},le=(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}},Be=async A=>{if(ae.has(A))return ae.get(A);if(A.endsWith("svg")){const t=await we(A),e=t.width,n=t.height,i={src:A,width:e,height:n,aspect:e/n};return ae.set(A,i),i}{const t=await NA(A),e=await ne(t),n={src:A,width:e.width,height:e.height,aspect:e.width/e.height};return ae.set(A,n),n}},we=async A=>{const t=await fetch(A),e=await t.text();return de(e)},de=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 he={};y(he,"determineCorrectFontSizeAndLines",(()=>Ce)),y(he,"determineCorrectTextboxRegion",(()=>Qe));const Ee=(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]},Ce=(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]=Ee(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]=Ee(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]=Ee(e,n,c,g,r),[c,a,s]},Qe=(A,t,e,n,i)=>{let a={...A},s={...A},[r,o,c]=Ce(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]=Ce(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 ue={};y(ue,"svgObjectURL",(()=>me)),y(ue,"LayoutElementFactory",(()=>fe));const Ie=(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},De=async A=>new Promise((t=>{fetch(A).then((A=>{t(A.text())})).catch((A=>console.error(A)))})),me=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)},pe=async(A,t,e)=>{const n=A.layoutState.layout.useEditableArea&&A.layoutState.layout.editableArea||{width:A.layoutState.layout.width,height:A.layoutState.layout.height,x:0,y:0},i=(n.width<n.height?n.width:n.height)/2,a={top:n.y+n.height/2-i/2,left:n.x+n.width/2-i/2,width:i,height:i,rotation:0,panelId:A.layoutState.layout.panelId};if(e&&t===P.Illustration){const A=await Qt(await De(e)),t=(new DOMParser).parseFromString(A.svg,"image/svg+xml").firstElementChild.getAttribute("viewBox");if(!t)throw new Error("SVG missing viewBox.");const n=a.height,i=t.split(" "),s=(parseFloat(i[2])||1)/(parseFloat(i[3])||1);a.height=a.width/s,a.top+=(n-a.height)/2}if(e&&t===P.Image){const A=a.height,t=await fetch(e),n=await t.arrayBuffer(),i=await ne(n),s=i.width/i.height;a.height=a.width/s,a.top+=(A-a.height)/2}return a};class fe{static async getFrame(A,t){const e=await re(t.region,t.src),n=await ge(e),i=t.region||await pe(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||Ie(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 pe(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||Ie(A,e.layer||0),immutable:e.immutable,preserveAspectRatio:"none"}}static async getTextbox(A,t){const{configuration:e,fontSrc:n,designInputStep:i}=t,a=t.region||await pe(A,P.Textbox),s={assetUrl:n,name:(await TA(n)).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=it({id:Y(),type:P.Textbox,x:a.left,y:a.top,width:a.width,height:a.height,align:et(e.textAlign,e.vertical),curved:e.curved,fill:i?.color||e.colour||"#000000",fontData:s,layer:a.layer||0,layerIndex:a.layerIndex||Ie(A,a.layer||0),paths:e.paths,rotation:a.rotation,vertical:e.vertical,verticalAlign:e.verticalAlign||"middle",algorithm:b.Traditional,fontSize:e.size||Math.max(Math.round(.025*a.height),1),text:c,input:r},c),l=Qe({...a,height:g.height},s,g.fontSize,g?.text?.split("\n")||[],g.align);return{...g,x:l.left,y:l.top+(a.height-l.height)/2,width:l.width,height:l.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 pe(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||Ie(A,i.layer||0),immutable:i.immutable}}static async getIllustration(A,t){const e=t.region||await pe(A,P.Illustration,t.src),n=await Qt(await De(t.src)),i=await me(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||Ie(A,e.layer||0),immutable:e.immutable}}}function Me(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 ye extends Error{constructor(A){super(A),this.name=this.constructor.name}}class Fe extends ye{constructor(A){super(`ConfigurationError - ${A}`)}}class xe extends Fe{constructor(A){super(`Option not Configured: ${A.stepTitle}`),Me(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class Ye extends Fe{constructor(A){super(`Panel not Found: ${A.panelId}`),Me(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class ve extends Fe{constructor(A){super(`Asset not found for variant: ${A.name}`),Me(this,"variant",void 0),this.variant=A}}class Ne extends Fe{constructor(A){super(`Resource not found for asset: ${A.name}`),Me(this,"asset",void 0),this.asset=A}}class Se extends Fe{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),Me(this,"step",void 0),this.step=A}}class Pe extends ye{constructor(A){super(`ImplementationError - ${A}`)}}class Re extends Pe{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class He extends Pe{constructor(A){super(`Parsing Error: ${A}`)}}class Ue extends Pe{constructor(A){super(`Client Error: ${A}`)}}class be extends Pe{constructor(A){super(`Resource Generation Failed: ${A}`)}}function Ge(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 ke{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(){Ge(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 Oe=(()=>{try{return localStorage?new ke:new Je}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Je}})();function ze(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 je=new class{constructor(){ze(this,"defaultServerUrl","https://api.spiff.com.au"),ze(this,"defaultServicesApiUrl","https://services.spiff.com.au"),ze(this,"defaultHubUrl","https://hub.spiff.com.au"),ze(this,"serverUrl",void 0),ze(this,"servicesApiUrl",void 0),ze(this,"hubUrl",void 0),ze(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 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}let Te;const Ke=A=>{Te=A},Ve=async()=>{const A={transactionOwnerId:Te};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=je.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 Xe=new class{constructor(){Le(this,"client",void 0),Le(this,"uncachedOperations",[]),je.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 Ve();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 Ve(),t=je.getServerUrl()+"/v2/api-docs";return await M(w)(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const We=new class{constructor(){Le(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),je.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=(0,d.createHttpLink)({uri:`${je.getServerUrl()}/graphql`,fetch:C.fetch}),t=(0,h.setContext)((async(A,{headers:t})=>{const e=t||{},n=await Ve();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 Ze(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 qe="persistentAssets";class $e{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=Oe.getMap(qe);n&&n.forEach(((A,t)=>{e.set(t,A)})),Oe.setMap(qe,e)}static remove(A){const t=Oe.getMap(qe);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),Oe.setMap(qe,t))}static list(){const A=Oe.getMap(qe);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const _e=new class{constructor(){Ze(this,"server",void 0),Ze(this,"cache",new Map),Ze(this,"materialCache",new Map),Ze(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await ne(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)}})),Ze(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await _e.getLocalOrFromServer(A.assetKey))),Ze(this,"getMaterialFromVariant",(async A=>A.material?A.material:await _e.getMaterialLocalOrFromServer(A.materialId))),this.server=Xe}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new Re("Failed to get asset from cache!");return t}const t=(async()=>(await Xe.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 Xe.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;$e.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 _e.uploadAssetWithProgress(e,n,t,!0)}}removePersistedAsset(A){$e.remove(A)}getPersistedAssets(){return $e.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 Re("Unexpected mimetype: "+t)}}};function An(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 tn=new class{constructor(){An(this,"cache",new Map),An(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),An(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),An(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),An(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 tn.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 _e.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 _e.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}},en=(0,Q.createContext)(new It),nn=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}},an=()=>{const A=(0,Q.useContext)(en),[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 sn(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 rn;var on;(on=rn||(rn={})).None="None",on.FrameAdjustment="FrameAdjustment",on.FinalizeDesign="FinalizeDesign",on.SavedDesigns="SavedDesigns",on.ThreeDPreview="ThreeDPreview",on.Panels="Panels";const cn=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,xTranslation:0,yTranslation:0,maxZoom:5,units:k.Pixel,subMenu:rn.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),gn=(A,t)=>M(u)(A,t.apply(A))?A:t.apply(A),ln=(0,Q.createContext)({}),Bn=A=>{const{getAllLayouts:e}=an(),[n,i]=(0,Q.useReducer)(gn,cn(e,A.defaultZoom||1)),a=(0,Q.useMemo)((()=>({state:n,uiDispatcher:i})),[n,i]);return(0,t.jsx)(ln.Provider,{value:a,children:A.children})};class wn{constructor(A){sn(this,"changes",void 0),this.changes=A}apply(A){return{...A,...this.changes}}}const dn=()=>(0,Q.useContext)(ln);let hn;var En;(En=hn||(hn={}))[En.Orbit=0]="Orbit",En[En.Pan=1]="Pan";const Cn=(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,1.7*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 Qn;var un;let In;var Dn;(un=Qn||(Qn={})).Translate="Translate",un.Rotate="Rotate",un.Resize="Resize",(Dn=In||(In={})).ControlLeft="ControlLeft",Dn.ControlRight="ControlRight",Dn.Equal="Equal",Dn.MetaLeft="MetaLeft",Dn.MetaRight="MetaRight",Dn.Minus="Minus",Dn.ArrowLeft="ArrowLeft",Dn.ArrowRight="ArrowRight",Dn.ArrowUp="ArrowUp",Dn.ArrowDown="ArrowDown",Dn.AltLeft="AltLeft",Dn.AltRight="AltRight",Dn.Delete="Delete",Dn.Backspace="Backspace";const mn=(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 Re("Unknown unit of measurement")}};let a=t.x,s=t.y,r=t.x,o=t.y;switch(A){case In.ArrowLeft:r=t.x-1/i();break;case In.ArrowUp:o=t.y-1/i();break;case In.ArrowRight:r=t.x+1/i();break;case In.ArrowDown:o=t.y+1/i();break;default:throw new Re("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 Nt(t.id,a,s)};let pn=0,fn=0;var Mn=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},Fn=(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},xn=(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}),Yn=(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 Qn.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=e.height-n,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=xn({x:A.destX,y:A.destY},A.targetRect,Q);if(wA({x:u.x,y:u.y},s,-l).y>E+a)return{...t,height:1}}break;case O.East:{const n=c*w+g*B,i=e.width+n;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=xn({x:A.destX,y:A.destY},A.targetRect,Q);if(wA({x:u.x,y:u.y},s,-l).x<d)return{...t,width:1}}break;case O.West:{const n=c*w+g*B,i=e.x+n,a=e.width-n;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=xn({x:A.destX,y:A.destY},A.targetRect,u);if(wA({x:I.x,y:I.y},r,-l).x>E+a)return{...t,width:1}}break;case O.South:{const n=-c*B+g*w,i=e.height+n,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=xn({x:A.destX,y:A.destY},A.targetRect,C);if(wA({x:Q.x,y:Q.y},a,-l).y<d)return{...t,height:1}}break;case O.Northeast:{const n=c*w+g*B,i=e.width+n;let a=e.height+n/d,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=xn({x:A.destX,y:A.destY},A.targetRect,D),p=wA({x:m.x,y:m.y},o,-l);if(p.x<Q||p.y>u+a)return{...t,height:1,width:1}}break;case O.Northwest:{const n=-c*w+-g*B,i=e.x-n,a=e.width+n;let s=e.y-n/d,r=e.height+n/d,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=xn({x:A.destX,y:A.destY},A.targetRect,m),f=wA({x:p.x,y:p.y},E,-l);if(f.x>u+a||f.y>I+r)return{...t,height:1,width:1}}break;case O.Southeast:{const n=c*w+g*B,i=e.width+n;let a=e.height+n/d,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=xn({x:A.destX,y:A.destY},A.targetRect,I),m=wA({x:D.x,y:D.y},r,-l);if(m.x<C||m.y<Q)return{...t,height:1,width:1}}break;case O.Southwest:{const n=-c*w+-g*B,i=e.width+n;let a=e.x-n,s=e.height+n/d,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=xn({x:A.destX,y:A.destY},A.targetRect,D),p=wA({x:m.x,y:m.y},o,-l);if(p.x>Q+i||p.y<u)return{...t,height:1,width:1}}}return yn(h.left,h.top,h.width,h.height,h.rotation,s)&&Fn(h.left,h.top,h.width,h.height,h.rotation,s)&&(t=h),t;case Qn.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)Mn=0,C=(e.rotation+I-D)%360;else{Mn+=Math.sqrt(c**2+g**2);const A=Math.abs(Mn)>8*window.devicePixelRatio/r;C=A?(e.rotation+I-D)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Mn=0)}return yn(e.x,e.y,e.width,e.height,C,s)&&Fn(e.x,e.y,e.width,e.height,C,s)&&(Q=C),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:Q};case Qn.Translate:let m,p,f=e.x,M=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}};pn+=c,fn+=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,l=void 0!==i&&Math.abs(e.x+pn-i)<=8/r,B=void 0!==s&&Math.abs(e.y+fn-s)<=8/o;A&&l?m=e.x:(m=e.x+pn,pn=0),t&&B?p=e.y:(p=e.y+fn,fn=0)}return yn(m,p,e.width,e.height,e.rotation,s)&&(M=p),Fn(m,p,e.width,e.height,e.rotation,s)&&(f=m),{top:M,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 Nt(e.id,r.left,r.top),new Pt(e.id,r.width,r.height),new St(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},vn=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"})]})]})},Nn="#ffffff",Sn=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:Nn,style:{cursor:s,pointerEvents:"none"},stroke:g,strokeWidth:l})]}):(0,t.jsx)("circle",{className:o,cx:i,cy:a,r:c,fill:Nn,style:{cursor:s},stroke:g,strokeWidth:l,onPointerDown:r})},Pn=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:Nn,style:{cursor:g,pointerEvents:"none"},stroke:w,strokeWidth:d})]}):(0,t.jsx)("rect",{x:s,y:r,width:o,height:c,rx:B,fill:Nn,style:{cursor:g},stroke:w,strokeWidth:d,onPointerDown:l})},Rn=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]),M=(0,Q.useCallback)((A=>D(A,lA(O.South,360-r),O.South)),[D,r]),y=(0,Q.useCallback)((A=>D(A,O.Northwest,O.Northwest)),[D]),F=(0,Q.useCallback)((A=>D(A,O.Northeast,O.Northeast)),[D]),x=(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)(Sn,{isMobile:e,outerRadius:h,x:0,y:0,cursorStyle:"nw-resize",onPointerDown:y,handleClass:"cornerNorthWest",cornerRadius:l,color:n,strokeWidth:I}),v?(0,t.jsx)(Sn,{isMobile:e,outerRadius:h,x:a,y:0,cursorStyle:"ne-resize",onPointerDown:F,handleClass:"cornerNorthEast",cornerRadius:l,color:n,strokeWidth:I}):void 0,v?(0,t.jsx)(Sn,{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)(Sn,{isMobile:e,outerRadius:h,x:0,y:i,cursorStyle:"sw-resize",onPointerDown:x,handleClass:"cornerSouthWest",cornerRadius:l,color:n,strokeWidth:I}):void 0,v&&!c?(0,t.jsx)(Pn,{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)(Pn,{isMobile:e,outerRadius:E,outerWidth:C,outerHeight:u,x:a/2-w/2,y:i-d/2,width:w,height:d,onPointerDown:M,edgeHandleRadius:B,cursorStyle:"s-resize",color:n,strokeWidth:I}):void 0,c?void 0:(0,t.jsx)(Pn,{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)(Pn,{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]})},Hn=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"})]})]})},Un="spiffElementID",bn=({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}=nn(),m=(0,Q.useCallback)((A=>{u(A),A[Un]=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]),M=(0,Q.useCallback)((A=>{I(A),o(i)}),[i,D,o]),y=a?void 0:w?g?"grabbing":"grab":"pointer",F=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:F,fill:"none",strokeWidth:C,style:{cursor:y},onPointerDown:a?void 0:m,onPointerUp:a?void 0:p,onPointerEnter:a?void 0:f,onPointerLeave:a?void 0:M})})},Gn=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)(Hn,{isMobile:e&&!!r,color:n,elementWidth:g,onBeginRotate:s,scaleFactor:c}),e&&r&&(0,t.jsx)(vn,{onPointerDown:r,elementWidth:g,scaleFactor:c}),(0,t.jsx)(Rn,{isMobile:e,color:n,elementHeight:i,elementWidth:g,rotation:o,scaleFactor:c,onBeginResize:a,disableX:w,disableY:d})]})},kn=.5,Jn=["TEXTAREA","INPUT"],On=(A,t,e,n,i,a,s,r)=>{const{state:o,uiDispatcher:c}=(0,Q.useContext)(ln),{getLayoutById:g,getReducerState:l,flattenSequence:B}=an(),[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 wn({zoom:kn}));if(n>o.maxZoom)return void c(new wn({zoom:o.maxZoom}));c(new wn({zoom:n}))}}),[n,c,A,i,o.maxZoom]);const p=(0,Q.useCallback)(((A,n)=>{c(new wn({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 wn({scrolledMovement:!1}))}),[c,o.zoom]);const f=t?.current?.getBoundingClientRect(),M=((f?.width||1)+(f?.height||1))/2,y=(m.layoutState.layout.width+m.layoutState.layout.height)/2/M/o.zoom,F=(0,Q.useMemo)((()=>{const A=o.activeModifierKeys,t=o.elementEvent,e=A.includes(In.ControlLeft)||A.includes(In.MetaLeft)||A.includes(In.ControlRight)||A.includes(In.MetaRight);if(!o.selectedElement||!t||e)return[];const n=t&&t.type===Qn.Translate,i=t&&t.type===Qn.Rotate,a=m.layoutState.elements.find((A=>A.id===o.selectedElement));return(n||i)&&a?Cn(a,m.layoutState,y,s):[]}),[o.selectedElement,o.elementEvent,o.activeModifierKeys,m.layoutState,y]),x=(0,Q.useCallback)((()=>{const A=Y();d(A),E(l().transaction)}),[l]),v=(0,Q.useCallback)((A=>{D(A.target),A[Un]||(D(null),c(new wn({selectedElement:void 0})))}),[o,c]),N=(0,Q.useCallback)((()=>{c(new wn({scrolledMovement:!0}))}),[c]),S=(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(Yn({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,F,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,F,a,C]),P=(0,Q.useCallback)((A=>{c(new wn({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(In.AltLeft)||r.includes(In.AltRight))&&(A.code===In.Equal||A.code===In.Minus)){const t=.05*n;A.code===In.Equal?c(new wn({zoom:e+t<=n?e+=t:e})):c(new wn({zoom:e-t>=kn?e-t:e}))}const g=m.layoutState.elements.find((A=>A.id===s));if(s&&g){if(A.code===In.MetaLeft||A.code===In.ControlLeft||A.code===In.MetaRight||A.code===In.ControlRight){const t=A.code,e=o.activeModifierKeys;if(!e.includes(t))return c(new wn({activeModifierKeys:e.concat(t)}))}if(A.code===In.ArrowDown||A.code===In.ArrowUp||A.code===In.ArrowLeft||A.code===In.ArrowRight){c(new wn({elementEvent:{type:Qn.Translate}}));const e=mn(A.code,g,o.units,t);a(e,!1),c(new wn({elementEvent:void 0}))}A.code!==In.Delete&&A.code!==In.Backspace||"advanced"!==i||(c(new wn({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===In.MetaLeft||A.code===In.ControlLeft||A.code===In.MetaRight||A.code===In.ControlRight){const t=o.activeModifierKeys,e=A.code;c(new wn({activeModifierKeys:t.filter((A=>A!==e))}))}}),[c,o.activeModifierKeys]);return{guidelines:F,scale:y,zoomableElementRef:e,setElementEvent:P,handleZoom:p,handleKeyDown:H,handleKeyUp:U,handlePointerPressedBackground:v,handlePointerReleased:R,handlePointerMove:S,handleScroll:N,handleSequenceStart:x}},zn=(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!(Jn.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])},jn=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}=dn(),{getLayoutById:I}=an(),D=I(u.layoutId),[m,p]=(0,Q.useState)(void 0),f=(0,Q.useCallback)((A=>{p(A)}),[]),M=(0,Q.useCallback)((A=>{m===A&&p(void 0)}),[m]),y=(0,Q.useCallback)((()=>{h(),w({type:Qn.Translate})}),[w]),F=(0,Q.useCallback)(((A,t)=>{h(),w({type:Qn.Resize,relativeAxis:A,screenAxis:t})}),[w]),x=(0,Q.useCallback)((()=>{h(),w({type:Qn.Rotate})}),[w]),Y=i||{x:0,y:0,width:c,height:o},v=D.layoutState.elements,N=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)(bn,{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:y,onPointerEnter:f,onPointerLeave:M,scaleFactor:l},A.id)})),N&&(0,t.jsx)(Gn,{isMobile:e,color:n,x:N.x,y:N.y,disableX:N.type===P.Frame||N.type===P.Image,disableY:N.type===P.Textbox||N.type===P.Frame||N.type===P.Image,width:N.width,height:N.height,rotation:N.rotation,onBeginResize:F,onBeginRotate:x,scaleFactor:l,onContextMenuHandlePointerDown:C})]})},Ln=A=>{const{isMobile:e,color:n,outlineColor:i,editorRef:a,zoomableElementRef:s,interactionElementRef:r,guidelines:o,isMakingAdjustments:c,outlineArea:g,visibleLayoutId:l,xTranslation:B,yTranslation:w,targetedElements:d,borderRadius:h,canvasFilter:E,handleContextMenu:C,onMouseMove:u,onContextMenuHandlePointerDown:I,handleKeyDown:D,handleKeyUp:m,handlePointerMove:p,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:y,onSequenceStart:F,setElementEvent:x,onElementSelected:Y}=A,{getLayoutById:v}=an(),N=v(l),S=N.layoutState,{state:P}=dn(),R=(0,Q.useCallback)((A=>{if(g){const t={left:g.x||0,top:g.y||0,width:g.width||1,height:g.height||1,panelId:"",rotation:0};return D(A,t)}return D(A)}),[D,g]),U=(0,Q.useCallback)((A=>{if(g){const t={left:g.x||0,top:g.y||0,width:g.width||1,height:g.height||1,panelId:"",rotation:0};return p(A,t)}return p(A)}),[p,g]),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(${B}px, ${w}px)`,display:"flex",justifyContent:"center",alignItems:"center",filter:E||"drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2))",overflow:"visible"})),[P.zoom,P.xTranslation,P.yTranslation]),k=10/P.zoom,J=S.layout.width,O=S.layout.height,z=s.current?.offsetHeight||1024,j=s.current?.offsetWidth||1024,L=k*(Math.sqrt(J*O)/1e3)*(100/Math.sqrt(z*j))*Math.sqrt((T=j/z,Math.exp(Math.abs(Math.log(T)))));var T;const K=(0,Q.useMemo)((()=>({configuration:{purpose:H.FreeDesign},height:c?"100%":"auto",width:c?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",outlineArea:g?{...g,scale:L}:void 0,borderRadius:h,outlineColor:i})),[c,L]);return(0,t.jsx)("div",{style:b,onContextMenu:C,onKeyDown:R,onKeyUp:m,onPointerDown:f,onMouseLeave:M,onPointerMoveCapture:U,onPointerUp:M,onWheelCapture:y,ref:r,tabIndex:-1,children:(0,t.jsxs)("div",{ref:s,style:G,children:[A.children,N.getComponentWithProps(K),(0,t.jsx)(jn,{isMobile:e,primaryColor:n,editorRef:a,elementEvent:P.elementEvent,guidelines:o,layoutHeight:S.layout.height,layoutWidth:S.layout.width,onElementEvent:x,onSequenceStart:F,onElementSelected:Y,scale:L,selectedElement:P.selectedElement,targetedElements:d,onMouseMove:u,onContextMenuHandlePointerDown:I})]})})},Tn=({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}=an(),{state:h,uiDispatcher:E}=dn(),C=(0,Q.useRef)(null),u=(0,Q.useRef)(null),I=(0,Q.useRef)(null),{guidelines:D,handleKeyDown:m,handleKeyUp:p,handlePointerMove:f,handlePointerPressedBackground:M,handlePointerReleased:y,handleScroll:F,handleSequenceStart:x,setElementEvent:Y}=On(C,u,I,void 0,"advanced",w,a,B),v=(0,Q.useMemo)((()=>d(h.layoutId)),[d,h.layoutId]),N=(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 zt(A,b.Traditional),!0)}l&&l(A,t),E(new wn({selectedElement:A}))}),[w,d,h.layoutId,E]),S=(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)(Ln,{outlineArea:S,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:M,handlePointerReleased:y,handleScroll:F,onSequenceStart:x,setElementEvent:Y,onElementSelected:N})},Kn=d.gql`
2
2
  mutation CreateTransaction($integrationProductId: String!, $bulk: Boolean) {
3
3
  transactionCreate(integrationProductId: $integrationProductId, bulk: $bulk) {
4
4
  id
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import{CommandContext as A,AssetType as t,BringForwardCommand as e,CanvasCommand as n,CreateElementCommand as i,CreateLayoutCommand as a,DeleteElementCommand as s,FontAlignmentCommand as r,FontColorCommand as o,FontSizeCommand as c,FontSourceCommand as g,GroupCommand as B,LayoutElementFactory as w,LayoutElementType as l,MoveCommand as E,ResizeCommand as d,RotateCommand as Q,SendBackwardsCommand as C,StepAspectType as h,StepType as I,TextChangeCommand as D,UnitOfMeasurement as u,dataUrlFromExternalUrl as p,findElement as m,frameDataCache as f,generate as M,getAxisAlignedBoundingBox as F,generateSVGWithUnknownColors as Y,getAttributesFromArrayBuffer as y,rehydrateSerializedLayout as N,getFrameData as v,getSvgString as x,loadFontFromDataUrl as S,loadFontFromExternalUrl as P,determineCorrectFontSizeAndLines as R,patternImageDataCache as U,registerJSDOM as H,TextAlgorithm as G,FontAlgorithmCommand as J,isCloseToValue as b,mmPerPixel as k,cmPerPixel as O,ScaleAxis as z,getElementVertices as L,rotateAroundPoint as T,calculateTextboxLines as j,defaultLineHeightFactor as K,findAngle as V,currentDirection as X,LayoutRenderingPurpose as W,svgObjectURL as Z,UpdateWorkflowStateCommand as q,calculateOffsets as $,UpdateFramePattern as _,generateDefaultRectangleFrameSvg as AA,fetchAsString as tA,GetSVGDimensions as eA,modifySVGWithElementProperties as nA,IllustrationColorCommand as iA,IllustrationCacheCommand as aA,getFontMetrics as sA,applyTextTransformations as rA,createElementNS as oA,createElement as cA,sortElementsByLayersWithIndex as gA,toBase64 as BA,getPatternImageData as wA,getVariant as lA,generateFrameSVG as EA,getDefaultVariant as dA,domParser as QA,sanitizeSvgTree as CA,traverse as hA,xmlSerializer as IA,fetchAsArrayBuffer as DA,arrayBufferToDataUrl as uA,loadFontFaceSet as pA,MaterialEffectMode as mA}from"@spiffcommerce/papyrus";import fA from"swagger-client";import{createHttpLink as MA,InMemoryCache as FA,ApolloClient as YA,from as yA,gql as NA}from"@apollo/client";import{setContext as vA}from"@apollo/client/link/context";import{onError as xA}from"@apollo/client/link/error";import{fetch as SA}from"cross-fetch";import{createContext as PA,useState as RA,useCallback as UA,useContext as HA,useEffect as GA,useReducer as JA,useMemo as bA,useRef as kA}from"react";import{jsx as OA,jsxs as zA,Fragment as LA}from"react/jsx-runtime";import TA from"lodash.isequal";import{Canvg as jA}from"canvg";import KA from"lodash.clonedeep";import VA from"lodash.debounce";import{toString as XA}from"qrcode";import WA from"svg-path-bbox";function ZA(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 qA extends Error{constructor(A){super(A),this.name=this.constructor.name}}class $A extends qA{constructor(A){super(`ConfigurationError - ${A}`)}}class _A extends $A{constructor(A){super(`Option not Configured: ${A.stepTitle}`),ZA(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class At extends $A{constructor(A){super(`Panel not Found: ${A.panelId}`),ZA(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class tt extends $A{constructor(A){super(`Asset not found for variant: ${A.name}`),ZA(this,"variant",void 0),this.variant=A}}class et extends $A{constructor(A){super(`Resource not found for asset: ${A.name}`),ZA(this,"asset",void 0),this.asset=A}}class nt extends $A{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),ZA(this,"step",void 0),this.step=A}}class it extends qA{constructor(A){super(`ImplementationError - ${A}`)}}class at extends it{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class st extends it{constructor(A){super(`Parsing Error: ${A}`)}}class rt extends it{constructor(A){super(`Client Error: ${A}`)}}class ot extends it{constructor(A){super(`Resource Generation Failed: ${A}`)}}function ct(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 gt{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 Bt{constructor(){ct(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 wt=(()=>{try{return localStorage?new gt:new Bt}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Bt}})();function lt(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 Et=new class{constructor(){lt(this,"defaultServerUrl","https://api.spiff.com.au"),lt(this,"defaultServicesApiUrl","https://services.spiff.com.au"),lt(this,"defaultHubUrl","https://hub.spiff.com.au"),lt(this,"serverUrl",void 0),lt(this,"servicesApiUrl",void 0),lt(this,"hubUrl",void 0),lt(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 dt(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 Qt;const Ct=A=>{Qt=A},ht=async()=>{const A={transactionOwnerId:Qt};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=Et.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 It=new class{constructor(){dt(this,"client",void 0),dt(this,"uncachedOperations",[]),Et.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 ht();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 ht(),t=Et.getServerUrl()+"/v2/api-docs";return await fA(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const Dt=new class{constructor(){dt(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),Et.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=MA({uri:`${Et.getServerUrl()}/graphql`,fetch:SA}),t=vA((async(A,{headers:t})=>{const e=t||{},n=await ht();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=xA((({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 FA({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 YA({link:yA([e,t,A]),cache:n,name:"Core"})}};function ut(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 pt="persistentAssets";class mt{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=wt.getMap(pt);n&&n.forEach(((A,t)=>{e.set(t,A)})),wt.setMap(pt,e)}static remove(A){const t=wt.getMap(pt);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),wt.setMap(pt,t))}static list(){const A=wt.getMap(pt);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const ft=new class{constructor(){ut(this,"server",void 0),ut(this,"cache",new Map),ut(this,"materialCache",new Map),ut(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await y(t);return{name:A.name.substring(A.name.lastIndexOf("/")+1),blob:((A,t)=>{let e=atob(A.split(",")[1]),n=[];for(let A=0;A<e.length;A++)n.push(e.charCodeAt(A));return new Blob([new Uint8Array(n)],{type:t})})(e.dataUrl,A.type)}})),ut(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await ft.getLocalOrFromServer(A.assetKey))),ut(this,"getMaterialFromVariant",(async A=>A.material?A.material:await ft.getMaterialLocalOrFromServer(A.materialId))),this.server=It}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new at("Failed to get asset from cache!");return t}const t=(async()=>(await It.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 It.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;mt.add(a.assetResponse.asset),t(A)},i.onerror=n,i.send(A.blob)})),a.assetResponse.asset}async uploadFile(A,e){const n=!("image/svg+xml"===A.type||"application/pdf"===A.type),i=n?t.Image:t.Illustration;if(n){const t=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(t,i,e,!0)}{const t={name:A.name,blob:new Blob([A],{type:A.type})};return await ft.uploadAssetWithProgress(t,i,e,!0)}}removePersistedAsset(A){mt.remove(A)}getPersistedAssets(){return mt.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 at("Unexpected mimetype: "+t)}}};function Mt(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 Ft=new class{constructor(){Mt(this,"cache",new Map),Mt(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),Mt(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),Mt(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),Mt(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 Ft.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 ft.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 ft.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}},Yt=PA(new A),yt=function(){const[A,t]=RA([]);return{addEvent:UA((A=>{t((t=>[...t,A]))}),[]),updateEvent:UA((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:UA((A=>{t((t=>t.filter((t=>t.pointerId!==A.pointerId))))}),[]),eventCache:A,curActiveEvents:A.length}},Nt=()=>{const A=HA(Yt),[t,e]=RA(new Date);GA((()=>{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 vt(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 xt;var St;(St=xt||(xt={})).None="None",St.FrameAdjustment="FrameAdjustment",St.FinalizeDesign="FinalizeDesign",St.SavedDesigns="SavedDesigns",St.ThreeDPreview="ThreeDPreview",St.Panels="Panels";const Pt=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,xTranslation:0,yTranslation:0,maxZoom:5,units:u.Pixel,subMenu:xt.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Rt=(A,t)=>TA(A,t.apply(A))?A:t.apply(A),Ut=PA({}),Ht=A=>{const{getAllLayouts:t}=Nt(),[e,n]=JA(Rt,Pt(t,A.defaultZoom||1)),i=bA((()=>({state:e,uiDispatcher:n})),[e,n]);return OA(Ut.Provider,{value:i,children:A.children})};class Gt{constructor(A){vt(this,"changes",void 0),this.changes=A}apply(A){return{...A,...this.changes}}}const Jt=()=>HA(Ut);let bt;var kt;(kt=bt||(bt={}))[kt.Orbit=0]="Orbit",kt[kt.Pan=1]="Pan";const Ot=(A,t,e,n)=>{const i=t.layout.useEditableArea&&t.layout.editableArea||{width:t.layout.width,height:t.layout.height,x:0,y:0},a=t.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),s=a.map((A=>F(A.x,A.y,A.width,A.height,A.rotation))),r=[],o=new Set;s.forEach((A=>o.add(A.minX))),s.forEach((A=>o.add(A.maxX))),[i.x,i.x+i.width/2,i.x+i.width].forEach((A=>o.add(A)));const c=new Set;s.forEach((A=>c.add(A.minY))),s.forEach((A=>c.add(A.maxY))),[i.y,i.y+i.height/2,i.y+i.height].forEach((A=>c.add(A)));const g=a.map((A=>A.y));for(let A=-315;A<=315;A+=45)g.push(A);const B=F(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}],l=[{value:B.minY,anchor:-1},{value:B.minY+(B.maxY-B.minY)/2,anchor:0},{value:B.minY+(B.maxY-B.minY),anchor:1}],E=[{value:A.rotation,anchor:0}],d=(A,t,n,a)=>{const s=[];return t.forEach((t=>{const r=n.find((A=>b(t,A.value,1.7*e))),[o,c]=((A,t)=>[{x:"x"===A?t:i.x,y:"x"===A?i.y:t},{x:"x"===A?t:i.x+i.width,y:"x"===A?i.y+i.height:t}])(A,t),g="rotation"===A?null:OA("line",{x1:o.x,y1:o.y,x2:c.x,y2:c.y,stroke:a||"#D61B5C",strokeWidth:1.2*e},`${A}-${t}-${o.x}-${o.y}-${c.x}-${c.y}`);void 0!==r&&s.push({type:A,value:t,anchorPoint:r.anchor,svgNode:g,guidelineCoordinates:[o,c]})})),s};return r.push(...d("x",Array.from(o),w,n),...d("y",Array.from(c),l,n),...d("rotation",g,E,n)),r};let zt;var Lt;let Tt;var jt;(Lt=zt||(zt={})).Translate="Translate",Lt.Rotate="Rotate",Lt.Resize="Resize",(jt=Tt||(Tt={})).ControlLeft="ControlLeft",jt.ControlRight="ControlRight",jt.Equal="Equal",jt.MetaLeft="MetaLeft",jt.MetaRight="MetaRight",jt.Minus="Minus",jt.ArrowLeft="ArrowLeft",jt.ArrowRight="ArrowRight",jt.ArrowUp="ArrowUp",jt.ArrowDown="ArrowDown",jt.AltLeft="AltLeft",jt.AltRight="AltRight",jt.Delete="Delete",jt.Backspace="Backspace";const Kt=(A,t,e,n)=>{const i=()=>{switch(e){case u.Pixel:return 1;case u.Millimeter:return k;case u.Centimeter:return O;default:throw new at("Unknown unit of measurement")}};let a=t.x,s=t.y,r=t.x,o=t.y;switch(A){case Tt.ArrowLeft:r=t.x-1/i();break;case Tt.ArrowUp:o=t.y-1/i();break;case Tt.ArrowRight:r=t.x+1/i();break;case Tt.ArrowDown:o=t.y+1/i();break;default:throw new at("Unhandled element interaction!")}const c=F(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 E(t.id,a,s)};let Vt=0,Xt=0;var Wt=0;const Zt=(A,t,e,n,i,a)=>{const s=F(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},qt=(A,t,e,n,i,a)=>{const s=F(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},$t=(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}),_t=(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,B=e.rotation*Math.PI/180,w=Math.sin(B),E=Math.cos(B),d=e.type===l.Textbox?1:e.width/e.height;switch(i.type){case zt.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},Q=t;switch(i.screenAxis){case z.North:{const n=-c*w+g*E,i=e.y+n,a=e.height-n,s=L({...e}).center,r=L({...e,y:i,height:a}).center,o=T(r,s,B),l=o.x-e.width/2,d=o.y-a/2;Q={...t,left:l,top:d,height:a};const C=180*B/Math.PI,h=F(l,d,e.width,a,C),I=$t({x:A.destX,y:A.destY},A.targetRect,h);if(T({x:I.x,y:I.y},s,-B).y>d+a)return{...t,height:1}}break;case z.East:{const n=c*E+g*w,i=e.width+n;let a=e.height;if(e.type===l.Textbox){const A=e,n=j(A.fontSize,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=n.requiredHeight,!a||!n.requiredWidth)return t}const s=L({...e}).center,r=L({...e,width:i,height:a}).center,o=T(r,s,B),d=o.x-i/2,C=o.y-a/2;Q={...t,left:d,top:C,width:i,height:a};const h=180*B/Math.PI,I=F(d,C,e.width,a,h),D=$t({x:A.destX,y:A.destY},A.targetRect,I);if(T({x:D.x,y:D.y},s,-B).x<d)return{...t,width:1}}break;case z.West:{const n=c*E+g*w,i=e.x+n,a=e.width-n;let s=e.height;if(e.type===l.Textbox){const A=e,n=j(A.fontSize,A.fontData,{...A,width:a},A.input||A.text||"",A.lineHeight);if(s=n.requiredHeight,!s||!n.requiredWidth)return t}const r=L({...e}).center,o=L({...e,width:a,height:s,x:i}).center,d=T(o,r,B),C=d.x-a/2,h=d.y-s/2;Q={...t,left:C,top:h,width:a,height:s};const I=180*B/Math.PI,D=F(C,h,e.width,s,I),u=$t({x:A.destX,y:A.destY},A.targetRect,D);if(T({x:u.x,y:u.y},r,-B).x>C+a)return{...t,width:1}}break;case z.South:{const n=-c*w+g*E,i=e.height+n,a=L({...e}).center,s=L({...e,height:i}).center,r=T(s,a,B),o=r.x-e.width/2,l=r.y-i/2;Q={...t,left:o,top:l,height:i};const d=180*B/Math.PI,C=F(o,l,e.width,i,d),h=$t({x:A.destX,y:A.destY},A.targetRect,C);if(T({x:h.x,y:h.y},a,-B).y<l)return{...t,height:1}}break;case z.Northeast:{const n=c*E+g*w,i=e.width+n;let a=e.height+n/d,s=e.y-n/d,r=e.fontSize;if(e.type===l.Textbox){const A=e;r=A.fontSize+n/8;const o=j(r,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);a=o.requiredHeight;const c=A.lineHeight||K;if(s=e.y-n*c/8,!a||!o.requiredWidth)return t}const o=L({...e}).center,C=L({...e,width:i,height:a,y:s}).center,h=T(C,o,B),I=h.x-i/2,D=h.y-a/2;Q={...t,left:I,top:D,width:i,height:a,fontSize:r};const u=180*B/Math.PI,p=F(I,D,e.width,a,u),m=$t({x:A.destX,y:A.destY},A.targetRect,p),f=T({x:m.x,y:m.y},o,-B);if(f.x<I||f.y>D+a)return{...t,height:1,width:1}}break;case z.Northwest:{const n=-c*E+-g*w,i=e.x-n,a=e.width+n;let s=e.y-n/d,r=e.height+n/d,o=e.fontSize;if(e.type===l.Textbox){const A=e;o=A.fontSize+n/8;const i=j(o,A.fontData,{...A,width:a},A.input||A.text||"",A.lineHeight);r=i.requiredHeight;const c=A.lineHeight||K;if(s=e.y-n*c/8,!r||!i.requiredWidth)return t}const C=L({...e}).center,h=L({...e,x:i,y:s,width:a,height:r}).center,I=T(h,C,B),D=I.x-a/2,u=I.y-r/2;Q={...t,left:D,top:u,width:a,height:r,fontSize:o};const p=180*B/Math.PI,m=F(D,u,e.width,r,p),f=$t({x:A.destX,y:A.destY},A.targetRect,m),M=T({x:f.x,y:f.y},C,-B);if(M.x>D+a||M.y>u+r)return{...t,height:1,width:1}}break;case z.Southeast:{const n=c*E+g*w,i=e.width+n;let a=e.height+n/d,s=e.fontSize;if(e.type===l.Textbox){const A=e;s=A.fontSize+n/8;const r=j(s,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=r.requiredHeight,!a||!r.requiredWidth)return t}const r=L({...e}).center,o=L({...e,width:i,height:a}).center,C=T(o,r,B),h=C.x-i/2,I=C.y-a/2;Q={...t,left:h,top:I,width:i,height:a,fontSize:s};const D=180*B/Math.PI,u=F(h,I,e.width,a,D),p=$t({x:A.destX,y:A.destY},A.targetRect,u),m=T({x:p.x,y:p.y},r,-B);if(m.x<h||m.y<I)return{...t,height:1,width:1}}break;case z.Southwest:{const n=-c*E+-g*w,i=e.width+n;let a=e.x-n,s=e.height+n/d,r=e.fontSize;if(e.type===l.Textbox){const A=e;r=A.fontSize+n/8;const a=j(r,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(s=a.requiredHeight,!s||!a.requiredWidth)return t}const o=L({...e}).center,C=L({...e,width:i,height:s,x:a}).center,h=T(C,o,B),I=h.x-i/2,D=h.y-s/2;Q={...t,left:I,top:D,width:i,height:s,fontSize:r};const u=180*B/Math.PI,p=F(I,D,e.width,s,u),m=$t({x:A.destX,y:A.destY},A.targetRect,p),f=T({x:m.x,y:m.y},o,-B);if(f.x>I+i||f.y<D)return{...t,height:1,width:1}}}return Zt(Q.left,Q.top,Q.width,Q.height,Q.rotation,s)&&qt(Q.left,Q.top,Q.width,Q.height,Q.rotation,s)&&(t=Q),t;case zt.Rotate:const C={x:A.destX,y:A.destY};let h,I=e.rotation;const D=L(e,n,{x:r,y:o}),u=V(C,D.c,D.d),p=V(C,D.d,D.c);if(0===a.filter((A=>"rotation"===A.type)).length)Wt=0,h=(e.rotation+u-p)%360;else{Wt+=Math.sqrt(c**2+g**2);const A=Math.abs(Wt)>8*window.devicePixelRatio/r;h=A?(e.rotation+u-p)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Wt=0)}return Zt(e.x,e.y,e.width,e.height,h,s)&&qt(e.x,e.y,e.width,e.height,h,s)&&(I=h),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:I};case zt.Translate:let m,f,M=e.x,Y=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)m=e.x+c,f=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}};Vt+=c,Xt+=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,B=void 0!==i&&Math.abs(e.x+Vt-i)<=8/r,w=void 0!==s&&Math.abs(e.y+Xt-s)<=8/o;A&&B?m=e.x:(m=e.x+Vt,Vt=0),t&&w?f=e.y:(f=e.y+Xt,Xt=0)}return Zt(m,f,e.width,e.height,e.rotation,s)&&(Y=f),qt(m,f,e.width,e.height,e.rotation,s)&&(M=m),{top:Y,left:M,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,s),o=[];if(e.type===l.Textbox){const A=e;o.push(new D(A.id,A.input||A.text||""))}if(r.width>0&&r.height>0&&(o.push(new E(e.id,r.left,r.top),new d(e.id,r.width,r.height),new Q(e.id,r.rotation)),e.type===l.Textbox)){const A=e;r.fontSize&&A.fontSize!==r.fontSize&&o.push(new c(A.id,r.fontSize))}return o},Ae=A=>{const{onPointerDown:t,scaleFactor:e,elementWidth:n}=A,i=UA((A=>{A.stopPropagation(),t&&t(A)}),[t]),a=13*e;return zA("g",{transform:`translate(${30*e})`,children:[OA("circle",{cx:n/2,cy:-2.5*a,r:1.3*a,fill:"transparent",style:{cursor:"pointer"},onPointerDown:i}),zA("svg",{onPointerDown:i,x:n/2-a,y:-2.5*a-a,width:2*a,height:2*a,style:{cursor:"pointer"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[OA("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"}),OA("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"})]})]})},te="#ffffff",ee=A=>{const{isMobile:t,outerRadius:e,x:n,y:i,cursorStyle:a,onPointerDown:s,handleClass:r,cornerRadius:o,color:c,strokeWidth:g}=A,[B,w]=RA(!1);GA((()=>{const A=()=>{w(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const l=UA((A=>{w(!0),s(A)}),[s]);return t?zA(LA,{children:[OA("circle",{cx:n,cy:i,r:e,fill:B?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:a},onPointerDown:l}),OA("circle",{className:r,cx:n,cy:i,r:o,fill:te,style:{cursor:a,pointerEvents:"none"},stroke:c,strokeWidth:g})]}):OA("circle",{className:r,cx:n,cy:i,r:o,fill:te,style:{cursor:a},stroke:c,strokeWidth:g,onPointerDown:s})},ne=A=>{const{isMobile:t,outerRadius:e,outerWidth:n,outerHeight:i,x:a,y:s,width:r,height:o,cursorStyle:c,onPointerDown:g,edgeHandleRadius:B,color:w,strokeWidth:l}=A,[E,d]=RA(!1);GA((()=>{const A=()=>{d(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const Q=UA((A=>{d(!0),g(A)}),[g]);return t?zA(LA,{children:[OA("rect",{x:a-(n-r)/2,y:s-(i-o)/2,width:n,height:i,rx:e,fill:E?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:c},onPointerDown:Q}),OA("rect",{x:a,y:s,width:r,height:o,rx:B,fill:te,style:{cursor:c,pointerEvents:"none"},stroke:w,strokeWidth:l})]}):OA("rect",{x:a,y:s,width:r,height:o,rx:B,fill:te,style:{cursor:c},stroke:w,strokeWidth:l,onPointerDown:g})},ie=A=>{const{isMobile:t,color:e,elementHeight:n,elementWidth:i,onBeginResize:a,rotation:s,scaleFactor:r,disableX:o,disableY:c}=A,g=7.5*r,B=3*r,w=28*r,l=6*r,E=30*r,d=5*r,Q=40*r,C=36*r,h=1.2*r,I=UA(((A,t,e)=>{A.stopPropagation(),a(t,e)}),[a]),D=UA((A=>I(A,X(z.West,360-s),z.West)),[I,s]),u=UA((A=>I(A,X(z.East,360-s),z.East)),[I,s]),p=UA((A=>I(A,X(z.North,360-s),z.North)),[I,s]),m=UA((A=>I(A,X(z.South,360-s),z.South)),[I,s]),f=UA((A=>I(A,z.Northwest,z.Northwest)),[I]),M=UA((A=>I(A,z.Northeast,z.Northeast)),[I]),F=UA((A=>I(A,z.Southwest,z.Southwest)),[I]),Y=UA((A=>I(A,z.Northeast,z.Southeast)),[I]),y=(t?n-2*E-Q:n-2*g-w)>0&&(t?i-2*E-Q:i-2*g-w)>0;return zA(LA,{children:[OA(ee,{isMobile:t,outerRadius:E,x:0,y:0,cursorStyle:"nw-resize",onPointerDown:f,handleClass:"cornerNorthWest",cornerRadius:g,color:e,strokeWidth:h}),y?OA(ee,{isMobile:t,outerRadius:E,x:i,y:0,cursorStyle:"ne-resize",onPointerDown:M,handleClass:"cornerNorthEast",cornerRadius:g,color:e,strokeWidth:h}):void 0,y?OA(ee,{isMobile:t,outerRadius:E,x:i,y:n,cursorStyle:"se-resize",onPointerDown:Y,handleClass:"cornerSouthEast",cornerRadius:g,color:e,strokeWidth:h}):void 0,y?OA(ee,{isMobile:t,outerRadius:E,x:0,y:n,cursorStyle:"sw-resize",onPointerDown:F,handleClass:"cornerSouthWest",cornerRadius:g,color:e,strokeWidth:h}):void 0,y&&!o?OA(ne,{isMobile:t,outerRadius:d,outerWidth:C,outerHeight:Q,x:-l/2,y:n/2-w/2,width:l,height:w,onPointerDown:D,edgeHandleRadius:B,cursorStyle:"w-resize",color:e,strokeWidth:h}):void 0,y&&!c?OA(ne,{isMobile:t,outerRadius:d,outerWidth:Q,outerHeight:C,x:i/2-w/2,y:n-l/2,width:w,height:l,onPointerDown:m,edgeHandleRadius:B,cursorStyle:"s-resize",color:e,strokeWidth:h}):void 0,o?void 0:OA(ne,{isMobile:t,outerRadius:d,outerWidth:C,outerHeight:Q,x:i-l/2,y:n/2-Math.min(w,.8*n)/2,width:l,height:Math.min(w,.8*n),onPointerDown:u,edgeHandleRadius:B,cursorStyle:"e-resize",color:e,strokeWidth:h}),y&&!c?OA(ne,{isMobile:t,outerRadius:d,outerWidth:Q,outerHeight:C,x:i/2-w/2,y:-l/2,width:w,height:l,onPointerDown:p,edgeHandleRadius:B,cursorStyle:"n-resize",color:e,strokeWidth:h}):void 0]})},ae=A=>{const{isMobile:t,color:e,elementWidth:n,onBeginRotate:i,scaleFactor:a}=A,s=UA((A=>{A.stopPropagation(),i()}),[i]),r=13*a;return zA("g",{transform:t?`translate(${-(30*a)})`:void 0,children:[OA("circle",{cx:n/2,cy:-2.5*r,r:1.3*r,fill:"transparent",style:{cursor:"ew-resize"},onPointerDown:s}),zA("svg",{x:n/2-r,y:-2.5*r-r,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*r,viewBox:"0 0 24 24",width:2*r,stroke:e,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",onPointerDown:s,children:[" ",OA("polyline",{points:"23 4 23 10 17 10"})," ",OA("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})]})},se="spiffElementID",re=({color:A,height:t,highlighted:e,id:n,immutable:i,onBeginMove:a,onPointerEnter:s,onPointerLeave:r,onSelected:o,pressed:c,rotation:g,scaleFactor:B,selected:w,width:l,x:E,y:d})=>{const Q=1.2*B,{addEvent:C,removeEvent:h,curActiveEvents:I}=yt(),D=UA((A=>{C(A),A[se]=n;0===I&&0===A.button&&(o(n,A),a())}),[n,w,I,o,a]),u=UA((A=>{h(A)}),[]),p=UA((A=>{s(n)}),[n,I,s]),m=UA((A=>{h(A),r(n)}),[n,I,r]);return OA("g",{transform:`translate(${E}, ${d}) rotate(${g} ${l/2} ${t/2})`,children:OA("rect",{className:"interactableInnerRect",width:l,height:t,stroke:w||e?A:"none",pointerEvents:i?"none":"visibleFill",fill:"none",strokeWidth:Q,style:{cursor:i?void 0:w?c?"grabbing":"grab":"pointer"},onPointerDown:i?void 0:D,onPointerUp:i?void 0:u,onPointerEnter:i?void 0:p,onPointerLeave:i?void 0:m})})},oe=A=>{const{isMobile:t,color:e,height:n,onBeginResize:i,onBeginRotate:a,onContextMenuHandlePointerDown:s,rotation:r,scaleFactor:o,width:c,x:g,y:B,disableX:w,disableY:l}=A;return zA("g",{transform:`translate(${g}, ${B}) rotate(${r} ${c/2} ${n/2})`,children:[OA(ae,{isMobile:t&&!!s,color:e,elementWidth:c,onBeginRotate:a,scaleFactor:o}),t&&s&&OA(Ae,{onPointerDown:s,elementWidth:c,scaleFactor:o}),OA(ie,{isMobile:t,color:e,elementHeight:n,elementWidth:c,rotation:r,scaleFactor:o,onBeginResize:i,disableX:w,disableY:l})]})},ce=.5,ge=["TEXTAREA","INPUT"],Be=(A,t,e,n,i,a,r,o)=>{const{state:c,uiDispatcher:g}=HA(Ut),{getLayoutById:w,getReducerState:l,flattenSequence:E}=Nt(),[d,Q]=RA(void 0),[C,h]=RA(void 0),[I,D]=RA(void 0),[u,p]=RA(null),m=w(c.layoutId);GA((()=>{if("adjustment"===i&&A?.current&&n){if(n<ce)return void g(new Gt({zoom:ce}));if(n>c.maxZoom)return void g(new Gt({zoom:c.maxZoom}));g(new Gt({zoom:n}))}}),[n,g,A,i,c.maxZoom]);const f=UA(((A,n)=>{g(new Gt({zoom:n}));const a=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!c.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))}),[g,t,e,c.scrolledMovement,i]);GA((()=>{c.zoom<=1&&g(new Gt({scrolledMovement:!1}))}),[g,c.zoom]);const F=t?.current?.getBoundingClientRect(),Y=((F?.width||1)+(F?.height||1))/2,y=(m.layoutState.layout.width+m.layoutState.layout.height)/2/Y/c.zoom,N=bA((()=>{const A=c.activeModifierKeys,t=c.elementEvent,e=A.includes(Tt.ControlLeft)||A.includes(Tt.MetaLeft)||A.includes(Tt.ControlRight)||A.includes(Tt.MetaRight);if(!c.selectedElement||!t||e)return[];const n=t&&t.type===zt.Translate,i=t&&t.type===zt.Rotate,a=m.layoutState.elements.find((A=>A.id===c.selectedElement));return(n||i)&&a?Ot(a,m.layoutState,y,r):[]}),[c.selectedElement,c.elementEvent,c.activeModifierKeys,m.layoutState,y]),v=UA((()=>{const A=M();Q(A),h(l().transaction)}),[l]),x=UA((A=>{p(A.target),A[se]||(p(null),g(new Gt({selectedElement:void 0})))}),[c,g]),S=UA((()=>{g(new Gt({scrolledMovement:!0}))}),[g]),P=UA(((e,n)=>{const i=m.layoutState.elements.find((A=>A.id===c.selectedElement)),s=u?.getBoundingClientRect();if(!(c.elementEvent&&A.current&&t.current&&c.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(),o=new B(_t({deltaX:I?e.screenX-I.screenX:0,deltaY:I?e.screenY-I.screenY:0,destX:e.clientX,destY:e.clientY,targetRect:s},m.layoutState.layout,i,r,c.elementEvent,N,n));o.sequenceId=d,a(o,!1),D({screenX:e.screenX,screenY:e.screenY})}),[m.layoutState.elements,m.layoutState.layout,c.elementEvent,A,c.selectedElement,t,N,a,I]),R=UA((A=>{g(new Gt({elementEvent:A}))}),[g]),U=UA((()=>{R(void 0),d&&C&&(E(d,C),Q(void 0),h(void 0),o&&o()),D(void 0)}),[R,d,C,E,o]),H=UA(((A,t)=>{let e=c.zoom;const n=c.maxZoom,r=c.selectedElement,o=c.activeModifierKeys;if((o.includes(Tt.AltLeft)||o.includes(Tt.AltRight))&&(A.code===Tt.Equal||A.code===Tt.Minus)){const t=.05*n;A.code===Tt.Equal?g(new Gt({zoom:e+t<=n?e+=t:e})):g(new Gt({zoom:e-t>=ce?e-t:e}))}const B=m.layoutState.elements.find((A=>A.id===r));if(r&&B){if(A.code===Tt.MetaLeft||A.code===Tt.ControlLeft||A.code===Tt.MetaRight||A.code===Tt.ControlRight){const t=A.code,e=c.activeModifierKeys;if(!e.includes(t))return g(new Gt({activeModifierKeys:e.concat(t)}))}if(A.code===Tt.ArrowDown||A.code===Tt.ArrowUp||A.code===Tt.ArrowLeft||A.code===Tt.ArrowRight){g(new Gt({elementEvent:{type:zt.Translate}}));const e=Kt(A.code,B,c.units,t);a(e,!1),g(new Gt({elementEvent:void 0}))}A.code!==Tt.Delete&&A.code!==Tt.Backspace||"advanced"!==i||(g(new Gt({selectedElement:void 0})),a(new s(B.id),!1))}}),[a,g,m.layoutState.elements,i,c.activeModifierKeys,c.maxZoom,c.selectedElement,c.units,c.zoom]),G=UA((A=>{if(A.code===Tt.MetaLeft||A.code===Tt.ControlLeft||A.code===Tt.MetaRight||A.code===Tt.ControlRight){const t=c.activeModifierKeys,e=A.code;g(new Gt({activeModifierKeys:t.filter((A=>A!==e))}))}}),[g,c.activeModifierKeys]);return{guidelines:N,scale:y,zoomableElementRef:e,setElementEvent:R,handleZoom:f,handleKeyDown:H,handleKeyUp:G,handlePointerPressedBackground:x,handlePointerReleased:U,handlePointerMove:P,handleScroll:S,handleSequenceStart:v}},we=(A,t,e)=>{const n=bA((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),i=kA([]),a=UA((()=>{const A=n.every((A=>i.current.includes(A))),t=i.current.length===n.length;return A&&t}),[]),s=UA((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const n=A.target;return!(ge.indexOf(n.tagName)>=0)&&(i.current=[...new Set([...i.current,e])],a()&&t(),A.preventDefault())}),[a,n,t,A]),r=UA((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]);GA((()=>(window.addEventListener("keydown",s),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",r)})),[s,r])},le=A=>{const{isMobile:t,primaryColor:e,customViewbox:n,editorRef:i,elementEvent:a,guidelines:s,layoutHeight:r,layoutWidth:o,targetedElements:c,scale:g,selectedElement:B,onElementEvent:w,onElementSelected:E,onSequenceStart:d,onMouseMove:Q,onContextMenuHandlePointerDown:C}=A,{state:h}=Jt(),{getLayoutById:I}=Nt(),D=I(h.layoutId),[u,p]=RA(void 0),m=UA((A=>{p(A)}),[]),f=UA((A=>{u===A&&p(void 0)}),[u]),M=UA((()=>{d(),w({type:zt.Translate})}),[w]),F=UA(((A,t)=>{d(),w({type:zt.Resize,relativeAxis:A,screenAxis:t})}),[w]),Y=UA((()=>{d(),w({type:zt.Rotate})}),[w]),y=n||{x:0,y:0,width:o,height:r},N=D.layoutState.elements,v=N.find((A=>A.id===B));return zA("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:[OA("rect",{onMouseMove:Q,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:i,width:o,height:r}),s.map((A=>A.svgNode)),N.map((A=>{const t=void 0!==B&&A.id===B,n=t&&void 0!==a,i=void 0!==u&&A.id===u;return OA(re,{color:e,id:A.id,selected:t,highlighted:i,pressed:n,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,immutable:A.immutable||c&&!c.includes(A.id),onSelected:E,onBeginMove:M,onPointerEnter:m,onPointerLeave:f,scaleFactor:g},A.id)})),v&&OA(oe,{isMobile:t,color:e,x:v.x,y:v.y,disableX:v.type===l.Frame||v.type===l.Image,disableY:v.type===l.Textbox||v.type===l.Frame||v.type===l.Image,width:v.width,height:v.height,rotation:v.rotation,onBeginResize:F,onBeginRotate:Y,scaleFactor:g,onContextMenuHandlePointerDown:C})]})},Ee=A=>{const{isMobile:t,color:e,editorRef:n,zoomableElementRef:i,interactionElementRef:a,guidelines:s,isMakingAdjustments:r,outlineArea:o,visibleLayoutId:c,xTranslation:g,yTranslation:B,targetedElements:w,borderRadius:l,canvasFilter:E,handleContextMenu:d,onMouseMove:Q,onContextMenuHandlePointerDown:C,handleKeyDown:h,handleKeyUp:I,handlePointerMove:D,handlePointerPressedBackground:u,handlePointerReleased:p,handleScroll:m,onSequenceStart:f,setElementEvent:M,onElementSelected:F}=A,{getLayoutById:Y}=Nt(),y=Y(c),N=y.layoutState,{state:v}=Jt(),x=UA((A=>{if(o){const t={left:o.x||0,top:o.y||0,width:o.width||1,height:o.height||1,panelId:"",rotation:0};return h(A,t)}return h(A)}),[h,o]),S=UA((A=>{if(o){const t={left:o.x||0,top:o.y||0,width:o.width||1,height:o.height||1,panelId:"",rotation:0};return D(A,t)}return D(A)}),[D,o]),P=bA((()=>{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}),[]),R=bA((()=>({height:"100%",transform:`scale(${v.zoom}) translate(${g}px, ${B}px)`,display:"flex",justifyContent:"center",alignItems:"center",filter:E||"drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2))",overflow:"visible"})),[v.zoom,v.xTranslation,v.yTranslation]),U=10/v.zoom,H=N.layout.width,G=N.layout.height,J=i.current?.offsetHeight||1024,b=i.current?.offsetWidth||1024,k=U*(Math.sqrt(H*G)/1e3)*(100/Math.sqrt(J*b))*Math.sqrt((O=b/J,Math.exp(Math.abs(Math.log(O)))));var O;const z=bA((()=>({configuration:{purpose:W.FreeDesign},height:r?"100%":"auto",width:r?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",outlineArea:o?{...o,scale:k}:void 0,borderRadius:l})),[r,k]);return OA("div",{style:P,onContextMenu:d,onKeyDown:x,onKeyUp:I,onPointerDown:u,onMouseLeave:p,onPointerMoveCapture:S,onPointerUp:p,onWheelCapture:m,ref:a,tabIndex:-1,children:zA("div",{ref:i,style:R,children:[A.children,y.getComponentWithProps(z),OA(le,{isMobile:t,primaryColor:e,editorRef:n,elementEvent:v.elementEvent,guidelines:s,layoutHeight:N.layout.height,layoutWidth:N.layout.width,onElementEvent:M,onSequenceStart:f,onElementSelected:F,scale:k,selectedElement:v.selectedElement,targetedElements:w,onMouseMove:Q,onContextMenuHandlePointerDown:C})]})})},de=({isMobile:A,color:t,borderRadius:e,guidelineColor:n,canvasFilter:i,hideEditableAreaRect:a,handleContextMenu:s,onMouseMove:r,onContextMenuHandlePointerDown:o,onElementSelected:c,onDragEnd:g})=>{const{commandDispatcher:B,getLayoutById:w}=Nt(),{state:E,uiDispatcher:d}=Jt(),Q=kA(null),C=kA(null),h=kA(null),{guidelines:I,handleKeyDown:D,handleKeyUp:u,handlePointerMove:p,handlePointerPressedBackground:m,handlePointerReleased:f,handleScroll:M,handleSequenceStart:F,setElementEvent:Y}=Be(Q,C,h,void 0,"advanced",B,n,g),y=bA((()=>w(E.layoutId)),[w,E.layoutId]),N=UA(((A,t)=>{const e=y.layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===l.Textbox){const t=e.algorithm;(!t||t===G.Autosize)&&B(new J(A,G.Traditional),!0)}c&&c(A,t),d(new Gt({selectedElement:A}))}),[B,w,E.layoutId,d]),v=bA((()=>{if(y.layoutState.layout.useEditableArea)return{...y.layoutState.layout.editableArea,hidden:a}}),[y.layoutState.layout.useEditableArea,y.layoutState.layout.editableArea,a]);return OA(Ee,{outlineArea:v,isMobile:A,color:t,editorRef:Q,interactionElementRef:C,zoomableElementRef:h,guidelines:I,visibleLayoutId:E.layoutId,xTranslation:E.xTranslation,yTranslation:E.yTranslation,borderRadius:e,canvasFilter:i,handleContextMenu:s,onMouseMove:r,onContextMenuHandlePointerDown:o,handleKeyDown:D,handleKeyUp:u,handlePointerMove:p,handlePointerPressedBackground:m,handlePointerReleased:f,handleScroll:M,onSequenceStart:F,setElementEvent:Y,onElementSelected:N})},Qe=NA`
1
+ import{CommandContext as A,AssetType as t,BringForwardCommand as e,CanvasCommand as n,CreateElementCommand as i,CreateLayoutCommand as a,DeleteElementCommand as s,FontAlignmentCommand as r,FontColorCommand as o,FontSizeCommand as c,FontSourceCommand as g,GroupCommand as B,LayoutElementFactory as w,LayoutElementType as l,MoveCommand as E,ResizeCommand as d,RotateCommand as Q,SendBackwardsCommand as C,StepAspectType as h,StepType as I,TextChangeCommand as D,UnitOfMeasurement as u,dataUrlFromExternalUrl as p,findElement as m,frameDataCache as f,generate as M,getAxisAlignedBoundingBox as F,generateSVGWithUnknownColors as Y,getAttributesFromArrayBuffer as y,rehydrateSerializedLayout as N,getFrameData as v,getSvgString as x,loadFontFromDataUrl as S,loadFontFromExternalUrl as P,determineCorrectFontSizeAndLines as R,patternImageDataCache as U,registerJSDOM as H,TextAlgorithm as G,FontAlgorithmCommand as J,isCloseToValue as b,mmPerPixel as k,cmPerPixel as O,ScaleAxis as z,getElementVertices as L,rotateAroundPoint as T,calculateTextboxLines as j,defaultLineHeightFactor as K,findAngle as V,currentDirection as X,LayoutRenderingPurpose as W,svgObjectURL as Z,UpdateWorkflowStateCommand as q,calculateOffsets as $,UpdateFramePattern as _,generateDefaultRectangleFrameSvg as AA,fetchAsString as tA,GetSVGDimensions as eA,modifySVGWithElementProperties as nA,IllustrationColorCommand as iA,IllustrationCacheCommand as aA,getFontMetrics as sA,applyTextTransformations as rA,createElementNS as oA,createElement as cA,sortElementsByLayersWithIndex as gA,toBase64 as BA,getPatternImageData as wA,getVariant as lA,generateFrameSVG as EA,getDefaultVariant as dA,domParser as QA,sanitizeSvgTree as CA,traverse as hA,xmlSerializer as IA,fetchAsArrayBuffer as DA,arrayBufferToDataUrl as uA,loadFontFaceSet as pA,MaterialEffectMode as mA}from"@spiffcommerce/papyrus";import fA from"swagger-client";import{createHttpLink as MA,InMemoryCache as FA,ApolloClient as YA,from as yA,gql as NA}from"@apollo/client";import{setContext as vA}from"@apollo/client/link/context";import{onError as xA}from"@apollo/client/link/error";import{fetch as SA}from"cross-fetch";import{createContext as PA,useState as RA,useCallback as UA,useContext as HA,useEffect as GA,useReducer as JA,useMemo as bA,useRef as kA}from"react";import{jsx as OA,jsxs as zA,Fragment as LA}from"react/jsx-runtime";import TA from"lodash.isequal";import{Canvg as jA}from"canvg";import KA from"lodash.clonedeep";import VA from"lodash.debounce";import{toString as XA}from"qrcode";import WA from"svg-path-bbox";function ZA(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 qA extends Error{constructor(A){super(A),this.name=this.constructor.name}}class $A extends qA{constructor(A){super(`ConfigurationError - ${A}`)}}class _A extends $A{constructor(A){super(`Option not Configured: ${A.stepTitle}`),ZA(this,"optionId",void 0),this.optionId=A?.optionId||"N/A"}}class At extends $A{constructor(A){super(`Panel not Found: ${A.panelId}`),ZA(this,"panelId",void 0),this.panelId=A?.panelId||"N/A"}}class tt extends $A{constructor(A){super(`Asset not found for variant: ${A.name}`),ZA(this,"variant",void 0),this.variant=A}}class et extends $A{constructor(A){super(`Resource not found for asset: ${A.name}`),ZA(this,"asset",void 0),this.asset=A}}class nt extends $A{constructor(A,t){super(`Workflow Misconfiguration: ${A.stepName} - ${t}`),ZA(this,"step",void 0),this.step=A}}class it extends qA{constructor(A){super(`ImplementationError - ${A}`)}}class at extends it{constructor(A){super(`Unhandled Behavior Encountered: ${A}`)}}class st extends it{constructor(A){super(`Parsing Error: ${A}`)}}class rt extends it{constructor(A){super(`Client Error: ${A}`)}}class ot extends it{constructor(A){super(`Resource Generation Failed: ${A}`)}}function ct(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 gt{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 Bt{constructor(){ct(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 wt=(()=>{try{return localStorage?new gt:new Bt}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new Bt}})();function lt(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 Et=new class{constructor(){lt(this,"defaultServerUrl","https://api.spiff.com.au"),lt(this,"defaultServicesApiUrl","https://services.spiff.com.au"),lt(this,"defaultHubUrl","https://hub.spiff.com.au"),lt(this,"serverUrl",void 0),lt(this,"servicesApiUrl",void 0),lt(this,"hubUrl",void 0),lt(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 dt(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 Qt;const Ct=A=>{Qt=A},ht=async()=>{const A={transactionOwnerId:Qt};return window.location.href.includes("/workflows/product/")?{...await new Promise((A=>{const t=Et.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 It=new class{constructor(){dt(this,"client",void 0),dt(this,"uncachedOperations",[]),Et.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 ht();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 ht(),t=Et.getServerUrl()+"/v2/api-docs";return await fA(t,{authorizations:{OAuth2:{token:{access_token:A.bearer,token_type:"Bearer"}},PartnerId:A.partnerId}})}};const Dt=new class{constructor(){dt(this,"shadowGraphqlClient",void 0),this.shadowGraphqlClient=this.constructShadowGraphqlClient(),Et.addServerUrlCallback((()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()}))}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const A=MA({uri:`${Et.getServerUrl()}/graphql`,fetch:SA}),t=vA((async(A,{headers:t})=>{const e=t||{},n=await ht();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=xA((({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 FA({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 YA({link:yA([e,t,A]),cache:n,name:"Core"})}};function ut(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 pt="persistentAssets";class mt{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=wt.getMap(pt);n&&n.forEach(((A,t)=>{e.set(t,A)})),wt.setMap(pt,e)}static remove(A){const t=wt.getMap(pt);if(!t)return;const e=Array.from(t.entries()).find((t=>t[0]===A));e&&(t.delete(e[0]),wt.setMap(pt,t))}static list(){const A=wt.getMap(pt);return A?Array.from(A.entries()).map((A=>({assetKey:A[0],src:A[1]}))):[]}}const ft=new class{constructor(){ut(this,"server",void 0),ut(this,"cache",new Map),ut(this,"materialCache",new Map),ut(this,"loadImageAsFileInfo",(async A=>{const t=await A.arrayBuffer(),e=await y(t);return{name:A.name.substring(A.name.lastIndexOf("/")+1),blob:((A,t)=>{let e=atob(A.split(",")[1]),n=[];for(let A=0;A<e.length;A++)n.push(e.charCodeAt(A));return new Blob([new Uint8Array(n)],{type:t})})(e.dataUrl,A.type)}})),ut(this,"getAssetFromVariant",(async A=>A.asset?A.asset:await ft.getLocalOrFromServer(A.assetKey))),ut(this,"getMaterialFromVariant",(async A=>A.material?A.material:await ft.getMaterialLocalOrFromServer(A.materialId))),this.server=It}async getLocalOrFromServer(A){if(this.cache.has(A)){const t=this.cache.get(A);if(!t)throw new at("Failed to get asset from cache!");return t}const t=(async()=>(await It.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 It.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;mt.add(a.assetResponse.asset),t(A)},i.onerror=n,i.send(A.blob)})),a.assetResponse.asset}async uploadFile(A,e){const n=!("image/svg+xml"===A.type||"application/pdf"===A.type),i=n?t.Image:t.Illustration;if(n){const t=await this.loadImageAsFileInfo(A);return await this.uploadAssetWithProgress(t,i,e,!0)}{const t={name:A.name,blob:new Blob([A],{type:A.type})};return await ft.uploadAssetWithProgress(t,i,e,!0)}}removePersistedAsset(A){mt.remove(A)}getPersistedAssets(){return mt.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 at("Unexpected mimetype: "+t)}}};function Mt(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 Ft=new class{constructor(){Mt(this,"cache",new Map),Mt(this,"getDisplayImageSource",(A=>{if(A){const t=A.displayImage?.links.find((A=>"cdn"===A.rel));if(t)return t.href}})),Mt(this,"getSelectedVariant",((A,t)=>{if(A&&0!==t.length)return A.variants.find((A=>A.id===t[0]))})),Mt(this,"getSelectedVariants",((A,t)=>A?.variants.filter((A=>t.includes(A.id)))||[])),Mt(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 Ft.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 ft.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 ft.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}},Yt=PA(new A),yt=function(){const[A,t]=RA([]);return{addEvent:UA((A=>{t((t=>[...t,A]))}),[]),updateEvent:UA((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:UA((A=>{t((t=>t.filter((t=>t.pointerId!==A.pointerId))))}),[]),eventCache:A,curActiveEvents:A.length}},Nt=()=>{const A=HA(Yt),[t,e]=RA(new Date);GA((()=>{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 vt(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 xt;var St;(St=xt||(xt={})).None="None",St.FrameAdjustment="FrameAdjustment",St.FinalizeDesign="FinalizeDesign",St.SavedDesigns="SavedDesigns",St.ThreeDPreview="ThreeDPreview",St.Panels="Panels";const Pt=(A,t)=>({layoutId:A()[0].layoutState.layout.id,selectedElement:void 0,zoom:t,xTranslation:0,yTranslation:0,maxZoom:5,units:u.Pixel,subMenu:xt.None,activeModifierKeys:[],metaPressed:!1,elementEvent:void 0,scrolledMovement:!1}),Rt=(A,t)=>TA(A,t.apply(A))?A:t.apply(A),Ut=PA({}),Ht=A=>{const{getAllLayouts:t}=Nt(),[e,n]=JA(Rt,Pt(t,A.defaultZoom||1)),i=bA((()=>({state:e,uiDispatcher:n})),[e,n]);return OA(Ut.Provider,{value:i,children:A.children})};class Gt{constructor(A){vt(this,"changes",void 0),this.changes=A}apply(A){return{...A,...this.changes}}}const Jt=()=>HA(Ut);let bt;var kt;(kt=bt||(bt={}))[kt.Orbit=0]="Orbit",kt[kt.Pan=1]="Pan";const Ot=(A,t,e,n)=>{const i=t.layout.useEditableArea&&t.layout.editableArea||{width:t.layout.width,height:t.layout.height,x:0,y:0},a=t.elements.filter((t=>t.id!==A.id&&!t.immutable&&!t.productOverlay)),s=a.map((A=>F(A.x,A.y,A.width,A.height,A.rotation))),r=[],o=new Set;s.forEach((A=>o.add(A.minX))),s.forEach((A=>o.add(A.maxX))),[i.x,i.x+i.width/2,i.x+i.width].forEach((A=>o.add(A)));const c=new Set;s.forEach((A=>c.add(A.minY))),s.forEach((A=>c.add(A.maxY))),[i.y,i.y+i.height/2,i.y+i.height].forEach((A=>c.add(A)));const g=a.map((A=>A.y));for(let A=-315;A<=315;A+=45)g.push(A);const B=F(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}],l=[{value:B.minY,anchor:-1},{value:B.minY+(B.maxY-B.minY)/2,anchor:0},{value:B.minY+(B.maxY-B.minY),anchor:1}],E=[{value:A.rotation,anchor:0}],d=(A,t,n,a)=>{const s=[];return t.forEach((t=>{const r=n.find((A=>b(t,A.value,1.7*e))),[o,c]=((A,t)=>[{x:"x"===A?t:i.x,y:"x"===A?i.y:t},{x:"x"===A?t:i.x+i.width,y:"x"===A?i.y+i.height:t}])(A,t),g="rotation"===A?null:OA("line",{x1:o.x,y1:o.y,x2:c.x,y2:c.y,stroke:a||"#D61B5C",strokeWidth:1.2*e},`${A}-${t}-${o.x}-${o.y}-${c.x}-${c.y}`);void 0!==r&&s.push({type:A,value:t,anchorPoint:r.anchor,svgNode:g,guidelineCoordinates:[o,c]})})),s};return r.push(...d("x",Array.from(o),w,n),...d("y",Array.from(c),l,n),...d("rotation",g,E,n)),r};let zt;var Lt;let Tt;var jt;(Lt=zt||(zt={})).Translate="Translate",Lt.Rotate="Rotate",Lt.Resize="Resize",(jt=Tt||(Tt={})).ControlLeft="ControlLeft",jt.ControlRight="ControlRight",jt.Equal="Equal",jt.MetaLeft="MetaLeft",jt.MetaRight="MetaRight",jt.Minus="Minus",jt.ArrowLeft="ArrowLeft",jt.ArrowRight="ArrowRight",jt.ArrowUp="ArrowUp",jt.ArrowDown="ArrowDown",jt.AltLeft="AltLeft",jt.AltRight="AltRight",jt.Delete="Delete",jt.Backspace="Backspace";const Kt=(A,t,e,n)=>{const i=()=>{switch(e){case u.Pixel:return 1;case u.Millimeter:return k;case u.Centimeter:return O;default:throw new at("Unknown unit of measurement")}};let a=t.x,s=t.y,r=t.x,o=t.y;switch(A){case Tt.ArrowLeft:r=t.x-1/i();break;case Tt.ArrowUp:o=t.y-1/i();break;case Tt.ArrowRight:r=t.x+1/i();break;case Tt.ArrowDown:o=t.y+1/i();break;default:throw new at("Unhandled element interaction!")}const c=F(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 E(t.id,a,s)};let Vt=0,Xt=0;var Wt=0;const Zt=(A,t,e,n,i,a)=>{const s=F(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},qt=(A,t,e,n,i,a)=>{const s=F(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},$t=(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}),_t=(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,B=e.rotation*Math.PI/180,w=Math.sin(B),E=Math.cos(B),d=e.type===l.Textbox?1:e.width/e.height;switch(i.type){case zt.Resize:let t={top:e.y,left:e.x,width:e.width,height:e.height,rotation:e.rotation,fontSize:e.fontSize},Q=t;switch(i.screenAxis){case z.North:{const n=-c*w+g*E,i=e.y+n,a=e.height-n,s=L({...e}).center,r=L({...e,y:i,height:a}).center,o=T(r,s,B),l=o.x-e.width/2,d=o.y-a/2;Q={...t,left:l,top:d,height:a};const C=180*B/Math.PI,h=F(l,d,e.width,a,C),I=$t({x:A.destX,y:A.destY},A.targetRect,h);if(T({x:I.x,y:I.y},s,-B).y>d+a)return{...t,height:1}}break;case z.East:{const n=c*E+g*w,i=e.width+n;let a=e.height;if(e.type===l.Textbox){const A=e,n=j(A.fontSize,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=n.requiredHeight,!a||!n.requiredWidth)return t}const s=L({...e}).center,r=L({...e,width:i,height:a}).center,o=T(r,s,B),d=o.x-i/2,C=o.y-a/2;Q={...t,left:d,top:C,width:i,height:a};const h=180*B/Math.PI,I=F(d,C,e.width,a,h),D=$t({x:A.destX,y:A.destY},A.targetRect,I);if(T({x:D.x,y:D.y},s,-B).x<d)return{...t,width:1}}break;case z.West:{const n=c*E+g*w,i=e.x+n,a=e.width-n;let s=e.height;if(e.type===l.Textbox){const A=e,n=j(A.fontSize,A.fontData,{...A,width:a},A.input||A.text||"",A.lineHeight);if(s=n.requiredHeight,!s||!n.requiredWidth)return t}const r=L({...e}).center,o=L({...e,width:a,height:s,x:i}).center,d=T(o,r,B),C=d.x-a/2,h=d.y-s/2;Q={...t,left:C,top:h,width:a,height:s};const I=180*B/Math.PI,D=F(C,h,e.width,s,I),u=$t({x:A.destX,y:A.destY},A.targetRect,D);if(T({x:u.x,y:u.y},r,-B).x>C+a)return{...t,width:1}}break;case z.South:{const n=-c*w+g*E,i=e.height+n,a=L({...e}).center,s=L({...e,height:i}).center,r=T(s,a,B),o=r.x-e.width/2,l=r.y-i/2;Q={...t,left:o,top:l,height:i};const d=180*B/Math.PI,C=F(o,l,e.width,i,d),h=$t({x:A.destX,y:A.destY},A.targetRect,C);if(T({x:h.x,y:h.y},a,-B).y<l)return{...t,height:1}}break;case z.Northeast:{const n=c*E+g*w,i=e.width+n;let a=e.height+n/d,s=e.y-n/d,r=e.fontSize;if(e.type===l.Textbox){const A=e;r=A.fontSize+n/8;const o=j(r,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);a=o.requiredHeight;const c=A.lineHeight||K;if(s=e.y-n*c/8,!a||!o.requiredWidth)return t}const o=L({...e}).center,C=L({...e,width:i,height:a,y:s}).center,h=T(C,o,B),I=h.x-i/2,D=h.y-a/2;Q={...t,left:I,top:D,width:i,height:a,fontSize:r};const u=180*B/Math.PI,p=F(I,D,e.width,a,u),m=$t({x:A.destX,y:A.destY},A.targetRect,p),f=T({x:m.x,y:m.y},o,-B);if(f.x<I||f.y>D+a)return{...t,height:1,width:1}}break;case z.Northwest:{const n=-c*E+-g*w,i=e.x-n,a=e.width+n;let s=e.y-n/d,r=e.height+n/d,o=e.fontSize;if(e.type===l.Textbox){const A=e;o=A.fontSize+n/8;const i=j(o,A.fontData,{...A,width:a},A.input||A.text||"",A.lineHeight);r=i.requiredHeight;const c=A.lineHeight||K;if(s=e.y-n*c/8,!r||!i.requiredWidth)return t}const C=L({...e}).center,h=L({...e,x:i,y:s,width:a,height:r}).center,I=T(h,C,B),D=I.x-a/2,u=I.y-r/2;Q={...t,left:D,top:u,width:a,height:r,fontSize:o};const p=180*B/Math.PI,m=F(D,u,e.width,r,p),f=$t({x:A.destX,y:A.destY},A.targetRect,m),M=T({x:f.x,y:f.y},C,-B);if(M.x>D+a||M.y>u+r)return{...t,height:1,width:1}}break;case z.Southeast:{const n=c*E+g*w,i=e.width+n;let a=e.height+n/d,s=e.fontSize;if(e.type===l.Textbox){const A=e;s=A.fontSize+n/8;const r=j(s,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(a=r.requiredHeight,!a||!r.requiredWidth)return t}const r=L({...e}).center,o=L({...e,width:i,height:a}).center,C=T(o,r,B),h=C.x-i/2,I=C.y-a/2;Q={...t,left:h,top:I,width:i,height:a,fontSize:s};const D=180*B/Math.PI,u=F(h,I,e.width,a,D),p=$t({x:A.destX,y:A.destY},A.targetRect,u),m=T({x:p.x,y:p.y},r,-B);if(m.x<h||m.y<I)return{...t,height:1,width:1}}break;case z.Southwest:{const n=-c*E+-g*w,i=e.width+n;let a=e.x-n,s=e.height+n/d,r=e.fontSize;if(e.type===l.Textbox){const A=e;r=A.fontSize+n/8;const a=j(r,A.fontData,{...A,width:i},A.input||A.text||"",A.lineHeight);if(s=a.requiredHeight,!s||!a.requiredWidth)return t}const o=L({...e}).center,C=L({...e,width:i,height:s,x:a}).center,h=T(C,o,B),I=h.x-i/2,D=h.y-s/2;Q={...t,left:I,top:D,width:i,height:s,fontSize:r};const u=180*B/Math.PI,p=F(I,D,e.width,s,u),m=$t({x:A.destX,y:A.destY},A.targetRect,p),f=T({x:m.x,y:m.y},o,-B);if(f.x>I+i||f.y<D)return{...t,height:1,width:1}}}return Zt(Q.left,Q.top,Q.width,Q.height,Q.rotation,s)&&qt(Q.left,Q.top,Q.width,Q.height,Q.rotation,s)&&(t=Q),t;case zt.Rotate:const C={x:A.destX,y:A.destY};let h,I=e.rotation;const D=L(e,n,{x:r,y:o}),u=V(C,D.c,D.d),p=V(C,D.d,D.c);if(0===a.filter((A=>"rotation"===A.type)).length)Wt=0,h=(e.rotation+u-p)%360;else{Wt+=Math.sqrt(c**2+g**2);const A=Math.abs(Wt)>8*window.devicePixelRatio/r;h=A?(e.rotation+u-p)%360:a.find((A=>"rotation"===A.type))?.value||0,A&&(Wt=0)}return Zt(e.x,e.y,e.width,e.height,h,s)&&qt(e.x,e.y,e.width,e.height,h,s)&&(I=h),{top:e.y,left:e.x,width:e.width,height:e.height,rotation:I};case zt.Translate:let m,f,M=e.x,Y=e.y;if(0===a.filter((A=>"rotation"!==A.type)).length)m=e.x+c,f=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}};Vt+=c,Xt+=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,B=void 0!==i&&Math.abs(e.x+Vt-i)<=8/r,w=void 0!==s&&Math.abs(e.y+Xt-s)<=8/o;A&&B?m=e.x:(m=e.x+Vt,Vt=0),t&&w?f=e.y:(f=e.y+Xt,Xt=0)}return Zt(m,f,e.width,e.height,e.rotation,s)&&(Y=f),qt(m,f,e.width,e.height,e.rotation,s)&&(M=m),{top:Y,left:M,width:e.width,height:e.height,rotation:e.rotation}}})(A,t,e,n,i,a,s),o=[];if(e.type===l.Textbox){const A=e;o.push(new D(A.id,A.input||A.text||""))}if(r.width>0&&r.height>0&&(o.push(new E(e.id,r.left,r.top),new d(e.id,r.width,r.height),new Q(e.id,r.rotation)),e.type===l.Textbox)){const A=e;r.fontSize&&A.fontSize!==r.fontSize&&o.push(new c(A.id,r.fontSize))}return o},Ae=A=>{const{onPointerDown:t,scaleFactor:e,elementWidth:n}=A,i=UA((A=>{A.stopPropagation(),t&&t(A)}),[t]),a=13*e;return zA("g",{transform:`translate(${30*e})`,children:[OA("circle",{cx:n/2,cy:-2.5*a,r:1.3*a,fill:"transparent",style:{cursor:"pointer"},onPointerDown:i}),zA("svg",{onPointerDown:i,x:n/2-a,y:-2.5*a-a,width:2*a,height:2*a,style:{cursor:"pointer"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[OA("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"}),OA("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"})]})]})},te="#ffffff",ee=A=>{const{isMobile:t,outerRadius:e,x:n,y:i,cursorStyle:a,onPointerDown:s,handleClass:r,cornerRadius:o,color:c,strokeWidth:g}=A,[B,w]=RA(!1);GA((()=>{const A=()=>{w(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const l=UA((A=>{w(!0),s(A)}),[s]);return t?zA(LA,{children:[OA("circle",{cx:n,cy:i,r:e,fill:B?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:a},onPointerDown:l}),OA("circle",{className:r,cx:n,cy:i,r:o,fill:te,style:{cursor:a,pointerEvents:"none"},stroke:c,strokeWidth:g})]}):OA("circle",{className:r,cx:n,cy:i,r:o,fill:te,style:{cursor:a},stroke:c,strokeWidth:g,onPointerDown:s})},ne=A=>{const{isMobile:t,outerRadius:e,outerWidth:n,outerHeight:i,x:a,y:s,width:r,height:o,cursorStyle:c,onPointerDown:g,edgeHandleRadius:B,color:w,strokeWidth:l}=A,[E,d]=RA(!1);GA((()=>{const A=()=>{d(!1)};return document.addEventListener("pointerup",A),()=>{document.removeEventListener("pointerup",A)}}),[]);const Q=UA((A=>{d(!0),g(A)}),[g]);return t?zA(LA,{children:[OA("rect",{x:a-(n-r)/2,y:s-(i-o)/2,width:n,height:i,rx:e,fill:E?"rgba(0,0,0,0.5)":"rgba(0,0,0,0)",style:{cursor:c},onPointerDown:Q}),OA("rect",{x:a,y:s,width:r,height:o,rx:B,fill:te,style:{cursor:c,pointerEvents:"none"},stroke:w,strokeWidth:l})]}):OA("rect",{x:a,y:s,width:r,height:o,rx:B,fill:te,style:{cursor:c},stroke:w,strokeWidth:l,onPointerDown:g})},ie=A=>{const{isMobile:t,color:e,elementHeight:n,elementWidth:i,onBeginResize:a,rotation:s,scaleFactor:r,disableX:o,disableY:c}=A,g=7.5*r,B=3*r,w=28*r,l=6*r,E=30*r,d=5*r,Q=40*r,C=36*r,h=1.2*r,I=UA(((A,t,e)=>{A.stopPropagation(),a(t,e)}),[a]),D=UA((A=>I(A,X(z.West,360-s),z.West)),[I,s]),u=UA((A=>I(A,X(z.East,360-s),z.East)),[I,s]),p=UA((A=>I(A,X(z.North,360-s),z.North)),[I,s]),m=UA((A=>I(A,X(z.South,360-s),z.South)),[I,s]),f=UA((A=>I(A,z.Northwest,z.Northwest)),[I]),M=UA((A=>I(A,z.Northeast,z.Northeast)),[I]),F=UA((A=>I(A,z.Southwest,z.Southwest)),[I]),Y=UA((A=>I(A,z.Northeast,z.Southeast)),[I]),y=(t?n-2*E-Q:n-2*g-w)>0&&(t?i-2*E-Q:i-2*g-w)>0;return zA(LA,{children:[OA(ee,{isMobile:t,outerRadius:E,x:0,y:0,cursorStyle:"nw-resize",onPointerDown:f,handleClass:"cornerNorthWest",cornerRadius:g,color:e,strokeWidth:h}),y?OA(ee,{isMobile:t,outerRadius:E,x:i,y:0,cursorStyle:"ne-resize",onPointerDown:M,handleClass:"cornerNorthEast",cornerRadius:g,color:e,strokeWidth:h}):void 0,y?OA(ee,{isMobile:t,outerRadius:E,x:i,y:n,cursorStyle:"se-resize",onPointerDown:Y,handleClass:"cornerSouthEast",cornerRadius:g,color:e,strokeWidth:h}):void 0,y?OA(ee,{isMobile:t,outerRadius:E,x:0,y:n,cursorStyle:"sw-resize",onPointerDown:F,handleClass:"cornerSouthWest",cornerRadius:g,color:e,strokeWidth:h}):void 0,y&&!o?OA(ne,{isMobile:t,outerRadius:d,outerWidth:C,outerHeight:Q,x:-l/2,y:n/2-w/2,width:l,height:w,onPointerDown:D,edgeHandleRadius:B,cursorStyle:"w-resize",color:e,strokeWidth:h}):void 0,y&&!c?OA(ne,{isMobile:t,outerRadius:d,outerWidth:Q,outerHeight:C,x:i/2-w/2,y:n-l/2,width:w,height:l,onPointerDown:m,edgeHandleRadius:B,cursorStyle:"s-resize",color:e,strokeWidth:h}):void 0,o?void 0:OA(ne,{isMobile:t,outerRadius:d,outerWidth:C,outerHeight:Q,x:i-l/2,y:n/2-Math.min(w,.8*n)/2,width:l,height:Math.min(w,.8*n),onPointerDown:u,edgeHandleRadius:B,cursorStyle:"e-resize",color:e,strokeWidth:h}),y&&!c?OA(ne,{isMobile:t,outerRadius:d,outerWidth:Q,outerHeight:C,x:i/2-w/2,y:-l/2,width:w,height:l,onPointerDown:p,edgeHandleRadius:B,cursorStyle:"n-resize",color:e,strokeWidth:h}):void 0]})},ae=A=>{const{isMobile:t,color:e,elementWidth:n,onBeginRotate:i,scaleFactor:a}=A,s=UA((A=>{A.stopPropagation(),i()}),[i]),r=13*a;return zA("g",{transform:t?`translate(${-(30*a)})`:void 0,children:[OA("circle",{cx:n/2,cy:-2.5*r,r:1.3*r,fill:"transparent",style:{cursor:"ew-resize"},onPointerDown:s}),zA("svg",{x:n/2-r,y:-2.5*r-r,xmlns:"http://www.w3.org/2000/svg",style:{cursor:"ew-resize"},height:2*r,viewBox:"0 0 24 24",width:2*r,stroke:e,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",onPointerDown:s,children:[" ",OA("polyline",{points:"23 4 23 10 17 10"})," ",OA("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})]})},se="spiffElementID",re=({color:A,height:t,highlighted:e,id:n,immutable:i,onBeginMove:a,onPointerEnter:s,onPointerLeave:r,onSelected:o,pressed:c,rotation:g,scaleFactor:B,selected:w,width:l,x:E,y:d})=>{const Q=1.2*B,{addEvent:C,removeEvent:h,curActiveEvents:I}=yt(),D=UA((A=>{C(A),A[se]=n;0===I&&0===A.button&&(o(n,A),a())}),[n,w,I,o,a]),u=UA((A=>{h(A)}),[]),p=UA((A=>{s(n)}),[n,I,s]),m=UA((A=>{h(A),r(n)}),[n,I,r]);return OA("g",{transform:`translate(${E}, ${d}) rotate(${g} ${l/2} ${t/2})`,children:OA("rect",{className:"interactableInnerRect",width:l,height:t,stroke:w||e?A:"none",pointerEvents:i?"none":"visibleFill",fill:"none",strokeWidth:Q,style:{cursor:i?void 0:w?c?"grabbing":"grab":"pointer"},onPointerDown:i?void 0:D,onPointerUp:i?void 0:u,onPointerEnter:i?void 0:p,onPointerLeave:i?void 0:m})})},oe=A=>{const{isMobile:t,color:e,height:n,onBeginResize:i,onBeginRotate:a,onContextMenuHandlePointerDown:s,rotation:r,scaleFactor:o,width:c,x:g,y:B,disableX:w,disableY:l}=A;return zA("g",{transform:`translate(${g}, ${B}) rotate(${r} ${c/2} ${n/2})`,children:[OA(ae,{isMobile:t&&!!s,color:e,elementWidth:c,onBeginRotate:a,scaleFactor:o}),t&&s&&OA(Ae,{onPointerDown:s,elementWidth:c,scaleFactor:o}),OA(ie,{isMobile:t,color:e,elementHeight:n,elementWidth:c,rotation:r,scaleFactor:o,onBeginResize:i,disableX:w,disableY:l})]})},ce=.5,ge=["TEXTAREA","INPUT"],Be=(A,t,e,n,i,a,r,o)=>{const{state:c,uiDispatcher:g}=HA(Ut),{getLayoutById:w,getReducerState:l,flattenSequence:E}=Nt(),[d,Q]=RA(void 0),[C,h]=RA(void 0),[I,D]=RA(void 0),[u,p]=RA(null),m=w(c.layoutId);GA((()=>{if("adjustment"===i&&A?.current&&n){if(n<ce)return void g(new Gt({zoom:ce}));if(n>c.maxZoom)return void g(new Gt({zoom:c.maxZoom}));g(new Gt({zoom:n}))}}),[n,g,A,i,c.maxZoom]);const f=UA(((A,n)=>{g(new Gt({zoom:n}));const a=t?.current?.scrollWidth-t?.current?.clientWidth!=0,s=t?.current?.scrollHeight-t?.current?.clientHeight!=0;t.current&&e.current&&!c.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))}),[g,t,e,c.scrolledMovement,i]);GA((()=>{c.zoom<=1&&g(new Gt({scrolledMovement:!1}))}),[g,c.zoom]);const F=t?.current?.getBoundingClientRect(),Y=((F?.width||1)+(F?.height||1))/2,y=(m.layoutState.layout.width+m.layoutState.layout.height)/2/Y/c.zoom,N=bA((()=>{const A=c.activeModifierKeys,t=c.elementEvent,e=A.includes(Tt.ControlLeft)||A.includes(Tt.MetaLeft)||A.includes(Tt.ControlRight)||A.includes(Tt.MetaRight);if(!c.selectedElement||!t||e)return[];const n=t&&t.type===zt.Translate,i=t&&t.type===zt.Rotate,a=m.layoutState.elements.find((A=>A.id===c.selectedElement));return(n||i)&&a?Ot(a,m.layoutState,y,r):[]}),[c.selectedElement,c.elementEvent,c.activeModifierKeys,m.layoutState,y]),v=UA((()=>{const A=M();Q(A),h(l().transaction)}),[l]),x=UA((A=>{p(A.target),A[se]||(p(null),g(new Gt({selectedElement:void 0})))}),[c,g]),S=UA((()=>{g(new Gt({scrolledMovement:!0}))}),[g]),P=UA(((e,n)=>{const i=m.layoutState.elements.find((A=>A.id===c.selectedElement)),s=u?.getBoundingClientRect();if(!(c.elementEvent&&A.current&&t.current&&c.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(),o=new B(_t({deltaX:I?e.screenX-I.screenX:0,deltaY:I?e.screenY-I.screenY:0,destX:e.clientX,destY:e.clientY,targetRect:s},m.layoutState.layout,i,r,c.elementEvent,N,n));o.sequenceId=d,a(o,!1),D({screenX:e.screenX,screenY:e.screenY})}),[m.layoutState.elements,m.layoutState.layout,c.elementEvent,A,c.selectedElement,t,N,a,I]),R=UA((A=>{g(new Gt({elementEvent:A}))}),[g]),U=UA((()=>{R(void 0),d&&C&&(E(d,C),Q(void 0),h(void 0),o&&o()),D(void 0)}),[R,d,C,E,o]),H=UA(((A,t)=>{let e=c.zoom;const n=c.maxZoom,r=c.selectedElement,o=c.activeModifierKeys;if((o.includes(Tt.AltLeft)||o.includes(Tt.AltRight))&&(A.code===Tt.Equal||A.code===Tt.Minus)){const t=.05*n;A.code===Tt.Equal?g(new Gt({zoom:e+t<=n?e+=t:e})):g(new Gt({zoom:e-t>=ce?e-t:e}))}const B=m.layoutState.elements.find((A=>A.id===r));if(r&&B){if(A.code===Tt.MetaLeft||A.code===Tt.ControlLeft||A.code===Tt.MetaRight||A.code===Tt.ControlRight){const t=A.code,e=c.activeModifierKeys;if(!e.includes(t))return g(new Gt({activeModifierKeys:e.concat(t)}))}if(A.code===Tt.ArrowDown||A.code===Tt.ArrowUp||A.code===Tt.ArrowLeft||A.code===Tt.ArrowRight){g(new Gt({elementEvent:{type:zt.Translate}}));const e=Kt(A.code,B,c.units,t);a(e,!1),g(new Gt({elementEvent:void 0}))}A.code!==Tt.Delete&&A.code!==Tt.Backspace||"advanced"!==i||(g(new Gt({selectedElement:void 0})),a(new s(B.id),!1))}}),[a,g,m.layoutState.elements,i,c.activeModifierKeys,c.maxZoom,c.selectedElement,c.units,c.zoom]),G=UA((A=>{if(A.code===Tt.MetaLeft||A.code===Tt.ControlLeft||A.code===Tt.MetaRight||A.code===Tt.ControlRight){const t=c.activeModifierKeys,e=A.code;g(new Gt({activeModifierKeys:t.filter((A=>A!==e))}))}}),[g,c.activeModifierKeys]);return{guidelines:N,scale:y,zoomableElementRef:e,setElementEvent:R,handleZoom:f,handleKeyDown:H,handleKeyUp:G,handlePointerPressedBackground:x,handlePointerReleased:U,handlePointerMove:P,handleScroll:S,handleSequenceStart:v}},we=(A,t,e)=>{const n=bA((()=>[...new Set(A)].map((A=>String(A).toLowerCase()))),[]),i=kA([]),a=UA((()=>{const A=n.every((A=>i.current.includes(A))),t=i.current.length===n.length;return A&&t}),[]),s=UA((A=>{const e=String(A.key).toLowerCase();if(A.repeat||"meta"===e)return;const n=A.target;return!(ge.indexOf(n.tagName)>=0)&&(i.current=[...new Set([...i.current,e])],a()&&t(),A.preventDefault())}),[a,n,t,A]),r=UA((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]);GA((()=>(window.addEventListener("keydown",s),window.addEventListener("keyup",r),()=>{window.removeEventListener("keydown",s),window.removeEventListener("keyup",r)})),[s,r])},le=A=>{const{isMobile:t,primaryColor:e,customViewbox:n,editorRef:i,elementEvent:a,guidelines:s,layoutHeight:r,layoutWidth:o,targetedElements:c,scale:g,selectedElement:B,onElementEvent:w,onElementSelected:E,onSequenceStart:d,onMouseMove:Q,onContextMenuHandlePointerDown:C}=A,{state:h}=Jt(),{getLayoutById:I}=Nt(),D=I(h.layoutId),[u,p]=RA(void 0),m=UA((A=>{p(A)}),[]),f=UA((A=>{u===A&&p(void 0)}),[u]),M=UA((()=>{d(),w({type:zt.Translate})}),[w]),F=UA(((A,t)=>{d(),w({type:zt.Resize,relativeAxis:A,screenAxis:t})}),[w]),Y=UA((()=>{d(),w({type:zt.Rotate})}),[w]),y=n||{x:0,y:0,width:o,height:r},N=D.layoutState.elements,v=N.find((A=>A.id===B));return zA("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:[OA("rect",{onMouseMove:Q,style:{pointerEvents:"all"},fill:"none",stroke:"none",ref:i,width:o,height:r}),s.map((A=>A.svgNode)),N.map((A=>{const t=void 0!==B&&A.id===B,n=t&&void 0!==a,i=void 0!==u&&A.id===u;return OA(re,{color:e,id:A.id,selected:t,highlighted:i,pressed:n,x:A.x,y:A.y,width:A.width,height:A.height,rotation:A.rotation,immutable:A.immutable||c&&!c.includes(A.id),onSelected:E,onBeginMove:M,onPointerEnter:m,onPointerLeave:f,scaleFactor:g},A.id)})),v&&OA(oe,{isMobile:t,color:e,x:v.x,y:v.y,disableX:v.type===l.Frame||v.type===l.Image,disableY:v.type===l.Textbox||v.type===l.Frame||v.type===l.Image,width:v.width,height:v.height,rotation:v.rotation,onBeginResize:F,onBeginRotate:Y,scaleFactor:g,onContextMenuHandlePointerDown:C})]})},Ee=A=>{const{isMobile:t,color:e,outlineColor:n,editorRef:i,zoomableElementRef:a,interactionElementRef:s,guidelines:r,isMakingAdjustments:o,outlineArea:c,visibleLayoutId:g,xTranslation:B,yTranslation:w,targetedElements:l,borderRadius:E,canvasFilter:d,handleContextMenu:Q,onMouseMove:C,onContextMenuHandlePointerDown:h,handleKeyDown:I,handleKeyUp:D,handlePointerMove:u,handlePointerPressedBackground:p,handlePointerReleased:m,handleScroll:f,onSequenceStart:M,setElementEvent:F,onElementSelected:Y}=A,{getLayoutById:y}=Nt(),N=y(g),v=N.layoutState,{state:x}=Jt(),S=UA((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 I(A,t)}return I(A)}),[I,c]),P=UA((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 u(A,t)}return u(A)}),[u,c]),R=bA((()=>{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}),[]),U=bA((()=>({height:"100%",transform:`scale(${x.zoom}) translate(${B}px, ${w}px)`,display:"flex",justifyContent:"center",alignItems:"center",filter:d||"drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2))",overflow:"visible"})),[x.zoom,x.xTranslation,x.yTranslation]),H=10/x.zoom,G=v.layout.width,J=v.layout.height,b=a.current?.offsetHeight||1024,k=a.current?.offsetWidth||1024,O=H*(Math.sqrt(G*J)/1e3)*(100/Math.sqrt(b*k))*Math.sqrt((z=k/b,Math.exp(Math.abs(Math.log(z)))));var z;const L=bA((()=>({configuration:{purpose:W.FreeDesign},height:o?"100%":"auto",width:o?"100%":"auto",maxHeight:"100%",maxWidth:"100%",position:"absolute",outlineArea:c?{...c,scale:O}:void 0,borderRadius:E,outlineColor:n})),[o,O]);return OA("div",{style:R,onContextMenu:Q,onKeyDown:S,onKeyUp:D,onPointerDown:p,onMouseLeave:m,onPointerMoveCapture:P,onPointerUp:m,onWheelCapture:f,ref:s,tabIndex:-1,children:zA("div",{ref:a,style:U,children:[A.children,N.getComponentWithProps(L),OA(le,{isMobile:t,primaryColor:e,editorRef:i,elementEvent:x.elementEvent,guidelines:r,layoutHeight:v.layout.height,layoutWidth:v.layout.width,onElementEvent:F,onSequenceStart:M,onElementSelected:Y,scale:O,selectedElement:x.selectedElement,targetedElements:l,onMouseMove:C,onContextMenuHandlePointerDown:h})]})})},de=({isMobile:A,color:t,outlineColor:e,borderRadius:n,guidelineColor:i,canvasFilter:a,hideEditableAreaRect:s,handleContextMenu:r,onMouseMove:o,onContextMenuHandlePointerDown:c,onElementSelected:g,onDragEnd:B})=>{const{commandDispatcher:w,getLayoutById:E}=Nt(),{state:d,uiDispatcher:Q}=Jt(),C=kA(null),h=kA(null),I=kA(null),{guidelines:D,handleKeyDown:u,handleKeyUp:p,handlePointerMove:m,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:F,handleSequenceStart:Y,setElementEvent:y}=Be(C,h,I,void 0,"advanced",w,i,B),N=bA((()=>E(d.layoutId)),[E,d.layoutId]),v=UA(((A,t)=>{const e=N.layoutState.elements.find((t=>t.id===A));if(A&&e&&e.type===l.Textbox){const t=e.algorithm;(!t||t===G.Autosize)&&w(new J(A,G.Traditional),!0)}g&&g(A,t),Q(new Gt({selectedElement:A}))}),[w,E,d.layoutId,Q]),x=bA((()=>{if(N.layoutState.layout.useEditableArea)return{...N.layoutState.layout.editableArea,hidden:s}}),[N.layoutState.layout.useEditableArea,N.layoutState.layout.editableArea,s]);return OA(Ee,{outlineArea:x,isMobile:A,color:t,outlineColor:e,editorRef:C,interactionElementRef:h,zoomableElementRef:I,guidelines:D,visibleLayoutId:d.layoutId,xTranslation:d.xTranslation,yTranslation:d.yTranslation,borderRadius:n,canvasFilter:a,handleContextMenu:r,onMouseMove:o,onContextMenuHandlePointerDown:c,handleKeyDown:u,handleKeyUp:p,handlePointerMove:m,handlePointerPressedBackground:f,handlePointerReleased:M,handleScroll:F,onSequenceStart:Y,setElementEvent:y,onElementSelected:v})},Qe=NA`
2
2
  mutation CreateTransaction($integrationProductId: String!, $bulk: Boolean) {
3
3
  transactionCreate(integrationProductId: $integrationProductId, bulk: $bulk) {
4
4
  id
package/dist/types.d.ts CHANGED
@@ -1131,6 +1131,7 @@ export const useShortcutCombination: (shortcutKeys: string[], onCombinationPress
1131
1131
  export const EditorCore: FunctionComponent<{
1132
1132
  isMobile: boolean;
1133
1133
  color?: string;
1134
+ outlineColor?: string;
1134
1135
  editorRef: RefObject<SVGRectElement>;
1135
1136
  zoomableElementRef: RefObject<HTMLDivElement>;
1136
1137
  interactionElementRef: RefObject<HTMLDivElement>;
@@ -1169,6 +1170,7 @@ export const EditorCore: FunctionComponent<{
1169
1170
  export const AdvancedEditor: FunctionComponent<{
1170
1171
  isMobile: boolean;
1171
1172
  color?: string;
1173
+ outlineColor?: string;
1172
1174
  guidelineColor?: string;
1173
1175
  borderRadius?: number;
1174
1176
  canvasFilter?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "0.10.166",
3
+ "version": "0.10.167",
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.49",
82
+ "@spiffcommerce/papyrus": "^1.5.50",
83
83
  "canvg": "https://github.com/spiffdev/canvg.git#03bcd151b12441e88ecb552bb658356f5bbe92c4",
84
84
  "cross-fetch": "^3.1.5",
85
85
  "graphql": "^16.6.0",