@spiffcommerce/core 26.7.3 → 26.7.4

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("@apollo/client/core"),Un=require("@apollo/client/link/context"),Gn=require("@apollo/client/link/error"),Tn=require("preact-render-to-string"),Jn=require("@apollo/client/link/remove-typename"),Ln=require("exifr/dist/mini.umd.cjs"),na=require("css"),On=require("fuse.js"),cA=require("pith"),xt=require("lodash.clonedeep"),ia=require("qrcode"),lA=require("svg-path-bbox"),je=require("opentype.js"),S=require("preact/jsx-runtime"),zn=require("data-uri-to-buffer"),JA=require("lodash.chunk"),sa=require("lodash.isequal"),Ve=require("unicode-default-word-boundary"),oa=require("lodash.debounce");var Kt=(n=>(n.Data="Data",n.Font="Font",n.Frame="Frame",n.Illustration="Illustration",n.Image="Image",n.Model="Model",n.Material="Material",n.Color="Color",n.QuestionnaireCollateral="QuestionnaireCollateral",n.RequestCollateral="RequestCollateral",n.SignupCollateral="SignupCollateral",n.Video="Video",n.ColorProfile="ColorProfile",n.Environment="Environment",n))(Kt||{}),nt=(n=>(n.FileUpload="FileUpload",n.Option="Option",n.ColorOption="ColorOption",n.Text="Text",n))(nt||{}),M=(n=>(n.Information="Information",n.Bulk="Bulk",n.DigitalContent="DigitalContent",n.Finish="Finish",n.Frame="Frame",n.Illustration="Illustration",n.Introduction="Introduction",n.Material="Material",n.Model="Model",n.Module="Module",n.Picture="Picture",n.Photo="Photo",n.ProductOverlay="ProductOverlay",n.Question="Question",n.Shape="Shape",n.SilentIllustration="SilentIllustration",n.Text="Text",n))(M||{}),ra=(n=>(n.Color="Color",n.Colors="Colors",n.Selection="Selection",n.Selections="Selections",n.Text="Text",n.Upload="Upload",n))(ra||{}),Pt=(n=>(n.ThreeD="ThreeD",n.FreeDesign="FreeDesign",n.Print="Print",n))(Pt||{}),N=(n=>(n.Frame="frame",n.Group="group",n.Image="image",n.Pattern="pattern",n.Illustration="illustration",n.Textbox="textbox",n))(N||{}),ca=(n=>(n.Hyperlink="Hyperlink",n.Edit="Edit",n.Approve="Approve",n))(ca||{}),la=(n=>(n.Hub="Hub",n.Shopify="Shopify",n))(la||{}),Qe=(n=>(n.BackgroundRemover="BackgroundRemover",n.ConversionAccelerator="Conversion Accelerator",n.ProcessBuilder="ProcessBuilder",n))(Qe||{}),ga=(n=>(n[n.Orbit=0]="Orbit",n[n.Pan=1]="Pan",n))(ga||{}),da=(n=>(n.Manual="Manual",n.OnStart="OnStart",n.OnQuit="OnQuit",n.OnEnd="OnEnd",n))(da||{}),Ba=(n=>(n.Email="Email",n.FirstName="FirstName",n.LastName="LastName",n.Phone="Phone",n))(Ba||{}),Wt=(n=>(n.Owner="Owner",n.Approver="Approver",n.Editor="Editor",n.Viewer="Viewer",n))(Wt||{}),pt=(n=>(n.Autosize="Autosize",n.Traditional="Traditional",n))(pt||{}),K=(n=>(n[n.North=0]="North",n[n.Northeast=1]="Northeast",n[n.East=2]="East",n[n.Southeast=3]="Southeast",n[n.South=4]="South",n[n.Southwest=5]="Southwest",n[n.West=6]="West",n[n.Northwest=7]="Northwest",n))(K||{}),ha=(n=>(n.Pixel="px",n.Millimeter="mm",n.Centimeter="cm",n))(ha||{});class Ca extends Error{constructor(t){super(t),this.name=this.constructor.name}}class _t extends Ca{constructor(t){super(`ConfigurationError - ${t}`)}}class Xt extends _t{constructor(t){super(`Option not Configured: ${t.stepTitle}`),this.optionId=(t==null?void 0:t.optionId)||"N/A"}}class X extends _t{constructor(t){super(`Panel not Found: ${t.panelId}`),this.panelId=(t==null?void 0:t.panelId)||"N/A"}}class Bt extends _t{constructor(t){super(`Asset not found for variant: ${t.name}`),this.variant=t}}class vt extends _t{constructor(t){super(`Resource not found for asset: ${t.name}`),this.asset=t}}class qt extends _t{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),this.step=t}}class pe extends Ca{constructor(t){super(`ImplementationError - ${t}`)}}class L extends pe{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class mt extends pe{constructor(t){super(`Parsing Error: ${t}`)}}class lt extends pe{constructor(t){super(`Client Error: ${t}`)}}class Ie extends pe{constructor(t){super(`Resource Generation Failed: ${t}`)}}class jn{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}class LA{constructor(){this.storage=new Map}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}const Vn=()=>{try{return localStorage?new jn:new LA}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new LA}},k=Vn();class Kn{constructor(){this.defaultServerUrl="https://api.au.spiffcommerce.com",this.defaultServicesApiUrl="https://services.au.spiffcommerce.com",this.defaultHubUrl="https://hub.au.spiffcommerce.com",this.serverUrl=this.defaultServerUrl,this.servicesApiUrl=this.defaultServicesApiUrl,this.hubUrl=this.defaultHubUrl,this.serverUrlCallbacks=[]}getServerUrl(){return this.serverUrl}getServicesApiUrl(){return this.servicesApiUrl}getHubUrl(){return this.hubUrl}setServerUrl(t){this.serverUrl=t,this.serverUrlCallbacks.forEach(e=>e())}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}}const dt=new Kn;let Ke,We;function Wn(n){Ke=n}function Xn(n){We=n}function te(){return Ke?new Ke().window:(console.log("DOM constructor is not registered. Assuming browser environment. If not, please register DOM constructor before calling this function."),window)}function ot(n,t){if(!We){if(typeof window<"u"&&window.fetch)return window.fetch(n,t);if(typeof global<"u"&&global.fetch)return global.fetch(n,t);throw new Error("Fetch implementation is not registered. Please register it before calling this function.")}return We(n,t)}const ua=new Map,OA=new Map,zA=new Map,wa=async n=>{const t=OA.get(n);if(t)return t;const A=(async()=>{var i;const a=await ot(n);return ua.set(n,((i=a.headers)==null?void 0:i.get("content-type"))||""),await a.arrayBuffer()})();return OA.set(n,A),A},qn=async n=>{const t=zA.get(n);if(t)return t;const A=(async()=>await(await ot(n)).text())();return zA.set(n,A),A},Rt=n=>n.every(t=>t!=="undefined"),ce=n=>Rt([typeof document])?document.createElement(n):te().document.createElement(n),Zn=(n,t)=>{if(Rt([typeof document]))return document.createElementNS(n,t);const A=te().document.createElement(t);return A.setAttribute("xmlns",n),A},it=()=>{if(Rt([typeof DOMParser]))return new DOMParser;const n=te();return new n.DOMParser},$n=()=>Rt([typeof DOMParser])?DOMParser:te().DOMParser,De=(n,t)=>new Promise((e,A)=>{t?wa(n).then(e).catch(A):ot(n).then(a=>{a.arrayBuffer().then(e).catch(A)}).catch(a=>{A(a)})}),_=(n,t)=>new Promise((e,A)=>{t?qn(n).then(e).catch(A):ot(n).then(a=>{a.text().then(e).catch(A)}).catch(A)}),Ea=n=>Tn.renderToStaticMarkup(n),ke=new Map,_n=async(n,t)=>{if(Rt([typeof FontFace])){if(ke.has(t))return ke.get(t);const e=n.names.fullName.en,A=new FontFace(e,`url(${t})`);document.fonts.add(A);const a=A.load();return ke.set(t,a),a}},wt=()=>{if(Rt([typeof XMLSerializer]))return new XMLSerializer;const n=te();return new n.XMLSerializer},jA=n=>btoa(n),ee=n=>{function t(){const A=new Uint8Array(n),a=4;if(A.length>=a){const i=new Array(a);for(let r=0;r<a;r++)i[r]=new Uint8Array(n)[r].toString(16);const s=i.join("").toUpperCase();switch(s){case"89504E47":return"image/png";case"47494638":return"image/gif";case"25504446":return"application/pdf";case"504B0304":return"application/zip"}switch(s.slice(0,4)){case"FFD8":return"image/jpeg"}}return null}const e=t();return e||"image/svg+xml"},ti=async n=>{const t=await wa(n),e=ua.get(n)||ee(t);return await ai(new Blob([t],{type:e}))},ei=n=>{let t="";const e=n.byteLength;for(let A=0;A<e;A++)t+=String.fromCharCode(n[A]);return t},Ai=async n=>{const t=ee(n),e=new Uint8Array(n),A=ei(e),a=btoa(A);return`data:${t};base64,${a}`},gA=n=>`data:image/svg+xml;base64,${btoa(n)}`,ma=n=>{const t=n.replace(/\r?\n/g,""),e=t.indexOf(",");if(e===-1||e<=4)throw new TypeError("malformed data: URI");const A=t.substring(5,e).split(";");let a=!1;for(let s=1;s<A.length;s++)A[s]==="base64"&&(a=!0);const i=decodeURI(t.substring(e+1));return a?new Uint8Array(atob(i).split("").map(o=>o.charCodeAt(0))).buffer:new Uint8Array(i.split("").map(o=>o.charCodeAt(0))).buffer},ai=n=>new Promise((t,e)=>{const A=new FileReader;A.onload=function(a){const i=a.target;!i||!i.result?e():t(i.result.toString())},A.readAsDataURL(n)});let fa;const VA=n=>{fa=n};let dA;const ni=n=>{dA=n},ii=()=>dA;let Qa;const pa=n=>{Qa=n},si=()=>new Promise(n=>{const t=dt.getHubUrl(),e=A=>{A.origin===t&&(window.removeEventListener("message",e),n(A.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))}),oi=async()=>{const n={applicationKey:dA,customerToken:fa,bearer:Qa};return typeof window<"u"&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await si(),...n}:n};class ri{constructor(){this.shadowGraphqlClient=this.constructShadowGraphqlClient(),dt.addServerUrlCallback(()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()})}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const t=Q.createHttpLink({uri:`${dt.getServerUrl()}/graphql`,fetch:ot}),e=Un.setContext(async(i,s)=>{const{headers:o}=s,r=o||{},c=await oi(),l=s.bearer??c.bearer,g=s.partnerId??c.partnerId,d=s.activeIntegration??c.activeIntegration,B=s.transactionOwnerId,h=s.customerToken??c.customerToken,C=s.applicationKey??c.applicationKey,u=s.bundleOwnerId;try{if(window&&window.__SENTRY__){const w=window.__SENTRY__.hub;if(w){const E=w.traceHeaders();Object.entries(E).forEach(([m,f])=>{r[m]=f})}}}catch{}return l&&(r.Authorization=`Bearer ${l}`),g&&(r.partnerId=g),d&&(r.activeIntegration=d),B&&(r.transactionOwnerId=B),h&&(r.customerToken=h),C&&(r["X-Application-Key"]=C),u&&(r.bundleOwnerId=u),{headers:r}}),A=Gn.onError(({operation:i,graphQLErrors:s,networkError:o})=>{const r=s||[];o&&console.log("GraphQL Network error"),r.forEach(()=>console.log("GraphQL Error: "+i.operationName))}),a=Jn.removeTypenameFromVariables();return new Q.ApolloClient({link:Q.from([a,A,e,t]),cache:new Q.InMemoryCache,name:"Core"})}}const y=new ri;let Xe,qe;const ht=(n,t,e)=>{if(Xe!==void 0)return Xe(n,t,e);try{const A=Ia(!0);return BA(A),A.createCanvas(n,t,e)}catch{throw new Error("Canvas module not set")}},Ae=(n,t)=>{if(qe!==void 0)return qe(n,t);try{const e=Ia(!0);return BA(e),e.loadImage(n,t)}catch{throw new Error("Canvas module not set")}};function BA(n){Xe=n==null?void 0:n.createCanvas,qe=n==null?void 0:n.loadImage}function Ia(n){try{if(document.createElement("canvas").getContext("2d"))return{createCanvas:(e,A,a)=>{const i=document.createElement("canvas");return e!=null&&(i.width=e),A!=null&&(i.height=A),i},loadImage:(e,A)=>new Promise((a,i)=>{const s=document.createElement("img");A!==!1&&(s.crossOrigin="Anonymous"),s.onload=()=>{a(s)},s.onerror=i,s.src=e})}}catch(t){if(n)throw t}}let Ne;function hA(){return Ne===void 0&&(Ne=$n()),Ne}let le=null;const ci=n=>new Promise(t=>{if(ee(n)!=="image/jpeg")return t(1);Ln.orientation(n).then(A=>t(A||1)).catch(()=>t(1))}),li=async()=>{if(le!==null)return!le;const t=await Ae("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return le=t.width===2&&t.height===3,!le},gi=n=>{const e=n.naturalWidth/n.naturalHeight;return n.naturalHeight<=8192&&n.naturalWidth<=8192?[n.naturalWidth,n.naturalHeight]:n.naturalHeight>n.naturalWidth?[e*8192,8192]:[8192,8192/e]},di=async n=>{var g;const t=await Ai(n),e=await Ae(t),[A,a]=gi(e);if(!await li()){const d=ht(A,a);return(g=d.getContext("2d"))==null||g.drawImage(e,0,0,A,a),d}const s=await ci(n),[o,r]=s>4?[a,A]:[A,a],c=ht(o,r),l=c.getContext("2d");switch(s){case 2:l.translate(o,0),l.scale(-1,1);break;case 3:l.translate(o,r),l.rotate(Math.PI);break;case 4:l.translate(0,r),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(-o,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-o,r),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-r);break}return l.drawImage(e,0,0,o,r),c},ae=async n=>{const t=await di(n);return ee(n)==="image/jpeg"?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}},Zt=["Yellow C","Yellow 012 C","Orange 021 C","Warm Red C","Red 032 C","Rubine Red C","Rhodamine Red C","Purple C","Violet C","Blue 072 C","Reflex Blue C","Process Blue C","Green C","Black C","Yellow 0131 C","Red 0331 C","Magenta 0521 C","Violet 0631 C","Blue 0821 C","Green 0921 C","Black 0961 C","801 C","802 C","803 C","804 C","805 C","806 C","807 C","871 C","872 C","873 C","874 C","875 C","876 C","877 C","Medium Yellow C","Bright Orange C","Bright Red C","Strong Red C","Pink C","Medium Purple C","Dark Blue C","Medium Blue C","Bright Green C","Neutral Black C","100 C","101 C","102 C","103 C","104 C","105 C","7401 C","7402 C","7403 C","7404 C","7405 C","7406 C","7407 C","106 C","107 C","108 C","109 C","110 C","111 C","112 C","113 C","114 C","115 C","116 C","117 C","118 C","119 C","127 C","128 C","129 C","130 C","131 C","132 C","133 C","1205 C","1215 C","1225 C","1235 C","1245 C","1255 C","1265 C","120 C","121 C","122 C","123 C","124 C","125 C","126 C","7548 C","7549 C","7550 C","7551 C","7552 C","7553 C","7554 C","7555 C","7556 C","7557 C","7558 C","7559 C","7560 C","7561 C","134 C","135 C","136 C","137 C","138 C","139 C","140 C","1345 C","1355 C","1365 C","1375 C","1385 C","1395 C","1405 C","141 C","142 C","143 C","144 C","145 C","146 C","147 C","7408 C","7409 C","7410 C","7411 C","7412 C","7413 C","7414 C","7562 C","7563 C","7564 C","7565 C","7566 C","7567 C","7568 C","7569 C","7570 C","7571 C","7572 C","7573 C","7574 C","7575 C","712 C","713 C","714 C","715 C","716 C","717 C","718 C","148 C","149 C","150 C","151 C","152 C","153 C","154 C","155 C","156 C","157 C","158 C","159 C","160 C","161 C","1485 C","1495 C","1505 C","1525 C","1535 C","1545 C","1555 C","1565 C","1575 C","1585 C","1595 C","1605 C","1615 C","162 C","163 C","164 C","165 C","166 C","167 C","168 C","7576 C","7577 C","7578 C","7579 C","7580 C","7581 C","7582 C","1625 C","1635 C","1645 C","1655 C","1665 C","1675 C","1685 C","169 C","170 C","171 C","172 C","173 C","174 C","175 C","7583 C","7584 C","7585 C","7586 C","7587 C","7588 C","7589 C","7590 C","7591 C","7592 C","7593 C","7594 C","7595 C","7596 C","7597 C","7598 C","7599 C","7600 C","7601 C","7602 C","7603 C","7604 C","7605 C","7606 C","7607 C","7608 C","7609 C","7610 C","7611 C","7612 C","7613 C","7614 C","7615 C","7616 C","7617 C","7520 C","7521 C","7522 C","7523 C","7524 C","7525 C","7526 C","489 C","488 C","487 C","486 C","485 C","484 C","483 C","176 C","177 C","178 C","179 C","180 C","181 C","1765 C","1775 C","1785 C","1788 C","1795 C","1805 C","1815 C","1767 C","1777 C","1787 C","1797 C","1807 C","1817 C","7618 C","7619 C","7620 C","7621 C","7622 C","7623 C","7624 C","7625 C","7626 C","7627 C","7628 C","7629 C","7630 C","7631 C","7415 C","7416 C","7417 C","7418 C","7419 C","7420 C","7421 C","182 C","183 C","184 C","185 C","186 C","187 C","188 C","196 C","197 C","198 C","199 C","200 C","201 C","202 C","189 C","190 C","191 C","192 C","193 C","194 C","195 C","1895 C","1905 C","1915 C","1925 C","1935 C","1945 C","1955 C","705 C","706 C","707 C","708 C","709 C","710 C","711 C","698 C","699 C","700 C","701 C","702 C","703 C","704 C","203 C","204 C","205 C","206 C","207 C","208 C","209 C","210 C","211 C","212 C","213 C","214 C","215 C","216 C","7422 C","7423 C","7424 C","7425 C","7426 C","7427 C","7428 C","7632 C","7633 C","7634 C","7635 C","7636 C","7637 C","7638 C","217 C","218 C","219 C","220 C","221 C","222 C","7639 C","7640 C","7641 C","7642 C","7643 C","7644 C","7645 C","223 C","224 C","225 C","226 C","227 C","228 C","229 C","230 C","231 C","232 C","233 C","234 C","235 C","670 C","671 C","672 C","673 C","674 C","675 C","676 C","677 C","678 C","679 C","680 C","681 C","682 C","683 C","684 C","685 C","686 C","687 C","688 C","689 C","690 C","510 C","509 C","508 C","507 C","506 C","505 C","504 C","7429 C","7430 C","7431 C","7432 C","7433 C","7434 C","7435 C","691 C","692 C","693 C","694 C","695 C","696 C","697 C","496 C","495 C","494 C","493 C","492 C","491 C","490 C","503 C","502 C","501 C","500 C","499 C","498 C","497 C","5035 C","5025 C","5015 C","5005 C","4995 C","4985 C","4975 C","236 C","237 C","238 C","239 C","240 C","241 C","242 C","2365 C","2375 C","2385 C","2395 C","2405 C","2415 C","2425 C","243 C","244 C","245 C","246 C","247 C","248 C","249 C","7646 C","7647 C","7648 C","7649 C","7650 C","7651 C","7652 C","250 C","251 C","252 C","253 C","254 C","255 C","517 C","516 C","515 C","514 C","513 C","512 C","511 C","7436 C","7437 C","7438 C","7439 C","7440 C","7441 C","7442 C","2562 C","2572 C","2582 C","2592 C","2602 C","2612 C","2622 C","7653 C","7654 C","7655 C","7656 C","7657 C","7658 C","7659 C","524 C","523 C","522 C","521 C","520 C","519 C","518 C","5245 C","5235 C","5225 C","5215 C","5205 C","5195 C","5185 C","5175 C","5165 C","5155 C","5145 C","5135 C","5125 C","5115 C","531 C","530 C","529 C","528 C","527 C","526 C","525 C","256 C","257 C","258 C","259 C","260 C","261 C","262 C","2563 C","2573 C","2583 C","2593 C","2603 C","2613 C","2623 C","7660 C","7661 C","7662 C","7663 C","7664 C","7665 C","7666 C","2567 C","2577 C","2587 C","2597 C","2607 C","2617 C","2627 C","263 C","264 C","265 C","266 C","267 C","268 C","269 C","2635 C","2645 C","2655 C","2665 C","2685 C","2695 C","270 C","271 C","272 C","273 C","274 C","275 C","276 C","2705 C","2715 C","2725 C","2735 C","2745 C","2755 C","2765 C","7667 C","7668 C","7669 C","7670 C","7671 C","7672 C","7673 C","7443 C","7444 C","7445 C","7446 C","7447 C","7448 C","7449 C","7674 C","7675 C","7676 C","7677 C","7678 C","7679 C","7680 C","663 C","664 C","665 C","666 C","667 C","668 C","669 C","5315 C","5305 C","5295 C","5285 C","5275 C","5265 C","5255 C","538 C","537 C","536 C","535 C","534 C","533 C","532 C","7541 C","7542 C","7543 C","7544 C","7545 C","7546 C","7547 C","552 C","551 C","550 C","549 C","548 C","547 C","546 C","5455 C","5445 C","5435 C","5425 C","5415 C","5405 C","5395 C","642 C","643 C","644 C","645 C","646 C","647 C","648 C","649 C","650 C","651 C","652 C","653 C","654 C","655 C","656 C","657 C","658 C","659 C","660 C","661 C","662 C","7450 C","7451 C","7452 C","7453 C","7454 C","7455 C","7456 C","2706 C","2716 C","2726 C","2736 C","2746 C","2756 C","2766 C","2708 C","2718 C","2728 C","2738 C","2748 C","2758 C","2768 C","2707 C","2717 C","2727 C","2747 C","2757 C","2767 C","277 C","278 C","279 C","280 C","281 C","282 C","283 C","284 C","285 C","286 C","287 C","288 C","289 C","7681 C","7682 C","7683 C","7684 C","7685 C","7686 C","7687 C","545 C","544 C","543 C","542 C","541 C","540 C","539 C","290 C","291 C","292 C","293 C","294 C","295 C","296 C","2905 C","2915 C","2925 C","2935 C","2945 C","2955 C","2965 C","297 C","298 C","299 C","300 C","301 C","302 C","303 C","7688 C","7689 C","7690 C","7691 C","7692 C","7693 C","7694 C","2975 C","2985 C","2995 C","3005 C","3015 C","3025 C","3035 C","7695 C","7696 C","7697 C","7698 C","7699 C","7700 C","7701 C","7457 C","7458 C","7459 C","7460 C","7461 C","7462 C","7463 C","304 C","305 C","306 C","307 C","308 C","309 C","635 C","636 C","637 C","638 C","639 C","640 C","641 C","7702 C","7703 C","7704 C","7705 C","7706 C","7707 C","7708 C","628 C","629 C","630 C","631 C","632 C","633 C","634 C","310 C","311 C","312 C","313 C","314 C","315 C","316 C","3105 C","3115 C","3125 C","3135 C","3145 C","3155 C","3165 C","7709 C","7710 C","7711 C","7712 C","7713 C","7714 C","7715 C","317 C","318 C","319 C","320 C","321 C","322 C","323 C","7464 C","7465 C","7466 C","7467 C","7468 C","7469 C","7470 C","7471 C","7472 C","7473 C","7474 C","7475 C","7476 C","7477 C","5523 C","5513 C","5503 C","5493 C","5483 C","5473 C","5463 C","7716 C","7717 C","7718 C","7719 C","7720 C","7721 C","7722 C","324 C","325 C","326 C","327 C","328 C","329 C","330 C","3242 C","3252 C","3262 C","3272 C","3282 C","3292 C","3302 C","3245 C","3255 C","3265 C","3275 C","3285 C","3295 C","3305 C","3248 C","3258 C","3268 C","3278 C","3288 C","3298 C","3308 C","566 C","565 C","564 C","563 C","562 C","561 C","560 C","573 C","572 C","571 C","570 C","569 C","568 C","567 C","559 C","558 C","557 C","556 C","555 C","554 C","553 C","5595 C","5585 C","5575 C","5565 C","5555 C","5545 C","5535 C","5665 C","5655 C","5645 C","5635 C","5625 C","5615 C","5605 C","5527 C","5517 C","5507 C","5497 C","5487 C","5477 C","5467 C","621 C","622 C","623 C","624 C","625 C","626 C","627 C","331 C","332 C","333 C","334 C","335 C","336 C","337 C","338 C","339 C","340 C","341 C","342 C","343 C","7723 C","7724 C","7725 C","7726 C","7727 C","7728 C","7729 C","3375 C","3385 C","3395 C","3405 C","3415 C","3425 C","3435 C","344 C","345 C","346 C","347 C","348 C","349 C","350 C","351 C","352 C","353 C","354 C","355 C","356 C","357 C","7478 C","7479 C","7480 C","7481 C","7482 C","7483 C","7484 C","7730 C","7731 C","7732 C","7733 C","7734 C","7735 C","7736 C","7737 C","7738 C","7739 C","7740 C","7741 C","7742 C","7743 C","358 C","359 C","360 C","361 C","362 C","363 C","364 C","7485 C","7486 C","7487 C","7488 C","7489 C","7490 C","7491 C","365 C","366 C","367 C","368 C","369 C","370 C","371 C","372 C","373 C","374 C","375 C","376 C","377 C","378 C","580 C","579 C","578 C","577 C","576 C","575 C","574 C","5807 C","5797 C","5787 C","5777 C","5767 C","5757 C","5747 C","5875 C","5865 C","5855 C","5845 C","5835 C","5825 C","5815 C","5803 C","5793 C","5783 C","5773 C","5763 C","5753 C","5743 C","7492 C","7493 C","7494 C","7495 C","7496 C","7497 C","7498 C","7744 C","7745 C","7746 C","7747 C","7748 C","7749 C","7750 C","379 C","380 C","381 C","382 C","383 C","384 C","385 C","386 C","387 C","388 C","389 C","390 C","391 C","392 C","587 C","586 C","585 C","584 C","583 C","582 C","581 C","393 C","394 C","395 C","396 C","397 C","398 C","399 C","3935 C","3945 C","3955 C","3965 C","3975 C","3985 C","3995 C","600 C","601 C","602 C","603 C","604 C","605 C","606 C","607 C","608 C","609 C","610 C","611 C","612 C","613 C","461 C","460 C","459 C","458 C","457 C","456 C","455 C","614 C","615 C","616 C","617 C","618 C","619 C","620 C","7751 C","7752 C","7753 C","7754 C","7755 C","7756 C","7757 C","7758 C","7759 C","7760 C","7761 C","7762 C","7763 C","7764 C","7765 C","7766 C","7767 C","7768 C","7769 C","7770 C","7771 C","4545 C","4535 C","4525 C","4515 C","4505 C","4495 C","4485 C","454 C","453 C","452 C","451 C","450 C","449 C","448 C","7499 C","7500 C","7501 C","7502 C","7503 C","7504 C","7505 C","468 C","467 C","466 C","465 C","464 C","463 C","462 C","7506 C","7507 C","7508 C","7509 C","7510 C","7511 C","7512 C","719 C","720 C","721 C","722 C","723 C","724 C","725 C","475 C","474 C","473 C","472 C","471 C","470 C","469 C","726 C","727 C","728 C","729 C","730 C","731 C","732 C","4685 C","4675 C","4665 C","4655 C","4645 C","4635 C","4625 C","7513 C","7514 C","7515 C","7516 C","7517 C","7518 C","7519 C","4755 C","4745 C","4735 C","4725 C","4715 C","4705 C","4695 C","482 C","481 C","480 C","479 C","478 C","477 C","476 C","7527 C","7528 C","7529 C","7530 C","7531 C","7532 C","7533 C","7534 C","7535 C","7536 C","7537 C","7538 C","7539 C","7540 C","427 C","428 C","429 C","430 C","431 C","432 C","433 C","420 C","421 C","422 C","423 C","424 C","425 C","426 C","441 C","442 C","443 C","444 C","445 C","446 C","447 C","413 C","414 C","415 C","416 C","417 C","418 C","419 C","400 C","401 C","402 C","403 C","404 C","405 C","406 C","407 C","408 C","409 C","410 C","411 C","412 C","434 C","435 C","436 C","437 C","438 C","439 C","440 C","Warm Gray 1 C","Warm Gray 2 C","Warm Gray 3 C","Warm Gray 4 C","Warm Gray 5 C","Warm Gray 6 C","Warm Gray 7 C","Warm Gray 8 C","Warm Gray 9 C","Warm Gray 10 C","Warm Gray 11 C","Cool Gray 1 C","Cool Gray 2 C","Cool Gray 3 C","Cool Gray 4 C","Cool Gray 5 C","Cool Gray 6 C","Cool Gray 7 C","Cool Gray 8 C","Cool Gray 9 C","Cool Gray 10 C","Cool Gray 11 C","Black 2 C","Black 3 C","Black 4 C","Black 5 C","Black 6 C","Black 7 C"],kt=["FEDD00","FFD700","FE5000","F9423A","EF3340","CE0058","E10098","BB29BB","440099","10069F","001489","0085CA","00AB84","2D2926","F2F0A1","FCAEBB","F1B2DC","BF9BDE","74D1EA","9DE7D7","9E978E","009ACE","44D62C","FFE900","FFAA4D","FF7276","FF3EB5","EA27C2","84754E","85714D","866D4B","8B6F4E","87674F","8B634B","8A8D8F","FFD900","FF5E00","F93822","CE0056","D62598","4E008E","00239C","0084CA","00B08B","222223","F6EB61","F7EA48","FCE300","C5A900","AF9800","897A27","F5E1A4","ECD898","EED484","F4DA40","F2CD00","F1C400","CBA052","F9E547","FBE122","FEDB00","FFD100","DAAA00","AA8A00","9C8412","FAE053","FBDD40","FDDA24","FFCD00","C99700","AC8400","897322","F3DD6D","F3D54E","F3D03E","F2A900","CC8A00","A07400","6C571B","F8E08E","FBD872","FFC845","FFB81C","C69214","AD841F","886B25","FBDB65","FDD757","FED141","FFC72C","EAAA00","B58500","9A7611","FFC600","FFB500","D19000","B47E00","73531D","5A4522","4B3D2A","D29F13","B78B20","9F7D23","967126","8F6A2A","7D622E","6C5D34","FDD26E","FFC658","FFBF3F","FFA300","DE7C00","AF6D04","74531C","FDD086","FFC56E","FFB549","FF9E1B","D57800","996017","6E4C1E","F2C75C","F1BE48","F1B434","ED8B00","CF7F00","A76D11","715C2A","F6BE00","F0B323","FEAD77","E6A65D","D38235","DC8633","C16C18","BD9B60","D69A2D","DB8A06","CD7925","AD6433","89532F","775135","D78825","D3832B","C67D30","B67233","A7662B","9E6A38","835D32","FCC89B","FDBE87","FDAA63","F68D2E","EA7600","D45D00","BE4D00","FECB8B","FFC27B","FFB25B","FF8200","E57200","BE6A14","9B5A1A","EFD19F","EFBE7D","ECA154","E87722","CB6015","A1561C","603D20","FFAE62","FF8F1C","FF6900","B94700","94450B","653819","FFB990","FFA06A","FF7F32","FF6A13","D86018","A65523","8B4720","FFBE9F","FF9D6E","FF7F41","FF671F","E35205","BE531C","73381D","DB864E","E07E3C","DC6B2F","DC582A","C05131","864A33","674736","FFA38B","FF8D6D","FF6A39","FC4C02","DC4405","A9431E","833921","FFB3AB","FF8674","FF5C39","FA4616","CF4520","963821","6B3529","C4622D","BA5826","AF5C37","9E5330","924C2E","7B4D35","5C4738","D4B59E","C07D59","B15533","9D432C","7C3A2D","6B3D2E","5C3D31","D14124","BD472A","B33D26","8D3F2B","83412C","7B4931","674230","E4D5D3","E1BBB4","D6938A","C26E60","A4493D","823B34","683431","DDBCB0","CA9A8E","BC8A7E","A37F74","866761","6B4C4C","583D3E","EABEB0","C09C83","B46A55","AB5C57","A45248","9A6A4F","8A391B","ECC3B2","ECBAA8","EAA794","E8927C","DA291C","9A3324","653024","FFB1BB","FF808B","FF585D","E03C31","BE3A34","81312F","FFA3B5","FF8DA1","F8485E","EE2737","D22630","AF272F","7C2529","FCAFC0","FB637E","F4364C","CB333B","A4343A","643335","C66E4E","C04C36","B7312C","AB2328","93272C","8A2A2B","802F2D","E1523D","C63527","A72B2A","9E2A2B","6D3332","633231","572D2D","E6BAA8","E56A54","E04E39","CD545B","B04A5A","9B2242","651D32","FABBCB","FC9BB3","F65275","E4002B","C8102E","A6192E","76232F","ECC7CD","E89CAE","DF4661","D50032","BA0C2F","9D2235","862633","F8A3BC","F67599","EF426F","E40046","BF0D3E","9B2743","782F40","F5B6CD","F59BBB","EF4A81","E0004D","C5003E","A6093D","8A1538","F5DADF","F7CED7","F9B5C4","F890A5","EF6079","E03E52","CB2C30","F2D4D7","F4C3CC","F2ACB9","E68699","D25B73","B83A4B","9E2A2F","ECB3CB","E782A9","E0457B","CE0037","A50034","861F41","6F263D","F99FC9","F57EB6","F04E98","E31C79","CE0F69","AC145A","7D2248","F4CDD4","E06287","E24585","B52555","A4123F","971B2F","6A2C3E","D6C9CA","C4A4A7","C16784","C63663","BC204B","912F46","7E2D40","EABEDB","E56DB1","DA1884","A50050","910048","6C1D45","936D73","934054","8E2C48","732E4A","672E45","582D40","502B3A","EF95CF","EB6FBD","DF1995","D0006F","AA0061","890C58","672146","F4A6D7","F277C6","E93CAC","C6007E","A20067","840B55","EAD3E2","E6BCD8","DFA0C9","D986BA","C6579A","AE2573","960051","E5CEDB","E3C8D8","DEBED2","C996B6","B06C96","994878","7C2855","E4C6D4","DCB6C9","D0A1BA","BE84A3","A76389","893B67","612141","EBBECB","E8B3C3","E4A9BB","D592AA","84344E","6F2C3F","572932","E2BCCB","DCA9BF","C9809E","B55C80","A73A64","9B3259","872651","E9CDD0","E4BEC3","D7A3AB","C48490","B46B7A","984856","893C47","F2C6CF","F1BDC8","E9A2B2","DC8699","8F3237","7F3035","5D2A2C","E9C4C7","E5BAC1","DAA5AD","C6858F","7A3E3A","6A3735","512F2E","DFC2C3","DBB7BB","CCA1A6","B07C83","9C6169","874B52","3F2021","F1A7DC","EC86D0","E45DBF","DB3EB1","C5299B","AF1685","80225F","EFBAE1","E277CD","D539B5","C800A1","B0008E","9E007E","830065","EAB8E4","E59BDC","DD7FD3","C724B1","BB16A3","A51890","80276C","A56E87","A83D72","991E66","8A1B61","722257","6A2A5B","5E2751","E7BAE4","DD9CDF","C964CF","AD1AAC","981D97","72246C","EBC6DF","E6BEDD","E2ACD7","D48BC8","93328E","833177","612C51","EEDAEA","CCAED0","D59ED7","B288B9","A277A6","9F5CC0","963CBD","D7A9E3","C98BDB","AC4FC6","9B26B6","87189D","772583","653165","948794","A2789C","A15A95","8E3A80","6E2B62","6A3460","5D3754","D5C2D8","C9B1D0","BA9CC5","A57FB2","642F6C","59315F","4B3048","DBCDD3","D0BEC7","C6B0BC","AF95A6","86647A","66435A","4A3041","D8C8D1","D3C0CD","BFA5B8","9B7793","7E5475","693C5E","512A44","DFC8E7","D7B9E4","CAA2DD","B580D1","8031A7","702F8A","572C5F","D6BFDD","C6A1CF","8C4799","6D2077","642667","5D285F","51284F","CBA3D8","B884CB","A05EB5","84329B","702082","671E75","5F2167","9991A4","8D6E97","7A4183","6B3077","653279","5E366E","5C4E63","C1A0DA","A77BCA","8246AF","5C068C","500778","470A68","3C1053","D7C6E6","C1A7E2","9063CD","753BBD","5F259F","582C83","512D6D","C5B4E3","AD96DC","9678D3","7D55C7","330072","2E1A47","B4B5DF","9595D2","7474C1","24135F","211551","201747","221C35","A7A4E0","8B84D7","685BC7","2E008B","280071","250E62","201547","6E7CA0","686E9F","615E9B","565294","514689","4C4184","535486","DDDAE8","B6B8DC","A7A2C3","8986CA","5D4777","4B384C","41273B","878CB4","7C7FAB","7566A0","6F5091","68478D","563D82","523178","E5E1E6","E0DBE3","C6BCD0","A192B2","7C6992","614B79","3F2A56","D8D7DF","C6C4D2","B3B0C4","8D89A5","595478","403A60","1E1A34","C5CFDA","BBC7D6","A2B2C8","8E9FBC","1B365D","1F2A44","1C1F2A","D9E1E2","A4BCC2","98A4AE","768692","425563","253746","131E29","B9D3DC","A3C7D2","8DB9CA","6BA4B8","003D4C","00313C","072B31","BFCED6","B7C9D3","A6BBC8","7A99AC","5B7F95","4F758B","081F2C","D1DDE6","C6D6E3","9BB8D3","7DA1C4","5E8AB4","236192","002E5D","DBE2E9","CED9E5","A7BCD6","7D9BC1","326295","003A70","002554","DDE5ED","C8D8EB","B1C9E8","7BA4DB","407EC9","003594","001A70","BDC5DB","89ABE3","8094DD","7BA6DE","5F8FB4","3A5DAE","606EB2","CBD3EB","9FAEE5","485CC7","1E22AA","171C8F","151F6D","141B4D","B8CCEA","5C88DA","0047BB","06038D","001871","001E62","071D49","C3D7EE","A7C6ED","307FE2","001A72","001E60","13294B","ABCAE9","8BB8E8","418FDE","012169","00205B","041E42","92C1E9","6CACE4","0072CE","0033A0","003087","002D72","0C2340","94A9CB","6787B7","426DA9","385E9D","2C5697","1D4F91","1D428A","C6DAE7","BDD6E6","A4C8E1","7BAFD4","003C71","003057","00263A","B9D9EB","9BCBEB","69B3E7","003DA5","002F6C","002855","041C2C","8DC8E8","62B5E5","009CDE","0057B8","004C97","003865","00263E","71C5E8","41B6E6","00A3E0","005EB8","004B87","003B5C","002A3A","4698CB","298FC2","0076A8","006298","005587","004976","01426A","99D6EA","5BC2E7","00A9E0","0077C8","00629B","004F71","003E51","7BA7BC","6399AE","4E87A0","41748D","34657F","165C7D","005776","BBDDE6","71B2C9","4298B5","0086BF","007DBA","00558C","002B49","9ADBE8","59CBE8","00B5E2","006BA6","00587C","003B49","A4DBE8","8BD3E6","4EC3E0","00AFD7","0095C8","0082BA","0067A0","48A9C5","009CBD","0085AD","007096","006A8E","00617F","005670","B8DDE1","9BD3DD","77C5D5","3EB1C8","0093B2","007396","005F83","6AD1E3","05C3DE","00A9CE","0092BC","007FA3","00677F","004851","68D2DF","00C1D5","00AEC7","008EAA","00778B","006272","004F59","63B1BC","00A7B5","0097A9","00859B","007D8A","007680","006269","B1E4E3","88DBDF","2DCCD3","009CA6","008C95","007377","005F61","A0D1CA","40C1AC","00B0B9","00A3AD","007398","005F86","005A70","7EDDD3","5CB8B2","279989","007681","487A7B","0D5257","244C5A","B6CFD0","ABC7CA","94B7BB","7FA9AE","4F868E","115E67","07272D","00968F","00857D","007672","006D68","00635B","005E5D","005151","9CDBD9","64CCC9","00B2A9","008675","007367","00685E","00534C","71DBD4","2AD2C9","00BFB3","00A499","008578","00594F","004C45","7CE0D3","2CD5C4","00C7B1","00B398","009681","007864","004E42","6DCDB8","49C5B1","00AB8E","009B77","008264","006A52","034638","B9DCD2","A1D6CA","86C8BC","6BBBAE","006F62","00594C","1D3C34","B5E3D8","A5DFD3","98DBCE","6BCABA","00816D","006C5B","173F35","ADCAB8","9ABEAA","85B09A","6FA287","28724F","205C40","284734","BFCEC2","A7BDB1","92ACA0","7F9C90","5C7F71","43695B","183028","BAC5B9","B0BDB0","A3B2A4","94A596","708573","5E7461","22372B","BCC9C5","B1C0BC","9DB0AC","829995","5D7975","3E5D58","18332F","D1E0D7","B7CDC2","9AB9AD","789F90","507F70","285C4D","13322B","A7E6D7","8CE2D0","3CDBC0","009775","007B5F","00664F","8FD6BD","6ECEB2","00B388","00965E","007A53","006747","115740","50A684","00966C","008755","007B4B","006F44","006845","005844","7AE1BF","47D7AC","00C389","00AF66","007749","006341","154734","A0DAB3","91D6AC","71CC98","009A44","00843D","046A38","2C5234","A2E4B8","8FE2B0","80E0A7","00B140","009639","007A33","215732","9BE3BF","26D07C","00BF6F","00B74F","009F4D","275D38","00573F","4B9560","228848","007A3E","007041","286140","36573B","395542","6BA539","48A23F","319B42","3A913F","44883E","4A773C","44693D","ADDC91","A1D884","6CC24A","43B02A","509E2F","4C8C2B","4A7729","D0DEBB","BCE194","8EDD65","78D64B","74AA50","719949","79863C","C2E189","B7DD79","A4D65E","78BE20","64A70B","658D1B","546223","D4EB8E","CDEA80","C5E86C","97D700","84BD00","7A9A01","59621D","C4D6A4","BCD19B","B7CE95","A9C47F","789D4A","67823A","4E5B31","D0D1AB","C6C89B","BABD8B","A2A569","8A8D4A","6D712E","3D441E","D2CE9E","CBC793","C0BB87","AFA96E","A09958","89813D","555025","C3C6A8","B3B995","A3AA83","899064","737B4C","5E6738","3E4827","BFCC80","BBC592","9CAF88","8F993E","76881D","7A7256","5B6236","BABC16","ABAD23","999B30","888D30","7C8034","727337","656635","E2E868","DBE442","CEDC00","C4D600","A8AD00","949300","787121","E9EC6B","E3E935","E0E721","D0DF00","B5BD00","9A9500","827A04","E3E48D","E0E27C","DBDE70","D2D755","B7BF10","8E8C13","625D20","F0EC74","EDE939","ECE81A","E1E000","BFB800","ADA400","A09200","F3EA5D","F3E500","EFDF00","EEDC00","BBA600","9A8700","685C20","F1EB9C","F0E991","F0E87B","EDE04B","EADA24","E1CD00","CFB500","EBE49A","E9E186","E6DE77","E1D555","D7C826","C4B000","B39B00","E9DF97","E4D77E","DECD63","D9C756","B89D18","A28E2A","695B24","DCD59A","D6CF8D","D0C883","C0B561","AC9F3C","9F912A","8A7B19","CAB64B","CFB023","C1A01E","A08629","897630","736635","675E33","D4C304","C4B200","91852C","747136","5D6439","585C3B","535435","BBB323","B4A91F","AA9D2E","8F7E35","716135","635939","4E4934","D5CB9F","CFC493","C5B783","B3A369","998542","8C7732","614F25","CAC7A7","BFBB98","B0AA7E","9B945F","594A25","524727","4A412A","F1E6B2","DFD1A7","D9C89E","CEB888","A89968","94795D","816040","DDCBA4","D3BC8D","C6AA76","B9975B","8B5B29","744F28","5C462B","EFDBB2","FCD299","E1B87F","D6A461","C6893F","B77729","A6631B","EDC8A3","E7B78A","DDA46F","C88242","B36924","934D11","7D3F16","F3CFB3","F1C6A7","F0BF9B","E59E6D","B86125","A45A2A","693F23","E0C09F","D9B48F","CDA077","B58150","9E652E","774212","623412","E0C6AD","DCBFA6","CDA788","BF9474","AD7C59","946037","4F2C1D","E1B7A7","D5A286","C58B68","99552B","85431E","6D4F47","5E4B3C","D7C4B7","CDB5A7","C0A392","AE8A79","956C58","7C4D3A","5B3427","DBC8B6","D3BBA8","C6A992","AA8066","703F2A","623B2A","4E3629","D6D2C4","C5B9AC","B7A99A","A39382","7A6855","63513D","473729","D1CCBD","B7B09C","A69F88","A7ACA2","949A90","8E9089","4B4F54","D0D3D4","C1C6C8","A2AAAD","7C878E","5B6770","333F48","1D252D","C7C9C7","B2B4B2","9EA2A2","898D8D","707372","54585A","25282A","BEC6C4","A2ACAB","919D9D","717C7D","505759","3F4444","373A36","BABBB1","A8A99E","919388","7E7F74","65665C","51534A","212322","C4BFB6","AFA9A0","9D968D","8C857B","776E64","696158","C4BCB7","B2A8A2","978C87","857874","746661","5E514D","382F2D","D0C4C5","C1B2B6","AB989D","7B6469","584446","453536","382E2C","D7D2CB","CBC4BC","BFB8AF","B6ADA5","ACA39A","A59C94","968C83","8C8279","83786F","796E65","6E6259","D9D9D6","D0D0CE","C8C9C7","BBBCBC","B1B3B3","A7A8AA","97999B","888B8D","75787B","63666A","53565A","332F21","212721","31261D","3E2B2E","101820","3D3935"],be=kt.map(n=>[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]);function Bi(n){const t=Zt.indexOf(n);return t>=0?kt[t]:""}function Da(n){const t=kt.indexOf(n);return t>=0?Zt[t]:""}function hi(n,t=64){const e=[],A=[],a=Da(n);a&&e.push({pms:a,hex:n,distance:0});const i=parseInt(n.substring(0,2),16),s=parseInt(n.substring(2,4),16),o=parseInt(n.substring(4,6),16);let r,c,l;for(let g=0;g<kt.length;g++){r=be[g][0],c=be[g][1],l=be[g][2];const d=Math.sqrt(Math.pow(i-r,2)+Math.pow(s-c,2)+Math.pow(o-l,2));A.push(d)}for(let g=0;g<A.length;g++)A[g]<=t&&!e.some(d=>d.pms===Zt[g])&&e.push({pms:Zt[g],hex:kt[g],distance:A[g]});return e.sort((g,d)=>g.distance-d.distance)}const Ci=Zt.map((n,t)=>({pms:n,hex:kt[t]})),ui=new On(Ci,{keys:["pms"]});function wi(n,t){return ui.search(n,t?{limit:t}:void 0)}let Ht=null;function ya(n){if(n.startsWith("#"))return KA(n);if(!document)throw new Error("browserColorToHex is only supported on browsers");if(Ht||(Ht=document.createElement("canvas").getContext("2d")),!Ht)throw new Error("Failed to create canvas context required to convert colors");Ht.fillStyle=n;const t=KA(Ht.fillStyle);return t||console.error(`Unknown browser color ${n}`),t}function KA(n){const t=n.substring(1).toUpperCase();return t.length===6?t:t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:""}const ge=n=>{const t=Fa(n.spotColor);return t?`${n.browserValue} ${t}`:n.browserValue},Fa=n=>{if(!n)return"";if(n.profileName.includes("/")&&n.profileName.includes(".icc")){const t=n.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${n.namedColor})`}return`icc-named-color(${n.profileName}, ${n.namedColor})`},Ze=n=>{const t=n.split(/[ ](?=[^)]*?(?:\(|$))/);if(t.length===0)return{browserValue:"#000000"};if(t.length===1)return{browserValue:t[0]};const e=t[1].match(/\(([^)]+)\)/gm);if(!e)throw new Error("Unhandled state of color value in SVG");const A=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:A[0],namedColor:A[1]}}},Ei=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],mi=["fill","stroke"],Nt=(n,t)=>{t(n),n.children.length>0&&Array.from(n.children).forEach(e=>Nt(e,t))},fi=(n,t)=>{try{return n.matches(t)}catch{return n.classList.contains(t.substring(1))}},ye=(n,t=!1)=>{!t&&n.setAttribute("preserveAspectRatio","none");const e=[];Nt(n,A=>{var i,s,o;if(A.tagName==="script"){A.remove();return}if(A.tagName==="style"){try{(i=na.parse(A.innerHTML).stylesheet)==null||i.rules.forEach(c=>{e.push(c)}),A.remove()}catch(r){console.error(r)}return}const a=(o=(s=A.attributes.getNamedItem("style"))==null?void 0:s.value)==null?void 0:o.trim();if(a){const r=[];a.split(";").forEach(l=>{const g=l.trim();if(g){const[d,B]=g.split(":"),h=d.toLowerCase();mi.indexOf(h)>-1?A.setAttribute(h,B.trim()):r.push(g)}}),r.length>0?A.setAttribute("style",r.join(";")):A.removeAttribute("style")}}),Nt(n,A=>{e.forEach(a=>{var i;(i=a.selectors)==null||i.forEach(s=>{var o;fi(A,s)&&((o=a.declarations)==null||o.forEach(r=>{r.property&&r.value&&A.setAttribute(r.property,r.value)}))})})})},Qi=n=>{const t=/pt|pc|mm|cm|in/gm,e=n.getAttribute("viewBox"),A=n.getAttribute("width"),a=n.getAttribute("height");if(!e)throw new Error("viewBox not specified on SVG!");A&&n.setAttribute("width",A.replace(t,"")),a&&n.setAttribute("height",a.replace(t,""))},Ma=n=>it().parseFromString(n,"image/svg+xml").firstElementChild,pi=(n,t,e)=>{n.setAttribute("height",`${e}px`),n.setAttribute("width",`${t}px`)},Sa=(n,t,e)=>{Nt(n,A=>{const a=A.attributes.getNamedItem("fill");a&&a.value!=="none"&&A.classList.forEach(s=>{if(s.startsWith("spiff-fill")){const o=t[s.replace("spiff-fill-","")];if(o)A.setAttribute("fill",e?ge(o):o.browserValue);else{const r=t[s];r&&A.setAttribute("fill",e?ge(r):r.browserValue)}}});const i=A.attributes.getNamedItem("stroke");i&&i.value!=="none"&&A.classList.forEach(s=>{if(s.startsWith("spiff-stroke")){const o=t[s.replace("spiff-stroke-","")];if(o)A.setAttribute("stroke",e?ge(o):o.browserValue);else{const r=t[s];r&&A.setAttribute("fill",e?ge(r):r.browserValue)}}})})},xa=n=>wt().serializeToString(n),CA=(n,t,e,A,a)=>{const i=Ma(n);if(!i)throw new Error("Failed to read SVG.");return pi(i,t,e),Sa(i,A,a),xa(i)},Ya=(n,t,e)=>{const A=Ma(n);if(!A)throw new Error("Failed to read SVG.");return Sa(A,t,e),xa(A)},Ii=n=>{const t=/<svg.*<\/svg>/s,e=n.match(t)||[],A=(e==null?void 0:e.length)>0?e[0]:"";return it().parseFromString(A,"image/svg+xml")},st=async n=>{const e=Ii(n).firstElementChild;if(!e)throw new Error("Failed to read SVG.");ye(e);const A={};Nt(e,s=>{Ei.includes(s.tagName)&&!s.attributes.getNamedItem("fill")&&s.setAttribute("fill","black");const o=s.attributes.getNamedItem("fill");if(o&&o.value!=="none"&&!o.value.startsWith("url(")){const c=Ze(o.value),l=c.browserValue.replace(/\W/g,""),g=`spiff-fill-${l}`;s.setAttribute("fill",c.browserValue),s.classList.add(g),A[l]=c}const r=s.attributes.getNamedItem("stroke");if(r&&r.value!=="none"&&!r.value.startsWith("url(")){const c=Ze(r.value),l=c.browserValue.replace(/\W/g,""),g=`spiff-stroke-${l}`;s.classList.add(g),s.setAttribute("stroke",c.browserValue),A[l]=c}});const i=wt().serializeToString(e);return{colors:A,svg:i}},Di=Q.gql`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("@apollo/client/core"),Un=require("@apollo/client/link/context"),Gn=require("@apollo/client/link/error"),Tn=require("preact-render-to-string"),Jn=require("@apollo/client/link/remove-typename"),Ln=require("exifr/dist/mini.umd.cjs"),na=require("css"),On=require("fuse.js"),cA=require("pith"),xt=require("lodash.clonedeep"),ia=require("qrcode"),lA=require("svg-path-bbox"),je=require("opentype.js"),S=require("preact/jsx-runtime"),zn=require("data-uri-to-buffer"),JA=require("lodash.chunk"),sa=require("lodash.isequal"),Ve=require("unicode-default-word-boundary"),oa=require("lodash.debounce");var Kt=(n=>(n.Data="Data",n.Font="Font",n.Frame="Frame",n.Illustration="Illustration",n.Image="Image",n.Model="Model",n.Material="Material",n.Color="Color",n.QuestionnaireCollateral="QuestionnaireCollateral",n.RequestCollateral="RequestCollateral",n.SignupCollateral="SignupCollateral",n.Video="Video",n.ColorProfile="ColorProfile",n.Environment="Environment",n))(Kt||{}),et=(n=>(n.FileUpload="FileUpload",n.Option="Option",n.ColorOption="ColorOption",n.Text="Text",n))(et||{}),M=(n=>(n.Information="Information",n.Bulk="Bulk",n.DigitalContent="DigitalContent",n.Finish="Finish",n.Frame="Frame",n.Illustration="Illustration",n.Introduction="Introduction",n.Material="Material",n.Model="Model",n.Module="Module",n.Picture="Picture",n.Photo="Photo",n.ProductOverlay="ProductOverlay",n.Question="Question",n.Shape="Shape",n.SilentIllustration="SilentIllustration",n.Text="Text",n))(M||{}),ra=(n=>(n.Color="Color",n.Colors="Colors",n.Selection="Selection",n.Selections="Selections",n.Text="Text",n.Upload="Upload",n))(ra||{}),Pt=(n=>(n.ThreeD="ThreeD",n.FreeDesign="FreeDesign",n.Print="Print",n))(Pt||{}),N=(n=>(n.Frame="frame",n.Group="group",n.Image="image",n.Pattern="pattern",n.Illustration="illustration",n.Textbox="textbox",n))(N||{}),ca=(n=>(n.Hyperlink="Hyperlink",n.Edit="Edit",n.Approve="Approve",n))(ca||{}),la=(n=>(n.Hub="Hub",n.Shopify="Shopify",n))(la||{}),Qe=(n=>(n.BackgroundRemover="BackgroundRemover",n.ConversionAccelerator="Conversion Accelerator",n.ProcessBuilder="ProcessBuilder",n))(Qe||{}),ga=(n=>(n[n.Orbit=0]="Orbit",n[n.Pan=1]="Pan",n))(ga||{}),da=(n=>(n.Manual="Manual",n.OnStart="OnStart",n.OnQuit="OnQuit",n.OnEnd="OnEnd",n))(da||{}),Ba=(n=>(n.Email="Email",n.FirstName="FirstName",n.LastName="LastName",n.Phone="Phone",n))(Ba||{}),Wt=(n=>(n.Owner="Owner",n.Approver="Approver",n.Editor="Editor",n.Viewer="Viewer",n))(Wt||{}),pt=(n=>(n.Autosize="Autosize",n.Traditional="Traditional",n))(pt||{}),K=(n=>(n[n.North=0]="North",n[n.Northeast=1]="Northeast",n[n.East=2]="East",n[n.Southeast=3]="Southeast",n[n.South=4]="South",n[n.Southwest=5]="Southwest",n[n.West=6]="West",n[n.Northwest=7]="Northwest",n))(K||{}),ha=(n=>(n.Pixel="px",n.Millimeter="mm",n.Centimeter="cm",n))(ha||{});class Ca extends Error{constructor(t){super(t),this.name=this.constructor.name}}class _t extends Ca{constructor(t){super(`ConfigurationError - ${t}`)}}class Xt extends _t{constructor(t){super(`Option not Configured: ${t.stepTitle}`),this.optionId=(t==null?void 0:t.optionId)||"N/A"}}class X extends _t{constructor(t){super(`Panel not Found: ${t.panelId}`),this.panelId=(t==null?void 0:t.panelId)||"N/A"}}class Bt extends _t{constructor(t){super(`Asset not found for variant: ${t.name}`),this.variant=t}}class vt extends _t{constructor(t){super(`Resource not found for asset: ${t.name}`),this.asset=t}}class qt extends _t{constructor(t,e){super(`Workflow Misconfiguration: ${t.stepName} - ${e}`),this.step=t}}class pe extends Ca{constructor(t){super(`ImplementationError - ${t}`)}}class L extends pe{constructor(t){super(`Unhandled Behavior Encountered: ${t}`)}}class mt extends pe{constructor(t){super(`Parsing Error: ${t}`)}}class lt extends pe{constructor(t){super(`Client Error: ${t}`)}}class Ie extends pe{constructor(t){super(`Resource Generation Failed: ${t}`)}}class jn{get(t){return localStorage.getItem(t)||void 0}set(t,e){localStorage.setItem(t,e)}remove(t){localStorage.removeItem(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}class LA{constructor(){this.storage=new Map}get(t){return this.storage.get(t)||void 0}set(t,e){this.storage.set(t,e)}remove(t){this.storage.delete(t)}getMap(t){const e=this.get(t);if(e)return new Map(JSON.parse(e))}setMap(t,e){const A=JSON.stringify([...e.entries()]);this.set(t,A)}}const Vn=()=>{try{return localStorage?new jn:new LA}catch{return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."),new LA}},k=Vn();class Kn{constructor(){this.defaultServerUrl="https://api.au.spiffcommerce.com",this.defaultServicesApiUrl="https://services.au.spiffcommerce.com",this.defaultHubUrl="https://hub.au.spiffcommerce.com",this.serverUrl=this.defaultServerUrl,this.servicesApiUrl=this.defaultServicesApiUrl,this.hubUrl=this.defaultHubUrl,this.serverUrlCallbacks=[]}getServerUrl(){return this.serverUrl}getServicesApiUrl(){return this.servicesApiUrl}getHubUrl(){return this.hubUrl}setServerUrl(t){this.serverUrl=t,this.serverUrlCallbacks.forEach(e=>e())}setServicesApiUrl(t){this.servicesApiUrl=t}setHubUrl(t){this.hubUrl=t}addServerUrlCallback(t){this.serverUrlCallbacks.push(t)}}const dt=new Kn;let Ke,We;function Wn(n){Ke=n}function Xn(n){We=n}function te(){return Ke?new Ke().window:(console.log("DOM constructor is not registered. Assuming browser environment. If not, please register DOM constructor before calling this function."),window)}function ot(n,t){if(!We){if(typeof window<"u"&&window.fetch)return window.fetch(n,t);if(typeof global<"u"&&global.fetch)return global.fetch(n,t);throw new Error("Fetch implementation is not registered. Please register it before calling this function.")}return We(n,t)}const ua=new Map,OA=new Map,zA=new Map,wa=async n=>{const t=OA.get(n);if(t)return t;const A=(async()=>{var i;const a=await ot(n);return ua.set(n,((i=a.headers)==null?void 0:i.get("content-type"))||""),await a.arrayBuffer()})();return OA.set(n,A),A},qn=async n=>{const t=zA.get(n);if(t)return t;const A=(async()=>await(await ot(n)).text())();return zA.set(n,A),A},Rt=n=>n.every(t=>t!=="undefined"),ce=n=>Rt([typeof document])?document.createElement(n):te().document.createElement(n),Zn=(n,t)=>{if(Rt([typeof document]))return document.createElementNS(n,t);const A=te().document.createElement(t);return A.setAttribute("xmlns",n),A},it=()=>{if(Rt([typeof DOMParser]))return new DOMParser;const n=te();return new n.DOMParser},$n=()=>Rt([typeof DOMParser])?DOMParser:te().DOMParser,De=(n,t)=>new Promise((e,A)=>{t?wa(n).then(e).catch(A):ot(n).then(a=>{a.arrayBuffer().then(e).catch(A)}).catch(a=>{A(a)})}),_=(n,t)=>new Promise((e,A)=>{t?qn(n).then(e).catch(A):ot(n).then(a=>{a.text().then(e).catch(A)}).catch(A)}),Ea=n=>Tn.renderToStaticMarkup(n),ke=new Map,_n=async(n,t)=>{if(Rt([typeof FontFace])){if(ke.has(t))return ke.get(t);const e=n.names.fullName.en,A=new FontFace(e,`url(${t})`);document.fonts.add(A);const a=A.load();return ke.set(t,a),a}},wt=()=>{if(Rt([typeof XMLSerializer]))return new XMLSerializer;const n=te();return new n.XMLSerializer},jA=n=>btoa(n),ee=n=>{function t(){const A=new Uint8Array(n),a=4;if(A.length>=a){const i=new Array(a);for(let r=0;r<a;r++)i[r]=new Uint8Array(n)[r].toString(16);const s=i.join("").toUpperCase();switch(s){case"89504E47":return"image/png";case"47494638":return"image/gif";case"25504446":return"application/pdf";case"504B0304":return"application/zip"}switch(s.slice(0,4)){case"FFD8":return"image/jpeg"}}return null}const e=t();return e||"image/svg+xml"},ti=async n=>{const t=await wa(n),e=ua.get(n)||ee(t);return await ai(new Blob([t],{type:e}))},ei=n=>{let t="";const e=n.byteLength;for(let A=0;A<e;A++)t+=String.fromCharCode(n[A]);return t},Ai=async n=>{const t=ee(n),e=new Uint8Array(n),A=ei(e),a=btoa(A);return`data:${t};base64,${a}`},gA=n=>`data:image/svg+xml;base64,${btoa(n)}`,ma=n=>{const t=n.replace(/\r?\n/g,""),e=t.indexOf(",");if(e===-1||e<=4)throw new TypeError("malformed data: URI");const A=t.substring(5,e).split(";");let a=!1;for(let s=1;s<A.length;s++)A[s]==="base64"&&(a=!0);const i=decodeURI(t.substring(e+1));return a?new Uint8Array(atob(i).split("").map(o=>o.charCodeAt(0))).buffer:new Uint8Array(i.split("").map(o=>o.charCodeAt(0))).buffer},ai=n=>new Promise((t,e)=>{const A=new FileReader;A.onload=function(a){const i=a.target;!i||!i.result?e():t(i.result.toString())},A.readAsDataURL(n)});let fa;const VA=n=>{fa=n};let dA;const ni=n=>{dA=n},ii=()=>dA;let Qa;const pa=n=>{Qa=n},si=()=>new Promise(n=>{const t=dt.getHubUrl(),e=A=>{A.origin===t&&(window.removeEventListener("message",e),n(A.data))};window.parent!==window&&(window.addEventListener("message",e,!1),window.parent.postMessage("ready",t))}),oi=async()=>{const n={applicationKey:dA,customerToken:fa,bearer:Qa};return typeof window<"u"&&(window.location.href.includes("/workflows/product/")||window.location.href.includes("hub=true"))?{...await si(),...n}:n};class ri{constructor(){this.shadowGraphqlClient=this.constructShadowGraphqlClient(),dt.addServerUrlCallback(()=>{this.shadowGraphqlClient=this.constructShadowGraphqlClient()})}getShadowGraphqlClient(){return this.shadowGraphqlClient}constructShadowGraphqlClient(){const t=Q.createHttpLink({uri:`${dt.getServerUrl()}/graphql`,fetch:ot}),e=Un.setContext(async(i,s)=>{const{headers:o}=s,r=o||{},c=await oi(),l=s.bearer??c.bearer,g=s.partnerId??c.partnerId,d=s.activeIntegration??c.activeIntegration,B=s.transactionOwnerId,h=s.customerToken??c.customerToken,C=s.applicationKey??c.applicationKey,u=s.bundleOwnerId;try{if(window&&window.__SENTRY__){const w=window.__SENTRY__.hub;if(w){const E=w.traceHeaders();Object.entries(E).forEach(([m,f])=>{r[m]=f})}}}catch{}return l&&(r.Authorization=`Bearer ${l}`),g&&(r.partnerId=g),d&&(r.activeIntegration=d),B&&(r.transactionOwnerId=B),h&&(r.customerToken=h),C&&(r["X-Application-Key"]=C),u&&(r.bundleOwnerId=u),{headers:r}}),A=Gn.onError(({operation:i,graphQLErrors:s,networkError:o})=>{const r=s||[];o&&console.log("GraphQL Network error"),r.forEach(()=>console.log("GraphQL Error: "+i.operationName))}),a=Jn.removeTypenameFromVariables();return new Q.ApolloClient({link:Q.from([a,A,e,t]),cache:new Q.InMemoryCache,name:"Core"})}}const y=new ri;let Xe,qe;const ht=(n,t,e)=>{if(Xe!==void 0)return Xe(n,t,e);try{const A=Ia(!0);return BA(A),A.createCanvas(n,t,e)}catch{throw new Error("Canvas module not set")}},Ae=(n,t)=>{if(qe!==void 0)return qe(n,t);try{const e=Ia(!0);return BA(e),e.loadImage(n,t)}catch{throw new Error("Canvas module not set")}};function BA(n){Xe=n==null?void 0:n.createCanvas,qe=n==null?void 0:n.loadImage}function Ia(n){try{if(document.createElement("canvas").getContext("2d"))return{createCanvas:(e,A,a)=>{const i=document.createElement("canvas");return e!=null&&(i.width=e),A!=null&&(i.height=A),i},loadImage:(e,A)=>new Promise((a,i)=>{const s=document.createElement("img");A!==!1&&(s.crossOrigin="Anonymous"),s.onload=()=>{a(s)},s.onerror=i,s.src=e})}}catch(t){if(n)throw t}}let Ne;function hA(){return Ne===void 0&&(Ne=$n()),Ne}let le=null;const ci=n=>new Promise(t=>{if(ee(n)!=="image/jpeg")return t(1);Ln.orientation(n).then(A=>t(A||1)).catch(()=>t(1))}),li=async()=>{if(le!==null)return!le;const t=await Ae("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/xABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAAAAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQvoP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXwH/9k=");return le=t.width===2&&t.height===3,!le},gi=n=>{const e=n.naturalWidth/n.naturalHeight;return n.naturalHeight<=8192&&n.naturalWidth<=8192?[n.naturalWidth,n.naturalHeight]:n.naturalHeight>n.naturalWidth?[e*8192,8192]:[8192,8192/e]},di=async n=>{var g;const t=await Ai(n),e=await Ae(t),[A,a]=gi(e);if(!await li()){const d=ht(A,a);return(g=d.getContext("2d"))==null||g.drawImage(e,0,0,A,a),d}const s=await ci(n),[o,r]=s>4?[a,A]:[A,a],c=ht(o,r),l=c.getContext("2d");switch(s){case 2:l.translate(o,0),l.scale(-1,1);break;case 3:l.translate(o,r),l.rotate(Math.PI);break;case 4:l.translate(0,r),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(-o,0);break;case 7:l.rotate(-.5*Math.PI),l.translate(-o,r),l.scale(1,-1);break;case 8:l.rotate(.5*Math.PI),l.translate(0,-r);break}return l.drawImage(e,0,0,o,r),c},ae=async n=>{const t=await di(n);return ee(n)==="image/jpeg"?{dataUrl:t.toDataURL("image/jpeg",1),height:t.height,width:t.width}:{dataUrl:t.toDataURL(),height:t.height,width:t.width}},Zt=["Yellow C","Yellow 012 C","Orange 021 C","Warm Red C","Red 032 C","Rubine Red C","Rhodamine Red C","Purple C","Violet C","Blue 072 C","Reflex Blue C","Process Blue C","Green C","Black C","Yellow 0131 C","Red 0331 C","Magenta 0521 C","Violet 0631 C","Blue 0821 C","Green 0921 C","Black 0961 C","801 C","802 C","803 C","804 C","805 C","806 C","807 C","871 C","872 C","873 C","874 C","875 C","876 C","877 C","Medium Yellow C","Bright Orange C","Bright Red C","Strong Red C","Pink C","Medium Purple C","Dark Blue C","Medium Blue C","Bright Green C","Neutral Black C","100 C","101 C","102 C","103 C","104 C","105 C","7401 C","7402 C","7403 C","7404 C","7405 C","7406 C","7407 C","106 C","107 C","108 C","109 C","110 C","111 C","112 C","113 C","114 C","115 C","116 C","117 C","118 C","119 C","127 C","128 C","129 C","130 C","131 C","132 C","133 C","1205 C","1215 C","1225 C","1235 C","1245 C","1255 C","1265 C","120 C","121 C","122 C","123 C","124 C","125 C","126 C","7548 C","7549 C","7550 C","7551 C","7552 C","7553 C","7554 C","7555 C","7556 C","7557 C","7558 C","7559 C","7560 C","7561 C","134 C","135 C","136 C","137 C","138 C","139 C","140 C","1345 C","1355 C","1365 C","1375 C","1385 C","1395 C","1405 C","141 C","142 C","143 C","144 C","145 C","146 C","147 C","7408 C","7409 C","7410 C","7411 C","7412 C","7413 C","7414 C","7562 C","7563 C","7564 C","7565 C","7566 C","7567 C","7568 C","7569 C","7570 C","7571 C","7572 C","7573 C","7574 C","7575 C","712 C","713 C","714 C","715 C","716 C","717 C","718 C","148 C","149 C","150 C","151 C","152 C","153 C","154 C","155 C","156 C","157 C","158 C","159 C","160 C","161 C","1485 C","1495 C","1505 C","1525 C","1535 C","1545 C","1555 C","1565 C","1575 C","1585 C","1595 C","1605 C","1615 C","162 C","163 C","164 C","165 C","166 C","167 C","168 C","7576 C","7577 C","7578 C","7579 C","7580 C","7581 C","7582 C","1625 C","1635 C","1645 C","1655 C","1665 C","1675 C","1685 C","169 C","170 C","171 C","172 C","173 C","174 C","175 C","7583 C","7584 C","7585 C","7586 C","7587 C","7588 C","7589 C","7590 C","7591 C","7592 C","7593 C","7594 C","7595 C","7596 C","7597 C","7598 C","7599 C","7600 C","7601 C","7602 C","7603 C","7604 C","7605 C","7606 C","7607 C","7608 C","7609 C","7610 C","7611 C","7612 C","7613 C","7614 C","7615 C","7616 C","7617 C","7520 C","7521 C","7522 C","7523 C","7524 C","7525 C","7526 C","489 C","488 C","487 C","486 C","485 C","484 C","483 C","176 C","177 C","178 C","179 C","180 C","181 C","1765 C","1775 C","1785 C","1788 C","1795 C","1805 C","1815 C","1767 C","1777 C","1787 C","1797 C","1807 C","1817 C","7618 C","7619 C","7620 C","7621 C","7622 C","7623 C","7624 C","7625 C","7626 C","7627 C","7628 C","7629 C","7630 C","7631 C","7415 C","7416 C","7417 C","7418 C","7419 C","7420 C","7421 C","182 C","183 C","184 C","185 C","186 C","187 C","188 C","196 C","197 C","198 C","199 C","200 C","201 C","202 C","189 C","190 C","191 C","192 C","193 C","194 C","195 C","1895 C","1905 C","1915 C","1925 C","1935 C","1945 C","1955 C","705 C","706 C","707 C","708 C","709 C","710 C","711 C","698 C","699 C","700 C","701 C","702 C","703 C","704 C","203 C","204 C","205 C","206 C","207 C","208 C","209 C","210 C","211 C","212 C","213 C","214 C","215 C","216 C","7422 C","7423 C","7424 C","7425 C","7426 C","7427 C","7428 C","7632 C","7633 C","7634 C","7635 C","7636 C","7637 C","7638 C","217 C","218 C","219 C","220 C","221 C","222 C","7639 C","7640 C","7641 C","7642 C","7643 C","7644 C","7645 C","223 C","224 C","225 C","226 C","227 C","228 C","229 C","230 C","231 C","232 C","233 C","234 C","235 C","670 C","671 C","672 C","673 C","674 C","675 C","676 C","677 C","678 C","679 C","680 C","681 C","682 C","683 C","684 C","685 C","686 C","687 C","688 C","689 C","690 C","510 C","509 C","508 C","507 C","506 C","505 C","504 C","7429 C","7430 C","7431 C","7432 C","7433 C","7434 C","7435 C","691 C","692 C","693 C","694 C","695 C","696 C","697 C","496 C","495 C","494 C","493 C","492 C","491 C","490 C","503 C","502 C","501 C","500 C","499 C","498 C","497 C","5035 C","5025 C","5015 C","5005 C","4995 C","4985 C","4975 C","236 C","237 C","238 C","239 C","240 C","241 C","242 C","2365 C","2375 C","2385 C","2395 C","2405 C","2415 C","2425 C","243 C","244 C","245 C","246 C","247 C","248 C","249 C","7646 C","7647 C","7648 C","7649 C","7650 C","7651 C","7652 C","250 C","251 C","252 C","253 C","254 C","255 C","517 C","516 C","515 C","514 C","513 C","512 C","511 C","7436 C","7437 C","7438 C","7439 C","7440 C","7441 C","7442 C","2562 C","2572 C","2582 C","2592 C","2602 C","2612 C","2622 C","7653 C","7654 C","7655 C","7656 C","7657 C","7658 C","7659 C","524 C","523 C","522 C","521 C","520 C","519 C","518 C","5245 C","5235 C","5225 C","5215 C","5205 C","5195 C","5185 C","5175 C","5165 C","5155 C","5145 C","5135 C","5125 C","5115 C","531 C","530 C","529 C","528 C","527 C","526 C","525 C","256 C","257 C","258 C","259 C","260 C","261 C","262 C","2563 C","2573 C","2583 C","2593 C","2603 C","2613 C","2623 C","7660 C","7661 C","7662 C","7663 C","7664 C","7665 C","7666 C","2567 C","2577 C","2587 C","2597 C","2607 C","2617 C","2627 C","263 C","264 C","265 C","266 C","267 C","268 C","269 C","2635 C","2645 C","2655 C","2665 C","2685 C","2695 C","270 C","271 C","272 C","273 C","274 C","275 C","276 C","2705 C","2715 C","2725 C","2735 C","2745 C","2755 C","2765 C","7667 C","7668 C","7669 C","7670 C","7671 C","7672 C","7673 C","7443 C","7444 C","7445 C","7446 C","7447 C","7448 C","7449 C","7674 C","7675 C","7676 C","7677 C","7678 C","7679 C","7680 C","663 C","664 C","665 C","666 C","667 C","668 C","669 C","5315 C","5305 C","5295 C","5285 C","5275 C","5265 C","5255 C","538 C","537 C","536 C","535 C","534 C","533 C","532 C","7541 C","7542 C","7543 C","7544 C","7545 C","7546 C","7547 C","552 C","551 C","550 C","549 C","548 C","547 C","546 C","5455 C","5445 C","5435 C","5425 C","5415 C","5405 C","5395 C","642 C","643 C","644 C","645 C","646 C","647 C","648 C","649 C","650 C","651 C","652 C","653 C","654 C","655 C","656 C","657 C","658 C","659 C","660 C","661 C","662 C","7450 C","7451 C","7452 C","7453 C","7454 C","7455 C","7456 C","2706 C","2716 C","2726 C","2736 C","2746 C","2756 C","2766 C","2708 C","2718 C","2728 C","2738 C","2748 C","2758 C","2768 C","2707 C","2717 C","2727 C","2747 C","2757 C","2767 C","277 C","278 C","279 C","280 C","281 C","282 C","283 C","284 C","285 C","286 C","287 C","288 C","289 C","7681 C","7682 C","7683 C","7684 C","7685 C","7686 C","7687 C","545 C","544 C","543 C","542 C","541 C","540 C","539 C","290 C","291 C","292 C","293 C","294 C","295 C","296 C","2905 C","2915 C","2925 C","2935 C","2945 C","2955 C","2965 C","297 C","298 C","299 C","300 C","301 C","302 C","303 C","7688 C","7689 C","7690 C","7691 C","7692 C","7693 C","7694 C","2975 C","2985 C","2995 C","3005 C","3015 C","3025 C","3035 C","7695 C","7696 C","7697 C","7698 C","7699 C","7700 C","7701 C","7457 C","7458 C","7459 C","7460 C","7461 C","7462 C","7463 C","304 C","305 C","306 C","307 C","308 C","309 C","635 C","636 C","637 C","638 C","639 C","640 C","641 C","7702 C","7703 C","7704 C","7705 C","7706 C","7707 C","7708 C","628 C","629 C","630 C","631 C","632 C","633 C","634 C","310 C","311 C","312 C","313 C","314 C","315 C","316 C","3105 C","3115 C","3125 C","3135 C","3145 C","3155 C","3165 C","7709 C","7710 C","7711 C","7712 C","7713 C","7714 C","7715 C","317 C","318 C","319 C","320 C","321 C","322 C","323 C","7464 C","7465 C","7466 C","7467 C","7468 C","7469 C","7470 C","7471 C","7472 C","7473 C","7474 C","7475 C","7476 C","7477 C","5523 C","5513 C","5503 C","5493 C","5483 C","5473 C","5463 C","7716 C","7717 C","7718 C","7719 C","7720 C","7721 C","7722 C","324 C","325 C","326 C","327 C","328 C","329 C","330 C","3242 C","3252 C","3262 C","3272 C","3282 C","3292 C","3302 C","3245 C","3255 C","3265 C","3275 C","3285 C","3295 C","3305 C","3248 C","3258 C","3268 C","3278 C","3288 C","3298 C","3308 C","566 C","565 C","564 C","563 C","562 C","561 C","560 C","573 C","572 C","571 C","570 C","569 C","568 C","567 C","559 C","558 C","557 C","556 C","555 C","554 C","553 C","5595 C","5585 C","5575 C","5565 C","5555 C","5545 C","5535 C","5665 C","5655 C","5645 C","5635 C","5625 C","5615 C","5605 C","5527 C","5517 C","5507 C","5497 C","5487 C","5477 C","5467 C","621 C","622 C","623 C","624 C","625 C","626 C","627 C","331 C","332 C","333 C","334 C","335 C","336 C","337 C","338 C","339 C","340 C","341 C","342 C","343 C","7723 C","7724 C","7725 C","7726 C","7727 C","7728 C","7729 C","3375 C","3385 C","3395 C","3405 C","3415 C","3425 C","3435 C","344 C","345 C","346 C","347 C","348 C","349 C","350 C","351 C","352 C","353 C","354 C","355 C","356 C","357 C","7478 C","7479 C","7480 C","7481 C","7482 C","7483 C","7484 C","7730 C","7731 C","7732 C","7733 C","7734 C","7735 C","7736 C","7737 C","7738 C","7739 C","7740 C","7741 C","7742 C","7743 C","358 C","359 C","360 C","361 C","362 C","363 C","364 C","7485 C","7486 C","7487 C","7488 C","7489 C","7490 C","7491 C","365 C","366 C","367 C","368 C","369 C","370 C","371 C","372 C","373 C","374 C","375 C","376 C","377 C","378 C","580 C","579 C","578 C","577 C","576 C","575 C","574 C","5807 C","5797 C","5787 C","5777 C","5767 C","5757 C","5747 C","5875 C","5865 C","5855 C","5845 C","5835 C","5825 C","5815 C","5803 C","5793 C","5783 C","5773 C","5763 C","5753 C","5743 C","7492 C","7493 C","7494 C","7495 C","7496 C","7497 C","7498 C","7744 C","7745 C","7746 C","7747 C","7748 C","7749 C","7750 C","379 C","380 C","381 C","382 C","383 C","384 C","385 C","386 C","387 C","388 C","389 C","390 C","391 C","392 C","587 C","586 C","585 C","584 C","583 C","582 C","581 C","393 C","394 C","395 C","396 C","397 C","398 C","399 C","3935 C","3945 C","3955 C","3965 C","3975 C","3985 C","3995 C","600 C","601 C","602 C","603 C","604 C","605 C","606 C","607 C","608 C","609 C","610 C","611 C","612 C","613 C","461 C","460 C","459 C","458 C","457 C","456 C","455 C","614 C","615 C","616 C","617 C","618 C","619 C","620 C","7751 C","7752 C","7753 C","7754 C","7755 C","7756 C","7757 C","7758 C","7759 C","7760 C","7761 C","7762 C","7763 C","7764 C","7765 C","7766 C","7767 C","7768 C","7769 C","7770 C","7771 C","4545 C","4535 C","4525 C","4515 C","4505 C","4495 C","4485 C","454 C","453 C","452 C","451 C","450 C","449 C","448 C","7499 C","7500 C","7501 C","7502 C","7503 C","7504 C","7505 C","468 C","467 C","466 C","465 C","464 C","463 C","462 C","7506 C","7507 C","7508 C","7509 C","7510 C","7511 C","7512 C","719 C","720 C","721 C","722 C","723 C","724 C","725 C","475 C","474 C","473 C","472 C","471 C","470 C","469 C","726 C","727 C","728 C","729 C","730 C","731 C","732 C","4685 C","4675 C","4665 C","4655 C","4645 C","4635 C","4625 C","7513 C","7514 C","7515 C","7516 C","7517 C","7518 C","7519 C","4755 C","4745 C","4735 C","4725 C","4715 C","4705 C","4695 C","482 C","481 C","480 C","479 C","478 C","477 C","476 C","7527 C","7528 C","7529 C","7530 C","7531 C","7532 C","7533 C","7534 C","7535 C","7536 C","7537 C","7538 C","7539 C","7540 C","427 C","428 C","429 C","430 C","431 C","432 C","433 C","420 C","421 C","422 C","423 C","424 C","425 C","426 C","441 C","442 C","443 C","444 C","445 C","446 C","447 C","413 C","414 C","415 C","416 C","417 C","418 C","419 C","400 C","401 C","402 C","403 C","404 C","405 C","406 C","407 C","408 C","409 C","410 C","411 C","412 C","434 C","435 C","436 C","437 C","438 C","439 C","440 C","Warm Gray 1 C","Warm Gray 2 C","Warm Gray 3 C","Warm Gray 4 C","Warm Gray 5 C","Warm Gray 6 C","Warm Gray 7 C","Warm Gray 8 C","Warm Gray 9 C","Warm Gray 10 C","Warm Gray 11 C","Cool Gray 1 C","Cool Gray 2 C","Cool Gray 3 C","Cool Gray 4 C","Cool Gray 5 C","Cool Gray 6 C","Cool Gray 7 C","Cool Gray 8 C","Cool Gray 9 C","Cool Gray 10 C","Cool Gray 11 C","Black 2 C","Black 3 C","Black 4 C","Black 5 C","Black 6 C","Black 7 C"],kt=["FEDD00","FFD700","FE5000","F9423A","EF3340","CE0058","E10098","BB29BB","440099","10069F","001489","0085CA","00AB84","2D2926","F2F0A1","FCAEBB","F1B2DC","BF9BDE","74D1EA","9DE7D7","9E978E","009ACE","44D62C","FFE900","FFAA4D","FF7276","FF3EB5","EA27C2","84754E","85714D","866D4B","8B6F4E","87674F","8B634B","8A8D8F","FFD900","FF5E00","F93822","CE0056","D62598","4E008E","00239C","0084CA","00B08B","222223","F6EB61","F7EA48","FCE300","C5A900","AF9800","897A27","F5E1A4","ECD898","EED484","F4DA40","F2CD00","F1C400","CBA052","F9E547","FBE122","FEDB00","FFD100","DAAA00","AA8A00","9C8412","FAE053","FBDD40","FDDA24","FFCD00","C99700","AC8400","897322","F3DD6D","F3D54E","F3D03E","F2A900","CC8A00","A07400","6C571B","F8E08E","FBD872","FFC845","FFB81C","C69214","AD841F","886B25","FBDB65","FDD757","FED141","FFC72C","EAAA00","B58500","9A7611","FFC600","FFB500","D19000","B47E00","73531D","5A4522","4B3D2A","D29F13","B78B20","9F7D23","967126","8F6A2A","7D622E","6C5D34","FDD26E","FFC658","FFBF3F","FFA300","DE7C00","AF6D04","74531C","FDD086","FFC56E","FFB549","FF9E1B","D57800","996017","6E4C1E","F2C75C","F1BE48","F1B434","ED8B00","CF7F00","A76D11","715C2A","F6BE00","F0B323","FEAD77","E6A65D","D38235","DC8633","C16C18","BD9B60","D69A2D","DB8A06","CD7925","AD6433","89532F","775135","D78825","D3832B","C67D30","B67233","A7662B","9E6A38","835D32","FCC89B","FDBE87","FDAA63","F68D2E","EA7600","D45D00","BE4D00","FECB8B","FFC27B","FFB25B","FF8200","E57200","BE6A14","9B5A1A","EFD19F","EFBE7D","ECA154","E87722","CB6015","A1561C","603D20","FFAE62","FF8F1C","FF6900","B94700","94450B","653819","FFB990","FFA06A","FF7F32","FF6A13","D86018","A65523","8B4720","FFBE9F","FF9D6E","FF7F41","FF671F","E35205","BE531C","73381D","DB864E","E07E3C","DC6B2F","DC582A","C05131","864A33","674736","FFA38B","FF8D6D","FF6A39","FC4C02","DC4405","A9431E","833921","FFB3AB","FF8674","FF5C39","FA4616","CF4520","963821","6B3529","C4622D","BA5826","AF5C37","9E5330","924C2E","7B4D35","5C4738","D4B59E","C07D59","B15533","9D432C","7C3A2D","6B3D2E","5C3D31","D14124","BD472A","B33D26","8D3F2B","83412C","7B4931","674230","E4D5D3","E1BBB4","D6938A","C26E60","A4493D","823B34","683431","DDBCB0","CA9A8E","BC8A7E","A37F74","866761","6B4C4C","583D3E","EABEB0","C09C83","B46A55","AB5C57","A45248","9A6A4F","8A391B","ECC3B2","ECBAA8","EAA794","E8927C","DA291C","9A3324","653024","FFB1BB","FF808B","FF585D","E03C31","BE3A34","81312F","FFA3B5","FF8DA1","F8485E","EE2737","D22630","AF272F","7C2529","FCAFC0","FB637E","F4364C","CB333B","A4343A","643335","C66E4E","C04C36","B7312C","AB2328","93272C","8A2A2B","802F2D","E1523D","C63527","A72B2A","9E2A2B","6D3332","633231","572D2D","E6BAA8","E56A54","E04E39","CD545B","B04A5A","9B2242","651D32","FABBCB","FC9BB3","F65275","E4002B","C8102E","A6192E","76232F","ECC7CD","E89CAE","DF4661","D50032","BA0C2F","9D2235","862633","F8A3BC","F67599","EF426F","E40046","BF0D3E","9B2743","782F40","F5B6CD","F59BBB","EF4A81","E0004D","C5003E","A6093D","8A1538","F5DADF","F7CED7","F9B5C4","F890A5","EF6079","E03E52","CB2C30","F2D4D7","F4C3CC","F2ACB9","E68699","D25B73","B83A4B","9E2A2F","ECB3CB","E782A9","E0457B","CE0037","A50034","861F41","6F263D","F99FC9","F57EB6","F04E98","E31C79","CE0F69","AC145A","7D2248","F4CDD4","E06287","E24585","B52555","A4123F","971B2F","6A2C3E","D6C9CA","C4A4A7","C16784","C63663","BC204B","912F46","7E2D40","EABEDB","E56DB1","DA1884","A50050","910048","6C1D45","936D73","934054","8E2C48","732E4A","672E45","582D40","502B3A","EF95CF","EB6FBD","DF1995","D0006F","AA0061","890C58","672146","F4A6D7","F277C6","E93CAC","C6007E","A20067","840B55","EAD3E2","E6BCD8","DFA0C9","D986BA","C6579A","AE2573","960051","E5CEDB","E3C8D8","DEBED2","C996B6","B06C96","994878","7C2855","E4C6D4","DCB6C9","D0A1BA","BE84A3","A76389","893B67","612141","EBBECB","E8B3C3","E4A9BB","D592AA","84344E","6F2C3F","572932","E2BCCB","DCA9BF","C9809E","B55C80","A73A64","9B3259","872651","E9CDD0","E4BEC3","D7A3AB","C48490","B46B7A","984856","893C47","F2C6CF","F1BDC8","E9A2B2","DC8699","8F3237","7F3035","5D2A2C","E9C4C7","E5BAC1","DAA5AD","C6858F","7A3E3A","6A3735","512F2E","DFC2C3","DBB7BB","CCA1A6","B07C83","9C6169","874B52","3F2021","F1A7DC","EC86D0","E45DBF","DB3EB1","C5299B","AF1685","80225F","EFBAE1","E277CD","D539B5","C800A1","B0008E","9E007E","830065","EAB8E4","E59BDC","DD7FD3","C724B1","BB16A3","A51890","80276C","A56E87","A83D72","991E66","8A1B61","722257","6A2A5B","5E2751","E7BAE4","DD9CDF","C964CF","AD1AAC","981D97","72246C","EBC6DF","E6BEDD","E2ACD7","D48BC8","93328E","833177","612C51","EEDAEA","CCAED0","D59ED7","B288B9","A277A6","9F5CC0","963CBD","D7A9E3","C98BDB","AC4FC6","9B26B6","87189D","772583","653165","948794","A2789C","A15A95","8E3A80","6E2B62","6A3460","5D3754","D5C2D8","C9B1D0","BA9CC5","A57FB2","642F6C","59315F","4B3048","DBCDD3","D0BEC7","C6B0BC","AF95A6","86647A","66435A","4A3041","D8C8D1","D3C0CD","BFA5B8","9B7793","7E5475","693C5E","512A44","DFC8E7","D7B9E4","CAA2DD","B580D1","8031A7","702F8A","572C5F","D6BFDD","C6A1CF","8C4799","6D2077","642667","5D285F","51284F","CBA3D8","B884CB","A05EB5","84329B","702082","671E75","5F2167","9991A4","8D6E97","7A4183","6B3077","653279","5E366E","5C4E63","C1A0DA","A77BCA","8246AF","5C068C","500778","470A68","3C1053","D7C6E6","C1A7E2","9063CD","753BBD","5F259F","582C83","512D6D","C5B4E3","AD96DC","9678D3","7D55C7","330072","2E1A47","B4B5DF","9595D2","7474C1","24135F","211551","201747","221C35","A7A4E0","8B84D7","685BC7","2E008B","280071","250E62","201547","6E7CA0","686E9F","615E9B","565294","514689","4C4184","535486","DDDAE8","B6B8DC","A7A2C3","8986CA","5D4777","4B384C","41273B","878CB4","7C7FAB","7566A0","6F5091","68478D","563D82","523178","E5E1E6","E0DBE3","C6BCD0","A192B2","7C6992","614B79","3F2A56","D8D7DF","C6C4D2","B3B0C4","8D89A5","595478","403A60","1E1A34","C5CFDA","BBC7D6","A2B2C8","8E9FBC","1B365D","1F2A44","1C1F2A","D9E1E2","A4BCC2","98A4AE","768692","425563","253746","131E29","B9D3DC","A3C7D2","8DB9CA","6BA4B8","003D4C","00313C","072B31","BFCED6","B7C9D3","A6BBC8","7A99AC","5B7F95","4F758B","081F2C","D1DDE6","C6D6E3","9BB8D3","7DA1C4","5E8AB4","236192","002E5D","DBE2E9","CED9E5","A7BCD6","7D9BC1","326295","003A70","002554","DDE5ED","C8D8EB","B1C9E8","7BA4DB","407EC9","003594","001A70","BDC5DB","89ABE3","8094DD","7BA6DE","5F8FB4","3A5DAE","606EB2","CBD3EB","9FAEE5","485CC7","1E22AA","171C8F","151F6D","141B4D","B8CCEA","5C88DA","0047BB","06038D","001871","001E62","071D49","C3D7EE","A7C6ED","307FE2","001A72","001E60","13294B","ABCAE9","8BB8E8","418FDE","012169","00205B","041E42","92C1E9","6CACE4","0072CE","0033A0","003087","002D72","0C2340","94A9CB","6787B7","426DA9","385E9D","2C5697","1D4F91","1D428A","C6DAE7","BDD6E6","A4C8E1","7BAFD4","003C71","003057","00263A","B9D9EB","9BCBEB","69B3E7","003DA5","002F6C","002855","041C2C","8DC8E8","62B5E5","009CDE","0057B8","004C97","003865","00263E","71C5E8","41B6E6","00A3E0","005EB8","004B87","003B5C","002A3A","4698CB","298FC2","0076A8","006298","005587","004976","01426A","99D6EA","5BC2E7","00A9E0","0077C8","00629B","004F71","003E51","7BA7BC","6399AE","4E87A0","41748D","34657F","165C7D","005776","BBDDE6","71B2C9","4298B5","0086BF","007DBA","00558C","002B49","9ADBE8","59CBE8","00B5E2","006BA6","00587C","003B49","A4DBE8","8BD3E6","4EC3E0","00AFD7","0095C8","0082BA","0067A0","48A9C5","009CBD","0085AD","007096","006A8E","00617F","005670","B8DDE1","9BD3DD","77C5D5","3EB1C8","0093B2","007396","005F83","6AD1E3","05C3DE","00A9CE","0092BC","007FA3","00677F","004851","68D2DF","00C1D5","00AEC7","008EAA","00778B","006272","004F59","63B1BC","00A7B5","0097A9","00859B","007D8A","007680","006269","B1E4E3","88DBDF","2DCCD3","009CA6","008C95","007377","005F61","A0D1CA","40C1AC","00B0B9","00A3AD","007398","005F86","005A70","7EDDD3","5CB8B2","279989","007681","487A7B","0D5257","244C5A","B6CFD0","ABC7CA","94B7BB","7FA9AE","4F868E","115E67","07272D","00968F","00857D","007672","006D68","00635B","005E5D","005151","9CDBD9","64CCC9","00B2A9","008675","007367","00685E","00534C","71DBD4","2AD2C9","00BFB3","00A499","008578","00594F","004C45","7CE0D3","2CD5C4","00C7B1","00B398","009681","007864","004E42","6DCDB8","49C5B1","00AB8E","009B77","008264","006A52","034638","B9DCD2","A1D6CA","86C8BC","6BBBAE","006F62","00594C","1D3C34","B5E3D8","A5DFD3","98DBCE","6BCABA","00816D","006C5B","173F35","ADCAB8","9ABEAA","85B09A","6FA287","28724F","205C40","284734","BFCEC2","A7BDB1","92ACA0","7F9C90","5C7F71","43695B","183028","BAC5B9","B0BDB0","A3B2A4","94A596","708573","5E7461","22372B","BCC9C5","B1C0BC","9DB0AC","829995","5D7975","3E5D58","18332F","D1E0D7","B7CDC2","9AB9AD","789F90","507F70","285C4D","13322B","A7E6D7","8CE2D0","3CDBC0","009775","007B5F","00664F","8FD6BD","6ECEB2","00B388","00965E","007A53","006747","115740","50A684","00966C","008755","007B4B","006F44","006845","005844","7AE1BF","47D7AC","00C389","00AF66","007749","006341","154734","A0DAB3","91D6AC","71CC98","009A44","00843D","046A38","2C5234","A2E4B8","8FE2B0","80E0A7","00B140","009639","007A33","215732","9BE3BF","26D07C","00BF6F","00B74F","009F4D","275D38","00573F","4B9560","228848","007A3E","007041","286140","36573B","395542","6BA539","48A23F","319B42","3A913F","44883E","4A773C","44693D","ADDC91","A1D884","6CC24A","43B02A","509E2F","4C8C2B","4A7729","D0DEBB","BCE194","8EDD65","78D64B","74AA50","719949","79863C","C2E189","B7DD79","A4D65E","78BE20","64A70B","658D1B","546223","D4EB8E","CDEA80","C5E86C","97D700","84BD00","7A9A01","59621D","C4D6A4","BCD19B","B7CE95","A9C47F","789D4A","67823A","4E5B31","D0D1AB","C6C89B","BABD8B","A2A569","8A8D4A","6D712E","3D441E","D2CE9E","CBC793","C0BB87","AFA96E","A09958","89813D","555025","C3C6A8","B3B995","A3AA83","899064","737B4C","5E6738","3E4827","BFCC80","BBC592","9CAF88","8F993E","76881D","7A7256","5B6236","BABC16","ABAD23","999B30","888D30","7C8034","727337","656635","E2E868","DBE442","CEDC00","C4D600","A8AD00","949300","787121","E9EC6B","E3E935","E0E721","D0DF00","B5BD00","9A9500","827A04","E3E48D","E0E27C","DBDE70","D2D755","B7BF10","8E8C13","625D20","F0EC74","EDE939","ECE81A","E1E000","BFB800","ADA400","A09200","F3EA5D","F3E500","EFDF00","EEDC00","BBA600","9A8700","685C20","F1EB9C","F0E991","F0E87B","EDE04B","EADA24","E1CD00","CFB500","EBE49A","E9E186","E6DE77","E1D555","D7C826","C4B000","B39B00","E9DF97","E4D77E","DECD63","D9C756","B89D18","A28E2A","695B24","DCD59A","D6CF8D","D0C883","C0B561","AC9F3C","9F912A","8A7B19","CAB64B","CFB023","C1A01E","A08629","897630","736635","675E33","D4C304","C4B200","91852C","747136","5D6439","585C3B","535435","BBB323","B4A91F","AA9D2E","8F7E35","716135","635939","4E4934","D5CB9F","CFC493","C5B783","B3A369","998542","8C7732","614F25","CAC7A7","BFBB98","B0AA7E","9B945F","594A25","524727","4A412A","F1E6B2","DFD1A7","D9C89E","CEB888","A89968","94795D","816040","DDCBA4","D3BC8D","C6AA76","B9975B","8B5B29","744F28","5C462B","EFDBB2","FCD299","E1B87F","D6A461","C6893F","B77729","A6631B","EDC8A3","E7B78A","DDA46F","C88242","B36924","934D11","7D3F16","F3CFB3","F1C6A7","F0BF9B","E59E6D","B86125","A45A2A","693F23","E0C09F","D9B48F","CDA077","B58150","9E652E","774212","623412","E0C6AD","DCBFA6","CDA788","BF9474","AD7C59","946037","4F2C1D","E1B7A7","D5A286","C58B68","99552B","85431E","6D4F47","5E4B3C","D7C4B7","CDB5A7","C0A392","AE8A79","956C58","7C4D3A","5B3427","DBC8B6","D3BBA8","C6A992","AA8066","703F2A","623B2A","4E3629","D6D2C4","C5B9AC","B7A99A","A39382","7A6855","63513D","473729","D1CCBD","B7B09C","A69F88","A7ACA2","949A90","8E9089","4B4F54","D0D3D4","C1C6C8","A2AAAD","7C878E","5B6770","333F48","1D252D","C7C9C7","B2B4B2","9EA2A2","898D8D","707372","54585A","25282A","BEC6C4","A2ACAB","919D9D","717C7D","505759","3F4444","373A36","BABBB1","A8A99E","919388","7E7F74","65665C","51534A","212322","C4BFB6","AFA9A0","9D968D","8C857B","776E64","696158","C4BCB7","B2A8A2","978C87","857874","746661","5E514D","382F2D","D0C4C5","C1B2B6","AB989D","7B6469","584446","453536","382E2C","D7D2CB","CBC4BC","BFB8AF","B6ADA5","ACA39A","A59C94","968C83","8C8279","83786F","796E65","6E6259","D9D9D6","D0D0CE","C8C9C7","BBBCBC","B1B3B3","A7A8AA","97999B","888B8D","75787B","63666A","53565A","332F21","212721","31261D","3E2B2E","101820","3D3935"],be=kt.map(n=>[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)]);function Bi(n){const t=Zt.indexOf(n);return t>=0?kt[t]:""}function Da(n){const t=kt.indexOf(n);return t>=0?Zt[t]:""}function hi(n,t=64){const e=[],A=[],a=Da(n);a&&e.push({pms:a,hex:n,distance:0});const i=parseInt(n.substring(0,2),16),s=parseInt(n.substring(2,4),16),o=parseInt(n.substring(4,6),16);let r,c,l;for(let g=0;g<kt.length;g++){r=be[g][0],c=be[g][1],l=be[g][2];const d=Math.sqrt(Math.pow(i-r,2)+Math.pow(s-c,2)+Math.pow(o-l,2));A.push(d)}for(let g=0;g<A.length;g++)A[g]<=t&&!e.some(d=>d.pms===Zt[g])&&e.push({pms:Zt[g],hex:kt[g],distance:A[g]});return e.sort((g,d)=>g.distance-d.distance)}const Ci=Zt.map((n,t)=>({pms:n,hex:kt[t]})),ui=new On(Ci,{keys:["pms"]});function wi(n,t){return ui.search(n,t?{limit:t}:void 0)}let Ht=null;function ya(n){if(n.startsWith("#"))return KA(n);if(!document)throw new Error("browserColorToHex is only supported on browsers");if(Ht||(Ht=document.createElement("canvas").getContext("2d")),!Ht)throw new Error("Failed to create canvas context required to convert colors");Ht.fillStyle=n;const t=KA(Ht.fillStyle);return t||console.error(`Unknown browser color ${n}`),t}function KA(n){const t=n.substring(1).toUpperCase();return t.length===6?t:t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:""}const ge=n=>{const t=Fa(n.spotColor);return t?`${n.browserValue} ${t}`:n.browserValue},Fa=n=>{if(!n)return"";if(n.profileName.includes("/")&&n.profileName.includes(".icc")){const t=n.profileName.replace(/\s/g,"-"),e=t.lastIndexOf("/");return`icc-named-color(${t.slice(e+1).slice(0,-4)}, ${n.namedColor})`}return`icc-named-color(${n.profileName}, ${n.namedColor})`},Ze=n=>{const t=n.split(/[ ](?=[^)]*?(?:\(|$))/);if(t.length===0)return{browserValue:"#000000"};if(t.length===1)return{browserValue:t[0]};const e=t[1].match(/\(([^)]+)\)/gm);if(!e)throw new Error("Unhandled state of color value in SVG");const A=e[0].replace(/[() ]/g,"").split(",");return{browserValue:t[0],spotColor:{profileName:A[0],namedColor:A[1]}}},Ei=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],mi=["fill","stroke"],Nt=(n,t)=>{t(n),n.children.length>0&&Array.from(n.children).forEach(e=>Nt(e,t))},fi=(n,t)=>{try{return n.matches(t)}catch{return n.classList.contains(t.substring(1))}},ye=(n,t=!1)=>{!t&&n.setAttribute("preserveAspectRatio","none");const e=[];Nt(n,A=>{var i,s,o;if(A.tagName==="script"){A.remove();return}if(A.tagName==="style"){try{(i=na.parse(A.innerHTML).stylesheet)==null||i.rules.forEach(c=>{e.push(c)}),A.remove()}catch(r){console.error(r)}return}const a=(o=(s=A.attributes.getNamedItem("style"))==null?void 0:s.value)==null?void 0:o.trim();if(a){const r=[];a.split(";").forEach(l=>{const g=l.trim();if(g){const[d,B]=g.split(":"),h=d.toLowerCase();mi.indexOf(h)>-1?A.setAttribute(h,B.trim()):r.push(g)}}),r.length>0?A.setAttribute("style",r.join(";")):A.removeAttribute("style")}}),Nt(n,A=>{e.forEach(a=>{var i;(i=a.selectors)==null||i.forEach(s=>{var o;fi(A,s)&&((o=a.declarations)==null||o.forEach(r=>{r.property&&r.value&&A.setAttribute(r.property,r.value)}))})})})},Qi=n=>{const t=/pt|pc|mm|cm|in/gm,e=n.getAttribute("viewBox"),A=n.getAttribute("width"),a=n.getAttribute("height");if(!e)throw new Error("viewBox not specified on SVG!");A&&n.setAttribute("width",A.replace(t,"")),a&&n.setAttribute("height",a.replace(t,""))},Ma=n=>it().parseFromString(n,"image/svg+xml").firstElementChild,pi=(n,t,e)=>{n.setAttribute("height",`${e}px`),n.setAttribute("width",`${t}px`)},Sa=(n,t,e)=>{Nt(n,A=>{const a=A.attributes.getNamedItem("fill");a&&a.value!=="none"&&A.classList.forEach(s=>{if(s.startsWith("spiff-fill")){const o=t[s.replace("spiff-fill-","")];if(o)A.setAttribute("fill",e?ge(o):o.browserValue);else{const r=t[s];r&&A.setAttribute("fill",e?ge(r):r.browserValue)}}});const i=A.attributes.getNamedItem("stroke");i&&i.value!=="none"&&A.classList.forEach(s=>{if(s.startsWith("spiff-stroke")){const o=t[s.replace("spiff-stroke-","")];if(o)A.setAttribute("stroke",e?ge(o):o.browserValue);else{const r=t[s];r&&A.setAttribute("fill",e?ge(r):r.browserValue)}}})})},xa=n=>wt().serializeToString(n),CA=(n,t,e,A,a)=>{const i=Ma(n);if(!i)throw new Error("Failed to read SVG.");return pi(i,t,e),Sa(i,A,a),xa(i)},Ya=(n,t,e)=>{const A=Ma(n);if(!A)throw new Error("Failed to read SVG.");return Sa(A,t,e),xa(A)},Ii=n=>{const t=/<svg.*<\/svg>/s,e=n.match(t)||[],A=(e==null?void 0:e.length)>0?e[0]:"";return it().parseFromString(A,"image/svg+xml")},st=async n=>{const e=Ii(n).firstElementChild;if(!e)throw new Error("Failed to read SVG.");ye(e);const A={};Nt(e,s=>{Ei.includes(s.tagName)&&!s.attributes.getNamedItem("fill")&&s.setAttribute("fill","black");const o=s.attributes.getNamedItem("fill");if(o&&o.value!=="none"&&!o.value.startsWith("url(")){const c=Ze(o.value),l=c.browserValue.replace(/\W/g,""),g=`spiff-fill-${l}`;s.setAttribute("fill",c.browserValue),s.classList.add(g),A[l]=c}const r=s.attributes.getNamedItem("stroke");if(r&&r.value!=="none"&&!r.value.startsWith("url(")){const c=Ze(r.value),l=c.browserValue.replace(/\W/g,""),g=`spiff-stroke-${l}`;s.classList.add(g),s.setAttribute("stroke",c.browserValue),A[l]=c}});const i=wt().serializeToString(e);return{colors:A,svg:i}},Di=Q.gql`
2
2
  fragment AssetMetadataFields on Asset {
3
3
  metadata {
4
4
  key
@@ -3155,7 +3155,7 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
3155
3155
  mutation RejectTransaction($id: String!, $note: String) {
3156
3156
  transactionReject(id: $id, note: $note)
3157
3157
  }
3158
- `;var re=(n=>(n.Error="Error",n.Warning="Warning",n.Info="Info",n))(re||{});const Ko=1e3;class Aa extends wA{constructor(t){super(),this.createdAt=new Date,this.update=t}async execute(){await this.update(),await new Promise(t=>{window.setTimeout(()=>{t()},Ko)})}}class Wo{constructor(t,e,A,a,i,s,o,r,c,l,g,d,B=!1,h,C=!1,u=!1,w=!1){this.workflowStatePromiseQueue=new EA(1),this.initialized=!1,this.readOnly=!1,this.isReloadedTransaction=!1,this.singleVariantsRenderable=!1,this.stepTags={},this.renderLayouts=()=>{var f;if(!this.previewService)return;const E=this.getCommandContext().getAllLayouts(),m=(f=this.getLayoutPreviewService())==null?void 0:f.getAll();if(m)for(const[,p]of m)p.render(E)},this.experience=t,this.client=e,this.updateTransaction=o,this.commandContext=s,this.reloadedState=d,this.transaction=r,this.readOnly=B,this.singleVariantsRenderable=u,this.confirmedDesign=!1,this.editedSteps={},this.informationResults=[],this.mandatorySteps={},this.pendingUpdates=[],this.selectionCost=0,this.workflow=A,this.stepSpecificServices={},this.profanityFilter=a,this.pollers=[],this.allScenes=[],this.layouts=i,this.product=c,this.previewService=l,this.modelContainer=h,this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},this.validationErrors={steps:new Map},this.confirmCallbacks=[],this.editedCallbacks=[],this.elementsCallbacks=[],this.informationResultCallbacks=[],this.initCallbacks=[],this.mandatoryCallbacks=[],this.makingAdjustmentsCallback=[],this.metadataCallbacks=[],this.selectionCallbacks=[],this.stepSpecificStorageCallbacks={},this.storageCallbacks=[],this.validationCallbacks=[],this.currentAdjustingStepId="",this.renderableContextService=g,this.isReloadedTransaction=C,this.workflow.steps.forEach(E=>{this.stepTags[E.stepName]=E.tags??[]}),w&&(this.workflowStatePromiseQueue.enabled=!1),this.initializationPromise=this.initializeDefaultWorkflowState(A),this.initializationPromise.then(()=>{this.initialized=!0}),this.initializationPromise.catch(E=>{throw console.error(E),this.initialized=!1,new Error("Workflow initialization failed due to an error. See console.")}),this.initializationPromise.finally(()=>this.getCommandContext().registerStateCallback(()=>{this.updateStateWithServer(),this.renderLayouts()}))}async initializeDefaultWorkflowState(t){const e=()=>{var l,g;const o=this.workflow.finalizeStepConfig;if(!o)return;const r=o.lookAtAnimation,c=o.modelAnimation;r&&((l=this.previewService)==null||l.executeCameraAnimation(r)),c&&((g=this.modelContainer)==null||g.executeAnimation(c))};this.reloadedState&&this.reloadedState.serializableWorkflow.steps.forEach(o=>{this.storage[o.stepName]=o.storage||{}}),this.allScenes=await ss(t);const a=Ft(this.allScenes,this.stepSelections).map(o=>o.silentSteps).flat(),{stepElements:i,commands:s}=await this.stepElementsForIntroducedSilentSteps(a,!!this.reloadedState);this.commandContext.apply(new G(s),!0),this.stepElements={...this.stepElements,...i},await this.ensureStepsAreLoaded(),!this.isReloadedTransaction&&this.updateStateWithServer(),this.renderLayouts(),this.reloadedState&&e()}getWorkflowExperience(){return this.experience}getClient(){return this.client}setWorkflowStateSyncEnabled(t){this.workflowStatePromiseQueue.enabled=t}getProduct(){return this.product}getInitializationPromise(){return this.initializationPromise}isInitialized(){return this.initialized}addConfirmCallback(t){t(this.confirmedDesign),this.confirmCallbacks.push(t)}addEditedCallback(t){t(this.editedSteps),this.editedCallbacks.push(t)}addElementsCallback(t){t(this.stepElements),this.elementsCallbacks.push(t)}addInformationResultCallback(t){t(this.informationResults),this.informationResultCallbacks.push(t)}addInitCallback(t){t(this.stepInitialised),this.initCallbacks.push(t)}addMandatoryCallback(t){t(this.mandatorySteps),this.mandatoryCallbacks.push(t)}addMetadataCallback(t){t(this.stepMetadata),this.metadataCallbacks.push(t)}async addSelectionCallback(t){t({selectionCost:this.selectionCost,selections:this.stepSelections,traversableScenes:await this.traversableScenes()}),this.selectionCallbacks.push(t)}addStepSpecificStorageCallback(t,e){Object.keys(this.storage).includes(e)||(this.storage[e]={}),t(this.storage[e]),Object.keys(this.stepSpecificStorageCallbacks).includes(e)||(this.stepSpecificStorageCallbacks[e]=[]),this.stepSpecificStorageCallbacks[e].push(t)}addStorageCallback(t){t(this.storage),this.storageCallbacks.push(t)}addMakingAdjustmentsCallback(t){t(this.currentAdjustingStepId),this.makingAdjustmentsCallback.push(t)}addPoller(t){this.pollers.push(t)}addValidationCallback(t){this.validationCallbacks.push(t),t(this.validationErrors)}getLayouts(){return this.layouts}getAllLayoutData(){return this.commandContext.getAllLayouts().map(t=>t.layoutState)}getLayoutPreviewService(){return this.renderableContextService}getInformationResults(){return this.informationResults}getPreviewService(){return this.previewService}getProfanities(){return this.profanityFilter}getCommandContext(){return this.commandContext}getRegionElements(t){return this.stepElements[t]||[]}getStepSpecificServices(t){return this.stepSpecificServices[t]}getTransaction(){return this.transaction}getTransactionCustomer(){return this.ownerCustomer}setTransactionCustomer(t){this.ownerCustomer=t}setTransactionCustomerDetails(t){this.ownerCustomer={...this.ownerCustomer,emailAddress:t.email}}getModelContainer(){return this.modelContainer}setModelContainer(t){(!t||this.previewService&&this.previewService.getAllModels().includes(t))&&(this.modelContainer=t,t&&t.metadata&&t.metadata instanceof Map&&this.modelContainer.metadata.set("workflowManager",this))}setTransaction(t){this.transaction=t}getWorkflow(){return this.workflow}getCommandDispatcher(){return t=>this.commandContext.apply(t,!this.initialized)}getWorkflowSelections(){const t={};return this.workflow.steps.forEach(e=>{const A=this.stepSelections[e.stepName];A&&A.selectedVariants&&A.selectedVariants.length>0&&(t[e.stepName]={selections:A.selectedVariants})}),t}getStepSelections(){return this.stepSelections}markStepsAsInitialised(t){const e={...this.stepInitialised};t.forEach(A=>{e[A]=!0}),this.stepInitialised=e,this.onInitChange()}getUpdatesPending(){return this.pendingUpdates.length>0}markUpdateCompleted(t){this.pendingUpdates=this.pendingUpdates.filter(e=>e!==t)}markUpdatePending(){const t=b();return this.pendingUpdates=[...this.pendingUpdates,t],t}setEditedStatus(t,e){this.editedSteps={...this.editedSteps,[t]:e},this.onEditedChange()}setInformationResults(t){this.informationResults=[...t],this.onInformationResultChange()}setCurrentAdjustingStepId(t){this.currentAdjustingStepId=t,this.onMakingAdjustmentsChange()}setMandatoryFulfilled(t,e){this.mandatorySteps[t]!==e&&(this.mandatorySteps={...this.mandatorySteps,[t]:e},this.setInformationResults([]),this.onMandatoryChange())}setStepError(t,e,A){let a=!1;if(!this.validationErrors.steps.has(t)&&A)a=!0,this.validationErrors.steps.set(t,new Map([[e,A]]));else if(this.validationErrors.steps.has(t)){const i=this.validationErrors.steps.get(t);A&&A!==i.get(e)?(a=!0,i.set(e,A)):A||(a=!0,i.delete(e),i.size===0&&this.validationErrors.steps.delete(t))}a&&this.onValidationChange()}getStepErrors(t){return this.validationErrors.steps.get(t)}getValidationErrors(){return this.validationErrors}toggleDesignConfirmed(){this.confirmedDesign=!this.confirmedDesign,this.onConfirmChange()}toggleMakingAdjustmentsCallback(t){t(this.mandatorySteps),this.mandatoryCallbacks.push(t)}async injectIntoPreviewService(t,e){if(this.modelContainer)throw new Error("You must eject from the preview service before injecting again.");if(this.previewService=t,!this.getProduct().modelUrl||!this.previewService)return;const A=t.loadModel({model:this.getProduct().modelUrl,contextService:this.getLayoutPreviewService()},{refocusCamera:e});this.setModelContainer(A),Ft(this.allScenes,this.stepSelections).filter(s=>s).map(s=>s.renderableSteps).flat().filter(s=>s.type===M.Model||s.type===M.Material).forEach(s=>{var c,l,g;if(!((c=s.option)!=null&&c.id)){console.error(`Failed to read option id from step: ${s.stepName}`);return}const o=((l=this.stepSelections[s.stepName])==null?void 0:l.selectedVariants)||[];if(o.length===0)return;const r=o[0];if(s.type===M.Model){if(!this.modelContainer)throw new L("We should always have a model container when injecting a preview!");const d=(g=r.asset)==null?void 0:g.fileLink;if(!d){console.error(`Failed to read model url from variant: ${r.id} for step: ${s.stepName}`);return}const B=s.data;this.modelContainer.applyModelVariant(s.stepName,{model:d,contextService:this.getLayoutPreviewService()},B.replaceProductModel||!1)}else{const d=r.material;if(!d){console.error(`Failed to read material from variant: ${r.id} for step: ${s.stepName}`);return}s.data.targetMaterials.forEach(h=>{if(!this.modelContainer)throw new L("We should always have a model container when injecting a preview!");this.modelContainer.applyMaterialVariant(h,s.option.id,d)})}}),await A.getInitializationPromise(),this.renderLayouts()}ejectFromPreviewService(){if(this.modelContainer){if(!this.modelContainer.dispose)throw new Error("This feature is not supported in the current preview service.");this.modelContainer.dispose(),this.modelContainer=void 0}this.previewService=void 0}updateStorage(t,e){const A={...this.storage,[t]:{...this.storage[t],...e}};if(!sa(A,this.storage)){this.storage=A;const a=new $A(this.constructSerializableWorkflow());this.commandContext.apply(a,!0),this.onStepSpecificStorageChange(t),this.onStorageChange()}}constructSerializableWorkflow(){const t=[];return this.allScenes.forEach(e=>{e.renderableSteps.forEach(A=>{var i,s;const a={stepName:A.stepName};a.storage=this.storage[A.stepName],a.selectedVariants=(s=(i=this.stepSelections[A.stepName])==null?void 0:i.selectedVariants)==null?void 0:s.map(o=>({id:o.id,priceModifier:o.priceModifier})),t.push(a)})}),{steps:t}}updateStateWithServer(){if(this.readOnly)return;const t=this.serialize();this.workflowStatePromiseQueue.enqueue(new Aa(async()=>{await new Promise(e=>{setTimeout(()=>{e()},1)}),await this.updateTransaction({variables:{id:this.transaction.id,workflowState:t}})}))}async updateStateWithServerImmediate(){if(this.readOnly)return;const t=this.serialize();return new Aa(async()=>{await this.updateTransaction({variables:{id:this.transaction.id,workflowState:t}})}).execute()}serialize(){const t=this.getCommandContext().getState();if(!t)throw new L("Attempted to serialize state before it was initialized.");const e=xt(t.transaction),A=this.dehydrateState(e);return JSON.stringify(A)}dehydrateState(t){var e;for(const A of Object.values(t.layouts).map(a=>a.elements).flat())A.type==="illustration"&&(delete A.cachedObjectURL,A.src&&delete A.svg),A.type==="frame"&&((e=A.pattern)==null||delete e.svg);return this.deleteFieldNameFromObjectRecursive(t,"__typename"),t}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const A in t)A===e?delete t[A]:this.deleteFieldNameFromObjectRecursive(t[A],e)}async outstandingRequestsPromise(){return this.workflowStatePromiseQueue.finalize()}updateMetadata(t,e){this.stepMetadata={...this.stepMetadata,[t]:{...this.stepMetadata[t],...e}},this.onMetadataChange()}removeElements(t){const e=(A,a)=>Object.keys(A).reduce((i,s)=>{const o=[...A[s]||[]];return a.forEach(r=>{const c=o.findIndex(l=>l.id===r.id);c>-1&&o.splice(c,1)}),i[s]=o,i},{});this.stepElements=e(this.stepElements,t)}getInvalidCanvasRegions(){return this.workflow.steps.reduce((t,e)=>(ft(e,this.stepSelections)||this.stepElements[e.stepName]&&this.stepElements[e.stepName].forEach(A=>t.push(A)),t),[])}getInvalidModelVariants(){return this.workflow.steps.reduce((t,e)=>(e.type===M.Model&&!ft(e,this.stepSelections)&&t.push(e.stepName),t),[])}async stepElementsForIntroducedSilentSteps(t,e){const A=this.product;if(!A)return Promise.resolve({stepElements:{},commands:[]});const a=async(c,l,g)=>{if(c.type===M.SilentIllustration){const d=await new _A(c,l).trigger();return{step:c,results:d}}else if(c.type===M.ProductOverlay){const d=await new _A(c,l,g).trigger();return{step:c,results:d}}return Promise.reject("Unknown silent step. This is a bug")},i=t.filter(c=>!this.stepInitialised[c.stepName]),s={stepElements:{},commands:[]},o=[];for(const c of i)this.markStepsAsInitialised([c.stepName]),e||o.push(a(c,this.layouts,A));const r=await Promise.all(o);for(const c of r)s.stepElements[c.step.stepName]=c.results.map(l=>l.regionElement),s.commands=[...s.commands,...c.results.map(l=>l.command)];return s}getStepStorage(t){return this.storage[t]}getMetadata(t){return this.stepMetadata[t]}getWorkflowMetadata(){return this.stepMetadata}getStepTags(t){return this.stepTags[t]||[]}getSerializedStep(t,e){return e.find(A=>A.stepName===t)}async updateTransactionShareActions(){const t=await this.client.getShareActionsForTransaction(this.transaction.id);this.transaction.transactionShareActions=t}async updateTransactionStakeholders(){var e;const t=await y.getShadowGraphqlClient().query({query:Vi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.transaction.id}});!((e=t==null?void 0:t.data)!=null&&e.transactions)||t.data.transactions.length!==1?(this.transaction.currentStakeholder=void 0,this.transaction.stakeholders=void 0):(this.transaction.stakeholders=t.data.transactions[0].stakeholders,this.transaction.currentStakeholder=t.data.transactions[0].currentStakeholder)}async approveTransaction(t){await y.getShadowGraphqlClient().mutate({mutation:jo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.getTransaction().id,note:t}})}async rejectTransaction(t){await y.getShadowGraphqlClient().mutate({mutation:Vo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.getTransaction().id,note:t}})}async reset(){this.commandContext.getAllLayouts().forEach(e=>e.layoutState.elements.forEach(A=>{this.getCommandDispatcher()(new ut(A.id))})),this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},await this.ensureStepsAreLoaded()}async setSelectionsAndElements(t,e,A,a){var p;const i=this.stepSelections;this.stepSelections={...this.stepSelections,[t]:{selectedVariants:e}},this.selectionCost=Object.values(this.stepSelections).reduce((I,D)=>I+D.selectedVariants.map(F=>F.priceModifier||0).reduce((F,x)=>F+x,0),0),this.workflow.steps.forEach(I=>{ft(I,this.stepSelections)||(this.stepInitialised[I.stepName]=!1,delete this.stepMetadata[I.stepName],delete this.stepSelections[I.stepName],delete this.storage[I.stepName])});const s=this.allScenes,o=Ft(s,i),r=Ft(s,this.stepSelections),c=o.map(I=>I.silentSteps).flat(),g=r.map(I=>I.silentSteps).flat().filter(I=>!c.some(D=>D.stepName===I.stepName));c.forEach(I=>{ft(I,this.stepSelections)||(this.stepInitialised[I.stepName]=!1)});const d=this.getInvalidCanvasRegions(),{stepElements:B,commands:h}=await this.stepElementsForIntroducedSilentSteps(g,!1);this.stepElements={...this.stepElements,...B,[t]:A},this.removeElements(d);const C=this.workflow.steps.find(I=>I.stepName===t);if((C==null?void 0:C.type)===M.Frame){const I=(p=this.getWorkflowExperience().getStepById(C.stepName))==null?void 0:p.frameService;I==null||I.setTargetElements(A.map(D=>D.id))}const u=d.map(I=>new ut(I.id)),w=new $A(this.constructSerializableWorkflow()),E=[...h,...u,w];E.length>0&&this.commandContext.apply(new G(E),!0),await this.ensureStepsAreLoaded(),this.onElementsChange();const m=this.getInvalidModelVariants(),f=this.modelContainer;if(f){const I=m.map(D=>f.applyModelVariant(D,{contextService:this.getLayoutPreviewService()},!1));await Promise.all(I)}await this.onSelectionChange(),a&&await a()}async ensureStepsAreLoaded(){const e=Ft(this.allScenes,this.stepSelections).map(r=>r.renderableSteps),A=[],a=e.flat();for(const r of a)if(!this.stepInitialised[r.stepName])switch(this.stepInitialised[r.stepName]=!0,r.type){case M.DigitalContent:A.push(yA.init(r,this,this.reloadedState));break;case M.Frame:A.push(rt.init(r,this,this.reloadedState));break;case M.Illustration:A.push(jt.init(r,this,this.reloadedState));break;case M.Material:A.push(FA.init(r,this,this.reloadedState));break;case M.Model:A.push(MA.init(r,this,this.reloadedState));break;case M.Module:this.stepSpecificServices[r.stepName]={module:await sn(r.data.module)},A.push(SA.init(r,this,this.reloadedState));break;case M.Picture:A.push(xA.init(r,this,this.reloadedState));break;case M.Question:A.push(YA.init(r,this,this.reloadedState));break;case M.Shape:A.push(St.init(r,this,this.reloadedState));break;case M.Text:A.push(W.init(r,this,this.reloadedState));break}const i=(await Promise.allSettled(A)).map(r=>{if(r.status==="rejected")throw new Error(`Step initialization failed: ${r.reason}`);return r.value}),s=i.filter(r=>!!r&&!!r.command).map(r=>r.command),o=i.filter(r=>!!r&&!!r.followup).map(r=>r.followup);s&&s.length>0&&this.commandContext.apply(new G(s),!0);for(const r of o)await r();o.length>0&&await this.ensureStepsAreLoaded(),this.onInitChange()}onConfirmChange(){this.confirmCallbacks.forEach(t=>t(this.confirmedDesign))}onEditedChange(){this.editedCallbacks.forEach(t=>t(this.editedSteps))}onElementsChange(){this.elementsCallbacks.forEach(t=>t(this.stepElements))}onInformationResultChange(){this.informationResultCallbacks.forEach(t=>t(this.informationResults))}onInitChange(){this.initCallbacks.forEach(t=>t(this.stepInitialised))}onMakingAdjustmentsChange(){this.makingAdjustmentsCallback.forEach(t=>{t(this.currentAdjustingStepId)})}onMandatoryChange(){this.mandatoryCallbacks.forEach(t=>t(this.mandatorySteps))}onMetadataChange(){this.metadataCallbacks.forEach(t=>{t(this.stepMetadata)})}async onSelectionChange(){const t=await this.traversableScenes();for(const e of this.selectionCallbacks)e({selectionCost:this.selectionCost,selections:this.stepSelections,traversableScenes:t})}onStepSpecificStorageChange(t){Object.keys(this.stepSpecificStorageCallbacks).includes(t)||(this.stepSpecificStorageCallbacks[t]=[]),this.stepSpecificStorageCallbacks[t].forEach(e=>e(this.storage[t]))}onStorageChange(){this.storageCallbacks.forEach(t=>t(this.storage))}onValidationChange(){this.validationCallbacks.forEach(t=>t(this.validationErrors))}traversableScenes(){return cs(this.allScenes,this.stepSelections,this.singleVariantsRenderable)}}class at{constructor(t){this.variantData=t}getType(){var t;return(t=this.variantData.asset)==null?void 0:t.type}getId(){return this.variantData.id}getName(){return this.variantData.name}getPriceFormatted(t,e){return this.variantData.priceModifier.toLocaleString(t||"en-US",{style:"currency",currency:"USD",...e})}getPrice(){return this.variantData.priceModifier}getAsset(){var t,e,A;return(A=(e=(t=this.variantData.asset)==null?void 0:t.versions)==null?void 0:e.find(a=>a.name==="cdn"))==null?void 0:A.link}getAssetResource(){return this.variantData.asset}getThumbnail(){var A,a,i,s;const t=(i=(a=(A=this.variantData.thumbnail)==null?void 0:A.versions)==null?void 0:a.find(o=>o.name==="thumbnail"))==null?void 0:i.link,e=(s=this.variantData.thumbnail)==null?void 0:s.fileLink;return t||e}getColor(){return this.variantData.color}isDefault(){return!!this.variantData.default}getResource(){return this.variantData}isEnabled(){return this.variantData.enabled}}const on=class iA{constructor(t,e,A){this.manager=t,this.step=e,this.tags=A}setUpdateState(t){iA.updateState.set(`${this.step.stepName}-${this.manager.getTransaction().id}`,t)}getUpdateState(){return!!iA.updateState.get(`${this.step.stepName}-${this.manager.getTransaction().id}`)}getCurrentVariant(){const e=this.manager.getWorkflowSelections()[this.step.stepName],A=e==null?void 0:e.selections[0];if(A)return new at(A)}getAvailableVariants(){var e,A;return(((A=(e=this.step.option)==null?void 0:e.variants)==null?void 0:A.filter(a=>a.enabled))||[]).map(a=>new at(a))}getAllVariants(){var e;return(((e=this.step.option)==null?void 0:e.variants)||[]).map(A=>new at(A))}getId(){return this.step.stepName}getName(){return this.step.stepTitle}getHelpText(){return this.step.helpText}getType(){return this.step.type}getRaw(){return this.step}getTags(){return this.tags}hasTag(t){return this.tags.includes(t)||!1}getMandatory(){return this.step.mandatory||!1}getOverrideGlobalPropertyConfiguration(t){var A;return(((A=this.manager.getStepStorage(this.step.stepName))==null?void 0:A.overrideGlobalConfigurations)??{})[t.toString()]??!1}setOverrideGlobalPropertyConfiguration(t,e){var a;const A=((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.overrideGlobalConfigurations)??{};this.manager.updateStorage(this.step.stepName,{overrideGlobalConfigurations:{...A,[t.toString()]:e}})}getGlobalPropertyAspects(t){var e;return((e=this.step.globalPropertyAspectConfigurations)==null?void 0:e.filter(A=>A.globalPropertyConfigurationId===t&&A.aspectName).map(A=>A.aspectName))??[]}executeAnimations(){const t=this.manager.getPreviewService(),e=this.manager.getModelContainer(),A=this.step.data.modelAnimation,a=this.step.data.lookAtAnimation;t?a&&t.executeCameraAnimation(a):console.warn("No preview service available, cannot execute camera animations."),e?A&&e.executeAnimation(A):console.warn("No model container available, cannot execute model animations.")}};on.updateState=new Map;let et=on;class rn extends et{constructor(t,e,A){super(t,e,A)}async selectVariant(t){if(!this.getUpdateState()&&this.getCurrentVariant()!==t)return jt.selectVariant(this.step,t.getResource(),this.manager.getRegionElements(this.step.stepName)||[],e=>this.setUpdateState(e),this.manager)}getColors(){const t=this.manager.getRegionElements(this.step.stepName)||[];if(t.length!==0)try{return J(t[0].id,this.manager.getAllLayoutData()).colors}catch(e){console.error(e)}}setColor(t,e,A){const a=new Map;return A?a.set(t,{browserValue:e,pmsValue:A}):a.set(t,e),jt.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,()=>this.manager.getCommandContext().getAllLayouts(),a)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?jt.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}isPMSPickerEnabled(){return this.step.data.pmsPickerEnabled??!1}}class cn extends et{constructor(t,e,A){super(t,e,A)}selectVariant(t){return FA.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class ln extends et{constructor(t,e,A){super(t,e,A)}selectVariant(t){return MA.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class gn extends et{constructor(t,e,A){super(t,e,A)}selectVariant(t){return xA.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class dn extends et{constructor(t,e,A){super(t,e,A)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await YA.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){var t;return this.step.data.displayType||((t=this.step.option)==null?void 0:t.displayType)}}class Bn extends et{constructor(t,e,A){super(t,e,A)}selectVariant(t){const e=t.getResource();return St.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return St.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return St.availableColours(this.step)}setCustomColor(t){var e,A;return((e=this.getCurrentVariant())==null?void 0:e.getColor())!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${(A=this.getCurrentVariant())==null?void 0:A.getColor()}`),St.setCustomColor(t,this.step,this.manager)}getCustomColor(){var e,A,a;((e=this.getCurrentVariant())==null?void 0:e.getColor())!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${(A=this.getCurrentVariant())==null?void 0:A.getColor()}`);const t=(a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.colour;if(!t)throw new Error(`Color not available on step ${this.step.stepName}. Set a default on the workflow to fix this.`);return t}}class hn extends et{constructor(t,e,A){super(t,e,A)}async selectVariant(t){W.selectVariant(this.step,t.getResource(),this.manager,e=>{if(e)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occurred with text",messageType:re.Error,stepID:this.step.stepName}]);else{const A=this.manager.getInformationResults().filter(a=>a.stepID!==this.step.stepName);this.manager.setInformationResults(A)}},()=>{})}getAvailableFillColors(){return this.step.data.colorPickerEnabled?W.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeFillColor(this.step,t,e,this.manager)}getFillColor(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.color)||"#000000"}getAvailableFillImages(){return W.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeFillImage(this.step,t,e,this.manager)}getFillImage(){var t;return(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.fillImage}getAlignment(){const t=W.findLayoutElements(this.manager,this.step);return t==null?void 0:t[0].align}setAlignment(t){const e=this.manager.getRegionElements(this.step.stepName);W.changeAlignment(this.step,t,e,this.manager)}setFullTextCustomization(t){var s;const e=((s=this.manager.getStepStorage(this.step.stepName))==null?void 0:s.inputText)||"",A=this.step.data.replaceableText!==void 0?this.step.data.replaceableText.replace("{{}}",e):e,a=t?A:this.step.data.defaultText;return this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:a,defaultCleared:!1}),this.setText(a)}setText(t){var l;const e={input:t,helperData:{}},A=W.findLayoutElements(this.manager,this.step),a=W.filterUnsupportedCharacters(t,(l=A[0])==null?void 0:l.fontData),i=!!this.step.data&&!!this.step.data.maxLength&&a.length>this.step.data.maxLength;i||(e.input=a);const s=A.length<=0,o=s?{inputText:a,text:a}:{inputText:a};this.manager.updateStorage(this.step.stepName,o);const r=this.manager.getStepStorage(this.step.stepName),c=W.getProcessedInput(a,this.step.data,!!r.customiseAllText);if(s)i||this.manager.updateMetadata(this.step.stepName,{text:c});else{const{command:g,errorData:d,helperData:B}=W.updateInputText(a,A,this.step,this.manager);g&&this.manager.getCommandDispatcher()(g),e.helperData=B,e.errorData=d,!i&&!d&&this.manager.updateMetadata(this.step.stepName,{text:c})}return e}getText(){var A;const t=this.step.data.defaultText,e=this.manager.getStepStorage(this.step.stepName);return t&&(e==null?void 0:e.defaultCleared)!==void 0&&!(e!=null&&e.defaultCleared)?t:((A=this.manager.getStepStorage(this.step.stepName))==null?void 0:A.text)||""}isReplaceable(){return this.step.data.userCanReplaceText}newLinesSupported(){return this.step.data.allowNewlines||!1}clearDefaultTextIfNecessary(){const t=this.manager.getStepStorage(this.step.stepName);if(!(t!=null&&t.defaultCleared)&&this.step.data.deleteDefaultOnFocus){const e=this.setText("");this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""});const A=W.findLayoutElements(this.manager,this.step);return W.updateInputText("",A,this.step,this.manager),e}}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=this.getText();return t-e.length}setCustomColor(t){throw new Error("Custom color support is not yet available on text. Check back soon.")}getCustomColor(){throw new Error("Custom color support is not yet available on text. Check back soon.")}getAvailableStrokeColors(){return this.step.data.strokeEnabled?W.availableStrokeColors(this.step):[]}getStrokeColor(){var t,e;return((e=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.strokeColor)==null?void 0:e.browserValue)||"#000000"}async setStrokeColor(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeStrokeColor(this.step,t,e,this.manager)}}class Cn extends et{constructor(t,e,A){super(t,e,A)}async selectVariant(){}getContent(){return this.step.data.content}}class un extends et{constructor(t,e,A){super(t,e,A)}async selectVariant(){}getPreviewURL(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.videoUrl)||""}async selectVideo(t){return yA.regenerateQRCode(this.manager.getRegionElements(this.step.stepName),t.key,this.manager,this.step)}}class wn extends et{constructor(t,e,A){super(t,e,A)}async selectVariant(){console.info("Text Modules don't support variants.")}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=this.getText();return t-e.length}getCharacterLimit(){return this.step.data.maxLength}getText(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.text)||""}setText(t){SA.changeText(this.step,t,this.manager,"",e=>{if(e)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:e,messageType:re.Error,stepID:this.step.stepName}]);else{const A=this.manager.getInformationResults().filter(a=>a.stepID!==this.step.stepName);this.manager.setInformationResults(A)}})}}class de{static get(t,e){switch(e.type){case M.DigitalContent:return new un(t,e,t.getStepTags(e.stepName));case M.Information:return new Cn(t,e,t.getStepTags(e.stepName));case M.Question:return new dn(t,e,t.getStepTags(e.stepName));case M.Text:return new hn(t,e,t.getStepTags(e.stepName));case M.Illustration:return new rn(t,e,t.getStepTags(e.stepName));case M.Picture:return new gn(t,e,t.getStepTags(e.stepName));case M.Shape:return new Bn(t,e,t.getStepTags(e.stepName));case M.Material:return new cn(t,e,t.getStepTags(e.stepName));case M.Model:return new ln(t,e,t.getStepTags(e.stepName));case M.Frame:return new Hn(t,e,t.getStepTags(e.stepName));case M.Module:return new wn(t,e,t.getStepTags(e.stepName));default:throw new L(`Step type ${e.type} not yet supported in Core SDK`)}}}const En=Q.gql`
3158
+ `;var re=(n=>(n.Error="Error",n.Warning="Warning",n.Info="Info",n))(re||{});const Ko=1e3;class Aa extends wA{constructor(t){super(),this.createdAt=new Date,this.update=t}async execute(){await this.update(),await new Promise(t=>{window.setTimeout(()=>{t()},Ko)})}}class Wo{constructor(t,e,A,a,i,s,o,r,c,l,g,d,B=!1,h,C=!1,u=!1,w=!1){this.workflowStatePromiseQueue=new EA(1),this.initialized=!1,this.readOnly=!1,this.isReloadedTransaction=!1,this.singleVariantsRenderable=!1,this.stepTags={},this.renderLayouts=()=>{var f;if(!this.previewService)return;const E=this.getCommandContext().getAllLayouts(),m=(f=this.getLayoutPreviewService())==null?void 0:f.getAll();if(m)for(const[,p]of m)p.render(E)},this.experience=t,this.client=e,this.updateTransaction=o,this.commandContext=s,this.reloadedState=d,this.transaction=r,this.readOnly=B,this.singleVariantsRenderable=u,this.confirmedDesign=!1,this.editedSteps={},this.informationResults=[],this.mandatorySteps={},this.pendingUpdates=[],this.selectionCost=0,this.workflow=A,this.stepSpecificServices={},this.profanityFilter=a,this.pollers=[],this.allScenes=[],this.layouts=i,this.product=c,this.previewService=l,this.modelContainer=h,this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},this.validationErrors={steps:new Map},this.confirmCallbacks=[],this.editedCallbacks=[],this.elementsCallbacks=[],this.informationResultCallbacks=[],this.initCallbacks=[],this.mandatoryCallbacks=[],this.makingAdjustmentsCallback=[],this.metadataCallbacks=[],this.selectionCallbacks=[],this.stepSpecificStorageCallbacks={},this.storageCallbacks=[],this.validationCallbacks=[],this.currentAdjustingStepId="",this.renderableContextService=g,this.isReloadedTransaction=C,this.workflow.steps.forEach(E=>{this.stepTags[E.stepName]=E.tags??[]}),w&&(this.workflowStatePromiseQueue.enabled=!1),this.initializationPromise=this.initializeDefaultWorkflowState(A),this.initializationPromise.then(()=>{this.initialized=!0}),this.initializationPromise.catch(E=>{throw console.error(E),this.initialized=!1,new Error("Workflow initialization failed due to an error. See console.")}),this.initializationPromise.finally(()=>this.getCommandContext().registerStateCallback(()=>{this.updateStateWithServer(),this.renderLayouts()}))}async initializeDefaultWorkflowState(t){const e=()=>{var l,g;const o=this.workflow.finalizeStepConfig;if(!o)return;const r=o.lookAtAnimation,c=o.modelAnimation;r&&((l=this.previewService)==null||l.executeCameraAnimation(r)),c&&((g=this.modelContainer)==null||g.executeAnimation(c))};this.reloadedState&&this.reloadedState.serializableWorkflow.steps.forEach(o=>{this.storage[o.stepName]=o.storage||{}}),this.allScenes=await ss(t);const a=Ft(this.allScenes,this.stepSelections).map(o=>o.silentSteps).flat(),{stepElements:i,commands:s}=await this.stepElementsForIntroducedSilentSteps(a,!!this.reloadedState);this.commandContext.apply(new G(s),!0),this.stepElements={...this.stepElements,...i},await this.ensureStepsAreLoaded(),!this.isReloadedTransaction&&this.updateStateWithServer(),this.renderLayouts(),this.reloadedState&&e()}getWorkflowExperience(){return this.experience}getClient(){return this.client}setWorkflowStateSyncEnabled(t){this.workflowStatePromiseQueue.enabled=t}getProduct(){return this.product}getInitializationPromise(){return this.initializationPromise}isInitialized(){return this.initialized}addConfirmCallback(t){t(this.confirmedDesign),this.confirmCallbacks.push(t)}addEditedCallback(t){t(this.editedSteps),this.editedCallbacks.push(t)}addElementsCallback(t){t(this.stepElements),this.elementsCallbacks.push(t)}addInformationResultCallback(t){t(this.informationResults),this.informationResultCallbacks.push(t)}addInitCallback(t){t(this.stepInitialised),this.initCallbacks.push(t)}addMandatoryCallback(t){t(this.mandatorySteps),this.mandatoryCallbacks.push(t)}addMetadataCallback(t){t(this.stepMetadata),this.metadataCallbacks.push(t)}async addSelectionCallback(t){t({selectionCost:this.selectionCost,selections:this.stepSelections,traversableScenes:await this.traversableScenes()}),this.selectionCallbacks.push(t)}addStepSpecificStorageCallback(t,e){Object.keys(this.storage).includes(e)||(this.storage[e]={}),t(this.storage[e]),Object.keys(this.stepSpecificStorageCallbacks).includes(e)||(this.stepSpecificStorageCallbacks[e]=[]),this.stepSpecificStorageCallbacks[e].push(t)}addStorageCallback(t){t(this.storage),this.storageCallbacks.push(t)}addMakingAdjustmentsCallback(t){t(this.currentAdjustingStepId),this.makingAdjustmentsCallback.push(t)}addPoller(t){this.pollers.push(t)}addValidationCallback(t){this.validationCallbacks.push(t),t(this.validationErrors)}getLayouts(){return this.layouts}getAllLayoutData(){return this.commandContext.getAllLayouts().map(t=>t.layoutState)}getLayoutPreviewService(){return this.renderableContextService}getInformationResults(){return this.informationResults}getPreviewService(){return this.previewService}getProfanities(){return this.profanityFilter}getCommandContext(){return this.commandContext}getRegionElements(t){return this.stepElements[t]||[]}getStepSpecificServices(t){return this.stepSpecificServices[t]}getTransaction(){return this.transaction}getTransactionCustomer(){return this.ownerCustomer}setTransactionCustomer(t){this.ownerCustomer=t}setTransactionCustomerDetails(t){this.ownerCustomer={...this.ownerCustomer,emailAddress:t.email}}getModelContainer(){return this.modelContainer}setModelContainer(t){(!t||this.previewService&&this.previewService.getAllModels().includes(t))&&(this.modelContainer=t,t&&t.metadata&&t.metadata instanceof Map&&this.modelContainer.metadata.set("workflowManager",this))}setTransaction(t){this.transaction=t}getWorkflow(){return this.workflow}getCommandDispatcher(){return t=>this.commandContext.apply(t,!this.initialized)}getWorkflowSelections(){const t={};return this.workflow.steps.forEach(e=>{const A=this.stepSelections[e.stepName];A&&A.selectedVariants&&A.selectedVariants.length>0&&(t[e.stepName]={selections:A.selectedVariants})}),t}getStepSelections(){return this.stepSelections}markStepsAsInitialised(t){const e={...this.stepInitialised};t.forEach(A=>{e[A]=!0}),this.stepInitialised=e,this.onInitChange()}getUpdatesPending(){return this.pendingUpdates.length>0}markUpdateCompleted(t){this.pendingUpdates=this.pendingUpdates.filter(e=>e!==t)}markUpdatePending(){const t=b();return this.pendingUpdates=[...this.pendingUpdates,t],t}setEditedStatus(t,e){this.editedSteps={...this.editedSteps,[t]:e},this.onEditedChange()}setInformationResults(t){this.informationResults=[...t],this.onInformationResultChange()}setCurrentAdjustingStepId(t){this.currentAdjustingStepId=t,this.onMakingAdjustmentsChange()}setMandatoryFulfilled(t,e){this.mandatorySteps[t]!==e&&(this.mandatorySteps={...this.mandatorySteps,[t]:e},this.setInformationResults([]),this.onMandatoryChange())}setStepError(t,e,A){let a=!1;if(!this.validationErrors.steps.has(t)&&A)a=!0,this.validationErrors.steps.set(t,new Map([[e,A]]));else if(this.validationErrors.steps.has(t)){const i=this.validationErrors.steps.get(t);A&&A!==i.get(e)?(a=!0,i.set(e,A)):A||(a=!0,i.delete(e),i.size===0&&this.validationErrors.steps.delete(t))}a&&this.onValidationChange()}getStepErrors(t){return this.validationErrors.steps.get(t)}getValidationErrors(){return this.validationErrors}toggleDesignConfirmed(){this.confirmedDesign=!this.confirmedDesign,this.onConfirmChange()}toggleMakingAdjustmentsCallback(t){t(this.mandatorySteps),this.mandatoryCallbacks.push(t)}async injectIntoPreviewService(t,e){if(this.modelContainer)throw new Error("You must eject from the preview service before injecting again.");if(this.previewService=t,!this.getProduct().modelUrl||!this.previewService)return;const A=t.loadModel({model:this.getProduct().modelUrl,contextService:this.getLayoutPreviewService()},{refocusCamera:e});this.setModelContainer(A),Ft(this.allScenes,this.stepSelections).filter(s=>s).map(s=>s.renderableSteps).flat().filter(s=>s.type===M.Model||s.type===M.Material).forEach(s=>{var c,l,g;if(!((c=s.option)!=null&&c.id)){console.error(`Failed to read option id from step: ${s.stepName}`);return}const o=((l=this.stepSelections[s.stepName])==null?void 0:l.selectedVariants)||[];if(o.length===0)return;const r=o[0];if(s.type===M.Model){if(!this.modelContainer)throw new L("We should always have a model container when injecting a preview!");const d=(g=r.asset)==null?void 0:g.fileLink;if(!d){console.error(`Failed to read model url from variant: ${r.id} for step: ${s.stepName}`);return}const B=s.data;this.modelContainer.applyModelVariant(s.stepName,{model:d,contextService:this.getLayoutPreviewService()},B.replaceProductModel||!1)}else{const d=r.material;if(!d){console.error(`Failed to read material from variant: ${r.id} for step: ${s.stepName}`);return}s.data.targetMaterials.forEach(h=>{if(!this.modelContainer)throw new L("We should always have a model container when injecting a preview!");this.modelContainer.applyMaterialVariant(h,s.option.id,d)})}}),await A.getInitializationPromise(),this.renderLayouts()}ejectFromPreviewService(){if(this.modelContainer){if(!this.modelContainer.dispose)throw new Error("This feature is not supported in the current preview service.");this.modelContainer.dispose(),this.modelContainer=void 0}this.previewService=void 0}updateStorage(t,e){const A={...this.storage,[t]:{...this.storage[t],...e}};if(!sa(A,this.storage)){this.storage=A;const a=new $A(this.constructSerializableWorkflow());this.commandContext.apply(a,!0),this.onStepSpecificStorageChange(t),this.onStorageChange()}}constructSerializableWorkflow(){const t=[];return this.allScenes.forEach(e=>{e.renderableSteps.forEach(A=>{var i,s;const a={stepName:A.stepName};a.storage=this.storage[A.stepName],a.selectedVariants=(s=(i=this.stepSelections[A.stepName])==null?void 0:i.selectedVariants)==null?void 0:s.map(o=>({id:o.id,priceModifier:o.priceModifier})),t.push(a)})}),{steps:t}}updateStateWithServer(){if(this.readOnly)return;const t=this.serialize();this.workflowStatePromiseQueue.enqueue(new Aa(async()=>{await new Promise(e=>{setTimeout(()=>{e()},1)}),await this.updateTransaction({variables:{id:this.transaction.id,workflowState:t}})}))}async updateStateWithServerImmediate(){if(this.readOnly)return;const t=this.serialize();return new Aa(async()=>{await this.updateTransaction({variables:{id:this.transaction.id,workflowState:t}})}).execute()}serialize(){const t=this.getCommandContext().getState();if(!t)throw new L("Attempted to serialize state before it was initialized.");const e=xt(t.transaction),A=this.dehydrateState(e);return JSON.stringify(A)}dehydrateState(t){var e;for(const A of Object.values(t.layouts).map(a=>a.elements).flat())A.type==="illustration"&&(delete A.cachedObjectURL,A.src&&delete A.svg),A.type==="frame"&&((e=A.pattern)==null||delete e.svg);return this.deleteFieldNameFromObjectRecursive(t,"__typename"),t}deleteFieldNameFromObjectRecursive(t,e){if(!(typeof t!="object"||t===null))for(const A in t)A===e?delete t[A]:this.deleteFieldNameFromObjectRecursive(t[A],e)}async outstandingRequestsPromise(){return this.workflowStatePromiseQueue.finalize()}updateMetadata(t,e){this.stepMetadata={...this.stepMetadata,[t]:{...this.stepMetadata[t],...e}},this.onMetadataChange()}removeElements(t){const e=(A,a)=>Object.keys(A).reduce((i,s)=>{const o=[...A[s]||[]];return a.forEach(r=>{const c=o.findIndex(l=>l.id===r.id);c>-1&&o.splice(c,1)}),i[s]=o,i},{});this.stepElements=e(this.stepElements,t)}getInvalidCanvasRegions(){return this.workflow.steps.reduce((t,e)=>(ft(e,this.stepSelections)||this.stepElements[e.stepName]&&this.stepElements[e.stepName].forEach(A=>t.push(A)),t),[])}getInvalidModelVariants(){return this.workflow.steps.reduce((t,e)=>(e.type===M.Model&&!ft(e,this.stepSelections)&&t.push(e.stepName),t),[])}async stepElementsForIntroducedSilentSteps(t,e){const A=this.product;if(!A)return Promise.resolve({stepElements:{},commands:[]});const a=async(c,l,g)=>{if(c.type===M.SilentIllustration){const d=await new _A(c,l).trigger();return{step:c,results:d}}else if(c.type===M.ProductOverlay){const d=await new _A(c,l,g).trigger();return{step:c,results:d}}return Promise.reject("Unknown silent step. This is a bug")},i=t.filter(c=>!this.stepInitialised[c.stepName]),s={stepElements:{},commands:[]},o=[];for(const c of i)this.markStepsAsInitialised([c.stepName]),e||o.push(a(c,this.layouts,A));const r=await Promise.all(o);for(const c of r)s.stepElements[c.step.stepName]=c.results.map(l=>l.regionElement),s.commands=[...s.commands,...c.results.map(l=>l.command)];return s}getStepStorage(t){return this.storage[t]}getMetadata(t){return this.stepMetadata[t]}getWorkflowMetadata(){return this.stepMetadata}getStepTags(t){return this.stepTags[t]||[]}getSerializedStep(t,e){return e.find(A=>A.stepName===t)}async updateTransactionShareActions(){const t=await this.client.getShareActionsForTransaction(this.transaction.id);this.transaction.transactionShareActions=t}async updateTransactionStakeholders(){var e;const t=await y.getShadowGraphqlClient().query({query:Vi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.transaction.id}});!((e=t==null?void 0:t.data)!=null&&e.transactions)||t.data.transactions.length!==1?(this.transaction.currentStakeholder=void 0,this.transaction.stakeholders=void 0):(this.transaction.stakeholders=t.data.transactions[0].stakeholders,this.transaction.currentStakeholder=t.data.transactions[0].currentStakeholder)}async approveTransaction(t){await y.getShadowGraphqlClient().mutate({mutation:jo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.getTransaction().id,note:t}})}async rejectTransaction(t){await y.getShadowGraphqlClient().mutate({mutation:Vo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.getTransaction().id,note:t}})}async reset(){this.commandContext.getAllLayouts().forEach(e=>e.layoutState.elements.forEach(A=>{this.getCommandDispatcher()(new ut(A.id))})),this.stepElements={},this.stepInitialised={},this.stepMetadata={},this.stepSelections={},this.storage={},await this.ensureStepsAreLoaded()}async setSelectionsAndElements(t,e,A,a){var p;const i=this.stepSelections;this.stepSelections={...this.stepSelections,[t]:{selectedVariants:e}},this.selectionCost=Object.values(this.stepSelections).reduce((I,D)=>I+D.selectedVariants.map(F=>F.priceModifier||0).reduce((F,x)=>F+x,0),0),this.workflow.steps.forEach(I=>{ft(I,this.stepSelections)||(this.stepInitialised[I.stepName]=!1,delete this.stepMetadata[I.stepName],delete this.stepSelections[I.stepName],delete this.storage[I.stepName])});const s=this.allScenes,o=Ft(s,i),r=Ft(s,this.stepSelections),c=o.map(I=>I.silentSteps).flat(),g=r.map(I=>I.silentSteps).flat().filter(I=>!c.some(D=>D.stepName===I.stepName));c.forEach(I=>{ft(I,this.stepSelections)||(this.stepInitialised[I.stepName]=!1)});const d=this.getInvalidCanvasRegions(),{stepElements:B,commands:h}=await this.stepElementsForIntroducedSilentSteps(g,!1);this.stepElements={...this.stepElements,...B,[t]:A},this.removeElements(d);const C=this.workflow.steps.find(I=>I.stepName===t);if((C==null?void 0:C.type)===M.Frame){const I=(p=this.getWorkflowExperience().getStepById(C.stepName))==null?void 0:p.frameService;I==null||I.setTargetElements(A.map(D=>D.id))}const u=d.map(I=>new ut(I.id)),w=new $A(this.constructSerializableWorkflow()),E=[...h,...u,w];E.length>0&&this.commandContext.apply(new G(E),!0),await this.ensureStepsAreLoaded(),this.onElementsChange();const m=this.getInvalidModelVariants(),f=this.modelContainer;if(f){const I=m.map(D=>f.applyModelVariant(D,{contextService:this.getLayoutPreviewService()},!1));await Promise.all(I)}await this.onSelectionChange(),a&&await a()}async ensureStepsAreLoaded(){const e=Ft(this.allScenes,this.stepSelections).map(r=>r.renderableSteps),A=[],a=e.flat();for(const r of a)if(!this.stepInitialised[r.stepName])switch(this.stepInitialised[r.stepName]=!0,r.type){case M.DigitalContent:A.push(yA.init(r,this,this.reloadedState));break;case M.Frame:A.push(rt.init(r,this,this.reloadedState));break;case M.Illustration:A.push(jt.init(r,this,this.reloadedState));break;case M.Material:A.push(FA.init(r,this,this.reloadedState));break;case M.Model:A.push(MA.init(r,this,this.reloadedState));break;case M.Module:this.stepSpecificServices[r.stepName]={module:await sn(r.data.module)},A.push(SA.init(r,this,this.reloadedState));break;case M.Picture:A.push(xA.init(r,this,this.reloadedState));break;case M.Question:A.push(YA.init(r,this,this.reloadedState));break;case M.Shape:A.push(St.init(r,this,this.reloadedState));break;case M.Text:A.push(W.init(r,this,this.reloadedState));break}const i=(await Promise.allSettled(A)).map(r=>{if(r.status==="rejected")throw new Error(`Step initialization failed: ${r.reason}`);return r.value}),s=i.filter(r=>!!r&&!!r.command).map(r=>r.command),o=i.filter(r=>!!r&&!!r.followup).map(r=>r.followup);s&&s.length>0&&this.commandContext.apply(new G(s),!0);for(const r of o)await r();o.length>0&&await this.ensureStepsAreLoaded(),this.onInitChange()}onConfirmChange(){this.confirmCallbacks.forEach(t=>t(this.confirmedDesign))}onEditedChange(){this.editedCallbacks.forEach(t=>t(this.editedSteps))}onElementsChange(){this.elementsCallbacks.forEach(t=>t(this.stepElements))}onInformationResultChange(){this.informationResultCallbacks.forEach(t=>t(this.informationResults))}onInitChange(){this.initCallbacks.forEach(t=>t(this.stepInitialised))}onMakingAdjustmentsChange(){this.makingAdjustmentsCallback.forEach(t=>{t(this.currentAdjustingStepId)})}onMandatoryChange(){this.mandatoryCallbacks.forEach(t=>t(this.mandatorySteps))}onMetadataChange(){this.metadataCallbacks.forEach(t=>{t(this.stepMetadata)})}async onSelectionChange(){const t=await this.traversableScenes();for(const e of this.selectionCallbacks)e({selectionCost:this.selectionCost,selections:this.stepSelections,traversableScenes:t})}onStepSpecificStorageChange(t){Object.keys(this.stepSpecificStorageCallbacks).includes(t)||(this.stepSpecificStorageCallbacks[t]=[]),this.stepSpecificStorageCallbacks[t].forEach(e=>e(this.storage[t]))}onStorageChange(){this.storageCallbacks.forEach(t=>t(this.storage))}onValidationChange(){this.validationCallbacks.forEach(t=>t(this.validationErrors))}traversableScenes(){return cs(this.allScenes,this.stepSelections,this.singleVariantsRenderable)}}class nt{constructor(t){this.variantData=t}getType(){var t;return(t=this.variantData.asset)==null?void 0:t.type}getId(){return this.variantData.id}getName(){return this.variantData.name}getPriceFormatted(t,e){return this.variantData.priceModifier.toLocaleString(t||"en-US",{style:"currency",currency:"USD",...e})}getPrice(){return this.variantData.priceModifier}getAsset(){var t,e,A;return(A=(e=(t=this.variantData.asset)==null?void 0:t.versions)==null?void 0:e.find(a=>a.name==="cdn"))==null?void 0:A.link}getAssetResource(){return this.variantData.asset}getThumbnail(){var A,a,i,s;const t=(i=(a=(A=this.variantData.thumbnail)==null?void 0:A.versions)==null?void 0:a.find(o=>o.name==="thumbnail"))==null?void 0:i.link,e=(s=this.variantData.thumbnail)==null?void 0:s.fileLink;return t||e}getColor(){return this.variantData.color}isDefault(){return!!this.variantData.default}getResource(){return this.variantData}isEnabled(){return this.variantData.enabled}}const on=class iA{constructor(t,e,A){this.manager=t,this.step=e,this.tags=A}setUpdateState(t){iA.updateState.set(`${this.step.stepName}-${this.manager.getTransaction().id}`,t)}getUpdateState(){return!!iA.updateState.get(`${this.step.stepName}-${this.manager.getTransaction().id}`)}getCurrentVariant(){const e=this.manager.getWorkflowSelections()[this.step.stepName],A=e==null?void 0:e.selections[0];if(A)return new nt(A)}getAvailableVariants(){var e,A;return(((A=(e=this.step.option)==null?void 0:e.variants)==null?void 0:A.filter(a=>a.enabled))||[]).map(a=>new nt(a))}getAllVariants(){var e;return(((e=this.step.option)==null?void 0:e.variants)||[]).map(A=>new nt(A))}getId(){return this.step.stepName}getName(){return this.step.stepTitle}getHelpText(){return this.step.helpText}getType(){return this.step.type}getRaw(){return this.step}getTags(){return this.tags}hasTag(t){return this.tags.includes(t)||!1}getMandatory(){return this.step.mandatory||!1}getOverrideGlobalPropertyConfiguration(t){var A;return(((A=this.manager.getStepStorage(this.step.stepName))==null?void 0:A.overrideGlobalConfigurations)??{})[t.toString()]??!1}setOverrideGlobalPropertyConfiguration(t,e){var a;const A=((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.overrideGlobalConfigurations)??{};this.manager.updateStorage(this.step.stepName,{overrideGlobalConfigurations:{...A,[t.toString()]:e}})}getGlobalPropertyAspects(t){var e;return((e=this.step.globalPropertyAspectConfigurations)==null?void 0:e.filter(A=>A.globalPropertyConfigurationId===t&&A.aspectName).map(A=>A.aspectName))??[]}executeAnimations(){const t=this.manager.getPreviewService(),e=this.manager.getModelContainer(),A=this.step.data.modelAnimation,a=this.step.data.lookAtAnimation;t?a&&t.executeCameraAnimation(a):console.warn("No preview service available, cannot execute camera animations."),e?A&&e.executeAnimation(A):console.warn("No model container available, cannot execute model animations.")}};on.updateState=new Map;let At=on;class rn extends At{constructor(t,e,A){super(t,e,A)}async selectVariant(t){if(!this.getUpdateState()&&this.getCurrentVariant()!==t)return jt.selectVariant(this.step,t.getResource(),this.manager.getRegionElements(this.step.stepName)||[],e=>this.setUpdateState(e),this.manager)}getColors(){const t=this.manager.getRegionElements(this.step.stepName)||[];if(t.length!==0)try{return J(t[0].id,this.manager.getAllLayoutData()).colors}catch(e){console.error(e)}}setColor(t,e,A){const a=new Map;return A?a.set(t,{browserValue:e,pmsValue:A}):a.set(t,e),jt.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,()=>this.manager.getCommandContext().getAllLayouts(),a)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?jt.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}isPMSPickerEnabled(){return this.step.data.pmsPickerEnabled??!1}}class cn extends At{constructor(t,e,A){super(t,e,A)}selectVariant(t){return FA.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class ln extends At{constructor(t,e,A){super(t,e,A)}selectVariant(t){return MA.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class gn extends At{constructor(t,e,A){super(t,e,A)}selectVariant(t){return xA.selectVariant(this.step,t.getResource(),this.manager,e=>this.setUpdateState(e))}}class dn extends At{constructor(t,e,A){super(t,e,A)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await YA.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){var t;return this.step.data.displayType||((t=this.step.option)==null?void 0:t.displayType)}}class Bn extends At{constructor(t,e,A){super(t,e,A)}selectVariant(t){const e=t.getResource();return St.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return St.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return St.availableColours(this.step)}setCustomColor(t){var e,A;return((e=this.getCurrentVariant())==null?void 0:e.getColor())!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${(A=this.getCurrentVariant())==null?void 0:A.getColor()}`),St.setCustomColor(t,this.step,this.manager)}getCustomColor(){var e,A,a;((e=this.getCurrentVariant())==null?void 0:e.getColor())!=="#custom"&&console.warn(`setting custom color for step ${this.step.stepName} but color is ${(A=this.getCurrentVariant())==null?void 0:A.getColor()}`);const t=(a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.colour;if(!t)throw new Error(`Color not available on step ${this.step.stepName}. Set a default on the workflow to fix this.`);return t}}class hn extends At{constructor(t,e,A){super(t,e,A)}async selectVariant(t){W.selectVariant(this.step,t.getResource(),this.manager,e=>{if(e)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occurred with text",messageType:re.Error,stepID:this.step.stepName}]);else{const A=this.manager.getInformationResults().filter(a=>a.stepID!==this.step.stepName);this.manager.setInformationResults(A)}},()=>{})}getAvailableFillColors(){return this.step.data.colorPickerEnabled?W.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeFillColor(this.step,t,e,this.manager)}getFillColor(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.color)||"#000000"}getAvailableFillImages(){return W.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeFillImage(this.step,t,e,this.manager)}getFillImage(){var t;return(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.fillImage}getAlignment(){const t=W.findLayoutElements(this.manager,this.step);return t==null?void 0:t[0].align}setAlignment(t){const e=this.manager.getRegionElements(this.step.stepName);W.changeAlignment(this.step,t,e,this.manager)}setFullTextCustomization(t){var s;const e=((s=this.manager.getStepStorage(this.step.stepName))==null?void 0:s.inputText)||"",A=this.step.data.replaceableText!==void 0?this.step.data.replaceableText.replace("{{}}",e):e,a=t?A:this.step.data.defaultText;return this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:a,defaultCleared:!1}),this.setText(a)}setText(t){var l;const e={input:t,helperData:{}},A=W.findLayoutElements(this.manager,this.step),a=W.filterUnsupportedCharacters(t,(l=A[0])==null?void 0:l.fontData),i=!!this.step.data&&!!this.step.data.maxLength&&a.length>this.step.data.maxLength;i||(e.input=a);const s=A.length<=0,o=s?{inputText:a,text:a}:{inputText:a};this.manager.updateStorage(this.step.stepName,o);const r=this.manager.getStepStorage(this.step.stepName),c=W.getProcessedInput(a,this.step.data,!!r.customiseAllText);if(s)i||this.manager.updateMetadata(this.step.stepName,{text:c});else{const{command:g,errorData:d,helperData:B}=W.updateInputText(a,A,this.step,this.manager);g&&this.manager.getCommandDispatcher()(g),e.helperData=B,e.errorData=d,!i&&!d&&this.manager.updateMetadata(this.step.stepName,{text:c})}return e}getText(){var A;const t=this.step.data.defaultText,e=this.manager.getStepStorage(this.step.stepName);return t&&(e==null?void 0:e.defaultCleared)!==void 0&&!(e!=null&&e.defaultCleared)?t:((A=this.manager.getStepStorage(this.step.stepName))==null?void 0:A.text)||""}isReplaceable(){return this.step.data.userCanReplaceText}newLinesSupported(){return this.step.data.allowNewlines||!1}clearDefaultTextIfNecessary(){const t=this.manager.getStepStorage(this.step.stepName);if(!(t!=null&&t.defaultCleared)&&this.step.data.deleteDefaultOnFocus){const e=this.setText("");this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""});const A=W.findLayoutElements(this.manager,this.step);return W.updateInputText("",A,this.step,this.manager),e}}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=this.getText();return t-e.length}setCustomColor(t){throw new Error("Custom color support is not yet available on text. Check back soon.")}getCustomColor(){throw new Error("Custom color support is not yet available on text. Check back soon.")}getAvailableStrokeColors(){return this.step.data.strokeEnabled?W.availableStrokeColors(this.step):[]}getStrokeColor(){var t,e;return((e=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.strokeColor)==null?void 0:e.browserValue)||"#000000"}async setStrokeColor(t){const e=this.manager.getRegionElements(this.step.stepName);await W.changeStrokeColor(this.step,t,e,this.manager)}}class Cn extends At{constructor(t,e,A){super(t,e,A)}async selectVariant(){}getContent(){return this.step.data.content}}class un extends At{constructor(t,e,A){super(t,e,A)}async selectVariant(){}getPreviewURL(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.videoUrl)||""}async selectVideo(t){return yA.regenerateQRCode(this.manager.getRegionElements(this.step.stepName),t.key,this.manager,this.step)}}class wn extends At{constructor(t,e,A){super(t,e,A)}async selectVariant(){console.info("Text Modules don't support variants.")}getCharactersRemaining(){const t=this.step.data.maxLength;if(t===void 0)return;const e=this.getText();return t-e.length}getCharacterLimit(){return this.step.data.maxLength}getText(){var t;return((t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.text)||""}setText(t){SA.changeText(this.step,t,this.manager,"",e=>{if(e)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:e,messageType:re.Error,stepID:this.step.stepName}]);else{const A=this.manager.getInformationResults().filter(a=>a.stepID!==this.step.stepName);this.manager.setInformationResults(A)}})}}class de{static get(t,e){switch(e.type){case M.DigitalContent:return new un(t,e,t.getStepTags(e.stepName));case M.Information:return new Cn(t,e,t.getStepTags(e.stepName));case M.Question:return new dn(t,e,t.getStepTags(e.stepName));case M.Text:return new hn(t,e,t.getStepTags(e.stepName));case M.Illustration:return new rn(t,e,t.getStepTags(e.stepName));case M.Picture:return new gn(t,e,t.getStepTags(e.stepName));case M.Shape:return new Bn(t,e,t.getStepTags(e.stepName));case M.Material:return new cn(t,e,t.getStepTags(e.stepName));case M.Model:return new ln(t,e,t.getStepTags(e.stepName));case M.Frame:return new Hn(t,e,t.getStepTags(e.stepName));case M.Module:return new wn(t,e,t.getStepTags(e.stepName));default:throw new L(`Step type ${e.type} not yet supported in Core SDK`)}}}const En=Q.gql`
3159
3159
  fragment CreateDesignTransaction on Transaction {
3160
3160
  id
3161
3161
  designName
@@ -3226,7 +3226,7 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
3226
3226
  }
3227
3227
  }
3228
3228
  }
3229
- `;function fe(n){const t=JSON.parse(atob(n.split(".")[1])).exp;return Math.floor(new Date().getTime()/1e3)>=t}const Zo=async n=>{var s,o;const e=((s=Object.entries(localStorage).find(([r,c])=>r.startsWith("CognitoIdentityServiceProvider")&&r.endsWith("idToken")))==null?void 0:s[0])||"",A=localStorage.getItem(e),a={};return A&&!fe(A)&&(a.Authorization=`Bearer ${A}`),(o=(await y.getShadowGraphqlClient().mutate({mutation:Xo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:n.name,layouts:n.layouts,workflowId:n.workflowId,transactionId:n.transactionId,previewImage:n.previewImage,useThreeDimPreview:n.useThreeDimPreview,metadata:n.metadata,selectedVariants:n.selectedVariants},context:{headers:a}})).data)==null?void 0:o.designCreate},$o=async n=>{var s,o;const e=((s=Object.entries(localStorage).find(([r,c])=>r.startsWith("CognitoIdentityServiceProvider")&&r.endsWith("idToken")))==null?void 0:s[0])||"",A=localStorage.getItem(e),a={};return A&&!fe(A)&&(a.Authorization=`Bearer ${A}`),(o=(await y.getShadowGraphqlClient().mutate({mutation:qo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{inputs:n.map(r=>({name:r.name,layouts:r.layouts,workflowId:r.workflowId,transactionId:r.transactionId,previewImage:r.previewImage,useThreeDimPreview:r.useThreeDimPreview,metadata:r.metadata,selectedVariants:r.selectedVariants}))},context:{headers:a}})).data)==null?void 0:o.designCreateMany},sA=(n,t,e)=>{const A=i=>{const s={};if(i.type==="Frame"){const o=n[i.stepName],r=i.data;if(!o||!o.image||r.hideImageInCart&&e)return s;s[`${i.stepTitle} image`]=o.image}if(i.type==="Illustration"){const o=n[i.stepName],r=i.data;if(!o||r.hideColorsInCart&&e||!o.colors)return s;if(o.colors.length>0){const c=o.colors.join(", ").toUpperCase();s[`${i.stepTitle} colors`]=c}}if(i.type==="Module"){const o=n[i.stepName],r=i.data;if(!o||o.text===void 0||o.text===null||r.hideTextInCart&&e)return s;s[`${i.stepTitle} text`]=o.text}if(i.type==="Text"){const o=n[i.stepName];if(!o)return s;const r=i.data;(!r.hideTextInCart||!e&&o.text!==void 0&&o.text!==null)&&(s[`${i.stepTitle} text`]=o.text),o.color&&(!r.hideColorInCart||!e)&&(s[`${i.stepTitle} color`]=o.color),o.strokeColor&&(!r.hideStrokeInCart||!e)&&(s[`${i.stepTitle} stroke`]=o.strokeColor)}return s},a={};return t.steps.forEach(i=>{Object.assign(a,A(i))}),a},_o=(n,t,e,A)=>{const a={};let i={};e?i=sA(e,t,!1):A&&(i=A);const o=t.steps.map(r=>r.stepTitle).filter((r,c,l)=>l.indexOf(r)==c);for(const r of o){if(Object.keys(n).includes(r)){const c=n[r],l=t.steps.find(g=>g.stepTitle===r);a[`${l==null?void 0:l.stepTitle} selection`]={value:c[0].name,priceModifier:c[0].priceModifier}}for(const c of Object.keys(i))[`${r} color`,`${r} colors`,`${r} text`,`${r} image`].includes(c)&&(a[c]={value:i[c],priceModifier:0})}return a},mn=(n,t,e,A,a,i,s,o)=>{var h,C;const r=t.basePrice||0,c=n.priceModifierTotal||0,l=_o(A,e,void 0,i),d=(k.getMap("transactionOwnerIds")||new Map).get(n.id),B={additionalExternalProductId:(h=n.integrationProduct)==null?void 0:h.additionalExternalProductId,additionalExternalVariantId:(C=n.integrationProduct)==null?void 0:C.additionalExternalVariantId,baseCost:r,designExternalVariants:n.designExternalVariants,designProductId:n.externalDesignProductId,designProductVariantId:n.externalDesignProductVariantId,event:"onComplete",exportedData:l,externalCartProductId:n.externalCartProductId,externalCartProductVariantId:n.externalCartProductVariantId,lineItemImageUrl:s||"",optionsCost:c,processExecutionId:o,quantity:n.quantity,transactionId:n.id,transactionOwnerId:d,weight:t.weight,workflowViewerLink:n.workflowViewerLink||"",workflowViewerReadOnlyLink:n.workflowViewerReadOnlyLink||""};return i&&(B.metadata=i),A&&(B.selectedVariants=A),a&&(B.sku=a),B},fn=async(n,t,e,A,a,i,s,o,r,c)=>{var F;await(async()=>{var V;if(c!==void 0)return c;await n.outstandingRequestsPromise();const Y=(k.getMap("transactionOwnerIds")||new Map).get(a.id),v=await y.getShadowGraphqlClient().query({query:Ra,variables:{ids:[a.id]},fetchPolicy:"no-cache",errorPolicy:"all",context:{transactionOwnerId:Y}}),H=(V=v.data)==null?void 0:V.transactions[0].workflowState;return v.errors?(v.errors.forEach(j=>{v.errors&&console.log("Server Error:",j.message)}),null):H??null})()||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(A())),await n.updateStateWithServerImmediate(A),console.log("Server state is undefined @ Workflow completion"));const d=n.getPreviewService(),B=(F=t==null?void 0:t.finalizeStepConfig)==null?void 0:F.lookAtAnimation,h=d&&t.showModelOnFinishStep&&!!B,C=r&&sA(r,t,!0),u=r&&sA(r,t,!1),w=async x=>{const Y={};let P=0;if(Object.keys(i).length>0)for(const v of Object.keys(i)){const H=i[v],V=t.steps.find(j=>j.stepName===v);for(let j=0;j<H.selections.length;++j){const At=H.selections[j];if(V&&(!x||V.option&&(V.option.variants||[]).length>1&&!V.data.hideSelectionInCart&&!V.data.hideSelectionsInCart)){const ve=V.stepTitle;Y[ve]?Y[ve].push({id:At.id||"",name:At.name,priceModifier:At.priceModifier}):Y[ve]=[{id:At.id||"",name:At.name,priceModifier:At.priceModifier}]}P+=At.priceModifier}}return[Y,P]},[E]=await w(!0),m=Object.fromEntries(Object.keys(E).map(x=>[x,E[x].map(Y=>Y.id)])),[f]=await w(!1),p=Object.fromEntries(Object.keys(f).map(x=>[x,f[x].map(Y=>Y.id)]));let I=await o(h,a.id);if(I){const x=await(await ot(I)).blob();I=(await T.uploadAsset({name:`${a.id}-preview-image.png`,blob:x},Kt.Image,!0,!1)).fileLink}return{designDetails:(()=>{const x={name:s,layouts:e.map(Y=>({index:Y.index,panelId:Y.panelId})),workflowId:t.id,transactionId:a.id,useThreeDimPreview:!!h,previewImage:I};if(u){const Y=[];for(const[P,v]of Object.entries(u))Y.push({key:P,value:v});x.metadata=Y}if(m){const Y=[];for(const[P,v]of Object.entries(p))Y.push({key:P,ids:v});x.selectedVariants=Y}return x})(),cartSelectionsWithPrices:E,cartMetadata:C}},Qn=async(n,t,e,A,a,i,s,o,r,c,l)=>{var w,E;r("workflow.steps.finish.finalize.buildingLayouts");const{designDetails:g,cartSelectionsWithPrices:d,cartMetadata:B}=await fn(n,t,e,A,i,s,o,c,l);r("workflow.steps.finish.finalize.creatingDesign");const h=await Zo(g),C=(w=h==null?void 0:h.transaction)==null?void 0:w.previewImageLink;if(!(h!=null&&h.transaction))throw new Error("Failed to create design");r("workflow.steps.finish.finalize.updatingTransaction");const u=h.transaction;return mn(u,a,t,d,h==null?void 0:h.sku,B,C,(E=h==null?void 0:h.processExecution)==null?void 0:E.id)},tr=async(n,t,e)=>{t("workflow.steps.finish.finalize.buildingLayouts"),await Promise.all(n.map(async o=>{await o.workflowManager.outstandingRequestsPromise()}));const a=await(async()=>{var c;const r=await y.getShadowGraphqlClient().query({query:Ra,variables:{ids:n.map(l=>l.transaction.id)},fetchPolicy:"no-cache",errorPolicy:"all"});return r.errors?(r.errors.forEach(l=>{r.errors&&console.log("Server Error:",l.message)}),null):(c=r.data)!=null&&c.transactions?r.data.transactions.map(l=>l.workflowState??null):null})(),i=await Promise.all(n.map(async(o,r)=>await fn(o.workflowManager,o.workflow,o.layouts,o.getReducerState,o.transaction,o.workflowSelections,o.designName,e??(()=>Promise.resolve(void 0)),o.workflowMetadata,a?a[r]:void 0)));t("workflow.steps.finish.finalize.creatingDesign");const s=await $o(i.map(o=>o.designDetails));if(!s)throw new Error("Failed to create designs");return t("workflow.steps.finish.finalize.updatingTransaction"),s.map((o,r)=>{var d;const c=n[r],l=i[r],g=o.transaction;return mn(g,c.product,c.workflow,l.cartSelectionsWithPrices,o.sku,l.cartMetadata,void 0,(d=o.processExecution)==null?void 0:d.id)})};class er{constructor(){this.localPersistenceKey="designTransactions",this.storageMethod="Local",this.designSavedListeners=[]}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter(e=>e!==t)}async getSavedDesigns(){if(this.storageMethod==="Local"){const t=k.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new L("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find(A=>A.transactionId===t)}async addDesign(t){const A=(await this.getSavedDesigns()).filter(a=>a.transactionId!==t.transactionId);A.unshift(t),await this.setDesigns(A),this.designSavedListeners.forEach(a=>a(t))}async renameDesign(t,e){const A=await this.getSavedDesigns(),a=A.find(i=>i.transactionId===t);if(!a)throw new Error(`No saved design for transaction ${t}.`);a.title=e,await this.setDesigns(A)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter(A=>A.transactionId!==t))}async setDesigns(t){if(this.storageMethod==="Local"){k.set(this.localPersistenceKey,JSON.stringify(t));return}throw new L("Unexpected storage method requested")}}const Ce=new er,Ar=Q.gql`
3229
+ `;function fe(n){const t=JSON.parse(atob(n.split(".")[1])).exp;return Math.floor(new Date().getTime()/1e3)>=t}const Zo=async n=>{var s,o;const e=((s=Object.entries(localStorage).find(([r,c])=>r.startsWith("CognitoIdentityServiceProvider")&&r.endsWith("idToken")))==null?void 0:s[0])||"",A=localStorage.getItem(e),a={};return A&&!fe(A)&&(a.Authorization=`Bearer ${A}`),(o=(await y.getShadowGraphqlClient().mutate({mutation:Xo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:n.name,layouts:n.layouts,workflowId:n.workflowId,transactionId:n.transactionId,previewImage:n.previewImage,useThreeDimPreview:n.useThreeDimPreview,metadata:n.metadata,selectedVariants:n.selectedVariants},context:{headers:a}})).data)==null?void 0:o.designCreate},$o=async n=>{var s,o;const e=((s=Object.entries(localStorage).find(([r,c])=>r.startsWith("CognitoIdentityServiceProvider")&&r.endsWith("idToken")))==null?void 0:s[0])||"",A=localStorage.getItem(e),a={};return A&&!fe(A)&&(a.Authorization=`Bearer ${A}`),(o=(await y.getShadowGraphqlClient().mutate({mutation:qo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{inputs:n.map(r=>({name:r.name,layouts:r.layouts,workflowId:r.workflowId,transactionId:r.transactionId,previewImage:r.previewImage,useThreeDimPreview:r.useThreeDimPreview,metadata:r.metadata,selectedVariants:r.selectedVariants}))},context:{headers:a}})).data)==null?void 0:o.designCreateMany},sA=(n,t,e)=>{const A=i=>{const s={};if(i.type==="Frame"){const o=n[i.stepName],r=i.data;if(!o||!o.image||r.hideImageInCart&&e)return s;s[`${i.stepTitle} image`]=o.image}if(i.type==="Illustration"){const o=n[i.stepName],r=i.data;if(!o||r.hideColorsInCart&&e||!o.colors)return s;if(o.colors.length>0){const c=o.colors.join(", ").toUpperCase();s[`${i.stepTitle} colors`]=c}}if(i.type==="Module"){const o=n[i.stepName],r=i.data;if(!o||o.text===void 0||o.text===null||r.hideTextInCart&&e)return s;s[`${i.stepTitle} text`]=o.text}if(i.type==="Text"){const o=n[i.stepName];if(!o)return s;const r=i.data;(!r.hideTextInCart||!e&&o.text!==void 0&&o.text!==null)&&(s[`${i.stepTitle} text`]=o.text),o.color&&(!r.hideColorInCart||!e)&&(s[`${i.stepTitle} color`]=o.color),o.strokeColor&&(!r.hideStrokeInCart||!e)&&(s[`${i.stepTitle} stroke`]=o.strokeColor)}return s},a={};return t.steps.forEach(i=>{Object.assign(a,A(i))}),a},_o=(n,t,e,A)=>{const a={};let i={};e?i=sA(e,t,!1):A&&(i=A);const o=t.steps.map(r=>r.stepTitle).filter((r,c,l)=>l.indexOf(r)==c);for(const r of o){if(Object.keys(n).includes(r)){const c=n[r],l=t.steps.find(g=>g.stepTitle===r);a[`${l==null?void 0:l.stepTitle} selection`]={value:c[0].name,priceModifier:c[0].priceModifier}}for(const c of Object.keys(i))[`${r} color`,`${r} colors`,`${r} text`,`${r} image`].includes(c)&&(a[c]={value:i[c],priceModifier:0})}return a},mn=(n,t,e,A,a,i,s,o)=>{var h,C;const r=t.basePrice||0,c=n.priceModifierTotal||0,l=_o(A,e,void 0,i),d=(k.getMap("transactionOwnerIds")||new Map).get(n.id),B={additionalExternalProductId:(h=n.integrationProduct)==null?void 0:h.additionalExternalProductId,additionalExternalVariantId:(C=n.integrationProduct)==null?void 0:C.additionalExternalVariantId,baseCost:r,designExternalVariants:n.designExternalVariants,designProductId:n.externalDesignProductId,designProductVariantId:n.externalDesignProductVariantId,event:"onComplete",exportedData:l,externalCartProductId:n.externalCartProductId,externalCartProductVariantId:n.externalCartProductVariantId,lineItemImageUrl:s||"",optionsCost:c,processExecutionId:o,quantity:n.quantity,transactionId:n.id,transactionOwnerId:d,weight:t.weight,workflowViewerLink:n.workflowViewerLink||"",workflowViewerReadOnlyLink:n.workflowViewerReadOnlyLink||""};return i&&(B.metadata=i),A&&(B.selectedVariants=A),a&&(B.sku=a),B},fn=async(n,t,e,A,a,i,s,o,r,c)=>{var F;await(async()=>{var V;if(c!==void 0)return c;await n.outstandingRequestsPromise();const Y=(k.getMap("transactionOwnerIds")||new Map).get(a.id),v=await y.getShadowGraphqlClient().query({query:Ra,variables:{ids:[a.id]},fetchPolicy:"no-cache",errorPolicy:"all",context:{transactionOwnerId:Y}}),H=(V=v.data)==null?void 0:V.transactions[0].workflowState;return v.errors?(v.errors.forEach(j=>{v.errors&&console.log("Server Error:",j.message)}),null):H??null})()||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(A())),await n.updateStateWithServerImmediate(A),console.log("Server state is undefined @ Workflow completion"));const d=n.getPreviewService(),B=(F=t==null?void 0:t.finalizeStepConfig)==null?void 0:F.lookAtAnimation,h=d&&t.showModelOnFinishStep&&!!B,C=r&&sA(r,t,!0),u=r&&sA(r,t,!1),w=async x=>{const Y={};let P=0;if(Object.keys(i).length>0)for(const v of Object.keys(i)){const H=i[v],V=t.steps.find(j=>j.stepName===v);for(let j=0;j<H.selections.length;++j){const at=H.selections[j];if(V&&(!x||V.option&&(V.option.variants||[]).length>1&&!V.data.hideSelectionInCart&&!V.data.hideSelectionsInCart)){const ve=V.stepTitle;Y[ve]?Y[ve].push({id:at.id||"",name:at.name,priceModifier:at.priceModifier}):Y[ve]=[{id:at.id||"",name:at.name,priceModifier:at.priceModifier}]}P+=at.priceModifier}}return[Y,P]},[E]=await w(!0),m=Object.fromEntries(Object.keys(E).map(x=>[x,E[x].map(Y=>Y.id)])),[f]=await w(!1),p=Object.fromEntries(Object.keys(f).map(x=>[x,f[x].map(Y=>Y.id)]));let I=await o(h,a.id);if(I){const x=await(await ot(I)).blob();I=(await T.uploadAsset({name:`${a.id}-preview-image.png`,blob:x},Kt.Image,!0,!1)).fileLink}return{designDetails:(()=>{const x={name:s,layouts:e.map(Y=>({index:Y.index,panelId:Y.panelId})),workflowId:t.id,transactionId:a.id,useThreeDimPreview:!!h,previewImage:I};if(u){const Y=[];for(const[P,v]of Object.entries(u))Y.push({key:P,value:v});x.metadata=Y}if(m){const Y=[];for(const[P,v]of Object.entries(p))Y.push({key:P,ids:v});x.selectedVariants=Y}return x})(),cartSelectionsWithPrices:E,cartMetadata:C}},Qn=async(n,t,e,A,a,i,s,o,r,c,l)=>{var w,E;r("workflow.steps.finish.finalize.buildingLayouts");const{designDetails:g,cartSelectionsWithPrices:d,cartMetadata:B}=await fn(n,t,e,A,i,s,o,c,l);r("workflow.steps.finish.finalize.creatingDesign");const h=await Zo(g),C=(w=h==null?void 0:h.transaction)==null?void 0:w.previewImageLink;if(!(h!=null&&h.transaction))throw new Error("Failed to create design");r("workflow.steps.finish.finalize.updatingTransaction");const u=h.transaction;return mn(u,a,t,d,h==null?void 0:h.sku,B,C,(E=h==null?void 0:h.processExecution)==null?void 0:E.id)},tr=async(n,t,e)=>{t("workflow.steps.finish.finalize.buildingLayouts"),await Promise.all(n.map(async o=>{await o.workflowManager.outstandingRequestsPromise()}));const a=await(async()=>{var c;const r=await y.getShadowGraphqlClient().query({query:Ra,variables:{ids:n.map(l=>l.transaction.id)},fetchPolicy:"no-cache",errorPolicy:"all"});return r.errors?(r.errors.forEach(l=>{r.errors&&console.log("Server Error:",l.message)}),null):(c=r.data)!=null&&c.transactions?r.data.transactions.map(l=>l.workflowState??null):null})(),i=await Promise.all(n.map(async(o,r)=>await fn(o.workflowManager,o.workflow,o.layouts,o.getReducerState,o.transaction,o.workflowSelections,o.designName,e??(()=>Promise.resolve(void 0)),o.workflowMetadata,a?a[r]:void 0)));t("workflow.steps.finish.finalize.creatingDesign");const s=await $o(i.map(o=>o.designDetails));if(!s)throw new Error("Failed to create designs");return t("workflow.steps.finish.finalize.updatingTransaction"),s.map((o,r)=>{var d;const c=n[r],l=i[r],g=o.transaction;return mn(g,c.product,c.workflow,l.cartSelectionsWithPrices,o.sku,l.cartMetadata,void 0,(d=o.processExecution)==null?void 0:d.id)})};class er{constructor(){this.localPersistenceKey="designTransactions",this.storageMethod="Local",this.designSavedListeners=[]}attachSaveListener(t){this.designSavedListeners.push(t)}detachSaveListener(t){this.designSavedListeners=this.designSavedListeners.filter(e=>e!==t)}async getSavedDesigns(){if(this.storageMethod==="Local"){const t=k.get(this.localPersistenceKey);return t?JSON.parse(t):[]}throw new L("Unexpected storage method requested")}async getSavedDesignByTransaction(t){return(await this.getSavedDesigns()).find(A=>A.transactionId===t)}async addDesign(t){const A=(await this.getSavedDesigns()).filter(a=>a.transactionId!==t.transactionId);A.unshift(t),await this.setDesigns(A),this.designSavedListeners.forEach(a=>a(t))}async renameDesign(t,e){const A=await this.getSavedDesigns(),a=A.find(i=>i.transactionId===t);if(!a)throw new Error(`No saved design for transaction ${t}.`);a.title=e,await this.setDesigns(A)}async removeDesign(t){const e=await this.getSavedDesigns();await this.setDesigns(e.filter(A=>A.transactionId!==t))}async setDesigns(t){if(this.storageMethod==="Local"){k.set(this.localPersistenceKey,JSON.stringify(t));return}throw new L("Unexpected storage method requested")}}const Ce=new er,Ar=Q.gql`
3230
3230
  mutation AddTransactionStakeholder($id: String!, $type: String!, $details: CustomerDetailsInput!) {
3231
3231
  transactionAddStakeholder(id: $id, details: $details, type: $type) {
3232
3232
  id
@@ -3261,7 +3261,7 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
3261
3261
  />
3262
3262
  </svg>
3263
3263
  `,h={"spiff-fill-shape":{browserValue:s.color||"#000000"}},C=b();return new z({colors:h,id:C,svg:d,type:N.Illustration,y:l.top,x:l.left,rotation:l.rotation,width:l.width,height:l.height,layer:l.layer,layerIndex:l.layerIndex,immutable:l.immutable},g)},r=A.data.regions;try{return r.map(o)}catch(l){return console.error(l),[]}},lr=async(n,t,e)=>{const A=[],i=(()=>{var c,l;return t.type===M.ProductOverlay?e||((c=t.data.asset)==null?void 0:c.fileLink)||"":((l=t.data.asset)==null?void 0:l.fileLink)||""})(),o=(()=>i.endsWith(".jpeg")||i.endsWith(".jpg")||i.endsWith(".png")?N.Image:(i.endsWith(".svg"),N.Illustration))(),r=t.data.regions;if(o==="image")try{r.forEach(c=>{const l=n.find(d=>d.panelId===c.panelId);if(!l)throw new X(c);const g={id:b(),src:i,type:o,y:c.top,x:c.left,width:c.width,height:c.height,layer:c.layer,layerIndex:c.layerIndex,productOverlay:t.type===M.ProductOverlay?!0:void 0,scaleX:1,scaleY:1,rotation:c.rotation,excludeFromExport:t.data.excludeFromPrint,preserveAspectRatio:"none"};A.push(new z(g,l))})}catch(c){console.error(c)}else{const c=await _(i,!0),l=g=>{const d=/<svg.*?<\/svg>/s,B=g.match(d)||[],h=(B==null?void 0:B.length)>0?B[0]:"",w=it().parseFromString(h,"image/svg+xml").firstElementChild;if(!w)throw new mt("Failed to read SVG.");return ye(w),wt().serializeToString(w)};r.forEach(g=>{const d=n.find(h=>h.panelId===g.panelId);if(!d)throw new X(g);const B={id:b(),src:i,asset_key:i,svg:l(c),colors:{},type:o,y:g.top,x:g.left,width:g.width,height:g.height,layer:g.layer,layerIndex:g.layerIndex,scaleX:1,scaleY:1,rotation:g.rotation,productOverlay:t.type===M.ProductOverlay?!0:void 0,excludeFromExport:t.data.excludeFromPrint};A.push(new z(B,d))})}return A},gr=async(n,t,e,A)=>{const a=[],i=e.data,s=30,o=u=>u.vertical?"center":u.textAlign||"center",r=()=>{var m;const u=A.option;if(!u)return;const w=((m=u.variants)==null?void 0:m.find(f=>f.id===i.fontVariantId))||se(u);if(!w||!w.asset)return;t[A.stepName]={selectedVariants:[w]};const E=w.asset.fileLink;if(E)return E},l=await(async()=>{const u=r();if(!u)return;const w=await It(u);return{assetUrl:u,name:w.names.fullName.en}})(),g=(A.data.replaceableText?A.data.replaceableText.replace("{{}}",i.text):i.text)||"",d=we(g,{vertical:A.data.vertical,uppercase:A.data.uppercase}),B=async u=>{const w=u.colorOption;if(!w)return;const E=$.getDefaultVariant(w);return E==null?void 0:E.color},h=i.color||await B(A.data),C=A.data.regions;for(const u of C){const w=n.find(m=>m.panelId===u.panelId);if(!w)continue;const E={stepName:e.name,id:b(),align:o(A.data),curved:A.data.curved,fill:i.color||h||"#000000",fontData:l,fontSize:A.data.size||s,height:u.height,layer:u.layer,layerIndex:u.layerIndex,paths:A.data.paths,rotation:u.rotation,text:d,type:N.Textbox,vertical:A.data.vertical,verticalAlign:A.data.verticalAlign||"middle",width:u.width,x:u.left,y:u.top};if(l){const[m,f]=Vt(A.data.size||s,l,u,[we(d,{vertical:A.data.vertical,uppercase:A.data.uppercase})],{size:A.data.size,minSize:A.data.minSize,maxSize:A.data.maxSize});a.push(new z({...E,fontSize:m,text:E.curved?E.text:(f||[]).join(`
3264
- `)},w))}else a.push(new z(E,w))}return a},dr=(n,t)=>n.conditions?n.conditions.every(e=>{const A=t[e.targetStepName];if(A&&A.selectedVariants){const a=A.selectedVariants;return e.requiredVariantSelections.some(i=>a.find(s=>s.id===i)!==void 0)}return!1}):!0,Dn=async(n,t,e,A)=>{const a=[],i={};for(const s of n){const o=t.steps.find(r=>r.stepName===s.name);if(o)switch(o.type){case M.DigitalContent:a.push(...await nr(e,s,o));break;case M.Frame:case M.Photo:a.push(...await ir(e,i,s,o));break;case M.Illustration:a.push(...await sr(e,i,s,o));break;case M.Module:a.push(...await or(e,s,o));break;case M.Picture:a.push(...await rr(e,i,s,o));break;case M.Shape:a.push(...await cr(e,i,s,o));break;case M.Text:a.push(...await gr(e,i,s,o));break}}for(const s of t.steps)s.type!==M.SilentIllustration&&s.type!==M.ProductOverlay||dr(s,i)&&a.push(...await lr(e,s,A));return a};class Br{constructor(t){this.handleCompleteRender=null;const e=new Map;t.forEach(A=>e.set(A.id,new ur(A.id,A.name,this,{width:A.width,height:A.height}))),this.layouts=e}setCompleteRenderCallback(t){this.handleCompleteRender=t,t(Array.from(this.layouts.values()))}onCompleteRender(){this.handleCompleteRender&&this.handleCompleteRender(Array.from(this.layouts.values()))}getAll(){return this.layouts}}const hr=()=>new Promise((n,t)=>{try{const A=ht().getContext("webgl2");n(!!A)}catch{n(!1)}}),Cr=hr();class ur{constructor(t,e,A,a){this.hasSetStaticContext=!1,this.interactiveDirty=!1,this.staticCtxDirty=!1,this.lastRequestedRenderArguments=void 0,this.lastCompletedStaticRender=void 0,this.renderQueue=new EA(2),this.id=t,this.name=e,this.service=A,this.panelSize=a}getID(){return this.id}getName(){return this.name}getPanelSize(){return this.panelSize}getStaticContext(){return this.textureCtx}setStaticContext(t){this.textureCtx=t,this.lastRequestedRenderArguments&&this.render(this.lastRequestedRenderArguments)}getStaticContextDirty(){return this.staticCtxDirty}setStaticContextDirty(t){this.staticCtxDirty=t}getInteractiveCanvasDirty(){return this.interactiveDirty}setInteractiveCanvasDirty(t){this.interactiveDirty=t}markLastCompletedStaticRender(){this.lastCompletedStaticRender=Date.now(),this.service.onCompleteRender()}getLastCompletedStaticRender(){return this.lastCompletedStaticRender}async render(t){const e=xt(t);this.lastRequestedRenderArguments=e;const A=this.getStaticContext();if(!A){this.markLastCompletedStaticRender(),this.setStaticContextDirty(!1);return}this.renderQueue.enqueue(new wr(this.getID(),A,await Cr,()=>{this.markLastCompletedStaticRender(),this.setStaticContextDirty(!0)},e))}}class wr extends wA{constructor(t,e,A,a,i){super(),this.layoutId=t,this.ctx=e,this.nonPOTSupport=A,this.onRender=a,this.layouts=i}getDynamicTextureResolution(){return this.getIsMobile()||!this.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}getIsMobile(){return window.innerWidth<=480}offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}resizeFit(t,e=4096){const A=e/t.width,a=e/t.height,i=Math.min(A,a);return i>1?t:{width:t.width*i,height:t.height*i}}async execute(){const t=this.layouts.find(B=>B.layoutState.layout.id===this.layoutId);if(!t)return;const e=t.layoutState.elements||[],A=t.layoutState.layout.width,a=t.layoutState.layout.height,i=A===1||a===1?{width:1,height:1}:this.getDynamicTextureResolution(),s=i.width,o=i.height;let r,c;if(this.nonPOTSupport){const B=s/o;A/a<B?(r=s,c=a*(s/A)):(r=A*(o/a),c=o);const C=this.resizeFit({width:r,height:c});r=C.width,c=C.height}else r=i.width,c=i.height;const l=Se(t.layoutState.layout,e,{renderingConfiguration:{purpose:Pt.ThreeD}}),g=Ea(l),d=await cA.Pith.from(this.ctx,g,{anonymousCrossOrigin:!0,ignoreDimensions:!this.nonPOTSupport,ignoreAnimation:!0,ignoreClear:!0,ignoreMouse:!0,enableRedraw:!1,createCanvas:ht,createImage:Ae,DOMParser:hA(),fetch});d.resize(r,c),await d.render(),this.onRender()}}const Er=(n,t)=>{const e=[];return n.forEach(A=>{const a=t.steps.find(i=>i.stepName===A.stepName);(a==null?void 0:a.type)===M.Text&&A.stepAspectType==="Text"&&e.push({name:a.stepName,data:{text:A.value}})}),e},mr=async(n,t,e,A)=>{let a={serializableWorkflow:{steps:[]},layouts:{}};a=new G(e.map(r=>new DA(r))).apply(a);const s=await Dn(n,t,e,A);return new G(s).apply(a)};class fr{constructor(t){this.handleCache={},this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){var e;if(!((e=this.bundle.getProductCollection())!=null&&e.getResource().globalPropertyConfiguration))return[];const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map(A=>this.getHandle(A)))}applyConditionsFromState(t,e){return e?t.filter(A=>this.aspectConditionsSatisfied(A.getRawProperty(),e)):t}aspectConditionsSatisfied(t,e){return!t.conditions||t.conditions.length===0?!0:t.conditions.some(A=>{const a=e.aspects.find(i=>i.name===A.targetAspectName);return a?A.requiredVariantSelections.some(i=>i===a.value):!1})}async createHandle(t){switch(t.type){case nt.FileUpload:return new yn(this.bundle,t);case nt.ColorOption:return new oA(this.bundle,t,t.entityId?await $.getOption(t.entityId):void 0);case nt.Option:{const e=t.entityId?await $.getOption(t.entityId):void 0;return(e==null?void 0:e.type)==="Color"?new oA(this.bundle,t,e):new RA(this.bundle,t,e)}case nt.Text:return new Fn(this.bundle,t);default:throw new Error("Unhandled Global Property Aspect Type")}}}class Pe{constructor(t,e){this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap(a=>a.getStepsConditionallyActive().filter(i=>{var s;return i.getOverrideGlobalPropertyConfiguration(this.property.type)?!1:(s=i.getRaw().globalPropertyAspectConfigurations)==null?void 0:s.some(o=>{var r,c;return o.globalPropertyConfigurationId===((c=(r=this.bundle.getProductCollection())==null?void 0:r.getResource().globalPropertyConfiguration)==null?void 0:c.id)&&o.aspectName===this.property.name})}))}getStateValue(){return this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name)}}class yn extends Pe{constructor(t,e){super(t,e)}async selectImage(t){const e=this.bundle.getGlobalPropertyStateManager();await Promise.all([e.setAspect(this.property.name,t.key,{...e.getAspectStorage(this.property.name)||{},originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}),this.applyImageSelection(t)])}async canUseBackgroundRemover(){return this.bundle.getClient().canUseAddon(Qe.BackgroundRemover)}async removeBackgroundFromImage(t=!0){if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const e=await this.getOriginalImage();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const A=this.bundle.getGlobalPropertyStateManager(),a=await T.removeBackgroundFromAsset(e),s={...A.getAspectStorage(this.property.name),backgroundRemovedAssetKey:a.key,useOriginalAsset:!t},r=[t?A.setAspect(this.property.name,a.key,s):A.setAspectStorage(this.property.name,s)];return t&&r.push(this.applyImageSelection(a,void 0,!1,!1)),await Promise.all(r),this.updateSharedStepStorage(s),a}hasImage(){return!!this.getStateValue()}async getImage(){const t=this.getStateValue();if(t)return T.getLocalOrFromServer(t)}async getOriginalImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t!=null&&t.originalAssetKey)return T.getLocalOrFromServer(t.originalAssetKey)}async getBackgroundRemovedImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t!=null&&t.backgroundRemovedAssetKey)return T.getLocalOrFromServer(t.backgroundRemovedAssetKey)}getUseOriginalImage(){var t;return((t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:t.useOriginalAsset)??!1}async setUseOriginalImage(t){const e=await this.getOriginalImage();if(!e)throw new Error("You must select an image before calling setUseOriginalImage");const A=this.bundle.getGlobalPropertyStateManager(),a=A.getAspectStorage(this.property.name);if((a==null?void 0:a.useOriginalAsset)===t)return;const i={...a,useOriginalAsset:t},s=t?a==null?void 0:a.originalAssetKey:a==null?void 0:a.backgroundRemovedAssetKey,o=[A.setAspect(this.property.name,s||"",i)];if(t)o.push(this.applyImageSelection(e,void 0,!1,!1));else{const r=async()=>{const c=await this.getBackgroundRemovedImage();if(!c)throw new Error("You must call removeBackgroundFromImage before attempting to use that version of the image.");this.applyImageSelection(c,void 0,!1,!1)};o.push(r())}this.updateSharedStepStorage(i)}async applyGlobalState(t){const e=this.getStateValue();if(!e)return;const A=await T.getLocalOrFromServer(e);if(!A)return;const a=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);await this.applyImageSelection(A,t,!1,!0),a?this.updateSharedStepStorage({...a}):(this.updateSharedStepStorage({originalAssetKey:e}),await this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{originalAssetKey:e}))}async applyImageSelection(t,e,A=!0,a=!0){const s=this.getSharedSteps(e).map(o=>{const r=o;if(r.getFrameService())return r.selectImage(t,A,a)});await Promise.all(s)}updateSharedStepStorage(t){this.bundle.getWorkflowExperiences().forEach(A=>A.getSteps().forEach(a=>{var s;if(a.getOverrideGlobalPropertyConfiguration(this.property.type))return;((s=a.getRaw().globalPropertyAspectConfigurations)==null?void 0:s.some(o=>{var r,c;return o.globalPropertyConfigurationId===((c=(r=this.bundle.getProductCollection())==null?void 0:r.getResource().globalPropertyConfiguration)==null?void 0:c.id)&&o.aspectName===this.property.name}))&&A.getWorkflowManager().updateStorage(a.getId(),{framePatternData:t})}))}}class Fn extends Pe{constructor(t,e){super(t,e)}getText(){const t=this.getStateValue();return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.getStateValue();if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const a=this.getSharedSteps(e).map(i=>{i.setText(t)});await Promise.all(a)}}class RA extends Pe{constructor(t,e,A){super(t,e),this.optionResource=A}getCurrentVariant(){var e,A;if(!this.optionResource)return;const t=this.getStateValue();if(t){const a=(A=this.optionResource.variants)==null?void 0:A.find(i=>i.id===t);return a?new at(a):void 0}else{const a=(e=this.optionResource.variants)==null?void 0:e.find(i=>{var s,o;return i.id===((o=(s=this.optionResource)==null?void 0:s.defaultVariant)==null?void 0:o.id)});return a?new at(a):void 0}}getAvailableVariants(){var e,A;return(((A=(e=this.optionResource)==null?void 0:e.variants)==null?void 0:A.filter(a=>a.enabled))||[]).map(a=>new at(a))}getAllVariants(){var e;return(((e=this.optionResource)==null?void 0:e.variants)||[]).map(A=>new at(A))}async selectVariant(t){console.log(`Selecting variant ${t.getId()}`),await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){var a,i;const e=this.getStateValue();if(!e)return Promise.resolve();const A=(i=(a=this.optionResource)==null?void 0:a.variants)==null?void 0:i.find(s=>s.id===e);return A?(console.log(`Applying global state using variant ${A.id} for aspect ${e}`),this.applyVariantSelection(new at(A),t)):Promise.resolve()}async applyVariantSelection(t,e){const a=this.getSharedSteps(e).map(i=>i.selectVariant(t));await Promise.all(a)}}class oA extends RA{constructor(t,e,A){super(t,e,A)}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyColorVariant(t)])}async applyGlobalState(t){var i,s,o;const e=this.getStateValue();if(!e)return Promise.resolve();const A=(s=(i=this.optionResource)==null?void 0:i.variants)==null?void 0:s.find(r=>r.id===e);if(!A)return Promise.resolve();await this.applyColorVariant(new at(A),t);const a=(o=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:o.customColor;a&&this.setCustomColor(a)}async applyColorVariant(t,e){const a=this.getSharedSteps(e).map(i=>{switch(i.getType()){case M.Shape:return i.selectVariant(t);case M.Text:return i.setFillColor({fill:t.getColor(),stroke:t.getColor(),variant:t.getResource()})}});await Promise.all(a)}setCustomColor(t){this.getSharedSteps().forEach(A=>A.setCustomColor(t)),this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{customColor:t})}getCustomColor(){var t,e;return((t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:t.customColor)||((e=this.getCurrentVariant())==null?void 0:e.getColor())||"#ffffff"}}class Qr{constructor(t,e,A,a,i){this.bundleId=t,this.bundleOwnerId=e,this.configuration=A,this.bundleOptions=i;const s=i==null?void 0:i.existingGlobalPropertyState;this.initPromise=s?Promise.resolve(s).then(()=>{this.globalPropertyState=s}):this.createGlobalPropertyState().then(o=>{this.globalPropertyState=o}),this.onGlobalPropertyStateChange=a}setBundleOptions(t){this.bundleOptions=t}getBundleOptions(){return this.bundleOptions}setConfiguration(t){this.configuration=t}getInitializationPromise(){return this.initPromise}getGlobalPropertyState(){return this.globalPropertyState}async setGlobalPropertyState(t){this.globalPropertyState||await this.initPromise;const e=xt(this.globalPropertyState);this.globalPropertyState={...t,id:e.id},await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(e,this.globalPropertyState)}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find(A=>A.name===t);if(e)return e.value}getAspectStorage(t){var e;if(!this.globalPropertyState)throw new Error("Global property state not initialized");return(e=this.globalPropertyState.aspects.find(A=>A.name===t))==null?void 0:e.storage}async setAspect(t,e,A){if(!this.globalPropertyState)throw new Error("Global property state not initialized");if(!this.configuration)throw new Error("Global property configuration not linked to the state manager.");const a=this.configuration.aspects.find(o=>o.name===t);if(!a)throw new Error(`Failed to find configuration aspect with name: ${t}`);const i=xt(this.globalPropertyState),s=this.globalPropertyState.aspects.find(o=>o.name===t);s?(s.value=e,s.type=a.type,A!==void 0&&(s.storage=A!==null?A:void 0)):this.globalPropertyState.aspects.push({name:t,value:e,type:a.type,storage:A!==null?A:void 0}),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(i,this.globalPropertyState)}async setAspectStorage(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");if(!this.configuration)throw new Error("Global property configuration not linked to the state manager.");const A=this.configuration.aspects.find(s=>s.name===t);if(!A)throw new Error(`Failed to find configuration aspect with name: ${t}`);const a=xt(this.globalPropertyState),i=this.globalPropertyState.aspects.find(s=>s.name===t);i?(i.storage=e!==null?e:void 0,i.type=A.type):this.globalPropertyState.aspects.push({name:t,value:"",type:A.type,storage:e!==null?e:void 0}),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(a,this.globalPropertyState)}async updateGlobalPropertyState(){var e,A;if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await y.getShadowGraphqlClient().mutate({mutation:Qo,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects.map(a=>{let i=a.type&&a.storage?{}:void 0;if(i)switch(a.type){case nt.FileUpload:{i.fileUpload=a.storage;break}case nt.Option:{i.option=a.storage;break}case nt.ColorOption:{i=a.storage;break}}return{name:a.name,value:a.value,type:a.type,storage:i}})},context:{headers:{bundleOwnerId:this.bundleOwnerId,...(e=this.bundleOptions)==null?void 0:e.additionalHeaders}}});if((A=t.data)!=null&&A.globalPropertyStateUpdate)this.globalPropertyState=t.data.globalPropertyStateUpdate;else throw new Error("Unable to update global property state")}async createGlobalPropertyState(){var e,A;const t=await y.getShadowGraphqlClient().mutate({mutation:fo,variables:{bundleId:this.bundleId},context:{headers:{bundleOwnerId:this.bundleOwnerId,...(e=this.bundleOptions)==null?void 0:e.additionalHeaders}}});if((A=t.data)!=null&&A.globalPropertyStateCreate&&t.data.globalPropertyStateCreate.id)return t.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}class pr{constructor(t){this.setState(t)}setState(t){t&&(this.state=JSON.parse(t))}applyStateToWorkflowExperience(t){var s;if(!this.state||!((s=t==null?void 0:t.getWorkflowManager())!=null&&s.getModelContainer()))return;const e=this.state.transactions.find(o=>o.transactionId===t.getWorkflowManager().getTransaction().id);if(!e)return;const A=this.getTransformToApply(e);if(!A)return;const a=this.flipTransform(A,t.getWorkflowManager().getPreviewService()),i=t.getWorkflowManager().getModelContainer();i.position=a.position,i.rotation=a.rotation,i.scale=a.scale}getTransformToApply(t){return t.activeTransform&&t.transforms?t.transforms[t.activeTransform]:t.transform}updateWorkflowExperienceTransform(t,e,A){const a=t.getWorkflowManager().getTransaction().id;this.state?this.state.transactions||(this.state.transactions=[]):this.state={transactions:[]};const i=this.state.transactions.find(s=>s.transactionId===a);i?(i.transforms||(i.transforms={}),i.transforms[e]=A):this.state.transactions.push({transactionId:a,activeTransform:e,transforms:{[e]:A}})}activateWorkflowExperienceTransform(t,e){var r,c;if(!((r=t==null?void 0:t.getWorkflowManager())!=null&&r.getModelContainer())||!this.state)return;const A=t.getWorkflowManager().getTransaction().id,a=this.state.transactions.find(l=>l.transactionId===A),i=(c=a==null?void 0:a.transforms)==null?void 0:c[e];if(!i)return;const s=this.flipTransform(i,t.getWorkflowManager().getPreviewService()),o=t.getWorkflowManager().getModelContainer();o.position=s.position,o.rotation=s.rotation,o.scale=s.scale,a.activeTransform=e}removeStateForTransaction(t){if(!this.state||!this.state.transactions)return;const e=this.state.transactions.findIndex(A=>A.transactionId===t);e!==-1&&this.state.transactions.splice(e,1)}getSerializedState(){if(this.state)return JSON.stringify(this.state)}flipTransform(t,e){return e&&e.flipTransform?e.flipTransform(t.position,{x:t.rotation.x*Math.PI/180,y:t.rotation.y*Math.PI/180,z:t.rotation.z*Math.PI/180},t.scale):{position:t.position,rotation:{x:t.rotation.x*Math.PI/180,y:t.rotation.y*Math.PI/180,z:t.rotation.z*Math.PI/180},scale:t.scale}}}class Mn{constructor(t){this.fullFetched=!1,this.collection=t;const e=this.collection.productCollectionProducts;e&&e.length>0&&(this.fullFetched=!0)}getId(){return this.collection.id}getName(){return this.collection.name}getDescription(){return this.collection.description||""}getImage(){return this.collection.image}getProducts(){if(!this.collection.productCollectionProducts)throw new Error("Failed to find products on collection. Ensure you fetch them first!");return this.collection.productCollectionProducts.map(t=>new Ot(t))}async fetchProducts(t){if(this.fullFetched)return this.collection.productCollectionProducts.map(A=>new Ot(A));const e=await y.getShadowGraphqlClient().query({query:yo,variables:{id:this.getId(),productIds:t},errorPolicy:"all"});return t||(this.fullFetched=!0),this.collection.productCollectionProducts=e.data.productCollections[0].productCollectionProducts||[],this.collection.productCollectionProducts.map(A=>new Ot(A))}async filterProducts(t){var i,s;const e=await y.getShadowGraphqlClient().query({query:Fo,errorPolicy:"all",variables:{id:this.getId(),filters:{link:"And",metafields:t}}});if(!((i=e.data)!=null&&i.productCollections)||((s=e.data)==null?void 0:s.productCollections.length)===0)throw new Error("Failed to filter product collection products.");const A=this.getProducts(),a=e.data.productCollections[0].productCollectionProducts.map(o=>o.product.id);return A.filter(o=>a.includes(o.getId()))}async fetchProductsFeed(t,e,A){var s,o,r,c,l,g;if(this.fullFetched){const d=await(A?this.filterProducts(A):this.fetchProducts());return{total:d.length,items:d.slice(t,t+e)}}const a=await y.getShadowGraphqlClient().query({query:Mo,variables:{id:this.getId(),limit:e,offset:t,filters:A?{link:"And",metafields:A}:void 0},errorPolicy:"all"});return{items:((r=(o=(s=a==null?void 0:a.data)==null?void 0:s.productCollections)==null?void 0:o[0].productCollectionProductsFeed)==null?void 0:r.items.map(d=>new Ot(d)))||[],total:((g=(l=(c=a==null?void 0:a.data)==null?void 0:c.productCollections)==null?void 0:l[0].productCollectionProductsFeed)==null?void 0:g.total)??0}}getTransformCollection(){if(this.collection.transformCollection)return new Sn(this.collection.transformCollection)}getResource(){return this.collection}}class Ot{constructor(t){this.product=t.product,this.productResource=t}getId(){return this.product.id}getName(){return this.product.name}getIntegrationByType(t,e){const a=(this.product.integrationProducts||[]).find(i=>{var c,l,g;const s=(c=i.integration)==null?void 0:c.type,o=((l=i.integration)==null?void 0:l.type)===t,r=e?((g=i.integration)==null?void 0:g.externalIntegrationId)===e:!0;return s&&o&&r});if(!a)throw new Error("Failed to find requested integration type on product. This is generally due to a configuration error");return a}getCurrentIntegration(){const e=(this.product.integrationProducts||[]).find(A=>{var a;return(a=A.integration)==null?void 0:a.isCurrent});if(!e)throw new Error(`Product: ${this.productResource.id} is not linked to this current integration. This is generally due to a configuration error.`);return e}getDefaultWorkflow(){const t=this.product.workflows;if(t===void 0)throw new lt("Called getDefaultWorkflow() before fetching collection products. Use collection.fetchProducts() first to ensure the data is available.");if(t.length===0)throw new lt("Called getDefaultWorkflow() but no workflows on requested product. Ensure at least 1 workflow is assigned to this product.");const e=this.productResource.workflowId;if(e){const A=t.find(a=>a.workflowName===e);if(A)return new Yt(A)}if(t.length===1)return console.warn("Called getDefaultWorkflow() but no default was configured. There is only one workflow available so we will fall back to using this!"),new Yt(t[0]);throw new lt("Called getDefaultWorkflow() but no default workflow is configured for the requested product. Multiple workflows exist so we can't assume!")}getAllWorkflows(){if((this.product.workflows||[]).length===0)throw new lt("No workflows on configured product. Ensure at least 1 workflow is assigned to this product.");return this.product.workflows.sort((e,A)=>(e.index??0)-(A.index??0)).map(e=>new Yt(e))}getIntegrations(){return this.product.integrationProducts||[]}getResource(){return this.product}getBasePrice(t){var a,i,s,o;const e=this.product.basePrice||0;if(!t)return e;if(!t.integrationType&&!t.externalId&&!t.integrationId)throw new Error("You must provide at least one of the following fields on the includeAdditionalProduct object: integrationType, externalId, integrationId");let A;return t.integrationId?A=(a=this.product.integrationProducts)==null?void 0:a.find(r=>{var c;return((c=r.integration)==null?void 0:c.id)===t.integrationId}):t.externalId?A=(i=this.product.integrationProducts)==null?void 0:i.find(r=>{var c;return((c=r.integration)==null?void 0:c.externalIntegrationId)===t.externalId}):A=(s=this.product.integrationProducts)==null?void 0:s.find(r=>{var c;return((c=r.integration)==null?void 0:c.type)===t.integrationType}),(o=A==null?void 0:A.additionalIntegrationProduct)!=null&&o.product?e+(A.additionalIntegrationProduct.product.basePrice||0):e}}class Yt{constructor(t){this.workflow=t}getId(){return this.workflow.workflowName}getName(){return this.workflow.friendlyName}getThumbnail(){return this.workflow.imageUrl}}class Sn{constructor(t){this.collection=t}getId(){return this.collection.id}getName(){return this.collection.name}getTransforms(){return this.collection.transforms.map(t=>new xn(t))}}class xn{constructor(t){this.transform=t}getId(){return this.transform.id}getName(){return this.transform.name}get(){return{position:this.transform.position,rotation:this.transform.rotation,scale:this.transform.scale}}}class ze{constructor(t,e,A,a,i,s){var r,c,l;this.eventListeners=new Map,this.workflowExperiences=[],this.client=t,this.id=e.id,this.name=e.name||"",this.shareActions=e.bundleShareActions,this.workflowViewerLink=e.workflowViewerLink,this.workflowViewerAmendLink=e.workflowViewerAmendLink,this.ownerId=i,this.metadata=new Map(((r=e.metadata)==null?void 0:r.map(g=>[g.key,g.value]))||[]),this.completed=e.completed??!1,this.productCollection=e.productCollection,this.bundleStateManager=new pr(e.bundleStateData);const o=(c=this.productCollection)==null?void 0:c.globalPropertyConfiguration;this.globalConfigurationPropertyId=o==null?void 0:o.id,this.globalPropertyStateManager=new Qr(this.id,this.ownerId,o,this.checkConditionalHandlesChanged.bind(this),s),this.globalPropertyHandleService=new fr(this),this.setPreviewService(A),this.initializationPromise=Promise.all([this.loadExistingWorkflowExperiences(((l=e.transactions)==null?void 0:l.map(g=>g.id))||[],{...a,bundleOwnerId:i}),this.globalPropertyStateManager.getInitializationPromise()]),this.initializationPromise.catch(g=>{console.error(`Bundle initialization failed: ${g}`)})}setBundleOptions(t){this.globalPropertyStateManager.setBundleOptions(t)}getInitializationPromise(){return this.initializationPromise}addEventListener(t,e){this.eventListeners.set(t,[...this.eventListeners.get(t)||[],e])}removeEventListener(t,e){const A=this.eventListeners.get(t)||[],a=A.indexOf(e);a>-1&&A.splice(a,1)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,e){return this.name=t,this.metadata=new Map(e),this.updateBundle()}hasGlobalProperties(){var t;return!!((t=this.productCollection)!=null&&t.globalPropertyConfiguration)}getGlobalPropertyConfiguration(){var t;return(t=this.productCollection)==null?void 0:t.globalPropertyConfiguration}async getGlobalProperties(){return this.globalPropertyHandleService.applyConditionsFromState(await this.globalPropertyHandleService.getHandles(),this.getGlobalPropertyStateManager().getGlobalPropertyState())}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}async getGlobalPropertyTotalSubunits(){return(await this.globalPropertyHandleService.getHandles()).filter(A=>A.getType()===nt.Option).map(A=>{var a;return((a=A.getCurrentVariant())==null?void 0:a.getPrice())||0}).reduce((A,a)=>A+a,0)}getTotalSubunits(){return this.workflowExperiences.map(t=>t.getTotalPriceSubunits()).reduce((t,e)=>t+e,0)}getProductCollection(){return this.productCollection?new Mn(this.productCollection):void 0}async addWorkflowExperience(t){t.setBundle(this),await this.appendWorkflowExperience(t),await this.injectExperienceIntoPreviewService(t),await t.getWorkflowManager().getInitializationPromise();const e=await this.getGlobalProperties();for(const A of e)await A.applyGlobalState([t])}async addWorkflowExperiences(t){const e=t.map(o=>o.getWorkflowManager().getTransaction().id),A=e.map(o=>this.workflowExperiences.find(r=>r.getWorkflowManager().getTransaction().id===o));if(A.some(o=>!!o))throw new Error("Unable to add transaction to bundle - Already Exists: "+A.filter(o=>!!o).map(o=>o==null?void 0:o.getWorkflowManager().getTransaction().id).join(", "));const a=k.getMap("transactionOwnerIds")||new Map,i=e.map(o=>a.get(o));await y.getShadowGraphqlClient().mutate({mutation:vo,variables:{id:this.id,transactionIds:e,transactionOwnerIds:i},context:{bundleOwnerId:this.ownerId}}).catch(o=>{console.error(o)}),this.workflowExperiences.push(...t);const s=async()=>{for(const r of t)r.setBundle(this),await this.injectExperienceIntoPreviewService(r);await Promise.all(t.map(r=>r.getWorkflowManager().getInitializationPromise()));const o=await this.getGlobalProperties();for(const r of o)await r.applyGlobalState(t)};await Promise.all([this.updateTransactionOrder(),s()]),this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges())}async appendWorkflowExperience(t,e=!0){const A=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find(o=>o.getWorkflowManager().getTransaction().id===A))throw new Error("Unable to add transaction to bundle - Already Exists!");const s=(k.getMap("transactionOwnerIds")||new Map).get(A);await y.getShadowGraphqlClient().mutate({mutation:Po,variables:{id:this.id,transactionId:A},context:{bundleOwnerId:this.ownerId,transactionOwnerId:s}}),e&&(this.workflowExperiences.push(t),this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges()))}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);await this.removeTransaction(e,this.workflowExperiences[e].getWorkflowManager().getTransaction())}async removeWorkflowExperiences(t){await this.removeTransactions(t.map(e=>e.getWorkflowManager().getTransaction()))}async removeWorkflowExperienceByTransaction(t){const e=this.workflowExperiences.findIndex(A=>A.getWorkflowManager().getTransaction().id===t.id);await this.removeTransaction(e,t)}async removeWorkflowExperiencesByTransactions(t){await this.removeTransactions(t)}async removeTransaction(t,e,A=!0){if(t>-1){const a=this.workflowExperiences.find(i=>i.getWorkflowManager().getTransaction().id===e.id);a.setBundle(void 0),this.previewService&&a.getWorkflowManager().ejectFromPreviewService(),this.bundleStateManager.removeStateForTransaction(e.id),await y.getShadowGraphqlClient().mutate({mutation:ko,variables:{id:this.id,transactionId:e.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([i,s])=>({key:i,value:s})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),A&&(this.workflowExperiences.splice(t,1),this.workflowExperiences.forEach(i=>i.checkForPriceBreakChanges()),a.checkForPriceBreakChanges(),await this.updateTransactionOrder())}else throw new Error("Unable to remove workflow experience from bundle - Not Found! - "+e.id)}async removeTransactions(t){const e=t.map(a=>this.workflowExperiences.findIndex(i=>i.getWorkflowManager().getTransaction().id===a.id));if(e.some(a=>a===-1))throw new Error("Unable to remove workflow experience from bundle - The following aren't included in the bundle: "+t.filter((a,i)=>e[i]===-1).map(a=>a.id).join(", "));const A=t.map(a=>this.workflowExperiences.splice(this.workflowExperiences.findIndex(i=>i.getWorkflowManager().getTransaction().id===a.id),1)[0]);A.forEach(a=>a.setBundle(void 0)),[...this.workflowExperiences,...A].forEach(a=>a.checkForPriceBreakChanges()),this.previewService&&A.forEach(a=>a.getWorkflowManager().ejectFromPreviewService()),t.forEach(a=>this.bundleStateManager.removeStateForTransaction(a.id)),await y.getShadowGraphqlClient().mutate({mutation:No,variables:{id:this.id,transactionIds:t.map(a=>a.id),name:this.name,metadata:Array.from(this.metadata.entries()).map(([a,i])=>({key:a,value:i})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),await this.updateTransactionOrder()}async insertWorkflowExperience(t,e){await this.appendWorkflowExperience(t,!1),this.workflowExperiences.splice(e,0,t),await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(t);const A=await this.getGlobalProperties();await Promise.all(A.map(a=>a.applyGlobalState([t])))})()])}async replaceWorkflowExperience(t,e){if(t<0||t>=this.workflowExperiences.length)throw new Error("Unable to replace workflow experience in bundle - Index out of range!");const A=this.workflowExperiences[t];if(A.getWorkflowManager().getTransaction().id===e.getWorkflowManager().getTransaction().id)throw new Error("Unable to replace workflow experience in bundle - Same transaction!");await Promise.all([this.removeTransaction(t,A.getWorkflowManager().getTransaction(),!1),this.appendWorkflowExperience(e,!1)]),this.workflowExperiences[t]=e,await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(e);const a=await this.getGlobalProperties();await Promise.all(a.map(i=>i.applyGlobalState([e])))})()])}async swapWorkflowExperiences(t,e){if(t<0||t>=this.workflowExperiences.length||e<0||e>=this.workflowExperiences.length)throw new Error("Unable to swap workflow experiences in bundle - Index out of range!");if(t===e)return;const A=this.workflowExperiences[t];this.workflowExperiences[t]=this.workflowExperiences[e],this.workflowExperiences[e]=A,await this.updateTransactionOrder()}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await this.updateTransactionOrder()}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,e){var i;const A=await y.getShadowGraphqlClient().mutate({mutation:bo,variables:{id:this.id,details:t,type:e||Wt.Owner},context:{bundleOwnerId:this.ownerId}});if(!((i=A.data)!=null&&i.bundleAddStakeholder))throw new Error("Bundle not found!");const a=A.data.bundleAddStakeholder.bundleStakeholders||[];this.storeStakeholderCustomers(a)}async removeStakeholder(t){var A;if(!((A=(await y.getShadowGraphqlClient().mutate({mutation:Ro,variables:{id:this.id,emailAddress:t},context:{bundleOwnerId:this.ownerId}})).data)!=null&&A.bundleRemoveStakeholder))throw new Error("Bundle not found!")}async updateStakeholders(t){var a;const e=await y.getShadowGraphqlClient().mutate({mutation:Ho,variables:{id:this.id,input:t},context:{bundleOwnerId:this.ownerId}});if(!((a=e.data)!=null&&a.bundleUpdateStakeholders))throw new Error("Bundle not found!");const A=e.data.bundleUpdateStakeholders.bundleStakeholders||[];this.storeStakeholderCustomers(A)}async getAllStakeholders(){const t=await y.getShadowGraphqlClient().query({query:ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id},context:{bundleOwnerId:this.ownerId}});if(!t.data.bundles||t.data.bundles.length===0)throw new Error("Bundle not found!");const e=t.data.bundles[0].bundleStakeholders||[];return this.storeStakeholderCustomers(e),e}async getCurrentStakeholder(){const t=await y.getShadowGraphqlClient().query({query:ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id},context:{bundleOwnerId:this.ownerId}});if(!t.data.bundles||t.data.bundles.length===0)throw new Error("Bundle not found!");return t.data.bundles[0].currentBundleStakeholder}storeStakeholderCustomers(t){t.forEach(e=>{e.customer&&this.client.storeCustomer(e.customer)})}async finish(t,e){if(this.completed)return await y.getShadowGraphqlClient().mutate({mutation:Lo,variables:{bundleId:this.id}}),{bundleId:this.id,items:[],bundleOwnerId:this.ownerId};const A=await tr(this.workflowExperiences.map(a=>({workflowManager:a.getWorkflowManager(),workflow:a.getWorkflowManager().getWorkflow(),layouts:a.getWorkflowManager().getLayouts(),getReducerState:()=>a.getCommandContext().getState(),product:a.getWorkflowManager().getProduct(),transaction:a.getWorkflowManager().getTransaction(),workflowSelections:a.getWorkflowManager().getWorkflowSelections(),designName:a.getWorkflowManager().getWorkflow().name,workflowMetadata:a.getWorkflowManager().getWorkflowMetadata()})),t??(()=>{}),e?(a,i)=>{const s=this.workflowExperiences.find(o=>o.getWorkflowManager().getTransaction().id===i);return s?e(s):(console.warn("SpiffCommerce - Bundle create design - Unable to find experience for transaction: "+i),Promise.resolve(void 0))}:void 0);return{bundleId:this.id,items:A,bundleOwnerId:this.ownerId}}async placeOrder(){const t=this.workflowExperiences.map(e=>({transactionId:e.getWorkflowManager().getTransaction().id,amountToOrder:e.getWorkflowManager().getTransaction().quantity||1}));return await this.getClient().placeOrder(t)}getPreviewService(){return this.previewService}async setPreviewService(t){if(this.workflowExperiences&&this.workflowExperiences.length>0&&(this.workflowExperiences.forEach(e=>e.getWorkflowManager().ejectFromPreviewService()),t))for(const e of this.workflowExperiences)await this.injectExperienceIntoPreviewService(e);t&&t.registerModelLoadEventListener&&t.registerModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService&&this.previewService!==t&&this.previewService.unregisterModelLoadEventListener&&this.previewService.unregisterModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService=t}updateWorkflowExperienceTransform(t,e,A){return this.bundleStateManager.updateWorkflowExperienceTransform(t,e,A),this.updateBundle()}activateWorkflowExperienceTransform(t,e){return this.bundleStateManager.activateWorkflowExperienceTransform(t,e),this.updateBundle()}async assignGlobalPropertyConfiguration(t){await y.getShadowGraphqlClient().mutate({mutation:To,variables:{bundleId:this.id,globalPropertyConfigurationId:t},context:{bundleOwnerId:this.ownerId}}),this.globalConfigurationPropertyId=t}async assignProductCollection(t){var A,a;const e=await y.getShadowGraphqlClient().mutate({mutation:Go(((A=this.globalPropertyStateManager.getBundleOptions())==null?void 0:A.eagerFetchProducts)??!1),variables:{id:this.id,productCollectionId:t??""},context:{bundleOwnerId:this.ownerId}});if((a=e.data)!=null&&a.bundleAssignProductCollection.productCollection&&!this.globalConfigurationPropertyId){this.productCollection=e.data.bundleAssignProductCollection.productCollection;const i=e.data.bundleAssignProductCollection.productCollection.globalPropertyConfiguration;this.globalPropertyStateManager.setConfiguration(i),this.globalConfigurationPropertyId=i==null?void 0:i.id}}onModelLoadEvent(t){t.eventType==="unload"||!t.modelContainer||(t.modelContainer.registerMaterialSelectedCallback(()=>this.onModelSelectedEvent(t.modelContainer,!0)),t.modelContainer.registerMaterialDeselectedCallback(()=>this.onModelSelectedEvent(t.modelContainer,!1)))}onModelSelectedEvent(t,e){if(t&&t.metadata&&t.metadata instanceof Map&&t.metadata.has("workflowManager")){const a=t.metadata.get("workflowManager").getTransaction(),i=this.workflowExperiences.find(s=>s.getWorkflowManager().getTransaction().id===a.id);i&&this.fireEvent(e?"workflow-experience-hover-enter":"workflow-experience-hover-exit",{workflowExperience:i})}}async injectExperienceIntoPreviewService(t){if(this.previewService){const e=t.getWorkflowManager().injectIntoPreviewService(this.previewService);try{this.bundleStateManager.applyStateToWorkflowExperience(t)}catch(A){console.error(`Unable to apply state to workflow experience: ${A}`)}await e}}async loadExistingWorkflowExperiences(t,e){if(t.length===0)return;const A=await this.client.getWorkflowExperiences(t.map(a=>({type:"transaction",transactionId:a})),e);if(A.forEach(a=>a.setBundle(this)),A.forEach(a=>a.checkForPriceBreakChanges()),this.workflowExperiences=A,this.previewService)for(const a of A)await this.injectExperienceIntoPreviewService(a)}async updateBundle(){var e;if(!((e=(await y.getShadowGraphqlClient().mutate({mutation:Yo,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([A,a])=>({key:A,value:a})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}})).data)!=null&&e.bundleUpdate))throw new Error("Bundle not found!")}async updateTransactionOrder(){await y.getShadowGraphqlClient().mutate({mutation:Uo,variables:{id:this.id,transactionIds:this.workflowExperiences.map(t=>t.getWorkflowManager().getTransaction().id)},context:{bundleOwnerId:this.ownerId}})}async checkConditionalHandlesChanged(t,e){const A=await this.globalPropertyHandleService.getHandles(),a=this.globalPropertyHandleService.applyConditionsFromState(A,t),i=this.globalPropertyHandleService.applyConditionsFromState(A,e);if((()=>{if(a.length!==i.length)return!0;for(let o=0;o<a.length;o++)if(a[o].getName()!==i[o].getName())return!0;return!1})()){this.fireEvent("conditional-global-properties-changed",{globalProperties:i});const o=i.filter(r=>!a.includes(r));await Promise.all(o.map(r=>r.applyGlobalState()))}}fireEvent(t,e){(this.eventListeners.get(t)||[]).forEach(a=>a({bundle:this,event:t,data:e}))}getShareActions(){return this.shareActions}getWorkflowViewerLink(){return this.workflowViewerLink}getWorkflowViewerAmendLink(){return this.workflowViewerAmendLink}async approve(t){await y.getShadowGraphqlClient().mutate({mutation:Oo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t}})}async reject(t){await y.getShadowGraphqlClient().mutate({mutation:zo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t}})}}const Ir=Q.gql`
3264
+ `)},w))}else a.push(new z(E,w))}return a},dr=(n,t)=>n.conditions?n.conditions.every(e=>{const A=t[e.targetStepName];if(A&&A.selectedVariants){const a=A.selectedVariants;return e.requiredVariantSelections.some(i=>a.find(s=>s.id===i)!==void 0)}return!1}):!0,Dn=async(n,t,e,A)=>{const a=[],i={};for(const s of n){const o=t.steps.find(r=>r.stepName===s.name);if(o)switch(o.type){case M.DigitalContent:a.push(...await nr(e,s,o));break;case M.Frame:case M.Photo:a.push(...await ir(e,i,s,o));break;case M.Illustration:a.push(...await sr(e,i,s,o));break;case M.Module:a.push(...await or(e,s,o));break;case M.Picture:a.push(...await rr(e,i,s,o));break;case M.Shape:a.push(...await cr(e,i,s,o));break;case M.Text:a.push(...await gr(e,i,s,o));break}}for(const s of t.steps)s.type!==M.SilentIllustration&&s.type!==M.ProductOverlay||dr(s,i)&&a.push(...await lr(e,s,A));return a};class Br{constructor(t){this.handleCompleteRender=null;const e=new Map;t.forEach(A=>e.set(A.id,new ur(A.id,A.name,this,{width:A.width,height:A.height}))),this.layouts=e}setCompleteRenderCallback(t){this.handleCompleteRender=t,t(Array.from(this.layouts.values()))}onCompleteRender(){this.handleCompleteRender&&this.handleCompleteRender(Array.from(this.layouts.values()))}getAll(){return this.layouts}}const hr=()=>new Promise((n,t)=>{try{const A=ht().getContext("webgl2");n(!!A)}catch{n(!1)}}),Cr=hr();class ur{constructor(t,e,A,a){this.hasSetStaticContext=!1,this.interactiveDirty=!1,this.staticCtxDirty=!1,this.lastRequestedRenderArguments=void 0,this.lastCompletedStaticRender=void 0,this.renderQueue=new EA(2),this.id=t,this.name=e,this.service=A,this.panelSize=a}getID(){return this.id}getName(){return this.name}getPanelSize(){return this.panelSize}getStaticContext(){return this.textureCtx}setStaticContext(t){this.textureCtx=t,this.lastRequestedRenderArguments&&this.render(this.lastRequestedRenderArguments)}getStaticContextDirty(){return this.staticCtxDirty}setStaticContextDirty(t){this.staticCtxDirty=t}getInteractiveCanvasDirty(){return this.interactiveDirty}setInteractiveCanvasDirty(t){this.interactiveDirty=t}markLastCompletedStaticRender(){this.lastCompletedStaticRender=Date.now(),this.service.onCompleteRender()}getLastCompletedStaticRender(){return this.lastCompletedStaticRender}async render(t){const e=xt(t);this.lastRequestedRenderArguments=e;const A=this.getStaticContext();if(!A){this.markLastCompletedStaticRender(),this.setStaticContextDirty(!1);return}this.renderQueue.enqueue(new wr(this.getID(),A,await Cr,()=>{this.markLastCompletedStaticRender(),this.setStaticContextDirty(!0)},e))}}class wr extends wA{constructor(t,e,A,a,i){super(),this.layoutId=t,this.ctx=e,this.nonPOTSupport=A,this.onRender=a,this.layouts=i}getDynamicTextureResolution(){return this.getIsMobile()||!this.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}getIsMobile(){return window.innerWidth<=480}offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}resizeFit(t,e=4096){const A=e/t.width,a=e/t.height,i=Math.min(A,a);return i>1?t:{width:t.width*i,height:t.height*i}}async execute(){const t=this.layouts.find(B=>B.layoutState.layout.id===this.layoutId);if(!t)return;const e=t.layoutState.elements||[],A=t.layoutState.layout.width,a=t.layoutState.layout.height,i=A===1||a===1?{width:1,height:1}:this.getDynamicTextureResolution(),s=i.width,o=i.height;let r,c;if(this.nonPOTSupport){const B=s/o;A/a<B?(r=s,c=a*(s/A)):(r=A*(o/a),c=o);const C=this.resizeFit({width:r,height:c});r=C.width,c=C.height}else r=i.width,c=i.height;const l=Se(t.layoutState.layout,e,{renderingConfiguration:{purpose:Pt.ThreeD}}),g=Ea(l),d=await cA.Pith.from(this.ctx,g,{anonymousCrossOrigin:!0,ignoreDimensions:!this.nonPOTSupport,ignoreAnimation:!0,ignoreClear:!0,ignoreMouse:!0,enableRedraw:!1,createCanvas:ht,createImage:Ae,DOMParser:hA(),fetch});d.resize(r,c),await d.render(),this.onRender()}}const Er=(n,t)=>{const e=[];return n.forEach(A=>{const a=t.steps.find(i=>i.stepName===A.stepName);(a==null?void 0:a.type)===M.Text&&A.stepAspectType==="Text"&&e.push({name:a.stepName,data:{text:A.value}})}),e},mr=async(n,t,e,A)=>{let a={serializableWorkflow:{steps:[]},layouts:{}};a=new G(e.map(r=>new DA(r))).apply(a);const s=await Dn(n,t,e,A);return new G(s).apply(a)};class fr{constructor(t){this.handleCache={},this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){var e;if(!((e=this.bundle.getProductCollection())!=null&&e.getResource().globalPropertyConfiguration))return[];const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map(A=>this.getHandle(A)))}applyConditionsFromState(t,e){return e?t.filter(A=>this.aspectConditionsSatisfied(A.getRawProperty(),e)):t}aspectConditionsSatisfied(t,e){return!t.conditions||t.conditions.length===0?!0:t.conditions.some(A=>{const a=e.aspects.find(i=>i.name===A.targetAspectName);return a?A.requiredVariantSelections.some(i=>i===a.value):!1})}async createHandle(t){switch(t.type){case et.FileUpload:return new yn(this.bundle,t);case et.ColorOption:return new oA(this.bundle,t,t.entityId?await $.getOption(t.entityId):void 0);case et.Option:{const e=t.entityId?await $.getOption(t.entityId):void 0;return(e==null?void 0:e.type)==="Color"?new oA(this.bundle,t,e):new RA(this.bundle,t,e)}case et.Text:return new Fn(this.bundle,t);default:throw new Error("Unhandled Global Property Aspect Type")}}}class Pe{constructor(t,e){this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap(a=>a.getStepsConditionallyActive().filter(i=>{var s;return i.getOverrideGlobalPropertyConfiguration(this.property.type)?!1:(s=i.getRaw().globalPropertyAspectConfigurations)==null?void 0:s.some(o=>{var r,c;return o.globalPropertyConfigurationId===((c=(r=this.bundle.getProductCollection())==null?void 0:r.getResource().globalPropertyConfiguration)==null?void 0:c.id)&&o.aspectName===this.property.name})}))}getStateValue(){return this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name)}}class yn extends Pe{constructor(t,e){super(t,e)}async selectImage(t){const e=this.bundle.getGlobalPropertyStateManager();await Promise.all([e.setAspect(this.property.name,t.key,{...e.getAspectStorage(this.property.name)||{},originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}),this.applyImageSelection(t)])}async canUseBackgroundRemover(){return this.bundle.getClient().canUseAddon(Qe.BackgroundRemover)}async removeBackgroundFromImage(t=!0){if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const e=await this.getOriginalImage();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const A=this.bundle.getGlobalPropertyStateManager(),a=await T.removeBackgroundFromAsset(e),s={...A.getAspectStorage(this.property.name),backgroundRemovedAssetKey:a.key,useOriginalAsset:!t},r=[t?A.setAspect(this.property.name,a.key,s):A.setAspectStorage(this.property.name,s)];return t&&r.push(this.applyImageSelection(a,void 0,!1,!1)),await Promise.all(r),this.updateSharedStepStorage(s),a}hasImage(){return!!this.getStateValue()}async getImage(){const t=this.getStateValue();if(t)return T.getLocalOrFromServer(t)}async getOriginalImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t!=null&&t.originalAssetKey)return T.getLocalOrFromServer(t.originalAssetKey)}async getBackgroundRemovedImage(){const t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);if(t!=null&&t.backgroundRemovedAssetKey)return T.getLocalOrFromServer(t.backgroundRemovedAssetKey)}getUseOriginalImage(){var t;return((t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:t.useOriginalAsset)??!1}async setUseOriginalImage(t){const e=await this.getOriginalImage();if(!e)throw new Error("You must select an image before calling setUseOriginalImage");const A=this.bundle.getGlobalPropertyStateManager(),a=A.getAspectStorage(this.property.name);if((a==null?void 0:a.useOriginalAsset)===t)return;const i={...a,useOriginalAsset:t},s=t?a==null?void 0:a.originalAssetKey:a==null?void 0:a.backgroundRemovedAssetKey,o=[A.setAspect(this.property.name,s||"",i)];if(t)o.push(this.applyImageSelection(e,void 0,!1,!1));else{const r=async()=>{const c=await this.getBackgroundRemovedImage();if(!c)throw new Error("You must call removeBackgroundFromImage before attempting to use that version of the image.");this.applyImageSelection(c,void 0,!1,!1)};o.push(r())}this.updateSharedStepStorage(i)}async applyGlobalState(t){const e=this.getStateValue();if(!e)return;const A=await T.getLocalOrFromServer(e);if(!A)return;const a=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);await this.applyImageSelection(A,t,!1,!0),a?this.updateSharedStepStorage({...a}):(this.updateSharedStepStorage({originalAssetKey:e}),await this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{originalAssetKey:e}))}async applyImageSelection(t,e,A=!0,a=!0){const s=this.getSharedSteps(e).map(o=>{const r=o;if(r.getFrameService())return r.selectImage(t,A,a)});await Promise.all(s)}updateSharedStepStorage(t){this.bundle.getWorkflowExperiences().forEach(A=>A.getSteps().forEach(a=>{var s;if(a.getOverrideGlobalPropertyConfiguration(this.property.type))return;((s=a.getRaw().globalPropertyAspectConfigurations)==null?void 0:s.some(o=>{var r,c;return o.globalPropertyConfigurationId===((c=(r=this.bundle.getProductCollection())==null?void 0:r.getResource().globalPropertyConfiguration)==null?void 0:c.id)&&o.aspectName===this.property.name}))&&A.getWorkflowManager().updateStorage(a.getId(),{framePatternData:t})}))}}class Fn extends Pe{constructor(t,e){super(t,e)}getText(){const t=this.getStateValue();return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.getStateValue();if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const a=this.getSharedSteps(e).map(i=>{i.setText(t)});await Promise.all(a)}}class RA extends Pe{constructor(t,e,A){super(t,e),this.optionResource=A}async initDefaultVariant(){var e,A;const t=(A=(e=this.optionResource)==null?void 0:e.variants)==null?void 0:A.find(a=>{var i,s;return a.id===((s=(i=this.optionResource)==null?void 0:i.defaultVariant)==null?void 0:s.id)});t&&await this.selectVariant(new nt(t))}getCurrentVariant(){var e,A;if(!this.optionResource)return;const t=this.getStateValue();if(t){const a=(A=this.optionResource.variants)==null?void 0:A.find(i=>i.id===t);return a?new nt(a):void 0}else{const a=(e=this.optionResource.variants)==null?void 0:e.find(i=>{var s,o;return i.id===((o=(s=this.optionResource)==null?void 0:s.defaultVariant)==null?void 0:o.id)});return a?new nt(a):void 0}}getAvailableVariants(){var e,A;return(((A=(e=this.optionResource)==null?void 0:e.variants)==null?void 0:A.filter(a=>a.enabled))||[]).map(a=>new nt(a))}getAllVariants(){var e;return(((e=this.optionResource)==null?void 0:e.variants)||[]).map(A=>new nt(A))}async selectVariant(t){console.log(`Selecting variant ${t.getId()}`),await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){var a,i;const e=this.getStateValue();if(!e)return Promise.resolve();const A=(i=(a=this.optionResource)==null?void 0:a.variants)==null?void 0:i.find(s=>s.id===e);return A?(console.log(`Applying global state using variant ${A.id} for aspect ${e}`),this.applyVariantSelection(new nt(A),t)):Promise.resolve()}async applyVariantSelection(t,e){const a=this.getSharedSteps(e).map(i=>i.selectVariant(t));await Promise.all(a)}}class oA extends RA{constructor(t,e,A){super(t,e,A)}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyColorVariant(t)])}async applyGlobalState(t){var i,s,o;const e=this.getStateValue();if(!e)return Promise.resolve();const A=(s=(i=this.optionResource)==null?void 0:i.variants)==null?void 0:s.find(r=>r.id===e);if(!A)return Promise.resolve();await this.applyColorVariant(new nt(A),t);const a=(o=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:o.customColor;a&&this.setCustomColor(a)}async applyColorVariant(t,e){const a=this.getSharedSteps(e).map(i=>{switch(i.getType()){case M.Shape:return i.selectVariant(t);case M.Text:return i.setFillColor({fill:t.getColor(),stroke:t.getColor(),variant:t.getResource()})}});await Promise.all(a)}setCustomColor(t){this.getSharedSteps().forEach(A=>A.setCustomColor(t)),this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name,{customColor:t})}getCustomColor(){var t,e;return((t=this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name))==null?void 0:t.customColor)||((e=this.getCurrentVariant())==null?void 0:e.getColor())||"#ffffff"}}class Qr{constructor(t,e,A,a,i){this.bundleId=t,this.bundleOwnerId=e,this.configuration=A,this.bundleOptions=i;const s=i==null?void 0:i.existingGlobalPropertyState;this.initPromise=s?Promise.resolve(s).then(()=>{this.globalPropertyState=s}):this.createGlobalPropertyState().then(o=>{this.globalPropertyState=o}),this.onGlobalPropertyStateChange=a}setBundleOptions(t){this.bundleOptions=t}getBundleOptions(){return this.bundleOptions}setConfiguration(t){this.configuration=t}getInitializationPromise(){return this.initPromise}getGlobalPropertyState(){return this.globalPropertyState}async setGlobalPropertyState(t){this.globalPropertyState||await this.initPromise;const e=xt(this.globalPropertyState);this.globalPropertyState={...t,id:e.id},await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(e,this.globalPropertyState)}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find(A=>A.name===t);if(e)return e.value}getAspectStorage(t){var e;if(!this.globalPropertyState)throw new Error("Global property state not initialized");return(e=this.globalPropertyState.aspects.find(A=>A.name===t))==null?void 0:e.storage}async setAspect(t,e,A){if(!this.globalPropertyState)throw new Error("Global property state not initialized");if(!this.configuration)throw new Error("Global property configuration not linked to the state manager.");const a=this.configuration.aspects.find(o=>o.name===t);if(!a)throw new Error(`Failed to find configuration aspect with name: ${t}`);const i=xt(this.globalPropertyState),s=this.globalPropertyState.aspects.find(o=>o.name===t);s?(s.value=e,s.type=a.type,A!==void 0&&(s.storage=A!==null?A:void 0)):this.globalPropertyState.aspects.push({name:t,value:e,type:a.type,storage:A!==null?A:void 0}),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(i,this.globalPropertyState)}async setAspectStorage(t,e){if(!this.globalPropertyState)throw new Error("Global property state not initialized");if(!this.configuration)throw new Error("Global property configuration not linked to the state manager.");const A=this.configuration.aspects.find(s=>s.name===t);if(!A)throw new Error(`Failed to find configuration aspect with name: ${t}`);const a=xt(this.globalPropertyState),i=this.globalPropertyState.aspects.find(s=>s.name===t);i?(i.storage=e!==null?e:void 0,i.type=A.type):this.globalPropertyState.aspects.push({name:t,value:"",type:A.type,storage:e!==null?e:void 0}),await this.updateGlobalPropertyState(),await this.onGlobalPropertyStateChange(a,this.globalPropertyState)}async updateGlobalPropertyState(){var e,A;if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await y.getShadowGraphqlClient().mutate({mutation:Qo,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects.map(a=>{let i=a.type&&a.storage?{}:void 0;if(i)switch(a.type){case et.FileUpload:{i.fileUpload=a.storage;break}case et.Option:{i.option=a.storage;break}case et.ColorOption:{i=a.storage;break}}return{name:a.name,value:a.value,type:a.type,storage:i}})},context:{headers:{bundleOwnerId:this.bundleOwnerId,...(e=this.bundleOptions)==null?void 0:e.additionalHeaders}}});if((A=t.data)!=null&&A.globalPropertyStateUpdate)this.globalPropertyState=t.data.globalPropertyStateUpdate;else throw new Error("Unable to update global property state")}async createGlobalPropertyState(){var e,A;const t=await y.getShadowGraphqlClient().mutate({mutation:fo,variables:{bundleId:this.bundleId},context:{headers:{bundleOwnerId:this.bundleOwnerId,...(e=this.bundleOptions)==null?void 0:e.additionalHeaders}}});if((A=t.data)!=null&&A.globalPropertyStateCreate&&t.data.globalPropertyStateCreate.id)return t.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}class pr{constructor(t){this.setState(t)}setState(t){t&&(this.state=JSON.parse(t))}applyStateToWorkflowExperience(t){var s;if(!this.state||!((s=t==null?void 0:t.getWorkflowManager())!=null&&s.getModelContainer()))return;const e=this.state.transactions.find(o=>o.transactionId===t.getWorkflowManager().getTransaction().id);if(!e)return;const A=this.getTransformToApply(e);if(!A)return;const a=this.flipTransform(A,t.getWorkflowManager().getPreviewService()),i=t.getWorkflowManager().getModelContainer();i.position=a.position,i.rotation=a.rotation,i.scale=a.scale}getTransformToApply(t){return t.activeTransform&&t.transforms?t.transforms[t.activeTransform]:t.transform}updateWorkflowExperienceTransform(t,e,A){const a=t.getWorkflowManager().getTransaction().id;this.state?this.state.transactions||(this.state.transactions=[]):this.state={transactions:[]};const i=this.state.transactions.find(s=>s.transactionId===a);i?(i.transforms||(i.transforms={}),i.transforms[e]=A):this.state.transactions.push({transactionId:a,activeTransform:e,transforms:{[e]:A}})}activateWorkflowExperienceTransform(t,e){var r,c;if(!((r=t==null?void 0:t.getWorkflowManager())!=null&&r.getModelContainer())||!this.state)return;const A=t.getWorkflowManager().getTransaction().id,a=this.state.transactions.find(l=>l.transactionId===A),i=(c=a==null?void 0:a.transforms)==null?void 0:c[e];if(!i)return;const s=this.flipTransform(i,t.getWorkflowManager().getPreviewService()),o=t.getWorkflowManager().getModelContainer();o.position=s.position,o.rotation=s.rotation,o.scale=s.scale,a.activeTransform=e}removeStateForTransaction(t){if(!this.state||!this.state.transactions)return;const e=this.state.transactions.findIndex(A=>A.transactionId===t);e!==-1&&this.state.transactions.splice(e,1)}getSerializedState(){if(this.state)return JSON.stringify(this.state)}flipTransform(t,e){return e&&e.flipTransform?e.flipTransform(t.position,{x:t.rotation.x*Math.PI/180,y:t.rotation.y*Math.PI/180,z:t.rotation.z*Math.PI/180},t.scale):{position:t.position,rotation:{x:t.rotation.x*Math.PI/180,y:t.rotation.y*Math.PI/180,z:t.rotation.z*Math.PI/180},scale:t.scale}}}class Mn{constructor(t){this.fullFetched=!1,this.collection=t;const e=this.collection.productCollectionProducts;e&&e.length>0&&(this.fullFetched=!0)}getId(){return this.collection.id}getName(){return this.collection.name}getDescription(){return this.collection.description||""}getImage(){return this.collection.image}getProducts(){if(!this.collection.productCollectionProducts)throw new Error("Failed to find products on collection. Ensure you fetch them first!");return this.collection.productCollectionProducts.map(t=>new Ot(t))}async fetchProducts(t){if(this.fullFetched)return this.collection.productCollectionProducts.map(A=>new Ot(A));const e=await y.getShadowGraphqlClient().query({query:yo,variables:{id:this.getId(),productIds:t},errorPolicy:"all"});return t||(this.fullFetched=!0),this.collection.productCollectionProducts=e.data.productCollections[0].productCollectionProducts||[],this.collection.productCollectionProducts.map(A=>new Ot(A))}async filterProducts(t){var i,s;const e=await y.getShadowGraphqlClient().query({query:Fo,errorPolicy:"all",variables:{id:this.getId(),filters:{link:"And",metafields:t}}});if(!((i=e.data)!=null&&i.productCollections)||((s=e.data)==null?void 0:s.productCollections.length)===0)throw new Error("Failed to filter product collection products.");const A=this.getProducts(),a=e.data.productCollections[0].productCollectionProducts.map(o=>o.product.id);return A.filter(o=>a.includes(o.getId()))}async fetchProductsFeed(t,e,A){var s,o,r,c,l,g;if(this.fullFetched){const d=await(A?this.filterProducts(A):this.fetchProducts());return{total:d.length,items:d.slice(t,t+e)}}const a=await y.getShadowGraphqlClient().query({query:Mo,variables:{id:this.getId(),limit:e,offset:t,filters:A?{link:"And",metafields:A}:void 0},errorPolicy:"all"});return{items:((r=(o=(s=a==null?void 0:a.data)==null?void 0:s.productCollections)==null?void 0:o[0].productCollectionProductsFeed)==null?void 0:r.items.map(d=>new Ot(d)))||[],total:((g=(l=(c=a==null?void 0:a.data)==null?void 0:c.productCollections)==null?void 0:l[0].productCollectionProductsFeed)==null?void 0:g.total)??0}}getTransformCollection(){if(this.collection.transformCollection)return new Sn(this.collection.transformCollection)}getResource(){return this.collection}}class Ot{constructor(t){this.product=t.product,this.productResource=t}getId(){return this.product.id}getName(){return this.product.name}getIntegrationByType(t,e){const a=(this.product.integrationProducts||[]).find(i=>{var c,l,g;const s=(c=i.integration)==null?void 0:c.type,o=((l=i.integration)==null?void 0:l.type)===t,r=e?((g=i.integration)==null?void 0:g.externalIntegrationId)===e:!0;return s&&o&&r});if(!a)throw new Error("Failed to find requested integration type on product. This is generally due to a configuration error");return a}getCurrentIntegration(){const e=(this.product.integrationProducts||[]).find(A=>{var a;return(a=A.integration)==null?void 0:a.isCurrent});if(!e)throw new Error(`Product: ${this.productResource.id} is not linked to this current integration. This is generally due to a configuration error.`);return e}getDefaultWorkflow(){const t=this.product.workflows;if(t===void 0)throw new lt("Called getDefaultWorkflow() before fetching collection products. Use collection.fetchProducts() first to ensure the data is available.");if(t.length===0)throw new lt("Called getDefaultWorkflow() but no workflows on requested product. Ensure at least 1 workflow is assigned to this product.");const e=this.productResource.workflowId;if(e){const A=t.find(a=>a.workflowName===e);if(A)return new Yt(A)}if(t.length===1)return console.warn("Called getDefaultWorkflow() but no default was configured. There is only one workflow available so we will fall back to using this!"),new Yt(t[0]);throw new lt("Called getDefaultWorkflow() but no default workflow is configured for the requested product. Multiple workflows exist so we can't assume!")}getAllWorkflows(){if((this.product.workflows||[]).length===0)throw new lt("No workflows on configured product. Ensure at least 1 workflow is assigned to this product.");return this.product.workflows.sort((e,A)=>(e.index??0)-(A.index??0)).map(e=>new Yt(e))}getIntegrations(){return this.product.integrationProducts||[]}getResource(){return this.product}getBasePrice(t){var a,i,s,o;const e=this.product.basePrice||0;if(!t)return e;if(!t.integrationType&&!t.externalId&&!t.integrationId)throw new Error("You must provide at least one of the following fields on the includeAdditionalProduct object: integrationType, externalId, integrationId");let A;return t.integrationId?A=(a=this.product.integrationProducts)==null?void 0:a.find(r=>{var c;return((c=r.integration)==null?void 0:c.id)===t.integrationId}):t.externalId?A=(i=this.product.integrationProducts)==null?void 0:i.find(r=>{var c;return((c=r.integration)==null?void 0:c.externalIntegrationId)===t.externalId}):A=(s=this.product.integrationProducts)==null?void 0:s.find(r=>{var c;return((c=r.integration)==null?void 0:c.type)===t.integrationType}),(o=A==null?void 0:A.additionalIntegrationProduct)!=null&&o.product?e+(A.additionalIntegrationProduct.product.basePrice||0):e}}class Yt{constructor(t){this.workflow=t}getId(){return this.workflow.workflowName}getName(){return this.workflow.friendlyName}getThumbnail(){return this.workflow.imageUrl}}class Sn{constructor(t){this.collection=t}getId(){return this.collection.id}getName(){return this.collection.name}getTransforms(){return this.collection.transforms.map(t=>new xn(t))}}class xn{constructor(t){this.transform=t}getId(){return this.transform.id}getName(){return this.transform.name}get(){return{position:this.transform.position,rotation:this.transform.rotation,scale:this.transform.scale}}}class ze{constructor(t,e,A,a,i,s){var c,l,g;this.eventListeners=new Map,this.workflowExperiences=[],this.client=t,this.id=e.id,this.name=e.name||"",this.shareActions=e.bundleShareActions,this.workflowViewerLink=e.workflowViewerLink,this.workflowViewerAmendLink=e.workflowViewerAmendLink,this.ownerId=i,this.metadata=new Map(((c=e.metadata)==null?void 0:c.map(d=>[d.key,d.value]))||[]),this.completed=e.completed??!1,this.productCollection=e.productCollection,this.bundleStateManager=new pr(e.bundleStateData);const o=(l=this.productCollection)==null?void 0:l.globalPropertyConfiguration;this.globalConfigurationPropertyId=o==null?void 0:o.id,this.globalPropertyStateManager=new Qr(this.id,this.ownerId,o,this.checkConditionalHandlesChanged.bind(this),s),this.globalPropertyHandleService=new fr(this),this.setPreviewService(A);const r=new Promise((d,B)=>{this.globalPropertyHandleService.getHandles().then(h=>{const C=h.map(u=>{if(u.getType()===et.ColorOption||u.getType()===et.Option)return u.initDefaultVariant()});Promise.all(C).then(d).catch(B)})});this.initializationPromise=Promise.all([this.loadExistingWorkflowExperiences(((g=e.transactions)==null?void 0:g.map(d=>d.id))||[],{...a,bundleOwnerId:i}),this.globalPropertyStateManager.getInitializationPromise(),r]),this.initializationPromise.catch(d=>{console.error(`Bundle initialization failed: ${d}`)})}setBundleOptions(t){this.globalPropertyStateManager.setBundleOptions(t)}getInitializationPromise(){return this.initializationPromise}addEventListener(t,e){this.eventListeners.set(t,[...this.eventListeners.get(t)||[],e])}removeEventListener(t,e){const A=this.eventListeners.get(t)||[],a=A.indexOf(e);a>-1&&A.splice(a,1)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}setNameAndMetadata(t,e){return this.name=t,this.metadata=new Map(e),this.updateBundle()}hasGlobalProperties(){var t;return!!((t=this.productCollection)!=null&&t.globalPropertyConfiguration)}getGlobalPropertyConfiguration(){var t;return(t=this.productCollection)==null?void 0:t.globalPropertyConfiguration}async getGlobalProperties(){return this.globalPropertyHandleService.applyConditionsFromState(await this.globalPropertyHandleService.getHandles(),this.getGlobalPropertyStateManager().getGlobalPropertyState())}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}async getGlobalPropertyTotalSubunits(){return(await this.globalPropertyHandleService.getHandles()).filter(A=>A.getType()===et.Option).map(A=>{var a;return((a=A.getCurrentVariant())==null?void 0:a.getPrice())||0}).reduce((A,a)=>A+a,0)}getTotalSubunits(){return this.workflowExperiences.map(t=>t.getTotalPriceSubunits()).reduce((t,e)=>t+e,0)}getProductCollection(){return this.productCollection?new Mn(this.productCollection):void 0}async addWorkflowExperience(t){t.setBundle(this),await this.appendWorkflowExperience(t),await this.injectExperienceIntoPreviewService(t),await t.getWorkflowManager().getInitializationPromise();const e=await this.getGlobalProperties();for(const A of e)await A.applyGlobalState([t])}async addWorkflowExperiences(t){const e=t.map(o=>o.getWorkflowManager().getTransaction().id),A=e.map(o=>this.workflowExperiences.find(r=>r.getWorkflowManager().getTransaction().id===o));if(A.some(o=>!!o))throw new Error("Unable to add transaction to bundle - Already Exists: "+A.filter(o=>!!o).map(o=>o==null?void 0:o.getWorkflowManager().getTransaction().id).join(", "));const a=k.getMap("transactionOwnerIds")||new Map,i=e.map(o=>a.get(o));await y.getShadowGraphqlClient().mutate({mutation:vo,variables:{id:this.id,transactionIds:e,transactionOwnerIds:i},context:{bundleOwnerId:this.ownerId}}).catch(o=>{console.error(o)}),this.workflowExperiences.push(...t);const s=async()=>{for(const r of t)r.setBundle(this),await this.injectExperienceIntoPreviewService(r);await Promise.all(t.map(r=>r.getWorkflowManager().getInitializationPromise()));const o=await this.getGlobalProperties();for(const r of o)await r.applyGlobalState(t)};await Promise.all([this.updateTransactionOrder(),s()]),this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges())}async appendWorkflowExperience(t,e=!0){const A=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find(o=>o.getWorkflowManager().getTransaction().id===A))throw new Error("Unable to add transaction to bundle - Already Exists!");const s=(k.getMap("transactionOwnerIds")||new Map).get(A);await y.getShadowGraphqlClient().mutate({mutation:Po,variables:{id:this.id,transactionId:A},context:{bundleOwnerId:this.ownerId,transactionOwnerId:s}}),e&&(this.workflowExperiences.push(t),this.workflowExperiences.forEach(o=>o.checkForPriceBreakChanges()))}async removeWorkflowExperience(t){const e=this.workflowExperiences.indexOf(t);await this.removeTransaction(e,this.workflowExperiences[e].getWorkflowManager().getTransaction())}async removeWorkflowExperiences(t){await this.removeTransactions(t.map(e=>e.getWorkflowManager().getTransaction()))}async removeWorkflowExperienceByTransaction(t){const e=this.workflowExperiences.findIndex(A=>A.getWorkflowManager().getTransaction().id===t.id);await this.removeTransaction(e,t)}async removeWorkflowExperiencesByTransactions(t){await this.removeTransactions(t)}async removeTransaction(t,e,A=!0){if(t>-1){const a=this.workflowExperiences.find(i=>i.getWorkflowManager().getTransaction().id===e.id);a.setBundle(void 0),this.previewService&&a.getWorkflowManager().ejectFromPreviewService(),this.bundleStateManager.removeStateForTransaction(e.id),await y.getShadowGraphqlClient().mutate({mutation:ko,variables:{id:this.id,transactionId:e.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([i,s])=>({key:i,value:s})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),A&&(this.workflowExperiences.splice(t,1),this.workflowExperiences.forEach(i=>i.checkForPriceBreakChanges()),a.checkForPriceBreakChanges(),await this.updateTransactionOrder())}else throw new Error("Unable to remove workflow experience from bundle - Not Found! - "+e.id)}async removeTransactions(t){const e=t.map(a=>this.workflowExperiences.findIndex(i=>i.getWorkflowManager().getTransaction().id===a.id));if(e.some(a=>a===-1))throw new Error("Unable to remove workflow experience from bundle - The following aren't included in the bundle: "+t.filter((a,i)=>e[i]===-1).map(a=>a.id).join(", "));const A=t.map(a=>this.workflowExperiences.splice(this.workflowExperiences.findIndex(i=>i.getWorkflowManager().getTransaction().id===a.id),1)[0]);A.forEach(a=>a.setBundle(void 0)),[...this.workflowExperiences,...A].forEach(a=>a.checkForPriceBreakChanges()),this.previewService&&A.forEach(a=>a.getWorkflowManager().ejectFromPreviewService()),t.forEach(a=>this.bundleStateManager.removeStateForTransaction(a.id)),await y.getShadowGraphqlClient().mutate({mutation:No,variables:{id:this.id,transactionIds:t.map(a=>a.id),name:this.name,metadata:Array.from(this.metadata.entries()).map(([a,i])=>({key:a,value:i})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}}),await this.updateTransactionOrder()}async insertWorkflowExperience(t,e){await this.appendWorkflowExperience(t,!1),this.workflowExperiences.splice(e,0,t),await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(t);const A=await this.getGlobalProperties();await Promise.all(A.map(a=>a.applyGlobalState([t])))})()])}async replaceWorkflowExperience(t,e){if(t<0||t>=this.workflowExperiences.length)throw new Error("Unable to replace workflow experience in bundle - Index out of range!");const A=this.workflowExperiences[t];if(A.getWorkflowManager().getTransaction().id===e.getWorkflowManager().getTransaction().id)throw new Error("Unable to replace workflow experience in bundle - Same transaction!");await Promise.all([this.removeTransaction(t,A.getWorkflowManager().getTransaction(),!1),this.appendWorkflowExperience(e,!1)]),this.workflowExperiences[t]=e,await Promise.all([this.updateTransactionOrder(),(async()=>{await this.injectExperienceIntoPreviewService(e);const a=await this.getGlobalProperties();await Promise.all(a.map(i=>i.applyGlobalState([e])))})()])}async swapWorkflowExperiences(t,e){if(t<0||t>=this.workflowExperiences.length||e<0||e>=this.workflowExperiences.length)throw new Error("Unable to swap workflow experiences in bundle - Index out of range!");if(t===e)return;const A=this.workflowExperiences[t];this.workflowExperiences[t]=this.workflowExperiences[e],this.workflowExperiences[e]=A,await this.updateTransactionOrder()}getWorkflowExperiences(){return[...this.workflowExperiences]}async sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t),await this.updateTransactionOrder()}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,e){var i;const A=await y.getShadowGraphqlClient().mutate({mutation:bo,variables:{id:this.id,details:t,type:e||Wt.Owner},context:{bundleOwnerId:this.ownerId}});if(!((i=A.data)!=null&&i.bundleAddStakeholder))throw new Error("Bundle not found!");const a=A.data.bundleAddStakeholder.bundleStakeholders||[];this.storeStakeholderCustomers(a)}async removeStakeholder(t){var A;if(!((A=(await y.getShadowGraphqlClient().mutate({mutation:Ro,variables:{id:this.id,emailAddress:t},context:{bundleOwnerId:this.ownerId}})).data)!=null&&A.bundleRemoveStakeholder))throw new Error("Bundle not found!")}async updateStakeholders(t){var a;const e=await y.getShadowGraphqlClient().mutate({mutation:Ho,variables:{id:this.id,input:t},context:{bundleOwnerId:this.ownerId}});if(!((a=e.data)!=null&&a.bundleUpdateStakeholders))throw new Error("Bundle not found!");const A=e.data.bundleUpdateStakeholders.bundleStakeholders||[];this.storeStakeholderCustomers(A)}async getAllStakeholders(){const t=await y.getShadowGraphqlClient().query({query:ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id},context:{bundleOwnerId:this.ownerId}});if(!t.data.bundles||t.data.bundles.length===0)throw new Error("Bundle not found!");const e=t.data.bundles[0].bundleStakeholders||[];return this.storeStakeholderCustomers(e),e}async getCurrentStakeholder(){const t=await y.getShadowGraphqlClient().query({query:ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id},context:{bundleOwnerId:this.ownerId}});if(!t.data.bundles||t.data.bundles.length===0)throw new Error("Bundle not found!");return t.data.bundles[0].currentBundleStakeholder}storeStakeholderCustomers(t){t.forEach(e=>{e.customer&&this.client.storeCustomer(e.customer)})}async finish(t,e){if(this.completed)return await y.getShadowGraphqlClient().mutate({mutation:Lo,variables:{bundleId:this.id}}),{bundleId:this.id,items:[],bundleOwnerId:this.ownerId};const A=await tr(this.workflowExperiences.map(a=>({workflowManager:a.getWorkflowManager(),workflow:a.getWorkflowManager().getWorkflow(),layouts:a.getWorkflowManager().getLayouts(),getReducerState:()=>a.getCommandContext().getState(),product:a.getWorkflowManager().getProduct(),transaction:a.getWorkflowManager().getTransaction(),workflowSelections:a.getWorkflowManager().getWorkflowSelections(),designName:a.getWorkflowManager().getWorkflow().name,workflowMetadata:a.getWorkflowManager().getWorkflowMetadata()})),t??(()=>{}),e?(a,i)=>{const s=this.workflowExperiences.find(o=>o.getWorkflowManager().getTransaction().id===i);return s?e(s):(console.warn("SpiffCommerce - Bundle create design - Unable to find experience for transaction: "+i),Promise.resolve(void 0))}:void 0);return{bundleId:this.id,items:A,bundleOwnerId:this.ownerId}}async placeOrder(){const t=this.workflowExperiences.map(e=>({transactionId:e.getWorkflowManager().getTransaction().id,amountToOrder:e.getWorkflowManager().getTransaction().quantity||1}));return await this.getClient().placeOrder(t)}getPreviewService(){return this.previewService}async setPreviewService(t){if(this.workflowExperiences&&this.workflowExperiences.length>0&&(this.workflowExperiences.forEach(e=>e.getWorkflowManager().ejectFromPreviewService()),t))for(const e of this.workflowExperiences)await this.injectExperienceIntoPreviewService(e);t&&t.registerModelLoadEventListener&&t.registerModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService&&this.previewService!==t&&this.previewService.unregisterModelLoadEventListener&&this.previewService.unregisterModelLoadEventListener(this.onModelLoadEvent.bind(this)),this.previewService=t}updateWorkflowExperienceTransform(t,e,A){return this.bundleStateManager.updateWorkflowExperienceTransform(t,e,A),this.updateBundle()}activateWorkflowExperienceTransform(t,e){return this.bundleStateManager.activateWorkflowExperienceTransform(t,e),this.updateBundle()}async assignGlobalPropertyConfiguration(t){await y.getShadowGraphqlClient().mutate({mutation:To,variables:{bundleId:this.id,globalPropertyConfigurationId:t},context:{bundleOwnerId:this.ownerId}}),this.globalConfigurationPropertyId=t}async assignProductCollection(t){var A,a;const e=await y.getShadowGraphqlClient().mutate({mutation:Go(((A=this.globalPropertyStateManager.getBundleOptions())==null?void 0:A.eagerFetchProducts)??!1),variables:{id:this.id,productCollectionId:t??""},context:{bundleOwnerId:this.ownerId}});if((a=e.data)!=null&&a.bundleAssignProductCollection.productCollection&&!this.globalConfigurationPropertyId){this.productCollection=e.data.bundleAssignProductCollection.productCollection;const i=e.data.bundleAssignProductCollection.productCollection.globalPropertyConfiguration;this.globalPropertyStateManager.setConfiguration(i),this.globalConfigurationPropertyId=i==null?void 0:i.id}}onModelLoadEvent(t){t.eventType==="unload"||!t.modelContainer||(t.modelContainer.registerMaterialSelectedCallback(()=>this.onModelSelectedEvent(t.modelContainer,!0)),t.modelContainer.registerMaterialDeselectedCallback(()=>this.onModelSelectedEvent(t.modelContainer,!1)))}onModelSelectedEvent(t,e){if(t&&t.metadata&&t.metadata instanceof Map&&t.metadata.has("workflowManager")){const a=t.metadata.get("workflowManager").getTransaction(),i=this.workflowExperiences.find(s=>s.getWorkflowManager().getTransaction().id===a.id);i&&this.fireEvent(e?"workflow-experience-hover-enter":"workflow-experience-hover-exit",{workflowExperience:i})}}async injectExperienceIntoPreviewService(t){if(this.previewService){const e=t.getWorkflowManager().injectIntoPreviewService(this.previewService);try{this.bundleStateManager.applyStateToWorkflowExperience(t)}catch(A){console.error(`Unable to apply state to workflow experience: ${A}`)}await e}}async loadExistingWorkflowExperiences(t,e){if(t.length===0)return;const A=await this.client.getWorkflowExperiences(t.map(a=>({type:"transaction",transactionId:a})),e);if(A.forEach(a=>a.setBundle(this)),A.forEach(a=>a.checkForPriceBreakChanges()),this.workflowExperiences=A,this.previewService)for(const a of A)await this.injectExperienceIntoPreviewService(a)}async updateBundle(){var e;if(!((e=(await y.getShadowGraphqlClient().mutate({mutation:Yo,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map(([A,a])=>({key:A,value:a})),bundleStateData:this.bundleStateManager.getSerializedState()},context:{bundleOwnerId:this.ownerId}})).data)!=null&&e.bundleUpdate))throw new Error("Bundle not found!")}async updateTransactionOrder(){await y.getShadowGraphqlClient().mutate({mutation:Uo,variables:{id:this.id,transactionIds:this.workflowExperiences.map(t=>t.getWorkflowManager().getTransaction().id)},context:{bundleOwnerId:this.ownerId}})}async checkConditionalHandlesChanged(t,e){const A=await this.globalPropertyHandleService.getHandles(),a=this.globalPropertyHandleService.applyConditionsFromState(A,t),i=this.globalPropertyHandleService.applyConditionsFromState(A,e);if((()=>{if(a.length!==i.length)return!0;for(let o=0;o<a.length;o++)if(a[o].getName()!==i[o].getName())return!0;return!1})()){this.fireEvent("conditional-global-properties-changed",{globalProperties:i});const o=i.filter(r=>!a.includes(r));await Promise.all(o.map(r=>r.applyGlobalState()))}}fireEvent(t,e){(this.eventListeners.get(t)||[]).forEach(a=>a({bundle:this,event:t,data:e}))}getShareActions(){return this.shareActions}getWorkflowViewerLink(){return this.workflowViewerLink}getWorkflowViewerAmendLink(){return this.workflowViewerAmendLink}async approve(t){await y.getShadowGraphqlClient().mutate({mutation:Oo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t}})}async reject(t){await y.getShadowGraphqlClient().mutate({mutation:zo,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:this.id,note:t}})}}const Ir=Q.gql`
3265
3265
  mutation processFlowCreate($processFlowId: String!, $inputs: [String]!) {
3266
3266
  processExecutionCreate(processFlowId: $processFlowId, inputs: $inputs) {
3267
3267
  id
@@ -3384,7 +3384,7 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
3384
3384
  }
3385
3385
  }
3386
3386
  }
3387
- `,Pr=async(n,t)=>{var a;const e=await y.getShadowGraphqlClient().query({query:$i(((a=t==null?void 0:t.assets)==null?void 0:a.metadata)||!1),errorPolicy:"all",variables:{ids:n}});if(e.error)throw e.error;if(e.errors)throw e.errors.forEach(i=>console.error(i)),new Error("Unable to read workflows. Consult GraphQL errors.");const A=e.data.workflows;if(A===void 0||A.length!==n.length)throw new Error(`Unable to read workflows: ${e.errors??"Length mismatch in response"}`);return A.forEach(i=>{i.steps.forEach(s=>{var o,r,c;delete s.data.__typename,(o=s.option)!=null&&o.id&&((r=s.option.defaultVariant)!=null&&r.asset&&T.cacheAsset(s.option.defaultVariant.asset),s.option.colorProfile&&T.cacheAsset(s.option.colorProfile),(c=s.option.variants)==null||c.forEach(l=>{l.asset&&T.cacheAsset(l.asset),l.thumbnail&&T.cacheAsset(l.thumbnail),l.material&&T.cacheMaterial(l.material)}),bt.set({id:s.option.id},Promise.resolve(s.option)))}),i.finalizeStepConfig||(i.finalizeStepConfig={}),i.finalizeStepConfig.termsMarkdown=i.partner.termsMarkdown}),A},vr=async(n,t)=>{const A=(await t).find(a=>a.id===n);if(!A)throw new Error(`Workflow not found: ${n}`);return A},GA=async(n,t)=>{const e=n.map(o=>bt.get({id:o,options:t})),A=n.filter((o,r)=>e[r]===void 0);if(A.length===0)return Promise.all(e);const a=Pr(A,t),i=A.map(o=>bt.set({id:o,options:t},vr(o,a))),s=e.filter(o=>o!==void 0);return await Promise.all(s.concat(i))},kr=async(n,t)=>(await GA([n],t))[0],Nr=n=>n.sort((t,e)=>t.index-e.index).map(t=>({id:b(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})),br=(n,t)=>{const e=n.workflowState,A=e?JSON.parse(e):void 0;return A?Object.values(A.layouts).map(a=>a.layout):Nr(t.panels)};class Rr{constructor(t){this.activeIntegration=void 0,this.updateTransactionState=async e=>{try{return y.getShadowGraphqlClient().mutate({...e,mutation:Ti})}catch(A){throw console.error(A),new lt("Critical - Unable to synchronize workflow state with server.")}},this.options=t,this.options.applicationKey&&ni(this.options.applicationKey),console.debug("------------------------"),console.debug("Spiff Commerce Core SDK"),console.debug("Version: 26.7.3"),console.debug(`Application Key Provided: ${!!this.options.applicationKey}`),console.debug("------------------------")}configure(t){dt.setHubUrl(t.hubUrl),dt.setServerUrl(t.serverUrl),dt.setServicesApiUrl(t.servicesApiUrl),this.marketplaceThemeInstallId=t.marketplaceThemeInstallId,this.marketplaceThemeInstallConfigurationId=t.marketplaceThemeInstallConfigurationId,t.bearerAuthenticationToken&&pa(t.bearerAuthenticationToken),this.options.applicationKey&&this.getIntegration()}getAssetManager(){return T}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!ii())throw new Error("Application key required to use Flow Service.");return new Yn}async getIntegration(){if(this.activeIntegration)return this.activeIntegration;if(!this.options.applicationKey)throw new Error("Cannot get current Integration without specifying an Application Key.");return this.activeIntegration=kn(this.options.applicationKey),this.activeIntegration}async canUseAddon(t){var e;try{return((e=(await this.getIntegration()).partner.activeAddons)==null?void 0:e.includes(t))??!1}catch(A){return console.error(A),!1}}async authenticateBundleFromLocalStorage(t){var a,i;const e=k.getMap("bundleOwnerIds");if(e!=null&&e.has(t))return Promise.resolve({success:!0,stakeholderType:Wt.Owner});const A=k.getMap("bundlePartnerIds")||new Map;if(A.has(t)){const s=A.get(t),r=(k.getMap("partnerCustomerIds")||new Map).get(s);if(r&&await this.authenticateCustomerId(r)){const l=(i=(a=this.customer)==null?void 0:a.bundleStakeholders)==null?void 0:i.find(g=>{var d;return((d=g.bundle)==null?void 0:d.id)===t});if(l)return Promise.resolve({success:!0,stakeholderType:l.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){var l,g,d,B,h,C;const e=y.getShadowGraphqlClient(),A=await e.query({query:_i,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${t}`);const a=A.data.transactions[0];if(!((g=(l=a.product)==null?void 0:l.partner)==null?void 0:g.id))throw new Error(`Unable to read transaction: ${t}`);if(a.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const s=k.getMap("transactionOwnerIds");if(s!=null&&s.has(t))return Promise.resolve({success:!0,stakeholderType:Wt.Owner});const o=k.getMap("transactionCustomerIds");if(o!=null&&o.has(t)){const u=o.get(t);if(u&&await this.authenticateCustomerId(u)){const E=((B=(d=this.customer)==null?void 0:d.bundleStakeholders)==null?void 0:B.find(m=>{var f,p;return(p=(f=m.bundle)==null?void 0:f.transactions)==null?void 0:p.some(I=>I.id===t)}))||((C=(h=this.customer)==null?void 0:h.stakeholders)==null?void 0:C.find(m=>{var f;return((f=m.transaction)==null?void 0:f.id)===t}));if(E)return Promise.resolve({success:!0,stakeholderType:E.type})}}const c=(await e.query({query:ts,errorPolicy:"all",variables:{id:a.workflowId}})).data.workflow;if(!c)throw new Error(`Unable to read workflow: ${a.workflowId}`);return Promise.resolve({success:!1,theme:c.overrideTheme,customLogoLink:a.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=k.getMap("transactionCustomerIds");e!=null&&e.has(t)&&(e.delete(t),k.setMap("transactionCustomerIds",e))}async customerHasBundleTemplates(t){const a=(await y.getShadowGraphqlClient().query({query:aa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;return a.id?a.hasBundleTemplates??!1:!1}getStakeholderTypeForTransaction(t){var A,a;const e=(a=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:a.find(i=>{var s;return((s=i.transaction)==null?void 0:s.id)===t});if(e)return e.type}async getOrCreateCustomer(t){var s;this.customer=void 0;const e=y.getShadowGraphqlClient(),a=(await e.query({query:aa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!a.id){const r=(s=(await e.mutate({mutation:Fr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data)==null?void 0:s.customerCreate;if(!r)throw new Error("Unable to create customer.");return this.storeCustomer(r),this.customer=r,{customer:r,isAuthenticated:!1}}this.storeCustomer(a);const i=await this.authenticateCustomerId(a.id);return{customer:this.customer||a,isAuthenticated:i}}getCustomer(){return this.customer}async authenticateCustomerId(t){var o;const e=y.getShadowGraphqlClient(),A=k.getMap("customerTokens");if(!(A!=null&&A.has(t)))return!1;const a=A.get(t);if(!a)return!1;const s=(o=(await e.mutate({mutation:Mr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:a}})).data)==null?void 0:o.customerAuthenticate;return s?(this.storeCustomer(s),VA(a),this.customer=s,!0):!1}async generateVerificationCode(t){await y.getShadowGraphqlClient().mutate({mutation:Sr,variables:{emailAddress:t}})}async verifyCode(t,e){var i,s;const a=(i=(await y.getShadowGraphqlClient().mutate({mutation:xr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data)==null?void 0:i.customerVerifyCode;if(a!=null&&a.loginToken){if(!((s=a.partner)!=null&&s.id))throw new Error(`Unable to find customer: ${t}`);const o=k.getMap("customerTokens")||new Map;return o.set(a.id,a.loginToken),k.setMap("customerTokens",o),this.storeCustomer(a),VA(a.loginToken),this.customer={...a,loginToken:void 0},!0}return!1}async getCustomerMetafields(){var e;if(!((e=this.customer)!=null&&e.id))throw new Error("Customer must be logged in before calling this function.");return(await y.getShadowGraphqlClient().query({query:Yr,variables:{id:this.customer.id}})).data.metafields}async getNewBundle(t,e,A){var c,l,g,d,B;const i=(g=(await y.getShadowGraphqlClient().mutate({mutation:So(((l=(c=A==null?void 0:A.graphql)==null?void 0:c.productCollection)==null?void 0:l.eagerFetchProducts)||!1),variables:{collectionId:t,initialMetadata:e?Object.entries(e).map((h,C)=>({key:h[0],value:h[1]})):void 0,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},fetchPolicy:"no-cache"})).data)==null?void 0:g.bundleCreate;if(!(i!=null&&i.id))throw new Error("Unable to create bundle");const s=k.getMap("bundlePartnerIds")||new Map;s.set(i.id,i.partner.id),k.setMap("bundlePartnerIds",s);const o=k.getMap("bundleOwnerIds")||new Map;o.set(i.id,i.bundleOwnerId),k.setMap("bundleOwnerIds",o);const r=new ze(this,i,void 0,void 0,i.bundleOwnerId,{eagerFetchProducts:(B=(d=A==null?void 0:A.graphql)==null?void 0:d.productCollection)==null?void 0:B.eagerFetchProducts});return await r.getInitializationPromise(),r}async getExistingBundle(t,e,A,a){var u,w,E,m,f,p,I,D,F,x,Y;const i=k.getMap("bundleOwnerIds"),s=i==null?void 0:i.get(t),r=((u=Object.entries(localStorage).find(([P,v])=>P.startsWith("CognitoIdentityServiceProvider")&&P.endsWith("idToken")))==null?void 0:u[0])||"",c=localStorage.getItem(r),l={};c&&!fe(c)&&(l.Authorization=`Bearer ${c}`);const g={bundleOwnerId:s,...l,...(w=a==null?void 0:a.graphql)==null?void 0:w.additionalHeaders},d=await y.getShadowGraphqlClient().query({query:Io(((m=(E=a==null?void 0:a.graphql)==null?void 0:E.productCollection)==null?void 0:m.eagerFetchProducts)||!1),variables:{id:t},fetchPolicy:"no-cache",context:{headers:g}});if(!((f=d.data)!=null&&f.bundles)||((p=d.data)==null?void 0:p.bundles.length)===0||!((I=d.data)!=null&&I.bundles[0]))throw new Error(`Unable to find bundle: ${t}`);const B=(D=d.data)==null?void 0:D.bundles[0],h=k.getMap("bundlePartnerIds")||new Map;h.set(B.id,B.partner.id),k.setMap("bundlePartnerIds",h);const C=new ze(this,B,e,A,s,{additionalHeaders:(F=a==null?void 0:a.graphql)==null?void 0:F.additionalHeaders,eagerFetchProducts:(Y=(x=a==null?void 0:a.graphql)==null?void 0:x.productCollection)==null?void 0:Y.eagerFetchProducts,existingGlobalPropertyState:d.data.globalPropertyState});return await C.getInitializationPromise(),C}async duplicateBundle(t,e,A,a){var u,w,E,m,f,p,I,D;const i=(u=k.getMap("bundleOwnerIds"))==null?void 0:u.get(t),o=((w=Object.entries(localStorage).find(([F,x])=>F.startsWith("CognitoIdentityServiceProvider")&&F.endsWith("idToken")))==null?void 0:w[0])||"",r=localStorage.getItem(o),c={};r&&!fe(r)&&(c.Authorization=`Bearer ${r}`);const l={bundleOwnerId:i,...c,...(E=a==null?void 0:a.graphql)==null?void 0:E.additionalHeaders},d=(p=(await y.getShadowGraphqlClient().mutate({mutation:xo(((f=(m=a==null?void 0:a.graphql)==null?void 0:m.productCollection)==null?void 0:f.eagerFetchProducts)||!1),variables:{id:t,template:e,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId,duplicateTransactions:A},context:{headers:l},fetchPolicy:"no-cache"})).data)==null?void 0:p.bundleDuplicate;if(!(d!=null&&d.id))throw new Error("Unable to duplicate bundle");const B=k.getMap("bundlePartnerIds")||new Map;B.set(d.id,d.partner.id),k.setMap("bundlePartnerIds",B);const h=k.getMap("bundleOwnerIds")||new Map;h.set(d.id,d.bundleOwnerId),k.setMap("bundleOwnerIds",h);const C=new ze(this,d,void 0,void 0,d.bundleOwnerId,{eagerFetchProducts:(D=(I=a==null?void 0:a.graphql)==null?void 0:I.productCollection)==null?void 0:D.eagerFetchProducts});return await C.getInitializationPromise(),C}async getBundlesForCustomer(t){var i;if(!((i=this.customer)!=null&&i.id))throw new Error("Customer not authenticated.");const{includeMetadata:e,...A}=t;return(await y.getShadowGraphqlClient().query({query:Jo(e??!1),variables:{...A,id:this.customer.id},fetchPolicy:"no-cache"})).data.customerBundlesFeed}async getBundleStakeholders(){var i;if(!this.customer)throw new Error("Customer not authenticated.");const t=await y.getShadowGraphqlClient().query({query:Do,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((i=t.data)!=null&&i.customers)||t.data.customers.length===0)throw new Error("Unable to find customer.");const A=t.data.customers[0].bundleStakeholders||[],a=k.getMap("bundlePartnerIds")||new Map;return A.forEach(s=>{var o,r;(o=s.bundle)!=null&&o.id&&((r=s.bundle.partner)!=null&&r.id)&&a.set(s.bundle.id,s.bundle.partner.id)}),k.setMap("bundlePartnerIds",a),A}async getWorkflowExperience(t,e){if(!t)throw new Error("getWorkflowExperience has been called without an options object! This is not supported.");const A=await this.getWorkflowExperiences([t],t.graphql),a=A[0];return e&&await a.getWorkflowManager().injectIntoPreviewService(e(a.getWorkflowManager().getWorkflow())),A[0]}async getWorkflowExperiences(t,e){if(t.length===0)throw new lt("No options provided!");const A=y.getShadowGraphqlClient(),a=async p=>{var x,Y,P;if(p.length===0)return[];const I=p.map(v=>v.option.transactionId),D=await A.query({query:Gi,variables:{ids:I},errorPolicy:"all",fetchPolicy:"no-cache"}),F=D.data.transactions;if(F.length!==p.length){const v=((Y=(x=D.errors)==null?void 0:x[0])==null?void 0:Y.message)||"Unknown error";throw new lt(`Not all transactions were found: ${v}`)}return!this.activeIntegration&&((P=F[0].integrationProduct)!=null&&P.integration)&&(this.activeIntegration=Promise.resolve(F[0].integrationProduct.integration)),F.map((v,H)=>{var V;return{transaction:v,workflowId:v.workflowId,readOnly:((V=p.find(j=>j.option.transactionId===v.id))==null?void 0:V.option.readOnly)??!1,index:p[H].index}})},i=async p=>{var F,x,Y;if(p.length===0)return[];const I=await A.mutate({mutation:Ui,variables:{inputs:p.map(P=>({integrationProductId:P.option.type==="integration"?P.option.integrationProductId:void 0,externalIntegrationId:P.option.type==="external"?P.option.externalIntegrationId:void 0,externalProductId:P.option.type==="external"?P.option.externalProductId:void 0,workflowId:P.option.workflowId,designName:P.option.designName,claim:!0})),marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},errorPolicy:"all",fetchPolicy:"no-cache"}),D=(F=I.data)==null?void 0:F.transactionCreateMany;if(!D||D.length===0){const P=((Y=(x=I.errors)==null?void 0:x[0])==null?void 0:Y.message)||"Unknown error";throw new lt(`Failed to create transactions: ${P}`)}return D.map((P,v)=>({transaction:P,workflowId:P.workflowId,readOnly:!1,index:p[v].index}))},s=t.map((p,I)=>({option:p,index:I})),o=s.filter(p=>p.option.type==="transaction"),r=s.filter(p=>p.option.type==="integration"||p.option.type==="external"),c=JA(o,10),l=JA(r,10),g=(await Promise.all([...c.map(a),...l.map(i)])).flat(),d=[...new Set(g.map(p=>p.workflowId))],B=await GA(d,e),h=new Map(B.map(p=>[p.id,p])),C=k.getMap("transactionOwnerIds")||new Map,u=g.map(async p=>{var V;const{transaction:I,workflowId:D,readOnly:F,index:x}=p,Y=h.get(D),P=t[x];!C.get(I.id)&&I.transactionOwnerId&&C.set(I.id,I.transactionOwnerId);const v=C.get(I.id)||void 0,H={product:I.product,transaction:I,layouts:[],singleVariantsRenderable:(V=P==null?void 0:P.workflowConfiguration)==null?void 0:V.singleVariantsRenderable,stateMutationFunc:F?async()=>{throw new L("State mutation is forbidden in read only mode!")}:async j=>this.updateTransactionState({...j,context:{transactionOwnerId:v,bundleOwnerId:e==null?void 0:e.bundleOwnerId}}),readOnly:F,workflow:Y,isReloadedTransaction:P.type==="transaction"};if(P.type==="transaction"&&I.workflowState){const j=JSON.parse(I.workflowState);H.layouts=Object.values(j.layouts||{}).map(At=>At.layout),await AA(j),H.reloadedState=j}else if(!F&&P.workflowState){const j=JSON.parse(P.workflowState);H.layouts=Object.values(j.layouts||{}).map(At=>At.layout),await AA(j),H.reloadedState=j}else H.layouts=br(H.transaction,H.workflow);return H.renderableContextService=new Br(H.layouts),H.delayWorkflowStateSync=!0,{experienceOptions:H,index:x,options:P}}),w=await Promise.all(u);k.setMap("transactionOwnerIds",C);const m=w.sort((p,I)=>p.index-I.index).map(async p=>{const{experienceOptions:I,options:D}=p,F=new In(this,I);return await F.getWorkflowManager().getInitializationPromise(),D.type!=="transaction"&&this.customer&&await F.attachCustomerDetails({email:this.customer.emailAddress}),F}),f=await Promise.all(m);return f.forEach(p=>p.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),f}storeCustomer(t){const e=k.getMap("partnerCustomerIds")||new Map;e.set(t.partner.id,t.id),k.setMap("partnerCustomerIds",e)}async getIntegrationProductById(t){var i,s;const a=(i=(await y.getShadowGraphqlClient().query({query:zi,variables:{ids:[t]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProducts;if(!a||a.length===0||!((s=a[0])!=null&&s.id))throw new Error("Integration product not found.");return new rA(a[0])}async getIntegrationProductFromExternalIds(t,e){var s;const i=(s=(await y.getShadowGraphqlClient().query({query:ji,variables:{externalProductId:e,externalIntegrationId:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:s.integrationProductFromExternalIds;if(!(i!=null&&i.id))throw new Error("Integration product not found.");return new rA(i)}async getIntegrationProduct(t){return t.type==="integration"?this.getIntegrationProductById(t.integrationProductId):this.getIntegrationProductFromExternalIds(t.externalIntegrationId,t.externalProductId)}async getShareActionsForTransaction(t){const A=(k.getMap("transactionOwnerIds")||new Map).get(t)||void 0,a=await y.getShadowGraphqlClient().query({query:Oi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t},context:{transactionOwnerId:A}});if(!a.data.transactions||a.data.transactions.length!==1)throw new Error(`Failed to fetch share actions for transaction: ${t}`);return a.data.transactions[0].transactionShareActions}async placeOrder(t){const e=await y.getShadowGraphqlClient().mutate({mutation:is,variables:{orderItems:t}});if(e.errors)throw new Error(e.errors[0].message);if(!e.data)throw new Error("Failed to create order: No order data in response.");return{id:e.data.orderCreate.id,internalId:e.data.orderCreate.internalId}}}const kn=async n=>(await y.getShadowGraphqlClient().query({query:As,errorPolicy:"all",fetchPolicy:"no-cache",context:{headers:{"x-application-key":n}}})).data.currentIntegration,Hr=async n=>{const e=await y.getShadowGraphqlClient().query({query:Li,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:n}});if(e.data.transactions.length!==0)return e.data.transactions[0]},Ur=async(n,t)=>{var A;return(A=(await y.getShadowGraphqlClient().query({query:es,errorPolicy:"all",variables:{themeConfigurationId:n,themeInstallId:t}})).data)==null?void 0:A.marketplaceThemeInstallConfiguration},Gr=async n=>{var e,A,a;return(a=(A=(e=(await y.getShadowGraphqlClient().query({query:ns,errorPolicy:"all",variables:{id:n}})).data)==null?void 0:e.bundles)==null?void 0:A[0])==null?void 0:a.marketplaceThemeInstallConfiguration},Tr=async n=>{var e,A,a;return(a=(A=(e=(await y.getShadowGraphqlClient().query({query:as,errorPolicy:"all",variables:{id:n}})).data)==null?void 0:e.transactions)==null?void 0:A[0])==null?void 0:a.marketplaceThemeInstallConfiguration};function Nn(n,t,e,A){const a=e.width*n.zoom,i=e.height*n.zoom;if(A){const o=n,r=Math.max(t.width/e.width,t.height/e.height);o.zoom=Math.max(r,n.zoom);const c=e.width*o.zoom,l=e.height*o.zoom;return o.x=Be(n.x,t.width-c,0),o.y=Be(n.y,t.height-l,0),o}const s=n;return s.x=Be(s.x,-a,t.width),s.y=Be(s.y,-i,t.height),s}function Be(n,t,e){return Math.min(Math.max(n,t),e)}class bn{constructor(t,e){this.minZoomScale=[.03],this.maxZoomScale=[20],this._debouncedUpdateFrameOffsets=oa(this.updateFrameOffsets,200),this.targetElements=[],this.onFrameDataChangeListeners=[],this.onZoomChangeListeners=[],this.forceImageCover=t,this.initialZoom=e,this.thresholdSettings={useThreshold:!1,invertThreshold:!1,threshold:128,thresholdSaturation:.5}}connectWorkflowManager(t,e){e&&t.addStepSpecificStorageCallback(async A=>{if(A){const a=A;if(a.currentFrameSources){let i=!1;for(let s=0;s<a.currentFrameSources.length;s++){const o=a.currentFrameSources[s],r=await oe(o),c=this.frameData?this.frameData[s]:void 0;sa(r,c)||(this.frameData||(this.frameData=new Array(a.currentFrameSources.length)),this.frameData[s]=r,i=!0)}i&&(this.onFrameDataChangeListeners.forEach(s=>s(this.frameData)),this.frameData&&this.imageData&&(this.recalculateOffsets(this.imageData),this.updateOffsets(this.offsets),this.recalculateZoomLimits(this.imageData,this.frameData)))}}},e),this.workflowManager=t,this.stepName=e}setTargetElements(t){this.targetElements=t}getFrameData(){return this.frameData}setFrameData(t){if(!t){this.frameData=void 0;return}t.forEach((e,A)=>{const a=Mt.get(e);a&&(this.frameData||(this.frameData=new Array(t.length)),this.frameData[A]=a)})}getImageData(){return this.imageData}getImageSrc(){if(this.imageData){if(this.imageData.svg){const t=Ya(this.imageData.svg,this.imageData.colors||{},!1);return gA(t)}return this.imageData.src}}getOffsets(){return this.offsets}setOffsets(t){this.offsets=t}setZoom(t,e,A,a){if(this.imageData&&this.offsets&&this.frameData){(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length));const i=this.frameData.map((s,o)=>{const r=(e[o]-this.offsets[o].x)/this.offsets[o].zoom,c=(A[o]-this.offsets[o].y)/this.offsets[o].zoom,l=e[o]-r*t[o],g=A[o]-c*t[o];return{x:l,y:g,zoom:this.imageData.width*t[o]/this.imageData.width}});this.updateOffsets(i,a),this.onZoomChangeListeners.forEach(s=>s(t))}}setPatternData(t,e=!0){this.imageData=t,t&&this.frameData&&((e||!this.offsets)&&this.recalculateOffsets(t),this.updateOffsets(this.offsets,void 0,!0)),this.imageData&&this.frameData&&this.recalculateZoomLimits(this.imageData,this.frameData)}updateOffsets(t,e,A){const a=this.imageData;if(!a||!this.frameData)return;if(this.frameData.length!==t.length)throw new L("Frame data and offsets are not the same length. This is a bug. Please report it.");if(!this.offsets.some((s,o)=>!(t[o].x===s.x&&t[o].y===s.y&&t[o].zoom===s.zoom))&&!A){e&&e();return}(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((s,o)=>{this.offsets[o]=Nn(t[o],s,this.imageData,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,a,this.frameData,this.thresholdSettings,e)}getThresholdSettings(){return this.thresholdSettings}setThresholdSettings(t){this.thresholdSettings=t,this.imageData&&this.frameData&&this._debouncedUpdateFrameOffsets(this.offsets,this.imageData,this.frameData,t)}onFrameDataChanged(t){t(this.frameData),this.onFrameDataChangeListeners.push(t)}onZoom(t){this.onZoomChangeListeners.push(t)}updateFrameOffsets(t,e,A,a,i){if(!A||A.length===0||A.some(o=>!o))throw new L("Frame data not set. This is a bug");if(!this.workflowManager)throw new L("No workflow manager set, cannot update offsets.");const s=this.workflowManager.getCommandDispatcher();this.targetElements.forEach((o,r)=>{s(new G([new Ls(o,e,t[r]),new Os(o,a.useThreshold,a.invertThreshold,a.threshold,a.thresholdSaturation)]))}),this.stepName&&this.workflowManager.updateStorage(this.stepName,{frameOffsetsList:t}),i&&i()}recalculateZoomLimits(t,e){(this.minZoomScale.length!==e.length||this.maxZoomScale.length!==e.length)&&(this.minZoomScale=new Array(e.length),this.maxZoomScale=new Array(e.length)),e.forEach((A,a)=>{const i=Math.max(A.width/t.width,A.height/t.height);this.forceImageCover?(this.minZoomScale[a]=i,this.maxZoomScale[a]=i*2.5):(this.minZoomScale[a]=i/10,this.maxZoomScale[a]=i*2.5)})}recalculateOffsets(t){this.frameData&&((!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((e,A)=>{this.offsets[A]=pA(t,e,this.initialZoom&&!this.forceImageCover?{scale:this.initialZoom}:void 0,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,t,this.frameData,this.thresholdSettings))}}class Jr{approveTransaction(t){throw new Error("Method not implemented.")}rejectTransaction(t){throw new Error("Method not implemented.")}getClient(){return this.client??{}}getWorkflowExperience(){return{}}setClient(t){this.client=t}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(t){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}getStepSelections(){return{}}setCurrentAdjustingStepId(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(t){}async updateTransactionShareActions(){}addValidationCallback(t){}setStepError(t,e,A){}getStepErrors(t){}getValidationErrors(){return{steps:new Map}}async updateTransactionStakeholders(){}getStepTags(t){return[]}}var Rn=(n=>(n.SelectFrame="SelectFrame",n.SelectImage="SelectImage",n.Position="Position",n))(Rn||{});class Hn extends et{constructor(t,e,A){super(t,e,A);const a=e.data;this.frameService=new bn(a.forceImageCover,a.initialZoomLevel),this.frameService.connectWorkflowManager(t,e.stepName)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return rt.selectVariant(this.step,t.getResource(),e,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged(e=>{e&&t(e)})}async selectImage(t,e=!0,A=!0){var a;if(await rt.selectImage(this.step,t,this.manager,A),e){const i=((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.framePatternData)||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...i,originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon(Qe.BackgroundRemover)}async canRemoveBackground(){var t,e,A,a;return await this.canUseBackgroundRemover()&&this.hasOriginalImageSelection()&&!!((e=(t=this.frameService)==null?void 0:t.getImageData())!=null&&e.src)&&!((a=(A=this.frameService)==null?void 0:A.getImageData())!=null&&a.svg)}async removeBackgroundFromImageSelection(t=!0){var i;if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const e=await this.getOriginalImageSelection();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const A=await T.removeBackgroundFromAsset(e);t&&await rt.selectImage(this.step,A,this.manager,!1);const a=((i=this.manager.getStepStorage(this.step.stepName))==null?void 0:i.framePatternData)||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...a,backgroundRemovedAssetKey:A.key,useOriginalAsset:!t}}),A}changeColors(t){rt.changeColors(this.step,this.manager,t)}getImageData(){if(this.frameService)return this.frameService.getImageData()}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?rt.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}async getOriginalImageColors(){const t=this.getImageData();return t!=null&&t.svg?(await st(t.svg)).colors:void 0}getMaxAllowedColors(){return this.step.data.maxColors}getUniqueColorCount(){return rt.getUniqueColorCount(this.step,this.manager)}getCurrentFrameStep(t,e,A,a){return a&&a.length>1&&t===void 0?"SelectFrame":e||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}getWhitelistedExtensions(){return[...this.step.data.whitelistedExtensions,...this.step.data.whitelistedExtensions.includes(".jpg")?[".jpeg"]:[]]}async getOriginalImageSelection(){var e,A;const t=(A=(e=this.manager.getStepStorage(this.step.stepName))==null?void 0:e.framePatternData)==null?void 0:A.originalAssetKey;if(t)return T.getLocalOrFromServer(t)}async getBackgroundRemovedImageSelection(){var e,A;const t=(A=(e=this.manager.getStepStorage(this.step.stepName))==null?void 0:e.framePatternData)==null?void 0:A.backgroundRemovedAssetKey;if(t)return T.getLocalOrFromServer(t)}hasOriginalImageSelection(){var t,e;return!!((e=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)!=null&&e.originalAssetKey)}hasBackgroundRemovedImageSelection(){var t,e;return!!((e=(t=this.getFrameStepStorage())==null?void 0:t.framePatternData)!=null&&e.backgroundRemovedAssetKey)}getUseOriginalImageSelection(){var t,e;return((e=(t=this.getFrameStepStorage())==null?void 0:t.framePatternData)==null?void 0:e.useOriginalAsset)??!1}async setUseOriginalImageSelection(t){var a;const e=((a=this.getFrameStepStorage())==null?void 0:a.framePatternData)||{};if(e.useOriginalAsset===t)return;const A=await this.getOriginalImageSelection();if(!A)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(t)await this.selectImage(A,!1,!1);else{const i=await this.getBackgroundRemovedImageSelection();if(!i)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(i,!1,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...e,useOriginalAsset:t}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}const Lr=Q.gql`
3387
+ `,Pr=async(n,t)=>{var a;const e=await y.getShadowGraphqlClient().query({query:$i(((a=t==null?void 0:t.assets)==null?void 0:a.metadata)||!1),errorPolicy:"all",variables:{ids:n}});if(e.error)throw e.error;if(e.errors)throw e.errors.forEach(i=>console.error(i)),new Error("Unable to read workflows. Consult GraphQL errors.");const A=e.data.workflows;if(A===void 0||A.length!==n.length)throw new Error(`Unable to read workflows: ${e.errors??"Length mismatch in response"}`);return A.forEach(i=>{i.steps.forEach(s=>{var o,r,c;delete s.data.__typename,(o=s.option)!=null&&o.id&&((r=s.option.defaultVariant)!=null&&r.asset&&T.cacheAsset(s.option.defaultVariant.asset),s.option.colorProfile&&T.cacheAsset(s.option.colorProfile),(c=s.option.variants)==null||c.forEach(l=>{l.asset&&T.cacheAsset(l.asset),l.thumbnail&&T.cacheAsset(l.thumbnail),l.material&&T.cacheMaterial(l.material)}),bt.set({id:s.option.id},Promise.resolve(s.option)))}),i.finalizeStepConfig||(i.finalizeStepConfig={}),i.finalizeStepConfig.termsMarkdown=i.partner.termsMarkdown}),A},vr=async(n,t)=>{const A=(await t).find(a=>a.id===n);if(!A)throw new Error(`Workflow not found: ${n}`);return A},GA=async(n,t)=>{const e=n.map(o=>bt.get({id:o,options:t})),A=n.filter((o,r)=>e[r]===void 0);if(A.length===0)return Promise.all(e);const a=Pr(A,t),i=A.map(o=>bt.set({id:o,options:t},vr(o,a))),s=e.filter(o=>o!==void 0);return await Promise.all(s.concat(i))},kr=async(n,t)=>(await GA([n],t))[0],Nr=n=>n.sort((t,e)=>t.index-e.index).map(t=>({id:b(),panelId:t.name,name:t.name,index:t.index,createdAt:new Date,updatedAt:new Date,transparentBackground:t.transparentBackground,height:t.height,width:t.width,previewRegion:t.previewRegion,useEditableArea:t.useEditableArea,editableArea:t.editableArea})),br=(n,t)=>{const e=n.workflowState,A=e?JSON.parse(e):void 0;return A?Object.values(A.layouts).map(a=>a.layout):Nr(t.panels)};class Rr{constructor(t){this.activeIntegration=void 0,this.updateTransactionState=async e=>{try{return y.getShadowGraphqlClient().mutate({...e,mutation:Ti})}catch(A){throw console.error(A),new lt("Critical - Unable to synchronize workflow state with server.")}},this.options=t,this.options.applicationKey&&ni(this.options.applicationKey),console.debug("------------------------"),console.debug("Spiff Commerce Core SDK"),console.debug("Version: 26.7.4"),console.debug(`Application Key Provided: ${!!this.options.applicationKey}`),console.debug("------------------------")}configure(t){dt.setHubUrl(t.hubUrl),dt.setServerUrl(t.serverUrl),dt.setServicesApiUrl(t.servicesApiUrl),this.marketplaceThemeInstallId=t.marketplaceThemeInstallId,this.marketplaceThemeInstallConfigurationId=t.marketplaceThemeInstallConfigurationId,t.bearerAuthenticationToken&&pa(t.bearerAuthenticationToken),this.options.applicationKey&&this.getIntegration()}getAssetManager(){return T}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!ii())throw new Error("Application key required to use Flow Service.");return new Yn}async getIntegration(){if(this.activeIntegration)return this.activeIntegration;if(!this.options.applicationKey)throw new Error("Cannot get current Integration without specifying an Application Key.");return this.activeIntegration=kn(this.options.applicationKey),this.activeIntegration}async canUseAddon(t){var e;try{return((e=(await this.getIntegration()).partner.activeAddons)==null?void 0:e.includes(t))??!1}catch(A){return console.error(A),!1}}async authenticateBundleFromLocalStorage(t){var a,i;const e=k.getMap("bundleOwnerIds");if(e!=null&&e.has(t))return Promise.resolve({success:!0,stakeholderType:Wt.Owner});const A=k.getMap("bundlePartnerIds")||new Map;if(A.has(t)){const s=A.get(t),r=(k.getMap("partnerCustomerIds")||new Map).get(s);if(r&&await this.authenticateCustomerId(r)){const l=(i=(a=this.customer)==null?void 0:a.bundleStakeholders)==null?void 0:i.find(g=>{var d;return((d=g.bundle)==null?void 0:d.id)===t});if(l)return Promise.resolve({success:!0,stakeholderType:l.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(t){var l,g,d,B,h,C;const e=y.getShadowGraphqlClient(),A=await e.query({query:_i,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${t}`);const a=A.data.transactions[0];if(!((g=(l=a.product)==null?void 0:l.partner)==null?void 0:g.id))throw new Error(`Unable to read transaction: ${t}`);if(a.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const s=k.getMap("transactionOwnerIds");if(s!=null&&s.has(t))return Promise.resolve({success:!0,stakeholderType:Wt.Owner});const o=k.getMap("transactionCustomerIds");if(o!=null&&o.has(t)){const u=o.get(t);if(u&&await this.authenticateCustomerId(u)){const E=((B=(d=this.customer)==null?void 0:d.bundleStakeholders)==null?void 0:B.find(m=>{var f,p;return(p=(f=m.bundle)==null?void 0:f.transactions)==null?void 0:p.some(I=>I.id===t)}))||((C=(h=this.customer)==null?void 0:h.stakeholders)==null?void 0:C.find(m=>{var f;return((f=m.transaction)==null?void 0:f.id)===t}));if(E)return Promise.resolve({success:!0,stakeholderType:E.type})}}const c=(await e.query({query:ts,errorPolicy:"all",variables:{id:a.workflowId}})).data.workflow;if(!c)throw new Error(`Unable to read workflow: ${a.workflowId}`);return Promise.resolve({success:!1,theme:c.overrideTheme,customLogoLink:a.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(t){const e=k.getMap("transactionCustomerIds");e!=null&&e.has(t)&&(e.delete(t),k.setMap("transactionCustomerIds",e))}async customerHasBundleTemplates(t){const a=(await y.getShadowGraphqlClient().query({query:aa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;return a.id?a.hasBundleTemplates??!1:!1}getStakeholderTypeForTransaction(t){var A,a;const e=(a=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:a.find(i=>{var s;return((s=i.transaction)==null?void 0:s.id)===t});if(e)return e.type}async getOrCreateCustomer(t){var s;this.customer=void 0;const e=y.getShadowGraphqlClient(),a=(await e.query({query:aa,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t}})).data.customer;if(!a.id){const r=(s=(await e.mutate({mutation:Fr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:t}}})).data)==null?void 0:s.customerCreate;if(!r)throw new Error("Unable to create customer.");return this.storeCustomer(r),this.customer=r,{customer:r,isAuthenticated:!1}}this.storeCustomer(a);const i=await this.authenticateCustomerId(a.id);return{customer:this.customer||a,isAuthenticated:i}}getCustomer(){return this.customer}async authenticateCustomerId(t){var o;const e=y.getShadowGraphqlClient(),A=k.getMap("customerTokens");if(!(A!=null&&A.has(t)))return!1;const a=A.get(t);if(!a)return!1;const s=(o=(await e.mutate({mutation:Mr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:a}})).data)==null?void 0:o.customerAuthenticate;return s?(this.storeCustomer(s),VA(a),this.customer=s,!0):!1}async generateVerificationCode(t){await y.getShadowGraphqlClient().mutate({mutation:Sr,variables:{emailAddress:t}})}async verifyCode(t,e){var i,s;const a=(i=(await y.getShadowGraphqlClient().mutate({mutation:xr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:t,verificationCode:e}})).data)==null?void 0:i.customerVerifyCode;if(a!=null&&a.loginToken){if(!((s=a.partner)!=null&&s.id))throw new Error(`Unable to find customer: ${t}`);const o=k.getMap("customerTokens")||new Map;return o.set(a.id,a.loginToken),k.setMap("customerTokens",o),this.storeCustomer(a),VA(a.loginToken),this.customer={...a,loginToken:void 0},!0}return!1}async getCustomerMetafields(){var e;if(!((e=this.customer)!=null&&e.id))throw new Error("Customer must be logged in before calling this function.");return(await y.getShadowGraphqlClient().query({query:Yr,variables:{id:this.customer.id}})).data.metafields}async getNewBundle(t,e,A){var c,l,g,d,B;const i=(g=(await y.getShadowGraphqlClient().mutate({mutation:So(((l=(c=A==null?void 0:A.graphql)==null?void 0:c.productCollection)==null?void 0:l.eagerFetchProducts)||!1),variables:{collectionId:t,initialMetadata:e?Object.entries(e).map((h,C)=>({key:h[0],value:h[1]})):void 0,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},fetchPolicy:"no-cache"})).data)==null?void 0:g.bundleCreate;if(!(i!=null&&i.id))throw new Error("Unable to create bundle");const s=k.getMap("bundlePartnerIds")||new Map;s.set(i.id,i.partner.id),k.setMap("bundlePartnerIds",s);const o=k.getMap("bundleOwnerIds")||new Map;o.set(i.id,i.bundleOwnerId),k.setMap("bundleOwnerIds",o);const r=new ze(this,i,void 0,void 0,i.bundleOwnerId,{eagerFetchProducts:(B=(d=A==null?void 0:A.graphql)==null?void 0:d.productCollection)==null?void 0:B.eagerFetchProducts});return await r.getInitializationPromise(),r}async getExistingBundle(t,e,A,a){var u,w,E,m,f,p,I,D,F,x,Y;const i=k.getMap("bundleOwnerIds"),s=i==null?void 0:i.get(t),r=((u=Object.entries(localStorage).find(([P,v])=>P.startsWith("CognitoIdentityServiceProvider")&&P.endsWith("idToken")))==null?void 0:u[0])||"",c=localStorage.getItem(r),l={};c&&!fe(c)&&(l.Authorization=`Bearer ${c}`);const g={bundleOwnerId:s,...l,...(w=a==null?void 0:a.graphql)==null?void 0:w.additionalHeaders},d=await y.getShadowGraphqlClient().query({query:Io(((m=(E=a==null?void 0:a.graphql)==null?void 0:E.productCollection)==null?void 0:m.eagerFetchProducts)||!1),variables:{id:t},fetchPolicy:"no-cache",context:{headers:g}});if(!((f=d.data)!=null&&f.bundles)||((p=d.data)==null?void 0:p.bundles.length)===0||!((I=d.data)!=null&&I.bundles[0]))throw new Error(`Unable to find bundle: ${t}`);const B=(D=d.data)==null?void 0:D.bundles[0],h=k.getMap("bundlePartnerIds")||new Map;h.set(B.id,B.partner.id),k.setMap("bundlePartnerIds",h);const C=new ze(this,B,e,A,s,{additionalHeaders:(F=a==null?void 0:a.graphql)==null?void 0:F.additionalHeaders,eagerFetchProducts:(Y=(x=a==null?void 0:a.graphql)==null?void 0:x.productCollection)==null?void 0:Y.eagerFetchProducts,existingGlobalPropertyState:d.data.globalPropertyState});return await C.getInitializationPromise(),C}async duplicateBundle(t,e,A,a){var u,w,E,m,f,p,I,D;const i=(u=k.getMap("bundleOwnerIds"))==null?void 0:u.get(t),o=((w=Object.entries(localStorage).find(([F,x])=>F.startsWith("CognitoIdentityServiceProvider")&&F.endsWith("idToken")))==null?void 0:w[0])||"",r=localStorage.getItem(o),c={};r&&!fe(r)&&(c.Authorization=`Bearer ${r}`);const l={bundleOwnerId:i,...c,...(E=a==null?void 0:a.graphql)==null?void 0:E.additionalHeaders},d=(p=(await y.getShadowGraphqlClient().mutate({mutation:xo(((f=(m=a==null?void 0:a.graphql)==null?void 0:m.productCollection)==null?void 0:f.eagerFetchProducts)||!1),variables:{id:t,template:e,marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId,duplicateTransactions:A},context:{headers:l},fetchPolicy:"no-cache"})).data)==null?void 0:p.bundleDuplicate;if(!(d!=null&&d.id))throw new Error("Unable to duplicate bundle");const B=k.getMap("bundlePartnerIds")||new Map;B.set(d.id,d.partner.id),k.setMap("bundlePartnerIds",B);const h=k.getMap("bundleOwnerIds")||new Map;h.set(d.id,d.bundleOwnerId),k.setMap("bundleOwnerIds",h);const C=new ze(this,d,void 0,void 0,d.bundleOwnerId,{eagerFetchProducts:(D=(I=a==null?void 0:a.graphql)==null?void 0:I.productCollection)==null?void 0:D.eagerFetchProducts});return await C.getInitializationPromise(),C}async getBundlesForCustomer(t){var i;if(!((i=this.customer)!=null&&i.id))throw new Error("Customer not authenticated.");const{includeMetadata:e,...A}=t;return(await y.getShadowGraphqlClient().query({query:Jo(e??!1),variables:{...A,id:this.customer.id},fetchPolicy:"no-cache"})).data.customerBundlesFeed}async getBundleStakeholders(){var i;if(!this.customer)throw new Error("Customer not authenticated.");const t=await y.getShadowGraphqlClient().query({query:Do,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((i=t.data)!=null&&i.customers)||t.data.customers.length===0)throw new Error("Unable to find customer.");const A=t.data.customers[0].bundleStakeholders||[],a=k.getMap("bundlePartnerIds")||new Map;return A.forEach(s=>{var o,r;(o=s.bundle)!=null&&o.id&&((r=s.bundle.partner)!=null&&r.id)&&a.set(s.bundle.id,s.bundle.partner.id)}),k.setMap("bundlePartnerIds",a),A}async getWorkflowExperience(t,e){if(!t)throw new Error("getWorkflowExperience has been called without an options object! This is not supported.");const A=await this.getWorkflowExperiences([t],t.graphql),a=A[0];return e&&await a.getWorkflowManager().injectIntoPreviewService(e(a.getWorkflowManager().getWorkflow())),A[0]}async getWorkflowExperiences(t,e){if(t.length===0)throw new lt("No options provided!");const A=y.getShadowGraphqlClient(),a=async p=>{var x,Y,P;if(p.length===0)return[];const I=p.map(v=>v.option.transactionId),D=await A.query({query:Gi,variables:{ids:I},errorPolicy:"all",fetchPolicy:"no-cache"}),F=D.data.transactions;if(F.length!==p.length){const v=((Y=(x=D.errors)==null?void 0:x[0])==null?void 0:Y.message)||"Unknown error";throw new lt(`Not all transactions were found: ${v}`)}return!this.activeIntegration&&((P=F[0].integrationProduct)!=null&&P.integration)&&(this.activeIntegration=Promise.resolve(F[0].integrationProduct.integration)),F.map((v,H)=>{var V;return{transaction:v,workflowId:v.workflowId,readOnly:((V=p.find(j=>j.option.transactionId===v.id))==null?void 0:V.option.readOnly)??!1,index:p[H].index}})},i=async p=>{var F,x,Y;if(p.length===0)return[];const I=await A.mutate({mutation:Ui,variables:{inputs:p.map(P=>({integrationProductId:P.option.type==="integration"?P.option.integrationProductId:void 0,externalIntegrationId:P.option.type==="external"?P.option.externalIntegrationId:void 0,externalProductId:P.option.type==="external"?P.option.externalProductId:void 0,workflowId:P.option.workflowId,designName:P.option.designName,claim:!0})),marketplaceThemeInstallId:this.marketplaceThemeInstallId,marketplaceThemeInstallConfigurationId:this.marketplaceThemeInstallConfigurationId},errorPolicy:"all",fetchPolicy:"no-cache"}),D=(F=I.data)==null?void 0:F.transactionCreateMany;if(!D||D.length===0){const P=((Y=(x=I.errors)==null?void 0:x[0])==null?void 0:Y.message)||"Unknown error";throw new lt(`Failed to create transactions: ${P}`)}return D.map((P,v)=>({transaction:P,workflowId:P.workflowId,readOnly:!1,index:p[v].index}))},s=t.map((p,I)=>({option:p,index:I})),o=s.filter(p=>p.option.type==="transaction"),r=s.filter(p=>p.option.type==="integration"||p.option.type==="external"),c=JA(o,10),l=JA(r,10),g=(await Promise.all([...c.map(a),...l.map(i)])).flat(),d=[...new Set(g.map(p=>p.workflowId))],B=await GA(d,e),h=new Map(B.map(p=>[p.id,p])),C=k.getMap("transactionOwnerIds")||new Map,u=g.map(async p=>{var V;const{transaction:I,workflowId:D,readOnly:F,index:x}=p,Y=h.get(D),P=t[x];!C.get(I.id)&&I.transactionOwnerId&&C.set(I.id,I.transactionOwnerId);const v=C.get(I.id)||void 0,H={product:I.product,transaction:I,layouts:[],singleVariantsRenderable:(V=P==null?void 0:P.workflowConfiguration)==null?void 0:V.singleVariantsRenderable,stateMutationFunc:F?async()=>{throw new L("State mutation is forbidden in read only mode!")}:async j=>this.updateTransactionState({...j,context:{transactionOwnerId:v,bundleOwnerId:e==null?void 0:e.bundleOwnerId}}),readOnly:F,workflow:Y,isReloadedTransaction:P.type==="transaction"};if(P.type==="transaction"&&I.workflowState){const j=JSON.parse(I.workflowState);H.layouts=Object.values(j.layouts||{}).map(at=>at.layout),await AA(j),H.reloadedState=j}else if(!F&&P.workflowState){const j=JSON.parse(P.workflowState);H.layouts=Object.values(j.layouts||{}).map(at=>at.layout),await AA(j),H.reloadedState=j}else H.layouts=br(H.transaction,H.workflow);return H.renderableContextService=new Br(H.layouts),H.delayWorkflowStateSync=!0,{experienceOptions:H,index:x,options:P}}),w=await Promise.all(u);k.setMap("transactionOwnerIds",C);const m=w.sort((p,I)=>p.index-I.index).map(async p=>{const{experienceOptions:I,options:D}=p,F=new In(this,I);return await F.getWorkflowManager().getInitializationPromise(),D.type!=="transaction"&&this.customer&&await F.attachCustomerDetails({email:this.customer.emailAddress}),F}),f=await Promise.all(m);return f.forEach(p=>p.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),f}storeCustomer(t){const e=k.getMap("partnerCustomerIds")||new Map;e.set(t.partner.id,t.id),k.setMap("partnerCustomerIds",e)}async getIntegrationProductById(t){var i,s;const a=(i=(await y.getShadowGraphqlClient().query({query:zi,variables:{ids:[t]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProducts;if(!a||a.length===0||!((s=a[0])!=null&&s.id))throw new Error("Integration product not found.");return new rA(a[0])}async getIntegrationProductFromExternalIds(t,e){var s;const i=(s=(await y.getShadowGraphqlClient().query({query:ji,variables:{externalProductId:e,externalIntegrationId:t},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:s.integrationProductFromExternalIds;if(!(i!=null&&i.id))throw new Error("Integration product not found.");return new rA(i)}async getIntegrationProduct(t){return t.type==="integration"?this.getIntegrationProductById(t.integrationProductId):this.getIntegrationProductFromExternalIds(t.externalIntegrationId,t.externalProductId)}async getShareActionsForTransaction(t){const A=(k.getMap("transactionOwnerIds")||new Map).get(t)||void 0,a=await y.getShadowGraphqlClient().query({query:Oi,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:t},context:{transactionOwnerId:A}});if(!a.data.transactions||a.data.transactions.length!==1)throw new Error(`Failed to fetch share actions for transaction: ${t}`);return a.data.transactions[0].transactionShareActions}async placeOrder(t){const e=await y.getShadowGraphqlClient().mutate({mutation:is,variables:{orderItems:t}});if(e.errors)throw new Error(e.errors[0].message);if(!e.data)throw new Error("Failed to create order: No order data in response.");return{id:e.data.orderCreate.id,internalId:e.data.orderCreate.internalId}}}const kn=async n=>(await y.getShadowGraphqlClient().query({query:As,errorPolicy:"all",fetchPolicy:"no-cache",context:{headers:{"x-application-key":n}}})).data.currentIntegration,Hr=async n=>{const e=await y.getShadowGraphqlClient().query({query:Li,errorPolicy:"all",fetchPolicy:"network-only",variables:{id:n}});if(e.data.transactions.length!==0)return e.data.transactions[0]},Ur=async(n,t)=>{var A;return(A=(await y.getShadowGraphqlClient().query({query:es,errorPolicy:"all",variables:{themeConfigurationId:n,themeInstallId:t}})).data)==null?void 0:A.marketplaceThemeInstallConfiguration},Gr=async n=>{var e,A,a;return(a=(A=(e=(await y.getShadowGraphqlClient().query({query:ns,errorPolicy:"all",variables:{id:n}})).data)==null?void 0:e.bundles)==null?void 0:A[0])==null?void 0:a.marketplaceThemeInstallConfiguration},Tr=async n=>{var e,A,a;return(a=(A=(e=(await y.getShadowGraphqlClient().query({query:as,errorPolicy:"all",variables:{id:n}})).data)==null?void 0:e.transactions)==null?void 0:A[0])==null?void 0:a.marketplaceThemeInstallConfiguration};function Nn(n,t,e,A){const a=e.width*n.zoom,i=e.height*n.zoom;if(A){const o=n,r=Math.max(t.width/e.width,t.height/e.height);o.zoom=Math.max(r,n.zoom);const c=e.width*o.zoom,l=e.height*o.zoom;return o.x=Be(n.x,t.width-c,0),o.y=Be(n.y,t.height-l,0),o}const s=n;return s.x=Be(s.x,-a,t.width),s.y=Be(s.y,-i,t.height),s}function Be(n,t,e){return Math.min(Math.max(n,t),e)}class bn{constructor(t,e){this.minZoomScale=[.03],this.maxZoomScale=[20],this._debouncedUpdateFrameOffsets=oa(this.updateFrameOffsets,200),this.targetElements=[],this.onFrameDataChangeListeners=[],this.onZoomChangeListeners=[],this.forceImageCover=t,this.initialZoom=e,this.thresholdSettings={useThreshold:!1,invertThreshold:!1,threshold:128,thresholdSaturation:.5}}connectWorkflowManager(t,e){e&&t.addStepSpecificStorageCallback(async A=>{if(A){const a=A;if(a.currentFrameSources){let i=!1;for(let s=0;s<a.currentFrameSources.length;s++){const o=a.currentFrameSources[s],r=await oe(o),c=this.frameData?this.frameData[s]:void 0;sa(r,c)||(this.frameData||(this.frameData=new Array(a.currentFrameSources.length)),this.frameData[s]=r,i=!0)}i&&(this.onFrameDataChangeListeners.forEach(s=>s(this.frameData)),this.frameData&&this.imageData&&(this.recalculateOffsets(this.imageData),this.updateOffsets(this.offsets),this.recalculateZoomLimits(this.imageData,this.frameData)))}}},e),this.workflowManager=t,this.stepName=e}setTargetElements(t){this.targetElements=t}getFrameData(){return this.frameData}setFrameData(t){if(!t){this.frameData=void 0;return}t.forEach((e,A)=>{const a=Mt.get(e);a&&(this.frameData||(this.frameData=new Array(t.length)),this.frameData[A]=a)})}getImageData(){return this.imageData}getImageSrc(){if(this.imageData){if(this.imageData.svg){const t=Ya(this.imageData.svg,this.imageData.colors||{},!1);return gA(t)}return this.imageData.src}}getOffsets(){return this.offsets}setOffsets(t){this.offsets=t}setZoom(t,e,A,a){if(this.imageData&&this.offsets&&this.frameData){(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length));const i=this.frameData.map((s,o)=>{const r=(e[o]-this.offsets[o].x)/this.offsets[o].zoom,c=(A[o]-this.offsets[o].y)/this.offsets[o].zoom,l=e[o]-r*t[o],g=A[o]-c*t[o];return{x:l,y:g,zoom:this.imageData.width*t[o]/this.imageData.width}});this.updateOffsets(i,a),this.onZoomChangeListeners.forEach(s=>s(t))}}setPatternData(t,e=!0){this.imageData=t,t&&this.frameData&&((e||!this.offsets)&&this.recalculateOffsets(t),this.updateOffsets(this.offsets,void 0,!0)),this.imageData&&this.frameData&&this.recalculateZoomLimits(this.imageData,this.frameData)}updateOffsets(t,e,A){const a=this.imageData;if(!a||!this.frameData)return;if(this.frameData.length!==t.length)throw new L("Frame data and offsets are not the same length. This is a bug. Please report it.");if(!this.offsets.some((s,o)=>!(t[o].x===s.x&&t[o].y===s.y&&t[o].zoom===s.zoom))&&!A){e&&e();return}(!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((s,o)=>{this.offsets[o]=Nn(t[o],s,this.imageData,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,a,this.frameData,this.thresholdSettings,e)}getThresholdSettings(){return this.thresholdSettings}setThresholdSettings(t){this.thresholdSettings=t,this.imageData&&this.frameData&&this._debouncedUpdateFrameOffsets(this.offsets,this.imageData,this.frameData,t)}onFrameDataChanged(t){t(this.frameData),this.onFrameDataChangeListeners.push(t)}onZoom(t){this.onZoomChangeListeners.push(t)}updateFrameOffsets(t,e,A,a,i){if(!A||A.length===0||A.some(o=>!o))throw new L("Frame data not set. This is a bug");if(!this.workflowManager)throw new L("No workflow manager set, cannot update offsets.");const s=this.workflowManager.getCommandDispatcher();this.targetElements.forEach((o,r)=>{s(new G([new Ls(o,e,t[r]),new Os(o,a.useThreshold,a.invertThreshold,a.threshold,a.thresholdSaturation)]))}),this.stepName&&this.workflowManager.updateStorage(this.stepName,{frameOffsetsList:t}),i&&i()}recalculateZoomLimits(t,e){(this.minZoomScale.length!==e.length||this.maxZoomScale.length!==e.length)&&(this.minZoomScale=new Array(e.length),this.maxZoomScale=new Array(e.length)),e.forEach((A,a)=>{const i=Math.max(A.width/t.width,A.height/t.height);this.forceImageCover?(this.minZoomScale[a]=i,this.maxZoomScale[a]=i*2.5):(this.minZoomScale[a]=i/10,this.maxZoomScale[a]=i*2.5)})}recalculateOffsets(t){this.frameData&&((!this.offsets||this.offsets.length!==this.frameData.length)&&(this.offsets=new Array(this.frameData.length)),this.frameData.forEach((e,A)=>{this.offsets[A]=pA(t,e,this.initialZoom&&!this.forceImageCover?{scale:this.initialZoom}:void 0,this.forceImageCover)}),this._debouncedUpdateFrameOffsets(this.offsets,t,this.frameData,this.thresholdSettings))}}class Jr{approveTransaction(t){throw new Error("Method not implemented.")}rejectTransaction(t){throw new Error("Method not implemented.")}getClient(){return this.client??{}}getWorkflowExperience(){return{}}setClient(t){this.client=t}getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(t){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(t){}addPoller(t){}addConfirmCallback(t){}addEditedCallback(t){}addElementsCallback(t){}addInformationResultCallback(t){}addInitCallback(t){}addMakingAdjustmentsCallback(t){}addMandatoryCallback(t){}addMetadataCallback(t){}addSelectionCallback(t){}addStepSpecificStorageCallback(t,e){}addStorageCallback(t){}getCommandDispatcher(){return t=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(t){return[]}getSerializedStep(t,e){}getStepSpecificServices(t){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(t){}markUpdateCompleted(t){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}getStepSelections(){return{}}setCurrentAdjustingStepId(t){}setEditedStatus(t,e){}setInformationResults(t){}setMandatoryFulfilled(t,e){}async setSelectionsAndElements(t,e,A){}toggleDesignConfirmed(){}updateMetadata(t,e){}async updateStorage(t,e){}injectIntoPreviewService(t){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(t){}async updateTransactionShareActions(){}addValidationCallback(t){}setStepError(t,e,A){}getStepErrors(t){}getValidationErrors(){return{steps:new Map}}async updateTransactionStakeholders(){}getStepTags(t){return[]}}var Rn=(n=>(n.SelectFrame="SelectFrame",n.SelectImage="SelectImage",n.Position="Position",n))(Rn||{});class Hn extends At{constructor(t,e,A){super(t,e,A);const a=e.data;this.frameService=new bn(a.forceImageCover,a.initialZoomLevel),this.frameService.connectWorkflowManager(t,e.stepName)}selectVariant(t){const e=this.manager.getRegionElements(this.step.stepName);return rt.selectVariant(this.step,t.getResource(),e,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(t){this.frameService&&this.frameService.onFrameDataChanged(e=>{e&&t(e)})}async selectImage(t,e=!0,A=!0){var a;if(await rt.selectImage(this.step,t,this.manager,A),e){const i=((a=this.manager.getStepStorage(this.step.stepName))==null?void 0:a.framePatternData)||{};this.manager.updateStorage(this.step.stepName,{framePatternData:{...i,originalAssetKey:t.key,backgroundRemovedAssetKey:void 0,useOriginalAsset:void 0}})}}async canUseBackgroundRemover(){return this.manager.getClient().canUseAddon(Qe.BackgroundRemover)}async canRemoveBackground(){var t,e,A,a;return await this.canUseBackgroundRemover()&&this.hasOriginalImageSelection()&&!!((e=(t=this.frameService)==null?void 0:t.getImageData())!=null&&e.src)&&!((a=(A=this.frameService)==null?void 0:A.getImageData())!=null&&a.svg)}async removeBackgroundFromImageSelection(t=!0){var i;if(!await this.canUseBackgroundRemover())throw new Error("The current Integration does not have access to the Background Remover. Please call canUseBackgroundRemover to ensure you disable this feature when appropriate.");const e=await this.getOriginalImageSelection();if(!e)throw new Error("You must supply an image selection before attempting to remove the background.");const A=await T.removeBackgroundFromAsset(e);t&&await rt.selectImage(this.step,A,this.manager,!1);const a=((i=this.manager.getStepStorage(this.step.stepName))==null?void 0:i.framePatternData)||{};return this.manager.updateStorage(this.step.stepName,{framePatternData:{...a,backgroundRemovedAssetKey:A.key,useOriginalAsset:!t}}),A}changeColors(t){rt.changeColors(this.step,this.manager,t)}getImageData(){if(this.frameService)return this.frameService.getImageData()}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?rt.availableColors(this.step,this.manager):Promise.resolve([])}isColorPickerEnabled(){return this.step.data.colorPickerEnabled??!1}async getOriginalImageColors(){const t=this.getImageData();return t!=null&&t.svg?(await st(t.svg)).colors:void 0}getMaxAllowedColors(){return this.step.data.maxColors}getUniqueColorCount(){return rt.getUniqueColorCount(this.step,this.manager)}getCurrentFrameStep(t,e,A,a){return a&&a.length>1&&t===void 0?"SelectFrame":e||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}getWhitelistedExtensions(){return[...this.step.data.whitelistedExtensions,...this.step.data.whitelistedExtensions.includes(".jpg")?[".jpeg"]:[]]}async getOriginalImageSelection(){var e,A;const t=(A=(e=this.manager.getStepStorage(this.step.stepName))==null?void 0:e.framePatternData)==null?void 0:A.originalAssetKey;if(t)return T.getLocalOrFromServer(t)}async getBackgroundRemovedImageSelection(){var e,A;const t=(A=(e=this.manager.getStepStorage(this.step.stepName))==null?void 0:e.framePatternData)==null?void 0:A.backgroundRemovedAssetKey;if(t)return T.getLocalOrFromServer(t)}hasOriginalImageSelection(){var t,e;return!!((e=(t=this.manager.getStepStorage(this.step.stepName))==null?void 0:t.framePatternData)!=null&&e.originalAssetKey)}hasBackgroundRemovedImageSelection(){var t,e;return!!((e=(t=this.getFrameStepStorage())==null?void 0:t.framePatternData)!=null&&e.backgroundRemovedAssetKey)}getUseOriginalImageSelection(){var t,e;return((e=(t=this.getFrameStepStorage())==null?void 0:t.framePatternData)==null?void 0:e.useOriginalAsset)??!1}async setUseOriginalImageSelection(t){var a;const e=((a=this.getFrameStepStorage())==null?void 0:a.framePatternData)||{};if(e.useOriginalAsset===t)return;const A=await this.getOriginalImageSelection();if(!A)throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");if(t)await this.selectImage(A,!1,!1);else{const i=await this.getBackgroundRemovedImageSelection();if(!i)throw new Error("You must call removeBackgroundFromImageSelection before attempting to apply the image.");await this.selectImage(i,!1,!1)}this.manager.updateStorage(this.step.stepName,{framePatternData:{...e,useOriginalAsset:t}})}getFrameStepStorage(){return this.manager.getStepStorage(this.step.stepName)}}const Lr=Q.gql`
3388
3388
  query GetLoggedInCustomer($email: String!) {
3389
3389
  customer(emailAddress: $email) {
3390
3390
  id
@@ -3500,5 +3500,5 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
3500
3500
  total
3501
3501
  }
3502
3502
  }
3503
- `,qr=async(n,t,e)=>await y.getShadowGraphqlClient().mutate({mutation:Kr,errorPolicy:"all",variables:{id:n,name:t},context:e}),Zr=async(n,t)=>await y.getShadowGraphqlClient().mutate({mutation:Or,errorPolicy:"all",variables:{id:n,name:t}}),$r=async(n,t)=>await y.getShadowGraphqlClient().mutate({mutation:Wr,errorPolicy:"all",variables:{id:n,template:t}}),_r=async(n,t)=>await y.getShadowGraphqlClient().mutate({mutation:zr,errorPolicy:"all",variables:{id:n,template:t}}),tc=async n=>(await y.getShadowGraphqlClient().query({query:Lr,errorPolicy:"all",variables:{email:n}})).data.customer,ec=async(n,t,e)=>await y.getShadowGraphqlClient().query({query:jr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,offset:e,limit:t}}),Ac=async(n,t)=>await y.getShadowGraphqlClient().query({query:Vr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n},context:t}),ac=async(n,t,e)=>{var a;const A=await y.getShadowGraphqlClient().query({query:TA,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,quicksearch:"",filters:{link:"and",status:{operator:"isAnyOf",values:["Created","DesignCompleted","ExternallyOrdered"]},template:{value:"false"}},offset:e,limit:t}});return((a=A==null?void 0:A.data.customerTransactionsFeed)==null?void 0:a.items)||[]},nc=async(n,t,e)=>{var a;const A=await y.getShadowGraphqlClient().query({query:TA,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,quicksearch:"",filters:{link:"and",status:{operator:"equals",value:"Ordered"},template:{value:"false"}},offset:e,limit:t}});return((a=A==null?void 0:A.data.customerTransactionsFeed)==null?void 0:a.items)||[]},ic=async(n,t,e)=>{var a;const A=await y.getShadowGraphqlClient().query({query:TA,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,quicksearch:"",filters:{link:"and",template:{value:"true"}},offset:e,limit:t}});return((a=A==null?void 0:A.data.customerTransactionsFeed)==null?void 0:a.items)||[]},sc=async(n,t,e)=>{var a;const A=await y.getShadowGraphqlClient().query({query:Xr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,offset:e,limit:t}});return((a=A==null?void 0:A.data.customerBundlesFeed)==null?void 0:a.items)||[]};exports.AddonHandle=Qe;exports.ArrayInput=yr;exports.AspectType=nt;exports.AssetNotFoundError=Bt;exports.AssetType=Kt;exports.BringForwardCommand=Ws;exports.BringToBackCommand=Ks;exports.BringToFrontCommand=Vs;exports.CanvasCommand=U;exports.CollectionProduct=Ot;exports.ColorOptionGlobalPropertyHandle=oA;exports.CommandContext=Oa;exports.ConversionDataType=Ba;exports.ConversionLocation=da;exports.CreateElementCommand=z;exports.CreateLayoutCommand=DA;exports.DeleteElementCommand=ut;exports.DigitalContentStepHandle=un;exports.FileUploadGlobalPropertyHandle=yn;exports.FlowExecutionNodeResult=zt;exports.FlowExecutionResult=Pn;exports.FlowService=Yn;exports.FontAlignmentCommand=qa;exports.FontColorCommand=Wa;exports.FontSizeCommand=Xa;exports.FontSourceCommand=aA;exports.FrameService=bn;exports.FrameStep=Rn;exports.FrameStepHandle=Hn;exports.GlobalPropertyHandle=Pe;exports.GroupCommand=G;exports.IllustrationStepHandle=rn;exports.InformationMessageType=re;exports.InformationStepHandle=Cn;exports.IntegrationProduct=rA;exports.IntegrationType=la;exports.LayoutElementFactory=Us;exports.LayoutElementType=N;exports.LayoutNotFoundError=X;exports.LayoutRenderingPurpose=Pt;exports.MaterialStepHandle=cn;exports.MisconfigurationError=qt;exports.MockWorkflowManager=Jr;exports.ModelStepHandle=ln;exports.ModuleStepHandle=wn;exports.MoveCommand=Gs;exports.ObjectInput=UA;exports.ObjectInputType=vn;exports.OptionGlobalPropertyHandle=RA;exports.OptionNotFoundError=Xt;exports.ParseError=mt;exports.PictureStepHandle=gn;exports.ProductCameraRig=ga;exports.ProductCollection=Mn;exports.ProductWorkflow=Yt;exports.PromiseCache=bt;exports.PromiseQueue=EA;exports.QuestionStepHandle=dn;exports.QueueablePromise=wA;exports.ResizeCommand=Js;exports.ResourceNotFoundError=vt;exports.RotateCommand=Ts;exports.ScaleAxis=K;exports.SendBackwardsCommand=Xs;exports.ShapeStepHandle=Bn;exports.ShareActionType=ca;exports.SpiffCommerceClient=Rr;exports.StakeholderType=Wt;exports.StepAspectType=ra;exports.StepHandle=et;exports.StepType=M;exports.TextAlgorithm=pt;exports.TextChangeCommand=Za;exports.TextGlobalPropertyHandle=Fn;exports.TextInput=Dr;exports.TextStepHandle=hn;exports.Transform=xn;exports.TransformCollection=Sn;exports.UnhandledBehaviorError=L;exports.UnitOfMeasurement=ha;exports.UpdateImageSourceCommand=zs;exports.Variant=at;exports.WorkflowExperienceEventType=pn;exports.WorkflowExperienceImpl=In;exports.assetService=T;exports.browserColorToHex=ya;exports.cmPerPixel=ps;exports.createDesign=Qn;exports.currentDirection=ms;exports.dataUrlFromExternalUrl=ti;exports.designService=Ce;exports.determineCorrectFontSizeAndLines=Vt;exports.digitalContentStepService=yA;exports.domParser=it;exports.duplicateBundle=$r;exports.duplicateTransaction=_r;exports.fetchAsString=_;exports.findAngle=ds;exports.findElement=J;exports.findPmsColors=wi;exports.frameDataCache=Mt;exports.frameStepService=rt;exports.generate=b;exports.generateCommands=Dn;exports.generateSVGWithUnknownColors=st;exports.generateStateFromDesignInputSteps=mr;exports.getAttributesFromArrayBuffer=ae;exports.getAxisAlignedBoundingBox=gs;exports.getBoundedOffsets=Nn;exports.getBundleThemeConfiguration=Gr;exports.getCustomer=tc;exports.getCustomerBundles=ec;exports.getElementVertices=fs;exports.getFrameData=oe;exports.getIntegration=kn;exports.getNEPoint=ws;exports.getNWPoint=us;exports.getOrderedTransactions=nc;exports.getOverrideThemeConfiguration=Ur;exports.getPointOfRotation=Cs;exports.getSEPoint=Es;exports.getSvgElement=Se;exports.getTemplateBundles=sc;exports.getTemplateTransactions=ic;exports.getTransaction=Hr;exports.getTransactionThemeConfiguration=Tr;exports.getTransactionsForBundle=Ac;exports.getTrueCoordinates=hs;exports.getUnorderedTransactions=ac;exports.getWorkflow=kr;exports.getWorkflows=GA;exports.graphQlManager=y;exports.illustrationStepService=jt;exports.isCloseToValue=Bs;exports.loadFont=It;exports.matchHexToPms=hi;exports.materialStepService=FA;exports.mmPerPixel=Qs;exports.modelStepService=MA;exports.moduleStepService=SA;exports.nameBundle=qr;exports.nameTransaction=Zr;exports.optionService=$;exports.outlineFontsInSvg=Fs;exports.patternImageDataCache=ct;exports.persistenceService=k;exports.pictureStepService=xA;exports.pmsToRgb=Bi;exports.questionStepService=YA;exports.registerFetchImplementation=Xn;exports.registerWindowImplementation=Wn;exports.rehydrateSerializedLayout=AA;exports.rgbToPms=Da;exports.rotateAroundPoint=Lt;exports.sanitizeSvgTree=ye;exports.setBearerAuthenticationToken=pa;exports.setCanvasModule=BA;exports.shapeStepService=St;exports.shortenUrl=$a;exports.spiffCoreConfiguration=dt;exports.stepAspectValuesToDesignInputSteps=Er;exports.svgColorValueToDefinition=Ze;exports.svgStringDimensions=IA;exports.svgToDataUrl=gA;exports.textStepService=W;exports.toast=tn;exports.xmlSerializer=wt;
3503
+ `,qr=async(n,t,e)=>await y.getShadowGraphqlClient().mutate({mutation:Kr,errorPolicy:"all",variables:{id:n,name:t},context:e}),Zr=async(n,t)=>await y.getShadowGraphqlClient().mutate({mutation:Or,errorPolicy:"all",variables:{id:n,name:t}}),$r=async(n,t)=>await y.getShadowGraphqlClient().mutate({mutation:Wr,errorPolicy:"all",variables:{id:n,template:t}}),_r=async(n,t)=>await y.getShadowGraphqlClient().mutate({mutation:zr,errorPolicy:"all",variables:{id:n,template:t}}),tc=async n=>(await y.getShadowGraphqlClient().query({query:Lr,errorPolicy:"all",variables:{email:n}})).data.customer,ec=async(n,t,e)=>await y.getShadowGraphqlClient().query({query:jr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,offset:e,limit:t}}),Ac=async(n,t)=>await y.getShadowGraphqlClient().query({query:Vr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n},context:t}),ac=async(n,t,e)=>{var a;const A=await y.getShadowGraphqlClient().query({query:TA,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,quicksearch:"",filters:{link:"and",status:{operator:"isAnyOf",values:["Created","DesignCompleted","ExternallyOrdered"]},template:{value:"false"}},offset:e,limit:t}});return((a=A==null?void 0:A.data.customerTransactionsFeed)==null?void 0:a.items)||[]},nc=async(n,t,e)=>{var a;const A=await y.getShadowGraphqlClient().query({query:TA,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,quicksearch:"",filters:{link:"and",status:{operator:"equals",value:"Ordered"},template:{value:"false"}},offset:e,limit:t}});return((a=A==null?void 0:A.data.customerTransactionsFeed)==null?void 0:a.items)||[]},ic=async(n,t,e)=>{var a;const A=await y.getShadowGraphqlClient().query({query:TA,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,quicksearch:"",filters:{link:"and",template:{value:"true"}},offset:e,limit:t}});return((a=A==null?void 0:A.data.customerTransactionsFeed)==null?void 0:a.items)||[]},sc=async(n,t,e)=>{var a;const A=await y.getShadowGraphqlClient().query({query:Xr,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:n,offset:e,limit:t}});return((a=A==null?void 0:A.data.customerBundlesFeed)==null?void 0:a.items)||[]};exports.AddonHandle=Qe;exports.ArrayInput=yr;exports.AspectType=et;exports.AssetNotFoundError=Bt;exports.AssetType=Kt;exports.BringForwardCommand=Ws;exports.BringToBackCommand=Ks;exports.BringToFrontCommand=Vs;exports.CanvasCommand=U;exports.CollectionProduct=Ot;exports.ColorOptionGlobalPropertyHandle=oA;exports.CommandContext=Oa;exports.ConversionDataType=Ba;exports.ConversionLocation=da;exports.CreateElementCommand=z;exports.CreateLayoutCommand=DA;exports.DeleteElementCommand=ut;exports.DigitalContentStepHandle=un;exports.FileUploadGlobalPropertyHandle=yn;exports.FlowExecutionNodeResult=zt;exports.FlowExecutionResult=Pn;exports.FlowService=Yn;exports.FontAlignmentCommand=qa;exports.FontColorCommand=Wa;exports.FontSizeCommand=Xa;exports.FontSourceCommand=aA;exports.FrameService=bn;exports.FrameStep=Rn;exports.FrameStepHandle=Hn;exports.GlobalPropertyHandle=Pe;exports.GroupCommand=G;exports.IllustrationStepHandle=rn;exports.InformationMessageType=re;exports.InformationStepHandle=Cn;exports.IntegrationProduct=rA;exports.IntegrationType=la;exports.LayoutElementFactory=Us;exports.LayoutElementType=N;exports.LayoutNotFoundError=X;exports.LayoutRenderingPurpose=Pt;exports.MaterialStepHandle=cn;exports.MisconfigurationError=qt;exports.MockWorkflowManager=Jr;exports.ModelStepHandle=ln;exports.ModuleStepHandle=wn;exports.MoveCommand=Gs;exports.ObjectInput=UA;exports.ObjectInputType=vn;exports.OptionGlobalPropertyHandle=RA;exports.OptionNotFoundError=Xt;exports.ParseError=mt;exports.PictureStepHandle=gn;exports.ProductCameraRig=ga;exports.ProductCollection=Mn;exports.ProductWorkflow=Yt;exports.PromiseCache=bt;exports.PromiseQueue=EA;exports.QuestionStepHandle=dn;exports.QueueablePromise=wA;exports.ResizeCommand=Js;exports.ResourceNotFoundError=vt;exports.RotateCommand=Ts;exports.ScaleAxis=K;exports.SendBackwardsCommand=Xs;exports.ShapeStepHandle=Bn;exports.ShareActionType=ca;exports.SpiffCommerceClient=Rr;exports.StakeholderType=Wt;exports.StepAspectType=ra;exports.StepHandle=At;exports.StepType=M;exports.TextAlgorithm=pt;exports.TextChangeCommand=Za;exports.TextGlobalPropertyHandle=Fn;exports.TextInput=Dr;exports.TextStepHandle=hn;exports.Transform=xn;exports.TransformCollection=Sn;exports.UnhandledBehaviorError=L;exports.UnitOfMeasurement=ha;exports.UpdateImageSourceCommand=zs;exports.Variant=nt;exports.WorkflowExperienceEventType=pn;exports.WorkflowExperienceImpl=In;exports.assetService=T;exports.browserColorToHex=ya;exports.cmPerPixel=ps;exports.createDesign=Qn;exports.currentDirection=ms;exports.dataUrlFromExternalUrl=ti;exports.designService=Ce;exports.determineCorrectFontSizeAndLines=Vt;exports.digitalContentStepService=yA;exports.domParser=it;exports.duplicateBundle=$r;exports.duplicateTransaction=_r;exports.fetchAsString=_;exports.findAngle=ds;exports.findElement=J;exports.findPmsColors=wi;exports.frameDataCache=Mt;exports.frameStepService=rt;exports.generate=b;exports.generateCommands=Dn;exports.generateSVGWithUnknownColors=st;exports.generateStateFromDesignInputSteps=mr;exports.getAttributesFromArrayBuffer=ae;exports.getAxisAlignedBoundingBox=gs;exports.getBoundedOffsets=Nn;exports.getBundleThemeConfiguration=Gr;exports.getCustomer=tc;exports.getCustomerBundles=ec;exports.getElementVertices=fs;exports.getFrameData=oe;exports.getIntegration=kn;exports.getNEPoint=ws;exports.getNWPoint=us;exports.getOrderedTransactions=nc;exports.getOverrideThemeConfiguration=Ur;exports.getPointOfRotation=Cs;exports.getSEPoint=Es;exports.getSvgElement=Se;exports.getTemplateBundles=sc;exports.getTemplateTransactions=ic;exports.getTransaction=Hr;exports.getTransactionThemeConfiguration=Tr;exports.getTransactionsForBundle=Ac;exports.getTrueCoordinates=hs;exports.getUnorderedTransactions=ac;exports.getWorkflow=kr;exports.getWorkflows=GA;exports.graphQlManager=y;exports.illustrationStepService=jt;exports.isCloseToValue=Bs;exports.loadFont=It;exports.matchHexToPms=hi;exports.materialStepService=FA;exports.mmPerPixel=Qs;exports.modelStepService=MA;exports.moduleStepService=SA;exports.nameBundle=qr;exports.nameTransaction=Zr;exports.optionService=$;exports.outlineFontsInSvg=Fs;exports.patternImageDataCache=ct;exports.persistenceService=k;exports.pictureStepService=xA;exports.pmsToRgb=Bi;exports.questionStepService=YA;exports.registerFetchImplementation=Xn;exports.registerWindowImplementation=Wn;exports.rehydrateSerializedLayout=AA;exports.rgbToPms=Da;exports.rotateAroundPoint=Lt;exports.sanitizeSvgTree=ye;exports.setBearerAuthenticationToken=pa;exports.setCanvasModule=BA;exports.shapeStepService=St;exports.shortenUrl=$a;exports.spiffCoreConfiguration=dt;exports.stepAspectValuesToDesignInputSteps=Er;exports.svgColorValueToDefinition=Ze;exports.svgStringDimensions=IA;exports.svgToDataUrl=gA;exports.textStepService=W;exports.toast=tn;exports.xmlSerializer=wt;
3504
3504
  //# sourceMappingURL=index.js.map